UNPKG

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.47 kB
(function(e,s){typeof exports=="object"&&typeof module!="undefined"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(e=typeof globalThis!="undefined"?globalThis:e||self,s(e.Config={}))})(this,function(e){"use strict";const s="2.4.1",c=[],o={components:[],plugins:[],prefix:"ax",mode:""},u=n=>`--${o.prefix}-${n}`,g=n=>o.components.find(i=>i.name===n).class,d=()=>{const n=o.components.filter(t=>t.dataDetection),i=o.plugins.filter(t=>t.dataDetection);return[...n,...i].map(t=>t.name)},l=()=>{const n=o.components.filter(t=>t.autoInit&&t.autoInit.enabled),i=o.plugins.filter(t=>t.autoInit&&t.autoInit.enabled);return[...n,...i].reduce((t,a)=>(t[a.name]=document.querySelectorAll(a.autoInit.selector),t),{})},r=(n,i)=>{if(!n.name||!n.class){console.error(`[Axentix] Error registering ${i} : Missing required parameters.`);return}if(o[i].some(t=>t.name===n.name)){console.error(`[Axentix] Error registering ${i} : Already exist.`);return}n.autoInit&&(n.autoInit.selector=n.autoInit.selector+=":not(.no-axentix-init)"),o[i].push(n)},f=n=>{r(n,"components")},m=n=>{r(n,"plugins")},p=()=>{window&&(window.Axentix||(window.Axentix={}),[...o.components,...o.plugins].forEach(n=>{window.Axentix[n.name]=n.class}))};e.config=o,e.exportToWindow=p,e.getAutoInitElements=l,e.getComponentClass=g,e.getCssVar=u,e.getDataElements=d,e.instances=c,e.registerComponent=f,e.registerPlugin=m,e.version=s,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});