import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2019-2026 GoodData Corporation
import { forwardRef, memo, useCallback } from "react";
import cx from "classnames";
export const Textarea = memo(forwardRef(function Textarea({ hasError = false, hasWarning = false, maxlength, id, placeholder, value, rows, onChange, onFocus, onBlur, validationError, autocomplete, accessibilityConfig, }, ref) {
    const getTextareaClassNames = useCallback(() => {
        return cx("gd-input-field", {
            "has-error": hasError,
            "has-warning": hasWarning,
        });
    }, [hasError, hasWarning]);
    const handleChange = useCallback((e) => {
        onChange(e.target.value);
    }, [onChange]);
    const handleBlur = useCallback((e) => {
        onBlur?.(e.target.value);
    }, [onBlur]);
    return (_jsx("textarea", { ref: ref, id: id, className: getTextareaClassNames(), maxLength: maxlength, placeholder: placeholder, value: value, rows: rows, onChange: handleChange, onFocus: onFocus, autoComplete: autocomplete, onBlur: handleBlur, "aria-describedby": validationError ? accessibilityConfig?.ariaDescribedBy : undefined, "aria-labelledby": accessibilityConfig?.ariaLabelledBy }));
}));
