Skip to content

fix(docs): fix component plugin's included plugins and directives #2966

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

Merged
merged 27 commits into from
Mar 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/components/importdoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default {
const firstDirective = this.directives[0]
const firstDirectiveImport = this.directiveImports[0]
return [
"// <b>Note:</b> Vue automatically prefixes the directive name with 'v-'",
"// Note: Vue automatically prefixes the directive name with 'v-'",
`import ${firstDirective} from '${firstDirectiveImport.importPath}'`,
`Vue.directive('${this.directiveName(firstDirective)}', ${firstDirective})`
].join('\n')
Expand Down Expand Up @@ -183,7 +183,7 @@ export default {
return kebabCase(directive).replace(/^v-/, '')
},
directiveAttr(directive) {
return this.directiveName(directive)
return kebabCase(directive)
},
directivePath(directive) {
const directiveName = this.directiveName(directive).replace(/^b-/, '')
Expand Down
8 changes: 4 additions & 4 deletions src/components/collapse/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import BCollapse from './collapse'
import BToggleDirectivePlugin from '../../directives/toggle'
import BToggleDirective from '../../directives/toggle/toggle'
import { installFactory } from '../../utils/plugins'

const components = {
BCollapse
}

const plugins = {
BToggleDirectivePlugin
const directives = {
BToggle: BToggleDirective
}

export default {
install: installFactory({ components, plugins })
install: installFactory({ components, directives })
}
6 changes: 3 additions & 3 deletions src/components/collapse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"meta": {
"title": "Collapse",
"description": "Easily toggle content visibility on your pages. Includes support for making accordions.",
"directives": [
"vBToggle"
],
"components": [
{
"component": "BCollapse",
"directives": [
"vBToggle"
],
"events": [
{
"event": "show",
Expand Down
8 changes: 4 additions & 4 deletions src/components/modal/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import BModal from './modal'
import BModalDirectivePlugin from '../../directives/modal'
import BModalDirective from '../../directives/modal/modal'
import { installFactory } from '../../utils/plugins'

const components = {
BModal
}

const plugins = {
BModalDirectivePlugin
const directives = {
BModal: BModalDirective
}

export default {
install: installFactory({ components, plugins })
install: installFactory({ components, directives })
}
6 changes: 3 additions & 3 deletions src/components/modal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"meta": {
"title": "Modal",
"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.",
"directives": [
"vBModal"
],
"components": [
{
"component": "BModal",
"directives": [
"vBModal"
],
"events": [
{
"event": "change",
Expand Down
10 changes: 4 additions & 6 deletions src/components/nav/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
"meta": {
"title": "Nav",
"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.",
"plugins": [
"Dropdown"
],
"components": [
{
"component": "BNav",
"plugins": [
"Dropdown"
]
},
"BNav",
"BNavItem",
"BNavText",
"BNavForm",
Expand Down
14 changes: 6 additions & 8 deletions src/components/navbar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
"meta": {
"title": "Navbar",
"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.",
"plugins": [
"Nav",
"Dropdown",
"Collapse"
],
"components": [
{
"component": "BNavbar",
"plugins": [
"Nav",
"Dropdown",
"Collapse"
]
},
"BNavbar",
"BNavbarNav",
"BNavbarBrand",
{
Expand Down
8 changes: 4 additions & 4 deletions src/components/popover/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import BPopover from './popover'
import BPopoverDirectivePlugin from '../../directives/popover'
import BPopoverDirective from '../../directives/popover/popover'
import { installFactory } from '../../utils/plugins'

const components = {
BPopover
}

const plugins = {
BPopoverDirectivePlugin
const directives = {
BPopover: BPopoverDirective
}

export default {
install: installFactory({ components, plugins })
install: installFactory({ components, directives })
}
6 changes: 3 additions & 3 deletions src/components/popover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"meta": {
"title": "Popover",
"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",
"directives": [
"vBPopover"
],
"components": [
{
"component": "BPopover",
"directives": [
"vBPopover"
],
"events": [
{
"event": "show",
Expand Down
8 changes: 4 additions & 4 deletions src/components/tooltip/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import BTooltip from './tooltip'
import BTooltipDirectivePlugin from '../../directives/tooltip'
import BTooltipDirective from '../../directives/tooltip/tooltip'
import { installFactory } from '../../utils/plugins'

const components = {
BTooltip
}

const plugins = {
BTooltipDirectivePlugin
const directives = {
BTooltip: BTooltipDirective
}

export default {
install: installFactory({ components, plugins })
install: installFactory({ components, directives })
}
6 changes: 3 additions & 3 deletions src/components/tooltip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"meta": {
"title": "Tooltip",
"description": "Easily add tooltips to elements or components via the <b-tooltip> component or v-b-tooltip directive.",
"directives": [
"vBTooltip"
],
"components": [
{
"component": "BTooltip",
"directives": [
"vBTooltip"
],
"events": [
{
"event": "show",
Expand Down
34 changes: 21 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@ import * as directivePlugins from './directives'
import { registerPlugins, vueUse } from './utils/plugins'
import { setConfig } from './utils/config'

const BootstrapVue = {
install(Vue, config = {}) {
// Configure BootstrapVue
setConfig(config)

// Register component plugins
registerPlugins(Vue, componentPlugins)

// Register directive plugins
registerPlugins(Vue, directivePlugins)
},
setConfig(config = {}) /* istanbul ignore next */ {
setConfig(config)
const install = (Vue, config = {}) => {
if (install.installed) {
/* istanbul ignore next */
return
}
install.installed = true

// Configure BootstrapVue
setConfig(config)

// Register component plugins
registerPlugins(Vue, componentPlugins)

// Register directive plugins
registerPlugins(Vue, directivePlugins)
}

install.installed = false

const BootstrapVue = {
install: install,
setConfig: setConfig
}

// Auto installation only occurs if window.Vue exists
Expand Down
10 changes: 9 additions & 1 deletion src/utils/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ import { setConfig } from './config'
* @returns {function} plugin install function
*/
export const installFactory = ({ components, directives, plugins }) => {
return (Vue, config = {}) => {
const install = (Vue, config = {}) => {
if (install.installed) {
/* istanbul ignore next */
return
}
install.installed = true
setConfig(config)
registerComponents(Vue, components)
registerDirectives(Vue, directives)
registerPlugins(Vue, plugins)
}
install.installed = false

return install
}

/**
Expand Down