'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Components

// Mixins

// Directives

// Utilities


var _transitions = require('../transitions');

var _VIcon = require('../VIcon');

var _VIcon2 = _interopRequireDefault(_VIcon);

var _registrable = require('../../mixins/registrable');

var _ripple = require('../../directives/ripple');

var _ripple2 = _interopRequireDefault(_ripple);

var _helpers = require('../../util/helpers');

var _mixins = require('../../util/mixins');

var _mixins2 = _interopRequireDefault(_mixins);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var baseMixins = (0, _mixins2.default)((0, _registrable.inject)('expansionPanel', 'v-expansion-panel-header', 'v-expansion-panel'));
exports.default = baseMixins.extend().extend({
    name: 'v-expansion-panel-header',
    directives: { Ripple: _ripple2.default },
    props: {
        disableIconRotate: Boolean,
        expandIcon: {
            type: String,
            default: '$vuetify.icons.expand'
        },
        hideActions: Boolean,
        ripple: {
            type: [Boolean, Object],
            default: false
        }
    },
    data: function data() {
        return {
            hasMousedown: false
        };
    },
    computed: {
        classes: function classes() {
            return {
                'v-expansion-panel-header--mousedown': this.hasMousedown
            };
        },
        isActive: function isActive() {
            return this.expansionPanel.isActive;
        },
        isDisabled: function isDisabled() {
            return this.expansionPanel.isDisabled;
        },
        isReadonly: function isReadonly() {
            return this.expansionPanel.isReadonly;
        }
    },
    created: function created() {
        this.expansionPanel.registerHeader(this);
    },
    beforeDestroy: function beforeDestroy() {
        this.expansionPanel.unregisterHeader();
    },

    methods: {
        onClick: function onClick(e) {
            this.$emit('click', e);
        },
        genIcon: function genIcon() {
            var icon = (0, _helpers.getSlot)(this, 'actions') || [this.$createElement(_VIcon2.default, this.expandIcon)];
            return this.$createElement(_transitions.VFadeTransition, [this.$createElement('div', {
                staticClass: 'v-expansion-panel-header__icon',
                class: {
                    'v-expansion-panel-header__icon--disable-rotate': this.disableIconRotate
                },
                directives: [{
                    name: 'show',
                    value: !this.isDisabled
                }]
            }, icon)]);
        }
    },
    render: function render(h) {
        var _this = this;

        return h('button', {
            staticClass: 'v-expansion-panel-header',
            class: this.classes,
            attrs: {
                tabindex: this.isDisabled ? -1 : null
            },
            directives: [{
                name: 'ripple',
                value: this.ripple
            }],
            on: _extends({}, this.$listeners, {
                click: this.onClick,
                mousedown: function mousedown() {
                    return _this.hasMousedown = true;
                },
                mouseup: function mouseup() {
                    return _this.hasMousedown = false;
                }
            })
        }, [(0, _helpers.getSlot)(this, 'default', { open: this.isActive }, true), this.hideActions || this.genIcon()]);
    }
});
//# sourceMappingURL=VExpansionPanelHeader.js.map