Files
NomadArch/packages/ui/src/stores/alerts.ts
Gemini AI b448d11991 fix: restore complete source code and fix launchers
- Copy complete source code packages from original CodeNomad project
- Add root package.json with npm workspace configuration
- Include electron-app, server, ui, tauri-app, and opencode-config packages
- Fix Launch-Windows.bat and Launch-Dev-Windows.bat to work with correct npm scripts
- Fix Launch-Unix.sh to work with correct npm scripts
- Launchers now correctly call npm run dev:electron which launches Electron app
2025-12-23 12:57:55 +04:00

47 lines
1.1 KiB
TypeScript

import { createSignal } from "solid-js"
export type AlertVariant = "info" | "warning" | "error"
export type AlertDialogState = {
type?: "alert" | "confirm"
title?: string
message: string
detail?: string
variant?: AlertVariant
confirmLabel?: string
cancelLabel?: string
onConfirm?: () => void
onCancel?: () => void
resolve?: (value: boolean) => void
}
const [alertDialogState, setAlertDialogState] = createSignal<AlertDialogState | null>(null)
export function showAlertDialog(message: string, options?: Omit<AlertDialogState, "message">) {
setAlertDialogState({
type: "alert",
message,
...options,
})
}
export function showConfirmDialog(message: string, options?: Omit<AlertDialogState, "message">): Promise<boolean> {
const activeElement = typeof document !== "undefined" ? (document.activeElement as HTMLElement | null) : null
activeElement?.blur()
return new Promise<boolean>((resolve) => {
setAlertDialogState({
type: "confirm",
message,
...options,
resolve,
})
})
}
export function dismissAlertDialog() {
setAlertDialogState(null)
}
export { alertDialogState }