UNPKG

nodality

Version:

A lightweight library for declarative UI elements.

2 lines 2.33 kB
/*! For license information please see stack.cjs.js.LICENSE.txt */ (()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}function o(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}e.r(t),e.d(t,{Stack:()=>i});var i=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.res=null,this.st=t},(t=[{key:"setup",value:function(){var e=document.createElement("div");return e.style.display="grid",this.res=e,this.st&&this.sticky(),this}},{key:"set",value:function(e){return this.setup(),e.height&&(this.res.style.height=e.height),e.sticky&&this.sticky(),this}},{key:"sticky",value:function(){return this.res.style.position="sticky",this.res.style.top=0,this}},{key:"add",value:function(e){this.children=e;for(var t=0;t<e.length;t++){var r=e[t].render();r.style.gridColumn=1,r.style.gridRow=1,this.res.appendChild(r)}return this}},{key:"toCode",value:function(){var e="new Stack().set({})";if(this.children.length>0){var t=this.children.map((function(e){return e.toCode()})).join(",\n");e+=".add([\n \n ".concat(t," \n \n])")}return[e]}},{key:"render",value:function(e){if(!e)return this.res;document.querySelector("body").style.margin=0,document.querySelector("body").style.padding=0,document.querySelector(e).appendChild(this.res)}}])&&n(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();module.exports=t})();