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(resolvers): add bootstrap-vue-next resolver #587

Merged
merged 9 commits into from
Feb 16, 2023
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
Original file line number Diff line number Diff line change
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' }
VividLemon marked this conversation as resolved.
Show resolved Hide resolved
},
})
}

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
Original file line number Diff line number Diff line change
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'