UNPKG

nodality

Version:

A lightweight library for declarative UI elements.

2 lines 2.44 kB
/*! For license information please see base.esm.js.LICENSE.txt */ var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,o(n.key),n)}}function o(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}t.d(e,{C:()=>i});var i=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.oldLength=0},(e=[{key:"observe",value:function(t){return this.initialState=t,this.Proxima(t)}},{key:"Proxima",value:function(t){var e=this;return new Proxy(t,{set:function(t,r,n,o){return alert("Setting ".concat(n," to ").concat(o)),t[n]=o,this.initialState.data.push(n),"length"!==r&&e.refreshUI("Added"),!0},has:function(t,r,n,o){return"length"!==r&&e.refreshUI("Deleted"),Reflect.has(t,r)}})}},{key:"refreshUI",value:function(t){var e=this.initialState;this.adjustState(e)}},{key:"loadState",value:function(t,e){return this.loadEl=e,this.initialState=t,alert(this.initialState.data),this.observe(this.state.data)}},{key:"adjustState",value:function(t){document.querySelector(this.loadEl);var e=t[t.length-1],r=document.createElement("p"),n=document.createTextNode(e);r.appendChild(n),document.body.appendChild(r)}},{key:"toNode",value:function(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstChild}},{key:"reactState",value:function(){var t=document.querySelector("#res");alert(this.render());var e=this.toNode(this.toHTML());t.appendChild(e)}},{key:"mount",value:function(t){this.el=t,this.render(t).render(t)}},{key:"toCode",value:function(){return[""]}},{key:"toHTML",value:function(t){return this.render(t).render(t).innerHTML}}])&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),a=e.C;export{a as Base};