/* Copyright (C) 2024 Manuel Bustillo*/ import { CheckIcon, XMarkIcon } from '@heroicons/react/24/outline'; import React, { useState } from 'react'; import { classNames } from '../button'; 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); } const onCancel = () => { setValue(initialValue); setEditing(false); } function renderForm() { return (
setValue(e.target.value)} autoFocus /> <>
) } return ( editing ? (renderForm()) : (renderText()) ); }