From 4727f6d44d496d0e853aca579f2aa9ec2b9de584 Mon Sep 17 00:00:00 2001 From: adamghill Date: Thu, 16 Feb 2023 08:39:47 -0500 Subject: [PATCH] Bump package. --- CHANGELOG.md | 3 ++ dist/dlite.es.js | 4 +-- package.json | 2 +- site/.buildinfo | 2 +- site/_static/documentation_options.js | 2 +- site/components/binding/index.html | 6 ++-- site/components/configuration/index.html | 6 ++-- site/components/directives/index.html | 6 ++-- site/components/events/index.html | 6 ++-- site/components/index.html | 10 +++---- site/components/store/index.html | 6 ++-- site/components/template/index.html | 6 ++-- site/examples/index.html | 6 ++-- site/faq/index.html | 6 ++-- site/genindex/index.html | 6 ++-- site/index.html | 6 ++-- site/installation/index.html | 24 ++++++++++------ site/objects.inv | Bin 2005 -> 2005 bytes site/search/index.html | 6 ++-- site/searchindex.js | 2 +- src/emerj.js | 35 +++++++++++++++-------- 21 files changed, 86 insertions(+), 64 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60fb949..c5ef9c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 0.16.2 +- Remove `visibility: hide` on first component render + # 0.16.1 - Include `link` tags with a `rel` of `stylesheet` for `Shadow DOM` scoped css diff --git a/dist/dlite.es.js b/dist/dlite.es.js index 4e6c4ef..e4a782c 100644 --- a/dist/dlite.es.js +++ b/dist/dlite.es.js @@ -1,2 +1,2 @@ -/* dlite v0.16.1 */ -const t=(t,e,n)=>{let r=t;const o=e.split(".");for(;o.length;){const t=o.shift();r[t]=o.length?r[t]?r[t]:{}:n,r=r[t]}},e=(t,e)=>e.split(".").reduce(((t,e)=>t&&t[e]),t),n=t=>"function"==typeof t,r=(t,e)=>t&&n(t[e]),o=t=>{const e=(new DOMParser).parseFromString(t,"text/html");return{head:e.head,body:e.body}},i=[["<","<"],[">",">"],["&","&"]],s=(t,e=!1)=>Object.freeze(Array.from(t.attributes).map((t=>{return{[e?(n=t.name,n.replace(/[-_\s+]([a-z])/g,(t=>t[1].toUpperCase()))):t.name]:t.value};var n})).reduce(((t,e)=>({...t,...e})),{})),l=(t,e)=>{let n=!1,r=!1;const o=new WeakMap,i=()=>{n?r||(r=!0):e()},s={get(t,e,n){if("#"===e)return t;const r=Reflect.get(t,e,n);if((t=>null===t||!["function","object"].includes(typeof t))(r)||"constructor"===e)return r;const i=((t,e)=>{let n=o.get(t);if(n)return n;n=new Map,o.set(t,n);let r=n.get(e);return r||(r=Reflect.getOwnPropertyDescriptor(t,e),n.set(e,r)),r})(t,e);if(i&&!i.configurable){if(i.set&&!i.get)return;if(!1===i.writable)return r}return new Proxy(r,s)},set(t,e,n,r){n&&void 0!==n["#"]&&(n=n["#"]);const o=Reflect.get(t,e,r),s=Reflect.set(t,e,n);return o!==n&&i(),s},defineProperty(t,e,n){const r=Reflect.defineProperty(t,e,n);return i(),r},deleteProperty(t,e){const n=Reflect.deleteProperty(t,e);return i(),n},apply(t,o,i){if(!n){n=!0;const s=Reflect.apply(t,o,i);return r&&e(),n=r=!1,s}return Reflect.apply(t,o,i)}};return new Proxy(t,s)};function c(t){return null===t||"object"!=typeof t?t:(Object.keys(t).forEach((function(e){const n=t[e];null!==n&&"object"==typeof n&&c(n)})),Object.freeze(t))}const a=t=>c(function(t){if(null===t||"object"!=typeof t)return t;var e=t.constructor();for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=a(t[n]));return e}(t)),u=[];for(const t in document){const e=null===document[t]||n(document[t]);t.startsWith("on")&&e&&u.push(t.substring(2))}const d="dl--elist",f=t=>`dl--on-${t}`;const h=(t,e)=>Array.from(t.childNodes).filter((t=>e(t))).map((t=>({[e(t)]:t}))).reduce(((t,e)=>({...t,...e})),{}),p=t=>t instanceof HTMLElement&&t.hasAttribute("ref-key")?t.getAttribute("ref-key"):t.id;function b(t,e,n={}){if(n={key:t=>p(t),...n},"string"==typeof e){const n=e;(e=document.createElement(t.nodeName)).innerHTML=n}const r=h(t,n.key);let o;for(o=0;e.firstChild;o++){const i=e.removeChild(e.firstChild);if(o>=t.childNodes.length){t.appendChild(i);continue}let l=t.childNodes[o];const c=n.key(i);if(n.key(l)||c){const e=c&&c in r?r[c]:i;e!==l&&(l=t.insertBefore(e,l))}if(l.nodeType!==i.nodeType||l.tagName!==i.tagName)t.replaceChild(i,l);else if([Node.TEXT_NODE,Node.COMMENT_NODE].indexOf(l.nodeType)>=0)l.textContent!==i.textContent&&(l.textContent=i.textContent);else if(l!==i){const t=s(l),e=s(i);for(const n in t)n in e||l.removeAttribute(n);for(const n in e)n in t&&t[n]===e[n]||l.setAttribute(n,e[n]);b(l,i)}}for(;t.childNodes.length>o;)t.removeChild(t.lastChild);return!0}const m={$key:function(t,e,n){t.setAttribute("ref-key",e),A(t,n)},$class:function(t,e,n){const r=e.split(";").map((t=>t.split(":",2).map((t=>t.trim())))).map((t=>`\${${t[1]} ? '${t[0]}': ''}`)).join(" "),o=(t.getAttribute("class")||"")+` ${r}`;t.setAttribute("class",o),A(t,n)},$style:function(t,e,n){const r=t.getAttribute("style")||"",o=`\${function() { return this.__$styleMap(${e});}.call(this)}`;t.setAttribute("style",(r?r+"; ":"")+o),A(t,n)},$for:function(t,e,n){const r=/(.*)\s+(in)\s+(.*)$/.exec(e);if(4===r.length){const e=r[1].replace("(","").replace(")",""),o=r[3];M(t,`\${${o}.map(function(${e}) { return \``,"`}.bind(this)).join('')}"),A(t,n)}},$if:function(t,e,n){A(t,n),w(t,`\${${e} ? `);const r=t.nextElementSibling;r&&g(r,"else")?(M(t,"`","`"),A(r,"else"),M(r,":`","`}")):M(t,"`","`:``}")},$text:function(t,e,n){t.textContent=e,A(t,n)}},y=t=>`:${t}`,g=(t,e)=>t.hasAttribute(y(e)),$=(t,e)=>t.getAttribute(y(e)),A=(t,e)=>t.removeAttribute(y(e)),v=(t,e)=>t.querySelectorAll(`[\\${y(e)}]`),w=(t,e)=>t.insertAdjacentText("beforebegin",e),M=(t,e,n)=>{w(t,e),((t,e)=>{t.insertAdjacentText("afterend",e)})(t,n)};const k=["data","el","shadowDOM","template","created","updated","removed","$store","prop","tagName"],x=t=>Object.keys(t).filter((t=>!k.includes(t))).filter((t=>!t.startsWith("$"))).filter((e=>r(t,e))).reduce(((e,n)=>({...e,[n]:t[n]})),{}),j=t=>Object.keys(t).filter((e=>!r(t,e))).reduce(((e,n)=>({...e,[n]:t[n]})),{}),N=t=>Object.keys(t).filter((e=>r(t,e))).map((e=>{return n=e,r=t[e],t=>t[n]=r({...t});var n,r})),E=t=>Object.keys(t).filter((t=>t.startsWith("$"))).filter((t=>!k.includes(t))).reduce(((e,n)=>({...e,[n]:t[n]})),{}),T=t=>e=>(e.$store=t.getState(),t.subscribe((n=>e.$store={...t.getState()}))),O=(t,e,n)=>{Object.keys(e).filter((t=>!t.startsWith("_"))).map((r=>t[r]=e[r].bind(n)))},_=t=>{const{head:e,body:n}=o(t);!function(t,e={}){const n={...e,...m};for(const e in n){const r=e.replace("$","");for(const o of v(t,r))if(g(o,r)){const t=$(o,r);n[e](o,t,r)}}}(n),function(t){for(const e of t.querySelectorAll("[\\@call], [\\@bind]")){let t=e.getAttribute("@call");e.removeAttribute("@call"),e.hasAttribute("@bind")&&(e.setAttribute("dl--bind",e.getAttribute("@bind")),e.removeAttribute("@bind"),t="__$bindInput");let n=["click"];e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?n=["input","paste"]:e instanceof HTMLSelectElement?n=["change"]:e instanceof HTMLFormElement?n=["submit"]:e instanceof HTMLAnchorElement&&e.setAttribute("href","javascript:void(0);");let r=(e.getAttribute(d)||"").split(",").filter((t=>t));r=r.concat(n),e.setAttribute(d,r.join(","));for(const r of n)e.setAttribute(f(r),t)}for(const e of u)for(const n of t.querySelectorAll(`[\\@${e}]`)){const t=(n.getAttribute(d)||"").split(",").filter((t=>t));t.push(e),n.setAttribute(d,t.join(",")),n.setAttribute(f(e),n.getAttribute(`@${e}`)),n.removeAttribute(`@${e}`),n instanceof HTMLAnchorElement&&n.setAttribute("href","javascript:void(0);")}}(n);let r=(t=>t.replace(/\$?\{([^\;\{]+)\}/g,((t,e)=>`\${${e}}`)))((s=n.innerHTML,i.reduce(((t,e)=>t.replace(new RegExp(e[0],"g"),e[1])),s)));var s;e.querySelectorAll('style, link[rel="stylesheet"]').forEach((t=>{r+=t.outerHTML}));const l=(c=r,t=>new Function(`return \`${c}\``).call(t));var c;return{html:r,render:(t,e)=>{const{head:n,body:r}=o(l(e));return r.append(...n.querySelectorAll("style, link")),!t.isEqualNode(r)&&b(t,r)}}};function C(n){const r=n.target,o=r.getAttribute("ld--bind");if("checkbox"===r.type){const n=e(this.data,o)||[];t(this.data,o,r.checked?n.concat(r.value):n.filter((t=>t!=r.value)))}else r.options&&r.multiple?t(this.data,o,[].reduce.call(r,((t,e)=>e.selected?t.concat(e.value):t),[])):t(this.data,o,r.value)}const L={__$styleMap:t=>Object.keys(t).map((e=>{return`${n=e,n.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}: ${t[e]};`;var n})).join(" ")};function S(t={}){const n={shadowDOM:!0,tagName:null,data:{},template:null,$store:{getState:()=>{},subscribe:()=>()=>{}},created(){},updated(){},removed(){},...t},r=T(n.$store),o=_(n.template),i=x(n),c=j(n.data),u=N(n.data),h=E(n),p=t=>u.forEach((e=>e(t)));let b=null;return window.customElements.define(n.tagName.toLowerCase(),class extends HTMLElement{constructor(){super(),this.style.visibility=this.style.visibility?this.style.visibility:"hidden",this.$root=n.shadowDOM?this.attachShadow({mode:"open"}):this,b=this}connectedCallback(){this._state={...this._state,...c,prop:s(this,!0)};const t=l(this._state,(()=>{p(this._state),o.render(this.$root,{...this._state,...L})&&n.updated.call(this.context),"hidden"===this.style.visibility&&this.style.removeProperty("visibility")}));this.disconnectStore=r(t),this.$root.innerHTML=o.html,this.context={...i,...h,data:t,el:this.$root,prop:this._state.prop,$store:n.$store},function(t,n){function r(t){Array.from(t.querySelectorAll(`[${d}]`)).map((t=>{(t.getAttribute(d)||"").split(",").filter((t=>t)).map((e=>{t[`on${e}`]=r=>{r.preventDefault();const o=t.getAttribute(f(e));n[o].call(n,r)}}))}))}Array.from(t.querySelectorAll("[dl--bind]")).map((t=>{const r=e(n.data,t.getAttribute("dl--bind"));try{"INPUT"===t.tagName&&["radio","checkbox"].includes(t.type)?r.includes(t.value)&&(t.checked=!0):t.value=r}catch(t){}}));const o=new MutationObserver((t=>{[...t].filter((t=>t.addedNodes.length>0)).map((t=>t.target)).map((t=>r(t)))}));o.observe(t,{attributes:!0,childList:!0,subtree:!0}),r(t)}(this.$root,{...this.context,__$bindInput:C}),O(this,i,this.context),p(this._state),o.render(this.$root,{...this._state,...L}),n.created.call(this.context)}disconnectedCallback(){n.removed.call(this.context),this.disconnectStore()}get data(){return a(this._state)}}),b}async function H(t){return await fetch(t).then((t=>{if(t.status>=400)throw new Error(`${t.url} (${t.status})`);return t})).then((t=>(t.headers.get("content-type")||"").includes("json")?t.json():t.text()))}function P(t,e={},n=""){const r=document.createElement(t);r.innerHTML=n;for(const[t,n]of Object.entries(e))r.setAttribute(t,n);return r}var q=(t,e={})=>(Array.isArray(t)||(t=[t]),t.map(((t,n)=>{try{return function(t){const e={el:null,template:null,tagName:null,shadowDOM:!0,debug:!1,...t},n=!e.tagName;if(e.tagName=e.tagName||`dlite-${Math.random().toString(36).substring(2,9).toLowerCase()}`,e.el){if("string"==typeof e.el){const t=document.querySelector(e.el);if(!t)throw new Error(`'${e.el}' could not be found.`);e.el=t}if(e.template||(e.template=e.el.innerHTML),e.el.innerHTML="",n){const t=P(e.tagName,s(e.el));for(const[n,r]of Object.entries(s(e.el)))t.setAttribute(n,r);e.el.parentNode.replaceChild(t,e.el)}}else if(!e.el&&n)throw new Error("Missing either 'el' or 'tagName' setting.");if(!e.template)throw new Error("Missing 'template' setting.");return S(e)}({...e,...t})}catch(r){if(!e.debug&&!t.debug)throw r;{const t=P("div",{style:"background-color: red; color: white; padding: 10px;"},`\n

