import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { SoftValidatableControl, } from '../validatable_control';
const resizeToClassNameMap = {
    vertical: 'softTextArea--resizeVertical',
    horizontal: 'softTextArea--resizeHorizontal',
    both: 'softTextArea--resizeBoth',
    none: 'softTextArea--resizeNone',
};
export const RESIZE = Object.keys(resizeToClassNameMap);
export class SoftTextArea extends Component {
    render() {
        let { children, className, compressed, fullWidth, id, inputRef, isInvalid, name, placeholder, resize, rows, ...rest } = this.props;
        const classes = classNames('softTextArea', resizeToClassNameMap[resize], {
            'softTextArea--fullWidth': fullWidth,
            'softTextArea--compressed': compressed,
        }, className);
        let definedRows;
        if (rows) {
            definedRows = rows;
        }
        else if (compressed) {
            definedRows = 3;
        }
        else {
            definedRows = 6;
        }
        return (React.createElement(SoftValidatableControl, { isInvalid: isInvalid },
            React.createElement("textarea", Object.assign({ className: classes }, rest, { rows: definedRows, name: name, id: id, ref: inputRef, placeholder: placeholder }), children)));
    }
}
SoftTextArea.defaultProps = {
    fullWidth: false,
    resize: 'vertical',
};
SoftTextArea.propTypes = {
    name: PropTypes.string,
    id: PropTypes.string,
    placeholder: PropTypes.string,
    rows: PropTypes.number,
    isInvalid: PropTypes.bool,
    fullWidth: PropTypes.bool,
    compressed: PropTypes.bool,
    /**
     * Which direction, if at all, should the textarea resize
     */
    resize: PropTypes.oneOf(RESIZE),
};
//# sourceMappingURL=SoftTextArea.js.map