/** * Input 输入框组件 * 设计稿参考: UIDesignSpec.md */ import React, { forwardRef } from 'react'; import { LucideIcon, Search, Eye, EyeOff } from 'lucide-react'; export interface InputProps extends React.InputHTMLAttributes { label?: string; error?: string; hint?: string; leftIcon?: LucideIcon; rightIcon?: LucideIcon; onRightIconClick?: () => void; fullWidth?: boolean; } export const Input = forwardRef(({ label, error, hint, leftIcon: LeftIcon, rightIcon: RightIcon, onRightIconClick, fullWidth = true, className = '', disabled, ...props }, ref) => { return (
{label && ( )}
{LeftIcon && ( )} {RightIcon && ( )}
{error && (

{error}

)} {hint && !error && (

{hint}

)}
); }); Input.displayName = 'Input'; // 搜索输入框 export const SearchInput = forwardRef>( (props, ref) => ( ) ); SearchInput.displayName = 'SearchInput'; // 密码输入框 export const PasswordInput = forwardRef>( (props, ref) => { const [showPassword, setShowPassword] = React.useState(false); return ( setShowPassword(!showPassword)} {...props} /> ); } ); PasswordInput.displayName = 'PasswordInput'; export default Input;