ncounter/dist/index.js
2024-04-12 12:32:14 -04:00

1 line
No EOL
7.9 KiB
JavaScript

!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";function r(){}n.r(e);function o(t){return t()}function u(){return Object.create(null)}function c(t){t.forEach(o)}function i(t){return"function"==typeof t}function l(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}new Set;function a(t,e){t.appendChild(e)}function s(t,e,n){t.insertBefore(e,n||null)}function f(t){t.parentNode.removeChild(t)}function d(t){return document.createElement(t)}function m(t){return document.createTextNode(t)}function p(){return m(" ")}function $(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function v(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function h(t,e){e=""+e,t.data!==e&&(t.data=e)}let g;function x(t){g=t}const y=[],b=Promise.resolve();let _=!1;const k=[],C=[],w=[];function O(){_||(_=!0,b.then(E))}function j(t){C.push(t)}function E(){const t=new Set;do{for(;y.length;){const t=y.shift();x(t),T(t.$$)}for(;k.length;)k.shift()();for(;C.length;){const e=C.pop();t.has(e)||(e(),t.add(e))}}while(y.length);for(;w.length;)w.pop()();_=!1}function T(t){t.fragment&&(t.update(t.dirty),c(t.before_render),t.fragment.p(t.dirty,t.ctx),t.dirty=null,t.after_render.forEach(j))}let M;function S(){M={remaining:0,callbacks:[]}}function P(){M.remaining||c(M.callbacks)}function V(t){M.callbacks.push(t)}let q;function I(t,e,n){const{fragment:r,on_mount:u,on_destroy:l,after_render:a}=t.$$;r.m(e,n),j(()=>{const e=u.map(o).filter(i);l?l.push(...e):c(e),t.$$.on_mount=[]}),a.forEach(j)}function L(t,e){t.$$&&(c(t.$$.on_destroy),t.$$.fragment.d(e),t.$$.on_destroy=t.$$.fragment=null,t.$$.ctx={})}function N(t,e,n,o,i,l){const a=g;x(t);const s=e.props||{},f=t.$$={fragment:null,ctx:null,props:l,update:r,not_equal:i,bound:u(),on_mount:[],on_destroy:[],before_render:[],after_render:[],context:new Map(a?a.$$.context:[]),callbacks:u(),dirty:null};let d=!1;var m;f.ctx=n?n(t,s,(e,n)=>{f.ctx&&i(f.ctx[e],f.ctx[e]=n)&&(f.bound[e]&&f.bound[e](n),d&&function(t,e){t.$$.dirty||(y.push(t),O(),t.$$.dirty=u()),t.$$.dirty[e]=!0}(t,e))}):s,f.update(),d=!0,c(f.before_render),f.fragment=o(f.ctx),e.target&&(e.hydrate?f.fragment.l((m=e.target,Array.from(m.childNodes))):f.fragment.c(),e.intro&&t.$$.fragment.i&&t.$$.fragment.i(),I(t,e.target,e.anchor),E()),x(a)}"undefined"!=typeof HTMLElement&&(q=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){for(const t in this.$$.slotted)this.appendChild(this.$$.slotted[t])}attributeChangedCallback(t,e,n){this[t]=n}$destroy(){L(this,!0),this.$destroy=r}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(){}});class A{$destroy(){L(this,!0),this.$destroy=r}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(){}}function B(t){var e,n,o,u=t.max-t.value;return{c(){e=d("span"),n=m(u),o=m(" remaining")},m(t,r){s(t,e,r),a(e,n),a(e,o)},p(t,e){(t.max||t.value)&&u!==(u=e.max-e.value)&&h(n,u)},i:r,o:r,d(t){t&&f(e)}}}function H(t,e,n){let{value:r,max:o}=e;return t.$set=(t=>{"value"in t&&n("value",r=t.value),"max"in t&&n("max",o=t.max)}),{value:r,max:o}}var K=class extends A{constructor(t){super(),N(this,t,H,B,l,["value","max"])}};function R(t){var e,n=new K({props:{value:t.counter.value,max:t.counter.max}});return{c(){n.$$.fragment.c()},m(t,r){I(n,t,r),e=!0},p(t,e){var r={};t.counter&&(r.value=e.counter.value),t.counter&&(r.max=e.counter.max),n.$set(r)},i(t){e||(n.$$.fragment.i(t),e=!0)},o(t){n.$$.fragment.o(t),e=!1},d(t){n.$destroy(t)}}}function z(t){var e,n;return{c(){(e=d("button")).textContent="+",v(e,"}",""),n=$(e,"click",t.click_handler)},m(t,n){s(t,e,n)},p:r,d(t){t&&f(e),n()}}}function D(t){var e,n,r,o;return{c(){e=d("input"),(r=d("button")).textContent="OK",v(e,"type","number"),o=[$(e,"input",t.input_input_handler),$(r,"click",t.increment)]},m(o,u){s(o,e,u),e.value=t.incrementValue,n=function(t){t.focus()}.call(null,e)||{},s(o,r,u)},p(t,n){t.incrementValue&&(e.value=n.incrementValue)},d(t){t&&f(e),n&&"function"==typeof n.destroy&&n.destroy(),t&&f(r),c(o)}}}function F(t){var e;return{c(){(e=d("div")).textContent="icon"},m(t,n){s(t,e,n)},d(t){t&&f(e)}}}function G(t){var e,n,r,o,u,c,i,l,v,g,x,y,b,_=t.counter.title,k=t.counter.value,C=t.counter.max&&R(t);function w(t){return t.showIncrement?D:t.counter.isClickCounter?void 0:z}var O=w(t),j=O&&O(t),E=t.counter.isClickCounter&&F();return{c(){e=d("div"),n=d("header"),r=m(_),o=p(),u=d("span"),c=m(k),i=p(),C&&C.c(),l=p(),j&&j.c(),v=p(),(g=d("button")).textContent="Reset",x=p(),E&&E.c(),e.className="counter svelte-16e2o0q",b=$(g,"click",t.reset)},m(t,f){s(t,e,f),a(e,n),a(n,r),a(e,o),a(e,u),a(u,c),a(e,i),C&&C.m(e,null),a(e,l),j&&j.m(e,null),a(e,v),a(e,g),a(e,x),E&&E.m(e,null),y=!0},p(t,n){y&&!t.counter||_===(_=n.counter.title)||h(r,_),y&&!t.counter||k===(k=n.counter.value)||h(c,k),n.counter.max?C?(C.p(t,n),C.i(1)):((C=R(n)).c(),C.i(1),C.m(e,l)):C&&(S(),V(()=>{C.d(1),C=null}),C.o(1),P()),O===(O=w(n))&&j?j.p(t,n):(j&&j.d(1),(j=O&&O(n))&&(j.c(),j.m(e,v))),n.counter.isClickCounter?E||((E=F()).c(),E.m(e,null)):E&&(E.d(1),E=null)},i(t){y||(C&&C.i(),y=!0)},o(t){C&&C.o(),y=!1},d(t){t&&f(e),C&&C.d(),j&&j.d(),E&&E.d(),b()}}}function J(t,e,n){let r,o,{counter:u}=e;return t.$set=(t=>{"counter"in t&&n("counter",u=t.counter)}),{counter:u,incrementValue:r,showIncrement:o,increment:function(){u.value+=r,n("counter",u),n("showIncrement",o=!1),n("incrementValue",r=null)},reset:function(){u.value=0,n("counter",u)},input_input_handler:function(){var t;t=this.value,n("incrementValue",r=""===t?void 0:+t)},click_handler:function(){n("showIncrement",o=!0)}}}var Q=class extends A{constructor(t){var e;super(),document.getElementById("svelte-16e2o0q-style")||((e=d("style")).id="svelte-16e2o0q-style",e.textContent=".counter.svelte-16e2o0q{border:1px solid black;margin-bottom:5px}",a(document.head,e)),N(this,t,J,G,l,["counter"])}};function U(t,e,n){const r=Object.create(t);return r.counter=e[n],r}function W(t){var e,n=new Q({props:{counter:t.counter}});return{c(){n.$$.fragment.c()},m(t,r){I(n,t,r),e=!0},p(t,e){var r={};t.counters&&(r.counter=e.counter),n.$set(r)},i(t){e||(n.$$.fragment.i(t),e=!0)},o(t){n.$$.fragment.o(t),e=!1},d(t){n.$destroy(t)}}}function X(t){for(var e,n,r=t.counters,o=[],u=0;u<r.length;u+=1)o[u]=W(U(t,r,u));function c(t,e,n){o[t]&&(e&&V(()=>{o[t].d(e),o[t]=null}),o[t].o(n))}return{c(){e=d("div");for(var t=0;t<o.length;t+=1)o[t].c()},m(t,r){s(t,e,r);for(var u=0;u<o.length;u+=1)o[u].m(e,null);n=!0},p(t,n){if(t.counters){r=n.counters;for(var u=0;u<r.length;u+=1){const c=U(n,r,u);o[u]?(o[u].p(t,c),o[u].i(1)):(o[u]=W(c),o[u].c(),o[u].i(1),o[u].m(e,null))}for(S();u<o.length;u+=1)c(u,1,1);P()}},i(t){if(!n){for(var e=0;e<r.length;e+=1)o[e].i();n=!0}},o(t){o=o.filter(Boolean);for(let t=0;t<o.length;t+=1)c(t,0);n=!1},d(t){t&&f(e),function(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}(o,t)}}}function Y(t){return{counters:[{title:"Test 1",value:0},{title:"Test 2",value:10},{title:"Max Test",value:0,max:100},{title:"Click Test",value:0,isClickCounter:!0}]}}new class extends A{constructor(t){super(),N(this,t,Y,X,l,[])}}({target:document.body})}]);