/* Copyright (C) 2024 Manuel Bustillo*/ import React, { useState } from 'react'; export default function InlineTextField({ initialValue, onChange }: { initialValue: string, onChange: (value: string) => void }) { const [editing, setEditing] = useState(false); const [value, setValue] = useState(initialValue); const renderText = () => setEditing(true)}>{value} const onConfirm = () => { onChange(value); setEditing(false); } function renderForm() { return (
setValue(e.target.value)} onBlur={onConfirm} autoFocus />
) } return ( editing ? (renderForm()) : (renderText()) ); }