@shimmer-from-structure/svelte 2.4.0 → 2.4.2

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.cjs ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("svelte/internal/disclose-version");const L=require("svelte/internal/client"),b=require("svelte"),v=require("@shimmer-from-structure/core");function A(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const h=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,h.get?h:{enumerable:!0,get:()=>r[n]})}}return t.default=r,Object.freeze(t)}const e=A(L),S=Symbol("SHIMMER_CONFIG");function _(){return b.getContext(S)||v.shimmerDefaults}function G(r={}){const t=_(),n={shimmerColor:r.shimmerColor??t.shimmerColor,backgroundColor:r.backgroundColor??t.backgroundColor,duration:r.duration??t.duration,fallbackBorderRadius:r.fallbackBorderRadius??t.fallbackBorderRadius};b.setContext(S,n)}var X=e.from_html("<div><div></div></div>"),Y=e.from_html(`<div style="position: relative;"><!> <div class="shimmer-measure-container" 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
+ "><!> <!></div></div>`);function K(r,t){e.push(t,!0);let n=e.prop(t,"loading",3,!0),h=e.prop(t,"shimmerColor",3,void 0),O=e.prop(t,"backgroundColor",3,void 0),E=e.prop(t,"duration",3,void 0),M=e.prop(t,"fallbackBorderRadius",3,void 0),i=e.state(void 0),C=e.state(e.proxy([]));const p=_(),B=e.derived(()=>h()??p.shimmerColor),w=e.derived(()=>O()??p.backgroundColor),D=e.derived(()=>E()??p.duration),I=e.derived(()=>M()??p.fallbackBorderRadius);let o,s;async function m(){if(!n()||!e.get(i)||(o==null||o.disconnect(),await b.tick(),!e.get(i)))return;const l=e.get(i),u=l.getBoundingClientRect(),c=[];Array.from(l.children).forEach(f=>{c.push(...v.extractElementInfo(f,u))}),e.set(C,c,!0),e.get(i)&&o&&o.observe(e.get(i),{childList:!0,subtree:!0,characterData:!0,attributes:!1})}e.user_effect(()=>(n()&&e.get(i)?(m(),s&&s(),s=v.createResizeObserver(e.get(i),m)):s&&(s(),s=void 0),()=>{s&&(s(),s=void 0)})),b.onMount(()=>(m(),e.get(i)&&(o=new MutationObserver(()=>{n()&&m()}),o.observe(e.get(i),{childList:!0,subtree:!0,characterData:!0,attributes:!1})),()=>{o==null||o.disconnect()}));function j(){m()}const x="style";var N={remeasure:j},k=e.comment(),T=e.first_child(k);{var q=l=>{var u=e.comment(),c=e.first_child(u);e.snippet(c,()=>t.children),e.append(l,u)},P=l=>{var u=Y(),c=e.child(u);e.element(c,()=>x,!1,(g,a)=>{var d=e.text();e.template_effect(()=>e.set_text(d,v.SHIMMER_CONTAINER_STYLES)),e.append(a,d)});var f=e.sibling(c,2),z=e.child(f);e.snippet(z,()=>t.children),e.reset(f),e.bind_this(f,g=>e.set(i,g),()=>e.get(i));var y=e.sibling(f,2),R=e.child(y);e.element(R,()=>x,!1,(g,a)=>{var d=e.text();d.nodeValue=`
10
+ @keyframes shimmer-animation {
11
+ 0% { transform: translateX(-100%); }
12
+ 100% { transform: translateX(100%); }
13
+ }
14
+ `,e.append(a,d)});var F=e.sibling(R,2);e.each(F,17,()=>e.get(C),e.index,(g,a)=>{var d=X(),H=e.child(d);e.reset(d),e.template_effect(()=>{e.set_style(d,`
15
+ position: absolute;
16
+ left: ${e.get(a).x??""}px;
17
+ top: ${e.get(a).y??""}px;
18
+ width: ${e.get(a).width??""}px;
19
+ height: ${e.get(a).height??""}px;
20
+ background-color: ${e.get(w)??""};
21
+ border-radius: ${(e.get(a).borderRadius==="0px"?e.get(I)+"px":e.get(a).borderRadius)??""};
22
+ overflow: hidden;
23
+ `),e.set_style(H,`
24
+ position: absolute;
25
+ top: 0;
26
+ left: 0;
27
+ width: 100%;
28
+ height: 100%;
29
+ background: linear-gradient(90deg, transparent, ${e.get(B)??""}, transparent);
30
+ animation: shimmer-animation ${e.get(D)??""}s infinite;
31
+ `)}),e.append(g,d)}),e.reset(y),e.reset(u),e.append(l,u)};e.if(T,l=>{n()?l(P,-1):l(q)})}return e.append(r,k),e.pop(N)}Object.defineProperty(exports,"shimmerDefaults",{enumerable:!0,get:()=>v.shimmerDefaults});exports.Shimmer=K;exports.getShimmerConfig=_;exports.setShimmerConfig=G;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@shimmer-from-structure/svelte",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "type": "module",
5
5
  "description": "Svelte adapter for shimmer-from-structure",
6
- "main": "dist/index.js",
6
+ "main": "dist/index.cjs",
7
7
  "module": "dist/index.esm.js",
8
8
  "types": "dist/index.d.ts",
