auto-skeleton-react 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,15 @@
1
- import { jsx as p, jsxs as ge } from "react/jsx-runtime";
2
- import { useMemo as fe, useRef as ye, useState as Se, useLayoutEffect as oe } from "react";
3
- function de(e) {
1
+ import { jsx as p, jsxs as Ae } from "react/jsx-runtime";
2
+ import { useMemo as Re, useRef as Ce, useState as Te, useLayoutEffect as me } from "react";
3
+ function xe(e) {
4
4
  var r;
5
- return e ? (r = e.hasAttribute) != null && r.call(e, "data-no-skeleton") ? !0 : de(e.parentElement) : !1;
5
+ return e ? (r = e.hasAttribute) != null && r.call(e, "data-no-skeleton") ? !0 : xe(e.parentElement) : !1;
6
6
  }
7
- function ce(e, r, i = 0) {
7
+ function ve(e, r, i = 0) {
8
8
  if (i > r.maxDepth) return null;
9
- if (de(e)) {
9
+ if (xe(e)) {
10
10
  const c = e.getBoundingClientRect(), l = window.getComputedStyle(e), o = {};
11
- for (const u of e.attributes)
12
- o[u.name] = u.value;
11
+ for (const f of e.attributes)
12
+ o[f.name] = f.value;
13
13
  return {
14
14
  rect: c,
15
15
  style: l,
@@ -23,34 +23,34 @@ function ce(e, r, i = 0) {
23
23
  }
24
24
  for (const c of r.ignoreSelectors)
25
25
  if (e.matches(c)) return null;
26
- const t = e.getBoundingClientRect(), s = window.getComputedStyle(e), y = e.tagName === "IMG", n = y ? e : null, S = n == null ? void 0 : n.getAttribute("src"), m = (n == null ? void 0 : n.src) || "", f = (n == null ? void 0 : n.naturalWidth) === 0 || (n == null ? void 0 : n.naturalHeight) === 0, a = !S || S === "", w = m === window.location.href || m.endsWith("/"), R = y && (a || w || f);
26
+ const t = e.getBoundingClientRect(), s = window.getComputedStyle(e), y = e.tagName === "IMG", n = y ? e : null, S = n == null ? void 0 : n.getAttribute("src"), m = (n == null ? void 0 : n.src) || "", u = (n == null ? void 0 : n.naturalWidth) === 0 || (n == null ? void 0 : n.naturalHeight) === 0, a = !S || S === "", w = m === window.location.href || m.endsWith("/"), R = y && (a || w || u);
27
27
  let v = t;
28
28
  if (R && n) {
29
29
  let c = 0, l = 0;
30
- const o = e.parentElement, u = o ? window.getComputedStyle(o) : null;
31
- let x = 0;
30
+ const o = e.parentElement, f = o ? window.getComputedStyle(o) : null;
31
+ let b = 0;
32
32
  if (o) {
33
- const d = o.getBoundingClientRect(), H = parseFloat((u == null ? void 0 : u.paddingLeft) || "0"), L = parseFloat((u == null ? void 0 : u.paddingRight) || "0");
34
- x = d.width - H - L;
33
+ const d = o.getBoundingClientRect(), H = parseFloat((f == null ? void 0 : f.paddingLeft) || "0"), B = parseFloat((f == null ? void 0 : f.paddingRight) || "0");
34
+ b = d.width - H - B;
35
35
  }
36
- const b = n.style.width, C = n.style.height;
37
- if (C && !C.includes("%")) {
38
- const d = parseFloat(C);
36
+ const x = n.style.width, T = n.style.height;
37
+ if (T && !T.includes("%")) {
38
+ const d = parseFloat(T);
39
39
  !isNaN(d) && d > 0 && (l = d);
40
40
  }
41
41
  if (l === 0) {
42
42
  const d = parseFloat(s.height);
43
43
  !isNaN(d) && d > 50 && (l = d);
44
44
  }
45
- if (b)
46
- if (b.includes("%")) {
47
- const d = parseFloat(b) / 100;
48
- !isNaN(d) && x > 0 && (c = x * d);
45
+ if (x)
46
+ if (x.includes("%")) {
47
+ const d = parseFloat(x) / 100;
48
+ !isNaN(d) && b > 0 && (c = b * d);
49
49
  } else {
50
- const d = parseFloat(b);
50
+ const d = parseFloat(x);
51
51
  !isNaN(d) && d > 0 && (c = d);
52
52
  }
53
- if (c === 0 && x > 0 && (c = x), c === 0) {
53
+ if (c === 0 && b > 0 && (c = b), c === 0) {
54
54
  const d = n.getAttribute("width");
55
55
  d && (c = parseFloat(d));
56
56
  }
@@ -78,7 +78,7 @@ function ce(e, r, i = 0) {
78
78
  const A = [];
79
79
  for (const c of e.children)
80
80
  if (c instanceof HTMLElement) {
81
- const l = ce(c, r, i + 1);
81
+ const l = ve(c, r, i + 1);
82
82
  l && A.push(l);
83
83
  }
84
84
  return {
@@ -90,19 +90,19 @@ function ce(e, r, i = 0) {
90
90
  children: A
91
91
  };
92
92
  }
93
- const he = ["TABLE", "THEAD", "TBODY", "TFOOT", "TR"], pe = ["TH", "TD"];
94
- function me(e) {
93
+ const be = ["TABLE", "THEAD", "TBODY", "TFOOT", "TR"], we = ["TH", "TD"];
94
+ function Ne(e) {
95
95
  var S, m;
96
96
  const { tagName: r, textContent: i, children: t, style: s, rect: y } = e;
97
- if (y.width * y.height < 100 || he.includes(r) || pe.includes(r)) return !1;
97
+ if (y.width * y.height < 100 || be.includes(r) || we.includes(r)) return !1;
98
98
  if (r.match(/^(IMG|BUTTON|INPUT|TEXTAREA|SELECT|SVG)$/) || i != null && i.trim() && t.length === 0) return !0;
99
99
  if (t.length === 1 && (i != null && i.trim())) {
100
- const f = t[0];
101
- if ((S = f.textContent) != null && S.trim() && f.children.length === 0) return !0;
100
+ const u = t[0];
101
+ if ((S = u.textContent) != null && S.trim() && u.children.length === 0) return !0;
102
102
  }
103
103
  return t.length > 1 || (m = s.display) != null && m.match(/flex|grid/) ? !1 : t.length === 0;
104
104
  }
105
- function B(e, r) {
105
+ function L(e, r) {
106
106
  var c;
107
107
  if (e.passthrough)
108
108
  return {
@@ -121,8 +121,8 @@ function B(e, r) {
121
121
  const l = m;
122
122
  let o = 1;
123
123
  if (l === "text") {
124
- const u = parseFloat(t.lineHeight), x = parseFloat(t.fontSize), b = u || x * 1.2;
125
- b > 0 && i.height > b && (o = Math.ceil(i.height / b));
124
+ const f = parseFloat(t.lineHeight), b = parseFloat(t.fontSize), x = f || b * 1.2;
125
+ x > 0 && i.height > x && (o = Math.ceil(i.height / x));
126
126
  }
127
127
  return {
128
128
  type: l,
@@ -152,8 +152,8 @@ function B(e, r) {
152
152
  }
153
153
  };
154
154
  }
155
- if (he.includes(s)) {
156
- const l = S.map((o) => B(o, r)).filter((o) => o.type !== "skip");
155
+ if (be.includes(s)) {
156
+ const l = S.map((o) => L(o, r)).filter((o) => o.type !== "skip");
157
157
  return {
158
158
  type: s.toLowerCase(),
159
159
  tagName: s,
@@ -177,8 +177,8 @@ function B(e, r) {
177
177
  }
178
178
  };
179
179
  }
180
- if (pe.includes(s)) {
181
- const l = S.map((o) => B(o, r)).filter((o) => o.type !== "skip");
180
+ if (we.includes(s)) {
181
+ const l = S.map((o) => L(o, r)).filter((o) => o.type !== "skip");
182
182
  return {
183
183
  type: s.toLowerCase(),
184
184
  tagName: s,
@@ -202,8 +202,8 @@ function B(e, r) {
202
202
  }
203
203
  };
204
204
  }
205
- if (!me(e)) {
206
- const l = S.map((o) => B(o, r)).filter((o) => o.type !== "skip");
205
+ if (!Ne(e)) {
206
+ const l = S.map((o) => L(o, r)).filter((o) => o.type !== "skip");
207
207
  return {
208
208
  type: "container",
209
209
  rect: {
@@ -222,16 +222,25 @@ function B(e, r) {
222
222
  padding: t.padding,
223
223
  border: t.border,
224
224
  boxSizing: t.boxSizing,
225
+ flex: t.flex,
226
+ flexGrow: t.flexGrow,
227
+ flexShrink: t.flexShrink,
228
+ flexBasis: t.flexBasis,
229
+ alignSelf: t.alignSelf,
230
+ justifySelf: t.justifySelf,
225
231
  justifyContent: t.justifyContent,
226
232
  alignItems: t.alignItems,
227
233
  flexDirection: t.flexDirection,
228
234
  minHeight: t.minHeight,
229
235
  gridTemplateColumns: t.gridTemplateColumns,
230
- gridTemplateRows: t.gridTemplateRows
236
+ gridTemplateRows: t.gridTemplateRows,
237
+ gridColumn: t.gridColumn,
238
+ gridRow: t.gridRow,
239
+ gridArea: t.gridArea
231
240
  }
232
241
  };
233
242
  }
234
- const f = i.width * i.height, a = {
243
+ const u = i.width * i.height, a = {
235
244
  text: 0,
236
245
  image: 0,
237
246
  icon: 0,
@@ -242,16 +251,16 @@ function B(e, r) {
242
251
  };
243
252
  y && y.trim().length > 0 && (a.text += 40), i.height < r.minTextHeight * 3 && i.height >= r.minTextHeight && (a.text += 30), s.match(/^(P|SPAN|H[1-6]|LABEL|A|DIV)$/) && (a.text += 20);
244
253
  const w = parseFloat(t.fontSize);
245
- w > 0 && w < 100 && (a.text += 20), s === "IMG" && (a.image += 100), n.role === "img" && (a.image += 60), t.backgroundImage !== "none" && (a.image += 50), f > r.minImageSize ** 2 && (a.image += 30), s === "SVG" && (a.icon += 70);
254
+ w > 0 && w < 100 && (a.text += 20), s === "IMG" && (a.image += 100), n.role === "img" && (a.image += 60), t.backgroundImage !== "none" && (a.image += 50), u > r.minImageSize ** 2 && (a.image += 30), s === "SVG" && (a.icon += 70);
246
255
  const R = i.width / i.height;
247
- f < r.iconMaxSize ** 2 && R > 0.8 && R < 1.2 && (a.icon += 40), s === "BUTTON" && (a.button += 80), n.role === "button" && (a.button += 60), t.cursor === "pointer" && f < 2e4 && (a.button += 30), s.match(/^(INPUT|TEXTAREA|SELECT)$/) && (a.input += 80), n.contenteditable && (a.input += 50), S.length > 1 && (a.container += 50), (c = t.display) != null && c.match(/flex|grid/) && (a.container += 30), f < 100 && (a.skip += 50), (i.height < 5 || i.width < 5) && (a.skip += 40);
256
+ u < r.iconMaxSize ** 2 && R > 0.8 && R < 1.2 && (a.icon += 40), s === "BUTTON" && (a.button += 80), n.role === "button" && (a.button += 60), t.cursor === "pointer" && u < 2e4 && (a.button += 30), s.match(/^(INPUT|TEXTAREA|SELECT)$/) && (a.input += 80), n.contenteditable && (a.input += 50), S.length > 1 && (a.container += 50), (c = t.display) != null && c.match(/flex|grid/) && (a.container += 30), u < 100 && (a.skip += 50), (i.height < 5 || i.width < 5) && (a.skip += 40);
248
257
  const v = Object.entries(a).filter(
249
258
  ([l]) => l !== "container"
250
259
  ).reduce((l, o) => o[1] > l[1] ? o : l), k = v[1] > 30 ? v[0] : "text";
251
260
  let A = 1;
252
261
  if (k === "text") {
253
- const l = parseFloat(t.lineHeight), o = parseFloat(t.fontSize), u = l || o * 1.2;
254
- u > 0 && i.height > u && (A = Math.ceil(i.height / u));
262
+ const l = parseFloat(t.lineHeight), o = parseFloat(t.fontSize), f = l || o * 1.2;
263
+ f > 0 && i.height > f && (A = Math.ceil(i.height / f));
255
264
  }
256
265
  return {
257
266
  type: k,
@@ -281,16 +290,16 @@ function B(e, r) {
281
290
  }
282
291
  };
283
292
  }
284
- function be({
293
+ function He({
285
294
  blueprint: e,
286
295
  baseColor: r,
287
296
  highlightColor: i,
288
297
  animation: t
289
298
  }) {
290
- return T(e, r, i, t);
299
+ return C(e, r, i, t);
291
300
  }
292
- function T(e, r, i, t, s) {
293
- var a, w, R, v, k, A, c, l, o, u, x, b, C, d, H, L, I, z, G, E, j, D, M, O, W, _, P, U, V, $, J, X, q, Y, K, Q, Z, ee, te, ie, re, se, le, ne, ae;
301
+ function C(e, r, i, t, s) {
302
+ var a, w, R, v, k, A, c, l, o, f, b, x, T, d, H, B, F, I, z, j, E, D, M, O, W, _, P, U, V, $, J, X, q, Y, K, Q, Z, ee, te, ie, re, se, le, ne, ae, oe, de, ce, he, pe, fe, ge, ue, ye, Se;
294
303
  if (e.type === "passthrough")
295
304
  return e.passthroughHtml ? /* @__PURE__ */ p(
296
305
  "div",
@@ -311,34 +320,34 @@ function T(e, r, i, t, s) {
311
320
  tableLayout: (R = e.preservedStyles) == null ? void 0 : R.tableLayout
312
321
  },
313
322
  children: (v = e.children) == null ? void 0 : v.map(
314
- (h, g) => T(h, r, i, t, g)
323
+ (h, g) => C(h, r, i, t, g)
315
324
  )
316
325
  },
317
326
  s
318
327
  );
319
328
  if (e.type === "thead")
320
329
  return /* @__PURE__ */ p("thead", { children: (k = e.children) == null ? void 0 : k.map(
321
- (h, g) => T(h, r, i, t, g)
330
+ (h, g) => C(h, r, i, t, g)
322
331
  ) }, s);
323
332
  if (e.type === "tbody")
324
333
  return /* @__PURE__ */ p("tbody", { children: (A = e.children) == null ? void 0 : A.map(
325
- (h, g) => T(h, r, i, t, g)
334
+ (h, g) => C(h, r, i, t, g)
326
335
  ) }, s);
327
336
  if (e.type === "tr")
328
337
  return /* @__PURE__ */ p("tr", { children: (c = e.children) == null ? void 0 : c.map(
329
- (h, g) => T(h, r, i, t, g)
338
+ (h, g) => C(h, r, i, t, g)
330
339
  ) }, s);
331
340
  if (e.type === "th" || e.type === "td") {
332
341
  const h = e.type, g = {
333
342
  padding: (l = e.preservedStyles) == null ? void 0 : l.padding,
334
343
  borderBottom: (o = e.preservedStyles) == null ? void 0 : o.borderBottom,
335
- backgroundColor: (u = e.preservedStyles) == null ? void 0 : u.backgroundColor,
336
- textAlign: (x = e.preservedStyles) == null ? void 0 : x.textAlign,
337
- verticalAlign: (b = e.preservedStyles) == null ? void 0 : b.verticalAlign,
338
- width: (C = e.preservedStyles) == null ? void 0 : C.width
344
+ backgroundColor: (f = e.preservedStyles) == null ? void 0 : f.backgroundColor,
345
+ textAlign: (b = e.preservedStyles) == null ? void 0 : b.textAlign,
346
+ verticalAlign: (x = e.preservedStyles) == null ? void 0 : x.verticalAlign,
347
+ width: (T = e.preservedStyles) == null ? void 0 : T.width
339
348
  };
340
349
  return e.children && e.children.length > 0 ? /* @__PURE__ */ p(h, { style: g, children: e.children.map(
341
- (N, ue) => T(N, r, i, t, ue)
350
+ (N, ke) => C(N, r, i, t, ke)
342
351
  ) }, s) : /* @__PURE__ */ p(h, { style: g, children: /* @__PURE__ */ p("div", { style: {
343
352
  width: "80%",
344
353
  height: 16,
@@ -359,20 +368,30 @@ function T(e, r, i, t, s) {
359
368
  // Don't set fixed height - let container size naturally from children
360
369
  // This avoids issues with incorrect height measurement from alt text
361
370
  boxSizing: "border-box",
362
- padding: (H = e.preservedStyles) == null ? void 0 : H.padding,
363
- border: g ? (L = e.preservedStyles) == null ? void 0 : L.border : void 0,
371
+ margin: (H = e.preservedStyles) == null ? void 0 : H.margin,
372
+ padding: (B = e.preservedStyles) == null ? void 0 : B.padding,
373
+ border: g ? (F = e.preservedStyles) == null ? void 0 : F.border : void 0,
364
374
  borderRadius: e.borderRadius,
365
- justifyContent: (I = e.preservedStyles) == null ? void 0 : I.justifyContent,
366
- alignItems: (z = e.preservedStyles) == null ? void 0 : z.alignItems,
367
- flexDirection: (G = e.preservedStyles) == null ? void 0 : G.flexDirection,
368
- minHeight: (E = e.preservedStyles) == null ? void 0 : E.minHeight,
375
+ flex: (I = e.preservedStyles) == null ? void 0 : I.flex,
376
+ flexGrow: (z = e.preservedStyles) != null && z.flexGrow ? Number(e.preservedStyles.flexGrow) : void 0,
377
+ flexShrink: (j = e.preservedStyles) != null && j.flexShrink ? Number(e.preservedStyles.flexShrink) : void 0,
378
+ flexBasis: (E = e.preservedStyles) == null ? void 0 : E.flexBasis,
379
+ alignSelf: (D = e.preservedStyles) == null ? void 0 : D.alignSelf,
380
+ justifySelf: (M = e.preservedStyles) == null ? void 0 : M.justifySelf,
381
+ justifyContent: (O = e.preservedStyles) == null ? void 0 : O.justifyContent,
382
+ alignItems: (W = e.preservedStyles) == null ? void 0 : W.alignItems,
383
+ flexDirection: (_ = e.preservedStyles) == null ? void 0 : _.flexDirection,
384
+ minHeight: (P = e.preservedStyles) == null ? void 0 : P.minHeight,
369
385
  // Preserve measured grid template so responsive breakpoints (e.g. md:grid-cols-*)
370
386
  // are kept exactly during skeleton rendering.
371
- gridTemplateColumns: (j = e.preservedStyles) == null ? void 0 : j.gridTemplateColumns,
372
- gridTemplateRows: (D = e.preservedStyles) == null ? void 0 : D.gridTemplateRows
387
+ gridTemplateColumns: (U = e.preservedStyles) == null ? void 0 : U.gridTemplateColumns,
388
+ gridTemplateRows: (V = e.preservedStyles) == null ? void 0 : V.gridTemplateRows,
389
+ gridColumn: ($ = e.preservedStyles) == null ? void 0 : $.gridColumn,
390
+ gridRow: (J = e.preservedStyles) == null ? void 0 : J.gridRow,
391
+ gridArea: (X = e.preservedStyles) == null ? void 0 : X.gridArea
373
392
  },
374
393
  children: e.children.map(
375
- (F, N) => T(F, r, i, t, N)
394
+ (G, N) => C(G, r, i, t, N)
376
395
  )
377
396
  },
378
397
  s
@@ -386,7 +405,7 @@ function T(e, r, i, t, s) {
386
405
  backgroundColor: r,
387
406
  display: "block",
388
407
  boxSizing: "border-box",
389
- margin: (M = e.preservedStyles) == null ? void 0 : M.margin
408
+ margin: (q = e.preservedStyles) == null ? void 0 : q.margin
390
409
  };
391
410
  return t === "pulse" && (h.animation = "skeleton-pulse 2s ease-in-out infinite"), /* @__PURE__ */ p("div", { style: h, className: "skeleton-image" }, s);
392
411
  }
@@ -399,50 +418,50 @@ function T(e, r, i, t, s) {
399
418
  minHeight: e.rect.height,
400
419
  boxSizing: "border-box",
401
420
  // Preserve flex-item properties
402
- margin: (O = e.preservedStyles) == null ? void 0 : O.margin,
403
- flex: (W = e.preservedStyles) == null ? void 0 : W.flex,
404
- flexGrow: (_ = e.preservedStyles) != null && _.flexGrow ? Number(e.preservedStyles.flexGrow) : void 0,
421
+ margin: (Y = e.preservedStyles) == null ? void 0 : Y.margin,
422
+ flex: (K = e.preservedStyles) == null ? void 0 : K.flex,
423
+ flexGrow: (Q = e.preservedStyles) != null && Q.flexGrow ? Number(e.preservedStyles.flexGrow) : void 0,
405
424
  flexShrink: 0,
406
425
  // Prevent flex compression
407
- flexBasis: (P = e.preservedStyles) == null ? void 0 : P.flexBasis,
408
- alignSelf: (U = e.preservedStyles) == null ? void 0 : U.alignSelf,
409
- justifySelf: (V = e.preservedStyles) == null ? void 0 : V.justifySelf,
426
+ flexBasis: (Z = e.preservedStyles) == null ? void 0 : Z.flexBasis,
427
+ alignSelf: (ee = e.preservedStyles) == null ? void 0 : ee.alignSelf,
428
+ justifySelf: (te = e.preservedStyles) == null ? void 0 : te.justifySelf,
410
429
  // Grid properties
411
- gridColumn: ($ = e.preservedStyles) == null ? void 0 : $.gridColumn,
412
- gridRow: (J = e.preservedStyles) == null ? void 0 : J.gridRow,
413
- gridArea: (X = e.preservedStyles) == null ? void 0 : X.gridArea,
430
+ gridColumn: (ie = e.preservedStyles) == null ? void 0 : ie.gridColumn,
431
+ gridRow: (re = e.preservedStyles) == null ? void 0 : re.gridRow,
432
+ gridArea: (se = e.preservedStyles) == null ? void 0 : se.gridArea,
414
433
  // Visual
415
434
  borderRadius: e.borderRadius,
416
435
  backgroundColor: r,
417
436
  // Preserve inline nature
418
437
  display: "inline-block",
419
- verticalAlign: ((q = e.preservedStyles) == null ? void 0 : q.verticalAlign) || "middle"
438
+ verticalAlign: ((le = e.preservedStyles) == null ? void 0 : le.verticalAlign) || "middle"
420
439
  };
421
440
  return t === "pulse" && (h.animation = "skeleton-pulse 2s ease-in-out infinite"), /* @__PURE__ */ p("div", { style: h, className: `skeleton-${e.type}` }, s);
422
441
  }
423
442
  const n = {
424
443
  // Only margin for spacing between siblings
425
- margin: (Y = e.preservedStyles) == null ? void 0 : Y.margin,
444
+ margin: (ne = e.preservedStyles) == null ? void 0 : ne.margin,
426
445
  // Flex-item properties
427
- flex: (K = e.preservedStyles) == null ? void 0 : K.flex,
428
- flexGrow: (Q = e.preservedStyles) != null && Q.flexGrow ? Number(e.preservedStyles.flexGrow) : void 0,
429
- flexShrink: (Z = e.preservedStyles) != null && Z.flexShrink ? Number(e.preservedStyles.flexShrink) : void 0,
430
- flexBasis: (ee = e.preservedStyles) == null ? void 0 : ee.flexBasis,
431
- alignSelf: (te = e.preservedStyles) == null ? void 0 : te.alignSelf,
446
+ flex: (ae = e.preservedStyles) == null ? void 0 : ae.flex,
447
+ flexGrow: (oe = e.preservedStyles) != null && oe.flexGrow ? Number(e.preservedStyles.flexGrow) : void 0,
448
+ flexShrink: (de = e.preservedStyles) != null && de.flexShrink ? Number(e.preservedStyles.flexShrink) : void 0,
449
+ flexBasis: (ce = e.preservedStyles) == null ? void 0 : ce.flexBasis,
450
+ alignSelf: (he = e.preservedStyles) == null ? void 0 : he.alignSelf,
432
451
  // Grid-item properties
433
- gridColumn: (ie = e.preservedStyles) == null ? void 0 : ie.gridColumn,
434
- gridRow: (re = e.preservedStyles) == null ? void 0 : re.gridRow,
435
- gridArea: (se = e.preservedStyles) == null ? void 0 : se.gridArea
436
- }, S = ((le = e.preservedStyles) == null ? void 0 : le.display) === "inline" ? "inline-block" : "block", m = {
452
+ gridColumn: (pe = e.preservedStyles) == null ? void 0 : pe.gridColumn,
453
+ gridRow: (fe = e.preservedStyles) == null ? void 0 : fe.gridRow,
454
+ gridArea: (ge = e.preservedStyles) == null ? void 0 : ge.gridArea
455
+ }, S = ((ue = e.preservedStyles) == null ? void 0 : ue.display) === "inline" ? "inline-block" : "block", m = {
437
456
  width: e.rect.width,
438
457
  height: e.rect.height,
439
458
  borderRadius: e.borderRadius,
440
459
  backgroundColor: r,
441
460
  display: S,
442
- verticalAlign: ((ne = e.preservedStyles) == null ? void 0 : ne.verticalAlign) || "middle"
461
+ verticalAlign: ((ye = e.preservedStyles) == null ? void 0 : ye.verticalAlign) || "middle"
443
462
  };
444
463
  if (t === "pulse" && (m.animation = "skeleton-pulse 2s ease-in-out infinite"), e.type === "text" && e.lines && e.lines > 1) {
445
- const h = parseFloat(((ae = e.preservedStyles) == null ? void 0 : ae.lineHeight) || "1.2"), g = e.rect.height / e.lines;
464
+ const h = parseFloat(((Se = e.preservedStyles) == null ? void 0 : Se.lineHeight) || "1.2"), g = e.rect.height / e.lines;
446
465
  return /* @__PURE__ */ p(
447
466
  "div",
448
467
  {
@@ -452,7 +471,7 @@ function T(e, r, i, t, s) {
452
471
  flexDirection: "column",
453
472
  gap: h > g ? h - g : 4
454
473
  },
455
- children: Array.from({ length: e.lines }).map((F, N) => /* @__PURE__ */ p(
474
+ children: Array.from({ length: e.lines }).map((G, N) => /* @__PURE__ */ p(
456
475
  "div",
457
476
  {
458
477
  style: {
@@ -469,10 +488,10 @@ function T(e, r, i, t, s) {
469
488
  s
470
489
  );
471
490
  }
472
- const f = `skeleton-${e.type}`;
473
- return /* @__PURE__ */ p("div", { style: n, children: /* @__PURE__ */ p("div", { style: m, className: f }) }, s);
491
+ const u = `skeleton-${e.type}`;
492
+ return /* @__PURE__ */ p("div", { style: n, children: /* @__PURE__ */ p("div", { style: m, className: u }) }, s);
474
493
  }
475
- const ve = {
494
+ const Be = {
476
495
  animation: "pulse",
477
496
  baseColor: "#e0e0e0",
478
497
  highlightColor: "#f5f5f5",
@@ -483,38 +502,38 @@ const ve = {
483
502
  maxDepth: 10,
484
503
  ignoreSelectors: [".no-skeleton", "[data-skeleton-ignore]"]
485
504
  };
486
- function ke({
505
+ function Fe({
487
506
  loading: e,
488
507
  children: r,
489
508
  config: i
490
509
  }) {
491
- const t = fe(
492
- () => ({ ...ve, ...i }),
510
+ const t = Re(
511
+ () => ({ ...Be, ...i }),
493
512
  [i]
494
- ), s = ye(null), [y, n] = Se(null);
495
- return oe(() => {
513
+ ), s = Ce(null), [y, n] = Te(null);
514
+ return me(() => {
496
515
  if (!e || !s.current)
497
516
  return;
498
- const f = requestAnimationFrame(() => {
517
+ const u = requestAnimationFrame(() => {
499
518
  if (s.current)
500
519
  try {
501
- const a = ce(s.current, t);
520
+ const a = ve(s.current, t);
502
521
  if (a) {
503
- const w = B(a, t);
522
+ const w = L(a, t);
504
523
  n(w);
505
524
  }
506
525
  } catch (a) {
507
526
  console.error("AutoSkeleton measurement failed:", a), n(null);
508
527
  }
509
528
  });
510
- return () => cancelAnimationFrame(f);
511
- }, [e, t]), oe(() => {
529
+ return () => cancelAnimationFrame(u);
530
+ }, [e, t]), me(() => {
512
531
  if (e) return;
513
- const f = setTimeout(() => {
532
+ const u = setTimeout(() => {
514
533
  n(null);
515
534
  }, 300);
516
- return () => clearTimeout(f);
517
- }, [e]), /* @__PURE__ */ ge("div", { style: { position: "relative" }, children: [
535
+ return () => clearTimeout(u);
536
+ }, [e]), /* @__PURE__ */ Ae("div", { style: { position: "relative" }, children: [
518
537
  /* @__PURE__ */ p("style", { children: `
519
538
  @keyframes skeleton-pulse {
520
539
  0%, 100% { opacity: 1; }
@@ -545,7 +564,7 @@ function ke({
545
564
  pointerEvents: e ? "auto" : "none"
546
565
  },
547
566
  children: /* @__PURE__ */ p(
548
- be,
567
+ He,
549
568
  {
550
569
  blueprint: y,
551
570
  baseColor: t.baseColor,
@@ -574,5 +593,5 @@ function ke({
574
593
  ] });
575
594
  }
576
595
  export {
577
- ke as AutoSkeleton
596
+ Fe as AutoSkeleton
578
597
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-skeleton-react",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Auto-generate skeleton loading screens from your existing React DOM structure",
5
5
  "type": "module",
6
6
  "main": "dist/auto-skeleton-react.js",
@@ -34,7 +34,7 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/ShanukJ/auto-skeleton/issues"
36
36
  },
37
- "homepage": "https://github.com/ShanukJ/auto-skeleton#readme",
37
+ "homepage": "https://autoskeleton.shanukj.me",
38
38
  "license": "MIT",
39
39
  "peerDependencies": {
40
40
  "react": ">=18.0.0",