import { useState } from "react"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogRoot, AlertDialogTitle, AlertDialogTrigger, } from "@godxjp/ui/feedback"; import { Badge, Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@godxjp/ui/data-display"; import { Button, Text } from "@godxjp/ui/general"; import { Flex, PageContainer } from "@godxjp/ui/layout"; /** Every branch of AlertDialogHeader's `tone`, in the order the vocabulary declares them. */ const headerTones = [ "default", "success", "warning", "destructive", "info", "muted", "neutral", ] as const; /** * AlertDialog · canonical destructive-confirm modal. NOT a free-form Dialog. * Flat prop API: title (required), description, confirmLabel, cancelLabel, * variant="destructive", confirmPhrase for high-friction ops, onConfirm async, * pending while work is running. * * AlertDialogRoot is the compound counterpart: same role="alertdialog" semantics, * bespoke content. Mirrors DialogRoot, which the flat `Dialog` export wraps. */ export default function Demo() { const [deleteOpen, setDeleteOpen] = useState(true); const [closeOpen, setCloseOpen] = useState(false); const [voidOpen, setVoidOpen] = useState(false); const [phraseOpen, setPhraseOpen] = useState(false); const [toneOpen, setToneOpen] = useState(false); const [headerTone, setHeaderTone] = useState<(typeof headerTones)[number]>("default"); return ( Destructive delete (pre-opened) Flat prop API: title (required) + description + confirmLabel + variant. onConfirm may be async; the dialog stays open until it resolves. Never use Dialog for destructive confirms. { await new Promise((r) => setTimeout(r, 800)); setDeleteOpen(false); }} /> Neutral confirm (the other variant branch) variant has two branches. default is the branch for a consequential but reversible step: the header band stays neutral and the confirm button keeps the primary style, so the dialog reads as a checkpoint rather than a warning. Reach for destructive only when the action cannot be undone. setCloseOpen(false)} /> Void / cancel action Same pattern for voiding an invoice or cancelling a batch job: destructive variant with a clear confirmLabel. setVoidOpen(false)} /> High-friction: confirmPhrase Pass confirmPhrase to require the user to type a specific string before the confirm button activates. Use for truly irreversible bulk operations. setPhraseOpen(false)} /> Compound composition (AlertDialogRoot) AlertDialogRoot is the compound counterpart of the flat preset above, and the mirror of DialogRoot. It supplies the alertdialog context that AlertDialogTitle, AlertDialogDescription, AlertDialogAction and AlertDialogCancel read, so a bespoke confirmation composes from the public API alone. Structure: AlertDialogRoot > AlertDialogTrigger + AlertDialogPortal > AlertDialogOverlay + AlertDialogContent > AlertDialogHeader > AlertDialogTitle. Focus trap, focus restoration and the modal role=alertdialog semantics stay Radix-owned. Reach for the flat AlertDialog first; use the Root only when the confirm body needs content the preset does not cover. 2026年7月分の支払を確定しますか? 確定すると振込データが生成され、取消には管理者の承認が必要になります。 対象 48 件・合計 12,480,000 円。確定後も明細の閲覧はできます。 戻る 確定する AlertDialogHeader tone band (every branch) AlertDialogHeader takes the same prop-driven form as DialogHeader: title, subtitle and an extra slot, plus tone. tone tints only the header band and leaves the text at the foreground colour, so a confirmation never turns into a loud solid fill. default paints no band at all; muted and neutral deliberately share the same quiet band. This branch matrix only became reachable from the public API once AlertDialogRoot shipped. Pick a branch to open the same alertdialog with that header. {headerTones.map((tone) => ( ))} {headerTone}} /> 帯の色だけが tone に追従し、見出しと本文の文字色は変わりません。取込済みの仕訳は 132 件、保留は 4 件です。 閉じる ); }