'use strict';

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

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

var _babelHelperVueJsxMergeProps2 = _interopRequireDefault(_babelHelperVueJsxMergeProps);

var _commonUtil = require('../utils/commonUtil');

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

require('./index.less');

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

var Badge = {
    functional: true,
    name: 'SnBadge',
    render: function render(h, context) {
        var props = context.props;
        var dot = props.dot,
            info = props.info;

        var showInfo = (0, _commonUtil.isDef)(info) && info !== '';

        if (!dot && !showInfo) {
            return;
        }

        return h(
            'div',
            (0, _babelHelperVueJsxMergeProps2['default'])([{
                'class': {
                    'sn-badge': true,
                    'sn-badge-dot': dot
                }
            }, (0, _functional.inherit)(context)]),
            [dot ? '' : props.info]
        );
    }
}; // Utils


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

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