import { FC, useContext, useState } from "react" import { PromptContext, PromptProps } from "../main/hooks/usePrompt" import { Button } from "./Button" import { Dialog, DialogActions, DialogContent, DialogTitle } from "./Dialog" import { TextField } from "./TextField" export const PromptDialog: FC = (props) => { const [input, setInput] = useState(props.initialText) const { setPrompt } = useContext(PromptContext) const close = () => { setPrompt(null) } const onCancel = () => { props.callback(null) close() } const onClickOK = () => { props.callback(input ?? null) close() } return ( {props.title} setInput(e.target.value)} autoFocus={true} onKeyPress={(e) => { if (e.key === "Enter") { onClickOK() } }} style={{ width: "100%" }} /> ) }