--- import Icon from './Icon.astro' import CaptureScript from '../components/CaptureScript.astro' interface Props { type?: astroHTML.JSX.HTMLInputTypeAttribute placeholder?: string value?: string flat?: boolean class?: string inputClass?: string id?: string prepend?: string append?: string appendButton?: { icon: string; description: string; pressed?: boolean }[] autocomplete?: string } const { type = 'text', placeholder, value, flat, class: className, inputClass, id, prepend, append, appendButton, autocomplete } = Astro.props const appendButtons = appendButton ?? [] // A password field's "eye" button gets a working show/hide toggle instead of a static icon — // it needs the field's id to target the input, so falls back to a plain icon button without one. const hasPasswordToggle = type === 'password' && appendButtons.some((button) => button.icon === 'eye' && id) // Built as a string (not a literal ` ---
{prepend && {prepend}} {append && {append}} { appendButtons.length > 0 && ( {appendButtons.map(({ icon, description, pressed }, index) => { const isPasswordToggle = icon === 'eye' && type === 'password' && id return ( ) })} ) }
{ hasPasswordToggle && ( ) }