Confirm

就地显示的确认,而不是模态框:标题、说明和错误,先“取消”后“确认”,焦点落在操作上,Esc 取消,并带忙碌状态。

可用框架
  • Angular: 可用
  • Vue: 可用
  • React: 可用
  • React Native: 可用

用法

Remove the lock from “Board”?

Its notes are decrypted and stay readable without Touch ID.

导入

ts
import {
  SoneConfirmActionsDirective,
  SoneConfirmComponent,
  SoneConfirmDescriptionDirective,
  SoneConfirmErrorDirective,
  SoneConfirmTitleDirective,
} from "@surface-one/angular/confirm";

API 参考

SoneConfirmActionsDirective指令

`[soneConfirmActions]` — extra controls at the start of the button row (a "Don't ask again" checkbox).

选择器
[soneConfirmActions]

SoneConfirmComponent组件

`[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)`.

选择器
[soneConfirm]
导出为
soneConfirm
输入
名称类型 默认值
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"
confirmLabel

The action button's label.

—$localize`Confirm`
cancelLabel

The cancel button's label.

—$localize`Cancel`
busyLabel

The action button's label while `busy`.

—$localize`Working…`
busy

The action is running: both buttons are disabled and the action shows `busyLabel`.

booleanfalse
autoFocus

Move focus to the Confirm button when the confirmation renders (default `true`).

booleantrue
输出
名称类型
confirm

The user confirmed (click on the action; never while `busy`).

void
cancel

The user cancelled (the Cancel button or Escape; never while `busy`).

void

SoneConfirmDescriptionDirective指令

`[soneConfirmDescription]` — the consequence ("This cannot be undone.").

选择器
[soneConfirmDescription]

SoneConfirmErrorDirective指令

`[soneConfirmError]` — why the last attempt failed; announced with `role="alert"`.

选择器
[soneConfirmError]

SoneConfirmTitleDirective指令

`[soneConfirmTitle]` — the question; names the alertdialog.

选择器
[soneConfirmTitle]