/** * The render-parameters UI for `TemplatedTextField`: the add/remove editor * (`KwargsEditor`) for editable values, and the read-only listing * (`ReadOnlyKwargs`) shown beside a read-only stored id. */ import { type ReactNode, useState } from 'react'; import { CloseIcon } from './icons'; import { TextInput } from './inputs'; import { Button } from './primitives'; import type { KwargRow } from './templated-text-kwargs'; /** The add/remove kwargs editor, revealed on demand and open when kwargs already exist. */ export function KwargsEditor({ label, rows, disabled, onChange, }: { readonly label: string; readonly rows: readonly KwargRow[]; readonly disabled: boolean; readonly onChange: (rows: KwargRow[]) => void; }): ReactNode { const [open, setOpen] = useState(rows.length > 0); const groupLabel = `${label} render parameters`; if (!open) { // Wrapped so the ghost button keeps its content width and stays left-aligned // in the field's column, marking it as this field's own disclosure rather than // a full-width control floating between two fields. return (
{row.key}
:
{row.value}