vuetify
Version:
Vue.js 2 Semantic Component Framework
110 lines (85 loc) • 2.54 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
require('../../../src/stylus/components/_chips.styl');
var _VIcon = require('../VIcon');
var _VIcon2 = _interopRequireDefault(_VIcon);
var _colorable = require('../../mixins/colorable');
var _colorable2 = _interopRequireDefault(_colorable);
var _themeable = require('../../mixins/themeable');
var _themeable2 = _interopRequireDefault(_themeable);
var _toggleable = require('../../mixins/toggleable');
var _toggleable2 = _interopRequireDefault(_toggleable);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
name: 'v-chip',
components: {
VIcon: _VIcon2.default
},
mixins: [_colorable2.default, _themeable2.default, _toggleable2.default],
props: {
close: Boolean,
disabled: Boolean,
label: Boolean,
outline: Boolean,
// Used for selects/tagging
selected: Boolean,
small: Boolean,
textColor: String,
value: {
type: Boolean,
default: true
}
},
computed: {
classes: function classes() {
var classes = this.addBackgroundColorClassChecks({
'chip--disabled': this.disabled,
'chip--selected': this.selected,
'chip--label': this.label,
'chip--outline': this.outline,
'chip--small': this.small,
'chip--removable': this.close,
'theme--light': this.light,
'theme--dark': this.dark
});
return this.textColor || this.outline ? this.addTextColorClassChecks(classes, this.textColor || this.color) : classes;
}
},
methods: {
genClose: function genClose(h) {
var _this = this;
var data = {
staticClass: 'chip__close',
on: {
click: function click(e) {
e.stopPropagation();
_this.$emit('input', false);
}
}
};
return h('div', data, [h(_VIcon2.default, 'cancel')]);
},
genContent: function genContent(h) {
var children = [this.$slots.default];
this.close && children.push(this.genClose(h));
return h('span', {
staticClass: 'chip__content'
}, children);
}
},
render: function render(h) {
var data = {
staticClass: 'chip',
'class': this.classes,
attrs: { tabindex: this.disabled ? -1 : 0 },
directives: [{
name: 'show',
value: this.isActive
}],
on: this.$listeners
};
return h('span', data, [this.genContent(h)]);
}
};