From 6ec259a0e71174651bae95d4628138bf6fd68742 Mon Sep 17 00:00:00 2001 From: kj_sh604 Date: Sun, 15 Mar 2026 16:19:35 -0400 Subject: refactor: packages/ --- .../OverwriteConfirm/OverwriteConfirmState.ts | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.ts (limited to 'packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.ts') diff --git a/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.ts b/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.ts new file mode 100644 index 0000000..04616aa --- /dev/null +++ b/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.ts @@ -0,0 +1,45 @@ +import { atom, editorJotaiStore } from "../../editor-jotai"; +import type React from "react"; + +export type OverwriteConfirmState = + | { + active: true; + title: string; + description: React.ReactNode; + actionLabel: string; + color: "danger" | "warning"; + + onClose: () => void; + onConfirm: () => void; + onReject: () => void; + } + | { active: false }; + +export const overwriteConfirmStateAtom = atom({ + active: false, +}); + +export async function openConfirmModal({ + title, + description, + actionLabel, + color, +}: { + title: string; + description: React.ReactNode; + actionLabel: string; + color: "danger" | "warning"; +}) { + return new Promise((resolve) => { + editorJotaiStore.set(overwriteConfirmStateAtom, { + active: true, + onConfirm: () => resolve(true), + onClose: () => resolve(false), + onReject: () => resolve(false), + title, + description, + actionLabel, + color, + }); + }); +} -- cgit v1.2.3