analysis-renderer
Version:
svelte + vite + webComponent, dashboard card
2 lines (1 loc) • 4.63 kB
JavaScript
(function(a,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(a=typeof globalThis<"u"?globalThis:a||self,s(a["custom-counter"]={}))})(this,function(a){"use strict";function s(){}function x(t){return t()}function j(){return Object.create(null)}function m(t){t.forEach(x)}function k(t){return typeof t=="function"}function z(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function B(t){return Object.keys(t).length===0}function p(t,e){t.appendChild(e)}function T(t,e,n){t.insertBefore(e,n||null)}function S(t){t.parentNode&&t.parentNode.removeChild(t)}function V(t){return document.createElement(t)}function g(t){return document.createTextNode(t)}function D(){return g(" ")}function F(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function G(t){return Array.from(t.childNodes)}function L(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function I(t){const e={};for(const n of t)e[n.name]=n.value;return e}let w;function _(t){w=t}const d=[],M=[],$=[],N=[],J=Promise.resolve();let E=!1;function K(){E||(E=!0,J.then(b))}function v(t){$.push(t)}const C=new Set;let h=0;function b(){if(h!==0)return;const t=w;do{try{for(;h<d.length;){const e=d[h];h++,_(e),Q(e.$$)}}catch(e){throw d.length=0,h=0,e}for(_(null),d.length=0,h=0;M.length;)M.pop()();for(let e=0;e<$.length;e+=1){const n=$[e];C.has(n)||(C.add(n),n())}$.length=0}while(d.length);for(;N.length;)N.pop()();E=!1,C.clear(),_(t)}function Q(t){if(t.fragment!==null){t.update(),m(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(v)}}const U=new Set;function W(t,e){t&&t.i&&(U.delete(t),t.i(e))}function X(t,e,n,o){const{fragment:u,after_update:l}=t.$$;u&&u.m(e,n),o||v(()=>{const i=t.$$.on_mount.map(x).filter(k);t.$$.on_destroy?t.$$.on_destroy.push(...i):m(i),t.$$.on_mount=[]}),l.forEach(v)}function Y(t,e){const n=t.$$;n.fragment!==null&&(m(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Z(t,e){t.$$.dirty[0]===-1&&(d.push(t),K(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function tt(t,e,n,o,u,l,i,y=[-1]){const c=w;_(t);const r=t.$$={fragment:null,ctx:[],props:l,update:s,not_equal:u,bound:j(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:j(),dirty:y,skip_bound:!1,root:e.target||c.$$.root};i&&i(r.root);let A=!1;if(r.ctx=n?n(t,e.props||{},(f,P,...R)=>{const q=R.length?R[0]:P;return r.ctx&&u(r.ctx[f],r.ctx[f]=q)&&(!r.skip_bound&&r.bound[f]&&r.bound[f](q),A&&Z(t,f)),P}):[],r.update(),A=!0,m(r.before_update),r.fragment=o?o(r.ctx):!1,e.target){if(e.hydrate){const f=G(e.target);r.fragment&&r.fragment.l(f),f.forEach(S)}else r.fragment&&r.fragment.c();e.intro&&W(t.$$.fragment),X(t,e.target,e.anchor,e.customElement),b()}_(c)}let O;typeof HTMLElement=="function"&&(O=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(x).filter(k);for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){m(this.$$.on_disconnect)}$destroy(){Y(this,1),this.$destroy=s}$on(t,e){if(!k(e))return s;const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const o=n.indexOf(e);o!==-1&&n.splice(o,1)}}$set(t){this.$$set&&!B(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});function et(t){let e,n,o,u,l,i,y;return{c(){e=V("button"),n=g("count is "),o=g(t[1]),u=D(),l=g(t[0]),this.c=s},m(c,r){T(c,e,r),p(e,n),p(e,o),p(e,u),p(e,l),i||(y=F(e,"click",t[2]),i=!0)},p(c,[r]){r&2&&L(o,c[1]),r&1&&L(l,c[0])},i:s,o:s,d(c){c&&S(e),i=!1,y()}}}function nt(t,e,n){let o=0,{url:u}=e;const l=()=>{n(1,o+=1)};return t.$$set=i=>{"url"in i&&n(0,u=i.url)},t.$$.update=()=>{t.$$.dirty&1&&u&&fetch(u).then(i=>i.json()).then(i=>console.log(i)),t.$$.dirty&2&&o>10&&(alert("不能超过10次"),n(1,o=10))},[u,o,l]}class H extends O{constructor(e){super(),this.shadowRoot.innerHTML="<style>button{color:aqua;font-size:20px;font-weight:500;padding:8px 12px;border:1px solid #ddd;margin:auto}</style>",tt(this,{target:this.shadowRoot,props:I(this.attributes),customElement:!0},nt,et,z,{url:0},null),e&&(e.target&&T(e.target,this,e.anchor),e.props&&(this.$set(e.props),b()))}static get observedAttributes(){return["url"]}get url(){return this.$$.ctx[0]}set url(e){this.$$set({url:e}),b()}}customElements.define("my-custom-counter",H),a.Counter=H,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});