Skip to content

Commit

Permalink
feat(resolvers): add bootstrap-vue-next resolver (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
VividLemon committed Feb 16, 2023
1 parent 5df0c0e commit 95e9ca2
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 40 deletions.
38 changes: 0 additions & 38 deletions src/core/resolvers/bootstrap-vue-3.ts

This file was deleted.

59 changes: 58 additions & 1 deletion src/core/resolvers/bootstrap-vue.ts
Expand Up @@ -54,7 +54,7 @@ const COMPONENT_ALIASES: Record<string, string> = {
*
* @link https://github.com/bootstrap-vue/bootstrap-vue
*/
export function BootstrapVueResolver(_options: BootstrapVueResolverOptions = {}): ComponentResolver[] {
export const BootstrapVueResolver = (_options: BootstrapVueResolverOptions = {}): ComponentResolver[] => {
const options = { directives: true, ..._options }
const resolvers: ComponentResolver[] = [{
type: 'component',
Expand Down Expand Up @@ -84,3 +84,60 @@ export function BootstrapVueResolver(_options: BootstrapVueResolverOptions = {})

return resolvers
}

/**
* Resolver for BootstrapVueNext
*
* @link https://github.com/bootstrap-vue/bootstrap-vue-next
*/
export const BootstrapVueNextResolver = (_options: BootstrapVueResolverOptions = {}): 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-next' }
},
}]

if (options.directives) {
resolvers.push({
type: 'directive',
resolve: (name) => {
if (name.match(/^B[A-Z]/))
return { name: `v${name}`, from: 'bootstrap-vue-next' }
},
})
}

return resolvers
}

/**
* Resolver for legacy BootstrapVue3 apps
*
* @deprecated use BootstrapVueNextResolver with https://github.com/bootstrap-vue/bootstrap-vue-next
* @link https://www.npmjs.com/package/bootstrap-vue-3
*/
export const BootstrapVue3Resolver = (_options: BootstrapVueResolverOptions = {}): 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: 0 additions & 1 deletion src/core/resolvers/index.ts
Expand Up @@ -19,5 +19,4 @@ export * from './arco'
export * from './tdesign'
export * from './layui-vue'
export * from './bootstrap-vue'
export * from './bootstrap-vue-3'
export * from './ionic'

0 comments on commit 95e9ca2

Please sign in to comment.