Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bootstrap-vue-3 resolver #520

Merged
merged 2 commits into from Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 38 additions & 0 deletions 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<ComponentResolver> => {
const options = { directives: true, ..._options }
const resolvers: Array<ComponentResolver> = [{
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
}
1 change: 1 addition & 0 deletions src/core/resolvers/index.ts
Expand Up @@ -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'