import "./alert.css"; /** The ROLE a button plays in the row. Not a style object — the name `style` * read as one, which is the confusion this rename removes. */ export type AlertButtonKind = "default" | "cancel" | "destructive"; export interface AlertButton { text: string; onPress?: () => void; /** Overrides the colour position would otherwise pick: `destructive` → danger, * `cancel` → secondary. */ kind?: AlertButtonKind; /** Makes this the primary button whatever its position. */ isPreferred?: boolean; } export interface AlertOptions { cancelable?: boolean; onDismiss?: () => void; } /** * WHAT A DESTRUCTIVE ACT ASKS BEFORE IT RUNS. * * Everything said ABOUT the object is the caller's — only the caller knows what * is being deleted. The kit owns the rest: the safe way out, the weakest true * consequence, the focus, the side each button sits on, and the typed gate. */ export interface ConfirmRequest { /** Names the OBJECT, as a question — "Delete order SO-1043?". Never "Are you * sure?": a question with no noun in it is a question about nothing. */ title: string; /** * ONE sentence stating the consequence. Omitted on a `danger` question, the * locale's `confirm.irreversible` stands in. * * A `primary` one gets no such default: "this cannot be undone" is the very * thing that is not true of it, and the kit does not know what IS. */ message?: string; /** The commit's words: VERB + NOUN — "Delete order". Never "OK" / "Yes". */ confirmLabel: string; /** A NAMED refusal where it reads better than the locale's Cancel — "Keep * order". */ cancelLabel?: string; /** * THE TYPED GATE — the object's own name. The commit stays disabled until the * field matches this string exactly. * * For the highest blast radius only: a record with children, a whole book, an * account. Asked of an ordinary delete it is the cry-wolf failure, and the * reader learns to copy-paste rather than to read. */ typed?: string; /** May be async: the commit goes pending, the dialog stays open until it * settles, and a rejection leaves it open with the failure under the buttons * — so the reader never loses the act to a write that did not land. */ onConfirm: () => void | Promise; onCancel?: () => void; /** * WHAT KIND OF ACT is being committed — `danger` (the default) for one that * destroys, `primary` for one that merely cannot be taken back cheaply: a * split, a promotion, a posting that writes many rows. * * It colours the commit and nothing else. Every other guarantee is the same * one — Cancel left and focused, Escape cancels, the commit may be async and * the surface stays open until it settles, with a refusal stated under the * buttons. That is the reason this is a tone rather than a second entry: an * app that needed a blocking question for a non-destructive write had to * choose between a dialog that reads as a delete and `Alert.alert`, which has * no pending state and no in-dialog failure — so the app took the write's * loading flag and its error back. */ tone?: "danger" | "primary"; } /** * THE BLOCKING CONFIRM — the kit's only one, and the reason there is no * `ConfirmDialog`: a second anatomy over one act is exactly what a reader cannot * learn. `Dialog` cannot take the job either — it announces `role="dialog"`, and * it needs an element in the tree, which a menu-item handler does not have. * * It renders into a React root of its OWN, because the API is imperative and a * call site has no element to hang it on. That is also why it takes no * `className`: there is no element the caller renders, so the styling contract * has nothing to attach to — restyle it through the `lotics-alert__*` classes. * The root carries a `LoticsLocaleProvider` of its own for the same reason: it * is outside the app's tree, so the pack has to be handed to it. */ declare class Alert { /** * THE FREE-FORM ALERT — a title, a message, and up to three buttons the caller * names. Use it to REPORT, or to ask something that is not a destructive act. * A destructive act is {@link Alert.confirm}, which owns the words, the focus * and the gate so an app cannot get them wrong. */ static alert(title: string, message?: string, buttons?: AlertButton[], options?: AlertOptions): void; /** * THE BLOCKING QUESTION AN ACT ASKS BEFORE IT RUNS. Cancel left and focused, * the commit right in the act's own tone, Escape cancels, and — while the * commit is in flight — nothing dismisses the surface, so a write cannot be * abandoned half-way by a stray keystroke. * * `tone` says which act it is; everything else is identical, which is what * keeps a split and a delete one anatomy a reader learns once. */ static confirm(request: ConfirmRequest): void; } export { Alert };