UNPKG

@rjsf/antd

Version:

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

17 lines 1.16 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { Input } from 'antd'; import { ariaDescribedByIds, } from '@rjsf/utils'; /** 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, formContext, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props; 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