'use strict';

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

var _babelHelperVueJsxMergeProps = require('babel-helper-vue-jsx-merge-props');

var _babelHelperVueJsxMergeProps2 = _interopRequireDefault(_babelHelperVueJsxMergeProps);

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _functional = require('../_utils/functional');

var _event = require('../_utils/dom/event');

require('./index.less');

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

function preventTouchMove(event) {
    (0, _event.preventDefault)(event, true);
}

var Overlay = {
    name: 'SnOverlay',
    functional: true,
    data: function data() {
        return {};
    },

    props: {
        show: Boolean,
        duration: [Number, String],
        className: null,
        customStyle: Object,
        zIndex: {
            type: [Number, String],
            'default': 1
        }
    },
    render: function render(h, context) {
        var props = context.props,
            slots = context.slots;
        var show = props.show,
            duration = props.duration,
            className = props.className,
            customStyle = props.customStyle,
            zIndex = props.zIndex;

        var style = (0, _extends3['default'])({
            zIndex: zIndex
        }, customStyle);
        if (duration !== undefined && duration !== null) {
            style.animationDuration = duration + 'ms';
        }

        return h(
            'transition',
            {
                attrs: { name: 'sn-fade' }
            },
            [h(
                'div',
                (0, _babelHelperVueJsxMergeProps2['default'])([{
                    directives: [{
                        name: 'show',
                        value: show
                    }],

                    style: style,
                    'class': ['sn-overlay', className],
                    on: {
                        'touchmove': preventTouchMove
                    }
                }, (0, _functional.inherit)(context, true)]),
                [slots['default']]
            )]
        );
    }
};

Overlay.install = function (Vue) {
    Vue.component(Overlay.name, Overlay);
};

exports['default'] = Overlay;
module.exports = exports.default;