UNPKG

bootstrap-vue

Version:

With more than 85 components, over 45 available plugins, several directives, and 1000+ icons, BootstrapVue provides one of the most comprehensive implementations of the Bootstrap v4 component and grid system available for Vue.js v2.6, complete with extens

45 lines (40 loc) 1.25 kB
import Vue, { mergeData } from '../../vue' import { NAME_BREADCRUMB } from '../../constants/components' import { isArray, isObject } from '../../utils/inspect' import { toString } from '../../utils/string' import { BBreadcrumbItem } from './breadcrumb-item' export const props = { items: { type: Array, default: null } } // @vue/component export const BBreadcrumb = /*#__PURE__*/ Vue.extend({ name: NAME_BREADCRUMB, functional: true, props, render(h, { props, data, children }) { let childNodes = children // Build child nodes from items if given. if (isArray(props.items)) { let activeDefined = false childNodes = props.items.map((item, idx) => { if (!isObject(item)) { item = { text: toString(item) } } // Copy the value here so we can normalize it. let active = item.active if (active) { activeDefined = true } if (!active && !activeDefined) { // Auto-detect active by position in list. active = idx + 1 === props.items.length } return h(BBreadcrumbItem, { props: { ...item, active } }) }) } return h('ol', mergeData(data, { staticClass: 'breadcrumb' }), childNodes) } })