DialogBox model
The DialogBox model composes the Dialog wrapper with promise-based dialogs.
open() returns a promise that resolves or rejects when the dialog closes.
Promise-based dialogs
Create the model with a render function, then await open() to collect the result. The example
below resolves with the submitted numbers and rejects when the dialog is dismissed.
const inputDialog = new DialogBox(({ defer }) => (
<Dialog open={!!defer} onClose={() => defer?.reject(new DialogBoxClose())}>
<Form onSubmit={submit}>
<FormControl name="a" type="number" />
</Form>
</Dialog>
));
const data = await inputDialog.open();