modality-kit 0.8.6 → 0.8.8
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/browser.js +1 -0
- package/dist/index.js +3 -6085
- package/dist/types/browser.d.ts +1 -0
- package/dist/types/index.d.ts +0 -1
- package/package.json +15 -14
package/dist/browser.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var{defineProperty:Z,getOwnPropertyNames:O,getOwnPropertyDescriptor:V}=Object,W=Object.prototype.hasOwnProperty;var _=new WeakMap,H=(x)=>{var j=_.get(x),q;if(j)return j;if(j=Z({},"__esModule",{value:!0}),x&&typeof x==="object"||typeof x==="function")O(x).map((B)=>!W.call(j,B)&&Z(j,B,{get:()=>x[B],enumerable:!(q=V(x,B))||q.enumerable}));return _.set(x,j),j};var M=(x,j)=>{for(var q in j)Z(x,q,{get:j[q],enumerable:!0,configurable:!0,set:(B)=>j[q]=()=>B})};var f={};M(f,{render:()=>$,registerStore:()=>F,ReactiveComponent:()=>Q});module.exports=H(f);class Q extends HTMLElement{#j;#G=!1;#q=!1;#K=!1;#x;#J;#B={};#Q=["click","dblclick","mousedown","mouseup","mousemove","mouseover","mouseout","focus","blur","change","input","submit","keydown","keyup","keypress"];_stores;_storeListeners;constructor(x={}){super();this.#J=x,this.#j=x.initialState||{}}get state(){return Object.freeze({...this.#j})}setState(x,j,q){let B=q||{...this.#j},J;if(typeof x==="function")J=x(this.#j);else J=x;let G={...this.#j,...J};if(this.#J.shouldUpdate&&!this.#J.shouldUpdate(G,B))return this.#j;else return this.#j=G,this.#X(B),G}forceUpdate(){this.#X({...this.#j})}#X(x){if(this.#G||this.#q)return;this.#q=!0,queueMicrotask(()=>{if(this.#q&&this.isConnected)this.#Y(x)})}#Y(x){this.#G=!0,this.#q=!1;let j=!this.#K,q=x||{...this.#j};try{if(this.#$(),this.#K=!0,!j&&typeof this.componentDidUpdate==="function")this.componentDidUpdate(this.#j,q)}catch(B){console.error("Error during component update:",B)}finally{this.#G=!1}}static#Z=(()=>{if(typeof window!=="undefined"&&window.trustedTypes&&window.trustedTypes.createPolicy)try{return window.trustedTypes.createPolicy("reactive-component",{createHTML:(x)=>x})}catch(x){return console.warn("Failed to create trusted types policy:",x),null}return null})();#_(x,j){if(Q.#Z)x.innerHTML=Q.#Z.createHTML(j);else x.innerHTML=j}#$(){if(!this.#x)this.#x=this.shadowRoot||this.attachShadow({mode:"open"}),this.#F();if(typeof window!=="undefined"&&window.trustedTypes&&window.trustedTypes.emptyHTML)this.#x.innerHTML=window.trustedTypes.emptyHTML;else while(this.#x.firstChild)this.#x.removeChild(this.#x.firstChild);let x=this.render();if(typeof x==="string"){let j=document.createElement("template");this.#_(j,x),this.#x.appendChild(j.content.cloneNode(!0))}else if(x instanceof DocumentFragment||x instanceof Element)this.#x.appendChild(x)}#F(){this.#Q.forEach((x)=>{let j=(B)=>{this.#I(B)};this.#B[x]=j;let q=!["mousedown","keydown","submit"].includes(x);this.#x.addEventListener(x,j,{passive:q})})}#I(x){let{type:j,target:q}=x;if(!q)return;let B=`data-${j}`,J=this.#x.querySelectorAll(`[${B}]`);Array.from(J).forEach((G)=>{if(q.isSameNode(G)||G.contains(q)){let K=G.getAttribute(B);if(K&&typeof this[K]==="function")this[K](x)}})}connectedCallback(){if(this._stores&&this._stores.length>0)this._storeListeners=[],this._stores.forEach((x)=>{let j=this.setState.bind(this);x.addListener(j),this._storeListeners.push({store:x,listener:j});let q=x.getState();this.setState(q)});if(this.#Y(),typeof this.componentDidMount==="function")this.componentDidMount()}disconnectedCallback(){if(this.#x&&Object.keys(this.#B).length>0)this.#Q.forEach((x)=>{let j=this.#B[x];if(j)this.#x.removeEventListener(x,j)}),this.#B={};if(this._storeListeners&&this._storeListeners.length>0)this._storeListeners.forEach(({store:x,listener:j})=>{x.removeListener(j)}),this._storeListeners=[]}}function $(x,j={},q){let B=document.createElement(x),{appendTo:J=document.body,...G}=j;if(Object.keys(G).forEach((K)=>{let X=G[K];if(X!=null){let I=typeof X==="object"?JSON.stringify(X):String(X);B.setAttribute(K,I)}}),q&&q.length>0)B._stores=q;if(J instanceof HTMLElement)J.appendChild(B);return B}var Y={current:{}};function F(x,j){let q=document.querySelector("connection-section");if(q)q._stores=j;else Y.current[x]=j}if(typeof document!=="undefined")document.addEventListener("DOMContentLoaded",()=>{let x=Object.keys(Y.current).map(async(j)=>{let q=document.querySelector(j);if(q)q._stores=Y.current[j],delete Y.current[j]});Promise.all(x)});
|