bootstrap-vue-next
Version:
BootstrapVueNext is an early and lovely component library for Vue 3 & Nuxt 3 based on Bootstrap 5 and Typescript.
93 lines (92 loc) • 2.95 kB
JavaScript
import { a as componentsWithExternalPath, f as directivesWithExternalPath, c as componentNames, e as directiveNames } from "./BootstrapVueOptions-DSytNWdb.mjs";
const bvKey = "bootstrap-vue-next";
const parseActiveImports = (options, values) => {
const { all, ...others } = options;
const valuesCopy = {};
if (all) {
values.forEach((el) => {
valuesCopy[el] = all;
});
}
const merge = { ...valuesCopy, ...others };
return Object.entries(merge).filter(([name, value]) => !!value && values.includes(name)).map(([name]) => name);
};
const usedComponents = /* @__PURE__ */ new Set();
const usedDirectives = /* @__PURE__ */ new Set();
const BootstrapVueNextResolver = Object.assign(
({
aliases = {},
directives = true,
components = true
} = {}) => {
const selectedComponents = typeof components === "boolean" ? { all: components } : components;
const compImports = parseActiveImports(selectedComponents, componentNames).reduce(
(map, name) => {
map.set(name, `${bvKey}${componentsWithExternalPath[name]}`);
return map;
},
/* @__PURE__ */ new Map()
);
const selectedDirectives = typeof directives === "boolean" ? { all: directives } : directives;
const dirImports = parseActiveImports(selectedDirectives, directiveNames).reduce(
(map, directive) => {
const key = directive.toLowerCase().startsWith("v") ? directive : `v${directive}`;
map.set(key, `${bvKey}${directivesWithExternalPath[key]}`);
return map;
},
/* @__PURE__ */ new Map()
);
const resolvers = [
{
type: "component",
resolve(name) {
const destination = compImports.get(name);
const aliasDestination = compImports.get(aliases[name]);
if (aliasDestination) {
const val = aliases[name];
usedComponents.add(val);
return {
name: val,
from: aliasDestination
};
}
if (destination) {
usedComponents.add(name);
return {
name,
from: destination
};
}
}
},
{
type: "directive",
resolve(name) {
const prefixedName = `v${name}`;
const destination = dirImports.get(prefixedName);
if (destination) {
usedDirectives.add(prefixedName);
return {
name: prefixedName,
from: destination
};
}
}
}
];
return resolvers;
},
{
__usedComponents: usedComponents,
__usedDirectives: usedDirectives
}
);
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
BootstrapVueNextResolver
}, Symbol.toStringTag, { value: "Module" }));
export {
BootstrapVueNextResolver as B,
index as i
};
//# sourceMappingURL=index-BSgsF2PB.mjs.map