import React from "react"; // PatternFly import { Button, InputGroup, TextInput, InputGroupItem, } from "@patternfly/react-core"; import { EyeSlashIcon } from "@patternfly/react-icons"; import { EyeIcon } from "@patternfly/react-icons"; // Layout helpers import InputRequiredText from "src/components/layouts/InputRequiredText"; import InputWithValidation, { RuleProps, } from "src/components/layouts/InputWithValidation"; export interface PropsToPasswordInput { dataCy: string; ariaLabel?: string; name?: string; id?: string; value?: string; passwordHidden?: boolean; onFocus?: React.MouseEventHandler; onChange: (value: string) => void; onRevealHandler: (value: boolean) => void; validated?: "success" | "warning" | "error" | "default"; isRequired?: boolean; isDisabled?: boolean; // Optional validation rules to enable helper messages rendering rules?: Array; requiredHelperText?: string; } // Note - onChange function should trigger validation check (validated prop) const RevealButton = (props: { dataCy: string; passwordHidden?: boolean; onRevealHandler: (value: boolean) => void; }) => ( ); const PasswordInput = (props: PropsToPasswordInput) => { if (props.rules && props.rules.length > 0) { return (
); } if (props.isRequired) { return (
); } return ( props.onChange(value)} validated={props.validated} isRequired={props.isRequired || false} isDisabled={props.isDisabled || false} /> ); }; export default PasswordInput;