import React, { useState } from 'react'; import { Box } from '../Box/Box'; import { Text } from '../Text/Text'; import { TextInput } from '../TextInput/TextInput'; import { ButtonGroup } from '../ButtonGroup/ButtonGroup'; import { IconButton } from '../IconButton/IconButton'; import { Flex } from '../Flex/Flex'; // FIX: Import TimesIcon to replace local CloseIcon definition for consistency. import { TimesIcon } from '../../icons'; // FIX: The CheckIcon and CloseIcon were not exported from the icons module. // The incorrect import has been removed, and these local placeholder definitions are used instead. const CheckIcon = () => ; interface EditableProps { defaultValue: string; onSave: (value: string) => void; } export const Editable: React.FC = ({ defaultValue, onSave }) => { const [isEditing, setIsEditing] = useState(false); const [value, setValue] = useState(defaultValue); const handleSave = () => { onSave(value); setIsEditing(false); }; const handleCancel = () => { setValue(defaultValue); setIsEditing(false); }; if (isEditing) { return ( setValue(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') handleSave(); if (e.key === 'Escape') handleCancel(); }} autoFocus /> ); } return ( setIsEditing(true)} style={{ cursor: 'pointer', borderBottom: '1px dashed grey', padding: '0.5rem 0.75rem' }}> {value} ); };