/** * The input-injection list of one attached state. Each row injects a value into the * run input BEFORE the run: either a template `input` jq (picked by name) or a * custom jq over the record, placed under the `into` run-input field. */ import type { ReactNode } from 'react'; import { Field } from '../components/field'; import { CloseIcon } from '../components/icons'; import { TextInput } from '../components/inputs'; import { Button } from '../components/primitives'; import { Select } from '../components/select'; import type { TemplateJqSuggestion } from './BindingJqField'; import { BindingTemplatedJqField } from './BindingTemplatedJqField'; import type { ResolvedTemplateJq } from './catalog'; import type { StateInjection, TemplatedTextCatalog } from './types'; function optionLabel(entry: ResolvedTemplateJq): string { return entry.description !== undefined && entry.description !== '' ? `${entry.ref} — ${entry.description}` : entry.ref; } const CUSTOM = '__custom__'; function InjectionRow({ injection, index, inputJq, suggestions, templates, onChange, onRemove, }: { readonly injection: StateInjection; readonly index: number; readonly inputJq: readonly ResolvedTemplateJq[]; readonly suggestions?: readonly TemplateJqSuggestion[]; readonly templates?: TemplatedTextCatalog; readonly onChange: (injection: StateInjection) => void; readonly onRemove: () => void; }): ReactNode { const isCustom = injection.jq !== null; const selectValue = isCustom ? CUSTOM : (injection.template_jq ?? ''); return (