diff --git a/docs/components/ConfirmDialog.md b/docs/components/ConfirmDialog.md new file mode 100644 index 00000000..3d122152 --- /dev/null +++ b/docs/components/ConfirmDialog.md @@ -0,0 +1,251 @@ +# ConfirmDialog + +`ConfirmDialog` is the shared, accessible confirmation modal used by destructive and irreversible flows in TalentTrust (e.g. submitting a milestone for approval, releasing escrow funds, opening a dispute). It traps keyboard focus inside the dialog, dismisses on **Escape** or backdrop click, and surfaces a `role="alertdialog"` when `tone="destructive"`. + +The component is intentionally minimal: it does **not** own focus restoration after close, do its own routing, or talk to the network. The owning component is responsible for opening, closing, and returning focus to its trigger once the dialog finishes. + +## Location + +`src/components/ConfirmDialog.tsx` + +## Props + +| Prop | Type | Required | Default | Description | +|------|------|----------|---------|-------------| +| `isOpen` | `boolean` | Yes | — | Whether the dialog is open. When `false`, the component renders nothing. | +| `title` | `string` | Yes | — | Dialog heading. Rendered as `
` and linked via `aria-describedby` (id generated by React `useId`). | +| `confirmLabel` | `string` | No | `"Confirm"` | Accessible name of the confirm button. | +| `cancelLabel` | `string` | No | `"Cancel"` | Accessible name of the cancel button. | +| `tone` | `'default' \| 'destructive'` | No | `'default'` | When `'destructive'`, the dialog uses `role="alertdialog"`. Otherwise it uses `role="dialog"`. | +| `onConfirm` | `() => void` | Yes | — | Callback fired when the user clicks the confirm button. | +| `onCancel` | `() => void` | Yes | — | Callback fired when the user clicks the cancel button, hits **Escape**, or clicks the backdrop. The caller decides what "cancel" means — typically closing the dialog and restoring focus. | + +All props are required unless marked otherwise. The component never mutates any of them. + +## Output contract + +When `isOpen` is `true`, the rendered tree is: + +```html +
+{description}
+ + +