2026-01-04 21:58:59 -05:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import { cn } from "@/shared/utils/cn";
|
|
|
|
|
|
|
|
|
|
export default function Input({
|
|
|
|
|
label,
|
|
|
|
|
type = "text",
|
|
|
|
|
placeholder,
|
|
|
|
|
value,
|
|
|
|
|
onChange,
|
|
|
|
|
error,
|
|
|
|
|
hint,
|
|
|
|
|
icon,
|
|
|
|
|
disabled = false,
|
|
|
|
|
required = false,
|
|
|
|
|
className,
|
|
|
|
|
inputClassName,
|
|
|
|
|
...props
|
|
|
|
|
}) {
|
|
|
|
|
return (
|
|
|
|
|
<div className={cn("flex flex-col gap-1.5", className)}>
|
|
|
|
|
{label && (
|
|
|
|
|
<label className="text-sm font-medium text-text-main">
|
|
|
|
|
{label}
|
|
|
|
|
{required && <span className="text-red-500 ml-1">*</span>}
|
|
|
|
|
</label>
|
|
|
|
|
)}
|
|
|
|
|
<div className="relative">
|
|
|
|
|
{icon && (
|
|
|
|
|
<div className="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-text-muted">
|
|
|
|
|
<span className="material-symbols-outlined text-[20px]">{icon}</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<input
|
|
|
|
|
type={type}
|
|
|
|
|
placeholder={placeholder}
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={onChange}
|
|
|
|
|
disabled={disabled}
|
|
|
|
|
className={cn(
|
2026-05-03 07:00:35 -04:00
|
|
|
"w-full py-2.5 px-3 text-sm text-text-main bg-surface-2 rounded-[10px]",
|
|
|
|
|
"border border-transparent placeholder-text-muted/70",
|
|
|
|
|
"focus:outline-none focus:ring-2 focus:ring-brand-500/30 focus:border-brand-500/40",
|
|
|
|
|
"transition-all duration-150 ease-out disabled:opacity-50 disabled:cursor-not-allowed",
|
2026-01-04 21:58:59 -05:00
|
|
|
// iOS zoom fix
|
|
|
|
|
"text-[16px] sm:text-sm",
|
|
|
|
|
icon && "pl-10",
|
2026-05-03 07:00:35 -04:00
|
|
|
error && "ring-1 ring-red-500 focus:ring-2 focus:ring-red-500/40 border-red-500/40",
|
2026-01-04 21:58:59 -05:00
|
|
|
inputClassName
|
|
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
{error && (
|
|
|
|
|
<p className="text-xs text-red-500 flex items-center gap-1">
|
|
|
|
|
<span className="material-symbols-outlined text-[14px]">error</span>
|
|
|
|
|
{error}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
{hint && !error && (
|
|
|
|
|
<p className="text-xs text-text-muted">{hint}</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|