axentix
Version:
Axentix is a framework mixing fully customizable components & utility-first classes, leaving the design choice to the developer.
45 lines (44 loc) • 1.47 kB
JavaScript
const r = "2.4.1", a = [], o = {
components: [],
plugins: [],
prefix: "ax",
mode: ""
}, c = (n) => `--${o.prefix}-${n}`, u = (n) => o.components.find((e) => e.name === n).class, g = () => {
const n = o.components.filter((t) => t.dataDetection), e = o.plugins.filter((t) => t.dataDetection);
return [...n, ...e].map((t) => t.name);
}, l = () => {
const n = o.components.filter(
(t) => t.autoInit && t.autoInit.enabled
), e = o.plugins.filter((t) => t.autoInit && t.autoInit.enabled);
return [...n, ...e].reduce((t, s) => (t[s.name] = document.querySelectorAll(s.autoInit.selector), t), {});
}, i = (n, e) => {
if (!n.name || !n.class) {
console.error(`[Axentix] Error registering ${e} : Missing required parameters.`);
return;
}
if (o[e].some((t) => t.name === n.name)) {
console.error(`[Axentix] Error registering ${e} : Already exist.`);
return;
}
n.autoInit && (n.autoInit.selector = n.autoInit.selector += ":not(.no-axentix-init)"), o[e].push(n);
}, m = (n) => {
i(n, "components");
}, p = (n) => {
i(n, "plugins");
}, x = () => {
window && (window.Axentix || (window.Axentix = {}), [...o.components, ...o.plugins].forEach((n) => {
window.Axentix[n.name] = n.class;
}));
};
export {
o as config,
x as exportToWindow,
l as getAutoInitElements,
u as getComponentClass,
c as getCssVar,
g as getDataElements,
a as instances,
m as registerComponent,
p as registerPlugin,
r as version
};