UNPKG

axentix

Version:

Axentix is a framework mixing fully customizable components & utility-first classes, leaving the design choice to the developer.

54 lines (53 loc) 1.86 kB
var I = Object.defineProperty; var u = (n) => { throw TypeError(n); }; var A = (n, t, s) => t in n ? I(n, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[t] = s; var c = (n, t, s) => A(n, typeof t != "symbol" ? t + "" : t, s), g = (n, t, s) => t.has(n) || u("Cannot " + s); var p = (n, t, s) => t.has(n) ? u("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s); var i = (n, t, s) => (g(n, t, "access private method"), s); const l = { components: [], plugins: [], prefix: "ax", mode: "" }, x = (n) => l.components.find((t) => t.name === n).class, y = () => { const n = l.components.filter( (s) => s.autoInit && s.autoInit.enabled ), t = l.plugins.filter((s) => s.autoInit && s.autoInit.enabled); return [...n, ...t].reduce((s, e) => (s[e.name] = document.querySelectorAll(e.autoInit.selector), s), {}); }; var o, m, a, h; class b { constructor(t, s) { p(this, o); c(this, "component"); c(this, "isAll"); c(this, "options"); this.component = t[0].toUpperCase() + t.slice(1).toLowerCase(), this.isAll = t === "all", this.options = this.isAll ? {} : s, i(this, o, m).call(this); } } o = new WeakSet(), m = function() { const t = y(); if (t.hasOwnProperty(this.component)) { const e = i(this, o, a).call(this, t[this.component]); i(this, o, h).call(this, e, this.component); } else this.isAll && Object.keys(t).forEach((e) => { const r = i(this, o, a).call(this, t[e]); r.length > 0 && i(this, o, h).call(this, r, e); }); }, a = function(t) { return Array.from(t).map((s) => "#" + s.id); }, h = function(t, s) { t.forEach((e) => { const r = x(s), d = [e, this.options]; try { new r(...d); } catch (f) { console.error("[Axentix] Unable to load " + s, f); } }); }; export { b as Axentix };