UNPKG

vuetify

Version:

Vue.js 2 Semantic Component Framework

116 lines (94 loc) 2.72 kB
import { VExpandTransition } from '../transitions'; import Bootable from '../../mixins/bootable'; import Toggleable from '../../mixins/toggleable'; import Rippleable from '../../mixins/rippleable'; import VIcon from '../VIcon'; import ClickOutside from '../../directives/click-outside'; export default { name: 'v-expansion-panel-content', mixins: [Bootable, Toggleable, Rippleable], components: { VIcon: VIcon }, directives: { ClickOutside: ClickOutside }, inject: ['focusable', 'panelClick'], data: function data() { return { height: 'auto' }; }, props: { hideActions: Boolean, ripple: { type: [Boolean, Object], default: false } }, methods: { genBody: function genBody() { return this.$createElement('div', { ref: 'body', class: 'expansion-panel__body', directives: [{ name: 'show', value: this.isActive }] }, this.showLazyContent(this.$slots.default)); }, genHeader: function genHeader() { var _this = this; return this.$createElement('div', { staticClass: 'expansion-panel__header', directives: [{ name: 'ripple', value: this.ripple }], on: { click: function click() { return _this.panelClick(_this._uid); } } }, [this.$slots.header, this.genIcon()]); }, genIcon: function genIcon(h) { if (this.hideActions) return null; var icon = this.$slots.actions || this.$createElement('v-icon', 'keyboard_arrow_down'); return this.$createElement('div', { staticClass: 'header__icon' }, [icon]); }, toggle: function toggle(uid) { var _this2 = this; var isActive = this._uid === uid && !this.isActive; if (isActive) this.isBooted = true; // We treat bootable differently // Needs time to calc height this.$nextTick(function () { return _this2.isActive = isActive; }); } }, render: function render(h) { var _this3 = this; var children = []; this.$slots.header && children.push(this.genHeader()); children.push(h(VExpandTransition, [this.genBody()])); return h('li', { staticClass: 'expansion-panel__container', 'class': { 'expansion-panel__container--active': this.isActive }, attrs: { tabindex: 0 }, on: { keydown: function keydown(e) { // Ensure element is focusable and the activeElement if (_this3.focusable && _this3.$el === document.activeElement && e.keyCode === 13) _this3.panelClick(_this3._uid); } } }, children); } };