'use strict';

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

var _listItem = require('../list-item');

var _listItem2 = _interopRequireDefault(_listItem);

var _textarea = require('../textarea');

var _textarea2 = _interopRequireDefault(_textarea);

var _inputItem = require('../mixins/input-item');

var _inputItem2 = _interopRequireDefault(_inputItem);

require('./index.less');

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

var TextareaItem = {
    name: 'SnTextareaItem',
    mixins: [_inputItem2['default']],

    props: {
        rows: {
            type: [Number, String],
            'default': 1
        },
        autosize: {
            type: Boolean,
            'default': true
        }
    },

    render: function render() {
        var h = arguments[0];
        var value = this.value,
            icon = this.icon,
            rightIcon = this.rightIcon,
            title = this.title,
            titleStyle = this.titleStyle,
            titleClass = this.titleClass,
            valueStyle = this.valueStyle,
            valueClass = this.valueClass,
            valuePosition = this.valuePosition,
            labelNumber = this.labelNumber,
            required = this.required,
            border = this.border,
            borderIndent = this.borderIndent,
            placeholder = this.placeholder,
            editable = this.editable,
            disabled = this.disabled,
            rows = this.rows,
            autosize = this.autosize,
            maxlength = this.maxlength,
            $slots = this.$slots;


        var renderTitle = $slots['title'] ? h(
            'div',
            { slot: 'title' },
            [$slots['title']]
        ) : null;
        var renderRightIcon = $slots['right-icon'] ? h(
            'div',
            { slot: 'right-icon' },
            [$slots['right-icon']]
        ) : null;

        return h(
            _listItem2['default'],
            {
                'class': 'sn-textarea-item',
                attrs: { icon: icon,
                    rightIcon: rightIcon,
                    title: title,
                    titleStyle: titleStyle,
                    titleClass: titleClass,
                    valueStyle: valueStyle,
                    valueClass: valueClass,
                    valuePosition: valuePosition,
                    labelNumber: labelNumber,
                    required: required,
                    border: border,
                    borderIndent: borderIndent
                },
                on: {
                    'click': this.onClick,
                    'right-icon-click': this.onRightIconClick
                }
            },
            [h(_textarea2['default'], {
                attrs: {
                    value: value,
                    maxlength: maxlength,
                    placeholder: placeholder,
                    disabled: disabled,
                    editable: editable,
                    rows: rows,
                    autosize: autosize
                },
                on: {
                    'focus': this.onFocus,
                    'input': this.onInput,
                    'change': this.onChange,
                    'blur': this.onBlur
                }
            }), renderTitle, renderRightIcon]
        );
    }
};

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

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