Improved prompt function add add ctx.* functions (#301)

This commit is contained in:
Gregory Schier
2025-11-15 08:19:58 -08:00
committed by GitHub
parent 7ced183b11
commit 84219571e8
29 changed files with 454 additions and 150 deletions

View File

@@ -6,7 +6,13 @@ import { showDialog } from './dialog';
type PromptArgs = Pick<DialogProps, 'title' | 'description'> &
Omit<PromptProps, 'onClose' | 'onCancel' | 'onResult'> & { id: string };
export async function showPrompt({ id, title, description, ...props }: PromptArgs) {
export async function showPrompt({
id,
title,
description,
required = true,
...props
}: PromptArgs) {
return new Promise((resolve: PromptProps['onResult']) => {
showDialog({
id,
@@ -21,6 +27,7 @@ export async function showPrompt({ id, title, description, ...props }: PromptArg
},
render: ({ hide }) =>
Prompt({
required,
onCancel: () => {
// Click cancel button within dialog
resolve(null);