@kickstartds/core
Advanced tools
Comparing version 1.0.0-alpha.9 to 1.0.0-alpha.10
@@ -1,1 +0,1 @@ | ||
import"lazysizes";import{uid as t}from"./uid.js";import{domLoaded as o}from"../core/domLoaded.js";function e(t){return t?t.isComponent?t:t().then((t=>t.default||t)):null}function n(t,o){o.forEach((o=>{o(t)}))}const s=(t,o)=>t.forEach((t=>{if(t.nodeType===Node.ELEMENT_NODE){[t,...t.querySelectorAll("[data-component]")].forEach(o)}}));function a(o,s,a,r){return new Promise((t=>{if(o.classList.contains("lazyload")&&!o.classList.contains("lazyloaded")){const e=rm.radio.on(`loadLazyComponent.${s}`,((n,s)=>{s===o&&(rm.radio.off(e),t(a))}))}else t(a)})).then(e).then((e=>{e&&(o.setAttribute("data-uid",t()),new e(o),n(o,r))})).catch((t=>{console.error(`Error in ${s}\n`,t)}))}document.addEventListener("lazybeforeunveil",(t=>{const o=t.target.dataset.component;o&&rm.radio.emit(`loadLazyComponent.${o}`,t.target)}));const r=new class{constructor({mountHooks:t=[],unmountHooks:e=[]}={}){this.mountHooks=t,this.unmountHooks=e,this.classes={};const n=new MutationObserver((t=>{t.forEach((t=>{switch(t.type){case"attributes":t.oldValue&&this.unmount([t.target]),t.target.dataset.component&&this.mount([t.target]);break;case"childList":this.mount(t.addedNodes),this.unmount(t.removedNodes)}}))}));o((()=>{n.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-component"]})}))}add(t){Object.assign(this.classes,t),o((()=>{Object.entries(t).forEach((([t,o])=>{document.body.querySelectorAll(`[data-component="${t}"]`).forEach((e=>{a(e,t,o,this.mountHooks)}))}))}))}mount(t){s(t,(t=>{if(t.hasAttribute("data-uid"))return;const o=t.dataset.component,e=this.classes[o];e&&a(t,o,e,this.mountHooks)}))}unmount(t){s(t,(t=>{t.hasAttribute("data-uid")&&n(t,this.unmountHooks)}))}};function i(t,o){r.add({[t]:o})}export{i as define}; | ||
import"lazysizes";import{uid as t}from"./uid.js";import{inBrowser as o,domLoaded as e}from"../core/domLoaded.js";function n(t){return t?t.isComponent?t:t().then((t=>t.default||t)):null}function s(t,o){o.forEach((o=>{o(t)}))}const a=(t,o)=>t.forEach((t=>{if(t.nodeType===Node.ELEMENT_NODE){[t,...t.querySelectorAll("[data-component]")].forEach(o)}}));function r(o,e,a,r){return new Promise((t=>{if(o.classList.contains("lazyload")&&!o.classList.contains("lazyloaded")){const n=rm.radio.on(`loadLazyComponent.${e}`,((e,s)=>{s===o&&(rm.radio.off(n),t(a))}))}else t(a)})).then(n).then((e=>{e&&(o.setAttribute("data-uid",t()),new e(o),s(o,r))})).catch((t=>{console.error(`Error in ${e}\n`,t)}))}o&&document.addEventListener("lazybeforeunveil",(t=>{const o=t.target.dataset.component;o&&window.rm.radio.emit(`loadLazyComponent.${o}`,t.target)}));const i=new class{constructor({mountHooks:t=[],unmountHooks:n=[]}={}){if(!o)return;this.mountHooks=t,this.unmountHooks=n,this.classes={};const s=new MutationObserver((t=>{t.forEach((t=>{switch(t.type){case"attributes":t.oldValue&&this.unmount([t.target]),t.target.dataset.component&&this.mount([t.target]);break;case"childList":this.mount(t.addedNodes),this.unmount(t.removedNodes)}}))}));e((()=>{s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-component"]})}))}add(t){Object.assign(this.classes,t),e((()=>{Object.entries(t).forEach((([t,o])=>{document.body.querySelectorAll(`[data-component="${t}"]`).forEach((e=>{r(e,t,o,this.mountHooks)}))}))}))}mount(t){a(t,(t=>{if(t.hasAttribute("data-uid"))return;const o=t.dataset.component,e=this.classes[o];e&&r(t,o,e,this.mountHooks)}))}unmount(t){a(t,(t=>{t.hasAttribute("data-uid")&&s(t,this.unmountHooks)}))}};function u(t,e){o&&i.add({[t]:e})}export{u as define}; |
@@ -1,1 +0,1 @@ | ||
const e=document.readyState,t="interactive"===e||"complete"===e,n=[];function o(e){t?setTimeout(e):n.push(e)}t||document.addEventListener("DOMContentLoaded",(()=>{for(;n.length;)n.pop()()}));export{o as domLoaded}; | ||
const e="undefined"!=typeof window,t=e&&document.readyState,n="interactive"===t||"complete"===t,o=[];function d(t){e&&(n?setTimeout(t):o.push(t))}e&&!n&&document.addEventListener("DOMContentLoaded",(()=>{for(;o.length;)o.pop()()}));export{d as domLoaded,e as inBrowser}; |
@@ -1,1 +0,1 @@ | ||
import r from"htm";import t from"vhtml";const n=new DOMParser;function o(r,t){return[...n.parseFromString(r,"text/html").body.children].map((r=>t.appendChild(r)))}const m=r.bind(t);export{m as html,o as render}; | ||
import r from"htm";import t from"vhtml";function m(r,t){return[...(new DOMParser).parseFromString(r,"text/html").body.children].map((r=>t.appendChild(r)))}const n=r.bind(t);export{n as html,m as render}; |
@@ -1,2 +0,2 @@ | ||
export { domLoaded } from './domLoaded.js'; | ||
export { domLoaded, inBrowser } from './domLoaded.js'; | ||
export { render, html } from './html.js'; | ||
@@ -3,0 +3,0 @@ export { uid } from './component/uid.js'; |
@@ -1,1 +0,1 @@ | ||
import"./radio.js";export{domLoaded}from"./domLoaded.js";export{html,render}from"./html.js";export{uid}from"../component/uid.js";export{define}from"../component/define.js";export{default as Component}from"../component/Component.js"; | ||
import"./radio.js";export{domLoaded,inBrowser}from"./domLoaded.js";export{html,render}from"./html.js";export{uid}from"../component/uid.js";export{define}from"../component/define.js";export{default as Component}from"../component/Component.js"; |
@@ -1,1 +0,1 @@ | ||
import i from"pubsub-js";window.rm=window.rm||{},window.rm.radio={on:(b,s)=>i.subscribe(b,s),once(b,s){i.subscribeOnce(b,s)},off:b=>i.unsubscribe(b),emit:(b,s)=>i.publish(b,s),emitSync:(b,s)=>i.publishSync(b,s)}; | ||
import i from"pubsub-js";import{inBrowser as o}from"./domLoaded.js";o&&(window.rm=window.rm||{},window.rm.radio={on:(o,r)=>i.subscribe(o,r),once(o,r){i.subscribeOnce(o,r)},off:o=>i.unsubscribe(o),emit:(o,r)=>i.publish(o,r),emitSync:(o,r)=>i.publishSync(o,r)}); |
@@ -16,2 +16,3 @@ { | ||
"html", | ||
"inBrowser", | ||
"render", | ||
@@ -21,3 +22,4 @@ "uid" | ||
"core/domLoaded.js": [ | ||
"domLoaded" | ||
"domLoaded", | ||
"inBrowser" | ||
], | ||
@@ -37,2 +39,3 @@ "core/html.js": [ | ||
"html", | ||
"inBrowser", | ||
"render", | ||
@@ -39,0 +42,0 @@ "uid" |
@@ -1,1 +0,1 @@ | ||
import"./core/radio.js";export{domLoaded}from"./core/domLoaded.js";export{html,render}from"./core/html.js";export{uid}from"./component/uid.js";export{define}from"./component/define.js";export{default as Component}from"./component/Component.js";import"./_shared/tokens-d32f3ac8.js";export*from"./storybook/helpers.js"; | ||
import"./core/radio.js";export{domLoaded,inBrowser}from"./core/domLoaded.js";export{html,render}from"./core/html.js";export{uid}from"./component/uid.js";export{define}from"./component/define.js";export{default as Component}from"./component/Component.js";import"./_shared/tokens-d32f3ac8.js";export*from"./storybook/helpers.js"; |
{ | ||
"name": "@kickstartds/core", | ||
"version": "1.0.0-alpha.9", | ||
"version": "1.0.0-alpha.10", | ||
"description": "kickstartDS Core Module", | ||
@@ -32,3 +32,3 @@ "author": "ruhmesmeile GmbH <mail@ruhmesmeile.com> (https://ruhmesmeile.com)", | ||
}, | ||
"gitHead": "4f5a46d62290d0285df01391e6b79541768f5311" | ||
"gitHead": "ba0e4176146c309861f1f1bb210c6ae05147affa" | ||
} |
46542
408