This commit is contained in:
Simon Vieille 2022-08-03 14:47:34 +02:00
commit 5c0b1ba655
Signed by: deblan
GPG key ID: 579388D585F70417
25 changed files with 2923 additions and 0 deletions

39
node_modules/@siimple/modules/index.js generated vendored Normal file
View file

@ -0,0 +1,39 @@
import {elements} from "./elements.js";
import {helpers} from "./helpers.js";
import {markup} from "./markup.js";
import {reset} from "./reset.js";
const all = {
...elements,
...helpers,
markup,
reset,
};
export const injectModules = config => {
const styles = {};
// Check for array --> only include specified modules
if (config.modules && Array.isArray(config.modules)) {
config.modules.forEach(key => {
all[key] && Object.assign(styles, all[key]);
});
}
// Check for object or undefined --> exclude modules
else if (typeof config.modules === "undefined" || config.modules) {
const excludeModules = new Set();
Object.keys(config.modules || {}).forEach(key => {
if (typeof config.modules[key] === "boolean" && !config.modules[key]) {
excludeModules.add(key);
}
});
Object.keys(all).forEach(key => {
!excludeModules.has(key) && Object.assign(styles, all[key]);
});
}
return Object.assign(config, {
styles: {
...styles,
...(config.styles || {}),
},
});
};