diff --git a/src/core/resolvers/bootstrap-vue-3.ts b/src/core/resolvers/bootstrap-vue-3.ts new file mode 100644 index 00000000..7c486723 --- /dev/null +++ b/src/core/resolvers/bootstrap-vue-3.ts @@ -0,0 +1,38 @@ +import type { ComponentResolver } from '../../types' + +export interface BootstrapVue3ResolverOptions { + /** + * Auto import for directives. + * + * @default true + */ + directives?: boolean +} + +/** + * Resolver for BootstrapVue + * + * @link https://github.com/cdmoro/bootstrap-vue-3 + */ +export const BootstrapVue3Resolver = (_options: BootstrapVue3ResolverOptions = {}): Array => { + const options = { directives: true, ..._options } + const resolvers: Array = [{ + type: 'component', + resolve: (name) => { + if (name.match(/^B[A-Z]/)) + return { name, from: 'bootstrap-vue-3' } + }, + }] + + if (options.directives) { + resolvers.push({ + type: 'directive', + resolve: (name) => { + if (name.match(/^B[A-Z]/)) + return { name: `V${name}`, from: 'bootstrap-vue-3' } + }, + }) + } + + return resolvers +} diff --git a/src/core/resolvers/index.ts b/src/core/resolvers/index.ts index ea5c4220..07b5a740 100644 --- a/src/core/resolvers/index.ts +++ b/src/core/resolvers/index.ts @@ -19,4 +19,5 @@ export * from './arco' export * from './tdesign' export * from './layui-vue' export * from './bootstrap-vue' +export * from './bootstrap-vue-3' export * from './ionic'