@shimmer-from-structure/svelte 1.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -124,7 +124,8 @@ const isLoading = ref(true);
124
124
  ```svelte
125
125
  <script>
126
126
  import { Shimmer } from '@shimmer-from-structure/svelte';
127
- let isLoading = true;
127
+
128
+ let isLoading = $state(true);
128
129
  </script>
129
130
 
130
131
  <Shimmer loading={isLoading}>
@@ -205,8 +206,9 @@ const userTemplate = {
205
206
  import { Shimmer } from '@shimmer-from-structure/svelte';
206
207
  import UserCard from './UserCard.svelte';
207
208
 
208
- export let user;
209
- let loading = true;
209
+ let { user } = $props();
210
+ let loading = $state(true);
211
+
210
212
  const userTemplate = {
211
213
  name: 'Loading...',
212
214
  role: 'Loading role...',
@@ -534,7 +536,9 @@ provideShimmerConfig({
534
536
  <!-- App.svelte or any parent component -->
535
537
  <script>
536
538
  import { setShimmerConfig } from '@shimmer-from-structure/svelte';
539
+ import Dashboard from './Dashboard.svelte';
537
540
 
541
+ // Must be called at the top level during component initialization
538
542
  setShimmerConfig({
539
543
  shimmerColor: 'rgba(56, 189, 248, 0.4)',
540
544
  backgroundColor: 'rgba(56, 189, 248, 0.1)',
package/dist/index.esm.js CHANGED
@@ -1,801 +1,122 @@
1
- var _e = Object.defineProperty;
2
- var ge = (e, t, n) => t in e ? _e(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var G = (e, t, n) => ge(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { setContext as pe, getContext as be, onMount as ye, tick as ke } from "svelte";
5
- import { shimmerDefaults as we, extractElementInfo as ve } from "@shimmer-from-structure/core";
6
- import { shimmerDefaults as ot } from "@shimmer-from-structure/core";
7
- function X() {
8
- }
9
- function Ce(e, t) {
10
- for (const n in t) e[n] = t[n];
11
- return (
12
- /** @type {T & S} */
13
- e
14
- );
15
- }
16
- function ie(e) {
17
- return e();
18
- }
19
- function Z() {
20
- return /* @__PURE__ */ Object.create(null);
21
- }
22
- function O(e) {
23
- e.forEach(ie);
24
- }
25
- function le(e) {
26
- return typeof e == "function";
27
- }
28
- function Re(e, t) {
29
- return e != e ? t == t : e !== t || e && typeof e == "object" || typeof e == "function";
30
- }
31
- function Ee(e) {
32
- return Object.keys(e).length === 0;
33
- }
34
- function Y(e, t, n, r) {
35
- if (e) {
36
- const o = se(e, t, n, r);
37
- return e[0](o);
38
- }
39
- }
40
- function se(e, t, n, r) {
41
- return e[1] && r ? Ce(n.ctx.slice(), e[1](r(t))) : n.ctx;
42
- }
43
- function q(e, t, n, r) {
44
- if (e[2] && r) {
45
- const o = e[2](r(n));
46
- if (t.dirty === void 0)
47
- return o;
48
- if (typeof o == "object") {
49
- const l = [], i = Math.max(t.dirty.length, o.length);
50
- for (let a = 0; a < i; a += 1)
51
- l[a] = t.dirty[a] | o[a];
52
- return l;
53
- }
54
- return t.dirty | o;
55
- }
56
- return t.dirty;
57
- }
58
- function z(e, t, n, r, o, l) {
59
- if (o) {
60
- const i = se(t, n, r, l);
61
- e.p(i, o);
62
- }
63
- }
64
- function J(e) {
65
- if (e.ctx.length > 32) {
66
- const t = [], n = e.ctx.length / 32;
67
- for (let r = 0; r < n; r++)
68
- t[r] = -1;
69
- return t;
70
- }
71
- return -1;
72
- }
73
- function N(e, t) {
74
- e.appendChild(t);
75
- }
76
- function xe(e, t, n) {
77
- const r = Be(e);
78
- if (!r.getElementById(t)) {
79
- const o = P("style");
80
- o.id = t, o.textContent = n, Se(r, o);
81
- }
82
- }
83
- function Be(e) {
84
- if (!e) return document;
85
- const t = e.getRootNode ? e.getRootNode() : e.ownerDocument;
86
- return t && /** @type {ShadowRoot} */
87
- t.host ? (
88
- /** @type {ShadowRoot} */
89
- t
90
- ) : e.ownerDocument;
91
- }
92
- function Se(e, t) {
93
- return N(
94
- /** @type {Document} */
95
- e.head || e,
96
- t
97
- ), t.sheet;
98
- }
99
- function Q(e, t, n) {
100
- e.insertBefore(t, n || null);
101
- }
102
- function T(e) {
103
- e.parentNode && e.parentNode.removeChild(e);
104
- }
105
- function P(e) {
106
- return document.createElement(e);
107
- }
108
- function ue(e) {
109
- return document.createTextNode(e);
110
- }
111
- function fe() {
112
- return ue(" ");
113
- }
114
- function Me() {
115
- return ue("");
116
- }
117
- function $(e, t, n) {
118
- n == null ? e.removeAttribute(t) : e.getAttribute(t) !== n && e.setAttribute(t, n);
119
- }
120
- function Ne(e) {
121
- return Array.from(e.childNodes);
122
- }
123
- function f(e, t, n, r) {
124
- n == null ? e.style.removeProperty(t) : e.style.setProperty(t, n, "");
125
- }
126
- let W;
127
- function D(e) {
128
- W = e;
129
- }
130
- const M = [], K = [];
131
- let I = [];
132
- const ee = [], Pe = /* @__PURE__ */ Promise.resolve();
133
- let U = !1;
134
- function Ie() {
135
- U || (U = !0, Pe.then(ce));
136
- }
137
- function V(e) {
138
- I.push(e);
139
- }
140
- const H = /* @__PURE__ */ new Set();
141
- let S = 0;
142
- function ce() {
143
- if (S !== 0)
144
- return;
145
- const e = W;
146
- do {
147
- try {
148
- for (; S < M.length; ) {
149
- const t = M[S];
150
- S++, D(t), Oe(t.$$);
151
- }
152
- } catch (t) {
153
- throw M.length = 0, S = 0, t;
154
- }
155
- for (D(null), M.length = 0, S = 0; K.length; ) K.pop()();
156
- for (let t = 0; t < I.length; t += 1) {
157
- const n = I[t];
158
- H.has(n) || (H.add(n), n());
159
- }
160
- I.length = 0;
161
- } while (M.length);
162
- for (; ee.length; )
163
- ee.pop()();
164
- U = !1, H.clear(), D(e);
165
- }
166
- function Oe(e) {
167
- if (e.fragment !== null) {
168
- e.update(), O(e.before_update);
169
- const t = e.dirty;
170
- e.dirty = [-1], e.fragment && e.fragment.p(e.ctx, t), e.after_update.forEach(V);
171
- }
172
- }
173
- function De(e) {
174
- const t = [], n = [];
175
- I.forEach((r) => e.indexOf(r) === -1 ? t.push(r) : n.push(r)), n.forEach((r) => r()), I = t;
176
- }
177
- const L = /* @__PURE__ */ new Set();
178
- let x;
179
- function ae() {
180
- x = {
181
- r: 0,
182
- c: [],
183
- p: x
184
- // parent group
185
- };
186
- }
187
- function de() {
188
- x.r || O(x.c), x = x.p;
189
- }
190
- function R(e, t) {
191
- e && e.i && (L.delete(e), e.i(t));
192
- }
193
- function B(e, t, n, r) {
194
- if (e && e.o) {
195
- if (L.has(e)) return;
196
- L.add(e), x.c.push(() => {
197
- L.delete(e), r && (n && e.d(1), r());
198
- }), e.o(t);
199
- } else r && r();
200
- }
201
- function te(e) {
202
- return (e == null ? void 0 : e.length) !== void 0 ? e : Array.from(e);
203
- }
204
- function Ae(e, t) {
205
- e.d(1), t.delete(e.key);
206
- }
207
- function je(e, t, n, r, o, l, i, a, c, u, y, m) {
208
- let p = e.length, b = l.length, k = p;
209
- const s = {};
210
- for (; k--; ) s[e[k].key] = k;
211
- const h = [], _ = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), w = [];
212
- for (k = b; k--; ) {
213
- const g = m(o, l, k), v = n(g);
214
- let C = i.get(v);
215
- C ? w.push(() => C.p(g, t)) : (C = u(v, g), C.c()), _.set(v, h[k] = C), v in s && E.set(v, Math.abs(k - s[v]));
216
- }
217
- const A = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Set();
218
- function d(g) {
219
- R(g, 1), g.m(a, y), i.set(g.key, g), y = g.first, b--;
220
- }
221
- for (; p && b; ) {
222
- const g = h[b - 1], v = e[p - 1], C = g.key, F = v.key;
223
- g === v ? (y = g.first, p--, b--) : _.has(F) ? !i.has(C) || A.has(C) ? d(g) : j.has(F) ? p-- : E.get(C) > E.get(F) ? (j.add(C), d(g)) : (A.add(F), p--) : (c(v, i), p--);
224
- }
225
- for (; p--; ) {
226
- const g = e[p];
227
- _.has(g.key) || c(g, i);
228
- }
229
- for (; b; ) d(h[b - 1]);
230
- return O(w), h;
231
- }
232
- function Fe(e, t, n) {
233
- const { fragment: r, after_update: o } = e.$$;
234
- r && r.m(t, n), V(() => {
235
- const l = e.$$.on_mount.map(ie).filter(le);
236
- e.$$.on_destroy ? e.$$.on_destroy.push(...l) : O(l), e.$$.on_mount = [];
237
- }), o.forEach(V);
238
- }
239
- function Le(e, t) {
240
- const n = e.$$;
241
- n.fragment !== null && (De(n.after_update), O(n.on_destroy), n.fragment && n.fragment.d(t), n.on_destroy = n.fragment = null, n.ctx = []);
242
- }
243
- function Te(e, t) {
244
- e.$$.dirty[0] === -1 && (M.push(e), Ie(), e.$$.dirty.fill(0)), e.$$.dirty[t / 31 | 0] |= 1 << t % 31;
245
- }
246
- function Ge(e, t, n, r, o, l, i = null, a = [-1]) {
247
- const c = W;
248
- D(e);
249
- const u = e.$$ = {
250
- fragment: null,
251
- ctx: [],
252
- // state
253
- props: l,
254
- update: X,
255
- not_equal: o,
256
- bound: Z(),
257
- // lifecycle
258
- on_mount: [],
259
- on_destroy: [],
260
- on_disconnect: [],
261
- before_update: [],
262
- after_update: [],
263
- context: new Map(t.context || (c ? c.$$.context : [])),
264
- // everything else
265
- callbacks: Z(),
266
- dirty: a,
267
- skip_bound: !1,
268
- root: t.target || c.$$.root
269
- };
270
- i && i(u.root);
271
- let y = !1;
272
- if (u.ctx = n ? n(e, t.props || {}, (m, p, ...b) => {
273
- const k = b.length ? b[0] : p;
274
- return u.ctx && o(u.ctx[m], u.ctx[m] = k) && (!u.skip_bound && u.bound[m] && u.bound[m](k), y && Te(e, m)), p;
275
- }) : [], u.update(), y = !0, O(u.before_update), u.fragment = r ? r(u.ctx) : !1, t.target) {
276
- if (t.hydrate) {
277
- const m = Ne(t.target);
278
- u.fragment && u.fragment.l(m), m.forEach(T);
279
- } else
280
- u.fragment && u.fragment.c();
281
- t.intro && R(e.$$.fragment), Fe(e, t.target, t.anchor), ce();
282
- }
283
- D(c);
284
- }
285
- class He {
286
- constructor() {
287
- /**
288
- * ### PRIVATE API
289
- *
290
- * Do not use, may change at any time
291
- *
292
- * @type {any}
293
- */
294
- G(this, "$$");
295
- /**
296
- * ### PRIVATE API
297
- *
298
- * Do not use, may change at any time
299
- *
300
- * @type {any}
301
- */
302
- G(this, "$$set");
303
- }
304
- /** @returns {void} */
305
- $destroy() {
306
- Le(this, 1), this.$destroy = X;
307
- }
308
- /**
309
- * @template {Extract<keyof Events, string>} K
310
- * @param {K} type
311
- * @param {((e: Events[K]) => void) | null | undefined} callback
312
- * @returns {() => void}
313
- */
314
- $on(t, n) {
315
- if (!le(n))
316
- return X;
317
- const r = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
318
- return r.push(n), () => {
319
- const o = r.indexOf(n);
320
- o !== -1 && r.splice(o, 1);
321
- };
322
- }
323
- /**
324
- * @param {Partial<Props>} props
325
- * @returns {void}
326
- */
327
- $set(t) {
328
- this.$$set && !Ee(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
329
- }
330
- }
331
- const Xe = "4";
332
- typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(Xe);
333
- const me = Symbol("SHIMMER_CONFIG");
334
- function he() {
335
- return be(me) || we;
336
- }
337
- function et(e = {}) {
338
- const t = he(), n = {
339
- shimmerColor: e.shimmerColor ?? t.shimmerColor,
340
- backgroundColor: e.backgroundColor ?? t.backgroundColor,
341
- duration: e.duration ?? t.duration,
342
- fallbackBorderRadius: e.fallbackBorderRadius ?? t.fallbackBorderRadius
1
+ import "svelte/internal/disclose-version";
2
+ import * as e from "svelte/internal/client";
3
+ import { getContext as G, setContext as H, onMount as L, tick as N } from "svelte";
4
+ import { shimmerDefaults as X, extractElementInfo as A } from "@shimmer-from-structure/core";
5
+ import { shimmerDefaults as V } from "@shimmer-from-structure/core";
6
+ const b = Symbol("SHIMMER_CONFIG");
7
+ function C() {
8
+ return G(b) || X;
9
+ }
10
+ function J(a = {}) {
11
+ const t = C(), d = {
12
+ shimmerColor: a.shimmerColor ?? t.shimmerColor,
13
+ backgroundColor: a.backgroundColor ?? t.backgroundColor,
14
+ duration: a.duration ?? t.duration,
15
+ fallbackBorderRadius: a.fallbackBorderRadius ?? t.fallbackBorderRadius
343
16
  };
344
- pe(me, n);
345
- }
346
- function Ke(e) {
347
- xe(e, "svelte-17yl4xt", ".shimmer-measure-container.svelte-17yl4xt *{color:transparent !important}.shimmer-measure-container.svelte-17yl4xt img,.shimmer-measure-container.svelte-17yl4xt svg,.shimmer-measure-container.svelte-17yl4xt video{opacity:0}@keyframes svelte-17yl4xt-shimmer-animation{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}");
348
- }
349
- function ne(e, t, n) {
350
- const r = e.slice();
351
- return r[19] = t[n], r[21] = n, r;
352
- }
353
- const Ue = (e) => ({
354
- shimmerTemplateProps: e & /*templateProps*/
355
- 2
356
- }), re = (e) => ({
357
- shimmerTemplateProps: (
358
- /*templateProps*/
359
- e[1]
360
- )
361
- });
362
- function Ve(e) {
363
- let t, n, r, o, l, i, a = [], c = /* @__PURE__ */ new Map(), u;
364
- const y = [ze, qe], m = [];
365
- function p(s, h) {
366
- return (
367
- /*templateProps*/
368
- s[1] ? 0 : 1
369
- );
370
- }
371
- r = p(e), o = m[r] = y[r](e);
372
- let b = te(
373
- /*elements*/
374
- e[3]
375
- );
376
- const k = (s) => (
377
- /*index*/
378
- s[21]
379
- );
380
- for (let s = 0; s < b.length; s += 1) {
381
- let h = ne(e, b, s), _ = k(h);
382
- c.set(_, a[s] = oe(_, h));
383
- }
384
- return {
385
- c() {
386
- t = P("div"), n = P("div"), o.c(), l = fe(), i = P("div");
387
- for (let s = 0; s < a.length; s += 1)
388
- a[s].c();
389
- $(n, "class", "shimmer-measure-container svelte-17yl4xt"), f(n, "pointer-events", "none"), $(n, "aria-hidden", "true"), f(i, "position", "absolute"), f(i, "top", "0"), f(i, "left", "0"), f(i, "right", "0"), f(i, "bottom", "0"), f(i, "overflow", "hidden"), f(i, "pointer-events", "none"), f(t, "position", "relative");
390
- },
391
- m(s, h) {
392
- Q(s, t, h), N(t, n), m[r].m(n, null), e[15](n), N(t, l), N(t, i);
393
- for (let _ = 0; _ < a.length; _ += 1)
394
- a[_] && a[_].m(i, null);
395
- u = !0;
396
- },
397
- p(s, h) {
398
- let _ = r;
399
- r = p(s), r === _ ? m[r].p(s, h) : (ae(), B(m[_], 1, 1, () => {
400
- m[_] = null;
401
- }), de(), o = m[r], o ? o.p(s, h) : (o = m[r] = y[r](s), o.c()), R(o, 1), o.m(n, null)), h & /*elements, resolvedBackgroundColor, resolvedFallbackBorderRadius, resolvedShimmerColor, resolvedDuration*/
402
- 248 && (b = te(
403
- /*elements*/
404
- s[3]
405
- ), a = je(a, h, k, 1, s, b, c, i, Ae, oe, null, ne));
406
- },
407
- i(s) {
408
- u || (R(o), u = !0);
409
- },
410
- o(s) {
411
- B(o), u = !1;
412
- },
413
- d(s) {
414
- s && T(t), m[r].d(), e[15](null);
415
- for (let h = 0; h < a.length; h += 1)
416
- a[h].d();
17
+ H(b, d);
18
+ }
19
+ var K = e.from_html('<div class="svelte-euvo5u"><div class="svelte-euvo5u"></div></div>'), P = e.from_html(`<div style="position: relative;" class="svelte-euvo5u"><div class="shimmer-measure-container svelte-euvo5u" style="pointer-events: none;" aria-hidden="true"><!></div> <div style="
20
+ position: absolute;
21
+ top: 0;
22
+ left: 0;
23
+ right: 0;
24
+ bottom: 0;
25
+ overflow: hidden;
26
+ pointer-events: none;
27
+ " class="svelte-euvo5u"></div></div>`);
28
+ const Y = {
29
+ hash: "svelte-euvo5u",
30
+ code: `.shimmer-measure-container.svelte-euvo5u * {color:transparent !important;}.shimmer-measure-container.svelte-euvo5u img,
31
+ .shimmer-measure-container.svelte-euvo5u svg,
32
+ .shimmer-measure-container.svelte-euvo5u video {opacity:0;}
33
+ @keyframes svelte-euvo5u-shimmer-animation {
34
+ 0% {
35
+ transform: translateX(-100%);
417
36
  }
418
- };
419
- }
420
- function Ye(e) {
421
- let t;
422
- const n = (
423
- /*#slots*/
424
- e[14].default
425
- ), r = Y(
426
- n,
427
- e,
428
- /*$$scope*/
429
- e[13],
430
- null
431
- );
432
- return {
433
- c() {
434
- r && r.c();
435
- },
436
- m(o, l) {
437
- r && r.m(o, l), t = !0;
438
- },
439
- p(o, l) {
440
- r && r.p && (!t || l & /*$$scope*/
441
- 8192) && z(
442
- r,
443
- n,
444
- o,
445
- /*$$scope*/
446
- o[13],
447
- t ? q(
448
- n,
449
- /*$$scope*/
450
- o[13],
451
- l,
452
- null
453
- ) : J(
454
- /*$$scope*/
455
- o[13]
456
- ),
457
- null
458
- );
459
- },
460
- i(o) {
461
- t || (R(r, o), t = !0);
462
- },
463
- o(o) {
464
- B(r, o), t = !1;
465
- },
466
- d(o) {
467
- r && r.d(o);
468
- }
469
- };
470
- }
471
- function qe(e) {
472
- let t;
473
- const n = (
474
- /*#slots*/
475
- e[14].default
476
- ), r = Y(
477
- n,
478
- e,
479
- /*$$scope*/
480
- e[13],
481
- null
482
- );
483
- return {
484
- c() {
485
- r && r.c();
486
- },
487
- m(o, l) {
488
- r && r.m(o, l), t = !0;
489
- },
490
- p(o, l) {
491
- r && r.p && (!t || l & /*$$scope*/
492
- 8192) && z(
493
- r,
494
- n,
495
- o,
496
- /*$$scope*/
497
- o[13],
498
- t ? q(
499
- n,
500
- /*$$scope*/
501
- o[13],
502
- l,
503
- null
504
- ) : J(
505
- /*$$scope*/
506
- o[13]
507
- ),
508
- null
509
- );
510
- },
511
- i(o) {
512
- t || (R(r, o), t = !0);
513
- },
514
- o(o) {
515
- B(r, o), t = !1;
516
- },
517
- d(o) {
518
- r && r.d(o);
519
- }
520
- };
521
- }
522
- function ze(e) {
523
- let t;
524
- const n = (
525
- /*#slots*/
526
- e[14].default
527
- ), r = Y(
528
- n,
529
- e,
530
- /*$$scope*/
531
- e[13],
532
- re
533
- );
534
- return {
535
- c() {
536
- r && r.c();
537
- },
538
- m(o, l) {
539
- r && r.m(o, l), t = !0;
540
- },
541
- p(o, l) {
542
- r && r.p && (!t || l & /*$$scope, templateProps*/
543
- 8194) && z(
544
- r,
545
- n,
546
- o,
547
- /*$$scope*/
548
- o[13],
549
- t ? q(
550
- n,
551
- /*$$scope*/
552
- o[13],
553
- l,
554
- Ue
555
- ) : J(
556
- /*$$scope*/
557
- o[13]
558
- ),
559
- re
560
- );
561
- },
562
- i(o) {
563
- t || (R(r, o), t = !0);
564
- },
565
- o(o) {
566
- B(r, o), t = !1;
567
- },
568
- d(o) {
569
- r && r.d(o);
570
- }
571
- };
572
- }
573
- function oe(e, t) {
574
- let n, r, o;
575
- return {
576
- key: e,
577
- first: null,
578
- c() {
579
- n = P("div"), r = P("div"), o = fe(), f(r, "position", "absolute"), f(r, "top", "0"), f(r, "left", "0"), f(r, "width", "100%"), f(r, "height", "100%"), f(r, "background", "linear-gradient(90deg, transparent, " + /*resolvedShimmerColor*/
580
- t[7] + ", transparent)"), f(r, "animation", "shimmer-animation " + /*resolvedDuration*/
581
- t[5] + "s infinite"), f(n, "position", "absolute"), f(
582
- n,
583
- "left",
584
- /*element*/
585
- t[19].x + "px"
586
- ), f(
587
- n,
588
- "top",
589
- /*element*/
590
- t[19].y + "px"
591
- ), f(
592
- n,
593
- "width",
594
- /*element*/
595
- t[19].width + "px"
596
- ), f(
597
- n,
598
- "height",
599
- /*element*/
600
- t[19].height + "px"
601
- ), f(
602
- n,
603
- "background-color",
604
- /*resolvedBackgroundColor*/
605
- t[6]
606
- ), f(
607
- n,
608
- "border-radius",
609
- /*element*/
610
- t[19].borderRadius === "0px" ? (
611
- /*resolvedFallbackBorderRadius*/
612
- t[4] + "px"
613
- ) : (
614
- /*element*/
615
- t[19].borderRadius
616
- )
617
- ), f(n, "overflow", "hidden"), this.first = n;
618
- },
619
- m(l, i) {
620
- Q(l, n, i), N(n, r), N(n, o);
621
- },
622
- p(l, i) {
623
- t = l, i & /*resolvedShimmerColor*/
624
- 128 && f(r, "background", "linear-gradient(90deg, transparent, " + /*resolvedShimmerColor*/
625
- t[7] + ", transparent)"), i & /*resolvedDuration*/
626
- 32 && f(r, "animation", "shimmer-animation " + /*resolvedDuration*/
627
- t[5] + "s infinite"), i & /*elements*/
628
- 8 && f(
629
- n,
630
- "left",
631
- /*element*/
632
- t[19].x + "px"
633
- ), i & /*elements*/
634
- 8 && f(
635
- n,
636
- "top",
637
- /*element*/
638
- t[19].y + "px"
639
- ), i & /*elements*/
640
- 8 && f(
641
- n,
642
- "width",
643
- /*element*/
644
- t[19].width + "px"
645
- ), i & /*elements*/
646
- 8 && f(
647
- n,
648
- "height",
649
- /*element*/
650
- t[19].height + "px"
651
- ), i & /*resolvedBackgroundColor*/
652
- 64 && f(
653
- n,
654
- "background-color",
655
- /*resolvedBackgroundColor*/
656
- t[6]
657
- ), i & /*elements, resolvedFallbackBorderRadius*/
658
- 24 && f(
659
- n,
660
- "border-radius",
661
- /*element*/
662
- t[19].borderRadius === "0px" ? (
663
- /*resolvedFallbackBorderRadius*/
664
- t[4] + "px"
665
- ) : (
666
- /*element*/
667
- t[19].borderRadius
668
- )
669
- );
670
- },
671
- d(l) {
672
- l && T(n);
37
+ 100% {
38
+ transform: translateX(100%);
673
39
  }
674
- };
675
- }
676
- function Je(e) {
677
- let t, n, r, o;
678
- const l = [Ye, Ve], i = [];
679
- function a(c, u) {
680
- return (
681
- /*loading*/
682
- c[0] ? 1 : 0
683
- );
684
- }
685
- return t = a(e), n = i[t] = l[t](e), {
686
- c() {
687
- n.c(), r = Me();
688
- },
689
- m(c, u) {
690
- i[t].m(c, u), Q(c, r, u), o = !0;
691
- },
692
- p(c, [u]) {
693
- let y = t;
694
- t = a(c), t === y ? i[t].p(c, u) : (ae(), B(i[y], 1, 1, () => {
695
- i[y] = null;
696
- }), de(), n = i[t], n ? n.p(c, u) : (n = i[t] = l[t](c), n.c()), R(n, 1), n.m(r.parentNode, r));
697
- },
698
- i(c) {
699
- o || (R(n), o = !0);
700
- },
701
- o(c) {
702
- B(n), o = !1;
703
- },
704
- d(c) {
705
- c && T(r), i[t].d(c);
706
- }
707
- };
708
- }
709
- function Qe(e, t, n) {
710
- let r, o, l, i, { $$slots: a = {}, $$scope: c } = t, { loading: u = !0 } = t, { shimmerColor: y = void 0 } = t, { backgroundColor: m = void 0 } = t, { duration: p = void 0 } = t, { fallbackBorderRadius: b = void 0 } = t, { templateProps: k = void 0 } = t, s, h = [];
711
- const _ = he();
712
- async function E() {
713
- if (!u || !s) return;
714
- w == null || w.disconnect(), await ke();
715
- const d = s, g = d.getBoundingClientRect(), v = [];
716
- Array.from(d.children).forEach((C) => {
717
- v.push(...ve(C, g));
718
- }), n(3, h = v), s && w && w.observe(s, {
40
+ }`
41
+ };
42
+ function Q(a, t) {
43
+ e.push(t, !0), e.append_styles(a, Y);
44
+ let d = e.prop(t, "loading", 3, !0), _ = e.prop(t, "shimmerColor", 3, void 0), k = e.prop(t, "backgroundColor", 3, void 0), x = e.prop(t, "duration", 3, void 0), R = e.prop(t, "fallbackBorderRadius", 3, void 0);
45
+ e.prop(t, "templateProps", 3, void 0);
46
+ let o = e.state(void 0), h = e.state(e.proxy([]));
47
+ const u = C(), y = e.derived(() => _() ?? u.shimmerColor), B = e.derived(() => k() ?? u.backgroundColor), w = e.derived(() => x() ?? u.duration), E = e.derived(() => R() ?? u.fallbackBorderRadius);
48
+ let r;
49
+ async function c() {
50
+ if (!d() || !e.get(o)) return;
51
+ r == null || r.disconnect(), await N();
52
+ const i = e.get(o), s = i.getBoundingClientRect(), n = [];
53
+ Array.from(i.children).forEach((v) => {
54
+ n.push(...A(v, s));
55
+ }), e.set(h, n, !0), e.get(o) && r && r.observe(e.get(o), {
719
56
  childList: !0,
720
57
  subtree: !0,
721
58
  characterData: !0,
722
59
  attributes: !1
723
60
  });
724
61
  }
725
- let w;
726
- ye(() => (E(), s && (w = new MutationObserver(() => {
727
- u && E();
728
- }), w.observe(s, {
62
+ e.user_effect(() => {
63
+ d() && e.get(o) && c();
64
+ }), L(() => (c(), e.get(o) && (r = new MutationObserver(() => {
65
+ d() && c();
66
+ }), r.observe(e.get(o), {
729
67
  childList: !0,
730
68
  subtree: !0,
731
69
  characterData: !0,
732
70
  attributes: !1
71
+ // Don't observe attribute changes (style updates)
733
72
  })), () => {
734
- w == null || w.disconnect();
73
+ r == null || r.disconnect();
735
74
  }));
736
- function A() {
737
- E();
738
- }
739
- function j(d) {
740
- K[d ? "unshift" : "push"](() => {
741
- s = d, n(2, s);
75
+ function S() {
76
+ c();
77
+ }
78
+ var M = { remeasure: S }, g = e.comment(), D = e.first_child(g);
79
+ {
80
+ var I = (i) => {
81
+ var s = e.comment(), n = e.first_child(s);
82
+ e.snippet(n, () => t.children), e.append(i, s);
83
+ }, F = (i) => {
84
+ var s = P(), n = e.child(s), v = e.child(n);
85
+ e.snippet(v, () => t.children), e.reset(n), e.bind_this(n, (f) => e.set(o, f), () => e.get(o));
86
+ var p = e.sibling(n, 2);
87
+ e.each(p, 21, () => e.get(h), e.index, (f, l) => {
88
+ var m = K(), O = e.child(m);
89
+ e.reset(m), e.template_effect(() => {
90
+ e.set_style(m, `
91
+ position: absolute;
92
+ left: ${e.get(l).x ?? ""}px;
93
+ top: ${e.get(l).y ?? ""}px;
94
+ width: ${e.get(l).width ?? ""}px;
95
+ height: ${e.get(l).height ?? ""}px;
96
+ background-color: ${e.get(B) ?? ""};
97
+ border-radius: ${(e.get(l).borderRadius === "0px" ? e.get(E) + "px" : e.get(l).borderRadius) ?? ""};
98
+ overflow: hidden;
99
+ `), e.set_style(O, `
100
+ position: absolute;
101
+ top: 0;
102
+ left: 0;
103
+ width: 100%;
104
+ height: 100%;
105
+ background: linear-gradient(90deg, transparent, ${e.get(y) ?? ""}, transparent);
106
+ animation: shimmer-animation ${e.get(w) ?? ""}s infinite;
107
+ `);
108
+ }), e.append(f, m);
109
+ }), e.reset(p), e.reset(s), e.append(i, s);
110
+ };
111
+ e.if(D, (i) => {
112
+ d() ? i(F, !1) : i(I);
742
113
  });
743
114
  }
744
- return e.$$set = (d) => {
745
- "loading" in d && n(0, u = d.loading), "shimmerColor" in d && n(8, y = d.shimmerColor), "backgroundColor" in d && n(9, m = d.backgroundColor), "duration" in d && n(10, p = d.duration), "fallbackBorderRadius" in d && n(11, b = d.fallbackBorderRadius), "templateProps" in d && n(1, k = d.templateProps), "$$scope" in d && n(13, c = d.$$scope);
746
- }, e.$$.update = () => {
747
- e.$$.dirty & /*shimmerColor*/
748
- 256 && n(7, r = y ?? _.shimmerColor), e.$$.dirty & /*backgroundColor*/
749
- 512 && n(6, o = m ?? _.backgroundColor), e.$$.dirty & /*duration*/
750
- 1024 && n(5, l = p ?? _.duration), e.$$.dirty & /*fallbackBorderRadius*/
751
- 2048 && n(4, i = b ?? _.fallbackBorderRadius), e.$$.dirty & /*loading, measureRef*/
752
- 5 && u && s && E();
753
- }, [
754
- u,
755
- k,
756
- s,
757
- h,
758
- i,
759
- l,
760
- o,
761
- r,
762
- y,
763
- m,
764
- p,
765
- b,
766
- A,
767
- c,
768
- a,
769
- j
770
- ];
771
- }
772
- class tt extends He {
773
- constructor(t) {
774
- super(), Ge(
775
- this,
776
- t,
777
- Qe,
778
- Je,
779
- Re,
780
- {
781
- loading: 0,
782
- shimmerColor: 8,
783
- backgroundColor: 9,
784
- duration: 10,
785
- fallbackBorderRadius: 11,
786
- templateProps: 1,
787
- remeasure: 12
788
- },
789
- Ke
790
- );
791
- }
792
- get remeasure() {
793
- return this.$$.ctx[12];
794
- }
115
+ return e.append(a, g), e.pop(M);
795
116
  }
796
117
  export {
797
- tt as Shimmer,
798
- he as getShimmerConfig,
799
- et as setShimmerConfig,
800
- ot as shimmerDefaults
118
+ Q as Shimmer,
119
+ C as getShimmerConfig,
120
+ J as setShimmerConfig,
121
+ V as shimmerDefaults
801
122
  };
package/dist/index.js CHANGED
@@ -1 +1,36 @@
1
- (function(y,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("svelte"),require("@shimmer-from-structure/core")):typeof define=="function"&&define.amd?define(["exports","svelte","@shimmer-from-structure/core"],v):(y=typeof globalThis<"u"?globalThis:y||self,v(y.ShimmerSvelte={},y.Svelte,y.ShimmerCore))})(this,function(y,v,B){"use strict";var ze=Object.defineProperty;var Je=(y,v,B)=>v in y?ze(y,v,{enumerable:!0,configurable:!0,writable:!0,value:B}):y[v]=B;var te=(y,v,B)=>Je(y,typeof v!="symbol"?v+"":v,B);function X(){}function be(e,t){for(const n in t)e[n]=t[n];return e}function ne(e){return e()}function re(){return Object.create(null)}function N(e){e.forEach(ne)}function oe(e){return typeof e=="function"}function ye(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function ke(e){return Object.keys(e).length===0}function K(e,t,n,r){if(e){const o=ie(e,t,n,r);return e[0](o)}}function ie(e,t,n,r){return e[1]&&r?be(n.ctx.slice(),e[1](r(t))):n.ctx}function U(e,t,n,r){if(e[2]&&r){const o=e[2](r(n));if(t.dirty===void 0)return o;if(typeof o=="object"){const l=[],i=Math.max(t.dirty.length,o.length);for(let a=0;a<i;a+=1)l[a]=t.dirty[a]|o[a];return l}return t.dirty|o}return t.dirty}function V(e,t,n,r,o,l){if(o){const i=ie(t,n,r,l);e.p(i,o)}}function Y(e){if(e.ctx.length>32){const t=[],n=e.ctx.length/32;for(let r=0;r<n;r++)t[r]=-1;return t}return-1}function O(e,t){e.appendChild(t)}function we(e,t,n){const r=ve(e);if(!r.getElementById(t)){const o=j("style");o.id=t,o.textContent=n,Ce(r,o)}}function ve(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t&&t.host?t:e.ownerDocument}function Ce(e,t){return O(e.head||e,t),t.sheet}function z(e,t,n){e.insertBefore(t,n||null)}function F(e){e.parentNode&&e.parentNode.removeChild(e)}function j(e){return document.createElement(e)}function le(e){return document.createTextNode(e)}function se(){return le(" ")}function Se(){return le("")}function ue(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Re(e){return Array.from(e.childNodes)}function f(e,t,n,r){n==null?e.style.removeProperty(t):e.style.setProperty(t,n,"")}let J;function T(e){J=e}const D=[],Q=[];let I=[];const fe=[],Ee=Promise.resolve();let W=!1;function Be(){W||(W=!0,Ee.then(ce))}function Z(e){I.push(e)}const $=new Set;let A=0;function ce(){if(A!==0)return;const e=J;do{try{for(;A<D.length;){const t=D[A];A++,T(t),Me(t.$$)}}catch(t){throw D.length=0,A=0,t}for(T(null),D.length=0,A=0;Q.length;)Q.pop()();for(let t=0;t<I.length;t+=1){const n=I[t];$.has(n)||($.add(n),n())}I.length=0}while(D.length);for(;fe.length;)fe.pop()();W=!1,$.clear(),T(e)}function Me(e){if(e.fragment!==null){e.update(),N(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(Z)}}function xe(e){const t=[],n=[];I.forEach(r=>e.indexOf(r)===-1?t.push(r):n.push(r)),n.forEach(r=>r()),I=t}const L=new Set;let x;function ae(){x={r:0,c:[],p:x}}function de(){x.r||N(x.c),x=x.p}function E(e,t){e&&e.i&&(L.delete(e),e.i(t))}function P(e,t,n,r){if(e&&e.o){if(L.has(e))return;L.add(e),x.c.push(()=>{L.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function me(e){return(e==null?void 0:e.length)!==void 0?e:Array.from(e)}function Pe(e,t){e.d(1),t.delete(e.key)}function Ne(e,t,n,r,o,l,i,a,c,u,k,m){let p=e.length,b=l.length,w=p;const s={};for(;w--;)s[e[w].key]=w;const h=[],_=new Map,M=new Map,C=[];for(w=b;w--;){const g=m(o,l,w),S=n(g);let R=i.get(S);R?C.push(()=>R.p(g,t)):(R=u(S,g),R.c()),_.set(S,h[w]=R),S in s&&M.set(S,Math.abs(w-s[S]))}const q=new Set,G=new Set;function d(g){E(g,1),g.m(a,k),i.set(g.key,g),k=g.first,b--}for(;p&&b;){const g=h[b-1],S=e[p-1],R=g.key,H=S.key;g===S?(k=g.first,p--,b--):_.has(H)?!i.has(R)||q.has(R)?d(g):G.has(H)?p--:M.get(R)>M.get(H)?(G.add(R),d(g)):(q.add(H),p--):(c(S,i),p--)}for(;p--;){const g=e[p];_.has(g.key)||c(g,i)}for(;b;)d(h[b-1]);return N(C),h}function Oe(e,t,n){const{fragment:r,after_update:o}=e.$$;r&&r.m(t,n),Z(()=>{const l=e.$$.on_mount.map(ne).filter(oe);e.$$.on_destroy?e.$$.on_destroy.push(...l):N(l),e.$$.on_mount=[]}),o.forEach(Z)}function je(e,t){const n=e.$$;n.fragment!==null&&(xe(n.after_update),N(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function De(e,t){e.$$.dirty[0]===-1&&(D.push(e),Be(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Ie(e,t,n,r,o,l,i=null,a=[-1]){const c=J;T(e);const u=e.$$={fragment:null,ctx:[],props:l,update:X,not_equal:o,bound:re(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(c?c.$$.context:[])),callbacks:re(),dirty:a,skip_bound:!1,root:t.target||c.$$.root};i&&i(u.root);let k=!1;if(u.ctx=n?n(e,t.props||{},(m,p,...b)=>{const w=b.length?b[0]:p;return u.ctx&&o(u.ctx[m],u.ctx[m]=w)&&(!u.skip_bound&&u.bound[m]&&u.bound[m](w),k&&De(e,m)),p}):[],u.update(),k=!0,N(u.before_update),u.fragment=r?r(u.ctx):!1,t.target){if(t.hydrate){const m=Re(t.target);u.fragment&&u.fragment.l(m),m.forEach(F)}else u.fragment&&u.fragment.c();t.intro&&E(e.$$.fragment),Oe(e,t.target,t.anchor),ce()}T(c)}class Ae{constructor(){te(this,"$$");te(this,"$$set")}$destroy(){je(this,1),this.$destroy=X}$on(t,n){if(!oe(n))return X;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const o=r.indexOf(n);o!==-1&&r.splice(o,1)}}$set(t){this.$$set&&!ke(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Te="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Te);const he=Symbol("SHIMMER_CONFIG");function ee(){return v.getContext(he)||B.shimmerDefaults}function Fe(e={}){const t=ee(),n={shimmerColor:e.shimmerColor??t.shimmerColor,backgroundColor:e.backgroundColor??t.backgroundColor,duration:e.duration??t.duration,fallbackBorderRadius:e.fallbackBorderRadius??t.fallbackBorderRadius};v.setContext(he,n)}function Le(e){we(e,"svelte-17yl4xt",".shimmer-measure-container.svelte-17yl4xt *{color:transparent !important}.shimmer-measure-container.svelte-17yl4xt img,.shimmer-measure-container.svelte-17yl4xt svg,.shimmer-measure-container.svelte-17yl4xt video{opacity:0}@keyframes svelte-17yl4xt-shimmer-animation{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}")}function _e(e,t,n){const r=e.slice();return r[19]=t[n],r[21]=n,r}const qe=e=>({shimmerTemplateProps:e&2}),ge=e=>({shimmerTemplateProps:e[1]});function Ge(e){let t,n,r,o,l,i,a=[],c=new Map,u;const k=[Ke,Xe],m=[];function p(s,h){return s[1]?0:1}r=p(e),o=m[r]=k[r](e);let b=me(e[3]);const w=s=>s[21];for(let s=0;s<b.length;s+=1){let h=_e(e,b,s),_=w(h);c.set(_,a[s]=pe(_,h))}return{c(){t=j("div"),n=j("div"),o.c(),l=se(),i=j("div");for(let s=0;s<a.length;s+=1)a[s].c();ue(n,"class","shimmer-measure-container svelte-17yl4xt"),f(n,"pointer-events","none"),ue(n,"aria-hidden","true"),f(i,"position","absolute"),f(i,"top","0"),f(i,"left","0"),f(i,"right","0"),f(i,"bottom","0"),f(i,"overflow","hidden"),f(i,"pointer-events","none"),f(t,"position","relative")},m(s,h){z(s,t,h),O(t,n),m[r].m(n,null),e[15](n),O(t,l),O(t,i);for(let _=0;_<a.length;_+=1)a[_]&&a[_].m(i,null);u=!0},p(s,h){let _=r;r=p(s),r===_?m[r].p(s,h):(ae(),P(m[_],1,1,()=>{m[_]=null}),de(),o=m[r],o?o.p(s,h):(o=m[r]=k[r](s),o.c()),E(o,1),o.m(n,null)),h&248&&(b=me(s[3]),a=Ne(a,h,w,1,s,b,c,i,Pe,pe,null,_e))},i(s){u||(E(o),u=!0)},o(s){P(o),u=!1},d(s){s&&F(t),m[r].d(),e[15](null);for(let h=0;h<a.length;h+=1)a[h].d()}}}function He(e){let t;const n=e[14].default,r=K(n,e,e[13],null);return{c(){r&&r.c()},m(o,l){r&&r.m(o,l),t=!0},p(o,l){r&&r.p&&(!t||l&8192)&&V(r,n,o,o[13],t?U(n,o[13],l,null):Y(o[13]),null)},i(o){t||(E(r,o),t=!0)},o(o){P(r,o),t=!1},d(o){r&&r.d(o)}}}function Xe(e){let t;const n=e[14].default,r=K(n,e,e[13],null);return{c(){r&&r.c()},m(o,l){r&&r.m(o,l),t=!0},p(o,l){r&&r.p&&(!t||l&8192)&&V(r,n,o,o[13],t?U(n,o[13],l,null):Y(o[13]),null)},i(o){t||(E(r,o),t=!0)},o(o){P(r,o),t=!1},d(o){r&&r.d(o)}}}function Ke(e){let t;const n=e[14].default,r=K(n,e,e[13],ge);return{c(){r&&r.c()},m(o,l){r&&r.m(o,l),t=!0},p(o,l){r&&r.p&&(!t||l&8194)&&V(r,n,o,o[13],t?U(n,o[13],l,qe):Y(o[13]),ge)},i(o){t||(E(r,o),t=!0)},o(o){P(r,o),t=!1},d(o){r&&r.d(o)}}}function pe(e,t){let n,r,o;return{key:e,first:null,c(){n=j("div"),r=j("div"),o=se(),f(r,"position","absolute"),f(r,"top","0"),f(r,"left","0"),f(r,"width","100%"),f(r,"height","100%"),f(r,"background","linear-gradient(90deg, transparent, "+t[7]+", transparent)"),f(r,"animation","shimmer-animation "+t[5]+"s infinite"),f(n,"position","absolute"),f(n,"left",t[19].x+"px"),f(n,"top",t[19].y+"px"),f(n,"width",t[19].width+"px"),f(n,"height",t[19].height+"px"),f(n,"background-color",t[6]),f(n,"border-radius",t[19].borderRadius==="0px"?t[4]+"px":t[19].borderRadius),f(n,"overflow","hidden"),this.first=n},m(l,i){z(l,n,i),O(n,r),O(n,o)},p(l,i){t=l,i&128&&f(r,"background","linear-gradient(90deg, transparent, "+t[7]+", transparent)"),i&32&&f(r,"animation","shimmer-animation "+t[5]+"s infinite"),i&8&&f(n,"left",t[19].x+"px"),i&8&&f(n,"top",t[19].y+"px"),i&8&&f(n,"width",t[19].width+"px"),i&8&&f(n,"height",t[19].height+"px"),i&64&&f(n,"background-color",t[6]),i&24&&f(n,"border-radius",t[19].borderRadius==="0px"?t[4]+"px":t[19].borderRadius)},d(l){l&&F(n)}}}function Ue(e){let t,n,r,o;const l=[He,Ge],i=[];function a(c,u){return c[0]?1:0}return t=a(e),n=i[t]=l[t](e),{c(){n.c(),r=Se()},m(c,u){i[t].m(c,u),z(c,r,u),o=!0},p(c,[u]){let k=t;t=a(c),t===k?i[t].p(c,u):(ae(),P(i[k],1,1,()=>{i[k]=null}),de(),n=i[t],n?n.p(c,u):(n=i[t]=l[t](c),n.c()),E(n,1),n.m(r.parentNode,r))},i(c){o||(E(n),o=!0)},o(c){P(n),o=!1},d(c){c&&F(r),i[t].d(c)}}}function Ve(e,t,n){let r,o,l,i,{$$slots:a={},$$scope:c}=t,{loading:u=!0}=t,{shimmerColor:k=void 0}=t,{backgroundColor:m=void 0}=t,{duration:p=void 0}=t,{fallbackBorderRadius:b=void 0}=t,{templateProps:w=void 0}=t,s,h=[];const _=ee();async function M(){if(!u||!s)return;C==null||C.disconnect(),await v.tick();const d=s,g=d.getBoundingClientRect(),S=[];Array.from(d.children).forEach(R=>{S.push(...B.extractElementInfo(R,g))}),n(3,h=S),s&&C&&C.observe(s,{childList:!0,subtree:!0,characterData:!0,attributes:!1})}let C;v.onMount(()=>(M(),s&&(C=new MutationObserver(()=>{u&&M()}),C.observe(s,{childList:!0,subtree:!0,characterData:!0,attributes:!1})),()=>{C==null||C.disconnect()}));function q(){M()}function G(d){Q[d?"unshift":"push"](()=>{s=d,n(2,s)})}return e.$$set=d=>{"loading"in d&&n(0,u=d.loading),"shimmerColor"in d&&n(8,k=d.shimmerColor),"backgroundColor"in d&&n(9,m=d.backgroundColor),"duration"in d&&n(10,p=d.duration),"fallbackBorderRadius"in d&&n(11,b=d.fallbackBorderRadius),"templateProps"in d&&n(1,w=d.templateProps),"$$scope"in d&&n(13,c=d.$$scope)},e.$$.update=()=>{e.$$.dirty&256&&n(7,r=k??_.shimmerColor),e.$$.dirty&512&&n(6,o=m??_.backgroundColor),e.$$.dirty&1024&&n(5,l=p??_.duration),e.$$.dirty&2048&&n(4,i=b??_.fallbackBorderRadius),e.$$.dirty&5&&u&&s&&M()},[u,w,s,h,i,l,o,r,k,m,p,b,q,c,a,G]}class Ye extends Ae{constructor(t){super(),Ie(this,t,Ve,Ue,ye,{loading:0,shimmerColor:8,backgroundColor:9,duration:10,fallbackBorderRadius:11,templateProps:1,remeasure:12},Le)}get remeasure(){return this.$$.ctx[12]}}Object.defineProperty(y,"shimmerDefaults",{enumerable:!0,get:()=>B.shimmerDefaults}),y.Shimmer=Ye,y.getShimmerConfig=ee,y.setShimmerConfig=Fe,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
1
+ (function(n,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("svelte/internal/disclose-version"),require("svelte/internal/client"),require("svelte"),require("@shimmer-from-structure/core")):typeof define=="function"&&define.amd?define(["exports","svelte/internal/disclose-version","svelte/internal/client","svelte","@shimmer-from-structure/core"],c):(n=typeof globalThis<"u"?globalThis:n||self,c(n.ShimmerSvelte={},null,n.SvelteInternalClient,n.Svelte,n.ShimmerCore))})(this,function(n,c,R,m,p){"use strict";function O(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const f=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,f.get?f:{enumerable:!0,get:()=>r[i]})}}return t.default=r,Object.freeze(t)}const e=O(R),y=Symbol("SHIMMER_CONFIG");function b(){return m.getContext(y)||p.shimmerDefaults}function B(r={}){const t=b(),i={shimmerColor:r.shimmerColor??t.shimmerColor,backgroundColor:r.backgroundColor??t.backgroundColor,duration:r.duration??t.duration,fallbackBorderRadius:r.fallbackBorderRadius??t.fallbackBorderRadius};m.setContext(y,i)}var w=e.from_html('<div class="svelte-euvo5u"><div class="svelte-euvo5u"></div></div>'),D=e.from_html(`<div style="position: relative;" class="svelte-euvo5u"><div class="shimmer-measure-container svelte-euvo5u" style="pointer-events: none;" aria-hidden="true"><!></div> <div style="
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ overflow: hidden;
8
+ pointer-events: none;
9
+ " class="svelte-euvo5u"></div></div>`);const M={hash:"svelte-euvo5u",code:`.shimmer-measure-container.svelte-euvo5u * {color:transparent !important;}.shimmer-measure-container.svelte-euvo5u img,
10
+ .shimmer-measure-container.svelte-euvo5u svg,
11
+ .shimmer-measure-container.svelte-euvo5u video {opacity:0;}
12
+ @keyframes svelte-euvo5u-shimmer-animation {
13
+ 0% {
14
+ transform: translateX(-100%);
15
+ }
16
+ 100% {
17
+ transform: translateX(100%);
18
+ }
19
+ }`};function j(r,t){e.push(t,!0),e.append_styles(r,M);let i=e.prop(t,"loading",3,!0),f=e.prop(t,"shimmerColor",3,void 0),E=e.prop(t,"backgroundColor",3,void 0),I=e.prop(t,"duration",3,void 0),P=e.prop(t,"fallbackBorderRadius",3,void 0);e.prop(t,"templateProps",3,void 0);let s=e.state(void 0),k=e.state(e.proxy([]));const v=b(),q=e.derived(()=>f()??v.shimmerColor),T=e.derived(()=>E()??v.backgroundColor),F=e.derived(()=>I()??v.duration),N=e.derived(()=>P()??v.fallbackBorderRadius);let o;async function h(){if(!i()||!e.get(s))return;o==null||o.disconnect(),await m.tick();const a=e.get(s),u=a.getBoundingClientRect(),d=[];Array.from(a.children).forEach(C=>{d.push(...p.extractElementInfo(C,u))}),e.set(k,d,!0),e.get(s)&&o&&o.observe(e.get(s),{childList:!0,subtree:!0,characterData:!0,attributes:!1})}e.user_effect(()=>{i()&&e.get(s)&&h()}),m.onMount(()=>(h(),e.get(s)&&(o=new MutationObserver(()=>{i()&&h()}),o.observe(e.get(s),{childList:!0,subtree:!0,characterData:!0,attributes:!1})),()=>{o==null||o.disconnect()}));function G(){h()}var H={remeasure:G},S=e.comment(),L=e.first_child(S);{var X=a=>{var u=e.comment(),d=e.first_child(u);e.snippet(d,()=>t.children),e.append(a,u)},z=a=>{var u=D(),d=e.child(u),C=e.child(d);e.snippet(C,()=>t.children),e.reset(d),e.bind_this(d,_=>e.set(s,_),()=>e.get(s));var x=e.sibling(d,2);e.each(x,21,()=>e.get(k),e.index,(_,l)=>{var g=w(),A=e.child(g);e.reset(g),e.template_effect(()=>{e.set_style(g,`
20
+ position: absolute;
21
+ left: ${e.get(l).x??""}px;
22
+ top: ${e.get(l).y??""}px;
23
+ width: ${e.get(l).width??""}px;
24
+ height: ${e.get(l).height??""}px;
25
+ background-color: ${e.get(T)??""};
26
+ border-radius: ${(e.get(l).borderRadius==="0px"?e.get(N)+"px":e.get(l).borderRadius)??""};
27
+ overflow: hidden;
28
+ `),e.set_style(A,`
29
+ position: absolute;
30
+ top: 0;
31
+ left: 0;
32
+ width: 100%;
33
+ height: 100%;
34
+ background: linear-gradient(90deg, transparent, ${e.get(q)??""}, transparent);
35
+ animation: shimmer-animation ${e.get(F)??""}s infinite;
36
+ `)}),e.append(_,g)}),e.reset(x),e.reset(u),e.append(a,u)};e.if(L,a=>{i()?a(z,!1):a(X)})}return e.append(r,S),e.pop(H)}Object.defineProperty(n,"shimmerDefaults",{enumerable:!0,get:()=>p.shimmerDefaults}),n.Shimmer=j,n.getShimmerConfig=b,n.setShimmerConfig=B,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
@@ -1,3 +1,4 @@
1
+ import { Snippet } from 'svelte';
1
2
  export interface ShimmerProps {
2
3
  loading?: boolean;
3
4
  shimmerColor?: string;
@@ -15,6 +16,10 @@ export interface ShimmerProps {
15
16
  * Example: { user: { name: "Lorem" }, settings: { theme: "dark" } }
16
17
  */
17
18
  templateProps?: Record<string, unknown>;
19
+ /**
20
+ * The content to render inside the shimmer component.
21
+ */
22
+ children?: Snippet;
18
23
  }
19
24
  export type { ShimmerConfig, ShimmerContextValue, ElementInfo } from '@shimmer-from-structure/core';
20
25
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAGD,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAGD,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shimmer-from-structure/svelte",
3
- "version": "1.1.0",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "description": "Svelte adapter for shimmer-from-structure",
6
6
  "main": "dist/index.js",
@@ -24,19 +24,19 @@
24
24
  "prepublishOnly": "cp ../../README.md ."
25
25
  },
26
26
  "peerDependencies": {
27
- "svelte": "^4.0.0 || ^5.0.0"
27
+ "svelte": "^5.0.0"
28
28
  },
29
29
  "dependencies": {
30
30
  "@shimmer-from-structure/core": "*"
31
31
  },
32
32
  "devDependencies": {
33
- "@sveltejs/vite-plugin-svelte": "^3.0.0",
33
+ "@sveltejs/vite-plugin-svelte": "^4.0.0",
34
34
  "@testing-library/dom": "^10.4.1",
35
35
  "@testing-library/jest-dom": "^6.9.1",
36
36
  "@testing-library/svelte": "^5.3.1",
37
37
  "jsdom": "^27.4.0",
38
- "svelte": "^4.0.0",
39
- "svelte-check": "^3.0.0",
38
+ "svelte": "^5.0.0",
39
+ "svelte-check": "^4.0.0",
40
40
  "tslib": "^2.0.0",
41
41
  "typescript": "^5.0.0"
42
42
  },