snapshot of https://github.com/mountain-loop/yaak.git (main, 2026-09-23; blobs > 131072B omitted)
Some checks failed
Lint and Test / Lint/Test (push) Has been cancelled
Generate Sponsors README / deploy (push) Has been skipped

This commit is contained in:
upstream-mirror
2026-09-23 17:39:41 +05:00
commit 906fb231cc
1544 changed files with 164131 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import type { FormInput, PromptTextRequest } from "@yaakapp-internal/plugins";
import type { ReactNode } from "react";
import type { DialogProps } from "../components/core/Dialog";
import { showPromptForm } from "./prompt-form";
type PromptProps = Omit<PromptTextRequest, "id" | "title" | "description"> & {
description?: ReactNode;
onCancel: () => void;
onResult: (value: string | null) => void;
};
type PromptArgs = Pick<DialogProps, "title" | "description"> &
Omit<PromptProps, "onClose" | "onCancel" | "onResult"> & { id: string };
export async function showPrompt({
id,
title,
description,
cancelText,
confirmText,
required,
...props
}: PromptArgs) {
const inputs: FormInput[] = [
{
...props,
optional: !required,
type: "text",
name: "value",
},
];
const result = await showPromptForm({
id,
title,
description,
inputs,
cancelText,
confirmText,
});
if (result == null) return null; // Cancelled
if (typeof result.value === "string") return result.value;
return props.defaultValue ?? "";
}