Confirm
Una conferma in linea al posto di una modale: titolo, descrizione ed errore, prima Annulla poi Conferma, focus sull’azione, Esc annulla e stato di attesa.
Angular: disponibile Vue: disponibile React: disponibile React Native: disponibile
Utilizzo
Remove the lock from “Board”?
Its notes are decrypted and stay readable without Touch ID.
Touch ID was cancelled. Try again.
<div class="demo-stack" style="max-width: 32rem">
<!-- Inline: render it with @if in place of the button that asked -->
@if (confirming()) {
<div
soneConfirm
variant="destructive"
confirmLabel="Delete"
busyLabel="Deleting…"
[busy]="busy()"
(confirm)="remove()"
(cancel)="close()"
>
<p soneConfirmTitle>Delete “Weekly sync”?</p>
<p soneConfirmDescription>It moves to the trash for 30 days.</p>
</div>
} @else {
<div class="demo-row">
<button #opener soneBtn variant="outline" type="button" (click)="confirming.set(true)">
Delete note
</button>
<span role="status" style="color: var(--text-secondary)">{{ status() }}</span>
</div>
}
<!-- Card: a bordered panel; extra controls go in soneConfirmActions -->
<div soneConfirm layout="card" variant="destructive" confirmLabel="Remove lock" [autoFocus]="false">
<h3 soneConfirmTitle>Remove the lock from “Board”?</h3>
<p soneConfirmDescription>Its notes are decrypted and stay readable without Touch ID.</p>
<p soneConfirmError>Touch ID was cancelled. Try again.</p>
</div>
</div>Importazione
import {
SoneConfirmActionsDirective,
SoneConfirmComponent,
SoneConfirmDescriptionDirective,
SoneConfirmErrorDirective,
SoneConfirmTitleDirective,
} from "@surface-one/angular/confirm";Riferimento API
SoneConfirmActionsDirectiveDirettiva
`[soneConfirmActions]` — extra controls at the start of the button row (a "Don't ask again" checkbox).
SoneConfirmComponentComponente
`[soneConfirm]` — an inline confirmation: the shadcn/ui Alert Dialog anatomy (title, description, Cancel then the action) rendered in place, in a row or a list, instead of in a modal. Render it with `@if` when the user asks to delete / discard / leave; it is a `role="alertdialog"` named by its `[soneConfirmTitle]` (or your `aria-label`) and described by its `[soneConfirmDescription]` and `[soneConfirmError]`. The buttons are drawn for you, always Cancel then Confirm. Focus moves to the Confirm button when it opens, Escape cancels, and while `busy` both buttons are `aria-disabled` (focus stays put) and the action shows `busyLabel` with a spinner. Extra controls in `[soneConfirmActions]` sit at the start of the button row. Give focus back to the control that opened it on `(cancel)`.
| Nome | Tipo | Predefinito |
|---|---|---|
variant`destructive` paints the action red (delete, discard, leave). | ConfirmVariant | "default" |
size`compact` uses extra-small buttons and tighter spacing — for a list row. | ConfirmSize | "default" |
layout`inline`: text and buttons share one wrapping row. `card`: a bordered panel, buttons below. | ConfirmLayout | "inline" |
confirmLabelThe action button's label. | — | $localize`Confirm` |
cancelLabelThe cancel button's label. | — | $localize`Cancel` |
busyLabelThe action button's label while `busy`. | — | $localize`Working…` |
busyThe action is running: both buttons are disabled and the action shows `busyLabel`. | boolean | false |
autoFocusMove focus to the Confirm button when the confirmation renders (default `true`). | boolean | true |
| Nome | Tipo |
|---|---|
confirmThe user confirmed (click on the action; never while `busy`). | void |
cancelThe user cancelled (the Cancel button or Escape; never while `busy`). | void |
SoneConfirmDescriptionDirectiveDirettiva
`[soneConfirmDescription]` — the consequence ("This cannot be undone.").
SoneConfirmErrorDirectiveDirettiva
`[soneConfirmError]` — why the last attempt failed; announced with `role="alert"`.
SoneConfirmTitleDirectiveDirettiva
`[soneConfirmTitle]` — the question; names the alertdialog.