Skip to content

Commit cbf24c3

Browse files
authored
fix(docs): fix component plugin's included plugins and directives (#2966)
1 parent a2f898b commit cbf24c3

File tree

13 files changed

+70
-58
lines changed

13 files changed

+70
-58
lines changed

docs/components/importdoc.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default {
144144
const firstDirective = this.directives[0]
145145
const firstDirectiveImport = this.directiveImports[0]
146146
return [
147-
"// <b>Note:</b> Vue automatically prefixes the directive name with 'v-'",
147+
"// Note: Vue automatically prefixes the directive name with 'v-'",
148148
`import ${firstDirective} from '${firstDirectiveImport.importPath}'`,
149149
`Vue.directive('${this.directiveName(firstDirective)}', ${firstDirective})`
150150
].join('\n')
@@ -183,7 +183,7 @@ export default {
183183
return kebabCase(directive).replace(/^v-/, '')
184184
},
185185
directiveAttr(directive) {
186-
return this.directiveName(directive)
186+
return kebabCase(directive)
187187
},
188188
directivePath(directive) {
189189
const directiveName = this.directiveName(directive).replace(/^b-/, '')

src/components/collapse/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import BCollapse from './collapse'
2-
import BToggleDirectivePlugin from '../../directives/toggle'
2+
import BToggleDirective from '../../directives/toggle/toggle'
33
import { installFactory } from '../../utils/plugins'
44

55
const components = {
66
BCollapse
77
}
88

9-
const plugins = {
10-
BToggleDirectivePlugin
9+
const directives = {
10+
BToggle: BToggleDirective
1111
}
1212

1313
export default {
14-
install: installFactory({ components, plugins })
14+
install: installFactory({ components, directives })
1515
}

src/components/collapse/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"meta": {
55
"title": "Collapse",
66
"description": "Easily toggle content visibility on your pages. Includes support for making accordions.",
7+
"directives": [
8+
"vBToggle"
9+
],
710
"components": [
811
{
912
"component": "BCollapse",
10-
"directives": [
11-
"vBToggle"
12-
],
1313
"events": [
1414
{
1515
"event": "show",

src/components/modal/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import BModal from './modal'
2-
import BModalDirectivePlugin from '../../directives/modal'
2+
import BModalDirective from '../../directives/modal/modal'
33
import { installFactory } from '../../utils/plugins'
44

55
const components = {
66
BModal
77
}
88

9-
const plugins = {
10-
BModalDirectivePlugin
9+
const directives = {
10+
BModal: BModalDirective
1111
}
1212

1313
export default {
14-
install: installFactory({ components, plugins })
14+
install: installFactory({ components, directives })
1515
}

src/components/modal/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"meta": {
55
"title": "Modal",
66
"description": "Modals are streamlined, but flexible dialog prompts powered by JavaScript and CSS. They support a number of use cases from user notification to completely custom content and feature a handful of helpful sub-components, sizes, variants, accessibility, and more.",
7+
"directives": [
8+
"vBModal"
9+
],
710
"components": [
811
{
912
"component": "BModal",
10-
"directives": [
11-
"vBModal"
12-
],
1313
"events": [
1414
{
1515
"event": "change",

src/components/nav/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
"meta": {
55
"title": "Nav",
66
"description": "Navigation components that share general markup and styles, from the base <b-nav> class to the active and disabled states. Swap modifier props to switch between each style.",
7+
"plugins": [
8+
"Dropdown"
9+
],
710
"components": [
8-
{
9-
"component": "BNav",
10-
"plugins": [
11-
"Dropdown"
12-
]
13-
},
11+
"BNav",
1412
"BNavItem",
1513
"BNavText",
1614
"BNavForm",

src/components/navbar/package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
"meta": {
55
"title": "Navbar",
66
"description": "The component <b-navbar> is a responsive wrapper that positions branding, navigation, and other elements into a concise header. It’s easily extensible and thanks to the <b-collapse> component.",
7+
"plugins": [
8+
"Nav",
9+
"Dropdown",
10+
"Collapse"
11+
],
712
"components": [
8-
{
9-
"component": "BNavbar",
10-
"plugins": [
11-
"Nav",
12-
"Dropdown",
13-
"Collapse"
14-
]
15-
},
13+
"BNavbar",
1614
"BNavbarNav",
1715
"BNavbarBrand",
1816
{

src/components/popover/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import BPopover from './popover'
2-
import BPopoverDirectivePlugin from '../../directives/popover'
2+
import BPopoverDirective from '../../directives/popover/popover'
33
import { installFactory } from '../../utils/plugins'
44

55
const components = {
66
BPopover
77
}
88

9-
const plugins = {
10-
BPopoverDirectivePlugin
9+
const directives = {
10+
BPopover: BPopoverDirective
1111
}
1212

1313
export default {
14-
install: installFactory({ components, plugins })
14+
install: installFactory({ components, directives })
1515
}

src/components/popover/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"meta": {
55
"title": "Popover",
66
"description": "The Popover feature provides a tooltip-like behavior, can be easily applied to any interactive element via the <b-popover> component or v-b-popover directive",
7+
"directives": [
8+
"vBPopover"
9+
],
710
"components": [
811
{
912
"component": "BPopover",
10-
"directives": [
11-
"vBPopover"
12-
],
1313
"events": [
1414
{
1515
"event": "show",

src/components/tooltip/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import BTooltip from './tooltip'
2-
import BTooltipDirectivePlugin from '../../directives/tooltip'
2+
import BTooltipDirective from '../../directives/tooltip/tooltip'
33
import { installFactory } from '../../utils/plugins'
44

55
const components = {
66
BTooltip
77
}
88

9-
const plugins = {
10-
BTooltipDirectivePlugin
9+
const directives = {
10+
BTooltip: BTooltipDirective
1111
}
1212

1313
export default {
14-
install: installFactory({ components, plugins })
14+
install: installFactory({ components, directives })
1515
}

src/components/tooltip/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"meta": {
55
"title": "Tooltip",
66
"description": "Easily add tooltips to elements or components via the <b-tooltip> component or v-b-tooltip directive.",
7+
"directives": [
8+
"vBTooltip"
9+
],
710
"components": [
811
{
912
"component": "BTooltip",
10-
"directives": [
11-
"vBTooltip"
12-
],
1313
"events": [
1414
{
1515
"event": "show",

src/index.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,28 @@ import * as directivePlugins from './directives'
33
import { registerPlugins, vueUse } from './utils/plugins'
44
import { setConfig } from './utils/config'
55

6-
const BootstrapVue = {
7-
install(Vue, config = {}) {
8-
// Configure BootstrapVue
9-
setConfig(config)
10-
11-
// Register component plugins
12-
registerPlugins(Vue, componentPlugins)
13-
14-
// Register directive plugins
15-
registerPlugins(Vue, directivePlugins)
16-
},
17-
setConfig(config = {}) /* istanbul ignore next */ {
18-
setConfig(config)
6+
const install = (Vue, config = {}) => {
7+
if (install.installed) {
8+
/* istanbul ignore next */
9+
return
1910
}
11+
install.installed = true
12+
13+
// Configure BootstrapVue
14+
setConfig(config)
15+
16+
// Register component plugins
17+
registerPlugins(Vue, componentPlugins)
18+
19+
// Register directive plugins
20+
registerPlugins(Vue, directivePlugins)
21+
}
22+
23+
install.installed = false
24+
25+
const BootstrapVue = {
26+
install: install,
27+
setConfig: setConfig
2028
}
2129

2230
// Auto installation only occurs if window.Vue exists

src/utils/plugins.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@ import { setConfig } from './config'
66
* @returns {function} plugin install function
77
*/
88
export const installFactory = ({ components, directives, plugins }) => {
9-
return (Vue, config = {}) => {
9+
const install = (Vue, config = {}) => {
10+
if (install.installed) {
11+
/* istanbul ignore next */
12+
return
13+
}
14+
install.installed = true
1015
setConfig(config)
1116
registerComponents(Vue, components)
1217
registerDirectives(Vue, directives)
1318
registerPlugins(Vue, plugins)
1419
}
20+
install.installed = false
21+
22+
return install
1523
}
1624

1725
/**

0 commit comments

Comments
 (0)