mirror of
https://github.com/ZwareBear/awx.git
synced 2026-03-29 04:03:35 -05:00
43 lines
1020 B
JavaScript
43 lines
1020 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { useField } from 'formik';
|
|
import { FormGroup, InputGroup } from '@patternfly/react-core';
|
|
import PasswordInput from './PasswordInput';
|
|
|
|
function PasswordField(props) {
|
|
const { id, name, label, validate, isRequired } = props;
|
|
const [, meta] = useField({ name, validate });
|
|
const isValid = !(meta.touched && meta.error);
|
|
|
|
return (
|
|
<FormGroup
|
|
fieldId={id}
|
|
helperTextInvalid={meta.error}
|
|
isRequired={isRequired}
|
|
isValid={isValid}
|
|
label={label}
|
|
>
|
|
<InputGroup>
|
|
<PasswordInput {...props} />
|
|
</InputGroup>
|
|
</FormGroup>
|
|
);
|
|
}
|
|
|
|
PasswordField.propTypes = {
|
|
id: PropTypes.string.isRequired,
|
|
name: PropTypes.string.isRequired,
|
|
label: PropTypes.string.isRequired,
|
|
validate: PropTypes.func,
|
|
isRequired: PropTypes.bool,
|
|
isDisabled: PropTypes.bool,
|
|
};
|
|
|
|
PasswordField.defaultProps = {
|
|
validate: () => {},
|
|
isRequired: false,
|
|
isDisabled: false,
|
|
};
|
|
|
|
export default PasswordField;
|