undo-toast 0.0.0-stage → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,118 @@
1
+ /*
2
+ * undo-toast: bottom-left on a wide screen, full width at the bottom on a narrow one, always just
3
+ * above a docked bottom bar (--undo-toast-dock, set by useBottomDock) and the iPhone home indicator.
4
+ * Typography is inherited from the host; tune it with the custom properties below.
5
+ */
6
+ .undo-toast-region {
7
+ --undo-toast-bg: #1f2328;
8
+ --undo-toast-fg: #f6f8fa;
9
+ --undo-toast-accent: #8ab4f8;
10
+ --undo-toast-gap: 24px;
11
+ --undo-toast-radius: 10px;
12
+ --undo-toast-max-width: 36rem;
13
+ --undo-toast-z: 1000;
14
+ --undo-toast-target: 36px;
15
+ position: fixed;
16
+ inset-inline-start: var(--undo-toast-gap);
17
+ bottom: calc(max(var(--undo-toast-dock, 0px), env(safe-area-inset-bottom, 0px)) + var(--undo-toast-gap));
18
+ z-index: var(--undo-toast-z);
19
+ max-width: min(var(--undo-toast-max-width), calc(100vw - 2 * var(--undo-toast-gap)));
20
+ pointer-events: none;
21
+ }
22
+ .undo-toast {
23
+ pointer-events: auto;
24
+ display: flex;
25
+ align-items: center;
26
+ gap: 0.25rem;
27
+ padding: 0.375rem 0.375rem 0.375rem 1rem;
28
+ border-radius: var(--undo-toast-radius);
29
+ background: var(--undo-toast-bg);
30
+ color: var(--undo-toast-fg);
31
+ font: inherit;
32
+ box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
33
+ animation: undo-toast-in 160ms ease-out;
34
+ }
35
+ .undo-toast-message {
36
+ flex: 1;
37
+ min-width: 0;
38
+ padding-inline-end: 0.5rem;
39
+ overflow-wrap: anywhere;
40
+ }
41
+ .undo-toast button {
42
+ font: inherit;
43
+ color: inherit;
44
+ background: none;
45
+ border: 0;
46
+ border-radius: calc(var(--undo-toast-radius) - 4px);
47
+ min-height: var(--undo-toast-target);
48
+ min-width: var(--undo-toast-target);
49
+ cursor: pointer;
50
+ touch-action: manipulation;
51
+ transition: transform 80ms ease-out, background-color 80ms ease-out;
52
+ }
53
+ .undo-toast button:active {
54
+ transform: scale(0.96);
55
+ }
56
+ .undo-toast button:focus-visible {
57
+ outline: 2px solid var(--undo-toast-accent);
58
+ outline-offset: 1px;
59
+ }
60
+ .undo-toast-undo {
61
+ display: inline-flex;
62
+ align-items: center;
63
+ gap: 0.5rem;
64
+ padding: 0 0.75rem;
65
+ color: var(--undo-toast-accent) !important;
66
+ font-weight: 600 !important;
67
+ }
68
+ .undo-toast-undo[data-pending] {
69
+ opacity: 0.6;
70
+ cursor: progress;
71
+ }
72
+ .undo-toast-hint {
73
+ font: inherit;
74
+ font-size: 0.8em;
75
+ font-weight: 400;
76
+ opacity: 0.7;
77
+ }
78
+ .undo-toast-close {
79
+ display: inline-grid;
80
+ place-items: center;
81
+ opacity: 0.8;
82
+ }
83
+ @media (hover: hover) and (pointer: fine) {
84
+ .undo-toast button:hover {
85
+ background: rgb(255 255 255 / 0.1);
86
+ }
87
+ }
88
+ /* Touch: 44 px targets, no keyboard hint. */
89
+ @media (pointer: coarse) {
90
+ .undo-toast-region {
91
+ --undo-toast-target: 44px;
92
+ }
93
+ .undo-toast-hint {
94
+ display: none;
95
+ }
96
+ }
97
+ /* A narrow screen: full width, 16 px from each side. */
98
+ @media (max-width: 600px) {
99
+ .undo-toast-region {
100
+ --undo-toast-gap: 16px;
101
+ inset-inline-end: var(--undo-toast-gap);
102
+ max-width: none;
103
+ }
104
+ }
105
+ @keyframes undo-toast-in {
106
+ from {
107
+ transform: translateY(8px);
108
+ opacity: 0;
109
+ }
110
+ }
111
+ @media (prefers-reduced-motion: reduce) {
112
+ .undo-toast {
113
+ animation: none;
114
+ }
115
+ .undo-toast button {
116
+ transition: none;
117
+ }
118
+ }
@@ -0,0 +1 @@
1
+ "use strict";var UndoToast=(()=>{var N=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(e,t)=>{for(var o in t)N(e,o,{get:t[o],enumerable:!0})},oe=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ee(t))!te.call(e,i)&&i!==o&&N(e,i,{get:()=>t[i],enumerable:!(s=Y(t,i))||s.enumerable});return e};var se=e=>oe(N({},"__esModule",{value:!0}),e);var fe={};ne(fe,{CONTEXT_FIELDS:()=>T,PRESETS:()=>E,RULES:()=>K,TIMING:()=>V,advise:()=>y,bindPage:()=>P,confirmLabel:()=>H,contextJsonSchema:()=>W,createUndoOffers:()=>U,defaultIsFailure:()=>_,getUndoOffers:()=>R,isEditable:()=>q,matchesHotkey:()=>S,mountUndoToast:()=>Q,offerFromHistory:()=>X,offerFromMutationFeedback:()=>J,offerUndo:()=>de,presetContext:()=>C,resolveContext:()=>M});var T={reversal:{values:["deferred","compensating","manual","none"],default:"compensating",describe:"How the action can be taken back. 'deferred': nothing is committed until the undo window ends (Gmail's undo send, zodal's undoable mutation). 'compensating': it is already done, and one Undo applies the inverse of the whole operation, in place (re-insert, restore; for a bulk action, one undo step for the whole selection). 'manual': recoverable, but only by hand, item by item, somewhere else (finding 30 songs in a playlist to remove them, restoring 12 items one by one from a trash without a one-step restore); recoverable is not reversible. 'none': it cannot be taken back (a payment, an email already delivered, Delete permanently, Empty Trash)."},cost:{values:["low","high"],default:"low",describe:"What a mistake costs the user. 'high': their work is lost (a document, hours of edits), many items at once, or something hard to recreate (a key, a playlist they built). 'low': it is easy to redo by hand."},frequency:{values:["rare","occasional","frequent"],default:"occasional",describe:"How often the user does this. 'frequent' (toggle, check, reorder, many times a session) makes a toast noise."},resultStaysInView:{values:[!0,!1],default:!1,describe:"True when the changed thing stays on screen showing its new state (a checked box, a renamed title), so the change is its own feedback. False when the item leaves the view, moves away, or the action was done by a shortcut."},failsOften:{values:[!0,!1],default:!1,describe:"True when the action often fails or its result is computed by the server: show it pending, not done, and report failure with Retry."},count:{values:"number",default:1,describe:"How many items the action touched. Above 1 the message names the count and the cost leans high."},hasUndoStack:{values:[!0,!1],default:!1,describe:"True when the app keeps its own undo history (acture-undo, Ctrl/Cmd+Z). Then the toast is a shortcut, the app owns Ctrl/Cmd+Z, and the action stays undoable after the toast leaves."},takesAway:{values:[!0,!1],default:!0,describe:"True when the action takes something from the user (deletes, removes, overwrites): losing its undo toast can lose their work. False when it only adds (to a playlist, a tag): if the undo is lost, nothing is gone, so no trash or undo history is called for."},hasTrash:{values:[!0,!1],default:!1,describe:"True when deleted things go to a trash or 'recently removed' that outlives the toast."},keepNotices:{values:[!0,!1],default:!1,describe:"The user's own setting 'keep notices until I close them' (WCAG 2.2.1, Timing Adjustable). True makes a compensating toast stay until closed."},message:{values:"string",default:void 0,describe:"The toast text, if known: longer text stays longer (reading time)."},verb:{values:"string",default:void 0,describe:"The action's verb phrase, for the confirmation button when the advice is to confirm: 'Move {count} {item|items} to Trash', 'Add {count} {song|songs} to playlist'. `{count}` is the count and `{one|other}` picks the singular at 1; without `{count}`, a count above 1 is appended as ' (12)'."}},E={"remove-item":{describe:"Remove one item from a list or collection (a segment, a row, a card); undo puts it back.",context:{reversal:"compensating",cost:"low"}},"delete-work":{describe:"Delete something the user built (a document, a playlist, a project).",context:{reversal:"compensating",cost:"high"}},"bulk-delete":{describe:"Delete several items at once (pass count).",context:{reversal:"compensating",cost:"high",count:2}},"move-to-trash":{describe:"Move one item to the Trash (soft delete); undo restores it, and so does the Trash after the toast leaves.",context:{reversal:"compensating",cost:"low",hasTrash:!0,verb:"Move to Trash"}},"bulk-move-to-trash":{describe:"Move a selection to the Trash (pass count). A timed toast when one Undo restores the whole selection; pass reversal: 'manual' when the Trash can only restore item by item, and it asks first.",context:{reversal:"compensating",cost:"high",count:2,hasTrash:!0,verb:"Move {count} {item|items} to Trash"}},"add-to-collection":{describe:"Add items to a playlist, folder or collection that is not in view (pass count for a selection). One Undo takes the addition back; pass reversal: 'manual' when the only way back is editing the collection by hand, and a bulk add asks first.",context:{reversal:"compensating",cost:"low",takesAway:!1,verb:"Add to collection"}},"delete-permanently":{describe:"Delete from the Trash for good (pass count). Cannot be taken back: always confirms.",context:{reversal:"none",cost:"high",verb:"Delete {count} {item|items} permanently"}},"empty-trash":{describe:"Empty the Trash (pass count). Cannot be taken back: always confirms.",context:{reversal:"none",cost:"high",verb:"Empty Trash"}},archive:{describe:"Archive, hide, or move out of the current view.",context:{reversal:"compensating",cost:"low"}},"clear-history":{describe:"Clear a list of past entries (recent searches, input history).",context:{reversal:"compensating",cost:"low"}},"forget-secret":{describe:"Forget a stored key or credential; it is held, not erased, until the window ends.",context:{reversal:"deferred",cost:"high"}},send:{describe:"Send, publish or share; held back until the window ends (undo send).",context:{reversal:"deferred",cost:"high"}},toggle:{describe:"Toggle, check, star, reorder: frequent, cheap, and its result stays in view.",context:{reversal:"compensating",cost:"low",frequency:"frequent",resultStaysInView:!0}},pay:{describe:"Pay, or any action with an external effect that cannot be called back.",context:{reversal:"none",cost:"high"}}};function M(e={}){let t={};for(let o of Object.keys(e))if(!(o in T))throw new Error(`undo-toast: unknown context field "${o}"; the fields are ${Object.keys(T).join(", ")}.`);for(let[o,s]of Object.entries(T)){let i=e[o];if(i===void 0){s.default!==void 0&&(t[o]=s.default);continue}if(s.values==="number"){if(typeof i!="number"||!Number.isFinite(i)||i<0)throw new Error(`undo-toast: "${o}" must be a non-negative number, got ${String(i)}.`)}else if(s.values==="string"){if(typeof i!="string")throw new Error(`undo-toast: "${o}" must be a string, got ${typeof i}.`)}else if(!s.values.includes(i))throw new Error(`undo-toast: "${o}" must be one of ${s.values.map(f=>JSON.stringify(f)).join(", ")}, got ${JSON.stringify(i)}.`);t[o]=i}return t}function C(e,t={}){let o=E[e];if(!o)throw new Error(`undo-toast: unknown preset "${e}"; the presets are ${Object.keys(E).join(", ")}.`);return{...o.context,...t}}function W(){let e={};for(let[t,o]of Object.entries(T)){let s=o.values==="number"?{type:"number",minimum:0}:o.values==="string"?{type:"string"}:o.values.every(i=>typeof i=="boolean")?{type:"boolean"}:{type:"string",enum:[...o.values]};e[t]={...s,description:o.describe,...o.default===void 0?{}:{default:o.default}}}return{$schema:"https://json-schema.org/draft/2020-12/schema",title:"ActionContext",type:"object",properties:e,additionalProperties:!1}}var V={actionMs:1e4,deferredMs:1e4,highCostMs:15e3,baseWords:10,msPerExtraWord:250,maxMs:2e4,resumeMinMs:4e3,confirmTypeAbove:10},Z=e=>e?e.trim().split(/\s+/).filter(Boolean).length:0,F=e=>e.cost==="high"||e.count>1,O=e=>e.hasUndoStack||e.hasTrash,p="docs/research/undo-toast-standard.md",L="docs/research/bulk-confirm.md";function H(e){if(!e.verb)return null;let t=e.verb.replace(/\{([^{}|]*)\|([^{}|]*)\}/g,(o,s,i)=>e.count===1?s:i);return t.includes("{count}")?t.replaceAll("{count}",String(e.count)):e.count>1?`${t} (${e.count})`:t}var j=()=>({surface:"confirm",durationMs:null}),K=[{id:"irreversible",when:e=>e.reversal==="none",then:(e,t,o)=>({...j(),typeToConfirm:t.count>o.confirmTypeAbove}),why:'Nothing can take it back, so an Undo button would lie: ask first, on a button that names the verb and the count ("Pay \u20AC12", "Delete 37 tracks permanently", not "OK"), with type-to-confirm above `timing.confirmTypeAbove` items; then show it pending.',source:`${p} \xA76; ${L}`,final:!0},{id:"bulk-confirm",when:e=>e.reversal==="manual"&&e.count>1,then:()=>j(),why:`A bulk action that no single Undo takes back (recoverable only by hand, item by item: from the playlist, from a trash without a one-step restore) asks first, with the count in the verb ("Move 12 items to Trash"), then shows it pending. Recoverable is not reversible. A plain confirmation, not a typed one: the items can still be recovered. To earn an undo toast instead, run the whole selection as one undo step (one history entry, one restore) and say reversal: 'compensating'.`,source:L,final:!0},{id:"manual",when:e=>e.reversal==="manual",then:(e,t)=>t.cost==="low"&&t.resultStaysInView?{surface:"none",durationMs:null}:j(),why:"One item, recoverable only by hand: there is no Undo to offer, so a toast would have nothing to do. If the change stays in view, cheap, it is its own feedback; otherwise ask first, so the user knows what happened and where. Make it compensating (an undo that restores it) to get an undo toast instead.",source:L,final:!0},{id:"fails-often",when:e=>e.failsOften,then:()=>({surface:"pending",durationMs:null}),why:"An action that often fails, or whose result the server computes, must not look done: keep the control pending until it is, and report a failure with Retry in a notice that stays until closed.",source:`${p} \xA76`,final:!0},{id:"bulk-one-step-undo",when:e=>e.count>1&&(e.reversal==="compensating"||e.reversal==="deferred"),then:()=>({}),why:"A bulk action gets an undo toast, not a confirmation, because one Undo takes the whole operation back in place; a dialog would teach people to click through it. If taking it back meant finding the items one by one, it would be reversal: 'manual' and would ask first (the bulk-confirm rule).",source:`${L}; ${p} \xA76`},{id:"result-in-view",when:e=>e.resultStaysInView&&!F(e)&&e.reversal==="compensating",then:()=>({surface:"none",durationMs:null}),why:"The changed thing stays on screen in its new state, so it is its own feedback; a toast for a cheap, visible change is noise. Undo stays available through the app's undo history (Ctrl/Cmd+Z) if it has one.",source:`${p} \xA76`,final:!0},{id:"only-way-back-addition",when:e=>e.reversal==="compensating"&&!O(e)&&!e.takesAway,then:()=>({durationMs:null}),why:"The toast is the only quick way to take the addition back, so it stays until Undo, Close, Escape, or the next action replaces it (Material 3: a snackbar with an action should remain). Nothing is lost if it goes: no trash or undo history is called for.",source:`${p} \xA72`},{id:"only-way-back",when:e=>e.reversal==="compensating"&&!O(e)&&e.takesAway,then:()=>({durationMs:null}),why:"The toast is the only way to undo, so it stays until Undo, Close, Escape, or the next action replaces it (Material 3: a snackbar with an action should remain; WCAG 2.2.1: a time limit must be adjustable). Give the app an undo history or a trash to make it timed.",source:`${p} \xA72`},{id:"undo-elsewhere",when:e=>e.reversal==="compensating"&&O(e),then:(e,t,o)=>({durationMs:o.actionMs}),why:"Undo is also reachable elsewhere (Ctrl/Cmd+Z, history, trash), so the toast is a shortcut and may leave on its own: 10 s, paused while hovered, focused, touched or hidden.",source:`${p} \xA72`},{id:"deferred",when:e=>e.reversal==="deferred",then:(e,t,o)=>({durationMs:o.deferredMs,onExpire:"commit",onClose:"commit"}),why:"Nothing is sent until the window ends: expiry sends, closing sends at once, a replacing toast sends, and so does `pagehide`. The window is always finite (a held action is stale for other tabs and lost with the tab) and the user should be able to choose its length (`timing.deferredMs`), as Gmail offers 5-30 s.",source:`${p} \xA72`},{id:"reading-time",when:(e,t)=>Z(e.message)>t.baseWords,then:(e,t,o)=>e.durationMs===null?{}:{durationMs:Math.min(o.maxMs,Math.max(e.durationMs,e.durationMs+(Z(t.message)-o.baseWords)*o.msPerExtraWord))},why:"A long message gets reading time on top of a timed toast (an estimate, capped).",source:`${p} \xA72`},{id:"high-cost",when:F,then:(e,t,o)=>e.durationMs===null?{}:{durationMs:Math.max(e.durationMs,o.highCostMs)},why:"A costly mistake (lost work, several items) gets a longer window when the toast is timed.",source:`${p} \xA72`},{id:"no-trash",when:e=>F(e)&&e.takesAway&&e.reversal==="compensating"&&!O(e),then:e=>({warnings:[...e.warnings,'Costly and undoable only from the toast: add a trash or "recently removed" that outlives it, or an undo history, so a replaced or closed toast is not a lost item.']}),why:"The toast should be a shortcut, not the only way back; prefer a soft delete. Not for an action that only adds (takesAway: false): a lost toast loses nothing.",source:`${p} \xA72`},{id:"keep-notices",when:e=>e.keepNotices&&e.reversal==="compensating",then:()=>({durationMs:null}),why:"The user asked to keep notices until they close them (WCAG 2.2.1, Timing Adjustable).",source:`${p} \xA72`},{id:"frequent",when:e=>e.frequency==="frequent",then:()=>({coalesce:!0}),why:'A burst of the same action merges into one toast with a count ("3 items deleted. Undo"); one Undo takes back the whole burst.',source:`${p} \xA75`},{id:"undo-stack",when:e=>e.hasUndoStack,then:e=>({hotkeys:{...e.hotkeys,undo:null}}),why:"The app's own undo history owns Ctrl/Cmd+Z, and a replaced toast's action stays undoable there.",source:`${p} \xA74`}];function ie(e){return{surface:"toast",confirmLabel:null,typeToConfirm:!1,durationMs:e.actionMs,resumeMinMs:e.resumeMinMs,pauseOn:["hover","focus","touch","hidden"],onExpire:"forget",onClose:"forget",coalesce:!1,undoLabel:"Undo",closeLabel:"Close notification",failedText:"Could not undo.",retryLabel:"Try again",hotkeys:{focus:"F8",undo:"$mod+z"},reasons:[],warnings:[]}}function y(e={},t={},{rules:o=K,timing:s,overrides:i,label:f=H}={}){let l={...V,...s},c=M(typeof e=="string"?C(e,t):{...e,...t}),d=ie(l);for(let u of o)if(u.when(c,l)&&(d={...d,...u.then(d,c,l)},d.reasons=[...d.reasons,{rule:u.id,why:u.why,source:u.source}],u.final))break;return i&&Object.keys(i).length&&(d={...d,...i},d.reasons=[...d.reasons,{rule:"override",why:`Set by the host: ${Object.keys(i).join(", ")}.`,source:"caller"}]),d.surface==="confirm"&&d.confirmLabel===null&&(d.confirmLabel=f(c)),d}var re={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()},_=e=>e===!1||typeof e=="object"&&e!==null&&e.ok===!1;function U({timers:e=re,onError:t=(s,i)=>console.error(`undo-toast: ${i} failed`,s),isFailure:o=_}={}){let s=null,i=null,f=0,l=new Set,c=new Set,d=()=>c.forEach(n=>n()),u=(n,r)=>typeof n.message=="function"?n.message(r):r>1?`${n.message} (${r})`:n.message,m=n=>n.pauseOn.some(r=>l.has(r)),A=(n,r)=>{if(n.advice)return n.advice;let a=n.context??{};return r>1?y(a,{count:r}):y(a)};function k(n,r){n.view={...n.view,...r}}function b(n){n.running&&(e.clearTimeout(n.timer),n.running=!1,n.remaining!==null&&(n.remaining-=e.now()-n.startedAt))}function h(n){let r=n.remaining!==null&&n.view.status==="shown"&&!m(n.view.advice);if(r!==n.running){if(!r)return b(n);n.startedAt=e.now(),n.running=!0,n.timer=e.setTimeout(()=>{s===n&&$("expire")},Math.max(0,n.remaining??0))}}function x(n){for(let r of n)if(r.commit)try{Promise.resolve(r.commit()).catch(a=>t(a,"commit"))}catch(a){t(a,"commit")}}function G(n,r,a){let g={view:{id:a,message:u(n,1),count:1,advice:r,status:"shown",paused:m(r)},input:n,entries:[{undo:n.undo,commit:n.commit}],remaining:r.durationMs,startedAt:e.now(),running:!1,timer:void 0};s=g,h(g)}function $(n){let r=s;if(!r)return;b(r),s=null,(n==="close"?r.view.advice.onClose:r.view.advice.onExpire)==="commit"&&r.view.status==="shown"&&x(r.entries),B(),d()}function B(){if(s||!i)return;let n=i;i=null,G(n.input,n.advice,n.id)}return{offer(n){let r=A(n,1);if(r.surface==="none")return null;if(r.surface!=="toast"){let v=r.reasons.at(-1)?.why??"";throw new Error(`undo-toast: this action calls for '${r.surface}', not an undo toast. ${v}`)}let a=s;if(a&&a.view.status==="undoing")return i&&i.advice.onExpire==="commit"&&x([{undo:i.input.undo,commit:i.input.commit}]),i={input:n,advice:r,id:++f},i.id;if(a&&r.coalesce&&n.key!==void 0&&a.input.key===n.key&&a.view.status==="shown"){b(a);let v=a.view.count+1,I=A(n,v);return a.entries.push({undo:n.undo,commit:n.commit}),a.remaining=I.durationMs,a.input=n,k(a,{message:u(n,v),count:v,advice:I,paused:m(I)}),h(a),d(),a.view.id}a&&(b(a),s=null,a.view.advice.onExpire==="commit"&&a.view.status==="shown"&&x(a.entries));let g=++f;return G(n,r,g),d(),g},async undo(){let n=s;if(!n||n.view.status==="undoing")return!1;b(n),k(n,{status:"undoing",error:void 0}),d();let r;try{for(;n.entries.length;){let g=await n.entries[n.entries.length-1].undo();if(o(g))throw new Error("undo-toast: the undo reported failure");n.entries.pop()}}catch(a){r=a}return r!==void 0?(t(r,"undo"),s===n&&(n.remaining=null,k(n,{status:"failed",error:r}),d()),!1):(s===n&&(s=null),B(),d(),!0)},close(){$("close")},hold(n,r){if(r===l.has(n))return;r?l.add(n):l.delete(n);let a=s;if(!a)return;let g=a.view.paused,v=m(a.view.advice);g!==v&&(v?b(a):a.remaining!==null&&(a.remaining=Math.max(a.remaining,a.view.advice.resumeMinMs)),k(a,{paused:v}),h(a),d())},flush(){s&&s.view.advice.onExpire==="commit"&&$("expire"),i&&i.advice.onExpire==="commit"&&(x([{undo:i.input.undo,commit:i.input.commit}]),i=null)},current:()=>s?.view??null,subscribe(n){return c.add(n),()=>c.delete(n)}}}function S(e,t,o=D()){if(!t)return!1;let s=t.toLowerCase().split("+"),i=s.pop(),f=s.includes("$mod")||s.includes("mod"),l=s.includes("meta")||f&&o,c=s.includes("ctrl")||f&&!o;return e.key.toLowerCase()===i&&e.metaKey===l&&e.ctrlKey===c&&e.shiftKey===s.includes("shift")&&e.altKey===s.includes("alt")}function D(){return typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent)}function q(e){let t=e;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;if(!t)return!1;let o=t.tagName;return o==="INPUT"||o==="TEXTAREA"||o==="SELECT"||t.isContentEditable===!0}function P(e,{doc:t=document,focus:o,contains:s}={}){let i=t.defaultView,f=()=>e.hold("hidden",t.visibilityState==="hidden"),l=()=>e.flush(),c=d=>{let u=e.current();if(!u||d.defaultPrevented||d.repeat)return;let{hotkeys:m}=u.advice;o&&S(d,m.focus)?(d.preventDefault(),o()):S(d,m.undo)&&!q(t.activeElement)?(d.preventDefault(),e.undo()):d.key==="Escape"&&s?.(t.activeElement)&&(d.preventDefault(),e.close())};return f(),t.addEventListener("visibilitychange",f),i?.addEventListener("pagehide",l),i?.addEventListener("keydown",c),()=>{t.removeEventListener("visibilitychange",f),i?.removeEventListener("pagehide",l),i?.removeEventListener("keydown",c),e.hold("hidden",!1)}}function J(e,{message:t,context:o={}}){if(e.kind!=="scheduled"||!e.undo||e.seconds===void 0)return null;let s=e.undo,i=y({...o,reversal:"deferred"},{},{overrides:{durationMs:e.seconds*1e3,pauseOn:[],onExpire:"forget",onClose:"forget"}});return{message:t,undo:()=>s(),advice:i}}function X(e,{message:t,context:o={},key:s}){let i=typeof o=="string"?y(o,{hasUndoStack:!0}):y({...o,hasUndoStack:!0});return{message:t,undo:()=>e.undo(),advice:i,...s===void 0?{}:{key:s}}}var ae;function R(){return ae??=U()}function de(e){return R().offer(e)}var z="http://www.w3.org/2000/svg",le=0;function Q({offers:e=R(),regionLabel:t="Notifications",container:o}={}){let s=w("section","undo-toast-region");s.setAttribute("aria-label",t);let i=w("div");i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-atomic","true"),s.append(i);let f=()=>(o??document.body).append(s);o||document.body?f():document.addEventListener("DOMContentLoaded",f,{once:!0});let l=null,c=null,d=null,u=null,m=()=>{if(l&&l.contains(document.activeElement)){let h=u;u=null,l.remove(),h?.isConnected&&h.focus()}else l?.remove();l=c=null,d=null},A=()=>{let h=e.current();if(!h)return m();h.id!==d&&(m(),{toast:l,undoButton:c}=ue(h,e,x=>u=x),d=h.id,i.append(l)),ce(l,c,h)},k=P(e,{focus:()=>{let h=document.activeElement;h instanceof HTMLElement&&!l?.contains(h)&&(u=h),c?.focus()},contains:h=>!!h&&!!l?.contains(h)}),b=e.subscribe(A);return A(),()=>{b(),k(),m(),s.remove()}}function w(e,t){let o=document.createElement(e);return t&&(o.className=t),o}function ue(e,t,o){let s=w("div","undo-toast"),i=w("span","undo-toast-message");i.id=`undo-toast-message-${++le}`;let f=w("button","undo-toast-undo");f.type="button",f.setAttribute("aria-describedby",i.id),f.addEventListener("click",()=>{t.undo()});let l=w("button","undo-toast-close");l.type="button",l.setAttribute("aria-label",e.advice.closeLabel),l.addEventListener("click",()=>t.close());let c=document.createElementNS(z,"svg");c.setAttribute("viewBox","0 0 16 16"),c.setAttribute("width","16"),c.setAttribute("height","16"),c.setAttribute("aria-hidden","true");let d=document.createElementNS(z,"path");return d.setAttribute("d","M4 4l8 8M12 4l-8 8"),d.setAttribute("stroke","currentColor"),d.setAttribute("stroke-width","1.75"),d.setAttribute("stroke-linecap","round"),c.append(d),l.append(c),s.append(i,f,l),s.addEventListener("pointerenter",u=>u.pointerType==="mouse"&&t.hold("hover",!0)),s.addEventListener("pointerleave",u=>u.pointerType==="mouse"&&t.hold("hover",!1)),s.addEventListener("pointerdown",u=>u.pointerType!=="mouse"&&t.hold("touch",!0)),s.addEventListener("pointerup",u=>u.pointerType!=="mouse"&&t.hold("touch",!1)),s.addEventListener("pointercancel",()=>t.hold("touch",!1)),s.addEventListener("focusin",u=>{let m=u.relatedTarget;m instanceof HTMLElement&&!s.contains(m)&&o(m),t.hold("focus",!0)}),s.addEventListener("focusout",u=>{s.contains(u.relatedTarget)||t.hold("focus",!1)}),{toast:s,undoButton:f}}function ce(e,t,o){let{advice:s,status:i}=o,f=i==="failed",l=i==="undoing";if(e.dataset.status=i,e.querySelector(".undo-toast-message").textContent=f?`${s.failedText} ${o.message}`:o.message,t.textContent=f?s.retryLabel:s.undoLabel,l?(t.setAttribute("aria-disabled","true"),t.setAttribute("aria-busy","true"),t.dataset.pending="true"):(t.removeAttribute("aria-disabled"),t.removeAttribute("aria-busy"),delete t.dataset.pending),s.hotkeys.undo&&!f){let c=w("kbd","undo-toast-hint");c.setAttribute("aria-hidden","true"),c.textContent=D()?"\u2318Z":"Ctrl+Z",t.append(c)}}return se(fe);})();
@@ -0,0 +1,48 @@
1
+ # ADR 0001: undo toasts get their own agent-first package
2
+
3
+ Status: accepted, 2026-11-16.
4
+
5
+ ## Context
6
+
7
+ Four undo offers had been written by hand across the owner's apps and zodal, each with its own numbers: two apps' hand-made `UndoBar`s (15 s each; one paused on hover and focus and offered "Undo" and "Dismiss" at a fixed `bottom: 11rem`, the other never paused, had no close control and a fixed offset), zodal's headless `undoable` mutation mode (5 s, deferred send) and zodal's field-history "History cleared. Undo" (10 s). None was shared, and the owner's review of the first found three problems that the others share: the toast floated a third of the way up the screen, "Dismiss" read as "dismiss the action" (that is, undo), and it was unclear whether and when the toast would leave, or what Enter would do.
8
+
9
+ The owner asked for the toast to become a reusable primitive whose parameters are chosen per action, with "agent primitives that enable agents to make these decisions smartly, based on best practices and standard UX", possibly as a package that catalogues the seams and their concrete dependencies.
10
+
11
+ ## Decision
12
+
13
+ 1. **A package of its own, `undo-toast`** (npm; free on npm, PyPI and GitHub when checked on 2026-11-16, as were the alternatives `undoffer`, `undo-offer`, `undotoast` and `backsies`), in the owner's frontend directory, MIT.
14
+ 2. **Not in zodal, not in acture.** The decision and the offer's life do not depend on a schema (zodal's concern) or on a command registry (acture's). Two of the four existing offers use neither. Both zodal (`onFeedback` of an `undoable` mutation) and acture (`createUndoHistory`) plug in through the one seam that matters, `undo: () => unknown`, via two small adapters typed by shape only, so when zodal's window becomes pausable the adapter changes and the apps do not.
15
+ 3. **The core is the decision: `advise(action) → Advice`**, with the rules as an ordered data table (`RULES`), the numbers in one object (`TIMING`), the vocabulary in one field table (`CONTEXT_FIELDS`, with `PRESETS` for common actions), and every rule citing its source in the research report. The advice says why, rule by rule (`reasons`), so an agent can explain or override any part. The CLI (`npx undo-toast advise …`) and the shipped skill are the agent surfaces over the same function.
16
+ 4. **The offer's life is framework-free** (`createUndoOffers`): one offer at a time, pauses, deferred commit, coalescing, a guarded undo that stays on screen if it fails. The React toast is one renderer of it (`undo-toast/react`).
17
+ 5. **No zod.** The field table is the schema: types, validation, CLI flags and the skill's table derive from it. A toast should not make every host install a validation library. Revisit if a host wants the context as a Zod schema (for an MCP tool, say).
18
+
19
+ The defaults follow the research (`docs/research/undo-toast-standard.md`), which settled the owner's three questions: the toast goes bottom-left on a wide screen and full width at the bottom on a phone, above any docked bar; the close control is an × named "Close notification", never "Dismiss"; nothing happens on Enter unless the user moved focus to a button. On duration, the research and the UX review disagreed (8 s with undo kept reachable elsewhere, against Material 3 and WCAG 2.2.1's "a toast with an action stays"); the rule now depends on the context: a toast that is the only way back stays until closed or replaced, one with a fallback (an undo history, a trash) leaves after 10 s, and a deferred action's window is 10 s (15 s when costly) and user-adjustable.
20
+
21
+ ## What the fleet already had (the search, 2026-11-16)
22
+
23
+ - The four hand-made undo offers above, and zodal's `undoSeconds` (core `operations.ts`) and `HISTORY_UNDO_MS` (`@zodal/ui`).
24
+ - **acture-undo** (`createUndoHistory`): the undo *history* (patches, transactions, Ctrl/Cmd+Z). Reused as the undo backend through `offerFromHistory`, not re-implemented; the toast is a consumer surface of it, not part of it.
25
+ - **zodal `createMutations` (`undoable` mode)**: the deferred send and its window. Reused through `offerFromMutationFeedback`; its window cannot be paused yet (i2mint/zodal#146).
26
+ - **zodal `createActionFeedback`** (press guard, pending and error state for actions): overlaps the `undoing` guard. Not reused because the guard here is three lines on the offer's own status, and `@zodal/ui` would be a dependency of every host.
27
+ - **acture-hotkeys** (tinykeys): overlaps the key matcher. Not reused because the toast needs two keys and no dependency; the advice emits tinykeys syntax (`$mod+z`) so an acture host can bind the same keys in its keymap instead.
28
+ - **Toast libraries** (sonner, react-hot-toast): their defaults (4-5 s, stacks) contradict the standard for a toast that is the only way back; a renderer seam is left for them instead of a dependency.
29
+ - Prior fleet research: the feedback principle's optimistic-updates note (undo beats a confirmation; zodal's feedback sink) is cited, not redone.
30
+
31
+ ## Seams
32
+
33
+ | # | Seam | v1 default | Replacement we can point at |
34
+ |---|---|---|---|
35
+ | 1 | What Undo does (`undo`, `commit` on each offer) | the host's callbacks | zodal `MutationFeedback.undo`, acture-undo `history.undo()`, through the structural adapters `offerFromMutationFeedback` / `offerFromHistory` (no import of either) |
36
+ | 2 | The renderer | `UndoToast` (React, plain DOM and CSS, no UI library) | sonner (the shadcn toast) or a design system's toast, over `subscribe` + `current()` |
37
+ | 3 | The rules and numbers (`rules`, `timing`, `overrides` on `advise`) | `RULES`, `TIMING` | a host's own policy, the owner's request for per-action parameters |
38
+ | 4 | Timers and clock (`timers` on `createUndoOffers`) | the global ones | the fake clock in the tests |
39
+
40
+ Not seams, on purpose: the live region (the toast's own `role="status"`), the placement (CSS custom properties), the close icon. The page wiring (keys, hidden tab, `pagehide`) is core code (`bindPage`) that every renderer calls, so a second renderer cannot drift from the first.
41
+
42
+ Surfaces: the shipped skill and the CLI are built; the React toast is built because the first consumers are React apps. MCP: the CLI's JSON is already what an MCP tool would return; not built until an agent outside a shell needs it. Python: none.
43
+
44
+ ## Consequences
45
+
46
+ - Apps replace their hand-made undo bars with `offerUndo` + `<UndoToast />` (adoption issues filed per app). zodal's 5 s default is shorter than the standard's 10 s for a deferred window; filed upstream, with the request to let a host pause a scheduled mutation's window.
47
+ - The frontend skill routes undo toasts here; acture remains the home of undo *history*.
48
+ - The first npm publish is the owner's (a new name needs their login); CI publishes later versions with trusted publishing.
@@ -0,0 +1,80 @@
1
+ # Bulk actions: confirmation or undo
2
+
3
+ An excerpt (section 4, unchanged) of the views-and-selection research report (2026-11-23) (128 references in all). It is the source of the `bulk-confirm`, `manual` and `bulk-one-step-undo` rules in `src/advise.ts`. Reference numbers are the report's own.
4
+
5
+ ## 4. Confirmation, undo and reversibility for bulk operations
6
+
7
+ ### 4.1 What the guidance says
8
+
9
+ - **Undo beats a warning.** Aza Raskin's argument is that people habituate to dialogs and click through them, so a warning does not protect; an undo does. The title is the rule: "Never use a warning when you mean undo". He also rejects louder warnings and typed confirmations as general fixes, and gives Gmail as the model: delete offers an undo at once, and the message also goes to Trash [19].
10
+ - **NN/g is more balanced.** Keep confirmations for actions with serious consequences, because "if you cry wolf too many times, people will stop paying attention"; make the dialog specific about the item and the consequence; label the buttons with the outcome, not Yes and No; add unusual friction such as typing only for rare severe cases; and offer undo wherever possible [18]. Heuristic 3, user control and freedom, asks for a clearly marked emergency exit and a visible undo [74].
11
+ - **Platforms agree.** Apple advises against alerts for common, undoable actions, even destructive ones [75] (summary). Fluent reserves alert dialogs for potential loss [76] (summary). Material's snackbar guidance recommends an "Undo" action [77] (summary).
12
+ - **Design systems grade by impact.** Carbon's remove pattern has three tiers: low impact needs no confirmation, especially when undo exists; medium impact gets a modal that states the consequences; high impact requires typing the resource name [78] (summary). Cloudscape limits typed confirmation to high-severity deletions, such as a resource that cannot be recreated, and warns that extra steps on low-impact deletions frustrate users [20]. GitHub Primer recommends an undo window for reversible actions [79] (summary).
13
+
14
+ ### 4.2 Thresholds by count
15
+
16
+ None of the design systems we could read gives a numeric threshold for the number of items. NN/g says only that thresholds need analysis and may be personal [18]. So a count rule has to be configuration, not a built-in number. The structure that the sources support is this: reversibility and cost of error choose the tier, and count can only promote an irreversible action from a plain confirmation to a typed one. A reversible bulk action stays at undo however large it is. Two conditions deserve promotion besides raw count: an implicit selection that includes items the user has not seen, and a selection with items hidden by the current filter.
17
+
18
+ ### 4.3 Dialog content
19
+
20
+ State the count and the object type ("Delete 37 tracks permanently?"), the consequence, and that it cannot be undone. Use verb labels ("Delete 37 tracks", "Cancel"). Style the destructive button as destructive and do not make it the default. For a typed confirmation, keep the primary button disabled until the text matches [18][20][78]. The scope text and count must come from the same selection object as the payload [17].
21
+
22
+ ### 4.4 Undo for bulk operations
23
+
24
+ - **One intention is one undo step.** Abowd and Dix frame undo as serving a user's intention, not a system command [80] (bibliographic record). A bulk delete of 37 items is therefore one history entry: a composite command or a transaction. Reusable hierarchical command objects are the classic implementation [81] (not opened).
25
+ - **Linear or selective.** Berlage's selective undo reverses one earlier command in the current state, when that is meaningful [82] (abstract). In shared data the established model is to undo one's own actions only [83] (not opened). A single global linear stack is therefore wrong for multi-user data.
26
+ - **Implementation strategies** (our synthesis): an inverse command (small, but wrong if the state drifted); a snapshot of the affected items (robust, costs memory); a delayed commit, where the call fires after the undo window (atomic, but a closed tab in the window loses or duplicates the action unless the pending intent is persisted); and soft delete, where the inverse is an attribute flip and undo survives a reload. Soft delete plus a toast is the combination to prefer for delete.
27
+ - **Timing and accessibility.** We could not verify a duration figure in the Material specification; the often-quoted "4 to 10 seconds" has no source we could find. Angular Material advises against a fixed duration on a snackbar that has an action, so that screen-reader users can reach it [84] (summary). WCAG 2.2.1 allows timed content when an alternative that does not rely on the timer exists [85], and O'Hara argues that a screen-reader user may not reach Undo before a toast goes, so undo should also live outside the toast [86]. Hence: pause the timer on hover and focus, and always mirror the undo in a persistent place (the trash, or a history entry).
28
+
29
+ ### 4.5 Partial failure
30
+
31
+ Batch APIs report per item. Elasticsearch's `_bulk` returns a top-level `errors` flag and one result per operation, in order [87] (summary). S3 `DeleteObjects` returns a result per key and reports a missing key as deleted, which makes it idempotent [88] (summary). HTTP 207 Multi-Status carries one status per resource [89] (summary). Best effort with per-item results is the norm; all-or-nothing needs a transaction and is right only when the items depend on each other. For the UI: report the counts and the per-item reasons, keep the failed items selected, offer "Retry failed", and make undo cover only what succeeded (our synthesis; we found no design-system page on partial-failure screens).
32
+
33
+ ### Recommendations
34
+
35
+ | Reversible by the system? | Cost and scale | Treatment |
36
+ |---|---|---|
37
+ | Yes (trash, archive, tag, move, status change) | any count | No dialog. Act at once; one compound undo ("37 items moved to Trash · Undo"); the trash or history is the long window |
38
+ | Yes, but with side effects that cannot be reversed (messages sent, external calls) | any | Plain confirmation naming the side effect |
39
+ | No (delete permanently, empty trash) | low cost, small count | Confirmation with count, object type and consequence; verb buttons; no destructive default |
40
+ | No | high cost, or count over a host-set limit, or an implicit selection with unseen items | Typed confirmation; primary disabled until it matches |
41
+
42
+ 1. Each action declares `reversible` and optionally `confirm: 'none' | 'simple' | 'typed'` and `confirmThreshold`; the component derives the default from `reversible`. Ship no magic number: the threshold is a setting with a documented default labelled as an estimate.
43
+ 2. Never show both a confirmation and an undo toast for one action.
44
+ 3. Give every bulk operation a `batchId`, so its undo and its restore from trash act on the group.
45
+ 4. Proposed result type, used by every selection action and by restore:
46
+
47
+ ```ts
48
+ type BulkResult = {
49
+ requested: number;
50
+ succeeded: Id[];
51
+ failed: { id: Id; code: string; message: string; retryable: boolean }[];
52
+ skipped: { id: Id; reason: string }[];
53
+ undoToken?: string;
54
+ };
55
+ ```
56
+
57
+ 5. Treat "not found" on delete as success. Show a toast for full success, and a result panel with "Retry failed" for partial success.
58
+
59
+ ## References
60
+
61
+ [17] [Migrate select-all actions from Polaris React — Shopify, 2026](https://shopify.dev/docs/apps/build/app-home/migrate-from-polaris-react/select-all-actions.md)
62
+ [18] [Confirmation Dialogs Can Prevent User Errors — If Not Overused — Nielsen Norman Group](https://www.nngroup.com/articles/confirmation-dialog/)
63
+ [19] [Never Use a Warning When You Mean Undo — Aza Raskin, A List Apart, 2007](https://alistapart.com/article/neveruseawarning/)
64
+ [20] [Delete with additional confirmation — Cloudscape](https://cloudscape.design/patterns/resource-management/delete/delete-with-additional-confirmation/)
65
+ [74] [User Control and Freedom (Usability Heuristic 3) — Nielsen Norman Group](https://www.nngroup.com/articles/user-control-and-freedom/)
66
+ [75] [Alerts — Apple Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/alerts) (search-summarised)
67
+ [76] [Dialog usage — Fluent 2](https://fluent2.microsoft.design/components/web/react/dialog/usage) (search-summarised)
68
+ [77] [Snackbars — Material Design](https://material.io/components/snackbars) (via search summary)
69
+ [78] [Remove pattern — Carbon Design System](https://carbondesignsystem.com/community/patterns/remove-pattern) (search-summarised)
70
+ [79] [Delete scenario pattern — GitHub Primer](https://primer.style/product/scenario-patterns/delete) (search-summarised)
71
+ [80] [Giving Undo Attention — Abowd and Dix, Interacting with Computers 4(3), 1992](https://bibbase.org/network/publication/abowd-dix-givingundoattention-1992) (bibliographic record)
72
+ [81] [Reusable Hierarchical Command Objects — Myers and Kosbie, CHI 1996](https://www.cs.cmu.edu/~amulet/papers/commandsCHI.html) (not opened)
73
+ [82] [A selective undo mechanism for graphical user interfaces based on command objects — Berlage, ACM TOCHI 1(3), 1994](https://scilit.com/publications/adb1ed36673556bf92702df99bdf41cf) (bibliographic record)
74
+ [83] [A Framework for Undoing Actions in Collaborative Systems — Prakash and Knister, TOCHI 1994](https://web.eecs.umich.edu/~aprakash/papers/undo-tochi94.pdf) (not opened)
75
+ [84] [Snackbar overview — Angular Material](https://material.angular.io/components/snack-bar) (via search summary)
76
+ [85] [Understanding SC 2.2.1 Timing Adjustable — W3C WCAG 2.2](https://www.w3.org/WAI/WCAG22/Understanding/timing-adjustable.html)
77
+ [86] [A toast to a11y toasts — Scott O'Hara, 2019](https://scottohara.me/blog/2019/07/08/a-toast-to-a11y-toasts.html)
78
+ [87] [Bulk API — Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html)
79
+ [88] [DeleteObjects — Amazon S3 API reference](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html)
80
+ [89] [207 Multi-Status — MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/207)
@@ -0,0 +1,193 @@
1
+ # Undo toasts: the established standard, and defaults for a reusable package
2
+
3
+ Research date: 2026-11-16. Scope: the transient "Item deleted. Undo" message shown after a reversible action, to set the defaults of a framework-free decision function with a React/TS surface.
4
+
5
+ ## Summary
6
+
7
+ The sources agree on more than the shipped libraries suggest. The design systems that have updated their guidance recently (Material 3, Carbon, Polaris in code, Fluent 2) converge on one rule that most toast libraries do not follow by default: **a toast that carries an action, and Undo is the archetypal action, should not vanish on a short timer** [1][2][12][20]. Material 3 now says it outright: snackbars with actions "should remain on the screen until the user takes an action on the snackbar, or dismisses it" [1], and "Snackbars with actions shouldn't auto-dismiss" [2]. WCAG 2.2.1 backs this whenever the toast is the only way to undo [35]. Libraries such as sonner (4 s) and react-hot-toast (2–4 s) default to short timers for every toast [24][26][27], and react-admin's undoable mode commits after 5 s [29][30], so the package should not copy library defaults.
8
+
9
+ The second consensus is about focus and announcement: announce politely through a live region that already exists, do not move focus, do not trap focus, give keyboard users a documented shortcut to reach the toast, and let Escape close it [2][37][38][43][46]. Carbon is the outlier here, since its actionable toast is an `alertdialog` that takes and traps focus [13][14].
10
+
11
+ The third is that an undo toast is often the wrong pattern: errors, long-running work, irreversible actions and trivial frequent actions each have a better pattern, and GitHub's Primer goes as far as recommending against toasts altogether [22][23][48][49][9].
12
+
13
+ ### Recommended defaults
14
+
15
+ | Setting | Recommended default | Where a different value applies |
16
+ |---|---|---|
17
+ | Name | "undo toast" in docs; "snackbar" as an alias | Material/Android codebases say snackbar [1][7] |
18
+ | Placement, desktop / wide | Bottom, inline-start (bottom-left in LTR), 24 px from the edges | Bottom-centre is equally sanctioned if consistent [1][4]; top-right only if the app already puts all notifications there (Carbon) [12] |
19
+ | Placement, phone / compact | Bottom, full width minus 16 px gutters, lifted above bottom nav, FAB, docked toolbar or persistent player | Never in front of navigation or a FAB [1][6] |
20
+ | Auto-dismiss when Undo is the only path to reverse the action | **None**: stays until Undo, Close, Escape, or replacement by the next toast | Required by M3 [1][2] and by WCAG 2.2.1 unless the timer is adjustable/extendable [35] |
21
+ | Auto-dismiss when the action is also reversible elsewhere (Ctrl/Cmd+Z, history, Trash) | 10 s, paused while hovered, focused, or the page is hidden | 4–7 s only for toasts with no action [2][5][15][24] |
22
+ | Commit model | Compensating undo (soft delete, restore on Undo); the toast lifetime is decoupled from the commit | Deferred commit only when the side effect cannot be reversed (sending email): window 10 s default, user-configurable (Gmail offers 5/10/20/30 s) [31] |
23
+ | Close control | Icon button "×" with accessible name "Close notification"; tooltip "Close" | Never "Dismiss", "Cancel" or "OK" as text beside Undo (see §3) [4][9] |
24
+ | Action label | Visible "Undo"; accessible name starts with it, e.g. "Undo delete of Report.pdf" | One action only [1][12] |
25
+ | Focus | Not moved on appear; not trapped; returns to the previously focused element (or next logical one) after Undo/Close | Carbon's `alertdialog` traps focus [13][14]; reserve that for decisions, not undo |
26
+ | Keyboard | Escape closes when focus is in the toast; Enter/Space only activate the focused button; a documented hotkey moves focus to the toast region (configurable, e.g. Alt+T as in sonner); Ctrl/Cmd+Z undoes the latest action when focus is not in an editable field | Gmail uses `z` [32]; Docs and macOS use Ctrl/Cmd+Z [34][8] |
27
+ | Announcement | Persistent `role="status"` (`aria-live="polite"`, `aria-atomic="true"`) region, present in the DOM before any message | `role="alert"` / assertive only for urgent errors, which should not be undo toasts anyway [37][46] |
28
+ | Stacking | One undo toast at a time; a new one replaces the old | Stacks (sonner 3, Fluent max 4) suit independent informational toasts [15][24] |
29
+ | Previous undo when replaced | Stays undoable through Ctrl/Cmd+Z / history (compensating model); a pending deferred commit is flushed | Batch same-kind actions inside the window: "3 items deleted. Undo" undoes all [8] |
30
+ | Motion | Short slide/fade; under `prefers-reduced-motion: reduce`, opacity only | WCAG 2.3.3 (AAA) [40] |
31
+ | Targets | Undo and Close at least 44×44 px on touch; never below 24×24 px | 2.5.8 AA is 24 px [39]; Apple 44 pt [11] |
32
+ | Swipe to dismiss | On for touch, threshold about 45 px, always paired with the Close button | 2.5.1 needs a single-pointer alternative [41] |
33
+
34
+ ## 1. Placement
35
+
36
+ **What the sources say.**
37
+
38
+ - Material 3: snackbars "should be placed at the bottom of a UI, in front of the main content", may be "nudged upwards to avoid overlapping with other UI elements near the bottom, such as FABs or docked toolbars", and must not sit in front of navigation; "Snackbars should appear above FABs", never in front of or behind one [1]. On medium and expanded breakpoints they "can be left-aligned or center-aligned if they are consistently placed on the same spot at the bottom of the screen", and must not be flush to an edge [1]. For keyboard users on the web, the snackbar must not "completely obscure" actionable or focused elements [1].
39
+ - Material 1 gave the numbers: on tablet/desktop "centered or left-aligned 24dp from the left and bottom edges"; on mobile it animates up from the bottom edge [4]. MDC Web exposes the left variant as `--leading`, tablet/desktop only [5]. Android's `setAnchorView` exists to put the snackbar above a FAB, `BottomAppBar` or `BottomNavigationView` [6].
40
+ - Apple HIG: iOS has no toast component. Undo is a system gesture (shake, three-finger swipe) that shows an alert titled "Undo <action>", plus Edit-menu items and Cmd+Z on Mac and iPad [8]. Apple prefers status integrated into the interface near what it describes over a floating message [10], and says not to raise alerts for "common, undoable actions, even when they're destructive" [9].
41
+ - IBM Carbon: toasts "slide in and out from the top right of the screen" and stack with the newest on top [12].
42
+ - Fluent 2: one consistent location, "where they are least likely to block the main content", typically a top or bottom corner; the React library defaults to `bottom-end` [15][16].
43
+ - Atlassian: "Flags appear at the bottom left of the screen and overlay any content", above modals [17].
44
+ - Shopify: the App Bridge toast "appears at the top of the interface in the web admin and at the bottom in the Shopify mobile app" [21].
45
+ - Gmail undo-send: the "Message sent" notice with Undo appears at the bottom left [31].
46
+ - GitHub Primer recommends against toasts, partly because they "may sit outside a user's view on large displays" and are disconnected from the trigger [22].
47
+ - Libraries: sonner defaults to `bottom-right`, 32 px offset, 16 px on mobile [24]; react-hot-toast defaults to `top-center` [28].
48
+
49
+ **Disagreement.** Bottom versus top is a real split: Material, Atlassian, Gmail and Fluent's library default are at the bottom; Carbon, Shopify web admin and react-hot-toast are at the top. Left versus right also splits (Atlassian and Gmail left, sonner and Fluent right).
50
+
51
+ **Recommendation.** Desktop: bottom, inline-start (bottom-left in LTR, mirrored in RTL), 24 px from the edges, as Material and Gmail do [1][4][31]. The inline-start corner keeps clear of the bottom-right FAB and chat widgets that Material explicitly protects [1]. Phone: bottom, full width minus 16 px gutters [24], with a configurable bottom clearance computed from the obstructions present (bottom nav, FAB, docked toolbar, persistent media player, safe-area inset) [1][6]. A top placement fits only an app whose notifications already live at the top (Carbon-style dashboards) [12][21]. The decision function should take the list of bottom obstructions as an input rather than hard-code an offset.
52
+
53
+ ## 2. Auto-dismiss timing and the WCAG questions
54
+
55
+ **What the design systems say.**
56
+
57
+ - Material 3: snackbars without actions "can auto-dismiss after 4–10 seconds, depending on platform"; "Avoid using auto-dismissing snackbars on web unless there's also inline feedback"; snackbars with actions "should remain on the screen until the user takes an action on the snackbar, or dismisses it" [1]. The accessibility page repeats "Snackbars with actions shouldn't auto-dismiss" [2]. This supersedes the older Material 2 guidance, which allowed "a minimum of four seconds, and a maximum of ten seconds" for all snackbars, actions included [3]. MDC Web's implementation still uses a 5000 ms default and accepts 4000–10000 ms or -1 (no timeout) [5]; Compose defaults to `SnackbarDuration.Short`, with `Indefinite` available [7].
58
+ - Carbon: toasts persist by default (React `timeout` defaults to 0) and can be set to dismiss after five seconds; actionable notifications "persist until a user dismisses them" [12][14].
59
+ - Polaris (from source; the guidance pages now redirect and could not be fetched): `DEFAULT_TOAST_DURATION = 5000`, `DEFAULT_TOAST_DURATION_WITH_ACTION = 10000`, and a console warning that a toast with an action "should persist for at least 10,000 milliseconds" [20].
60
+ - Fluent 2: a toast with no action "will time out after seven seconds"; hovering pauses it; "conditional dismissal" keeps a toast up until a condition is met [15]. The React library's default is 3000 ms with `pauseOnHover: false` [16], which disagrees with its own usage page.
61
+ - Atlassian: auto-dismiss flags close after 8 s (taken from a search summary of the auto-dismiss flag page and the Forge `showFlag` API; the page itself returned no text when fetched) [19]; "Never use auto dismiss flags for any critical warning or error messages" [17][18].
62
+ - Libraries: sonner 4000 ms for all toasts, paused while hovered, interacted with, or while the document is hidden [24][26]; react-hot-toast 2000 ms for success and 4000 ms otherwise, paused on hover [27][28]; react-admin's undoable mode shows the Undo notification and sends the mutation "after a 5 seconds delay" [29][30].
63
+ - Gmail undo-send offers a cancellation period of 5, 10, 20 or 30 seconds; the help page does not state the default [31].
64
+
65
+ **Reading-time rules.** None of the pages fetched for this report publishes a per-word formula (such as 500 ms/word); the numeric anchors in the primary sources are 4–10 s (Material) [2], 7 s (Fluent, no action) [15], 8 s (Atlassian) [19], and 10 s minimum with an action (Polaris) [20]. A per-word scaling is therefore a heuristic, not a standard; if the package offers one, treat it as a floor raiser on top of the 10 s minimum, never as a way to go shorter.
66
+
67
+ **WCAG 2.2.**
68
+
69
+ - **2.2.1 Timing Adjustable (Level A)** requires that, for each time limit set by the content, the user can turn it off, adjust it over at least ten times the default, or be warned and given at least 20 s to extend it, unless the limit is real-time, essential, or longer than 20 hours [35]. The Understanding document treats "any process that happens without user initiation after a set time" as a time limit, and its own notification example is the deciding test: a disappearing new-mail toast is fine because the inbox shows the same information, but "if the user has no other means of discovering the same information (or performing the same function), then each message would need to meet this success criterion" [35]. It adds that content on a timer need not be adjustable "if there is an alternative that does not rely on a timer" [35]. Applied to undo: **if the toast is the only way to undo, its timer is a time limit on that function and must be removable, adjustable 10×, or extendable**; if Ctrl/Cmd+Z, an undo history or a Trash also undoes the action, the toast may auto-dismiss. The 20-hour exception does not rescue a toast in practice. Primer, Roselli and O'Hara all read 2.2.1 this way [22][44][45].
70
+ - **Deferred commit is also a time limit.** When the action is committed at the end of the window (Gmail undo-send, react-admin undoable), the window bounds the undo function itself [29][31][35]. Gmail's user setting is an "adjust" mechanism, though 30 s is not ten times 5 s; whether Gmail conforms, or claims the essential exception, is not settled by the sources. The package should keep deferred commit for cases that really need it and pause the window while the toast is hovered or focused.
71
+ - **2.2.4 Interruptions (AAA)**: interruptions "can be postponed or suppressed by the user, except interruptions involving an emergency" [36]. A polite, non-focus-stealing toast is the low-interruption end; a global "quiet notifications" setting would satisfy it.
72
+ - **4.1.3 Status Messages (AA)**: a status message must be programmatically determinable "through role or properties" so assistive technology can present it without receiving focus [37]. Success/result messages use `role="status"` (technique ARIA22); `role="alert"` is for warnings and errors, and the listed failure is "Using role="alert" or aria-live="assertive" on content which is not important and time-sensitive" [37]. ARIA22's test checks that the `status` container exists "before the status message occurs" [38].
73
+ - **2.1.1 Keyboard and 2.4.3 Focus Order**: the Undo and Close controls must be keyboard operable and reachable in a logical order, and focus must be managed when the toast is removed [22][44][45].
74
+ - **Pause on hover and focus.** O'Hara: no auto-dismissal while focus or hover is inside the toast, while noting that screen-reader virtual cursors fire neither event [45]. sonner and react-hot-toast pause on hover; sonner also pauses while the page is hidden [26][28]. Fluent's guidance pauses on hover, its library default does not [15][16].
75
+
76
+ **Is the undo still available after the toast disappears?** Gmail: deleted mail stays in Trash "up to 30 days" and is recoverable [33]; `z` undoes the last action once keyboard shortcuts are enabled [32]. Google Docs: Ctrl/Cmd+Z and Ctrl/Cmd+Shift+Z [34]. Apple: Edit menu and Cmd+Z/Shift+Cmd+Z on Mac, shake and three-finger swipe on iPhone and iPad, with multiple levels and no "unnecessary limits" [8]. Material 3: snackbars "shouldn't be the only way to access a core use case" [1]. Figma was not checked for this report.
77
+
78
+ **Recommendation.** The decision function takes `undoElsewhere: boolean` (Ctrl/Cmd+Z, history panel, Trash) and `commit: 'compensating' | 'deferred'`. If Undo lives only in the toast, no timer: the toast stays until Undo, Close, Escape or replacement [1][2][35]. If it lives elsewhere too, 10 s [20], paused on hover, focus-within and `document.hidden` [26][45]. For deferred commits, a 10 s window by default, paused while hovered or focused, with the length exposed as a user setting, Gmail-style [31]. Flushing a pending commit on `pagehide` (or warning on unload) is an engineering choice; react-admin's docs do not say what it does when the tab closes during the window [29][30].
79
+
80
+ ## 3. The close control label
81
+
82
+ **What the sources say.** Material 1 allowed a single action "neither of which may be 'Dismiss' or 'Cancel'" [4]; Material 3 lists an optional close button in the anatomy, says "'Dismiss' or 'cancel' actions are optional", and cautions that a dismiss action is unnecessary for auto-dismissing snackbars [1]. Fluent 2 calls the control "Close" and allows it only when the content can be found again elsewhere [15]. Carbon's close button defaults to the accessible name "close notification" [14]; sonner's to "Close toast", with the close button off by default [26]; Polaris renders an icon-only close button with no accessible name in the source fetched, which is an accessibility bug rather than a precedent [20]. Apple reserves "Cancel" for "a button that cancels an alert's action" [9], which is exactly the reading that would make "Cancel" next to "Item deleted" mean undo.
83
+
84
+ **The confusion.** No source documents the "Dismiss" ambiguity directly. The reasoning is the Apple convention above: in a message about an action, "Cancel" and "Dismiss" read as verbs that apply to the action, so "Dismiss" beside "Item deleted" can be parsed as "dismiss the deletion". Material 1's ban on both words in snackbar actions points the same way [4]. "OK" or "Got it" implies acknowledgement is required, which a non-blocking toast does not need.
85
+
86
+ **Recommendation.** An icon-only "×" button with the accessible name "Close notification" (tooltip "Close"), positioned after Undo, visually quieter than Undo. The Undo button's visible text is "Undo", and its accessible name starts with that text and names the object ("Undo delete of Report.pdf"), which satisfies 2.5.3 Label in Name and its best practice of putting the visible label first [42]. Show the close button whenever the toast has no timer (it is then the only way to clear it besides Escape) [1][15].
87
+
88
+ ## 4. Keyboard and screen readers
89
+
90
+ **Focus.** Material 3: "announce the message but don't move focus", don't trap it, and "on web, a shortcut should exist for users to move focus to snackbars with actions (like Alt+G)", documented in help [2]. After the snackbar, focus returns to the element that triggered it or the next logical element [2]. The APG alert pattern: "it is crucial they do not affect keyboard focus" [43]. Fluent: toasts without actions get no keyboard focus [15]. Soueidan: moving focus to an interactive notification is acceptable only as "an immediate response to the user's action" [47]. Carbon disagrees for actionable toasts: role `alertdialog`, focus moved to the action and trapped [13][14]. Roselli and Soueidan say an interactive toast is really a non-modal dialog, and that the live region cannot convey the button's semantics [44][47].
91
+
92
+ **Keys.** Material 3: Tab moves between interactive elements, Esc dismisses when focus is in the snackbar [2]; MDC's `closeOnEscape` defaults to true [5]; Carbon's actionable notification also closes on Escape [14]; Polaris listens for Escape [20]. sonner's hotkey to focus the region is Alt+T [24][26]. No source recommends binding Enter globally to undo; Enter and Space should only activate the focused button, which native `<button>` elements do. Global Ctrl/Cmd+Z is the platform undo [8][34]; Gmail's single-key `z` requires shortcuts to be turned on [32].
93
+
94
+ **Live regions.** Polite, not assertive: Material 3 says "use a live region with a polite (queued) announcement" on Android and web [2]; WCAG lists assertive for non-urgent content as a failure [37]. Fluent and Polaris use assertive for most toasts [15][20], which contradicts this. The region must exist before content is injected: Soueidan says to place it "in the DOM as early as possible and then populate it" [46]; Roselli says live regions must be present at render and not hidden with `display: none` [44]; ARIA22 tests for it [38]. `role="status"` implies `aria-live="polite"` and atomic reading, though ARIA22 advises an explicit `aria-atomic="true"` [38][46]. Roselli recommends a labelled `region` landmark (not itself a live region) as the toast holder [44]; sonner labels its region "Notifications" and marks it polite [25][26].
95
+
96
+ **Recommendation.** Mount one visually empty `role="status"` region at app start and put only the message text in it. Render the toast (with Undo and Close) in a labelled region landmark beside it, not inside the live region. Do not move focus on appear. Escape closes when focus is inside; after Undo or Close, focus returns to the previously focused element, or the next logical element if that one was deleted [2][45]. Provide a configurable focus hotkey (default Alt+T, as sonner) and a global Ctrl/Cmd+Z that undoes the most recent action when focus is not in an editable field, so native text undo keeps working.
97
+
98
+ ## 5. Stacking and queueing
99
+
100
+ **What the sources say.** Material 3: "Only one snackbar may be displayed at a time"; consecutive snackbars appear one at a time, and "a snackbar with updated information can immediately replace an outdated snackbar"; don't stack them [1]. Material 1: the first contracts before the second appears [4]. Android: `LENGTH_INDEFINITE` lasts until dismissed "or another snackbar is shown" [6]. Stacking camp: Carbon (newest on top) [12], Atlassian (most recent on top; never mix dismissible and non-dismissible) [17], Fluent (at most four, 16 px apart) [15], sonner (three visible) [24].
101
+
102
+ **What happens to the previous undo.** No design system specifies it. Apple asks for multiple undo levels and for batch revert of "discrete but related actions" [8]. Under react-admin's deferred model, each mutation has its own 5 s timer [29].
103
+
104
+ **Recommendation.** One undo toast at a time; a new reversible action replaces it. The replaced action stays undoable through Ctrl/Cmd+Z and the undo history (compensating model) [8]; a pending deferred commit is flushed when replaced, since its only Undo control is gone. Same-kind actions within the window coalesce into one toast, "3 items deleted. Undo", whose Undo reverses all of them [8]. Independent informational toasts may stack separately, but not on top of the undo toast.
105
+
106
+ ## 6. When an undo toast is the wrong pattern
107
+
108
+ - **Irreversible, uncommon, or high-cost actions.** Apple: warn when an action "can cause data loss that's unexpected and irreversible", but not when data loss is the expected result [10]; alert for an "uncommon destructive action that they can't undo" [9]. NN/g: reserve confirmation for serious consequences, make it specific, label buttons by outcome, and for the most dangerous cases require an unusual act such as typing a word (MailChimp) [49]. → Confirm dialog, or type-to-confirm when cost is extreme.
109
+ - **Common, reversible actions.** Raskin: "Never use a warning when you mean undo", because people habituate to confirmations [51]; Apple: avoid alerts for "common, undoable actions, even when they're destructive" [9]; NN/g prefers undo to confirmation [49][50]. → Undo toast.
110
+ - **Deferred commit versus compensating undo.** Gmail delays the send (deferred, 5–30 s) [31] but makes delete soft, with 30 days in Trash [33]; react-admin defers every mutation by 5 s [29][30]. → Prefer compensating undo, which frees the toast from any timer; use deferred commit only for side effects that cannot be reversed afterwards (sending a message, charging, notifying others).
111
+ - **Long-running actions.** Fluent: "conditional dismissal" until a condition is met [15]; Primer: banners plus email or notification-centre follow-up [22]. → Persistent progress notification, not a timed toast.
112
+ - **Errors.** NN/g: a toast "would be a bad way to implement an error message"; one user waited minutes after missing a 5 s error [48]. Atlassian: never auto-dismiss errors or warnings [17][18]; Primer: banners or dialogs [22]. → Persistent error with Retry.
113
+ - **The result is off-screen.** Apple: "Show the results of an undo or redo", scrolling to the restored item if needed [8]. → After Undo, scroll to and highlight the restored item; if the original action's effect is off-screen, the toast text must name the object.
114
+ - **Very frequent, trivial actions.** Apple: people "only need to know when it doesn't" succeed [10]; Primer: simple successful actions need no confirmation, the visible result is the feedback [22]; Material 3: snackbars should not be overused relative to dialogs [1]. → No toast; keep undo in Ctrl/Cmd+Z and history.
115
+ - **Information the user must not miss.** Material 3 on the web: an auto-dismissing snackbar needs inline feedback near the trigger ("Saved" on the Save button) [1][2]. → Inline feedback plus, optionally, the toast. GOV.UK goes further: its design system has no toast at all, and reports the outcome of an action on a previous page with a notification banner (the success variant uses `role="alert"`) [52].
116
+
117
+ ## 7. Motion, touch targets, swipe
118
+
119
+ - **Motion.** WCAG 2.3.3 Animation from Interactions (AAA): "Motion animation triggered by interaction can be disabled, unless the animation is essential"; technique C39 is the `prefers-reduced-motion` media query [40]. Material 3: don't animate other components (such as the FAB) along with the snackbar [1]. sonner's source does not handle reduced motion [26]. → Slide plus fade normally, opacity-only under reduced motion.
120
+ - **Touch targets.** WCAG 2.5.8 (AA): at least 24×24 CSS px or sufficient spacing; the enhanced 2.5.5 uses 44×44 [39]; Apple: "a hit region of at least 44x44 pt" [11]; Roselli recommends large close targets for touch [44]. → 44×44 px hit areas for Undo and Close on coarse pointers, padding allowed to extend the visible size.
121
+ - **Swipe to dismiss.** Material snackbars "exit by being swiped off-screen" [4]; Android enables it inside `CoordinatorLayout` [6]; sonner uses a 45 px threshold or velocity above 0.11, in directions based on position [24][26]. WCAG 2.5.1 Pointer Gestures (A) lists swiping as path-based, so a single-pointer alternative is required [41]. → Swipe on for touch, the Close button always present when swipe is the only other dismissal.
122
+
123
+ ## 8. Terminology
124
+
125
+ Material calls the pattern a **snackbar** and reserves "toast" for Android system messages [1][4]. Carbon says **toast notification**, and **actionable notification** for one with a button [12]. Fluent 2, Polaris, Shopify App Bridge, sonner and react-hot-toast say **toast** [15][20][21][24][27]. Atlassian says **flag** [17]. NN/g defines a toast as "a small nonmodal popup that disappears after a few seconds", a kind of passive notification [48]. WCAG names the content a **status message** [37]; ARIA names the roles `status` and `alert` [37][43]. Apple has no component name; undo is a system feature [8]. → Use **"undo toast"** in package docs and API names, mention "snackbar" as a synonym for Material users, and use "status message" in accessibility docs.
126
+
127
+ ## Implications for the decision function
128
+
129
+ Inputs that the sources show to matter: reversibility (`none` / `compensating` / `deferred`), cost and frequency of the action, whether undo exists elsewhere (`undoElsewhere`), whether the affected object is visible, viewport class (compact / wide), the bottom obstructions present, text direction, pointer type, and `prefers-reduced-motion`. Outputs: the pattern (`none` / `undoToast` / `confirm` / `typeToConfirm` / `progress` / `persistentError`), placement and bottom clearance, duration (`null` for none), pause triggers, commit timing, close control on/off, and whether to coalesce with the current toast. Every row of the defaults table is one branch of that function.
130
+
131
+ ## Sources not fetched or partially fetched
132
+
133
+ - Polaris toast guidance: polaris.shopify.com and polaris-react.shopify.com redirect to shopify.dev and the old content path returns 404; findings come from the Polaris React source [20] and the App Bridge toast page [21].
134
+ - Material 3 snackbar pages render client-side and returned no text to a plain fetch; they were read in a browser [1][2]. The Material 2 guidelines were read from a third-party mirror [3].
135
+ - Fluent 2 toast accessibility page returned 404; the usage page and library source were used [15][16].
136
+ - Atlassian auto-dismiss flag page returned no text; the 8 s figure comes from a search summary of that page and of the Forge `showFlag` API [19].
137
+ - Apple HIG pages were read through their JSON data endpoints [8][9][10][11].
138
+ - Gmail's delete-undo toast duration and default undo-send period could not be verified; Figma was not checked.
139
+
140
+ ## REFERENCES
141
+
142
+ 1. [Material Design 3: Snackbar, guidelines](https://m3.material.io/components/snackbar/guidelines)
143
+ 2. [Material Design 3: Snackbar, accessibility](https://m3.material.io/components/snackbar/accessibility)
144
+ 3. [Material Design 2: Snackbars (third-party mirror of the original guidelines)](https://zyun.gitbook.io/temporary-views/official/material-design/original/snackbars)
145
+ 4. [Material Design 1: Snackbars & toasts](https://m1.material.io/components/snackbars-toasts.html)
146
+ 5. [Material Components for the Web: mdc-snackbar README](https://github.com/material-components/material-components-web/blob/master/packages/mdc-snackbar/README.md)
147
+ 6. [Material Components for Android: Snackbar](https://github.com/material-components/material-components-android/blob/master/docs/components/Snackbar.md)
148
+ 7. [Android Developers: Snackbar (Jetpack Compose)](https://developer.android.com/develop/ui/compose/components/snackbar)
149
+ 8. [Apple Human Interface Guidelines: Undo and redo](https://developer.apple.com/design/human-interface-guidelines/undo-and-redo)
150
+ 9. [Apple Human Interface Guidelines: Alerts](https://developer.apple.com/design/human-interface-guidelines/alerts)
151
+ 10. [Apple Human Interface Guidelines: Feedback](https://developer.apple.com/design/human-interface-guidelines/feedback)
152
+ 11. [Apple Human Interface Guidelines: Buttons](https://developer.apple.com/design/human-interface-guidelines/buttons)
153
+ 12. [Carbon Design System: Notification, usage](https://carbondesignsystem.com/components/notification/usage/)
154
+ 13. [Carbon Design System: Notification, accessibility](https://carbondesignsystem.com/components/notification/accessibility/)
155
+ 14. [Carbon React: Notification.tsx source](https://github.com/carbon-design-system/carbon/blob/main/packages/react/src/components/Notification/Notification.tsx)
156
+ 15. [Fluent 2: Toast, usage](https://fluent2.microsoft.design/components/web/react/core/toast/usage)
157
+ 16. [Fluent UI React v9: createToaster.ts source](https://github.com/microsoft/fluentui/blob/master/packages/react-components/react-toast/library/src/state/vanilla/createToaster.ts)
158
+ 17. [Atlassian Design System: Flag, usage](https://atlassian.design/components/flag/usage)
159
+ 18. [Atlassian Design System: Flag, examples](https://atlassian.design/components/flag/examples)
160
+ 19. [Atlassian Design System: Auto dismiss flag](https://atlassian.design/components/flag/auto-dismiss-flag) and [Atlassian Forge: showFlag](https://developer.atlassian.com/platform/forge/apis-reference/ui-api-bridge/showFlag/) (via search summary)
161
+ 20. [Shopify Polaris React: Toast.tsx source](https://github.com/Shopify/polaris/blob/main/polaris-react/src/components/Frame/components/Toast/Toast.tsx)
162
+ 21. [Shopify App Bridge: Toast API](https://shopify.dev/docs/api/app-bridge-library/apis/toast)
163
+ 22. [GitHub Primer: Accessibility, Toasts](https://primer.style/accessibility/toasts)
164
+ 23. [GitHub Primer: Notification messaging](https://primer.style/product/ui-patterns/notification-messaging/)
165
+ 24. [sonner: Toaster API](https://sonner.emilkowal.ski/toaster)
166
+ 25. [sonner: toast() API](https://sonner.emilkowal.ski/toast)
167
+ 26. [sonner: src/index.tsx source](https://github.com/emilkowalski/sonner/blob/main/src/index.tsx)
168
+ 27. [react-hot-toast: toast() API](https://react-hot-toast.com/docs/toast)
169
+ 28. [react-hot-toast: toaster.tsx source](https://github.com/timolins/react-hot-toast/blob/main/src/components/toaster.tsx)
170
+ 29. [react-admin: Features (undoable mutations)](https://marmelab.com/react-admin/Features.html)
171
+ 30. [react-admin: Edit, mutationMode](https://marmelab.com/react-admin/Edit.html)
172
+ 31. [Gmail Help: Unsend Gmail messages](https://support.google.com/mail/answer/2819488?hl=en)
173
+ 32. [Gmail Help: Keyboard shortcuts for Gmail](https://support.google.com/mail/answer/6594?hl=en)
174
+ 33. [Gmail Help: Delete or recover deleted Gmail messages](https://support.google.com/mail/answer/7401?hl=en)
175
+ 34. [Google Docs Editors Help: Keyboard shortcuts for Google Docs](https://support.google.com/docs/answer/179738?hl=en)
176
+ 35. [W3C: Understanding SC 2.2.1 Timing Adjustable](https://www.w3.org/WAI/WCAG22/Understanding/timing-adjustable.html)
177
+ 36. [W3C: Understanding SC 2.2.4 Interruptions](https://www.w3.org/WAI/WCAG22/Understanding/interruptions.html)
178
+ 37. [W3C: Understanding SC 4.1.3 Status Messages](https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html)
179
+ 38. [W3C: Technique ARIA22, Using role=status to present status messages](https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA22)
180
+ 39. [W3C: Understanding SC 2.5.8 Target Size (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html)
181
+ 40. [W3C: Understanding SC 2.3.3 Animation from Interactions](https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html)
182
+ 41. [W3C: Understanding SC 2.5.1 Pointer Gestures](https://www.w3.org/WAI/WCAG22/Understanding/pointer-gestures.html)
183
+ 42. [W3C: Understanding SC 2.5.3 Label in Name](https://www.w3.org/WAI/WCAG22/Understanding/label-in-name.html)
184
+ 43. [W3C ARIA Authoring Practices Guide: Alert pattern](https://www.w3.org/WAI/ARIA/apg/patterns/alert/)
185
+ 44. [Adrian Roselli: Defining 'Toast' Messages](https://adrianroselli.com/2020/01/defining-toast-messages.html)
186
+ 45. [Scott O'Hara: A toast to an accessible toast](https://www.scottohara.me/blog/2019/07/08/a-toast-to-a11y-toasts.html)
187
+ 46. [Sara Soueidan: Accessible notifications with ARIA Live Regions, part 1](https://www.sarasoueidan.com/blog/accessible-notifications-with-aria-live-regions-part-1/)
188
+ 47. [Sara Soueidan: Accessible notifications with ARIA Live Regions, part 2](https://www.sarasoueidan.com/blog/accessible-notifications-with-aria-live-regions-part-2/)
189
+ 48. [Nielsen Norman Group: Indicators, Validations, and Notifications](https://www.nngroup.com/articles/indicators-validations-notifications/)
190
+ 49. [Nielsen Norman Group: Confirmation Dialogs Can Prevent User Errors (If Not Overused)](https://www.nngroup.com/articles/confirmation-dialog/)
191
+ 50. [Nielsen Norman Group: Preventing User Errors: Avoiding Conscious Mistakes](https://www.nngroup.com/articles/user-mistakes/)
192
+ 51. [Aza Raskin, A List Apart: Never Use a Warning When you Mean Undo](https://alistapart.com/article/neveruseawarning/)
193
+ 52. [GOV.UK Design System: Notification banner](https://design-system.service.gov.uk/components/notification-banner/)