@shimmer-from-structure/svelte 2.1.1 → 2.2.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.
- package/dist/index.esm.js +73 -73
- package/dist/index.js +18 -21
- package/dist/src/types.d.ts +2 -4
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/src/Shimmer.test.d.ts +0 -2
- package/dist/src/Shimmer.test.d.ts.map +0 -1
- package/dist/src/test/setup.d.ts +0 -1
- package/dist/src/test/setup.d.ts.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import "svelte/internal/disclose-version";
|
|
2
2
|
import * as e from "svelte/internal/client";
|
|
3
|
-
import { getContext as
|
|
4
|
-
import { shimmerDefaults as
|
|
5
|
-
import { shimmerDefaults as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
return
|
|
3
|
+
import { getContext as N, setContext as X, onMount as A, tick as K } from "svelte";
|
|
4
|
+
import { shimmerDefaults as T, createResizeObserver as V, extractElementInfo as Y } from "@shimmer-from-structure/core";
|
|
5
|
+
import { shimmerDefaults as te } from "@shimmer-from-structure/core";
|
|
6
|
+
const _ = Symbol("SHIMMER_CONFIG");
|
|
7
|
+
function x() {
|
|
8
|
+
return N(_) || T;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const t =
|
|
12
|
-
shimmerColor:
|
|
13
|
-
backgroundColor:
|
|
14
|
-
duration:
|
|
15
|
-
fallbackBorderRadius:
|
|
10
|
+
function W(s = {}) {
|
|
11
|
+
const t = x(), c = {
|
|
12
|
+
shimmerColor: s.shimmerColor ?? t.shimmerColor,
|
|
13
|
+
backgroundColor: s.backgroundColor ?? t.backgroundColor,
|
|
14
|
+
duration: s.duration ?? t.duration,
|
|
15
|
+
fallbackBorderRadius: s.fallbackBorderRadius ?? t.fallbackBorderRadius
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
X(_, c);
|
|
18
18
|
}
|
|
19
|
-
var
|
|
19
|
+
var j = e.from_html("<div><div></div></div>"), q = e.from_html(`<div style="position: relative;"><div class="shimmer-measure-container svelte-euvo5u" style="pointer-events: none;" aria-hidden="true"><!></div> <div style="
|
|
20
20
|
position: absolute;
|
|
21
21
|
top: 0;
|
|
22
22
|
left: 0;
|
|
@@ -24,99 +24,99 @@ var K = e.from_html('<div class="svelte-euvo5u"><div class="svelte-euvo5u"></div
|
|
|
24
24
|
bottom: 0;
|
|
25
25
|
overflow: hidden;
|
|
26
26
|
pointer-events: none;
|
|
27
|
-
"
|
|
28
|
-
const
|
|
27
|
+
"><!> <!></div></div>`);
|
|
28
|
+
const J = {
|
|
29
29
|
hash: "svelte-euvo5u",
|
|
30
30
|
code: `.shimmer-measure-container.svelte-euvo5u * {color:transparent !important;}.shimmer-measure-container.svelte-euvo5u img,
|
|
31
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%);
|
|
36
|
-
}
|
|
37
|
-
100% {
|
|
38
|
-
transform: translateX(100%);
|
|
39
|
-
}
|
|
40
|
-
}`
|
|
32
|
+
.shimmer-measure-container.svelte-euvo5u video {opacity:0;}`
|
|
41
33
|
};
|
|
42
|
-
function
|
|
43
|
-
e.push(t, !0), e.append_styles(
|
|
44
|
-
let
|
|
45
|
-
e.
|
|
46
|
-
let o
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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), {
|
|
34
|
+
function Z(s, t) {
|
|
35
|
+
e.push(t, !0), e.append_styles(s, J);
|
|
36
|
+
let c = e.prop(t, "loading", 3, !0), k = e.prop(t, "shimmerColor", 3, void 0), y = e.prop(t, "backgroundColor", 3, void 0), R = e.prop(t, "duration", 3, void 0), B = e.prop(t, "fallbackBorderRadius", 3, void 0), r = e.state(void 0), h = e.state(e.proxy([]));
|
|
37
|
+
const f = x(), w = e.derived(() => k() ?? f.shimmerColor), E = e.derived(() => y() ?? f.backgroundColor), S = e.derived(() => R() ?? f.duration), M = e.derived(() => B() ?? f.fallbackBorderRadius);
|
|
38
|
+
let o, i;
|
|
39
|
+
async function m() {
|
|
40
|
+
if (!c() || !e.get(r) || (o == null || o.disconnect(), await K(), !e.get(r))) return;
|
|
41
|
+
const n = e.get(r), d = n.getBoundingClientRect(), a = [];
|
|
42
|
+
Array.from(n.children).forEach((g) => {
|
|
43
|
+
a.push(...Y(g, d));
|
|
44
|
+
}), e.set(h, a, !0), e.get(r) && o && o.observe(e.get(r), {
|
|
56
45
|
childList: !0,
|
|
57
46
|
subtree: !0,
|
|
58
47
|
characterData: !0,
|
|
59
48
|
attributes: !1
|
|
60
49
|
});
|
|
61
50
|
}
|
|
62
|
-
e.user_effect(() => {
|
|
63
|
-
|
|
64
|
-
}),
|
|
65
|
-
|
|
66
|
-
}),
|
|
51
|
+
e.user_effect(() => (c() && e.get(r) ? (m(), i && i(), i = V(e.get(r), m)) : i && (i(), i = void 0), () => {
|
|
52
|
+
i && (i(), i = void 0);
|
|
53
|
+
})), A(() => (m(), e.get(r) && (o = new MutationObserver(() => {
|
|
54
|
+
c() && m();
|
|
55
|
+
}), o.observe(e.get(r), {
|
|
67
56
|
childList: !0,
|
|
68
57
|
subtree: !0,
|
|
69
58
|
characterData: !0,
|
|
70
59
|
attributes: !1
|
|
71
60
|
// Don't observe attribute changes (style updates)
|
|
72
61
|
})), () => {
|
|
73
|
-
|
|
62
|
+
o == null || o.disconnect();
|
|
74
63
|
}));
|
|
75
|
-
function
|
|
76
|
-
|
|
64
|
+
function D() {
|
|
65
|
+
m();
|
|
77
66
|
}
|
|
78
|
-
|
|
67
|
+
const I = "style";
|
|
68
|
+
var O = { remeasure: D }, p = e.comment(), F = e.first_child(p);
|
|
79
69
|
{
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
e.snippet(
|
|
83
|
-
},
|
|
84
|
-
var
|
|
85
|
-
e.snippet(
|
|
86
|
-
var
|
|
87
|
-
e.
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
70
|
+
var z = (n) => {
|
|
71
|
+
var d = e.comment(), a = e.first_child(d);
|
|
72
|
+
e.snippet(a, () => t.children), e.append(n, d);
|
|
73
|
+
}, G = (n) => {
|
|
74
|
+
var d = q(), a = e.child(d), g = e.child(a);
|
|
75
|
+
e.snippet(g, () => t.children), e.reset(a), e.bind_this(a, (v) => e.set(r, v), () => e.get(r));
|
|
76
|
+
var b = e.sibling(a, 2), C = e.child(b);
|
|
77
|
+
e.element(C, () => I, !1, (v, l) => {
|
|
78
|
+
var u = e.text();
|
|
79
|
+
u.nodeValue = `
|
|
80
|
+
@keyframes shimmer-animation {
|
|
81
|
+
0% { transform: translateX(-100%); }
|
|
82
|
+
100% { transform: translateX(100%); }
|
|
83
|
+
}
|
|
84
|
+
`, e.append(l, u);
|
|
85
|
+
});
|
|
86
|
+
var H = e.sibling(C, 2);
|
|
87
|
+
e.each(H, 17, () => e.get(h), e.index, (v, l) => {
|
|
88
|
+
var u = j(), L = e.child(u);
|
|
89
|
+
e.reset(u), e.template_effect(() => {
|
|
90
|
+
e.set_style(u, `
|
|
91
91
|
position: absolute;
|
|
92
92
|
left: ${e.get(l).x ?? ""}px;
|
|
93
93
|
top: ${e.get(l).y ?? ""}px;
|
|
94
94
|
width: ${e.get(l).width ?? ""}px;
|
|
95
95
|
height: ${e.get(l).height ?? ""}px;
|
|
96
|
-
background-color: ${e.get(
|
|
97
|
-
border-radius: ${(e.get(l).borderRadius === "0px" ? e.get(
|
|
96
|
+
background-color: ${e.get(E) ?? ""};
|
|
97
|
+
border-radius: ${(e.get(l).borderRadius === "0px" ? e.get(M) + "px" : e.get(l).borderRadius) ?? ""};
|
|
98
98
|
overflow: hidden;
|
|
99
|
-
`), e.set_style(
|
|
99
|
+
`), e.set_style(L, `
|
|
100
100
|
position: absolute;
|
|
101
101
|
top: 0;
|
|
102
102
|
left: 0;
|
|
103
103
|
width: 100%;
|
|
104
104
|
height: 100%;
|
|
105
|
-
background: linear-gradient(90deg, transparent, ${e.get(
|
|
106
|
-
animation: shimmer-animation ${e.get(
|
|
105
|
+
background: linear-gradient(90deg, transparent, ${e.get(w) ?? ""}, transparent);
|
|
106
|
+
animation: shimmer-animation ${e.get(S) ?? ""}s infinite;
|
|
107
107
|
`);
|
|
108
|
-
}), e.append(
|
|
109
|
-
}), e.reset(
|
|
108
|
+
}), e.append(v, u);
|
|
109
|
+
}), e.reset(b), e.reset(d), e.append(n, d);
|
|
110
110
|
};
|
|
111
|
-
e.if(
|
|
112
|
-
|
|
111
|
+
e.if(F, (n) => {
|
|
112
|
+
c() ? n(G, !1) : n(z);
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
return e.append(
|
|
115
|
+
return e.append(s, p), e.pop(O);
|
|
116
116
|
}
|
|
117
117
|
export {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
Z as Shimmer,
|
|
119
|
+
x as getShimmerConfig,
|
|
120
|
+
W as setShimmerConfig,
|
|
121
|
+
te as shimmerDefaults
|
|
122
122
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(n,
|
|
1
|
+
(function(n,v){typeof exports=="object"&&typeof module<"u"?v(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"],v):(n=typeof globalThis<"u"?globalThis:n||self,v(n.ShimmerSvelte={},null,n.SvelteInternalClient,n.Svelte,n.ShimmerCore))})(this,function(n,v,B,h,g){"use strict";function w(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const p=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,p.get?p:{enumerable:!0,get:()=>r[i]})}}return t.default=r,Object.freeze(t)}const e=w(B),k=Symbol("SHIMMER_CONFIG");function _(){return h.getContext(k)||g.shimmerDefaults}function D(r={}){const t=_(),i={shimmerColor:r.shimmerColor??t.shimmerColor,backgroundColor:r.backgroundColor??t.backgroundColor,duration:r.duration??t.duration,fallbackBorderRadius:r.fallbackBorderRadius??t.fallbackBorderRadius};h.setContext(k,i)}var M=e.from_html("<div><div></div></div>"),j=e.from_html(`<div style="position: relative;"><div class="shimmer-measure-container svelte-euvo5u" style="pointer-events: none;" aria-hidden="true"><!></div> <div style="
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -6,31 +6,28 @@
|
|
|
6
6
|
bottom: 0;
|
|
7
7
|
overflow: hidden;
|
|
8
8
|
pointer-events: none;
|
|
9
|
-
"
|
|
9
|
+
"><!> <!></div></div>`);const E={hash:"svelte-euvo5u",code:`.shimmer-measure-container.svelte-euvo5u * {color:transparent !important;}.shimmer-measure-container.svelte-euvo5u img,
|
|
10
10
|
.shimmer-measure-container.svelte-euvo5u svg,
|
|
11
|
-
.shimmer-measure-container.svelte-euvo5u video {opacity:0;}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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,`
|
|
11
|
+
.shimmer-measure-container.svelte-euvo5u video {opacity:0;}`};function I(r,t){e.push(t,!0),e.append_styles(r,E);let i=e.prop(t,"loading",3,!0),p=e.prop(t,"shimmerColor",3,void 0),T=e.prop(t,"backgroundColor",3,void 0),q=e.prop(t,"duration",3,void 0),P=e.prop(t,"fallbackBorderRadius",3,void 0),o=e.state(void 0),S=e.state(e.proxy([]));const b=_(),z=e.derived(()=>p()??b.shimmerColor),F=e.derived(()=>T()??b.backgroundColor),N=e.derived(()=>q()??b.duration),G=e.derived(()=>P()??b.fallbackBorderRadius);let a,s;async function f(){if(!i()||!e.get(o)||(a==null||a.disconnect(),await h.tick(),!e.get(o)))return;const d=e.get(o),u=d.getBoundingClientRect(),l=[];Array.from(d.children).forEach(y=>{l.push(...g.extractElementInfo(y,u))}),e.set(S,l,!0),e.get(o)&&a&&a.observe(e.get(o),{childList:!0,subtree:!0,characterData:!0,attributes:!1})}e.user_effect(()=>(i()&&e.get(o)?(f(),s&&s(),s=g.createResizeObserver(e.get(o),f)):s&&(s(),s=void 0),()=>{s&&(s(),s=void 0)})),h.onMount(()=>(f(),e.get(o)&&(a=new MutationObserver(()=>{i()&&f()}),a.observe(e.get(o),{childList:!0,subtree:!0,characterData:!0,attributes:!1})),()=>{a==null||a.disconnect()}));function H(){f()}const L="style";var V={remeasure:H},x=e.comment(),X=e.first_child(x);{var A=d=>{var u=e.comment(),l=e.first_child(u);e.snippet(l,()=>t.children),e.append(d,u)},K=d=>{var u=j(),l=e.child(u),y=e.child(l);e.snippet(y,()=>t.children),e.reset(l),e.bind_this(l,C=>e.set(o,C),()=>e.get(o));var R=e.sibling(l,2),O=e.child(R);e.element(O,()=>L,!1,(C,c)=>{var m=e.text();m.nodeValue=`
|
|
12
|
+
@keyframes shimmer-animation {
|
|
13
|
+
0% { transform: translateX(-100%); }
|
|
14
|
+
100% { transform: translateX(100%); }
|
|
15
|
+
}
|
|
16
|
+
`,e.append(c,m)});var Y=e.sibling(O,2);e.each(Y,17,()=>e.get(S),e.index,(C,c)=>{var m=M(),J=e.child(m);e.reset(m),e.template_effect(()=>{e.set_style(m,`
|
|
20
17
|
position: absolute;
|
|
21
|
-
left: ${e.get(
|
|
22
|
-
top: ${e.get(
|
|
23
|
-
width: ${e.get(
|
|
24
|
-
height: ${e.get(
|
|
25
|
-
background-color: ${e.get(
|
|
26
|
-
border-radius: ${(e.get(
|
|
18
|
+
left: ${e.get(c).x??""}px;
|
|
19
|
+
top: ${e.get(c).y??""}px;
|
|
20
|
+
width: ${e.get(c).width??""}px;
|
|
21
|
+
height: ${e.get(c).height??""}px;
|
|
22
|
+
background-color: ${e.get(F)??""};
|
|
23
|
+
border-radius: ${(e.get(c).borderRadius==="0px"?e.get(G)+"px":e.get(c).borderRadius)??""};
|
|
27
24
|
overflow: hidden;
|
|
28
|
-
`),e.set_style(
|
|
25
|
+
`),e.set_style(J,`
|
|
29
26
|
position: absolute;
|
|
30
27
|
top: 0;
|
|
31
28
|
left: 0;
|
|
32
29
|
width: 100%;
|
|
33
30
|
height: 100%;
|
|
34
|
-
background: linear-gradient(90deg, transparent, ${e.get(
|
|
35
|
-
animation: shimmer-animation ${e.get(
|
|
36
|
-
`)}),e.append(
|
|
31
|
+
background: linear-gradient(90deg, transparent, ${e.get(z)??""}, transparent);
|
|
32
|
+
animation: shimmer-animation ${e.get(N)??""}s infinite;
|
|
33
|
+
`)}),e.append(C,m)}),e.reset(R),e.reset(u),e.append(d,u)};e.if(X,d=>{i()?d(K,!1):d(A)})}return e.append(r,x),e.pop(V)}Object.defineProperty(n,"shimmerDefaults",{enumerable:!0,get:()=>g.shimmerDefaults}),n.Shimmer=I,n.getShimmerConfig=_,n.setShimmerConfig=D,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/dist/src/types.d.ts
CHANGED
|
@@ -11,13 +11,11 @@ export interface ShimmerProps {
|
|
|
11
11
|
*/
|
|
12
12
|
fallbackBorderRadius?: number;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* These props will be injected into the slot when loading.
|
|
16
|
-
* Example: { user: { name: "Lorem" }, settings: { theme: "dark" } }
|
|
14
|
+
* This will be removed in a future version
|
|
17
15
|
*/
|
|
18
16
|
templateProps?: Record<string, unknown>;
|
|
19
17
|
/**
|
|
20
|
-
*
|
|
18
|
+
* This defines the layout structure that will be measured to generate the shimmer effect.
|
|
21
19
|
*/
|
|
22
20
|
children?: Snippet;
|
|
23
21
|
}
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;OAEG;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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Shimmer.test.d.ts","sourceRoot":"","sources":["../../src/Shimmer.test.ts"],"names":[],"mappings":""}
|
package/dist/src/test/setup.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/test/setup.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC"}
|