mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-15 08:13:27 +01:00
31 lines
811 B
TypeScript
31 lines
811 B
TypeScript
import type { DialogProps } from '../components/core/Dialog';
|
|
import { useDialog } from '../components/DialogContext';
|
|
import type { PromptProps } from './Prompt';
|
|
import { Prompt } from './Prompt';
|
|
|
|
export function usePrompt() {
|
|
const dialog = useDialog();
|
|
return ({
|
|
title,
|
|
description,
|
|
name,
|
|
label,
|
|
defaultValue,
|
|
}: {
|
|
title: DialogProps['title'];
|
|
description?: DialogProps['description'];
|
|
name: PromptProps['name'];
|
|
label: PromptProps['label'];
|
|
defaultValue: PromptProps['defaultValue'];
|
|
}) =>
|
|
new Promise((onResult: PromptProps['onResult']) => {
|
|
dialog.show({
|
|
title,
|
|
description,
|
|
hideX: true,
|
|
size: 'sm',
|
|
render: ({ hide }) => Prompt({ onHide: hide, onResult, name, label, defaultValue }),
|
|
});
|
|
});
|
|
}
|