import { IconChevronDown, IconEye, IconEyeOff } from "@tabler/icons-react" import { type ReactNode, useState } from "react" import { useTranslation } from "react-i18next" import { FieldDescription, FieldLabel, Field as UiField, } from "@/components/ui/field" import { Input } from "@/components/ui/input" import { Switch } from "@/components/ui/switch" import { cn } from "@/lib/utils" type FieldLayout = "default" | "setting-row" interface FieldProps { label: string hint?: string error?: string required?: boolean children: ReactNode layout?: FieldLayout controlClassName?: string } export function Field({ label, hint, error, required, children, layout = "default", controlClassName, }: FieldProps) { if (layout === "setting-row") { return (
{label} {required && *} {hint && ( {hint} )}
{children}
{error && ( {error} )}
) } return (
{label} {required && *} {hint && ( {hint} )}
{children} {error && ( {error} )}
) } interface KeyInputProps { value: string onChange: (v: string) => void placeholder?: string className?: string } export function KeyInput({ value, onChange, placeholder, className, }: KeyInputProps) { const [show, setShow] = useState(false) return (
onChange(e.target.value)} placeholder={placeholder} className={cn("pr-10", className)} />
) } interface SwitchCardFieldProps { label: string hint?: string error?: string checked: boolean onCheckedChange: (checked: boolean) => void ariaLabel?: string disabled?: boolean children?: ReactNode layout?: FieldLayout transparent?: boolean } export function SwitchCardField({ label, hint, error, checked, onCheckedChange, ariaLabel, disabled, children, layout = "default", transparent, }: SwitchCardFieldProps) { if (layout === "setting-row") { return (

{label}

{hint && (

{hint}

)}
{children && (
{children}
)} {error && (

{error}

)}
) } return (

{label}

{hint && (

{hint}

)}
{children &&
{children}
} {error && (

{error}

)}
) } interface AdvancedSectionProps { children: ReactNode } export function AdvancedSection({ children }: AdvancedSectionProps) { const { t } = useTranslation() const [open, setOpen] = useState(false) return (
{open && (
{children}
)}
) }