#${n+1}

\n${r}\n
\n Stacktrace\n ${r.stack.replaceAll("\n","
")}\n
`);document.body.prepend(t),console.error(r)}}})));export{q as default,H as fetcher}; +/* dlite v0.16.2 */ +const t=(t,e,n)=>{let r=t;const o=e.split(".");for(;o.length;){const t=o.shift();r[t]=o.length?r[t]?r[t]:{}:n,r=r[t]}},e=(t,e)=>e.split(".").reduce(((t,e)=>t&&t[e]),t),n=t=>"function"==typeof t,r=(t,e)=>t&&n(t[e]),o=t=>{const e=(new DOMParser).parseFromString(t,"text/html");return{head:e.head,body:e.body}},i=[["<","<"],[">",">"],["&","&"]],s=(t,e=!1)=>Object.freeze(Array.from(t.attributes).map((t=>{return{[e?(n=t.name,n.replace(/[-_\s+]([a-z])/g,(t=>t[1].toUpperCase()))):t.name]:t.value};var n})).reduce(((t,e)=>({...t,...e})),{})),l=(t,e)=>{let n=!1,r=!1;const o=new WeakMap,i=()=>{n?r||(r=!0):e()},s={get(t,e,n){if("#"===e)return t;const r=Reflect.get(t,e,n);if((t=>null===t||!["function","object"].includes(typeof t))(r)||"constructor"===e)return r;const i=((t,e)=>{let n=o.get(t);if(n)return n;n=new Map,o.set(t,n);let r=n.get(e);return r||(r=Reflect.getOwnPropertyDescriptor(t,e),n.set(e,r)),r})(t,e);if(i&&!i.configurable){if(i.set&&!i.get)return;if(!1===i.writable)return r}return new Proxy(r,s)},set(t,e,n,r){n&&void 0!==n["#"]&&(n=n["#"]);const o=Reflect.get(t,e,r),s=Reflect.set(t,e,n);return o!==n&&i(),s},defineProperty(t,e,n){const r=Reflect.defineProperty(t,e,n);return i(),r},deleteProperty(t,e){const n=Reflect.deleteProperty(t,e);return i(),n},apply(t,o,i){if(!n){n=!0;const s=Reflect.apply(t,o,i);return r&&e(),n=r=!1,s}return Reflect.apply(t,o,i)}};return new Proxy(t,s)};function c(t){return null===t||"object"!=typeof t?t:(Object.keys(t).forEach((function(e){const n=t[e];null!==n&&"object"==typeof n&&c(n)})),Object.freeze(t))}const a=t=>c(function(t){if(null===t||"object"!=typeof t)return t;var e=t.constructor();for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=a(t[n]));return e}(t)),u=[];for(const t in document){const e=null===document[t]||n(document[t]);t.startsWith("on")&&e&&u.push(t.substring(2))}const d="dl--elist",f=t=>`dl--on-${t}`;const h=(t,e)=>Array.from(t.childNodes).filter((t=>e(t))).map((t=>({[e(t)]:t}))).reduce(((t,e)=>({...t,...e})),{}),p=t=>t instanceof HTMLElement&&t.hasAttribute("ref-key")?t.getAttribute("ref-key"):t.id;function b(t,e,n={}){if(n={key:t=>p(t),...n},"string"==typeof e){const n=e;(e=document.createElement(t.nodeName)).innerHTML=n}const r=h(t,n.key);let o;for(o=0;e.firstChild;o++){const i=e.removeChild(e.firstChild);if(o>=t.childNodes.length){t.appendChild(i);continue}let l=t.childNodes[o];const c=n.key(i);if(n.key(l)||c){const e=c&&c in r?r[c]:i;e!==l&&(l=t.insertBefore(e,l))}if(l.nodeType!==i.nodeType||l.tagName!==i.tagName)t.replaceChild(i,l);else if([Node.TEXT_NODE,Node.COMMENT_NODE].indexOf(l.nodeType)>=0)l.textContent!==i.textContent&&(l.textContent=i.textContent);else if(l!==i){const t=s(l),e=s(i);for(const n in t)n in e||l.removeAttribute(n);for(const n in e)n in t&&t[n]===e[n]||l.setAttribute(n,e[n]);b(l,i)}}for(;t.childNodes.length>o;)t.removeChild(t.lastChild);return!0}const m={$key:function(t,e,n){t.setAttribute("ref-key",e),A(t,n)},$class:function(t,e,n){const r=e.split(";").map((t=>t.split(":",2).map((t=>t.trim())))).map((t=>`\${${t[1]} ? '${t[0]}': ''}`)).join(" "),o=(t.getAttribute("class")||"")+` ${r}`;t.setAttribute("class",o),A(t,n)},$style:function(t,e,n){const r=t.getAttribute("style")||"",o=`\${function() { return this.__$styleMap(${e});}.call(this)}`;t.setAttribute("style",(r?r+"; ":"")+o),A(t,n)},$for:function(t,e,n){const r=/(.*)\s+(in)\s+(.*)$/.exec(e);if(4===r.length){const e=r[1].replace("(","").replace(")",""),o=r[3];M(t,`\${${o}.map(function(${e}) { return \``,"`}.bind(this)).join('')}"),A(t,n)}},$if:function(t,e,n){A(t,n),w(t,`\${${e} ? `);const r=t.nextElementSibling;r&&g(r,"else")?(M(t,"`","`"),A(r,"else"),M(r,":`","`}")):M(t,"`","`:``}")},$text:function(t,e,n){t.textContent=e,A(t,n)}},y=t=>`:${t}`,g=(t,e)=>t.hasAttribute(y(e)),$=(t,e)=>t.getAttribute(y(e)),A=(t,e)=>t.removeAttribute(y(e)),v=(t,e)=>t.querySelectorAll(`[\\${y(e)}]`),w=(t,e)=>t.insertAdjacentText("beforebegin",e),M=(t,e,n)=>{w(t,e),((t,e)=>{t.insertAdjacentText("afterend",e)})(t,n)};const k=["data","el","shadowDOM","template","created","updated","removed","$store","prop","tagName"],x=t=>Object.keys(t).filter((t=>!k.includes(t))).filter((t=>!t.startsWith("$"))).filter((e=>r(t,e))).reduce(((e,n)=>({...e,[n]:t[n]})),{}),j=t=>Object.keys(t).filter((e=>!r(t,e))).reduce(((e,n)=>({...e,[n]:t[n]})),{}),N=t=>Object.keys(t).filter((e=>r(t,e))).map((e=>{return n=e,r=t[e],t=>t[n]=r({...t});var n,r})),E=t=>Object.keys(t).filter((t=>t.startsWith("$"))).filter((t=>!k.includes(t))).reduce(((e,n)=>({...e,[n]:t[n]})),{}),T=t=>e=>(e.$store=t.getState(),t.subscribe((n=>e.$store={...t.getState()}))),O=(t,e,n)=>{Object.keys(e).filter((t=>!t.startsWith("_"))).map((r=>t[r]=e[r].bind(n)))},C=t=>{const{head:e,body:n}=o(t);!function(t,e={}){const n={...e,...m};for(const e in n){const r=e.replace("$","");for(const o of v(t,r))if(g(o,r)){const t=$(o,r);n[e](o,t,r)}}}(n),function(t){for(const e of t.querySelectorAll("[\\@call], [\\@bind]")){let t=e.getAttribute("@call");e.removeAttribute("@call"),e.hasAttribute("@bind")&&(e.setAttribute("dl--bind",e.getAttribute("@bind")),e.removeAttribute("@bind"),t="__$bindInput");let n=["click"];e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?n=["input","paste"]:e instanceof HTMLSelectElement?n=["change"]:e instanceof HTMLFormElement?n=["submit"]:e instanceof HTMLAnchorElement&&e.setAttribute("href","javascript:void(0);");let r=(e.getAttribute(d)||"").split(",").filter((t=>t));r=r.concat(n),e.setAttribute(d,r.join(","));for(const r of n)e.setAttribute(f(r),t)}for(const e of u)for(const n of t.querySelectorAll(`[\\@${e}]`)){const t=(n.getAttribute(d)||"").split(",").filter((t=>t));t.push(e),n.setAttribute(d,t.join(",")),n.setAttribute(f(e),n.getAttribute(`@${e}`)),n.removeAttribute(`@${e}`),n instanceof HTMLAnchorElement&&n.setAttribute("href","javascript:void(0);")}}(n);let r=(t=>t.replace(/\$?\{([^\;\{]+)\}/g,((t,e)=>`\${${e}}`)))((s=n.innerHTML,i.reduce(((t,e)=>t.replace(new RegExp(e[0],"g"),e[1])),s)));var s;e.querySelectorAll('style, link[rel="stylesheet"]').forEach((t=>{r+=t.outerHTML}));const l=(c=r,t=>new Function(`return \`${c}\``).call(t));var c;return{html:r,render:(t,e)=>{const{head:n,body:r}=o(l(e));return r.append(...n.querySelectorAll("style, link")),!t.isEqualNode(r)&&b(t,r)}}};function L(n){const r=n.target,o=r.getAttribute("ld--bind");if("checkbox"===r.type){const n=e(this.data,o)||[];t(this.data,o,r.checked?n.concat(r.value):n.filter((t=>t!=r.value)))}else r.options&&r.multiple?t(this.data,o,[].reduce.call(r,((t,e)=>e.selected?t.concat(e.value):t),[])):t(this.data,o,r.value)}const S={__$styleMap:t=>Object.keys(t).map((e=>{return`${n=e,n.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}: ${t[e]};`;var n})).join(" ")};function _(t={}){const n={shadowDOM:!0,tagName:null,data:{},template:null,$store:{getState:()=>{},subscribe:()=>()=>{}},created(){},updated(){},removed(){},...t},r=T(n.$store),o=C(n.template),i=x(n),c=j(n.data),u=N(n.data),h=E(n);let p=null;return window.customElements.define(n.tagName.toLowerCase(),class extends HTMLElement{constructor(){super(),this.style.visibility=this.style.visibility?this.style.visibility:"hidden",this.$root=n.shadowDOM?this.attachShadow({mode:"open"}):this,p=this}render(t=!1){var e;e=this._state,u.forEach((t=>t(e))),o.render(this.$root,{...this._state,...S})&&!t&&n.updated.call(this.context),"hidden"===this.style.visibility&&this.style.removeProperty("visibility")}connectedCallback(){if(!this.isConnected)return;this._state={...this._state,...c,prop:s(this,!0)};const t=l(this._state,this.render.bind(this));this.disconnectStore=r(t),this.$root.innerHTML=o.html,this.context={...i,...h,data:t,el:this.$root,prop:this._state.prop,$store:n.$store},function(t,n){function r(t){Array.from(t.querySelectorAll(`[${d}]`)).map((t=>{(t.getAttribute(d)||"").split(",").filter((t=>t)).map((e=>{t[`on${e}`]=r=>{r.preventDefault();const o=t.getAttribute(f(e));n[o].call(n,r)}}))}))}Array.from(t.querySelectorAll("[dl--bind]")).map((t=>{const r=e(n.data,t.getAttribute("dl--bind"));try{"INPUT"===t.tagName&&["radio","checkbox"].includes(t.type)?r.includes(t.value)&&(t.checked=!0):t.value=r}catch(t){}}));const o=new MutationObserver((t=>{[...t].filter((t=>t.addedNodes.length>0)).map((t=>t.target)).map((t=>r(t)))}));o.observe(t,{attributes:!0,childList:!0,subtree:!0}),r(t)}(this.$root,{...this.context,__$bindInput:L}),O(this,i,this.context),this.render(!0),n.created.call(this.context)}disconnectedCallback(){n.removed.call(this.context),this.disconnectStore()}get data(){return a(this._state)}}),p}async function H(t){return await fetch(t).then((t=>{if(t.status>=400)throw new Error(`${t.url} (${t.status})`);return t})).then((t=>(t.headers.get("content-type")||"").includes("json")?t.json():t.text()))}function P(t,e={},n=""){const r=document.createElement(t);r.innerHTML=n;for(const[t,n]of Object.entries(e))r.setAttribute(t,n);return r}var q=(t,e={})=>(Array.isArray(t)||(t=[t]),t.map(((t,n)=>{try{return function(t){const e={el:null,template:null,tagName:null,shadowDOM:!0,debug:!1,...t},n=!e.tagName;if(e.tagName=e.tagName||`dlite-${Math.random().toString(36).substring(2,9).toLowerCase()}`,e.el){if("string"==typeof e.el){const t=document.querySelector(e.el);if(!t)throw new Error(`'${e.el}' could not be found.`);e.el=t}if(e.template||(e.template=e.el.innerHTML),e.el.innerHTML="",n){const t=P(e.tagName,s(e.el));for(const[n,r]of Object.entries(s(e.el)))t.setAttribute(n,r);e.el.parentNode.replaceChild(t,e.el)}}else if(!e.el&&n)throw new Error("Missing either 'el' or 'tagName' setting.");if(!e.template)throw new Error("Missing 'template' setting.");return _(e)}({...e,...t})}catch(r){if(!e.debug&&!t.debug)throw r;{const t=P("div",{style:"background-color: red; color: white; padding: 10px;"},`\n

#${n+1}

\n${r}\n
\n Stacktrace\n ${r.stack.replaceAll("\n","
")}\n
`);document.body.prepend(t),console.error(r)}}})));export{q as default,H as fetcher}; diff --git a/package.json b/package.json index e64c1a6..d4fa1b2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "dlite", "pkgName": "dlite", - "version": "0.16.1", + "version": "0.16.2", "author": "adamghill", "license": "MIT", "description": "A tiny, blazing fast view library that creates reactive Web Components.", diff --git a/site/.buildinfo b/site/.buildinfo index cdb78b2..10d7191 100644 --- a/site/.buildinfo +++ b/site/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: da9356a956fc2547c95254403f8883d7 +config: 323f39a55d244729c079325248e9952f tags: d77d1c0d9ca2f4c8421862c7c5a0d620 diff --git a/site/_static/documentation_options.js b/site/_static/documentation_options.js index cdff7f3..1fdb768 100644 --- a/site/_static/documentation_options.js +++ b/site/_static/documentation_options.js @@ -1,6 +1,6 @@ var DOCUMENTATION_OPTIONS = { URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), - VERSION: '0.16.1', + VERSION: '0.16.2', LANGUAGE: 'en', COLLAPSE_INDEX: false, BUILDER: 'dirhtml', diff --git a/site/components/binding/index.html b/site/components/binding/index.html index 214b7f6..c3189c0 100644 --- a/site/components/binding/index.html +++ b/site/components/binding/index.html @@ -6,7 +6,7 @@ - Data Binding - dlite 0.16.1 documentation + Data Binding - dlite 0.16.2 documentation @@ -124,7 +124,7 @@
-
dlite 0.16.1 documentation
+
dlite 0.16.2 documentation
@@ -147,7 +147,7 @@
@@ -147,7 +147,7 @@
@@ -147,7 +147,7 @@
@@ -147,7 +147,7 @@
@@ -147,7 +147,7 @@
@@ -147,7 +147,7 @@
@@ -147,7 +147,7 @@
@@ -147,7 +147,7 @@
@@ -147,7 +147,7 @@
@@ -145,7 +145,7 @@
@@ -147,7 +147,7 @@
@@ -147,7 +147,7 @@
@@ -144,7 +144,7 @@