192 lines
6.8 KiB
JavaScript
192 lines
6.8 KiB
JavaScript
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.default = void 0;
|
||
|
|
||
|
require("../../../src/components/VChip/VChip.sass");
|
||
|
|
||
|
var _mixins = _interopRequireDefault(require("../../util/mixins"));
|
||
|
|
||
|
var _transitions = require("../transitions");
|
||
|
|
||
|
var _VIcon = _interopRequireDefault(require("../VIcon"));
|
||
|
|
||
|
var _colorable = _interopRequireDefault(require("../../mixins/colorable"));
|
||
|
|
||
|
var _groupable = require("../../mixins/groupable");
|
||
|
|
||
|
var _themeable = _interopRequireDefault(require("../../mixins/themeable"));
|
||
|
|
||
|
var _toggleable = require("../../mixins/toggleable");
|
||
|
|
||
|
var _routable = _interopRequireDefault(require("../../mixins/routable"));
|
||
|
|
||
|
var _sizeable = _interopRequireDefault(require("../../mixins/sizeable"));
|
||
|
|
||
|
var _console = require("../../util/console");
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
||
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
||
|
|
||
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
||
|
|
||
|
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||
|
|
||
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||
|
|
||
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||
|
|
||
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||
|
|
||
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||
|
|
||
|
/* @vue/component */
|
||
|
var _default2 = (0, _mixins.default)(_colorable.default, _sizeable.default, _routable.default, _themeable.default, (0, _groupable.factory)('chipGroup'), (0, _toggleable.factory)('inputValue')).extend({
|
||
|
name: 'v-chip',
|
||
|
props: {
|
||
|
active: {
|
||
|
type: Boolean,
|
||
|
default: true
|
||
|
},
|
||
|
activeClass: {
|
||
|
type: String,
|
||
|
default: function _default() {
|
||
|
if (!this.chipGroup) return '';
|
||
|
return this.chipGroup.activeClass;
|
||
|
}
|
||
|
},
|
||
|
close: Boolean,
|
||
|
closeIcon: {
|
||
|
type: String,
|
||
|
default: '$vuetify.icons.delete'
|
||
|
},
|
||
|
disabled: Boolean,
|
||
|
draggable: Boolean,
|
||
|
filter: Boolean,
|
||
|
filterIcon: {
|
||
|
type: String,
|
||
|
default: '$vuetify.icons.complete'
|
||
|
},
|
||
|
label: Boolean,
|
||
|
link: Boolean,
|
||
|
outlined: Boolean,
|
||
|
pill: Boolean,
|
||
|
tag: {
|
||
|
type: String,
|
||
|
default: 'span'
|
||
|
},
|
||
|
textColor: String,
|
||
|
value: null
|
||
|
},
|
||
|
data: function data() {
|
||
|
return {
|
||
|
proxyClass: 'v-chip--active'
|
||
|
};
|
||
|
},
|
||
|
computed: {
|
||
|
classes: function classes() {
|
||
|
return _objectSpread({
|
||
|
'v-chip': true
|
||
|
}, _routable.default.options.computed.classes.call(this), {
|
||
|
'v-chip--clickable': this.isClickable,
|
||
|
'v-chip--disabled': this.disabled,
|
||
|
'v-chip--draggable': this.draggable,
|
||
|
'v-chip--label': this.label,
|
||
|
'v-chip--link': this.isLink,
|
||
|
'v-chip--no-color': !this.color,
|
||
|
'v-chip--outlined': this.outlined,
|
||
|
'v-chip--pill': this.pill,
|
||
|
'v-chip--removable': this.hasClose
|
||
|
}, this.themeClasses, {}, this.sizeableClasses, {}, this.groupClasses);
|
||
|
},
|
||
|
hasClose: function hasClose() {
|
||
|
return Boolean(this.close);
|
||
|
},
|
||
|
isClickable: function isClickable() {
|
||
|
return Boolean(_routable.default.options.computed.isClickable.call(this) || this.chipGroup);
|
||
|
}
|
||
|
},
|
||
|
created: function created() {
|
||
|
var _this = this;
|
||
|
|
||
|
var breakingProps = [['outline', 'outlined'], ['selected', 'input-value'], ['value', 'active'], ['@input', '@active.sync']];
|
||
|
/* istanbul ignore next */
|
||
|
|
||
|
breakingProps.forEach(function (_ref) {
|
||
|
var _ref2 = _slicedToArray(_ref, 2),
|
||
|
original = _ref2[0],
|
||
|
replacement = _ref2[1];
|
||
|
|
||
|
if (_this.$attrs.hasOwnProperty(original)) (0, _console.breaking)(original, replacement, _this);
|
||
|
});
|
||
|
},
|
||
|
methods: {
|
||
|
click: function click(e) {
|
||
|
this.$emit('click', e);
|
||
|
this.chipGroup && this.toggle();
|
||
|
},
|
||
|
genFilter: function genFilter() {
|
||
|
var children = [];
|
||
|
|
||
|
if (this.isActive) {
|
||
|
children.push(this.$createElement(_VIcon.default, {
|
||
|
staticClass: 'v-chip__filter',
|
||
|
props: {
|
||
|
left: true
|
||
|
}
|
||
|
}, this.filterIcon));
|
||
|
}
|
||
|
|
||
|
return this.$createElement(_transitions.VExpandXTransition, children);
|
||
|
},
|
||
|
genClose: function genClose() {
|
||
|
var _this2 = this;
|
||
|
|
||
|
return this.$createElement(_VIcon.default, {
|
||
|
staticClass: 'v-chip__close',
|
||
|
props: {
|
||
|
right: true
|
||
|
},
|
||
|
on: {
|
||
|
click: function click(e) {
|
||
|
e.stopPropagation();
|
||
|
|
||
|
_this2.$emit('click:close');
|
||
|
|
||
|
_this2.$emit('update:active', false);
|
||
|
}
|
||
|
}
|
||
|
}, this.closeIcon);
|
||
|
},
|
||
|
genContent: function genContent() {
|
||
|
return this.$createElement('span', {
|
||
|
staticClass: 'v-chip__content'
|
||
|
}, [this.filter && this.genFilter(), this.$slots.default, this.hasClose && this.genClose()]);
|
||
|
}
|
||
|
},
|
||
|
render: function render(h) {
|
||
|
var children = [this.genContent()];
|
||
|
|
||
|
var _this$generateRouteLi = this.generateRouteLink(),
|
||
|
tag = _this$generateRouteLi.tag,
|
||
|
data = _this$generateRouteLi.data;
|
||
|
|
||
|
data.attrs = _objectSpread({}, data.attrs, {
|
||
|
draggable: this.draggable ? 'true' : undefined,
|
||
|
tabindex: this.chipGroup && !this.disabled ? 0 : data.attrs.tabindex
|
||
|
});
|
||
|
data.directives.push({
|
||
|
name: 'show',
|
||
|
value: this.active
|
||
|
});
|
||
|
data = this.setBackgroundColor(this.color, data);
|
||
|
var color = this.textColor || this.outlined && this.color;
|
||
|
return h(tag, this.setTextColor(color, data), children);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
exports.default = _default2;
|
||
|
//# sourceMappingURL=VChip.js.map
|