import React from 'react';
import propTypes from 'prop-types';
import '../styles/textarea.css';
import '../styles/main.css';

export const Textarea = ({ placeholder, value, type, disabled, isRequired, isInvalid, isFullWidth, ...props }) => {

    const fullWidth = isFullWidth && 'full-width'
    const invalid = isInvalid && 'invalid'

    return (
        <textarea
            placeholder={placeholder}
            value={value}
            type={type}
            required={isRequired}
            disabled={disabled}
            className={[fullWidth, invalid].join(' ')}
            {...props}
        />
    );
}

Textarea.propTypes = {
    placeholder: propTypes.string,
    value: propTypes.string,
    type: propTypes.oneOf(["email", "number", "search", "text", "tel", "url", "password"]),
    disabled: propTypes.bool,
    isRequired: propTypes.bool,
    isInvalid: propTypes.bool,
    isFullWidth: propTypes.bool
};

Textarea.defaultProps = {
    placeholder: "Placeholder",
    value: "",
    type: "text",
    disabled: false,
    isRequired: false,
    isInvalid: false,
    isFullWidth: false
}