import { cn } from '../core/styling'; import * as React from 'react'; import { BasicField, BasicFieldOptions, extractBasicFieldProps, } from '../basic-field'; import { extractInputPartProps, InputAddon, InputAnatomy, InputContainer, InputIcon, InputStyling, } from '../input'; import * as PasswordToggleField from '@radix-ui/react-password-toggle-field'; import { LuEye, LuEyeClosed } from 'react-icons/lu'; /* ------------------------------------------------------------------------------------------------- * PasswordInput * -----------------------------------------------------------------------------------------------*/ export type PasswordInputProps = Omit< React.ComponentPropsWithRef<'input'>, 'size' | 'type' | 'autoComplete' > & InputStyling & BasicFieldOptions & { /** * Callback invoked when the value changes. Returns the string value. */ onValueChange?: (value: string) => void; /** * The autoComplete attribute for the password input. * @default "current-password" */ autoComplete?: 'current-password' | 'new-password'; }; export const PasswordInput = React.forwardRef< HTMLInputElement, PasswordInputProps >((props, ref) => { const [props1, basicFieldProps] = extractBasicFieldProps( props, React.useId() ); const [ { size, intent, leftAddon, leftIcon, rightAddon, rightIcon, className, onValueChange, onChange, autoComplete = 'current-password', ...rest }, { inputContainerProps, leftAddonProps, leftIconProps, rightAddonProps, rightIconProps, }, ] = extractInputPartProps({ ...props1, size: props1.size ?? 'md', intent: props1.intent ?? 'basic', leftAddon: props1.leftAddon, leftIcon: props1.leftIcon, rightAddon: props1.rightAddon, rightIcon: props1.rightIcon, }); const handleOnChange = React.useCallback( (e: React.ChangeEvent) => { onValueChange?.(e.target.value); onChange?.(e); }, [onValueChange, onChange] ); return (
} hidden={} />
); }); PasswordInput.displayName = 'PasswordInput';