mi-element 0.6.0 → 0.6.1
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/case.js +1 -1
- package/dist/context.js +2 -2
- package/dist/element.js +12 -6
- package/dist/escape.js +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/styling.js +3 -3
- package/docs/context.md +136 -0
- package/docs/controller.md +82 -0
- package/docs/element.md +394 -0
- package/docs/reactivity.md +41 -0
- package/docs/signal.md +192 -0
- package/docs/store.md +65 -0
- package/docs/styling.md +77 -0
- package/package.json +5 -4
- package/src/element.js +15 -14
- package/types/element.d.ts +12 -1
package/dist/case.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const camelToKebabCase = (str = "") => str.replace(/([A-Z])/g, (
|
|
1
|
+
const camelToKebabCase = (str = "") => str.replace(/([A-Z])/g, (_, m) => `-${m.toLowerCase()}`), kebabToCamelCase = (str = "") => str.toLowerCase().replace(/[-_]\w/g, m => m[1].toUpperCase());
|
|
2
2
|
|
|
3
3
|
export { camelToKebabCase, kebabToCamelCase };
|
package/dist/context.js
CHANGED
|
@@ -20,10 +20,10 @@ class ContextProvider {
|
|
|
20
20
|
onContextRequest=ev => {
|
|
21
21
|
if (ev.context !== this.context) return;
|
|
22
22
|
let unsubscribe;
|
|
23
|
-
ev.stopPropagation(), ev.subscribe && (unsubscribe = effect((
|
|
23
|
+
ev.stopPropagation(), ev.subscribe && (unsubscribe = effect(() => {
|
|
24
24
|
const value = this.get();
|
|
25
25
|
unsubscribe && ev.callback(value, unsubscribe);
|
|
26
|
-
}))
|
|
26
|
+
})), ev.callback(this.get(), unsubscribe);
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
package/dist/element.js
CHANGED
|
@@ -13,6 +13,12 @@ class MiElement extends HTMLElement {
|
|
|
13
13
|
mode: 'open'
|
|
14
14
|
};
|
|
15
15
|
static template;
|
|
16
|
+
static get attributes() {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
static get properties() {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
16
22
|
constructor() {
|
|
17
23
|
super(), this.#observedAttributes(this.constructor.attributes), this.#observedProperties(this.constructor.properties);
|
|
18
24
|
}
|
|
@@ -46,13 +52,13 @@ class MiElement extends HTMLElement {
|
|
|
46
52
|
return this.#types.get(name);
|
|
47
53
|
}
|
|
48
54
|
connectedCallback() {
|
|
49
|
-
this.#controllers.forEach(
|
|
55
|
+
this.#controllers.forEach(controller => controller.hostConnected?.());
|
|
50
56
|
const {shadowRootOptions: shadowRootOptions, template: template} = this.constructor;
|
|
51
57
|
this.renderRoot = shadowRootOptions ? this.shadowRoot ?? this.attachShadow(shadowRootOptions) : this,
|
|
52
58
|
this.addTemplate(template), this.render(), this.requestUpdate();
|
|
53
59
|
}
|
|
54
60
|
disconnectedCallback() {
|
|
55
|
-
this.#disposers.forEach(
|
|
61
|
+
this.#disposers.forEach(remover => remover()), this.#controllers.forEach(controller => controller.hostDisconnected?.());
|
|
56
62
|
}
|
|
57
63
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
58
64
|
const attr = this.#getName(name), type = this.#getType(attr);
|
|
@@ -70,9 +76,9 @@ class MiElement extends HTMLElement {
|
|
|
70
76
|
return !0;
|
|
71
77
|
}
|
|
72
78
|
requestUpdate() {
|
|
73
|
-
this.isConnected && requestAnimationFrame((
|
|
79
|
+
this.isConnected && requestAnimationFrame(() => {
|
|
74
80
|
this.shouldUpdate(this.#changedAttr) && this.update(this.#changedAttr), this.#changedAttr = {};
|
|
75
|
-
})
|
|
81
|
+
});
|
|
76
82
|
}
|
|
77
83
|
addTemplate(template) {
|
|
78
84
|
if (!(template instanceof HTMLTemplateElement)) throw new Error('template is not a HTMLTemplateElement');
|
|
@@ -81,7 +87,7 @@ class MiElement extends HTMLElement {
|
|
|
81
87
|
render() {}
|
|
82
88
|
update(_changedAttributes) {}
|
|
83
89
|
on(eventName, listener, node = this) {
|
|
84
|
-
node.addEventListener(eventName, listener), this.#disposers.add((
|
|
90
|
+
node.addEventListener(eventName, listener), this.#disposers.add(() => node.removeEventListener(eventName, listener));
|
|
85
91
|
}
|
|
86
92
|
once(eventName, listener, node = this) {
|
|
87
93
|
node.addEventListener(eventName, listener, {
|
|
@@ -103,7 +109,7 @@ class MiElement extends HTMLElement {
|
|
|
103
109
|
}
|
|
104
110
|
|
|
105
111
|
const define = (name, element, options) => {
|
|
106
|
-
element.observedAttributes = (element.observedAttributes || Object.keys(element.attributes || [])).map(
|
|
112
|
+
element.observedAttributes = (element.observedAttributes || Object.keys(element.attributes || [])).map(attr => attr.toLowerCase()),
|
|
107
113
|
renderTemplate(element), window.customElements.define(name, element, options);
|
|
108
114
|
}, renderTemplate = element => {
|
|
109
115
|
if (element.template instanceof HTMLTemplateElement) return;
|
package/dist/escape.js
CHANGED
|
@@ -6,7 +6,7 @@ const unsafeHtml = str => new UnsafeHtml(str), escMap = {
|
|
|
6
6
|
'>': '>',
|
|
7
7
|
"'": ''',
|
|
8
8
|
'"': '"'
|
|
9
|
-
}, escHtml = string => string instanceof UnsafeHtml ? string : ('' + string).replace(/&/g, '&').replace(/[&<>'"]/g,
|
|
9
|
+
}, escHtml = string => string instanceof UnsafeHtml ? string : ('' + string).replace(/&/g, '&').replace(/[&<>'"]/g, tag => escMap[tag]), esc = (strings, ...vars) => unsafeHtml(String.raw({
|
|
10
10
|
raw: strings
|
|
11
11
|
}, ...vars.map(escHtml)));
|
|
12
12
|
|
package/dist/index.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const t=[];class e extends EventTarget{#t;#e;constructor(t,e){super();const{equals:s}=e||{};this.#t=t,this.#e=s??((t,e)=>t===e)}get value(){return this.get()}set value(t){this.set(t)}get(){const e=t[t.length-1];return e&&e.add(this),this.#t}set(t){this.#e(this.#t,t)||(this.#t=t,this.dispatchEvent(new CustomEvent("signal")))}}const s=(t,s)=>t instanceof e?t:new e(t,s);function n(e){const s=new Set;t.push(s);try{e()}finally{t.pop()}for(const t of s)t.addEventListener("signal",e);return()=>{for(const t of s)t.removeEventListener("signal",e)}}class r{#s;constructor(t){this.#s=new e,n((()=>this.#s.set(t())))}get(){return this.#s.get()}}var o={State:e,Computed:r,createSignal:s,effect:n};const i="context-request";class a{constructor(t,e,n){this.host=t,this.context=e,this.state=s(n),this.host.addController?.(this)}hostConnected(){this.host.addEventListener(i,this.onContextRequest)}hostDisconnected(){this.host.removeEventListener(i,this.onContextRequest)}set(t){this.state.set(t)}get(){return this.state.get()}onContextRequest=t=>{if(t.context!==this.context)return;let e;t.stopPropagation(),t.subscribe&&(e=n((()=>{const s=this.get();e&&t.callback(s,e)}))),t.callback(this.get(),e)}}class c extends Event{constructor(t,e,s){super(i,{bubbles:!0,composed:!0}),this.context=t,this.callback=e,this.subscribe=s}}class l{constructor(t,e,s){const{subscribe:n=!1,validate:r=()=>!0}=s||{};this.host=t,this.context=e,this.subscribe=!!n,this.validate=r,this.value=void 0,this.unsubscribe=void 0,this.host.addController?.(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new c(this.context,this._callback.bind(this),this.subscribe))}_callback(t,e){e&&(this.subscribe?this.unsubscribe&&(this.unsubscribe!==e&&this.unsubscribe(),this.unsubscribe=e):e()),this.validate(t)&&(this.value=t,this.host.requestUpdate())}}const h=(t="")=>t.replace(/([A-Z])/g,((t,e)=>`-${e.toLowerCase()}`)),u=(t="")=>t.toLowerCase().replace(/[-_]\w/g,(t=>t[1].toUpperCase()));class d extends HTMLElement{#n={};#r=new Map;#o=new Map;#i=new Set;#a=new Set;#c={};static shadowRootOptions={mode:"open"};static template;constructor(){super(),this.#l(this.constructor.attributes),this.#h(this.constructor.properties)}#u(t,e){this.#n[t]=s(e),Object.defineProperty(this,t,{enumerable:!0,get(){return this.#n[t].get()},set(e){const s=this.#n[t].get();s!==e&&(this.#n[t].set(e),this.#c[t]=s,this.requestUpdate())}})}#l(t={}){for(const[e,s]of Object.entries(t)){const t=b(s);this.#o.set(e,t.type),this.#r.set(e.toLowerCase(),e),this.#r.set(h(e),e),this.#u(e,t.value)}}#h(t={}){for(const[e,s]of Object.entries(t))this.#r.has(e)||e in this.#n||this.#u(e,s)}#d(t){return this.#r.get(t)||t}#p(t){return this.#o.get(t)}connectedCallback(){this.#a.forEach((t=>t.hostConnected?.()));const{shadowRootOptions:t,template:e}=this.constructor;this.renderRoot=t?this.shadowRoot??this.attachShadow(t):this,this.addTemplate(e),this.render(),this.requestUpdate()}disconnectedCallback(){this.#i.forEach((t=>t())),this.#a.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){const n=this.#d(t),r=this.#p(n);this.#c[n]=this[n],this[n]=g(s,r),"Boolean"===r&&"false"===s&&this.removeAttribute(t),this.requestUpdate()}setAttribute(t,e){const s=this.#d(t);if(!(s in this.#n))return;const n=this.#p(s);"Boolean"===n?!0===e||""===e?super.setAttribute(t,""):super.removeAttribute(t):["String","Number"].includes(n??"")||!0===e?super.setAttribute(t,e):(this.#c[s]=this[s],this[s]=e,this.requestUpdate())}shouldUpdate(t){return!0}requestUpdate(){this.isConnected&&requestAnimationFrame((()=>{this.shouldUpdate(this.#c)&&this.update(this.#c),this.#c={}}))}addTemplate(t){if(!(t instanceof HTMLTemplateElement))throw new Error("template is not a HTMLTemplateElement");this.renderRoot.append(t.content.cloneNode(!0))}render(){}update(t){}on(t,e,s=this){s.addEventListener(t,e),this.#i.add((()=>s.removeEventListener(t,e)))}once(t,e,s=this){s.addEventListener(t,e,{once:!0})}dispose(...t){for(const e of t){if("function"!=typeof e)throw new TypeError("listener must be a function");this.#i.add(e)}}addController(t){this.#a.add(t),this.isConnected&&t.hostConnected?.()}removeController(t){this.#a.delete(t)}}const p=(t,e,s)=>{e.observedAttributes=(e.observedAttributes||Object.keys(e.attributes||[])).map((t=>t.toLowerCase())),f(e),window.customElements.define(t,e,s)},f=t=>{if(t.template instanceof HTMLTemplateElement)return;const e=document.createElement("template");e.innerHTML=t.template,t.template=e},b=t=>{switch(t){case Boolean:return{value:void 0,type:"Boolean"};case Number:return{value:void 0,type:"Number"};case String:return{value:void 0,type:"String"};default:return{value:t,type:toString.call(t).slice(8,-1)}}},g=(t,e)=>{switch(e){case"Number":return(t=>{const e=Number(t);return isNaN(e)?t:e})(t);case"Boolean":return"false"!==t&&(""===t||!!t)}return t};class m extends String{}const v=t=>new m(t),w={"&":"&","<":"<",">":">","'":"'",'"':"""},C=t=>t instanceof m?t:(""+t).replace(/&/g,"&").replace(/[&<>'"]/g,(t=>w[t])),y=(t,...e)=>v(String.raw({raw:t},...e.map(C)));function x(t){const e=t.querySelectorAll?.("[id]")||[],s={};for(const t of e)s[u(t.getAttribute("id")||t.nodeName.toLowerCase())]=t;return s}function A(t,e){const s={};for(const[n,r]of Object.entries(e))s[n]=t.querySelector?.(r);return s}class N extends e{constructor(t,e,s){super(e,s);for(const[e,s]of Object.entries(t))this[e]=t=>this.set(s(t)(this.get()))}}const S=t=>{const e=[];for(const[s,n]of Object.entries(t??{}))n&&e.push(s);return e.join(" ")},E=(t,e)=>{const{unit:s="px"}=e||{},n=[];for(const[e,r]of Object.entries(t??{})){if(null==r)continue;const t=Number.isFinite(r)?s:"";n.push(`${h(e)}:${r}${t}`)}return n.join(";")};let L=null;function k(t){t.adoptedStyleSheets.push(...(null===L&&(L=Array.from(document.styleSheets).map((({cssRules:t})=>{const e=new CSSStyleSheet,s=Array.from(t).map((t=>t.cssText)).join(" ");return e.replaceSync(s),e}))),L))}const{isArray:O}=Array,{getPrototypeOf:$,getOwnPropertyDescriptor:T}=Object,q=[],M=()=>document.createRange(),j=(t,e,s)=>(t.set(e,s),s),R=(t,e)=>e.reduceRight(W,t),W=(t,e)=>t.childNodes[e],{setPrototypeOf:B}=Object;let U;var D=(t,e,s)=>(U||(U=M()),s?U.setStartAfter(t):U.setStartBefore(t),U.setEndAfter(e),U.deleteContents(),t);const P=({firstChild:t,lastChild:e},s)=>D(t,e,s);let H=!1;const F=(t,e)=>H&&11===t.nodeType?1/e<0?e?P(t,!0):t.lastChild:e?t.valueOf():t.firstChild:t,_=t=>document.createComment(t);class z extends((t=>{function e(t){return B(t,new.target.prototype)}return e.prototype=t.prototype,e})(DocumentFragment)){#f=_("<>");#b=_("</>");#g=q;constructor(t){super(t),this.replaceChildren(this.#f,...t.childNodes,this.#b),H=!0}get firstChild(){return this.#f}get lastChild(){return this.#b}get parentNode(){return this.#f.parentNode}remove(){P(this,!1)}replaceWith(t){P(this,!0).replaceWith(t)}valueOf(){const{parentNode:t}=this;if(t===this)this.#g===q&&(this.#g=[...this.childNodes]);else{if(t){let{firstChild:t,lastChild:e}=this;for(this.#g=[t];t!==e;)this.#g.push(t=t.nextSibling)}this.replaceChildren(...this.#g)}return this}}const Z=(t,e,s)=>t.setAttribute(e,s),G=(t,e)=>t.removeAttribute(e);let V;const I=(t,e,s)=>{s=s.slice(1),V||(V=new WeakMap);const n=V.get(t)||j(V,t,{});let r=n[s];return r&&r[0]&&t.removeEventListener(s,...r),r=O(e)?e:[e,!1],n[s]=r,r[0]&&t.addEventListener(s,...r),e},J=(t,e)=>{const{t:s,n:n}=t;let r=!1;switch(typeof e){case"object":if(null!==e){(n||s).replaceWith(t.n=e.valueOf());break}case"undefined":r=!0;default:s.data=r?"":e,n&&(t.n=null,n.replaceWith(s))}return e},K=(t,e,s)=>t[s]=e,Q=(t,e,s)=>K(t,e,s.slice(1)),X=(t,e,s)=>null==e?(G(t,s),e):K(t,e,s),Y=(t,e)=>("function"==typeof e?e(t):e.current=t,e),tt=(t,e,s)=>(null==e?G(t,s):Z(t,s,e),e),et=(t,e,s)=>(t.toggleAttribute(s.slice(1),e),e),st=(t,e,s)=>{const{length:n}=e;if(t.data=`[${n}]`,n)return((t,e,s,n,r)=>{const o=s.length;let i=e.length,a=o,c=0,l=0,h=null;for(;c<i||l<a;)if(i===c){const e=a<o?l?n(s[l-1],-0).nextSibling:n(s[a],0):r;for(;l<a;)t.insertBefore(n(s[l++],1),e)}else if(a===l)for(;c<i;)h&&h.has(e[c])||t.removeChild(n(e[c],-1)),c++;else if(e[c]===s[l])c++,l++;else if(e[i-1]===s[a-1])i--,a--;else if(e[c]===s[a-1]&&s[l]===e[i-1]){const r=n(e[--i],-0).nextSibling;t.insertBefore(n(s[l++],1),n(e[c++],-0).nextSibling),t.insertBefore(n(s[--a],1),r),e[i]=s[a]}else{if(!h){h=new Map;let t=l;for(;t<a;)h.set(s[t],t++)}if(h.has(e[c])){const r=h.get(e[c]);if(l<r&&r<a){let o=c,u=1;for(;++o<i&&o<a&&h.get(e[o])===r+u;)u++;if(u>r-l){const o=n(e[c],0);for(;l<r;)t.insertBefore(n(s[l++],1),o)}else t.replaceChild(n(s[l++],1),n(e[c++],-1))}else c++}else t.removeChild(n(e[c++],-1))}return s})(t.parentNode,s,e,F,t);switch(s.length){case 1:s[0].remove();case 0:break;default:D(F(s[0],0),F(s.at(-1),-0),!1)}return q},nt=new Map([["aria",(t,e)=>{for(const s in e){const n=e[s],r="role"===s?s:`aria-${s}`;null==n?G(t,r):Z(t,r,n)}return e}],["class",(t,e)=>X(t,e,null==e?"class":"className")],["data",(t,e)=>{const{dataset:s}=t;for(const t in e)null==e[t]?delete s[t]:s[t]=e[t];return e}],["ref",Y],["style",(t,e)=>null==e?X(t,e,"style"):K(t.style,e,"cssText")]]),rt=(t,e,s)=>{switch(e[0]){case".":return Q;case"?":return et;case"@":return I;default:return s||"ownerSVGElement"in t?"ref"===e?Y:tt:nt.get(e)||(e in t?e.startsWith("on")?K:((t,e)=>{let s;do{s=T(t,e)}while(!s&&(t=$(t)));return s})(t,e)?.set?X:tt:tt)}},ot=(t,e)=>(t.textContent=null==e?"":e,e),it=(t,e,s)=>({a:t,b:e,c:s}),at=()=>it(null,null,q);var ct=t=>(e,s)=>{const{a:n,b:r,c:o}=t(e,s),i=document.importNode(n,!0);let a=q;if(r!==q){a=[];for(let t,e,s=0;s<r.length;s++){const{a:n,b:o,c:d}=r[s],p=n===e?t:t=R(i,e=n);a[s]=(c=o,l=p,h=d,u=o===st?[]:o===J?at():null,{v:q,u:c,t:l,n:h,c:u})}}var c,l,h,u;return((t,e)=>({b:t,c:e}))(o?i.firstChild:new z(i),a)};const lt=/^(?:plaintext|script|style|textarea|title|xmp)$/i,ht=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ut=/<([a-zA-Z0-9]+[a-zA-Z0-9:._-]*)([^>]*?)(\/?)>/g,dt=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,pt=/[\x01\x02]/g;let ft,bt,gt=document.createElement("template");var mt=(t,e)=>{if(e)return ft||(ft=document.createElementNS("http://www.w3.org/2000/svg","svg"),bt=M(),bt.selectNodeContents(ft)),bt.createContextualFragment(t);gt.innerHTML=t;const{content:s}=gt;return gt=gt.cloneNode(!1),s};const vt=t=>{const e=[];let s;for(;s=t.parentNode;)e.push(e.indexOf.call(s.childNodes,t)),t=s;return e},wt=()=>document.createTextNode(""),Ct=new WeakMap,yt="isµ";var xt=t=>(e,s)=>Ct.get(e)||((t,e,s)=>{const n=mt(((t,e,s)=>{let n=0;return t.join("").trim().replace(ut,((t,e,n,r)=>`<${e}${n.replace(dt,"=$2$1").trimEnd()}${r?s||ht.test(e)?" /":`></${e}`:""}>`)).replace(pt,(t=>""===t?`\x3c!--${e+n++}--\x3e`:e+n++))})(t,yt,s),s),{length:r}=t;let o=q;if(r>1){const t=[],i=document.createTreeWalker(n,129);let a=0,c=`${yt}${a++}`;for(o=[];a<r;){const n=i.nextNode();if(8===n.nodeType){if(n.data===c){const s=O(e[a-1])?st:J;s===J&&t.push(n),o.push(it(vt(n),s,null)),c=`${yt}${a++}`}}else{let t;for(;n.hasAttribute(c);){t||(t=vt(n));const e=n.getAttribute(c);o.push(it(t,rt(n,e,s),e)),G(n,c),c=`${yt}${a++}`}!s&<.test(n.localName)&&n.textContent.trim()===`\x3c!--${c}--\x3e`&&(o.push(it(t||vt(n),ot,null)),c=`${yt}${a++}`)}}for(a=0;a<t.length;a++)t[a].replaceWith(wt())}const{childNodes:i}=n;let{length:a}=i;return a<1?(a=1,n.appendChild(wt())):1===a&&1!==r&&1!==i[0].nodeType&&(a=0),j(Ct,t,it(n,o,1===a))})(e,s,t);const At=ct(xt(!1)),Nt=ct(xt(!0)),St=(t,{s:e,t:s,v:n})=>{if(t.a!==s){const{b:r,c:o}=(e?Nt:At)(s,n);t.a=s,t.b=r,t.c=o}for(let{c:e}=t,s=0;s<e.length;s++){const t=n[s],r=e[s];switch(r.u){case st:r.v=st(r.t,Et(r.c,t),r.v);break;case J:const e=t instanceof Lt?St(r.c||(r.c=at()),t):(r.c=null,t);e!==r.v&&(r.v=J(r,e));break;default:t!==r.v&&(r.v=r.u(r.t,t,r.n,r.v))}}return t.b},Et=(t,e)=>{let s=0,{length:n}=e;for(n<t.length&&t.splice(n);s<n;s++){const n=e[s];n instanceof Lt?e[s]=St(t[s]||(t[s]=at()),n):t[s]=null}return e};class Lt{constructor(t,e,s){this.s=t,this.t=e,this.v=s}toDOM(t=at()){return St(t,this)}}
|
|
2
|
-
/*! (c) Andrea Giammarchi - MIT */const
|
|
3
|
-
/*! (c) Andrea Giammarchi - MIT */const
|
|
1
|
+
const t=[];class e extends EventTarget{#t;#e;constructor(t,e){super();const{equals:s}=e||{};this.#t=t,this.#e=s??((t,e)=>t===e)}get value(){return this.get()}set value(t){this.set(t)}get(){const e=t[t.length-1];return e&&e.add(this),this.#t}set(t){this.#e(this.#t,t)||(this.#t=t,this.dispatchEvent(new CustomEvent("signal")))}}const s=(t,s)=>t instanceof e?t:new e(t,s);function n(e){const s=new Set;t.push(s);try{e()}finally{t.pop()}for(const t of s)t.addEventListener("signal",e);return()=>{for(const t of s)t.removeEventListener("signal",e)}}class r{#s;constructor(t){this.#s=new e,n(()=>this.#s.set(t()))}get(){return this.#s.get()}}var o={State:e,Computed:r,createSignal:s,effect:n};const i="context-request";class a{constructor(t,e,n){this.host=t,this.context=e,this.state=s(n),this.host.addController?.(this)}hostConnected(){this.host.addEventListener(i,this.onContextRequest)}hostDisconnected(){this.host.removeEventListener(i,this.onContextRequest)}set(t){this.state.set(t)}get(){return this.state.get()}onContextRequest=t=>{if(t.context!==this.context)return;let e;t.stopPropagation(),t.subscribe&&(e=n(()=>{const s=this.get();e&&t.callback(s,e)})),t.callback(this.get(),e)}}class c extends Event{constructor(t,e,s){super(i,{bubbles:!0,composed:!0}),this.context=t,this.callback=e,this.subscribe=s}}class l{constructor(t,e,s){const{subscribe:n=!1,validate:r=()=>!0}=s||{};this.host=t,this.context=e,this.subscribe=!!n,this.validate=r,this.value=void 0,this.unsubscribe=void 0,this.host.addController?.(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new c(this.context,this._callback.bind(this),this.subscribe))}_callback(t,e){e&&(this.subscribe?this.unsubscribe&&(this.unsubscribe!==e&&this.unsubscribe(),this.unsubscribe=e):e()),this.validate(t)&&(this.value=t,this.host.requestUpdate())}}const h=(t="")=>t.replace(/([A-Z])/g,(t,e)=>`-${e.toLowerCase()}`),u=(t="")=>t.toLowerCase().replace(/[-_]\w/g,t=>t[1].toUpperCase());class d extends HTMLElement{#n={};#r=new Map;#o=new Map;#i=new Set;#a=new Set;#c={};static shadowRootOptions={mode:"open"};static template;static get attributes(){return{}}static get properties(){return{}}constructor(){super(),this.#l(this.constructor.attributes),this.#h(this.constructor.properties)}#u(t,e){this.#n[t]=s(e),Object.defineProperty(this,t,{enumerable:!0,get(){return this.#n[t].get()},set(e){const s=this.#n[t].get();s!==e&&(this.#n[t].set(e),this.#c[t]=s,this.requestUpdate())}})}#l(t={}){for(const[e,s]of Object.entries(t)){const t=b(s);this.#o.set(e,t.type),this.#r.set(e.toLowerCase(),e),this.#r.set(h(e),e),this.#u(e,t.value)}}#h(t={}){for(const[e,s]of Object.entries(t))this.#r.has(e)||e in this.#n||this.#u(e,s)}#d(t){return this.#r.get(t)||t}#p(t){return this.#o.get(t)}connectedCallback(){this.#a.forEach(t=>t.hostConnected?.());const{shadowRootOptions:t,template:e}=this.constructor;this.renderRoot=t?this.shadowRoot??this.attachShadow(t):this,this.addTemplate(e),this.render(),this.requestUpdate()}disconnectedCallback(){this.#i.forEach(t=>t()),this.#a.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){const n=this.#d(t),r=this.#p(n);this.#c[n]=this[n],this[n]=g(s,r),"Boolean"===r&&"false"===s&&this.removeAttribute(t),this.requestUpdate()}setAttribute(t,e){const s=this.#d(t);if(!(s in this.#n))return;const n=this.#p(s);"Boolean"===n?!0===e||""===e?super.setAttribute(t,""):super.removeAttribute(t):["String","Number"].includes(n??"")||!0===e?super.setAttribute(t,e):(this.#c[s]=this[s],this[s]=e,this.requestUpdate())}shouldUpdate(t){return!0}requestUpdate(){this.isConnected&&requestAnimationFrame(()=>{this.shouldUpdate(this.#c)&&this.update(this.#c),this.#c={}})}addTemplate(t){if(!(t instanceof HTMLTemplateElement))throw new Error("template is not a HTMLTemplateElement");this.renderRoot.append(t.content.cloneNode(!0))}render(){}update(t){}on(t,e,s=this){s.addEventListener(t,e),this.#i.add(()=>s.removeEventListener(t,e))}once(t,e,s=this){s.addEventListener(t,e,{once:!0})}dispose(...t){for(const e of t){if("function"!=typeof e)throw new TypeError("listener must be a function");this.#i.add(e)}}addController(t){this.#a.add(t),this.isConnected&&t.hostConnected?.()}removeController(t){this.#a.delete(t)}}const p=(t,e,s)=>{e.observedAttributes=(e.observedAttributes||Object.keys(e.attributes||[])).map(t=>t.toLowerCase()),f(e),window.customElements.define(t,e,s)},f=t=>{if(t.template instanceof HTMLTemplateElement)return;const e=document.createElement("template");e.innerHTML=t.template,t.template=e},b=t=>{switch(t){case Boolean:return{value:void 0,type:"Boolean"};case Number:return{value:void 0,type:"Number"};case String:return{value:void 0,type:"String"};default:return{value:t,type:toString.call(t).slice(8,-1)}}},g=(t,e)=>{switch(e){case"Number":return(t=>{const e=Number(t);return isNaN(e)?t:e})(t);case"Boolean":return"false"!==t&&(""===t||!!t)}return t};class m extends String{}const v=t=>new m(t),w={"&":"&","<":"<",">":">","'":"'",'"':"""},C=t=>t instanceof m?t:(""+t).replace(/&/g,"&").replace(/[&<>'"]/g,t=>w[t]),y=(t,...e)=>v(String.raw({raw:t},...e.map(C)));function x(t){const e=t.querySelectorAll?.("[id]")||[],s={};for(const t of e)s[u(t.getAttribute("id")||t.nodeName.toLowerCase())]=t;return s}function A(t,e){const s={};for(const[n,r]of Object.entries(e))s[n]=t.querySelector?.(r);return s}class N extends e{constructor(t,e,s){super(e,s);for(const[e,s]of Object.entries(t))this[e]=t=>this.set(s(t)(this.get()))}}const S=t=>{const e=[];for(const[s,n]of Object.entries(t??{}))n&&e.push(s);return e.join(" ")},E=(t,e)=>{const{unit:s="px"}=e||{},n=[];for(const[e,r]of Object.entries(t??{})){if(null==r)continue;const t=Number.isFinite(r)?s:"";n.push(`${h(e)}:${r}${t}`)}return n.join(";")};let L=null;function k(t){t.adoptedStyleSheets.push(...(null===L&&(L=Array.from(document.styleSheets).map(({cssRules:t})=>{const e=new CSSStyleSheet,s=Array.from(t).map(t=>t.cssText).join(" ");return e.replaceSync(s),e})),L))}const{isArray:O}=Array,{getPrototypeOf:$,getOwnPropertyDescriptor:T}=Object,q=[],M=()=>document.createRange(),j=(t,e,s)=>(t.set(e,s),s),R=(t,e)=>e.reduceRight(W,t),W=(t,e)=>t.childNodes[e],{setPrototypeOf:B}=Object;let U;var D=(t,e,s)=>(U||(U=M()),s?U.setStartAfter(t):U.setStartBefore(t),U.setEndAfter(e),U.deleteContents(),t);const P=({firstChild:t,lastChild:e},s)=>D(t,e,s);let H=!1;const F=(t,e)=>H&&11===t.nodeType?1/e<0?e?P(t,!0):t.lastChild:e?t.valueOf():t.firstChild:t,_=t=>document.createComment(t);class z extends((t=>{function e(t){return B(t,new.target.prototype)}return e.prototype=t.prototype,e})(DocumentFragment)){#f=_("<>");#b=_("</>");#g=q;constructor(t){super(t),this.replaceChildren(this.#f,...t.childNodes,this.#b),H=!0}get firstChild(){return this.#f}get lastChild(){return this.#b}get parentNode(){return this.#f.parentNode}remove(){P(this,!1)}replaceWith(t){P(this,!0).replaceWith(t)}valueOf(){const{parentNode:t}=this;if(t===this)this.#g===q&&(this.#g=[...this.childNodes]);else{if(t){let{firstChild:t,lastChild:e}=this;for(this.#g=[t];t!==e;)this.#g.push(t=t.nextSibling)}this.replaceChildren(...this.#g)}return this}}const Z=(t,e,s)=>t.setAttribute(e,s),G=(t,e)=>t.removeAttribute(e);let V;const I=(t,e,s)=>{s=s.slice(1),V||(V=new WeakMap);const n=V.get(t)||j(V,t,{});let r=n[s];return r&&r[0]&&t.removeEventListener(s,...r),r=O(e)?e:[e,!1],n[s]=r,r[0]&&t.addEventListener(s,...r),e},J=(t,e)=>{const{t:s,n:n}=t;let r=!1;switch(typeof e){case"object":if(null!==e){(n||s).replaceWith(t.n=e.valueOf());break}case"undefined":r=!0;default:s.data=r?"":e,n&&(t.n=null,n.replaceWith(s))}return e},K=(t,e,s)=>t[s]=e,Q=(t,e,s)=>K(t,e,s.slice(1)),X=(t,e,s)=>null==e?(G(t,s),e):K(t,e,s),Y=(t,e)=>("function"==typeof e?e(t):e.current=t,e),tt=(t,e,s)=>(null==e?G(t,s):Z(t,s,e),e),et=(t,e,s)=>(t.toggleAttribute(s.slice(1),e),e),st=(t,e,s)=>{const{length:n}=e;if(t.data=`[${n}]`,n)return((t,e,s,n,r)=>{const o=s.length;let i=e.length,a=o,c=0,l=0,h=null;for(;c<i||l<a;)if(i===c){const e=a<o?l?n(s[l-1],-0).nextSibling:n(s[a],0):r;for(;l<a;)t.insertBefore(n(s[l++],1),e)}else if(a===l)for(;c<i;)h&&h.has(e[c])||t.removeChild(n(e[c],-1)),c++;else if(e[c]===s[l])c++,l++;else if(e[i-1]===s[a-1])i--,a--;else if(e[c]===s[a-1]&&s[l]===e[i-1]){const r=n(e[--i],-0).nextSibling;t.insertBefore(n(s[l++],1),n(e[c++],-0).nextSibling),t.insertBefore(n(s[--a],1),r),e[i]=s[a]}else{if(!h){h=new Map;let t=l;for(;t<a;)h.set(s[t],t++)}if(h.has(e[c])){const r=h.get(e[c]);if(l<r&&r<a){let o=c,u=1;for(;++o<i&&o<a&&h.get(e[o])===r+u;)u++;if(u>r-l){const o=n(e[c],0);for(;l<r;)t.insertBefore(n(s[l++],1),o)}else t.replaceChild(n(s[l++],1),n(e[c++],-1))}else c++}else t.removeChild(n(e[c++],-1))}return s})(t.parentNode,s,e,F,t);switch(s.length){case 1:s[0].remove();case 0:break;default:D(F(s[0],0),F(s.at(-1),-0),!1)}return q},nt=new Map([["aria",(t,e)=>{for(const s in e){const n=e[s],r="role"===s?s:`aria-${s}`;null==n?G(t,r):Z(t,r,n)}return e}],["class",(t,e)=>X(t,e,null==e?"class":"className")],["data",(t,e)=>{const{dataset:s}=t;for(const t in e)null==e[t]?delete s[t]:s[t]=e[t];return e}],["ref",Y],["style",(t,e)=>null==e?X(t,e,"style"):K(t.style,e,"cssText")]]),rt=(t,e,s)=>{switch(e[0]){case".":return Q;case"?":return et;case"@":return I;default:return s||"ownerSVGElement"in t?"ref"===e?Y:tt:nt.get(e)||(e in t?e.startsWith("on")?K:((t,e)=>{let s;do{s=T(t,e)}while(!s&&(t=$(t)));return s})(t,e)?.set?X:tt:tt)}},ot=(t,e)=>(t.textContent=null==e?"":e,e),it=(t,e,s)=>({a:t,b:e,c:s}),at=(t,e,s,n)=>({v:q,u:t,t:e,n:s,c:n}),ct=()=>it(null,null,q);var lt=t=>(e,s)=>{const{a:n,b:r,c:o}=t(e,s),i=document.importNode(n,!0);let a=q;if(r!==q){a=[];for(let t,e,s=0;s<r.length;s++){const{a:n,b:o,c:c}=r[s],l=n===e?t:t=R(i,e=n);a[s]=at(o,l,c,o===st?[]:o===J?ct():null)}}return{b:o?i.firstChild:new z(i),c:a}};const ht=/^(?:plaintext|script|style|textarea|title|xmp)$/i,ut=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,dt=/<([a-zA-Z0-9]+[a-zA-Z0-9:._-]*)([^>]*?)(\/?)>/g,pt=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,ft=/[\x01\x02]/g;let bt,gt,mt=document.createElement("template");var vt=(t,e)=>{if(e)return bt||(bt=document.createElementNS("http://www.w3.org/2000/svg","svg"),gt=M(),gt.selectNodeContents(bt)),gt.createContextualFragment(t);mt.innerHTML=t;const{content:s}=mt;return mt=mt.cloneNode(!1),s};const wt=t=>{const e=[];let s;for(;s=t.parentNode;)e.push(e.indexOf.call(s.childNodes,t)),t=s;return e},Ct=()=>document.createTextNode(""),yt=new WeakMap,xt="isµ";var At=t=>(e,s)=>yt.get(e)||((t,e,s)=>{const n=vt(((t,e,s)=>{let n=0;return t.join("").trim().replace(dt,(t,e,n,r)=>`<${e}${n.replace(pt,"=$2$1").trimEnd()}${r?s||ut.test(e)?" /":`></${e}`:""}>`).replace(ft,t=>""===t?`\x3c!--${e+n++}--\x3e`:e+n++)})(t,xt,s),s),{length:r}=t;let o=q;if(r>1){const t=[],i=document.createTreeWalker(n,129);let a=0,c=`${xt}${a++}`;for(o=[];a<r;){const n=i.nextNode();if(8===n.nodeType){if(n.data===c){const s=O(e[a-1])?st:J;s===J&&t.push(n),o.push(it(wt(n),s,null)),c=`${xt}${a++}`}}else{let t;for(;n.hasAttribute(c);){t||(t=wt(n));const e=n.getAttribute(c);o.push(it(t,rt(n,e,s),e)),G(n,c),c=`${xt}${a++}`}!s&&ht.test(n.localName)&&n.textContent.trim()===`\x3c!--${c}--\x3e`&&(o.push(it(t||wt(n),ot,null)),c=`${xt}${a++}`)}}for(a=0;a<t.length;a++)t[a].replaceWith(Ct())}const{childNodes:i}=n;let{length:a}=i;return a<1?(a=1,n.appendChild(Ct())):1===a&&1!==r&&1!==i[0].nodeType&&(a=0),j(yt,t,it(n,o,1===a))})(e,s,t);const Nt=lt(At(!1)),St=lt(At(!0)),Et=(t,{s:e,t:s,v:n})=>{if(t.a!==s){const{b:r,c:o}=(e?St:Nt)(s,n);t.a=s,t.b=r,t.c=o}for(let{c:e}=t,s=0;s<e.length;s++){const t=n[s],r=e[s];switch(r.u){case st:r.v=st(r.t,Lt(r.c,t),r.v);break;case J:const e=t instanceof kt?Et(r.c||(r.c=ct()),t):(r.c=null,t);e!==r.v&&(r.v=J(r,e));break;default:t!==r.v&&(r.v=r.u(r.t,t,r.n,r.v))}}return t.b},Lt=(t,e)=>{let s=0,{length:n}=e;for(n<t.length&&t.splice(n);s<n;s++){const n=e[s];n instanceof kt?e[s]=Et(t[s]||(t[s]=ct()),n):t[s]=null}return e};class kt{constructor(t,e,s){this.s=t,this.t=e,this.v=s}toDOM(t=ct()){return Et(t,this)}}
|
|
2
|
+
/*! (c) Andrea Giammarchi - MIT */const Ot=t=>(e,...s)=>new kt(t,e,s),$t=Ot(!1),Tt=Ot(!0),qt=new WeakMap;var Mt=(t,e,s)=>{const n=qt.get(t)||j(qt,t,ct()),{b:r}=n,o=e,i=o instanceof kt?o.toDOM(n):o;return r!==i&&t.replaceChildren((n.b=i).valueOf()),t};
|
|
3
|
+
/*! (c) Andrea Giammarchi - MIT */const jt=new WeakMap,Rt=t=>(e,s)=>{const n=jt.get(e)||j(jt,e,new Map);return n.get(s)||j(n,s,function(e,...s){return new kt(t,e,s).toDOM(this)}.bind(ct()))},Wt=Rt(!1),Bt=Rt(!0),Ut=new FinalizationRegistry(([t,e,s])=>{t(e)}),Dt=Object.create(null),Pt=new WeakMap,Ht=t=>t();let Ft=!0;const _t=t=>(e,s)=>{if(Ft="function"!=typeof s,zt(e),Ft)return Mt(e,s);Ft=!0;const n=new WeakRef(e),r=t(()=>{Mt(n.deref(),s())});return Pt.set(e,r),((t,e,{debug:s,handler:n,return:r,token:o=t}=Dt)=>{const i=r||new Proxy(t,n||Dt),a=[i,[e,t,!!s]];return!1!==o&&a.push(o),Ut.register(...a),i})(r,Ht,{return:e})},zt=t=>{const e=Pt.get(t);var s;e&&(Ft&&Pt.delete(t),s=e,Ut.unregister(s),e())},Zt=_t(n);export{r as Computed,l as ContextConsumer,a as ContextProvider,c as ContextRequestEvent,kt as Hole,d as MiElement,o as Signal,e as State,N as Store,k as addGlobalStyles,_t as attach,nt as attr,S as classMap,g as convertType,s as createSignal,p as define,zt as detach,n as effect,y as esc,C as escHtml,$t as html,Wt as htmlFor,x as refsById,A as refsBySelector,Zt as render,E as styleMap,Tt as svg,Bt as svgFor,v as unsafeHtml};
|
|
4
4
|
//# sourceMappingURL=index.min.js.map
|