@rjsf/semantic-ui
Version:
Semantic UI theme, fields and widgets for react-jsonschema-form
22 lines • 1.47 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { ariaDescribedByIds, labelValue, } from '@rjsf/utils';
import { Form } from 'semantic-ui-react';
import { getSemanticProps } from '../util.js';
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
*
* @param props - The `WidgetProps` for this component
*/
export default function TextareaWidget(props) {
const { id, htmlName, placeholder, value, required, disabled, autofocus, label, hideLabel, readonly, onBlur, onFocus, onChange, options, registry, rawErrors = [], } = props;
const semanticProps = getSemanticProps({
formContext: registry.formContext,
options,
defaultSchemaProps: { inverted: 'false' },
});
// eslint-disable-next-line no-shadow
const _onChange = ({ target: { value } }) => onChange && onChange(value === '' ? options.emptyValue : value);
const _onBlur = () => onBlur && onBlur(id, value);
const _onFocus = () => onFocus && onFocus(id, value);
return (_jsx(Form.TextArea, { id: id, name: htmlName || id, label: labelValue(label || undefined, hideLabel, false), placeholder: placeholder, autoFocus: autofocus, required: required, disabled: disabled || readonly, ...semanticProps, value: value || '', error: rawErrors.length > 0, rows: options.rows || 5, onChange: _onChange, onBlur: _onBlur, onFocus: _onFocus, "aria-describedby": ariaDescribedByIds(id) }, id));
}
//# sourceMappingURL=TextareaWidget.js.map