Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 5db1b0c

Browse files
committed
feat: use options in to install plugin to allow select some components, directives or linked BToastPlugin configuration
1 parent 615e44a commit 5db1b0c

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

packages/bootstrap-vue-next/src/BootstrapVue.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {App, Plugin} from 'vue'
2+
import {BToastPlugin} from './components'
23
import type {BootstrapVueOptions} from './types'
34

45
import './styles/styles.scss'
@@ -116,20 +117,19 @@ declare module '@vue/runtime-core' {
116117

117118
// Main app plugin
118119
const plugin: Plugin = {
119-
// TODO: use options in the future
120-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
121-
install(app: App, options: BootstrapVueOptions = {}) {
120+
install(app: App, options?: BootstrapVueOptions) {
122121
Object.entries(Components).forEach(([name, component]) => {
123-
app.component(name, component)
122+
if (!options?.components || options?.components[name as keyof typeof Components])
123+
app.component(name, component)
124124
})
125125

126126
Object.entries(Directives).forEach(([name, component]) => {
127-
if (name.toLowerCase().startsWith('v')) {
128-
app.directive(name.slice(1), component)
129-
} else {
130-
app.directive(name, component)
131-
}
127+
const parsedName = name.toLowerCase().startsWith('v') ? name.slice(1) : name
128+
if (!options?.directives || options?.directives[parsedName as keyof typeof Directives])
129+
app.directive(parsedName, component)
132130
})
131+
132+
if (options?.BToast) app.use(BToastPlugin, options)
133133
},
134134
}
135135

packages/bootstrap-vue-next/src/components/BToast/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export function useToast(vm?: any, key: symbol = injectkey): ToastInstance | und
223223
}
224224

225225
const BToastPlugin: Plugin = {
226-
install: (app: App, options: BootstrapVueOptions = {}) => {
226+
install: (app: App, options?: BootstrapVueOptions) => {
227227
app.provide(fetchKey, options?.BToast?.injectkey ?? injectkey)
228228
app.provide(options?.BToast?.injectkey ?? injectkey, new ToastController())
229229
},
Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
// TODO: Create the options for every component
1+
import * as Components from '../components'
2+
import * as Directives from '../directives/exports'
23

34
interface BToastPluginOptions {
45
injectkey: symbol
56
}
67

78
export interface BootstrapVueOptions {
8-
BAccordion?: Record<string, any>
9-
BAlert?: Record<string, any>
10-
BBadge?: Record<string, any>
11-
BButton?: Record<string, any>
12-
BButtonGroup?: Record<string, any>
13-
BButtonToolbar?: Record<string, any>
14-
BCard?: Record<string, any>
15-
BCollapse?: Record<string, any>
16-
BDropdown?: Record<string, any>
17-
BListGroup?: Record<string, any>
18-
BModal?: Record<string, any>
19-
BOffcanvas?: Record<string, any>
20-
BProgress?: Record<string, any>
21-
BSpinner?: Record<string, any>
22-
BTab?: Record<string, any>
9+
components?: Record<keyof typeof Components, boolean>
10+
directives?: Record<keyof typeof Directives, boolean>
2311
BToast?: BToastPluginOptions
2412
}

0 commit comments

Comments
 (0)