@particle-academy/react-fancy 5.40.0 → 5.41.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.
package/CHANGELOG.md CHANGED
@@ -11,6 +11,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [5.41.1] - 2026-10-17
15
+
16
+ ### Fixed
17
+
18
+ - **`Toast.Item` is now exported.** The docs describe it for rendering your own
19
+ viewport, and its props type `ToastItemProps` was exported, but the part was
20
+ not: following the docs gave `undefined` and a render crash. **Nothing to do**
21
+ unless you had worked around it, in which case `Toast.Item` now just works.
22
+
23
+ ## [5.41.0] - 2026-10-17
24
+
25
+ ### Added
26
+
27
+ - **`Toast.Stack` — a controlled stack of actionable toasts** (react-fancy#33),
28
+ for requests a person walks through rather than races: an agent asking to add a
29
+ database, a site, a process.
30
+
31
+ ```tsx
32
+ <Toast.Stack
33
+ items={approvals}
34
+ renderItem={(r) => <Approval request={r} onAllow={…} onDeny={…} onLater={…} />}
35
+ depth={2} offset={8} scaleStep={0.05}
36
+ frontIndex={front} onFrontIndexChange={setFront}
37
+ />
38
+ ```
39
+
40
+ - **A view of YOUR list, so it never drops anything.** No timer, no limit; an
41
+ item leaves only when you remove it. (The imperative provider's `maxToasts`
42
+ silently drops the oldest — the reason this is a separate component.)
43
+ - `depth` cards peek out behind the front one, each `offset` px higher and
44
+ `scaleStep` smaller; they are `inert` and `aria-hidden`, so only the front
45
+ card is interactive. Anything beyond `depth` shows as `+N`.
46
+ - **The wheel walks the stack**, one card per notch, adding up small trackpad
47
+ deltas, wrapping at both ends — and keeps the page from scrolling underneath.
48
+ - **Arrow keys** move the front when the stack has focus (it is focusable, with a
49
+ visible ring); a text field inside a card keeps its own arrows.
50
+ - `renderItem` renders anything, so a card can carry as many actions as it
51
+ needs. When the front item is removed, the next comes forward; an index left
52
+ out of range by a shrinking list is clamped.
53
+ - `position`: a screen corner (default `bottom-right`) or `"inline"`.
54
+ `cardClassName` restyles the card shell. A polite live region says
55
+ "2 of 5" as the front changes.
56
+
57
+ Handles: `data-react-fancy-toast-stack`, `-stack-card` (`front` / `behind`),
58
+ `-stack-more`, `-stack-status`, `-stack-position`.
59
+
60
+ **What you must DO: nothing.** `Toast.Provider` and `useToast` are unchanged.
61
+
14
62
  ## [5.40.0] - 2026-10-17
15
63
 
16
64
  ### Added
@@ -0,0 +1,297 @@
1
+ import { Badge } from './chunk-6FCQD2KQ.js';
2
+ import { Portal } from './chunk-WHEXTDPV.js';
3
+ import { useControllableState } from './chunk-EDYAXGUM.js';
4
+ import { cn } from './chunk-MMW2JGKZ.js';
5
+ import { createContext, useContext, useEffect, useRef, useState, useCallback, useMemo } from 'react';
6
+ import { Check, XCircle, AlertTriangle, Info, X } from 'lucide-react';
7
+ import { jsx, jsxs } from 'react/jsx-runtime';
8
+
9
+ var ToastContext = createContext(null);
10
+ function useToast() {
11
+ const ctx = useContext(ToastContext);
12
+ if (!ctx) {
13
+ throw new Error("useToast must be used within a <Toast.Provider>");
14
+ }
15
+ return ctx;
16
+ }
17
+ var VARIANT_STYLES = {
18
+ default: "border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900",
19
+ success: "border-emerald-200 bg-emerald-50 dark:border-emerald-800 dark:bg-emerald-950",
20
+ error: "border-red-200 bg-red-50 dark:border-red-800 dark:bg-red-950",
21
+ warning: "border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950",
22
+ info: "border-blue-200 bg-blue-50 dark:border-blue-800 dark:bg-blue-950"
23
+ };
24
+ var VARIANT_ICON_COLORS = {
25
+ default: "text-zinc-400",
26
+ success: "text-emerald-500",
27
+ error: "text-red-500",
28
+ warning: "text-amber-500",
29
+ info: "text-blue-500"
30
+ };
31
+ function ToastItem({ data, onDismiss }) {
32
+ const { id, title, description, variant = "default", action } = data;
33
+ const duration = data.duration ?? (action ? 0 : 5e3);
34
+ useEffect(() => {
35
+ if (duration <= 0) return;
36
+ const timer = setTimeout(() => onDismiss(id), duration);
37
+ return () => clearTimeout(timer);
38
+ }, [id, duration, onDismiss]);
39
+ return /* @__PURE__ */ jsx(
40
+ "div",
41
+ {
42
+ "data-react-fancy-toast-item": "",
43
+ role: "alert",
44
+ onKeyDown: (e) => {
45
+ if (e.key === "Escape") onDismiss(id);
46
+ },
47
+ className: cn(
48
+ "fancy-toast-in pointer-events-auto w-80 rounded-xl border p-4 shadow-lg",
49
+ VARIANT_STYLES[variant]
50
+ ),
51
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
52
+ /* @__PURE__ */ jsxs("div", { className: cn("mt-0.5 shrink-0", VARIANT_ICON_COLORS[variant]), children: [
53
+ variant === "success" && /* @__PURE__ */ jsx(Check, { size: 16 }),
54
+ variant === "error" && /* @__PURE__ */ jsx(XCircle, { size: 16 }),
55
+ variant === "warning" && /* @__PURE__ */ jsx(AlertTriangle, { size: 16 }),
56
+ variant === "info" && /* @__PURE__ */ jsx(Info, { size: 16 })
57
+ ] }),
58
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
59
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-zinc-900 dark:text-zinc-100", children: title }),
60
+ description && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-zinc-500 dark:text-zinc-400", children: description })
61
+ ] }),
62
+ action && /* @__PURE__ */ jsx(
63
+ "button",
64
+ {
65
+ type: "button",
66
+ onClick: () => {
67
+ action.onClick();
68
+ onDismiss(id);
69
+ },
70
+ className: "shrink-0 self-center rounded-md px-2 py-1 text-xs font-medium text-zinc-700 underline-offset-2 transition-colors hover:bg-zinc-100 hover:underline dark:text-zinc-200 dark:hover:bg-zinc-800",
71
+ children: action.label
72
+ }
73
+ ),
74
+ /* @__PURE__ */ jsx(
75
+ "button",
76
+ {
77
+ type: "button",
78
+ onClick: () => onDismiss(id),
79
+ className: "shrink-0 rounded p-0.5 text-zinc-400 transition-colors hover:text-zinc-600 dark:hover:text-zinc-300",
80
+ "aria-label": "Dismiss",
81
+ children: /* @__PURE__ */ jsx(X, { size: 14 })
82
+ }
83
+ )
84
+ ] })
85
+ }
86
+ );
87
+ }
88
+ ToastItem.displayName = "ToastItem";
89
+ var POSITION_STYLES = {
90
+ "top-right": "top-4 right-4",
91
+ "top-left": "top-4 left-4",
92
+ "bottom-right": "bottom-4 right-4",
93
+ "bottom-left": "bottom-4 left-4"
94
+ };
95
+ var WHEEL_STEP = 50;
96
+ var CARD = "rounded-xl border border-zinc-200 bg-white p-4 shadow-lg dark:border-zinc-700 dark:bg-zinc-900";
97
+ function defaultKey(item, index) {
98
+ const id = item?.id;
99
+ return typeof id === "string" || typeof id === "number" ? String(id) : String(index);
100
+ }
101
+ function isTextField(target) {
102
+ if (!(target instanceof HTMLElement)) return false;
103
+ return target.isContentEditable || target.getAttribute("contenteditable") === "true" || /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName);
104
+ }
105
+ function ToastStack({
106
+ items,
107
+ renderItem,
108
+ getKey = defaultKey,
109
+ depth = 2,
110
+ offset = 8,
111
+ scaleStep = 0.05,
112
+ frontIndex: controlledFront,
113
+ defaultFrontIndex = 0,
114
+ onFrontIndexChange,
115
+ position = "bottom-right",
116
+ label = "Notifications",
117
+ cardClassName,
118
+ className
119
+ }) {
120
+ const [rawFront, setFront] = useControllableState(
121
+ controlledFront,
122
+ defaultFrontIndex,
123
+ onFrontIndexChange
124
+ );
125
+ const count = items.length;
126
+ const front = count === 0 ? 0 : (rawFront % count + count) % count;
127
+ const stackRef = useRef(null);
128
+ const wheelTravel = useRef(0);
129
+ const live = useRef({ front, count });
130
+ live.current = { front, count };
131
+ const step = (by) => {
132
+ const { front: current, count: n } = live.current;
133
+ if (n < 2) return;
134
+ setFront(((current + by) % n + n) % n);
135
+ };
136
+ const stepRef = useRef(step);
137
+ stepRef.current = step;
138
+ useEffect(() => {
139
+ const el = stackRef.current;
140
+ if (!el) return;
141
+ const onWheel = (e) => {
142
+ if (live.current.count < 2 || e.deltaY === 0) return;
143
+ e.preventDefault();
144
+ if (e.deltaMode !== 0) {
145
+ wheelTravel.current = 0;
146
+ stepRef.current(Math.sign(e.deltaY));
147
+ return;
148
+ }
149
+ if (Math.abs(e.deltaY) >= WHEEL_STEP) {
150
+ wheelTravel.current = 0;
151
+ stepRef.current(Math.sign(e.deltaY));
152
+ return;
153
+ }
154
+ wheelTravel.current += e.deltaY;
155
+ if (Math.abs(wheelTravel.current) >= WHEEL_STEP) {
156
+ stepRef.current(Math.sign(wheelTravel.current));
157
+ wheelTravel.current = 0;
158
+ }
159
+ };
160
+ el.addEventListener("wheel", onWheel, { passive: false });
161
+ return () => el.removeEventListener("wheel", onWheel);
162
+ }, [count > 0, position]);
163
+ if (count === 0) return null;
164
+ const visibleBehind = Math.min(Math.max(0, depth), count - 1);
165
+ const hidden = count - 1 - visibleBehind;
166
+ const card = (index, k) => {
167
+ const item = items[index];
168
+ const isFront = k === 0;
169
+ return /* @__PURE__ */ jsx(
170
+ "div",
171
+ {
172
+ "data-react-fancy-toast-stack-card": isFront ? "front" : "behind",
173
+ "aria-hidden": isFront ? void 0 : true,
174
+ inert: isFront ? void 0 : true,
175
+ className: cn(
176
+ CARD,
177
+ "origin-top transition-transform duration-200",
178
+ isFront ? "relative" : "pointer-events-none absolute inset-0 overflow-hidden",
179
+ cardClassName
180
+ ),
181
+ style: {
182
+ zIndex: depth + 1 - k,
183
+ transform: isFront ? void 0 : `translateY(-${k * offset}px) scale(${1 - k * scaleStep})`
184
+ },
185
+ children: renderItem(item, { index, isFront })
186
+ },
187
+ getKey(item, index)
188
+ );
189
+ };
190
+ const stackEl = /* @__PURE__ */ jsxs(
191
+ "div",
192
+ {
193
+ ref: stackRef,
194
+ "data-react-fancy-toast-stack": "",
195
+ role: "region",
196
+ "aria-label": label,
197
+ tabIndex: 0,
198
+ onKeyDown: (e) => {
199
+ if (isTextField(e.target)) return;
200
+ if (e.key === "ArrowDown" || e.key === "ArrowRight") {
201
+ e.preventDefault();
202
+ step(1);
203
+ } else if (e.key === "ArrowUp" || e.key === "ArrowLeft") {
204
+ e.preventDefault();
205
+ step(-1);
206
+ }
207
+ },
208
+ className: cn(
209
+ "pointer-events-auto relative w-80 rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-violet-500 focus-visible:ring-offset-2",
210
+ className
211
+ ),
212
+ style: { paddingTop: visibleBehind * offset },
213
+ children: [
214
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
215
+ Array.from({ length: visibleBehind }, (_, i) => i + 1).map(
216
+ (k) => card((front + k) % count, k)
217
+ ),
218
+ card(front, 0)
219
+ ] }),
220
+ hidden > 0 && /* @__PURE__ */ jsxs(
221
+ Badge,
222
+ {
223
+ "data-react-fancy-toast-stack-more": "",
224
+ size: "sm",
225
+ variant: "soft",
226
+ color: "zinc",
227
+ className: "absolute -top-2 right-2 z-20",
228
+ children: [
229
+ "+",
230
+ hidden
231
+ ]
232
+ }
233
+ ),
234
+ /* @__PURE__ */ jsx("span", { "data-react-fancy-toast-stack-status": "", "aria-live": "polite", className: "sr-only", children: count > 1 ? `${front + 1} of ${count}` : "" })
235
+ ]
236
+ }
237
+ );
238
+ if (position === "inline") return stackEl;
239
+ return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(
240
+ "div",
241
+ {
242
+ "data-react-fancy-toast-stack-position": position,
243
+ className: cn("pointer-events-none fixed z-[100]", POSITION_STYLES[position]),
244
+ children: stackEl
245
+ }
246
+ ) });
247
+ }
248
+ ToastStack.displayName = "ToastStack";
249
+ var POSITION_STYLES2 = {
250
+ "top-right": "top-4 right-4",
251
+ "top-left": "top-4 left-4",
252
+ "bottom-right": "bottom-4 right-4",
253
+ "bottom-left": "bottom-4 left-4"
254
+ };
255
+ function ToastProvider({
256
+ children,
257
+ position = "bottom-right",
258
+ maxToasts = 5
259
+ }) {
260
+ const [toasts, setToasts] = useState([]);
261
+ const idCounter = useRef(0);
262
+ const toast = useCallback(
263
+ (data) => {
264
+ const id = `toast-${++idCounter.current}`;
265
+ setToasts((prev) => [...prev.slice(-(maxToasts - 1)), { ...data, id }]);
266
+ return id;
267
+ },
268
+ [maxToasts]
269
+ );
270
+ const dismiss = useCallback((id) => {
271
+ setToasts((prev) => prev.filter((t) => t.id !== id));
272
+ }, []);
273
+ const ctx = useMemo(() => ({ toasts, toast, dismiss }), [toasts, toast, dismiss]);
274
+ return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: ctx, children: [
275
+ children,
276
+ /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(
277
+ "div",
278
+ {
279
+ "data-react-fancy-toast": "",
280
+ className: cn(
281
+ "fixed z-[100] flex flex-col gap-2 pointer-events-none",
282
+ POSITION_STYLES2[position]
283
+ ),
284
+ children: toasts.map((t) => /* @__PURE__ */ jsx(ToastItem, { data: t, onDismiss: dismiss }, t.id))
285
+ }
286
+ ) })
287
+ ] });
288
+ }
289
+ var Toast = {
290
+ Provider: ToastProvider,
291
+ Stack: ToastStack,
292
+ Item: ToastItem
293
+ };
294
+
295
+ export { Toast, useToast };
296
+ //# sourceMappingURL=chunk-3AQLEMH7.js.map
297
+ //# sourceMappingURL=chunk-3AQLEMH7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Toast/Toast.context.ts","../src/components/Toast/ToastItem.tsx","../src/components/Toast/ToastStack.tsx","../src/components/Toast/Toast.tsx"],"names":["useEffect","jsx","jsxs","POSITION_STYLES","useRef"],"mappings":";;;;;;;;AAGO,IAAM,YAAA,GAAe,cAAwC,IAAI,CAAA;AAEjE,SAAS,QAAA,GAA8B;AAC5C,EAAA,MAAM,GAAA,GAAM,WAAW,YAAY,CAAA;AACnC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,MAAM,iDAAiD,CAAA;AAAA,EACnE;AACA,EAAA,OAAO,GAAA;AACT;ACNA,IAAM,cAAA,GAAiB;AAAA,EACrB,OAAA,EACE,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;AAEA,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,CAAC,EAAA,KAAe;AAC1C,IAAA,SAAA,CAAU,CAAC,SAAS,IAAA,CAAK,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,EAAA,KAAO,EAAE,CAAC,CAAA;AAAA,EACrD,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,OAAA,EAAQ,CAAA,EAAI,CAAC,MAAA,EAAQ,KAAA,EAAO,OAAO,CAAC,CAAA;AAEhF,EAAA,uBACEF,IAAAA,CAAC,YAAA,CAAa,QAAA,EAAb,EAAsB,OAAO,GAAA,EAC3B,QAAA,EAAA;AAAA,IAAA,QAAA;AAAA,oBACDD,GAAAA,CAAC,MAAA,EAAA,EACC,QAAA,kBAAAA,GAAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,wBAAA,EAAuB,EAAA;AAAA,QACvB,SAAA,EAAW,EAAA;AAAA,UACT,uDAAA;AAAA,UACAE,iBAAgB,QAAQ;AAAA,SAC1B;AAAA,QAEC,QAAA,EAAA,MAAA,CAAO,GAAA,CAAI,CAAC,CAAA,qBACXF,GAAAA,CAAC,SAAA,EAAA,EAAqB,IAAA,EAAM,CAAA,EAAG,SAAA,EAAW,OAAA,EAAA,EAA1B,CAAA,CAAE,EAAiC,CACpD;AAAA;AAAA,KACH,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;AAEO,IAAM,KAAA,GAAQ;AAAA,EACnB,QAAA,EAAU,aAAA;AAAA,EACV,KAAA,EAAO,UAAA;AAAA,EACP,IAAA,EAAM;AACR","file":"chunk-3AQLEMH7.js","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { ToastContextValue } from \"./Toast.types\";\n\nexport const ToastContext = createContext<ToastContextValue | null>(null);\n\nexport function useToast(): ToastContextValue {\n const ctx = useContext(ToastContext);\n if (!ctx) {\n throw new Error(\"useToast must be used within a <Toast.Provider>\");\n }\n return ctx;\n}\n","import { useEffect } from \"react\";\nimport { AlertTriangle, Check, Info, X, XCircle } from \"lucide-react\";\nimport { cn } from \"../../utils/cn\";\nimport type { ToastItemProps } from \"./Toast.types\";\n\nconst VARIANT_STYLES = {\n default:\n \"border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900\",\n success:\n \"border-emerald-200 bg-emerald-50 dark:border-emerald-800 dark:bg-emerald-950\",\n error:\n \"border-red-200 bg-red-50 dark:border-red-800 dark:bg-red-950\",\n warning:\n \"border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950\",\n info: \"border-blue-200 bg-blue-50 dark:border-blue-800 dark:bg-blue-950\",\n} as const;\n\nconst VARIANT_ICON_COLORS = {\n default: \"text-zinc-400\",\n success: \"text-emerald-500\",\n error: \"text-red-500\",\n warning: \"text-amber-500\",\n info: \"text-blue-500\",\n} as const;\n\nexport function ToastItem({ data, onDismiss }: ToastItemProps) {\n const { id, title, description, variant = \"default\", action } = data;\n // An action toast does not expire by default.\n const duration = data.duration ?? (action ? 0 : 5000);\n\n useEffect(() => {\n if (duration <= 0) return;\n const timer = setTimeout(() => onDismiss(id), duration);\n return () => clearTimeout(timer);\n }, [id, duration, onDismiss]);\n\n return (\n <div\n data-react-fancy-toast-item=\"\"\n role=\"alert\"\n // Scoped to the toast rather than the document: a global Escape handler\n // would fight whatever modal or drawer is already listening.\n onKeyDown={(e) => {\n if (e.key === \"Escape\") onDismiss(id);\n }}\n className={cn(\n \"fancy-toast-in pointer-events-auto w-80 rounded-xl border p-4 shadow-lg\",\n VARIANT_STYLES[variant],\n )}\n >\n <div className=\"flex items-start gap-3\">\n <div className={cn(\"mt-0.5 shrink-0\", VARIANT_ICON_COLORS[variant])}>\n {variant === \"success\" && <Check size={16} />}\n {variant === \"error\" && <XCircle size={16} />}\n {variant === \"warning\" && <AlertTriangle size={16} />}\n {variant === \"info\" && <Info size={16} />}\n </div>\n <div className=\"flex-1 min-w-0\">\n <p className=\"text-sm font-medium text-zinc-900 dark:text-zinc-100\">{title}</p>\n {description && (\n <p className=\"mt-1 text-xs text-zinc-500 dark:text-zinc-400\">\n {description}\n </p>\n )}\n </div>\n {action && (\n <button\n type=\"button\"\n onClick={() => {\n action.onClick();\n // The offer is consumed; leaving it up invites undoing an\n // already-undone action.\n onDismiss(id);\n }}\n className=\"shrink-0 self-center rounded-md px-2 py-1 text-xs font-medium text-zinc-700 underline-offset-2 transition-colors hover:bg-zinc-100 hover:underline dark:text-zinc-200 dark:hover:bg-zinc-800\"\n >\n {action.label}\n </button>\n )}\n <button\n type=\"button\"\n onClick={() => onDismiss(id)}\n className=\"shrink-0 rounded p-0.5 text-zinc-400 transition-colors hover:text-zinc-600 dark:hover:text-zinc-300\"\n aria-label=\"Dismiss\"\n >\n <X size={14} />\n </button>\n </div>\n </div>\n );\n}\n\nToastItem.displayName = \"ToastItem\";\n","import { useEffect, useRef, type ReactNode } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\nimport { Portal } from \"../Portal\";\nimport { Badge } from \"../Badge\";\nimport type { ToastPosition } from \"./Toast.types\";\n\nexport interface ToastStackProps<T> {\n /**\n * Everything to show — the stack is a VIEW of this list and owns none of it.\n * There is no limit and no timer: an item leaves only when you remove it.\n */\n items: readonly T[];\n /** One card's content, actions included. Only the front card is interactive. */\n renderItem: (item: T, state: { index: number; isFront: boolean }) => ReactNode;\n /** A stable key per item. Defaults to `item.id`, then the index. */\n getKey?: (item: T, index: number) => string;\n /** How many cards show behind the front one. Default 2. */\n depth?: number;\n /** How far each card behind peeks out above the one in front, in px. Default 8. */\n offset?: number;\n /** How much smaller each card behind is than the one in front. Default 0.05. */\n scaleStep?: number;\n /** Which item is in front, if you want to own it. Wraps; out-of-range values are clamped. */\n frontIndex?: number;\n defaultFrontIndex?: number;\n onFrontIndexChange?: (index: number) => void;\n /** A screen corner, or `\"inline\"` to render where it is placed. Default `\"bottom-right\"`. */\n position?: ToastPosition | \"inline\";\n /** The stack's accessible name. Default \"Notifications\". */\n label?: string;\n /** Classes for each card's shell, merged onto the defaults. */\n cardClassName?: string;\n className?: string;\n}\n\nconst POSITION_STYLES: Record<ToastPosition, string> = {\n \"top-right\": \"top-4 right-4\",\n \"top-left\": \"top-4 left-4\",\n \"bottom-right\": \"bottom-4 right-4\",\n \"bottom-left\": \"bottom-4 left-4\",\n};\n\n/** Pixels of wheel travel that count as one step. A mouse notch is ~100; a trackpad sends many small ones. */\nconst WHEEL_STEP = 50;\n\nconst CARD =\n \"rounded-xl border border-zinc-200 bg-white p-4 shadow-lg dark:border-zinc-700 dark:bg-zinc-900\";\n\nfunction defaultKey(item: unknown, index: number): string {\n const id = (item as { id?: unknown } | null)?.id;\n return typeof id === \"string\" || typeof id === \"number\" ? String(id) : String(index);\n}\n\nfunction isTextField(target: EventTarget | null): boolean {\n if (!(target instanceof HTMLElement)) return false;\n return (\n target.isContentEditable ||\n target.getAttribute(\"contenteditable\") === \"true\" ||\n /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName)\n );\n}\n\n/**\n * A controlled stack of actionable toasts — approval requests, say — that the\n * person walks through rather than races.\n *\n * Built for react-fancy#33. The owner's requirements were that requests stack\n * behind each other with a slight top offset, that scrolling over the stack\n * walks through them, and that a pending request NEVER expires or disappears.\n * The last is why this is a view of the caller's list rather than a queue it\n * keeps: there is nothing here that can drop an item, because nothing here owns\n * one. (The imperative provider's `maxToasts` silently drops the oldest.)\n */\nexport function ToastStack<T>({\n items,\n renderItem,\n getKey = defaultKey,\n depth = 2,\n offset = 8,\n scaleStep = 0.05,\n frontIndex: controlledFront,\n defaultFrontIndex = 0,\n onFrontIndexChange,\n position = \"bottom-right\",\n label = \"Notifications\",\n cardClassName,\n className,\n}: ToastStackProps<T>) {\n const [rawFront, setFront] = useControllableState(\n controlledFront,\n defaultFrontIndex,\n onFrontIndexChange,\n );\n const count = items.length;\n // Clamped for display rather than corrected through onChange: a list that\n // shrinks under a far-forward index must not make render report a change.\n const front = count === 0 ? 0 : ((rawFront % count) + count) % count;\n\n const stackRef = useRef<HTMLDivElement>(null);\n const wheelTravel = useRef(0);\n const live = useRef({ front, count });\n live.current = { front, count };\n\n const step = (by: number) => {\n const { front: current, count: n } = live.current;\n if (n < 2) return;\n setFront((((current + by) % n) + n) % n);\n };\n const stepRef = useRef(step);\n stepRef.current = step;\n\n /*\n * A native listener, because React's wheel listener is passive and cannot stop\n * the page scrolling underneath — and a stack that cycles AND scrolls the page\n * moves two things at once under the person's hand.\n */\n useEffect(() => {\n const el = stackRef.current;\n if (!el) return;\n\n const onWheel = (e: WheelEvent) => {\n if (live.current.count < 2 || e.deltaY === 0) return;\n e.preventDefault();\n\n // Line or page mode: every event is a notch.\n if (e.deltaMode !== 0) {\n wheelTravel.current = 0;\n stepRef.current(Math.sign(e.deltaY));\n return;\n }\n // A notch-sized event steps at once; small trackpad deltas add up first.\n if (Math.abs(e.deltaY) >= WHEEL_STEP) {\n wheelTravel.current = 0;\n stepRef.current(Math.sign(e.deltaY));\n return;\n }\n wheelTravel.current += e.deltaY;\n if (Math.abs(wheelTravel.current) >= WHEEL_STEP) {\n stepRef.current(Math.sign(wheelTravel.current));\n wheelTravel.current = 0;\n }\n };\n\n el.addEventListener(\"wheel\", onWheel, { passive: false });\n return () => el.removeEventListener(\"wheel\", onWheel);\n // Re-bound when the element can change: it appears with the first item, and\n // moving between a corner and inline remounts it.\n }, [count > 0, position]);\n\n if (count === 0) return null;\n\n const visibleBehind = Math.min(Math.max(0, depth), count - 1);\n const hidden = count - 1 - visibleBehind;\n\n const card = (index: number, k: number) => {\n const item = items[index];\n const isFront = k === 0;\n return (\n <div\n key={getKey(item, index)}\n data-react-fancy-toast-stack-card={isFront ? \"front\" : \"behind\"}\n aria-hidden={isFront ? undefined : true}\n inert={isFront ? undefined : true}\n className={cn(\n CARD,\n \"origin-top transition-transform duration-200\",\n isFront ? \"relative\" : \"pointer-events-none absolute inset-0 overflow-hidden\",\n cardClassName,\n )}\n style={{\n zIndex: depth + 1 - k,\n transform: isFront ? undefined : `translateY(-${k * offset}px) scale(${1 - k * scaleStep})`,\n }}\n >\n {renderItem(item, { index, isFront })}\n </div>\n );\n };\n\n const stackEl = (\n <div\n ref={stackRef}\n data-react-fancy-toast-stack=\"\"\n role=\"region\"\n aria-label={label}\n tabIndex={0}\n onKeyDown={(e) => {\n if (isTextField(e.target)) return;\n if (e.key === \"ArrowDown\" || e.key === \"ArrowRight\") {\n e.preventDefault();\n step(1);\n } else if (e.key === \"ArrowUp\" || e.key === \"ArrowLeft\") {\n e.preventDefault();\n step(-1);\n }\n }}\n className={cn(\n \"pointer-events-auto relative w-80 rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-violet-500 focus-visible:ring-offset-2\",\n className,\n )}\n style={{ paddingTop: visibleBehind * offset }}\n >\n <div className=\"relative\">\n {/* z-index decides what paints on top; the front card sizes the box. */}\n {Array.from({ length: visibleBehind }, (_, i) => i + 1).map((k) =>\n card((front + k) % count, k),\n )}\n {card(front, 0)}\n </div>\n {hidden > 0 && (\n <Badge\n data-react-fancy-toast-stack-more=\"\"\n size=\"sm\"\n variant=\"soft\"\n color=\"zinc\"\n className=\"absolute -top-2 right-2 z-20\"\n >\n +{hidden}\n </Badge>\n )}\n <span data-react-fancy-toast-stack-status=\"\" aria-live=\"polite\" className=\"sr-only\">\n {count > 1 ? `${front + 1} of ${count}` : \"\"}\n </span>\n </div>\n );\n\n if (position === \"inline\") return stackEl;\n\n return (\n <Portal>\n <div\n data-react-fancy-toast-stack-position={position}\n className={cn(\"pointer-events-none fixed z-[100]\", POSITION_STYLES[position])}\n >\n {stackEl}\n </div>\n </Portal>\n );\n}\n\nToastStack.displayName = \"ToastStack\";\n","import { useCallback, useMemo, useRef, useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Portal } from \"../Portal\";\nimport { ToastContext } from \"./Toast.context\";\nimport { ToastItem } from \"./ToastItem\";\nimport { ToastStack } from \"./ToastStack\";\nimport type { ToastData, ToastProviderProps } from \"./Toast.types\";\n\nconst POSITION_STYLES = {\n \"top-right\": \"top-4 right-4\",\n \"top-left\": \"top-4 left-4\",\n \"bottom-right\": \"bottom-4 right-4\",\n \"bottom-left\": \"bottom-4 left-4\",\n} as const;\n\nfunction ToastProvider({\n children,\n position = \"bottom-right\",\n maxToasts = 5,\n}: ToastProviderProps) {\n const [toasts, setToasts] = useState<ToastData[]>([]);\n const idCounter = useRef(0);\n\n const toast = useCallback(\n (data: Omit<ToastData, \"id\">) => {\n const id = `toast-${++idCounter.current}`;\n setToasts((prev) => [...prev.slice(-(maxToasts - 1)), { ...data, id }]);\n return id;\n },\n [maxToasts],\n );\n\n const dismiss = useCallback((id: string) => {\n setToasts((prev) => prev.filter((t) => t.id !== id));\n }, []);\n\n const ctx = useMemo(() => ({ toasts, toast, dismiss }), [toasts, toast, dismiss]);\n\n return (\n <ToastContext.Provider value={ctx}>\n {children}\n <Portal>\n <div\n data-react-fancy-toast=\"\"\n className={cn(\n \"fixed z-[100] flex flex-col gap-2 pointer-events-none\",\n POSITION_STYLES[position],\n )}\n >\n {toasts.map((t) => (\n <ToastItem key={t.id} data={t} onDismiss={dismiss} />\n ))}\n </div>\n </Portal>\n </ToastContext.Provider>\n );\n}\n\nexport const Toast = {\n Provider: ToastProvider,\n Stack: ToastStack,\n Item: ToastItem,\n};\n"]}