carbon-components-svelte/assets/SkeletonText.28989bc7.js
2020-10-03 09:11:24 -07:00

1 line
2.9 KiB
JavaScript

import{S as t,i as e,s as n,D as s,q as i,Y as a,o as l,B as o,w as r,C as h,G as c,g as d,k as u,l as f,x as p,y as g,I as x,A as m,J as _,a3 as w,Z as $,a9 as k}from"./index.cb5ffa4a.js";function y(t,e,n){const s=t.slice();return s[2]=e[n].width,s[18]=n,s}function b(t){let e,n,s,a,o=[t[4],{style:n="width: "+t[2]+";"+t[4].style}],h={};for(let t=0;t<o.length;t+=1)h=r(h,o[t]);return{c(){e=d("p"),this.h()},l(t){e=u(t,"P",{style:!0}),f(e).forEach(l),this.h()},h(){p(e,h),g(e,"bx--skeleton__text",!0),g(e,"bx--skeleton__heading",t[0])},m(n,l){i(n,e,l),s||(a=[x(e,"click",t[10]),x(e,"mouseover",t[11]),x(e,"mouseenter",t[12]),x(e,"mouseleave",t[13])],s=!0)},p(t,s){p(e,h=m(o,[16&s&&t[4],20&s&&n!==(n="width: "+t[2]+";"+t[4].style)&&{style:n}])),g(e,"bx--skeleton__text",!0),g(e,"bx--skeleton__heading",t[0])},d(t){t&&l(e),s=!1,_(a)}}}function v(t){let e,n,s,a=[],o=new Map,h=t[3];const c=t=>t[2];for(let e=0;e<h.length;e+=1){let n=y(t,h,e),s=c(n);o.set(s,a[e]=E(s,n))}let g=[t[4]],w={};for(let t=0;t<g.length;t+=1)w=r(w,g[t]);return{c(){e=d("div");for(let t=0;t<a.length;t+=1)a[t].c();this.h()},l(t){e=u(t,"DIV",{});var n=f(e);for(let t=0;t<a.length;t+=1)a[t].l(n);n.forEach(l),this.h()},h(){p(e,w)},m(l,o){i(l,e,o);for(let t=0;t<a.length;t+=1)a[t].m(e,null);n||(s=[x(e,"click",t[6]),x(e,"mouseover",t[7]),x(e,"mouseenter",t[8]),x(e,"mouseleave",t[9])],n=!0)},p(t,n){if(9&n){const s=t[3];a=$(a,n,c,1,t,s,o,e,k,E,null,y)}p(e,w=m(g,[16&n&&t[4]]))},d(t){t&&l(e);for(let t=0;t<a.length;t+=1)a[t].d();n=!1,_(s)}}}function E(t,e){let n;return{key:t,first:null,c(){n=d("p"),this.h()},l(t){n=u(t,"P",{style:!0}),f(n).forEach(l),this.h()},h(){w(n,"width",e[2]),g(n,"bx--skeleton__text",!0),g(n,"bx--skeleton__heading",e[0]),this.first=n},m(t,e){i(t,n,e)},p(t,e){8&e&&w(n,"width",t[2]),1&e&&g(n,"bx--skeleton__heading",t[0])},d(t){t&&l(n)}}}function I(t){let e;function n(t,e){return t[1]?v:b}let o=n(t),r=o(t);return{c(){r.c(),e=s()},l(t){r.l(t),e=s()},m(t,n){r.m(t,n),i(t,e,n)},p(t,[s]){o===(o=n(t))&&r?r.p(t,s):(r.d(1),r=o(t),r&&(r.c(),r.m(e.parentNode,e)))},i:a,o:a,d(t){r.d(t),t&&l(e)}}}function D(t,e,n){const s=["lines","heading","paragraph","width"];let i=o(e,s),{lines:a=3}=e,{heading:l=!1}=e,{paragraph:d=!1}=e,{width:u="100%"}=e;const f=[.973,.153,.567];let p,g,x;return t.$$set=t=>{e=r(r({},e),h(t)),n(4,i=o(e,s)),"lines"in t&&n(5,a=t.lines),"heading"in t&&n(0,l=t.heading),"paragraph"in t&&n(1,d=t.paragraph),"width"in t&&n(2,u=t.width)},t.$$.update=()=>{if(4&t.$$.dirty&&n(14,g=parseInt(u,10)),4&t.$$.dirty&&n(15,x=u.includes("px")),49198&t.$$.dirty&&d)for(let t=0;t<a;t++){const e=x?g-75:0,s=x?g:75,i=Math.floor(f[t%3]*(s-e+1))+e+"px";n(3,p=[...p,{width:x?i:`calc(${u} - ${i})`}])}},n(3,p=[]),[l,d,u,p,i,a,function(e){c(t,e)},function(e){c(t,e)},function(e){c(t,e)},function(e){c(t,e)},function(e){c(t,e)},function(e){c(t,e)},function(e){c(t,e)},function(e){c(t,e)}]}class M extends t{constructor(t){super(),e(this,t,D,I,n,{lines:5,heading:0,paragraph:1,width:2})}}export{M as S};