// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial /** * `QueryForm` — the address input + submit button for the pipeline explorer. * * Shows a spinner while parsing. * Presentational; `onSubmit` fires on form submission. */ import type { InputHTMLAttributes, KeyboardEvent, ReactNode } from "react" import { LoadingIndicator } from "../common/LoadingIndicator.tsx" export interface QueryFormProps { value: string onChange: (value: string) => void onSubmit: () => void disabled?: boolean busy?: boolean placeholder?: string /** * Keydown on the input — the hook a combobox (the demo's place-autocomplete) * needs for arrow/Enter/Esc nav. */ onKeyDown?: (event: KeyboardEvent) => void /** * Override for extra `` attributes (aria-combobox props, `autoComplete`, …). * * Merged last. */ inputProps?: InputHTMLAttributes } export function QueryForm({ value, onChange, onSubmit, disabled, busy, placeholder, onKeyDown, inputProps, }: QueryFormProps): ReactNode { return (
{ e.preventDefault() onSubmit() }} > onChange(e.target.value)} disabled={disabled} placeholder={placeholder} onKeyDown={onKeyDown} {...inputProps} />
) }