@hypothesis/frontend-shared
Version:
Shared components, styles and utilities for Hypothesis projects
41 lines • 1.2 kB
JavaScript
var _jsxFileName = "/home/runner/work/frontend-shared/frontend-shared/src/components/input/Textarea.tsx";
import { useSyncedRef } from '../../hooks/use-synced-ref';
import { useValidationError } from '../../hooks/use-validation-error';
import { downcastRef } from '../../util/typing';
import { inputStyles } from './Input';
import { jsxDEV as _jsxDEV } from "preact/jsx-dev-runtime";
/**
* Render a textarea
*/
export default function Textarea({
elementRef,
error,
feedback,
classes,
...htmlAttributes
}) {
if (!htmlAttributes.id && !htmlAttributes['aria-label']) {
console.warn('`Textarea` component should have either an `id` or an `aria-label` attribute');
}
const textAreaRef = downcastRef(elementRef);
const ref = useSyncedRef(textAreaRef);
if (error) {
feedback = 'error';
}
useValidationError(ref, error);
return _jsxDEV("textarea", {
"data-component": "Textarea",
...htmlAttributes,
ref: ref,
className: inputStyles({
classes,
feedback
}),
"aria-invalid": feedback === 'error'
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 40,
columnNumber: 5
}, this);
}
//# sourceMappingURL=Textarea.js.map