9
9
  "files": [
@@ -13,7 +13,7 @@
13
13
  ".": {
14
14
  "types": "./dist/index.d.ts",
15
15
  "import": "./dist/index.esm.js",
16
- "require": "./dist/index.js"
16
+ "require": "./dist/index.cjs"
17
17
  }
18
18
  },
19
19
  "scripts": {
package/dist/index.js DELETED
@@ -1,31 +0,0 @@
1
- (function(n,p){typeof exports=="object"&&typeof module<"u"?p(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"],p):(n=typeof globalThis<"u"?globalThis:n||self,p(n.ShimmerSvelte={},null,n.SvelteInternalClient,n.Svelte,n.ShimmerCore))})(this,(function(n,p,M,b,g){"use strict";function B(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const _=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,_.get?_:{enumerable:!0,get:()=>r[i]})}}return t.default=r,Object.freeze(t)}const e=B(M),y=Symbol("SHIMMER_CONFIG");function S(){return b.getContext(y)||g.shimmerDefaults}function w(r={}){const t=S(),i={shimmerColor:r.shimmerColor??t.shimmerColor,backgroundColor:r.backgroundColor??t.backgroundColor,duration:r.duration??t.duration,fallbackBorderRadius:r.fallbackBorderRadius??t.fallbackBorderRadius};b.setContext(y,i)}var D=e.from_html("<div><div></div></div>"),I=e.from_html(`<div style="position: relative;"><!> <div class="shimmer-measure-container" 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
- "><!> <!></div></div>`);function j(r,t){e.push(t,!0);let i=e.prop(t,"loading",3,!0),_=e.prop(t,"shimmerColor",3,void 0),T=e.prop(t,"backgroundColor",3,void 0),N=e.prop(t,"duration",3,void 0),q=e.prop(t,"fallbackBorderRadius",3,void 0),o=e.state(void 0),k=e.state(e.proxy([]));const C=S(),P=e.derived(()=>_()??C.shimmerColor),z=e.derived(()=>T()??C.backgroundColor),F=e.derived(()=>N()??C.duration),H=e.derived(()=>q()??C.fallbackBorderRadius);let a,l;async function v(){if(!i()||!e.get(o)||(a==null||a.disconnect(),await b.tick(),!e.get(o)))return;const u=e.get(o),c=u.getBoundingClientRect(),f=[];Array.from(u.children).forEach(m=>{f.push(...g.extractElementInfo(m,c))}),e.set(k,f,!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)?(v(),l&&l(),l=g.createResizeObserver(e.get(o),v)):l&&(l(),l=void 0),()=>{l&&(l(),l=void 0)})),b.onMount(()=>(v(),e.get(o)&&(a=new MutationObserver(()=>{i()&&v()}),a.observe(e.get(o),{childList:!0,subtree:!0,characterData:!0,attributes:!1})),()=>{a==null||a.disconnect()}));function L(){v()}const x="style";var A={remeasure:L},R=e.comment(),G=e.first_child(R);{var V=u=>{var c=e.comment(),f=e.first_child(c);e.snippet(f,()=>t.children),e.append(u,c)},X=u=>{var c=I(),f=e.child(c);e.element(f,()=>x,!1,(h,s)=>{var d=e.text();e.template_effect(()=>e.set_text(d,g.SHIMMER_CONTAINER_STYLES)),e.append(s,d)});var m=e.sibling(f,2),Y=e.child(m);e.snippet(Y,()=>t.children),e.reset(m),e.bind_this(m,h=>e.set(o,h),()=>e.get(o));var O=e.sibling(m,2),E=e.child(O);e.element(E,()=>x,!1,(h,s)=>{var d=e.text();d.nodeValue=`
10
- @keyframes shimmer-animation {
11
- 0% { transform: translateX(-100%); }
12
- 100% { transform: translateX(100%); }
13
- }
14
- `,e.append(s,d)});var K=e.sibling(E,2);e.each(K,17,()=>e.get(k),e.index,(h,s)=>{var d=D(),J=e.child(d);e.reset(d),e.template_effect(()=>{e.set_style(d,`
15
- position: absolute;
16
- left: ${e.get(s).x??""}px;
17
- top: ${e.get(s).y??""}px;
18
- width: ${e.get(s).width??""}px;
19
- height: ${e.get(s).height??""}px;
20
- background-color: ${e.get(z)??""};
21
- border-radius: ${(e.get(s).borderRadius==="0px"?e.get(H)+"px":e.get(s).borderRadius)??""};
22
- overflow: hidden;
23
- `),e.set_style(J,`
24
- position: absolute;
25
- top: 0;
26
- left: 0;
27
- width: 100%;
28
- height: 100%;
29
- background: linear-gradient(90deg, transparent, ${e.get(P)??""}, transparent);
30
- animation: shimmer-animation ${e.get(F)??""}s infinite;
31
- `)}),e.append(h,d)}),e.reset(O),e.reset(c),e.append(u,c)};e.if(G,u=>{i()?u(X,-1):u(V)})}return e.append(r,R),e.pop(A)}Object.defineProperty(n,"shimmerDefaults",{enumerable:!0,get:()=>g.shimmerDefaults}),n.Shimmer=j,n.getShimmerConfig=S,n.setShimmerConfig=w,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));