promptDialog(placeholder)
Massimo Melina committed
Sep 2, 2025 at 17:21 UTC
a9c2736a1bd346893dabc7cb3c08f87d3cdaf99b
1 file changed
+5
-2
frontend/src/dialog.ts
+5
-2
@@ -19,11 +19,12 @@ interface PromptOptions extends Partial<DialogOptions> {
19
type?: string,
20
trim?: boolean,
21
helperText?: ReactNode,
22
+ placeholder?: string,
23
inputProps?: Partial<InputHTMLAttributes<string>>
24
onSubmit?: (v: string) => Promisable<string>
25
onField?: (el: HTMLInputElement | HTMLTextAreaElement) => void
26
}
26
-export async function promptDialog(msg: string, { value, type, helperText, trim=true, inputProps, onSubmit, onField, ...rest }:PromptOptions={}) : Promise<string | undefined> {
27
+export async function promptDialog(msg: string, { value, type, helperText, trim=true, inputProps, onSubmit, onField, placeholder, ...rest }:PromptOptions={}) : Promise<string | undefined> {
28
const textarea = type === 'textarea' && type
29
return new Promise(resolve => newDialog({
30
className: 'dialog-prompt',
@@ -58,12 +59,14 @@ export async function promptDialog(msg: string, { value, type, helperText, trim=
59
ref,
60
type,
61
name: 'input',
62
+ autoFocus: true,
63
+ placeholder,
64
+ ...inputProps,
65
style: {
66
width: value ? (value.length / 2) + 'em' : 'auto',
67
minWidth: '100%', maxWidth: '100%', boxSizing: 'border-box',
68
...textarea && { width: '30em', maxHeight: '70vh' },
69
},
66
- autoFocus: true,
70
onKeyDown(ev: KeyboardEvent) {
71
const { key } = ev
72
if (key === 'Escape')