158 lines
No EOL
5.3 KiB
JavaScript
158 lines
No EOL
5.3 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = void 0;
|
|
|
|
require("../../../src/components/VList/VListItem.sass");
|
|
|
|
var _colorable = _interopRequireDefault(require("../../mixins/colorable"));
|
|
|
|
var _routable = _interopRequireDefault(require("../../mixins/routable"));
|
|
|
|
var _groupable = require("../../mixins/groupable");
|
|
|
|
var _themeable = _interopRequireDefault(require("../../mixins/themeable"));
|
|
|
|
var _toggleable = require("../../mixins/toggleable");
|
|
|
|
var _ripple = _interopRequireDefault(require("../../directives/ripple"));
|
|
|
|
var _helpers = require("./../../util/helpers");
|
|
|
|
var _console = require("../../util/console");
|
|
|
|
var _mixins = _interopRequireDefault(require("../../util/mixins"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
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; }
|
|
|
|
var baseMixins = (0, _mixins.default)(_colorable.default, _routable.default, _themeable.default, (0, _groupable.factory)('listItemGroup'), (0, _toggleable.factory)('inputValue'));
|
|
/* @vue/component */
|
|
|
|
var _default2 = baseMixins.extend().extend({
|
|
name: 'v-list-item',
|
|
directives: {
|
|
Ripple: _ripple.default
|
|
},
|
|
inheritAttrs: false,
|
|
inject: {
|
|
isInGroup: {
|
|
default: false
|
|
},
|
|
isInList: {
|
|
default: false
|
|
},
|
|
isInMenu: {
|
|
default: false
|
|
},
|
|
isInNav: {
|
|
default: false
|
|
}
|
|
},
|
|
props: {
|
|
activeClass: {
|
|
type: String,
|
|
default: function _default() {
|
|
if (!this.listItemGroup) return '';
|
|
return this.listItemGroup.activeClass;
|
|
}
|
|
},
|
|
dense: Boolean,
|
|
inactive: Boolean,
|
|
link: Boolean,
|
|
tag: {
|
|
type: String,
|
|
default: 'div'
|
|
},
|
|
threeLine: Boolean,
|
|
twoLine: Boolean,
|
|
value: null
|
|
},
|
|
data: function data() {
|
|
return {
|
|
proxyClass: 'v-list-item--active'
|
|
};
|
|
},
|
|
computed: {
|
|
classes: function classes() {
|
|
return _objectSpread({
|
|
'v-list-item': true
|
|
}, _routable.default.options.computed.classes.call(this), {
|
|
'v-list-item--dense': this.dense,
|
|
'v-list-item--disabled': this.disabled,
|
|
'v-list-item--link': this.isClickable && !this.inactive,
|
|
'v-list-item--three-line': this.threeLine,
|
|
'v-list-item--two-line': this.twoLine
|
|
}, this.themeClasses);
|
|
},
|
|
isClickable: function isClickable() {
|
|
return Boolean(_routable.default.options.computed.isClickable.call(this) || this.listItemGroup);
|
|
}
|
|
},
|
|
created: function created() {
|
|
/* istanbul ignore next */
|
|
if (this.$attrs.hasOwnProperty('avatar')) {
|
|
(0, _console.removed)('avatar', this);
|
|
}
|
|
},
|
|
methods: {
|
|
click: function click(e) {
|
|
if (e.detail) this.$el.blur();
|
|
this.$emit('click', e);
|
|
this.to || this.toggle();
|
|
},
|
|
genAttrs: function genAttrs() {
|
|
var attrs = _objectSpread({
|
|
'aria-disabled': this.disabled ? true : undefined,
|
|
tabindex: this.isClickable && !this.disabled ? 0 : -1
|
|
}, this.$attrs);
|
|
|
|
if (this.$attrs.hasOwnProperty('role')) {// do nothing, role already provided
|
|
} else if (this.isInNav) {// do nothing, role is inherit
|
|
} else if (this.isInGroup) {
|
|
attrs.role = 'listitem';
|
|
attrs['aria-selected'] = String(this.isActive);
|
|
} else if (this.isInMenu) {
|
|
attrs.role = this.isClickable ? 'menuitem' : undefined;
|
|
} else if (this.isInList && !this.isLink) {
|
|
attrs.role = 'listitem';
|
|
}
|
|
|
|
return attrs;
|
|
}
|
|
},
|
|
render: function render(h) {
|
|
var _this = this;
|
|
|
|
var _this$generateRouteLi = this.generateRouteLink(),
|
|
tag = _this$generateRouteLi.tag,
|
|
data = _this$generateRouteLi.data;
|
|
|
|
data.attrs = _objectSpread({}, data.attrs, {}, this.genAttrs());
|
|
data.on = _objectSpread({}, data.on, {
|
|
click: this.click,
|
|
keydown: function keydown(e) {
|
|
/* istanbul ignore else */
|
|
if (e.keyCode === _helpers.keyCodes.enter) _this.click(e);
|
|
|
|
_this.$emit('keydown', e);
|
|
}
|
|
});
|
|
var children = this.$scopedSlots.default ? this.$scopedSlots.default({
|
|
active: this.isActive,
|
|
toggle: this.toggle
|
|
}) : this.$slots.default;
|
|
tag = this.inactive ? 'div' : tag;
|
|
return h(tag, this.setTextColor(this.color, data), children);
|
|
}
|
|
});
|
|
|
|
exports.default = _default2;
|
|
//# sourceMappingURL=VListItem.js.map
|