Skip to content

Commit b58ed85

Browse files
authored
feat: bootstrap-vue-3 resolver (#520)
1 parent 2a120ee commit b58ed85

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/core/resolvers/bootstrap-vue-3.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import type { ComponentResolver } from '../../types'
2+
3+
export interface BootstrapVue3ResolverOptions {
4+
/**
5+
* Auto import for directives.
6+
*
7+
* @default true
8+
*/
9+
directives?: boolean
10+
}
11+
12+
/**
13+
* Resolver for BootstrapVue
14+
*
15+
* @link https://github.com/cdmoro/bootstrap-vue-3
16+
*/
17+
export const BootstrapVue3Resolver = (_options: BootstrapVue3ResolverOptions = {}): Array<ComponentResolver> => {
18+
const options = { directives: true, ..._options }
19+
const resolvers: Array<ComponentResolver> = [{
20+
type: 'component',
21+
resolve: (name) => {
22+
if (name.match(/^B[A-Z]/))
23+
return { name, from: 'bootstrap-vue-3' }
24+
},
25+
}]
26+
27+
if (options.directives) {
28+
resolvers.push({
29+
type: 'directive',
30+
resolve: (name) => {
31+
if (name.match(/^B[A-Z]/))
32+
return { name: `V${name}`, from: 'bootstrap-vue-3' }
33+
},
34+
})
35+
}
36+
37+
return resolvers
38+
}

src/core/resolvers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ export * from './arco'
1919
export * from './tdesign'
2020
export * from './layui-vue'
2121
export * from './bootstrap-vue'
22+
export * from './bootstrap-vue-3'
2223
export * from './ionic'

0 commit comments

Comments
 (0)