axentix
Version:
Axentix is a framework mixing fully customizable components & utility-first classes, leaving the design choice to the developer.
2 lines (1 loc) • 1.75 kB
JavaScript
(function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e.Core={}))})(this,function(e){"use strict";var y=Object.defineProperty;var h=e=>{throw TypeError(e)};var b=(e,t,o)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var u=(e,t,o)=>b(e,typeof t!="symbol"?t+"":t,o),C=(e,t,o)=>t.has(e)||h("Cannot "+o);var p=(e,t,o)=>t.has(e)?h("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,o);var c=(e,t,o)=>(C(e,t,"access private method"),o);var i,m,f,d;const t={components:[],plugins:[],prefix:"ax",mode:""},o=l=>t.components.find(n=>n.name===l).class,I=()=>{const l=t.components.filter(s=>s.autoInit&&s.autoInit.enabled),n=t.plugins.filter(s=>s.autoInit&&s.autoInit.enabled);return[...l,...n].reduce((s,r)=>(s[r.name]=document.querySelectorAll(r.autoInit.selector),s),{})};class x{constructor(n,s){p(this,i);u(this,"component");u(this,"isAll");u(this,"options");this.component=n[0].toUpperCase()+n.slice(1).toLowerCase(),this.isAll=n==="all",this.options=this.isAll?{}:s,c(this,i,m).call(this)}}i=new WeakSet,m=function(){const n=I();if(n.hasOwnProperty(this.component)){const r=c(this,i,f).call(this,n[this.component]);c(this,i,d).call(this,r,this.component)}else this.isAll&&Object.keys(n).forEach(r=>{const a=c(this,i,f).call(this,n[r]);a.length>0&&c(this,i,d).call(this,a,r)})},f=function(n){return Array.from(n).map(s=>"#"+s.id)},d=function(n,s){n.forEach(r=>{const a=o(s),A=[r,this.options];try{new a(...A)}catch(g){console.error("[Axentix] Unable to load "+s,g)}})},e.Axentix=x,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});