import { Eye, EyeOff } from 'lucide-react';
import { Box } from './Box';
import { IconButton } from './IconButton';
import { Input, InputProps } from './Input';

export interface PasswordFieldProps extends InputProps {
  showPassword?: boolean;
  onTogglePassword?: () => void;
}

/**
 * PasswordField
 * 
 * Stateless UI primitive for password inputs.
 * For stateful behavior, manage showPassword state in the parent component/template.
 */
export const PasswordField = ({ 
  showPassword = false, 
  onTogglePassword,
  ...props 
}: PasswordFieldProps) => {
  return (
    <Box position="relative" fullWidth>
      <Input
        {...props}
        type={showPassword ? 'text' : 'password'}
      />
      <Box 
        position="absolute" 
        right="0.5rem" 
        top="50%" 
        style={{ transform: 'translateY(-50%)' }}
        zIndex={10}
      >
        <IconButton
          icon={showPassword ? EyeOff : Eye}
          onClick={onTogglePassword}
          variant="ghost"
          size="sm"
          title={showPassword ? 'Hide password' : 'Show password'}
        />
      </Box>
    </Box>
  );
};
