@orbitcommerce/constellation-docs 0.0.0-stage → 1.0.0

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.
Files changed (62) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +6 -2
  3. package/dist/docs.css +8260 -0
  4. package/dist/index.d.ts +33 -0
  5. package/dist/index.js +308 -0
  6. package/dist/pages/Playground-CNbBbErC.js +129 -0
  7. package/dist/pages/_figures-data-BDmScEny.js +606 -0
  8. package/dist/pages/_foundations-blXWyYh8.js +30 -0
  9. package/dist/pages/_overlays-specimens-Dpn6oiyH.js +310 -0
  10. package/dist/pages/alert-BD4e6QTh.js +769 -0
  11. package/dist/pages/app-shell-KbA-nRqZ.js +1479 -0
  12. package/dist/pages/area-chart-B91dLcGo.js +562 -0
  13. package/dist/pages/avatar-DPPHXJAu.js +713 -0
  14. package/dist/pages/badge-C9JR0thI.js +729 -0
  15. package/dist/pages/button-D3V912P4.js +518 -0
  16. package/dist/pages/calendar-DSDZ9nRH.js +630 -0
  17. package/dist/pages/card-DUggbis3.js +659 -0
  18. package/dist/pages/checkbox-DwimQaK3.js +365 -0
  19. package/dist/pages/colour-BwuO8xAv.js +1498 -0
  20. package/dist/pages/command-palette-xAD7fOg6.js +1243 -0
  21. package/dist/pages/date-picker-BYSa816m.js +1421 -0
  22. package/dist/pages/delta-CtAo0eIM.js +574 -0
  23. package/dist/pages/dialog-BRAf4LMh.js +1451 -0
  24. package/dist/pages/docs-BNOb7AqR.js +515 -0
  25. package/dist/pages/empty-state-C-mLrXW2.js +417 -0
  26. package/dist/pages/figure-tabs-CoPFzzKz.js +460 -0
  27. package/dist/pages/home-dashboard-CFQwDtC9.js +959 -0
  28. package/dist/pages/host-B6znjEgQ.js +109 -0
  29. package/dist/pages/icon-button-C9eSVPPW.js +861 -0
  30. package/dist/pages/icons-sxkTs5Ob.js +473 -0
  31. package/dist/pages/input-KF9Gkawf.js +1093 -0
  32. package/dist/pages/installation-DpsX8G_n.js +445 -0
  33. package/dist/pages/kbd-cNfDoikz.js +544 -0
  34. package/dist/pages/live-globe-ClvLn9Lb.js +571 -0
  35. package/dist/pages/logo-BfGF1Pq9.js +571 -0
  36. package/dist/pages/menu-by2sgQ09.js +1618 -0
  37. package/dist/pages/motion-BvTGc2Dk.js +855 -0
  38. package/dist/pages/orbit-spinner-Dil1Z3Oy.js +332 -0
  39. package/dist/pages/overview-BPEbZQ6g.js +130 -0
  40. package/dist/pages/pagination-BBUnGvv5.js +249 -0
  41. package/dist/pages/popover-Db1gLDpb.js +1136 -0
  42. package/dist/pages/principles-CeAIOIdt.js +483 -0
  43. package/dist/pages/radio-group-CkdBWWfG.js +1077 -0
  44. package/dist/pages/registry-CroHzK9I.js +244 -0
  45. package/dist/pages/release-Dvo684UJ.js +13 -0
  46. package/dist/pages/rolling-number-qmvH84Mq.js +529 -0
  47. package/dist/pages/search-field-BN7MWGQ4.js +693 -0
  48. package/dist/pages/segmented-control-CTbIpRBW.js +777 -0
  49. package/dist/pages/select-DguELoRR.js +1429 -0
  50. package/dist/pages/separator-CPZub9pv.js +351 -0
  51. package/dist/pages/shape-DKvA0YKr.js +627 -0
  52. package/dist/pages/skeleton-DLuBhP46.js +561 -0
  53. package/dist/pages/sparkline-DMMYGbHn.js +668 -0
  54. package/dist/pages/switch-B-Qe4kcT.js +517 -0
  55. package/dist/pages/table-AMoODng4.js +607 -0
  56. package/dist/pages/tabs-B4M-usCV.js +1455 -0
  57. package/dist/pages/textarea-fTuUZRQb.js +693 -0
  58. package/dist/pages/toast-CKP03zjy.js +1176 -0
  59. package/dist/pages/tooltip-CBYil3kt.js +697 -0
  60. package/dist/pages/typography-PCbg8Bhg.js +735 -0
  61. package/manifest.json +3125 -0
  62. package/package.json +35 -4
