import { useState } from "react"; import { IconButton, Stack, TextField, Typography } from "@mui/material"; import { CheckRounded, CloseRounded, DeleteRounded, EditRounded, OpenInNewRounded, } from "@mui/icons-material"; interface Props { value?: string; onlyEdit?: boolean; onChange: (value?: string) => void; onOpenUrl?: (value?: string) => void; onDelete?: () => void; onCancel?: () => void; } const WebUIItem = (props: Props) => { const { value, onlyEdit = false, onChange, onDelete, onOpenUrl, onCancel, } = props; const [editing, setEditing] = useState(false); const [editValue, setEditValue] = useState(value); if (editing || onlyEdit) { return ( setEditValue(e.target.value)} placeholder={`Support %host %port %secret`} autoComplete="off" /> { onChange(editValue); setEditing(false); }} > { onCancel?.(); setEditing(false); }} > ); } return ( {value || "NULL"} onOpenUrl?.(value)} > { setEditing(true); setEditValue(value); }} > ); }; export default WebUIItem;