mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:14:03 +01:00
Add .oxfmtignore to skip generated bindings and wasm-pack output. Add npm format script, update DEVELOPMENT.md for Vite+ toolchain, and format all non-generated files with oxfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import type { FormInput, JsonPrimitive } from "@yaakapp-internal/plugins";
|
|
import type { DialogProps } from "../components/core/Dialog";
|
|
import type { PromptProps } from "../components/core/Prompt";
|
|
import { Prompt } from "../components/core/Prompt";
|
|
import { showDialog } from "./dialog";
|
|
|
|
type FormArgs = Pick<DialogProps, "title" | "description" | "size"> &
|
|
Omit<PromptProps, "onClose" | "onCancel" | "onResult"> & {
|
|
id: string;
|
|
onValuesChange?: (values: Record<string, JsonPrimitive>) => void;
|
|
onInputsUpdated?: (cb: (inputs: FormInput[]) => void) => void;
|
|
};
|
|
|
|
export async function showPromptForm({
|
|
id,
|
|
title,
|
|
description,
|
|
size,
|
|
onValuesChange,
|
|
onInputsUpdated,
|
|
...props
|
|
}: FormArgs) {
|
|
return new Promise((resolve: PromptProps["onResult"]) => {
|
|
showDialog({
|
|
id,
|
|
title,
|
|
description,
|
|
hideX: true,
|
|
size: size ?? "sm",
|
|
disableBackdropClose: true, // Prevent accidental dismisses
|
|
onClose: () => {
|
|
// Click backdrop, close, or escape
|
|
resolve(null);
|
|
},
|
|
render: ({ hide }) =>
|
|
Prompt({
|
|
onCancel: () => {
|
|
// Click cancel button within dialog
|
|
resolve(null);
|
|
hide();
|
|
},
|
|
onResult: (v) => {
|
|
resolve(v);
|
|
hide();
|
|
},
|
|
onValuesChange,
|
|
onInputsUpdated,
|
|
...props,
|
|
}),
|
|
});
|
|
});
|
|
}
|