vuikit
Version:
A Vuejs component library based on UIkit
73 lines (68 loc) • 2.1 kB
JavaScript
/**
* Vuikit 0.7.0
* (c) 2018 Miljan Aleksic
* @license MIT
*/
var subnav = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('ul',{staticClass:"uk-subnav",class:{ 'uk-subnav-divider': _vm.divider, 'uk-subnav-pill': _vm.pill }},[_vm._t("default")],2)},staticRenderFns: [],
name: 'Subnav',
props: {
activeItem: [String, Number],
divider: {
type: Boolean,
default: false
},
pill: {
type: Boolean,
default: false
}
},
computed: {
items: {
get: function get () {
return this.$slots.default.filter(function (c) { return c.componentOptions && c.componentOptions.tag === 'vk-subnav-item'; }
)
},
cache: false
}
},
beforeMount: function beforeMount () {
this.updateItems();
},
beforeUpdate: function beforeUpdate () {
this.updateItems();
},
methods: {
updateItems: function updateItems () {
var this$1 = this;
this.items.forEach(function (item, index) {
var alias = this$1.getItemAlias(item);
var active = this$1.activeItem === alias;
var props = item.componentOptions.propsData;
props.active = active;
props.alias = alias;
});
},
getItemAlias: function getItemAlias (item) {
return item.componentOptions.propsData.alias || this.items.indexOf(item) + 1
}
}
}
var subnavItem = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('li',{class:{ 'uk-active': _vm.active, 'uk-disabled': _vm.disabled }},[_c('a',{on:{"click":function($event){$event.preventDefault();(!_vm.disabled && !_vm.active) && _vm.$parent.$emit('change', _vm.alias);}}},[_vm._t("default",[_vm._v(_vm._s(_vm.label))])],2)])},staticRenderFns: [],
name: 'SubnavItem',
props: {
label: String,
alias: {
type: [String, Number],
default: ''
},
active: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
}
}
}
export { subnav as Subnav, subnavItem as SubnavItem };