UNPKG

@teknim/rjsf-mantine

Version:

Mantine theme, fields and widgets for react-jsonschema-form

26 lines 1.52 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { useCallback } from 'react'; import { labelValue } from '@rjsf/utils'; import { Textarea } from '@mantine/core'; import { cleanupOptions } from '../utils'; export default function TextareaWidget(props) { var _a; const { id, name, value, placeholder, required, disabled, readonly, autofocus, label, hideLabel, rawErrors, options, onChange, onBlur, onFocus, } = props; const themeProps = cleanupOptions(options); const emptyValue = (_a = options === null || options === void 0 ? void 0 : options.emptyValue) !== null && _a !== void 0 ? _a : ''; const handleChange = useCallback((e) => { onChange(e.target.value === '' ? emptyValue : e.target.value); }, [onChange, emptyValue]); const handleBlur = useCallback(({ target }) => { if (onBlur) { onBlur(id, target && target.value); } }, [onBlur, id]); const handleFocus = useCallback(({ target }) => { if (onFocus) { onFocus(id, target && target.value); } }, [onFocus, id]); return (_jsx(Textarea, { id: id, name: name, value: value || '', placeholder: placeholder || undefined, required: required, disabled: disabled || readonly, autoFocus: autofocus, label: labelValue(label || undefined, hideLabel, false), onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, error: rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined, ...themeProps })); } //# sourceMappingURL=TextareaWidget.js.map