UNPKG

@rjsf/antd

Version:

Ant Design theme, fields and widgets for react-jsonschema-form

18 lines 1.2 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { ariaDescribedByIds } from '@rjsf/utils'; import { Input } from 'antd'; /** The `PasswordWidget` component uses the `BaseInputTemplate` changing the type to `password`. * * @param props - The `WidgetProps` for this component */ export default function PasswordWidget(props) { const { disabled, registry, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props; const { formContext } = registry; const { readonlyAsDisabled = true } = formContext; const emptyValue = options.emptyValue || ''; const handleChange = ({ target }) => onChange(target.value === '' ? emptyValue : target.value); const handleBlur = ({ target }) => onBlur(id, target.value); const handleFocus = ({ target }) => onFocus(id, target.value); return (_jsx(Input.Password, { disabled: disabled || (readonlyAsDisabled && readonly), id: id, name: id, onBlur: !readonly ? handleBlur : undefined, onChange: !readonly ? handleChange : undefined, onFocus: !readonly ? handleFocus : undefined, placeholder: placeholder, value: value || '', "aria-describedby": ariaDescribedByIds(id) })); } //# sourceMappingURL=index.js.map