@@ -0,0 +1,1176 @@
1
+ "use client";
2
+ import { a as DocTable, d as Section, i as DocPage, l as Note, m as ThemePair, n as CodeBlock, o as Example, p as SubSection, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-BNOb7AqR.js";
3
+ import { c as SpecimenFrame } from "./_overlays-specimens-Dpn6oiyH.js";
4
+ import { useEffect, useId, useRef, useState } from "react";
5
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
+ import { Button, IconButton, Input, OrbitSpinner, SegmentedControl, Switch, Toaster, cx, toast, useThemeScope } from "@orbitcommerce/constellation";
7
+ import { ArrowsClockwiseIcon, CheckCircleIcon, InfoIcon, PaintBrushIcon, PaperPlaneTiltIcon, ShoppingBagIcon, TrashIcon, TruckIcon, UploadSimpleIcon, WarningCircleIcon, WarningIcon } from "@orbitcommerce/constellation/icons";
8
+ //#region src/pages/components/toast.tsx
9
+ var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
10
+ var failAfter = (ms, message) => new Promise((_, reject) => setTimeout(() => reject(new Error(message)), ms));
11
+ var TONE_ICONS = {
12
+ success: /* @__PURE__ */ jsx(CheckCircleIcon, {
13
+ weight: "fill",
14
+ "aria-hidden": "true"
15
+ }),
16
+ error: /* @__PURE__ */ jsx(WarningCircleIcon, {
17
+ weight: "fill",
18
+ "aria-hidden": "true"
19
+ }),
20
+ warning: /* @__PURE__ */ jsx(WarningIcon, {
21
+ weight: "fill",
22
+ "aria-hidden": "true"
23
+ }),
24
+ info: /* @__PURE__ */ jsx(InfoIcon, {
25
+ weight: "fill",
26
+ "aria-hidden": "true"
27
+ }),
28
+ loading: /* @__PURE__ */ jsx(OrbitSpinner, { size: 16 })
29
+ };
30
+ function CloseGlyph() {
31
+ return /* @__PURE__ */ jsx("svg", {
32
+ viewBox: "0 0 16 16",
33
+ fill: "none",
34
+ stroke: "currentColor",
35
+ strokeWidth: 1.6,
36
+ strokeLinecap: "round",
37
+ children: /* @__PURE__ */ jsx("path", { d: "M4.75 4.75l6.5 6.5M11.25 4.75l-6.5 6.5" })
38
+ });
39
+ }
40
+ function ToastStill({ tone = "message", title, description, action, closable = tone !== "loading", className, style }) {
41
+ return /* @__PURE__ */ jsxs("div", {
42
+ className: cx("o-toast", className),
43
+ "data-type": tone === "message" ? void 0 : tone,
44
+ style,
45
+ children: [
46
+ tone === "message" ? null : /* @__PURE__ */ jsx("div", {
47
+ className: "o-toast__icon",
48
+ children: TONE_ICONS[tone]
49
+ }),
50
+ /* @__PURE__ */ jsxs("div", {
51
+ className: "o-toast__content",
52
+ children: [/* @__PURE__ */ jsx("div", {
53
+ className: "o-toast__title",
54
+ children: title
55
+ }), description ? /* @__PURE__ */ jsx("div", {
56
+ className: "o-toast__description",
57
+ children: description
58
+ }) : null]
59
+ }),
60
+ /* @__PURE__ */ jsxs("div", {
61
+ className: "o-toast__controls",
62
+ children: [action ? /* @__PURE__ */ jsx(Button, {
63
+ size: "sm",
64
+ className: "o-toast__action",
65
+ tabIndex: -1,
66
+ children: action
67
+ }) : null, closable ? /* @__PURE__ */ jsx(IconButton, {
68
+ label: "Dismiss",
69
+ size: "sm",
70
+ className: "o-toast__close",
71
+ tabIndex: -1,
72
+ children: /* @__PURE__ */ jsx(CloseGlyph, {})
73
+ }) : null]
74
+ })
75
+ ]
76
+ });
77
+ }
78
+ function Preview() {
79
+ return /* @__PURE__ */ jsxs("div", {
80
+ className: "toast-preview",
81
+ children: [/* @__PURE__ */ jsx("div", { className: "o-toast toast-preview__back" }), /* @__PURE__ */ jsx(ToastStill, {
82
+ tone: "success",
83
+ title: "Order #1042 fulfilled",
84
+ description: "Tracking sent to James.",
85
+ closable: false
86
+ })]
87
+ });
88
+ }
89
+ function AllTonesStill() {
90
+ return /* @__PURE__ */ jsxs(SpecimenFrame, {
91
+ className: "toast-stills",
92
+ children: [
93
+ /* @__PURE__ */ jsx(ToastStill, {
94
+ tone: "success",
95
+ title: "Order #1042 marked as fulfilled",
96
+ description: "We emailed James Okafor his tracking link.",
97
+ action: "Undo"
98
+ }),
99
+ /* @__PURE__ */ jsx(ToastStill, {
100
+ tone: "error",
101
+ title: "Could not capture £89.50",
102
+ description: "The card issuer declined the payment for order #1043. Ask the customer for another card."
103
+ }),
104
+ /* @__PURE__ */ jsx(ToastStill, {
105
+ tone: "warning",
106
+ title: "Only 3 Walnut desk risers left"
107
+ }),
108
+ /* @__PURE__ */ jsx(ToastStill, {
109
+ tone: "info",
110
+ title: "Export on its way",
111
+ description: "We will email you the CSV of 318 orders when it is ready."
112
+ }),
113
+ /* @__PURE__ */ jsx(ToastStill, {
114
+ tone: "loading",
115
+ title: "Importing 248 products",
116
+ description: "From Northgate Supply. You can keep working."
117
+ }),
118
+ /* @__PURE__ */ jsx(ToastStill, { title: "Order link copied" })
119
+ ]
120
+ });
121
+ }
122
+ function LongStill() {
123
+ return /* @__PURE__ */ jsx(SpecimenFrame, {
124
+ className: "toast-stills",
125
+ children: /* @__PURE__ */ jsx(ToastStill, {
126
+ tone: "warning",
127
+ title: "Imported 245 of 248 products from Northgate Supply",
128
+ description: "3 were skipped because their SKUs are already in use: CHR-ARD-01, DSK-WAL-60 and LMP-BRS-01. Rename them in the file and import it again.",
129
+ action: "Download skipped rows"
130
+ })
131
+ });
132
+ }
133
+ function StackStill() {
134
+ return /* @__PURE__ */ jsxs(SpecimenFrame, {
135
+ className: "toast-stack-still",
136
+ children: [
137
+ /* @__PURE__ */ jsx("div", {
138
+ className: "o-toast",
139
+ "data-depth": "2"
140
+ }),
141
+ /* @__PURE__ */ jsx("div", {
142
+ className: "o-toast",
143
+ "data-depth": "1"
144
+ }),
145
+ /* @__PURE__ */ jsx(ToastStill, {
146
+ tone: "info",
147
+ title: "New order #1053",
148
+ description: "£312.00 from Priya Shah."
149
+ })
150
+ ]
151
+ });
152
+ }
153
+ function BasicsDemo() {
154
+ return /* @__PURE__ */ jsx(Button, {
155
+ variant: "primary",
156
+ icon: /* @__PURE__ */ jsx(TruckIcon, {}),
157
+ onClick: () => toast.success("Order #1042 marked as fulfilled", { description: "We emailed James Okafor his tracking link." }),
158
+ children: "Mark as fulfilled"
159
+ });
160
+ }
161
+ function importProducts() {
162
+ const id = toast.loading("Importing 248 products", { description: "From Northgate Supply. You can keep working." });
163
+ window.setTimeout(() => toast.success("Imported 248 products", {
164
+ id,
165
+ description: "231 new and 17 updated."
166
+ }), 2600);
167
+ }
168
+ function TonesDemo() {
169
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
170
+ /* @__PURE__ */ jsx(Button, {
171
+ onClick: () => toast.success("Order #1042 marked as fulfilled", { description: "We emailed James Okafor his tracking link." }),
172
+ children: "Success"
173
+ }),
174
+ /* @__PURE__ */ jsx(Button, {
175
+ onClick: () => toast.error("Could not capture £89.50", { description: "The card issuer declined the payment for order #1043. Ask the customer for another card." }),
176
+ children: "Error"
177
+ }),
178
+ /* @__PURE__ */ jsx(Button, {
179
+ onClick: () => toast.warning("Only 3 Walnut desk risers left", { description: "Reorder from Northgate Supply to keep it on sale." }),
180
+ children: "Warning"
181
+ }),
182
+ /* @__PURE__ */ jsx(Button, {
183
+ onClick: () => toast.info("Export on its way", { description: "We will email you the CSV of 318 orders when it is ready." }),
184
+ children: "Info"
185
+ }),
186
+ /* @__PURE__ */ jsx(Button, {
187
+ onClick: importProducts,
188
+ children: "Loading"
189
+ }),
190
+ /* @__PURE__ */ jsx(Button, {
191
+ onClick: () => toast("Order link copied"),
192
+ children: "Message"
193
+ })
194
+ ] });
195
+ }
196
+ function DescriptionDemo() {
197
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
198
+ onClick: () => toast.success("Discount code saved"),
199
+ children: "Title only"
200
+ }), /* @__PURE__ */ jsx(Button, {
201
+ onClick: () => toast.success("Discount code saved", { description: "SUMMER15 takes 15% off orders over £50 until 31 August." }),
202
+ children: "With a description"
203
+ })] });
204
+ }
205
+ function UndoDemo() {
206
+ const [status, setStatus] = useState("");
207
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
208
+ variant: "critical",
209
+ icon: /* @__PURE__ */ jsx(TrashIcon, {}),
210
+ onClick: () => {
211
+ setStatus("");
212
+ toast("Deleted Walnut desk riser", {
213
+ description: "It has left your catalogue.",
214
+ action: {
215
+ label: "Undo",
216
+ altText: "Undo deleting Walnut desk riser",
217
+ onClick: () => setStatus("Walnut desk riser is back in your catalogue.")
218
+ }
219
+ });
220
+ },
221
+ children: "Delete product"
222
+ }), /* @__PURE__ */ jsx("p", {
223
+ className: "toast-status",
224
+ "aria-live": "polite",
225
+ children: status
226
+ })] });
227
+ }
228
+ function RetryDemo() {
229
+ return /* @__PURE__ */ jsx(Button, {
230
+ icon: /* @__PURE__ */ jsx(PaperPlaneTiltIcon, {}),
231
+ onClick: () => toast.error("Could not send invoice INV-2207", {
232
+ description: "The email server did not answer.",
233
+ action: {
234
+ label: "Try again",
235
+ altText: "Try again to send invoice INV-2207",
236
+ onClick: async () => {
237
+ await wait(1400);
238
+ toast.success("Sent invoice INV-2207", { description: "Ella Brooks has it by email, as a PDF." });
239
+ }
240
+ }
241
+ }),
242
+ children: "Send invoice"
243
+ });
244
+ }
245
+ function PromiseDemo() {
246
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
247
+ variant: "inverse",
248
+ icon: /* @__PURE__ */ jsx(PaintBrushIcon, {}),
249
+ onClick: () => toast.promise(wait(1800), {
250
+ loading: "Publishing the Harbour theme",
251
+ success: {
252
+ title: "Harbour is live",
253
+ description: "Your store switched themes. You can switch back from Themes."
254
+ },
255
+ error: "Could not publish the theme"
256
+ }),
257
+ children: "Publish theme"
258
+ }), /* @__PURE__ */ jsx(Button, {
259
+ icon: /* @__PURE__ */ jsx(ArrowsClockwiseIcon, {}),
260
+ onClick: () => toast.promise(failAfter(2e3, "Northgate Supply did not answer. Try again in a few minutes."), {
261
+ loading: {
262
+ title: "Syncing stock",
263
+ description: "Checking 1,284 products against Northgate Supply."
264
+ },
265
+ success: (count) => `Updated stock for ${count} products`,
266
+ error: (error) => ({
267
+ title: "Stock sync failed",
268
+ description: error instanceof Error ? error.message : void 0
269
+ })
270
+ }),
271
+ children: "Sync stock"
272
+ })] });
273
+ }
274
+ function ImportDemo() {
275
+ const run = useRef({});
276
+ useEffect(() => () => {
277
+ window.clearInterval(run.current.timer);
278
+ if (run.current.id !== void 0) toast.dismiss(run.current.id);
279
+ }, []);
280
+ const start = () => {
281
+ window.clearInterval(run.current.timer);
282
+ const total = 248;
283
+ let done = 0;
284
+ const id = toast.loading(`Importing ${total} products`, { description: `0 of ${total} done` });
285
+ run.current.id = id;
286
+ run.current.timer = window.setInterval(() => {
287
+ done = Math.min(total, done + 31);
288
+ if (done < total) {
289
+ toast.loading(`Importing ${total} products`, {
290
+ id,
291
+ description: `${done} of ${total} done`
292
+ });
293
+ return;
294
+ }
295
+ window.clearInterval(run.current.timer);
296
+ run.current.id = void 0;
297
+ toast.success(`Imported ${total} products`, {
298
+ id,
299
+ description: "231 new and 17 updated.",
300
+ action: {
301
+ label: "View products",
302
+ onClick: () => {}
303
+ }
304
+ });
305
+ }, 450);
306
+ };
307
+ return /* @__PURE__ */ jsx(Button, {
308
+ icon: /* @__PURE__ */ jsx(UploadSimpleIcon, {}),
309
+ onClick: start,
310
+ children: "Import products"
311
+ });
312
+ }
313
+ var ORDERS = [
314
+ [
315
+ "#1051",
316
+ "£129.00",
317
+ "Ella Brooks"
318
+ ],
319
+ [
320
+ "#1052",
321
+ "£64.50",
322
+ "Sam Patel"
323
+ ],
324
+ [
325
+ "#1053",
326
+ "£312.00",
327
+ "Priya Shah"
328
+ ]
329
+ ];
330
+ function OrdersDemo() {
331
+ return /* @__PURE__ */ jsx(Button, {
332
+ icon: /* @__PURE__ */ jsx(ShoppingBagIcon, {}),
333
+ onClick: () => ORDERS.forEach(([order, total, name], i) => window.setTimeout(() => toast.info(`New order ${order}`, { description: `${total} from ${name}.` }), i * 350)),
334
+ children: "Three orders arrive"
335
+ });
336
+ }
337
+ /** A Toaster of its own inside each side of a theme pair: its toasts take that side's theme. */
338
+ function ScopedToasts() {
339
+ const theme = useThemeScope() ?? "light";
340
+ const [stage, setStage] = useState(null);
341
+ const toasterId = `toast-docs-${theme}`;
342
+ return /* @__PURE__ */ jsxs("div", {
343
+ ref: setStage,
344
+ className: "toast-scoped",
345
+ children: [/* @__PURE__ */ jsx(Button, {
346
+ icon: /* @__PURE__ */ jsx(ArrowsClockwiseIcon, {}),
347
+ onClick: () => toast.success("Stock synced", {
348
+ description: "1,284 products checked against Northgate Supply.",
349
+ toasterId
350
+ }),
351
+ children: "Sync stock"
352
+ }), stage ? /* @__PURE__ */ jsx(Toaster, {
353
+ id: toasterId,
354
+ container: stage,
355
+ hotkey: [],
356
+ offset: 16
357
+ }) : null]
358
+ });
359
+ }
360
+ var TONES = [
361
+ "message",
362
+ "success",
363
+ "info",
364
+ "warning",
365
+ "error",
366
+ "loading"
367
+ ];
368
+ var POSITIONS = [
369
+ "top-left",
370
+ "top-center",
371
+ "top-right",
372
+ "bottom-left",
373
+ "bottom-center",
374
+ "bottom-right"
375
+ ];
376
+ var quote = (text) => `'${text.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
377
+ function Control({ label, text, children }) {
378
+ const id = useId();
379
+ return /* @__PURE__ */ jsxs("div", {
380
+ className: "doc-playground__control",
381
+ "data-type": text ? "text" : void 0,
382
+ children: [/* @__PURE__ */ jsx("span", {
383
+ className: "doc-playground__label",
384
+ id,
385
+ children: label
386
+ }), children(id)]
387
+ });
388
+ }
389
+ function ToastPlayground() {
390
+ const [tone, setTone] = useState("success");
391
+ const [title, setTitle] = useState("Order #1042 marked as fulfilled");
392
+ const [description, setDescription] = useState("We emailed James Okafor his tracking link.");
393
+ const [action, setAction] = useState(true);
394
+ const [dismissable, setDismissable] = useState(true);
395
+ const [position, setPosition] = useState("bottom-right");
396
+ const lines = [
397
+ description ? `description: ${quote(description)},` : null,
398
+ action ? `action: { label: 'Undo', onClick: undo },` : null,
399
+ position !== "bottom-right" ? `position: ${quote(position)},` : null,
400
+ !dismissable && tone !== "loading" ? "dismissable: false," : null
401
+ ].filter((line) => line !== null);
402
+ const call = tone === "message" ? "toast" : `toast.${tone}`;
403
+ const code = lines.length ? `${call}(${quote(title)}, {\n${lines.map((line) => ` ${line}`).join("\n")}\n})` : `${call}(${quote(title)})`;
404
+ const show = () => {
405
+ const options = {
406
+ description: description || void 0,
407
+ action: action ? {
408
+ label: "Undo",
409
+ onClick: () => {}
410
+ } : void 0,
411
+ position,
412
+ dismissable
413
+ };
414
+ if (tone === "message") toast(title, options);
415
+ else toast[tone](title, options);
416
+ };
417
+ return /* @__PURE__ */ jsxs("figure", {
418
+ className: "doc-playground",
419
+ children: [
420
+ /* @__PURE__ */ jsxs("div", {
421
+ className: "doc-playground__stage",
422
+ children: [/* @__PURE__ */ jsx(Button, {
423
+ variant: "primary",
424
+ disabled: !title.trim(),
425
+ onClick: show,
426
+ children: "Show toast"
427
+ }), /* @__PURE__ */ jsx(Button, {
428
+ onClick: () => toast.dismiss(),
429
+ children: "Dismiss all"
430
+ })]
431
+ }),
432
+ /* @__PURE__ */ jsxs("div", {
433
+ className: "doc-playground__controls",
434
+ role: "group",
435
+ "aria-label": "Toast options",
436
+ children: [
437
+ /* @__PURE__ */ jsx(Control, {
438
+ label: "tone",
439
+ children: () => /* @__PURE__ */ jsx("div", {
440
+ className: "doc-playground__scroll",
441
+ children: /* @__PURE__ */ jsx(SegmentedControl, {
442
+ "aria-label": "tone",
443
+ size: "sm",
444
+ value: tone,
445
+ onValueChange: setTone,
446
+ options: TONES.map((t) => ({
447
+ value: t,
448
+ label: t
449
+ }))
450
+ })
451
+ })
452
+ }),
453
+ /* @__PURE__ */ jsx(Control, {
454
+ label: "title",
455
+ text: true,
456
+ children: (id) => /* @__PURE__ */ jsx(Input, {
457
+ size: "sm",
458
+ "aria-labelledby": id,
459
+ value: title,
460
+ onChange: (e) => setTitle(e.target.value)
461
+ })
462
+ }),
463
+ /* @__PURE__ */ jsx(Control, {
464
+ label: "description",
465
+ text: true,
466
+ children: (id) => /* @__PURE__ */ jsx(Input, {
467
+ size: "sm",
468
+ "aria-labelledby": id,
469
+ value: description,
470
+ onChange: (e) => setDescription(e.target.value)
471
+ })
472
+ }),
473
+ /* @__PURE__ */ jsx(Control, {
474
+ label: "action",
475
+ children: (id) => /* @__PURE__ */ jsx(Switch, {
476
+ size: "sm",
477
+ "aria-labelledby": id,
478
+ checked: action,
479
+ onCheckedChange: setAction
480
+ })
481
+ }),
482
+ /* @__PURE__ */ jsx(Control, {
483
+ label: "dismissable",
484
+ children: (id) => /* @__PURE__ */ jsx(Switch, {
485
+ size: "sm",
486
+ "aria-labelledby": id,
487
+ checked: dismissable,
488
+ onCheckedChange: setDismissable
489
+ })
490
+ }),
491
+ /* @__PURE__ */ jsx(Control, {
492
+ label: "position",
493
+ children: () => /* @__PURE__ */ jsx("div", {
494
+ className: "doc-playground__scroll",
495
+ children: /* @__PURE__ */ jsx(SegmentedControl, {
496
+ "aria-label": "position",
497
+ size: "sm",
498
+ value: position,
499
+ onValueChange: setPosition,
500
+ options: POSITIONS.map((p) => ({
501
+ value: p,
502
+ label: p
503
+ }))
504
+ })
505
+ })
506
+ })
507
+ ]
508
+ }),
509
+ /* @__PURE__ */ jsx(CodeBlock, { code })
510
+ ]
511
+ });
512
+ }
513
+ function Tone({ tone, children }) {
514
+ const colour = {
515
+ success: "var(--o-positive)",
516
+ error: "var(--o-negative)",
517
+ warning: "var(--o-warning)",
518
+ info: "var(--o-info)",
519
+ loading: "var(--o-accent)"
520
+ }[tone];
521
+ return /* @__PURE__ */ jsxs("span", {
522
+ className: "toast-tone",
523
+ style: { color: colour },
524
+ children: [TONE_ICONS[tone], /* @__PURE__ */ jsx("span", {
525
+ style: { color: "var(--o-fg-1)" },
526
+ children
527
+ })]
528
+ });
529
+ }
530
+ function DoDontToast(props) {
531
+ return /* @__PURE__ */ jsx(SpecimenFrame, {
532
+ className: "toast-stills",
533
+ children: /* @__PURE__ */ jsx(ToastStill, { ...props })
534
+ });
535
+ }
536
+ function Page() {
537
+ useEffect(() => () => toast.dismiss(), []);
538
+ return /* @__PURE__ */ jsxs(DocPage, {
539
+ title: "Toast",
540
+ status: "new",
541
+ importNames: ["Toaster", "toast"],
542
+ lead: "A short message at the edge of the window about something that just happened: an order fulfilled, an export started, a payment that failed. It leaves on its own, so it never carries anything the merchant has to act on.",
543
+ children: [
544
+ /* @__PURE__ */ jsxs(Section, {
545
+ id: "basics",
546
+ title: "Basics",
547
+ description: /* @__PURE__ */ jsxs("p", { children: [
548
+ "Mount one ",
549
+ /* @__PURE__ */ jsx("code", { children: "Toaster" }),
550
+ " near the root of the app, then call ",
551
+ /* @__PURE__ */ jsx("code", { children: "toast" }),
552
+ " from anywhere: an event handler, a mutation's ",
553
+ /* @__PURE__ */ jsx("code", { children: "onSuccess" }),
554
+ ", a hook. The Toaster draws nothing until a toast arrives. Each toast rises in from the bottom right on the Orbit spring, stays a few seconds and slips back out."
555
+ ] }),
556
+ children: [/* @__PURE__ */ jsx(Example, {
557
+ code: `
558
+ // Once, near the root of the app
559
+ <Toaster />
560
+
561
+ // Anywhere
562
+ toast.success('Order #1042 marked as fulfilled', {
563
+ description: 'We emailed James Okafor his tracking link.',
564
+ })`,
565
+ children: /* @__PURE__ */ jsx(BasicsDemo, {})
566
+ }), /* @__PURE__ */ jsxs(Note, {
567
+ title: "One Toaster",
568
+ children: [
569
+ "Two Toasters on a page show every toast twice. To have more than one, give each an ",
570
+ /* @__PURE__ */ jsx("code", { children: "id" }),
571
+ " and send toasts to it with ",
572
+ /* @__PURE__ */ jsx("code", { children: "toasterId" }),
573
+ ", as the theme demo below does."
574
+ ]
575
+ })]
576
+ }),
577
+ /* @__PURE__ */ jsxs(Section, {
578
+ id: "tones",
579
+ title: "Tones",
580
+ description: /* @__PURE__ */ jsxs("p", { children: [
581
+ "Five tones and a plain message. The surface never changes: only the icon carries the tone, in its status colour. A loading toast shows the orbit spinner and stays until you update it with the same ",
582
+ /* @__PURE__ */ jsx("code", { children: "id" }),
583
+ ", as the Loading button does after a moment."
584
+ ] }),
585
+ children: [/* @__PURE__ */ jsx(Example, {
586
+ code: `
587
+ toast.success('Order #1042 marked as fulfilled', { description: 'We emailed James Okafor his tracking link.' })
588
+ toast.error('Could not capture £89.50', {
589
+ description: 'The card issuer declined the payment for order #1043. Ask the customer for another card.',
590
+ })
591
+ toast.warning('Only 3 Walnut desk risers left', { description: 'Reorder from Northgate Supply to keep it on sale.' })
592
+ toast.info('Export on its way', { description: 'We will email you the CSV of 318 orders when it is ready.' })
593
+
594
+ const id = toast.loading('Importing 248 products', { description: 'From Northgate Supply. You can keep working.' })
595
+ // later, the same id turns it into the outcome
596
+ toast.success('Imported 248 products', { id, description: '231 new and 17 updated.' })
597
+
598
+ toast('Order link copied')`,
599
+ children: /* @__PURE__ */ jsx(TonesDemo, {})
600
+ }), /* @__PURE__ */ jsx(DocTable, {
601
+ columns: [
602
+ "Tone",
603
+ "Call",
604
+ "Stays for",
605
+ "Use it for"
606
+ ],
607
+ rows: [
608
+ [
609
+ /* @__PURE__ */ jsx(Tone, {
610
+ tone: "success",
611
+ children: "Success"
612
+ }),
613
+ /* @__PURE__ */ jsx("code", { children: "toast.success" }),
614
+ "4 seconds",
615
+ "Something the merchant did worked."
616
+ ],
617
+ [
618
+ /* @__PURE__ */ jsx(Tone, {
619
+ tone: "error",
620
+ children: "Error"
621
+ }),
622
+ /* @__PURE__ */ jsx("code", { children: "toast.error" }),
623
+ "8 seconds",
624
+ "Something did not work. Say what failed and what to do next."
625
+ ],
626
+ [
627
+ /* @__PURE__ */ jsx(Tone, {
628
+ tone: "warning",
629
+ children: "Warning"
630
+ }),
631
+ /* @__PURE__ */ jsx("code", { children: "toast.warning" }),
632
+ "6 seconds",
633
+ "It worked, with a catch worth knowing about."
634
+ ],
635
+ [
636
+ /* @__PURE__ */ jsx(Tone, {
637
+ tone: "info",
638
+ children: "Info"
639
+ }),
640
+ /* @__PURE__ */ jsx("code", { children: "toast.info" }),
641
+ "5 seconds",
642
+ "Something happened that the merchant did not do here: an export started, a new order came in."
643
+ ],
644
+ [
645
+ /* @__PURE__ */ jsx(Tone, {
646
+ tone: "loading",
647
+ children: "Loading"
648
+ }),
649
+ /* @__PURE__ */ jsx("code", { children: "toast.loading" }),
650
+ "Until it ends",
651
+ "Work that finishes on its own. Turn it into its outcome, or use toast.promise."
652
+ ],
653
+ [
654
+ /* @__PURE__ */ jsx("span", {
655
+ className: "toast-tone",
656
+ children: "Message"
657
+ }),
658
+ /* @__PURE__ */ jsx("code", { children: "toast" }),
659
+ "4 seconds",
660
+ "A quiet confirmation with no tone: a link copied, a draft saved."
661
+ ]
662
+ ]
663
+ })]
664
+ }),
665
+ /* @__PURE__ */ jsxs(Section, {
666
+ id: "both-themes",
667
+ title: "In both themes",
668
+ description: /* @__PURE__ */ jsx("p", { children: "Held still for review, light beside dark. The surface matches the popover's (raised, 14px corners, the floating shadow) and adds a hairline ring, so its edge holds over any page. The title is in the UI weight and the description is muted. In dark the surface lifts to graphite and the status colours brighten to stay readable." }),
669
+ children: [
670
+ /* @__PURE__ */ jsx(ThemePair, {
671
+ align: "fill",
672
+ caption: "Stills drawn with the toast's own classes. Every toast fired on this page is live.",
673
+ children: /* @__PURE__ */ jsx(AllTonesStill, {})
674
+ }),
675
+ /* @__PURE__ */ jsx(SubSection, {
676
+ title: "Long content",
677
+ description: /* @__PURE__ */ jsx("p", { children: "Titles and descriptions wrap; the icon and close button stay with the first line." }),
678
+ children: /* @__PURE__ */ jsx(ThemePair, {
679
+ align: "fill",
680
+ children: /* @__PURE__ */ jsx(LongStill, {})
681
+ })
682
+ }),
683
+ /* @__PURE__ */ jsx(SubSection, {
684
+ title: "Inside a ThemeScope",
685
+ description: /* @__PURE__ */ jsxs("p", { children: [
686
+ "A Toaster inside a ",
687
+ /* @__PURE__ */ jsx("code", { children: "ThemeScope" }),
688
+ " takes the scope's theme, as the kit's other overlays do; anywhere else it follows the page. Each side here has a Toaster of its own, framed to its panel."
689
+ ] }),
690
+ children: /* @__PURE__ */ jsx(ThemePair, { children: /* @__PURE__ */ jsx(ScopedToasts, {}) })
691
+ })
692
+ ]
693
+ }),
694
+ /* @__PURE__ */ jsx(Section, {
695
+ id: "descriptions",
696
+ title: "With and without a description",
697
+ description: /* @__PURE__ */ jsxs("p", { children: [
698
+ "The title says what happened. Add a ",
699
+ /* @__PURE__ */ jsx("code", { children: "description" }),
700
+ " only when the merchant needs one more fact: what happens next, or what changed."
701
+ ] }),
702
+ children: /* @__PURE__ */ jsx(Example, {
703
+ code: `
704
+ toast.success('Discount code saved')
705
+
706
+ toast.success('Discount code saved', {
707
+ description: 'SUMMER15 takes 15% off orders over £50 until 31 August.',
708
+ })`,
709
+ children: /* @__PURE__ */ jsx(DescriptionDemo, {})
710
+ })
711
+ }),
712
+ /* @__PURE__ */ jsxs(Section, {
713
+ id: "actions",
714
+ title: "Actions",
715
+ description: /* @__PURE__ */ jsxs("p", { children: [
716
+ "One follow-up, as a small button under the text: Undo, Try again, View order. The toast closes once the action has run. Call ",
717
+ /* @__PURE__ */ jsx("code", { children: "event.preventDefault()" }),
718
+ " in ",
719
+ /* @__PURE__ */ jsx("code", { children: "onClick" }),
720
+ " to keep it open; an action on a loading toast never closes it."
721
+ ] }),
722
+ children: [/* @__PURE__ */ jsx(SubSection, {
723
+ title: "Undo",
724
+ description: /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("code", { children: "altText" }), " is the button's accessible name, for when the label alone would be unclear out of context. Keep the label's words in it: if they are missing, the label is put in front."] }),
725
+ children: /* @__PURE__ */ jsx(Example, {
726
+ code: `
727
+ toast('Deleted Walnut desk riser', {
728
+ description: 'It has left your catalogue.',
729
+ action: {
730
+ label: 'Undo',
731
+ altText: 'Undo deleting Walnut desk riser',
732
+ onClick: () => restore(product),
733
+ },
734
+ })`,
735
+ children: /* @__PURE__ */ jsx(UndoDemo, {})
736
+ })
737
+ }), /* @__PURE__ */ jsx(SubSection, {
738
+ title: "Waiting for the action",
739
+ description: /* @__PURE__ */ jsxs("p", { children: [
740
+ "Return a promise from ",
741
+ /* @__PURE__ */ jsx("code", { children: "onClick" }),
742
+ " and the button keeps the comet in orbit until it settles. The toast closes when it resolves and stays when it rejects. This one tries again for a moment, then reports back."
743
+ ] }),
744
+ children: /* @__PURE__ */ jsx(Example, {
745
+ code: `
746
+ toast.error('Could not send invoice INV-2207', {
747
+ description: 'The email server did not answer.',
748
+ action: {
749
+ label: 'Try again',
750
+ altText: 'Try again to send invoice INV-2207',
751
+ onClick: async () => {
752
+ await sendInvoice(invoice)
753
+ toast.success('Sent invoice INV-2207', { description: 'Ella Brooks has it by email, as a PDF.' })
754
+ },
755
+ },
756
+ })`,
757
+ children: /* @__PURE__ */ jsx(RetryDemo, {})
758
+ })
759
+ })]
760
+ }),
761
+ /* @__PURE__ */ jsxs(Section, {
762
+ id: "loading",
763
+ title: "Loading and promises",
764
+ description: /* @__PURE__ */ jsxs("p", { children: [
765
+ /* @__PURE__ */ jsx("code", { children: "toast.promise" }),
766
+ " shows a loading toast while the work runs, then turns it into the outcome in place: the spinner gives way to the tone icon, which lands with a small settle. Each state is a title, or a",
767
+ " ",
768
+ /* @__PURE__ */ jsx("code", { children: "{ title, description }" }),
769
+ "; ",
770
+ /* @__PURE__ */ jsx("code", { children: "success" }),
771
+ " and ",
772
+ /* @__PURE__ */ jsx("code", { children: "error" }),
773
+ " can also be functions of the result or the error. Leave one out and the toast simply closes. It returns the toast's id straight away."
774
+ ] }),
775
+ children: [/* @__PURE__ */ jsx(Example, {
776
+ code: `
777
+ toast.promise(publishTheme(harbour), {
778
+ loading: 'Publishing the Harbour theme',
779
+ success: { title: 'Harbour is live', description: 'Your store switched themes. You can switch back from Themes.' },
780
+ error: 'Could not publish the theme',
781
+ })
782
+
783
+ toast.promise(syncStock(), {
784
+ loading: { title: 'Syncing stock', description: 'Checking 1,284 products against Northgate Supply.' },
785
+ success: (count) => \`Updated stock for \${count} products\`,
786
+ error: (error) => ({ title: 'Stock sync failed', description: error.message }),
787
+ })`,
788
+ caption: "Sync stock fails on purpose, to show the error state.",
789
+ children: /* @__PURE__ */ jsx(PromiseDemo, {})
790
+ }), /* @__PURE__ */ jsx(SubSection, {
791
+ title: "Progress, updated in place",
792
+ description: /* @__PURE__ */ jsxs("p", { children: [
793
+ "Call ",
794
+ /* @__PURE__ */ jsx("code", { children: "toast.loading" }),
795
+ " again with the same ",
796
+ /* @__PURE__ */ jsx("code", { children: "id" }),
797
+ " to update it, and finish with",
798
+ " ",
799
+ /* @__PURE__ */ jsx("code", { children: "toast.success" }),
800
+ " or ",
801
+ /* @__PURE__ */ jsx("code", { children: "toast.error" }),
802
+ " on that id. The toast keeps its place in the stack throughout. Dismiss it yourself if the work is abandoned."
803
+ ] }),
804
+ children: /* @__PURE__ */ jsx(Example, {
805
+ code: `
806
+ const id = toast.loading('Importing 248 products', { description: '0 of 248 done' })
807
+
808
+ onProgress((done) => toast.loading('Importing 248 products', { id, description: \`\${done} of 248 done\` }))
809
+
810
+ onDone(() =>
811
+ toast.success('Imported 248 products', {
812
+ id,
813
+ description: '231 new and 17 updated.',
814
+ action: { label: 'View products', onClick: openProducts },
815
+ }),
816
+ )`,
817
+ children: /* @__PURE__ */ jsx(ImportDemo, {})
818
+ })
819
+ })]
820
+ }),
821
+ /* @__PURE__ */ jsxs(Section, {
822
+ id: "timing",
823
+ title: "How long they stay",
824
+ description: /* @__PURE__ */ jsxs("p", { children: [
825
+ "Each tone has its own time on screen, longest for errors because they say what went wrong and what to do about it. A loading toast stays until it is updated or dismissed. Pass ",
826
+ /* @__PURE__ */ jsx("code", { children: "duration" }),
827
+ " in milliseconds to change one, or ",
828
+ /* @__PURE__ */ jsx("code", { children: "Infinity" }),
829
+ " to keep it until it is closed."
830
+ ] }),
831
+ children: [/* @__PURE__ */ jsx(DocTable, {
832
+ columns: ["Tone", "Default duration"],
833
+ rows: [
834
+ [/* @__PURE__ */ jsx("code", { children: "toast" }), "4,000ms"],
835
+ [/* @__PURE__ */ jsx("code", { children: "toast.success" }), "4,000ms"],
836
+ [/* @__PURE__ */ jsx("code", { children: "toast.info" }), "5,000ms"],
837
+ [/* @__PURE__ */ jsx("code", { children: "toast.warning" }), "6,000ms"],
838
+ [/* @__PURE__ */ jsx("code", { children: "toast.error" }), "8,000ms"],
839
+ [/* @__PURE__ */ jsx("code", { children: "toast.loading" }), "Infinity"]
840
+ ]
841
+ }), /* @__PURE__ */ jsx(Guidelines, { items: ["Every timer pauses while the pointer is over the toasts, while the stack is fanned out, and while the browser tab is in the background.", "An update by id restarts the timer, so a loading toast that turns into its outcome gets the outcome tone's full time."] })]
842
+ }),
843
+ /* @__PURE__ */ jsxs(Section, {
844
+ id: "stacking",
845
+ title: "Stacking and position",
846
+ description: /* @__PURE__ */ jsx("p", { children: "The newest toast sits in front. Up to two more fold behind it, each 12px further back and 5% smaller, with their content hidden. Hover the stack (or press Alt+T) and it fans out, 12px apart, with their timers paused. Swipe a toast towards the edge it sits against to dismiss it." }),
847
+ children: [
848
+ /* @__PURE__ */ jsx(ThemePair, {
849
+ align: "fill",
850
+ caption: "The folded stack, held still.",
851
+ children: /* @__PURE__ */ jsx(StackStill, {})
852
+ }),
853
+ /* @__PURE__ */ jsx(Example, {
854
+ code: `
855
+ toast.info('New order #1051', { description: '£129.00 from Ella Brooks.' })
856
+ toast.info('New order #1052', { description: '£64.50 from Sam Patel.' })
857
+ toast.info('New order #1053', { description: '£312.00 from Priya Shah.' })`,
858
+ caption: "Then hover the stack at the bottom right.",
859
+ children: /* @__PURE__ */ jsx(OrdersDemo, {})
860
+ }),
861
+ /* @__PURE__ */ jsx(SubSection, {
862
+ title: "Position",
863
+ description: /* @__PURE__ */ jsxs("p", { children: [
864
+ "Toasts appear at the Toaster's ",
865
+ /* @__PURE__ */ jsx("code", { children: "position" }),
866
+ ", the bottom right by default, 24px in from the edges. A toast can choose its own with ",
867
+ /* @__PURE__ */ jsx("code", { children: "position" }),
868
+ ", for a screen where that corner is busy; try it in the playground. On screens up to 600px wide they span the width, 16px in from each side."
869
+ ] })
870
+ })
871
+ ]
872
+ }),
873
+ /* @__PURE__ */ jsx(Section, {
874
+ id: "playground",
875
+ title: "Playground",
876
+ description: /* @__PURE__ */ jsx("p", { children: "Build a toast, show it, and copy the call. Toasts follow the site theme: switch it in the header." }),
877
+ children: /* @__PURE__ */ jsx(ToastPlayground, {})
878
+ }),
879
+ /* @__PURE__ */ jsxs(Section, {
880
+ id: "guidelines",
881
+ title: "Guidelines",
882
+ children: [
883
+ /* @__PURE__ */ jsx(DoDont, {
884
+ do: {
885
+ children: /* @__PURE__ */ jsx(DoDontToast, {
886
+ tone: "success",
887
+ title: "Refunded £89.50 to James Okafor",
888
+ description: "It reaches his card in 5 to 10 working days."
889
+ }),
890
+ caption: "Say what happened and to what, in the merchant's words. The description adds the one fact they need next."
891
+ },
892
+ dont: {
893
+ children: /* @__PURE__ */ jsx(DoDontToast, {
894
+ tone: "success",
895
+ title: "Success!",
896
+ description: "The operation completed successfully."
897
+ }),
898
+ caption: "A cheer with no subject sends them back to the page to find out what worked."
899
+ }
900
+ }),
901
+ /* @__PURE__ */ jsx(DoDont, {
902
+ do: {
903
+ children: /* @__PURE__ */ jsx(DoDontToast, {
904
+ tone: "error",
905
+ title: "Could not capture £89.50",
906
+ description: "The card issuer declined it. Ask the customer for another card."
907
+ }),
908
+ caption: "Name what failed and the way forward. Make the title clear without the icon."
909
+ },
910
+ dont: {
911
+ children: /* @__PURE__ */ jsx(DoDontToast, {
912
+ tone: "error",
913
+ title: "Error",
914
+ description: "Something went wrong. Please try again."
915
+ }),
916
+ caption: "\"Something went wrong\" tells the merchant nothing they can act on."
917
+ }
918
+ }),
919
+ /* @__PURE__ */ jsx(Guidelines, { items: [
920
+ "Use a toast to confirm something the merchant just did, or to report work that finished in the background.",
921
+ "A toast leaves on its own, so it is never the only place something important is said. Errors the merchant has to fix belong next to the problem: an error on the Field, or an Alert at the top of the form.",
922
+ "Never ask a question in a toast. A decision wants a dialog.",
923
+ "Title it with what happened, in a few words and sentence case, with no full stop. Screen readers read the title without the icon, so it has to carry the tone itself.",
924
+ "One action at most, and never the only way to do something: an Undo should also be possible from the page or its history.",
925
+ "Do not toast every autosave or every row of a bulk change. When several things finish together, say so once: \"Updated 12 products\".",
926
+ "Never raise a toast as a page loads. Toasts answer something that just happened."
927
+ ] })
928
+ ]
929
+ }),
930
+ /* @__PURE__ */ jsx(Section, {
931
+ id: "accessibility",
932
+ title: "Accessibility",
933
+ children: /* @__PURE__ */ jsx(Guidelines, { items: [
934
+ "The Toaster is a polite live region: screen readers read each toast as it arrives, without moving focus.",
935
+ "Alt+T (Option+T on a Mac) moves focus to the toasts and fans the stack out. Tab reaches each toast, its action and its close button; Escape folds the stack again.",
936
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
937
+ "The close button is named \"Dismiss\" (",
938
+ /* @__PURE__ */ jsx("code", { children: "closeLabel" }),
939
+ " on the Toaster changes it, for example in another language). An action's ",
940
+ /* @__PURE__ */ jsx("code", { children: "altText" }),
941
+ " becomes its accessible name."
942
+ ] }),
943
+ "Timers pause while the pointer is over the toasts and while the stack is fanned out, so there is time to read and reach them.",
944
+ "On touch screens a swipe towards the edge dismisses a toast. Loading toasts end with their work, so they cannot be dismissed unless they pass `dismissable: true` (for work that runs for minutes).",
945
+ "While a modal dialog is open, the page behind it takes no clicks, toasts included. They still appear and are read out.",
946
+ "With reduced motion, toasts fade in and out where they stand, and the stack rearranges without sliding."
947
+ ] })
948
+ }),
949
+ /* @__PURE__ */ jsx(Fragment$1, {}),
950
+ /* @__PURE__ */ jsxs(Section, {
951
+ id: "props",
952
+ title: "Props",
953
+ children: [
954
+ /* @__PURE__ */ jsx(DocTable, {
955
+ columns: [
956
+ "Call",
957
+ "Returns",
958
+ "What it does"
959
+ ],
960
+ rows: [
961
+ [
962
+ /* @__PURE__ */ jsx("code", { children: "toast(title, options?)" }),
963
+ /* @__PURE__ */ jsx("code", { children: "ToastId" }),
964
+ "A plain message, with no tone icon."
965
+ ],
966
+ [
967
+ /* @__PURE__ */ jsx("code", { children: "toast.success / error / warning / info (title, options?)" }),
968
+ /* @__PURE__ */ jsx("code", { children: "ToastId" }),
969
+ "A toast in that tone."
970
+ ],
971
+ [
972
+ /* @__PURE__ */ jsx("code", { children: "toast.loading(title, options?)" }),
973
+ /* @__PURE__ */ jsx("code", { children: "ToastId" }),
974
+ "Stays until updated with its id, or dismissed."
975
+ ],
976
+ [
977
+ /* @__PURE__ */ jsx("code", { children: "toast.promise(work, options)" }),
978
+ /* @__PURE__ */ jsx("code", { children: "ToastId" }),
979
+ "Loading while the work runs, then its outcome."
980
+ ],
981
+ [
982
+ /* @__PURE__ */ jsx("code", { children: "toast.dismiss(id?)" }),
983
+ /* @__PURE__ */ jsx("code", { children: "void" }),
984
+ "Closes one toast, or every toast without an id."
985
+ ]
986
+ ]
987
+ }),
988
+ /* @__PURE__ */ jsx(PropsTable, {
989
+ title: "Toast options",
990
+ rows: [
991
+ {
992
+ name: "description",
993
+ type: "ReactNode",
994
+ description: "One more fact, under the title."
995
+ },
996
+ {
997
+ name: "action",
998
+ type: "ToastAction",
999
+ description: "One follow-up, as a small button under the text. See below."
1000
+ },
1001
+ {
1002
+ name: "duration",
1003
+ type: "number",
1004
+ default: "by tone",
1005
+ description: "Time on screen in milliseconds. Infinity keeps it until it is closed."
1006
+ },
1007
+ {
1008
+ name: "id",
1009
+ type: "string | number",
1010
+ description: "Reuse the id of a toast that is showing to update it in place."
1011
+ },
1012
+ {
1013
+ name: "dismissable",
1014
+ type: "boolean",
1015
+ default: "true",
1016
+ description: "false hides the close button and turns off swipe to dismiss. Also accepted as dismissible."
1017
+ },
1018
+ {
1019
+ name: "position",
1020
+ type: "ToastPosition",
1021
+ description: "This toast's corner, instead of the Toaster's."
1022
+ },
1023
+ {
1024
+ name: "icon",
1025
+ type: "ReactNode",
1026
+ description: "Replaces the tone's icon. null shows none."
1027
+ },
1028
+ {
1029
+ name: "onDismiss",
1030
+ type: "(id) => void",
1031
+ description: "Runs when it is closed: its close button, a swipe or toast.dismiss."
1032
+ },
1033
+ {
1034
+ name: "onAutoClose",
1035
+ type: "(id) => void",
1036
+ description: "Runs when its time runs out."
1037
+ },
1038
+ {
1039
+ name: "toasterId",
1040
+ type: "string",
1041
+ description: "Sends it to the Toaster with this id, on a page with more than one."
1042
+ }
1043
+ ]
1044
+ }),
1045
+ /* @__PURE__ */ jsx(PropsTable, {
1046
+ title: "ToastAction",
1047
+ rows: [
1048
+ {
1049
+ name: "label",
1050
+ type: "ReactNode",
1051
+ required: true,
1052
+ description: "The button's words: a verb, like \"Undo\"."
1053
+ },
1054
+ {
1055
+ name: "onClick",
1056
+ type: "(event) => void | Promise<unknown>",
1057
+ required: true,
1058
+ description: "Runs on click, then the toast closes. Call event.preventDefault() to keep it. Return a promise to show the busy state until it settles."
1059
+ },
1060
+ {
1061
+ name: "altText",
1062
+ type: "string",
1063
+ description: "The accessible name, when the label needs context. Keep the label's words in it."
1064
+ },
1065
+ {
1066
+ name: "variant",
1067
+ type: "'default' | 'destructive'",
1068
+ default: "'default'",
1069
+ description: "destructive turns the button red."
1070
+ }
1071
+ ]
1072
+ }),
1073
+ /* @__PURE__ */ jsx(PropsTable, {
1074
+ title: "toast.promise options",
1075
+ rows: [
1076
+ {
1077
+ name: "loading",
1078
+ type: "ReactNode | { title, description? }",
1079
+ required: true,
1080
+ description: "Shown while the work runs."
1081
+ },
1082
+ {
1083
+ name: "success",
1084
+ type: "ReactNode | { title, description? } | (result) => …",
1085
+ description: "Shown when it resolves. Leave it out and the toast closes."
1086
+ },
1087
+ {
1088
+ name: "error",
1089
+ type: "ReactNode | { title, description? } | (error) => …",
1090
+ description: "Shown when it fails. Leave it out and the toast closes."
1091
+ },
1092
+ {
1093
+ name: "…",
1094
+ type: "Toast options",
1095
+ description: "Every toast option except description and icon. duration applies to the outcome."
1096
+ }
1097
+ ]
1098
+ }),
1099
+ /* @__PURE__ */ jsx(PropsTable, {
1100
+ title: "Toaster",
1101
+ rows: [
1102
+ {
1103
+ name: "position",
1104
+ type: "'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'",
1105
+ default: "'bottom-right'",
1106
+ description: "Where toasts appear."
1107
+ },
1108
+ {
1109
+ name: "gap",
1110
+ type: "number",
1111
+ default: "12",
1112
+ description: "Space between toasts when the stack fans out, and how far each folded toast peeks out."
1113
+ },
1114
+ {
1115
+ name: "offset",
1116
+ type: "number | string | { top, right, bottom, left }",
1117
+ default: "24px",
1118
+ description: "Distance from the window's edges."
1119
+ },
1120
+ {
1121
+ name: "mobileOffset",
1122
+ type: "number | string | { top, right, bottom, left }",
1123
+ default: "16px",
1124
+ description: "The same on screens up to 600px wide, where toasts span the width."
1125
+ },
1126
+ {
1127
+ name: "visibleToasts",
1128
+ type: "number",
1129
+ default: "3",
1130
+ description: "How many show in the stack at once."
1131
+ },
1132
+ {
1133
+ name: "expand",
1134
+ type: "boolean",
1135
+ default: "false",
1136
+ description: "Keep the stack fanned out instead of folded."
1137
+ },
1138
+ {
1139
+ name: "closeLabel",
1140
+ type: "string",
1141
+ default: "'Dismiss'",
1142
+ description: "Accessible name of each toast's close button."
1143
+ },
1144
+ {
1145
+ name: "hotkey",
1146
+ type: "string[]",
1147
+ default: "['altKey', 'KeyT']",
1148
+ description: "Keys that focus the toasts and fan them out. An empty array turns it off."
1149
+ },
1150
+ {
1151
+ name: "containerAriaLabel",
1152
+ type: "string",
1153
+ default: "'Notifications'",
1154
+ description: "Name of the region that holds the toasts."
1155
+ },
1156
+ {
1157
+ name: "container",
1158
+ type: "HTMLElement | null",
1159
+ default: "document.body",
1160
+ description: "Where the toasts are portalled."
1161
+ },
1162
+ {
1163
+ name: "id",
1164
+ type: "string",
1165
+ description: "Names this Toaster, for toasts sent with toasterId."
1166
+ }
1167
+ ]
1168
+ })
1169
+ ]
1170
+ }),
1171
+ /* @__PURE__ */ jsx(Toaster, {})
1172
+ ]
1173
+ });
1174
+ }
1175
+ //#endregion
1176
+ export { Page, Preview };