@plexui/ui 0.29.0 → 0.31.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 (175) hide show
  1. package/dist/es/components/Alert/Alert.js +2 -2
  2. package/dist/es/components/Alert/Alert.js.map +1 -1
  3. package/dist/es/components/Avatar/Avatar.js +3 -1
  4. package/dist/es/components/Avatar/Avatar.js.map +1 -1
  5. package/dist/es/components/ButtonGroup/ButtonGroup.js +1 -1
  6. package/dist/es/components/ButtonGroup/ButtonGroup.js.map +1 -1
  7. package/dist/es/components/ButtonGroup/index.js.map +1 -1
  8. package/dist/es/components/Checkbox/Checkbox.js +1 -3
  9. package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
  10. package/dist/es/components/ColorPicker/ColorPicker.js +227 -0
  11. package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -0
  12. package/dist/es/components/ColorPicker/ColorWell.js +58 -0
  13. package/dist/es/components/ColorPicker/ColorWell.js.map +1 -0
  14. package/dist/es/components/ColorPicker/index.js +3 -0
  15. package/dist/es/components/ColorPicker/index.js.map +1 -0
  16. package/dist/es/components/ColorPicker/shared.js +132 -0
  17. package/dist/es/components/ColorPicker/shared.js.map +1 -0
  18. package/dist/es/components/ContextMenu/ContextMenu.js +164 -0
  19. package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -0
  20. package/dist/es/components/ContextMenu/index.js +2 -0
  21. package/dist/es/components/ContextMenu/index.js.map +1 -0
  22. package/dist/es/components/ContextMenu/shared.js +57 -0
  23. package/dist/es/components/ContextMenu/shared.js.map +1 -0
  24. package/dist/es/components/DatePicker/DatePicker.js +4 -2
  25. package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
  26. package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
  27. package/dist/es/components/Dialog/Dialog.js +118 -24
  28. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  29. package/dist/es/components/Dialog/dialogSteps.js +85 -0
  30. package/dist/es/components/Dialog/dialogSteps.js.map +1 -0
  31. package/dist/es/components/Dialog/dialogViewport.js +74 -0
  32. package/dist/es/components/Dialog/dialogViewport.js.map +1 -0
  33. package/dist/es/components/Dialog/index.js +1 -1
  34. package/dist/es/components/Dialog/index.js.map +1 -1
  35. package/dist/es/components/Dialog/sheetDrag.js +2 -1
  36. package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
  37. package/dist/es/components/Field/Field.js +3 -3
  38. package/dist/es/components/Field/Field.js.map +1 -1
  39. package/dist/es/components/FieldGroup/FieldGroup.js +4 -2
  40. package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
  41. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +2 -2
  42. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
  43. package/dist/es/components/Icon/index.js +1 -0
  44. package/dist/es/components/Icon/index.js.map +1 -1
  45. package/dist/es/components/Icon/svg/Eyedropper.js +6 -0
  46. package/dist/es/components/Icon/svg/Eyedropper.js.map +1 -0
  47. package/dist/es/components/IndexBar/IndexBar.js +164 -0
  48. package/dist/es/components/IndexBar/IndexBar.js.map +1 -0
  49. package/dist/es/components/IndexBar/index.js +2 -0
  50. package/dist/es/components/IndexBar/index.js.map +1 -0
  51. package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
  52. package/dist/es/components/Input/Input.js +2 -2
  53. package/dist/es/components/Input/Input.js.map +1 -1
  54. package/dist/es/components/MarkdownEditor/MarkdownEditor.js +142 -1
  55. package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
  56. package/dist/es/components/Menu/Menu.js +109 -29
  57. package/dist/es/components/Menu/Menu.js.map +1 -1
  58. package/dist/es/components/Page/Page.js +41 -14
  59. package/dist/es/components/Page/Page.js.map +1 -1
  60. package/dist/es/components/PageControl/PageControl.js +146 -0
  61. package/dist/es/components/PageControl/PageControl.js.map +1 -0
  62. package/dist/es/components/PageControl/index.js +2 -0
  63. package/dist/es/components/PageControl/index.js.map +1 -0
  64. package/dist/es/components/PhoneLayout/PhoneLayout.js +41 -0
  65. package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -0
  66. package/dist/es/components/PhoneLayout/index.js +2 -0
  67. package/dist/es/components/PhoneLayout/index.js.map +1 -0
  68. package/dist/es/components/Popover/Popover.js +2 -1
  69. package/dist/es/components/Popover/Popover.js.map +1 -1
  70. package/dist/es/components/Select/Select.js +11 -6
  71. package/dist/es/components/Select/Select.js.map +1 -1
  72. package/dist/es/components/SelectControl/SelectControl.js +1 -1
  73. package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
  74. package/dist/es/components/Sidebar/Sidebar.js +21 -8
  75. package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
  76. package/dist/es/components/Slider/Slider.js +43 -8
  77. package/dist/es/components/Slider/Slider.js.map +1 -1
  78. package/dist/es/components/Stepper/Stepper.js +114 -0
  79. package/dist/es/components/Stepper/Stepper.js.map +1 -0
  80. package/dist/es/components/Stepper/index.js +2 -0
  81. package/dist/es/components/Stepper/index.js.map +1 -0
  82. package/dist/es/components/SwipeActions/SwipeActions.js +321 -0
  83. package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -0
  84. package/dist/es/components/SwipeActions/index.js +2 -0
  85. package/dist/es/components/SwipeActions/index.js.map +1 -0
  86. package/dist/es/components/TabBar/TabBar.js +128 -0
  87. package/dist/es/components/TabBar/TabBar.js.map +1 -0
  88. package/dist/es/components/TabBar/index.js +2 -0
  89. package/dist/es/components/TabBar/index.js.map +1 -0
  90. package/dist/es/components/Tabs/Tabs.js +13 -6
  91. package/dist/es/components/Tabs/Tabs.js.map +1 -1
  92. package/dist/es/components/TagInput/TagInput.js +5 -65
  93. package/dist/es/components/TagInput/TagInput.js.map +1 -1
  94. package/dist/es/components/Textarea/Textarea.js +1 -1
  95. package/dist/es/components/Textarea/Textarea.js.map +1 -1
  96. package/dist/es/components/Tip/Tip.js +106 -0
  97. package/dist/es/components/Tip/Tip.js.map +1 -0
  98. package/dist/es/components/Tip/index.js +2 -0
  99. package/dist/es/components/Tip/index.js.map +1 -0
  100. package/dist/es/components/Toast/ToastRenderer.js +22 -9
  101. package/dist/es/components/Toast/ToastRenderer.js.map +1 -1
  102. package/dist/es/components/Toast/Toaster.js +17 -6
  103. package/dist/es/components/Toast/Toaster.js.map +1 -1
  104. package/dist/es/components/Toast/toastLifecycle.js +113 -1
  105. package/dist/es/components/Toast/toastLifecycle.js.map +1 -1
  106. package/dist/es/components/Toolbar/Toolbar.js +31 -5
  107. package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
  108. package/dist/es/components/Toolbar/index.js.map +1 -1
  109. package/dist/es/hooks/useEscCloseStack.js +10 -3
  110. package/dist/es/hooks/useEscCloseStack.js.map +1 -1
  111. package/dist/es/lib/fieldRow.js +7 -1
  112. package/dist/es/lib/fieldRow.js.map +1 -1
  113. package/dist/es/lib/floatingBoundary.js +3 -1
  114. package/dist/es/lib/floatingBoundary.js.map +1 -1
  115. package/dist/es/lib/helpers.js +21 -0
  116. package/dist/es/lib/helpers.js.map +1 -1
  117. package/dist/es/lib/menuSubmenuPlacement.js +51 -6
  118. package/dist/es/lib/menuSubmenuPlacement.js.map +1 -1
  119. package/dist/es/lib/menuTriggerCover.js +70 -0
  120. package/dist/es/lib/menuTriggerCover.js.map +1 -0
  121. package/dist/es/lib/phoneLayout.js +16 -0
  122. package/dist/es/lib/phoneLayout.js.map +1 -0
  123. package/dist/es/lib/scrollEdges.js +34 -0
  124. package/dist/es/lib/scrollEdges.js.map +1 -0
  125. package/dist/es/lib/toastRegion.js +6 -0
  126. package/dist/es/lib/toastRegion.js.map +1 -0
  127. package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +8 -1
  128. package/dist/types/components/ButtonGroup/index.d.ts +1 -1
  129. package/dist/types/components/ColorPicker/ColorPicker.d.ts +34 -0
  130. package/dist/types/components/ColorPicker/ColorWell.d.ts +32 -0
  131. package/dist/types/components/ColorPicker/index.d.ts +3 -0
  132. package/dist/types/components/ColorPicker/shared.d.ts +69 -0
  133. package/dist/types/components/ContextMenu/ContextMenu.d.ts +78 -0
  134. package/dist/types/components/ContextMenu/index.d.ts +1 -0
  135. package/dist/types/components/ContextMenu/shared.d.ts +51 -0
  136. package/dist/types/components/DatePicker/DatePicker.d.ts +6 -1
  137. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +1 -0
  138. package/dist/types/components/Dialog/Dialog.d.ts +52 -3
  139. package/dist/types/components/Dialog/dialogSteps.d.ts +10 -0
  140. package/dist/types/components/Dialog/dialogViewport.d.ts +1 -0
  141. package/dist/types/components/Dialog/index.d.ts +1 -1
  142. package/dist/types/components/Field/Field.d.ts +11 -2
  143. package/dist/types/components/FieldGroup/FieldGroup.d.ts +11 -2
  144. package/dist/types/components/Icon/index.d.ts +1 -0
  145. package/dist/types/components/Icon/svg/Eyedropper.d.ts +6 -0
  146. package/dist/types/components/IndexBar/IndexBar.d.ts +35 -0
  147. package/dist/types/components/IndexBar/index.d.ts +1 -0
  148. package/dist/types/components/Indicator/LoadingIndicator.d.ts +1 -1
  149. package/dist/types/components/Menu/Menu.d.ts +79 -10
  150. package/dist/types/components/Page/Page.d.ts +8 -4
  151. package/dist/types/components/PageControl/PageControl.d.ts +52 -0
  152. package/dist/types/components/PageControl/index.d.ts +1 -0
  153. package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +18 -0
  154. package/dist/types/components/PhoneLayout/index.d.ts +1 -0
  155. package/dist/types/components/Select/Select.d.ts +3 -3
  156. package/dist/types/components/Stepper/Stepper.d.ts +56 -0
  157. package/dist/types/components/Stepper/index.d.ts +1 -0
  158. package/dist/types/components/SwipeActions/SwipeActions.d.ts +46 -0
  159. package/dist/types/components/SwipeActions/index.d.ts +1 -0
  160. package/dist/types/components/TabBar/TabBar.d.ts +88 -0
  161. package/dist/types/components/TabBar/index.d.ts +1 -0
  162. package/dist/types/components/Tip/Tip.d.ts +57 -0
  163. package/dist/types/components/Tip/index.d.ts +1 -0
  164. package/dist/types/components/Toast/toastLifecycle.d.ts +34 -0
  165. package/dist/types/components/Toolbar/Toolbar.d.ts +19 -5
  166. package/dist/types/components/Toolbar/index.d.ts +1 -1
  167. package/dist/types/hooks/useEscCloseStack.d.ts +5 -1
  168. package/dist/types/lib/fieldRow.d.ts +6 -0
  169. package/dist/types/lib/helpers.d.ts +6 -0
  170. package/dist/types/lib/menuSubmenuPlacement.d.ts +14 -1
  171. package/dist/types/lib/menuTriggerCover.d.ts +23 -0
  172. package/dist/types/lib/phoneLayout.d.ts +11 -0
  173. package/dist/types/lib/scrollEdges.d.ts +16 -0
  174. package/dist/types/lib/toastRegion.d.ts +5 -0
  175. package/package.json +2 -2
@@ -0,0 +1,106 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ import { Popover as RadixPopover } from "radix-ui";
5
+ import { useEffect, useId, useRef, useState } from "react";
6
+ import s from "@plexui/styles/components/Tip/Tip.module.css";
7
+ import { useEscCloseStack } from "../../hooks/useEscCloseStack.js";
8
+ import { preventDefaultHandler } from "../../lib/helpers.js";
9
+ import { Button } from "../Button/index.js";
10
+ import { X } from "../Icon/index.js";
11
+ import { TransitionGroup } from "../Transition/index.js";
12
+ import { overlayTiming } from "../Transition/shared.js";
13
+ const TipBody = ({ title, description, icon, actions, mobileActions, onClose, arrowEdge, className, ref, titleId, descriptionId, role }) => (_jsxs("div", { ref: ref, className: clsx(s.Tip, className), role: role, "aria-labelledby": role ? titleId : undefined, "data-arrow-edge": arrowEdge, "data-mobile-actions": mobileActions === "buttons" ? mobileActions : undefined, children: [icon && _jsx("div", { className: s.Icon, children: icon }), _jsxs("div", { className: s.Message, children: [_jsx("div", { className: s.Title, id: titleId, children: title }), description && _jsx("div", { className: s.Description, id: descriptionId, children: description })] }), actions && _jsx("div", { className: s.Actions, children: actions }), onClose && (_jsx(Button, { type: "button", onClick: onClose, color: "secondary", variant: "soft", uniform: true, pill: true, "aria-label": "Close tip", className: s.Close, children: _jsx(X, {}) }))] }));
14
+ /** A tip inside the page, after TipKit: a title, a description, an optional symbol, actions and Close. */
15
+ export const Tip = ({ ref, ...props }) => {
16
+ const id = useId();
17
+ return _jsx(TipBody, { ...props, ref: ref, titleId: `${id}-title`, descriptionId: `${id}-description`, role: "note" });
18
+ };
19
+ const TABBABLE = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), [contenteditable="true"]';
20
+ // What Tab can reach: no focus guards, nothing hidden (checkVisibility where the browser has it)
21
+ const tabbables = (root) => [...root.querySelectorAll(TABBABLE)].filter((element) => element.tabIndex >= 0 &&
22
+ !element.closest("[hidden], [inert], [data-radix-focus-guard], [data-reka-focus-guard]") &&
23
+ (typeof element.checkVisibility !== "function" || element.checkVisibility({ visibilityProperty: true })));
24
+ // The first element Tab reaches after the control, outside the tip
25
+ const nextAfter = (control, tip) => tabbables(control.ownerDocument).find((element) => !tip.contains(element) &&
26
+ !control.contains(element) &&
27
+ !!(control.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_FOLLOWING));
28
+ // Takes the Tab only when the focus moved
29
+ const focusInstead = (event, element) => {
30
+ if (!element)
31
+ return;
32
+ element.focus();
33
+ if (element.ownerDocument.activeElement === element)
34
+ event.preventDefault();
35
+ };
36
+ // A popover tip renders at the end of the page, but Tab reaches it as if it sat right after its control: from the
37
+ // control (or its last control) Tab moves into the tip, and Shift+Tab from what follows the control moves to the
38
+ // tip's last control. Listened for on the document, after the control's own handlers.
39
+ const tabIntoTip = (event, control, tip) => {
40
+ if (event.key !== "Tab" || event.defaultPrevented || !(event.target instanceof Node) || tip.contains(event.target))
41
+ return;
42
+ const items = tabbables(tip);
43
+ if (event.shiftKey) {
44
+ if (event.target === nextAfter(control, tip))
45
+ focusInstead(event, items.at(-1));
46
+ }
47
+ else if (event.target === (tabbables(control).at(-1) ?? control)) {
48
+ focusInstead(event, items[0]);
49
+ }
50
+ };
51
+ // Shift+Tab from the tip's first control returns to the control; Tab from its last moves on to what follows it
52
+ const tabOutOfTip = (event, control, tip) => {
53
+ if (event.key !== "Tab" || event.defaultPrevented)
54
+ return;
55
+ const items = tabbables(tip);
56
+ if (event.shiftKey) {
57
+ if (event.target === items[0])
58
+ focusInstead(event, tabbables(control).at(-1) ?? (control.tabIndex >= 0 ? control : undefined));
59
+ }
60
+ else if (event.target === items.at(-1)) {
61
+ focusInstead(event, nextAfter(control, tip));
62
+ }
63
+ };
64
+ /** A tip anchored to a control, after TipKit's popover tip. It does not take the focus. */
65
+ const TipPopover = ({ open: controlledOpen, defaultOpen = false, onOpenChange, children, side = "bottom", align = "center", sideOffset = 4, closeButton = true, className, ...content }) => {
66
+ const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
67
+ const open = controlledOpen ?? uncontrolledOpen;
68
+ const setOpen = (next) => {
69
+ if (controlledOpen === undefined)
70
+ setUncontrolledOpen(next);
71
+ onOpenChange?.(next);
72
+ };
73
+ const anchorRef = useRef(null);
74
+ const contentRef = useRef(null);
75
+ const id = useId();
76
+ const titleId = `${id}-title`;
77
+ const descriptionId = `${id}-description`;
78
+ useEscCloseStack(open, () => setOpen(false));
79
+ // Radix waits for the click that completes a press outside before it closes the tip; a press on the control
80
+ // does not close it. The tip never takes the focus, so focus moving elsewhere does not close it either.
81
+ const isOnControl = (target) => target instanceof Node && !!anchorRef.current?.contains(target);
82
+ // Tab reaches the tip as if it sat right after the control
83
+ useEffect(() => {
84
+ if (!open)
85
+ return;
86
+ const doc = anchorRef.current?.ownerDocument ?? document;
87
+ const onKeyDown = (event) => {
88
+ if (anchorRef.current && contentRef.current)
89
+ tabIntoTip(event, anchorRef.current, contentRef.current);
90
+ };
91
+ doc.addEventListener("keydown", onKeyDown);
92
+ return () => doc.removeEventListener("keydown", onKeyDown);
93
+ }, [open]);
94
+ const onTipKeyDown = (event) => {
95
+ if (anchorRef.current && contentRef.current)
96
+ tabOutOfTip(event.nativeEvent, anchorRef.current, contentRef.current);
97
+ };
98
+ return (_jsxs(RadixPopover.Root, { open: open, onOpenChange: setOpen, modal: false, children: [_jsx(RadixPopover.Anchor, { asChild: true, ref: anchorRef, children: children }), _jsx(RadixPopover.Portal, { forceMount: true, children: _jsx(TransitionGroup, { className: s.Transition, ...overlayTiming, overlay: true, children: open && (_jsxs(RadixPopover.Content, { ref: contentRef, forceMount: true, className: clsx(s.Popover, className), side: side, align: align, sideOffset: sideOffset,
99
+ // The arrow stays clear of the tip's corners
100
+ arrowPadding: 26, collisionPadding: 16, hideWhenDetached: true, "aria-labelledby": titleId, "aria-describedby": content.description ? descriptionId : undefined, onOpenAutoFocus: preventDefaultHandler, onCloseAutoFocus: preventDefaultHandler, onEscapeKeyDown: preventDefaultHandler, onPointerDownOutside: (event) => {
101
+ if (isOnControl(event.detail.originalEvent.target))
102
+ event.preventDefault();
103
+ }, onFocusOutside: preventDefaultHandler, onKeyDown: onTipKeyDown, children: [_jsx(TipBody, { ...content, onClose: closeButton ? () => setOpen(false) : undefined, titleId: titleId, descriptionId: descriptionId }), _jsx(RadixPopover.Arrow, { asChild: true, width: 47, height: 13, children: _jsx("span", { className: s.Arrow }) })] }, "tip")) }) })] }));
104
+ };
105
+ Tip.Popover = TipPopover;
106
+ //# sourceMappingURL=Tip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tip.js","sourceRoot":"","sources":["../../../../src/components/Tip/Tip.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAmE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3H,OAAO,CAAC,MAAM,8CAA8C,CAAA;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,qBAAqB,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EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,YAC/C,eAAM,SAAS,EAAE,CAAC,CAAC,KAAK,GAAI,GACT,KAzBjB,KAAK,CA0BY,CACxB,GACe,GACE,IACJ,CACrB,CAAA;AACH,CAAC,CAAA;AAED,GAAG,CAAC,OAAO,GAAG,UAAU,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Popover as RadixPopover } from \"radix-ui\"\nimport { type KeyboardEvent, type ReactElement, type ReactNode, type Ref, useEffect, useId, useRef, useState } from \"react\"\nimport s from \"@plexui/styles/components/Tip/Tip.module.css\"\nimport { useEscCloseStack } from \"../../hooks/useEscCloseStack\"\nimport { preventDefaultHandler } from \"../../lib/helpers\"\nimport { Button } from \"../Button\"\nimport { X } from \"../Icon\"\nimport { TransitionGroup } from \"../Transition\"\nimport { overlayTiming } from \"../Transition/shared\"\n\n/** The edge of an inline tip that points at what it explains. */\nexport type TipArrowEdge = \"top\" | \"bottom\" | \"left\" | \"right\"\n\n/** How a tip's actions show on a phone. */\nexport type TipMobileActions = \"rows\" | \"buttons\"\n\ntype TipContentProps = {\n /** The tip's title: what the feature is. */\n title: ReactNode\n /** One or two sentences on how to use it. */\n description?: ReactNode\n /** A symbol or image that leads the message, as a TipKit tip's image. */\n icon?: ReactNode\n /** Buttons for the tip's actions, side by side below the message. */\n actions?: ReactNode\n /**\n * How the actions show at 767px and below: rows of text under a separator, as iOS tips show them, or the buttons\n * as given, each a full-width capsule under the message, as an iOS card that asks for a permission.\n * @default \"rows\"\n */\n mobileActions?: TipMobileActions\n}\n\nexport type TipProps = TipContentProps & {\n /** Shows the Close button; called when it is clicked. */\n onClose?: () => void\n /** Draws an arrow at this edge, pointing at what the tip explains (TipKit's annotation). */\n arrowEdge?: TipArrowEdge\n /** Class applied to the tip */\n className?: string\n /** Ref applied to the tip */\n ref?: Ref<HTMLDivElement>\n}\n\ntype TipBodyProps = TipContentProps & {\n onClose?: () => void\n arrowEdge?: TipArrowEdge\n className?: string\n ref?: Ref<HTMLDivElement>\n titleId: string\n descriptionId: string\n role?: string\n}\n\nconst TipBody = ({ title, description, icon, actions, mobileActions, onClose, arrowEdge, className, ref, titleId, descriptionId, role }: TipBodyProps) => (\n <div\n ref={ref}\n className={clsx(s.Tip, className)}\n role={role}\n aria-labelledby={role ? titleId : undefined}\n data-arrow-edge={arrowEdge}\n data-mobile-actions={mobileActions === \"buttons\" ? mobileActions : undefined}\n >\n {icon && <div className={s.Icon}>{icon}</div>}\n <div className={s.Message}>\n <div className={s.Title} id={titleId}>{title}</div>\n {description && <div className={s.Description} id={descriptionId}>{description}</div>}\n </div>\n {actions && <div className={s.Actions}>{actions}</div>}\n {onClose && (\n <Button type=\"button\" onClick={onClose} color=\"secondary\" variant=\"soft\" uniform pill aria-label=\"Close tip\" className={s.Close}>\n <X />\n </Button>\n )}\n </div>\n)\n\n/** A tip inside the page, after TipKit: a title, a description, an optional symbol, actions and Close. */\nexport const Tip = ({ ref, ...props }: TipProps) => {\n const id = useId()\n return <TipBody {...props} ref={ref} titleId={`${id}-title`} descriptionId={`${id}-description`} role=\"note\" />\n}\n\nexport type TipPopoverProps = TipContentProps & {\n /** Shows the tip (controlled). */\n open?: boolean\n /** Shows the tip at first (uncontrolled). @default false */\n defaultOpen?: boolean\n /** Called when the tip opens or closes: Close, Escape or a press outside closes it. */\n onOpenChange?: (open: boolean) => void\n /** The control the tip explains. It stays usable while the tip shows. */\n children: ReactElement\n /** The side of the control the tip shows on. Turned when it does not fit. @default bottom */\n side?: \"top\" | \"right\" | \"bottom\" | \"left\"\n /** The alignment against the control. @default center */\n align?: \"start\" | \"center\" | \"end\"\n /** The distance from the control to the arrow's point, in pixels. @default 4 */\n sideOffset?: number\n /** Shows the Close button. @default true */\n closeButton?: boolean\n /** Class applied to the popover around the tip and its arrow */\n className?: string\n}\n\nconst TABBABLE =\n 'a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]'\n\n// What Tab can reach: no focus guards, nothing hidden (checkVisibility where the browser has it)\nconst tabbables = (root: ParentNode) =>\n [...root.querySelectorAll<HTMLElement>(TABBABLE)].filter(\n (element) =>\n element.tabIndex >= 0 &&\n !element.closest(\"[hidden], [inert], [data-radix-focus-guard], [data-reka-focus-guard]\") &&\n (typeof element.checkVisibility !== \"function\" || element.checkVisibility({ visibilityProperty: true })),\n )\n\n// The first element Tab reaches after the control, outside the tip\nconst nextAfter = (control: HTMLElement, tip: HTMLElement) =>\n tabbables(control.ownerDocument).find(\n (element) =>\n !tip.contains(element) &&\n !control.contains(element) &&\n !!(control.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_FOLLOWING),\n )\n\n// Takes the Tab only when the focus moved\nconst focusInstead = (event: globalThis.KeyboardEvent, element: HTMLElement | undefined) => {\n if (!element) return\n element.focus()\n if (element.ownerDocument.activeElement === element) event.preventDefault()\n}\n\n// A popover tip renders at the end of the page, but Tab reaches it as if it sat right after its control: from the\n// control (or its last control) Tab moves into the tip, and Shift+Tab from what follows the control moves to the\n// tip's last control. Listened for on the document, after the control's own handlers.\nconst tabIntoTip = (event: globalThis.KeyboardEvent, control: HTMLElement, tip: HTMLElement) => {\n if (event.key !== \"Tab\" || event.defaultPrevented || !(event.target instanceof Node) || tip.contains(event.target)) return\n const items = tabbables(tip)\n if (event.shiftKey) {\n if (event.target === nextAfter(control, tip)) focusInstead(event, items.at(-1))\n } else if (event.target === (tabbables(control).at(-1) ?? control)) {\n focusInstead(event, items[0])\n }\n}\n\n// Shift+Tab from the tip's first control returns to the control; Tab from its last moves on to what follows it\nconst tabOutOfTip = (event: globalThis.KeyboardEvent, control: HTMLElement, tip: HTMLElement) => {\n if (event.key !== \"Tab\" || event.defaultPrevented) return\n const items = tabbables(tip)\n if (event.shiftKey) {\n if (event.target === items[0]) focusInstead(event, tabbables(control).at(-1) ?? (control.tabIndex >= 0 ? control : undefined))\n } else if (event.target === items.at(-1)) {\n focusInstead(event, nextAfter(control, tip))\n }\n}\n\n/** A tip anchored to a control, after TipKit's popover tip. It does not take the focus. */\nconst TipPopover = ({\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n children,\n side = \"bottom\",\n align = \"center\",\n sideOffset = 4,\n closeButton = true,\n className,\n ...content\n}: TipPopoverProps) => {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen)\n const open = controlledOpen ?? uncontrolledOpen\n const setOpen = (next: boolean) => {\n if (controlledOpen === undefined) setUncontrolledOpen(next)\n onOpenChange?.(next)\n }\n const anchorRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const id = useId()\n const titleId = `${id}-title`\n const descriptionId = `${id}-description`\n useEscCloseStack(open, () => setOpen(false))\n // Radix waits for the click that completes a press outside before it closes the tip; a press on the control\n // does not close it. The tip never takes the focus, so focus moving elsewhere does not close it either.\n const isOnControl = (target: EventTarget | null) => target instanceof Node && !!anchorRef.current?.contains(target)\n // Tab reaches the tip as if it sat right after the control\n useEffect(() => {\n if (!open) return\n const doc = anchorRef.current?.ownerDocument ?? document\n const onKeyDown = (event: globalThis.KeyboardEvent) => {\n if (anchorRef.current && contentRef.current) tabIntoTip(event, anchorRef.current, contentRef.current)\n }\n doc.addEventListener(\"keydown\", onKeyDown)\n return () => doc.removeEventListener(\"keydown\", onKeyDown)\n }, [open])\n const onTipKeyDown = (event: KeyboardEvent) => {\n if (anchorRef.current && contentRef.current) tabOutOfTip(event.nativeEvent, anchorRef.current, contentRef.current)\n }\n\n return (\n <RadixPopover.Root open={open} onOpenChange={setOpen} modal={false}>\n <RadixPopover.Anchor asChild ref={anchorRef}>{children}</RadixPopover.Anchor>\n <RadixPopover.Portal forceMount>\n <TransitionGroup className={s.Transition} {...overlayTiming} overlay>\n {open && (\n <RadixPopover.Content\n key=\"tip\"\n ref={contentRef}\n forceMount\n className={clsx(s.Popover, className)}\n side={side}\n align={align}\n sideOffset={sideOffset}\n // The arrow stays clear of the tip's corners\n arrowPadding={26}\n collisionPadding={16}\n hideWhenDetached\n aria-labelledby={titleId}\n aria-describedby={content.description ? descriptionId : undefined}\n onOpenAutoFocus={preventDefaultHandler}\n onCloseAutoFocus={preventDefaultHandler}\n onEscapeKeyDown={preventDefaultHandler}\n onPointerDownOutside={(event) => {\n if (isOnControl(event.detail.originalEvent.target)) event.preventDefault()\n }}\n onFocusOutside={preventDefaultHandler}\n onKeyDown={onTipKeyDown}\n >\n <TipBody {...content} onClose={closeButton ? () => setOpen(false) : undefined} titleId={titleId} descriptionId={descriptionId} />\n <RadixPopover.Arrow asChild width={47} height={13}>\n <span className={s.Arrow} />\n </RadixPopover.Arrow>\n </RadixPopover.Content>\n )}\n </TransitionGroup>\n </RadixPopover.Portal>\n </RadixPopover.Root>\n )\n}\n\nTip.Popover = TipPopover\n"]}
@@ -0,0 +1,2 @@
1
+ export { Tip } from "./Tip.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Tip/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiF,MAAM,OAAO,CAAA","sourcesContent":["export { Tip, type TipArrowEdge, type TipMobileActions, type TipPopoverProps, type TipProps } from \"./Tip\"\n"]}
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
- import { isValidElement, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
4
+ import { isValidElement, useCallback, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
5
5
  import { toast, useSonner } from "sonner";
6
6
  import { CheckCircle, InfoCircle, Warning, XCircle } from "../Icon/index.js";
7
- import { documentDirection, offsetStyles, ToastLifecycle } from "./toastLifecycle.js";
7
+ import { announcerStyle, documentDirection, offsetStyles, ToastLifecycle } from "./toastLifecycle.js";
8
8
  const CloseIcon = () => _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), _jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] });
9
9
  const fallbackIcons = { success: _jsx(CheckCircle, { "aria-hidden": "true" }), error: _jsx(XCircle, { "aria-hidden": "true" }), warning: _jsx(Warning, { "aria-hidden": "true" }), info: _jsx(InfoCircle, { "aria-hidden": "true" }) };
10
10
  const actionObject = (value) => typeof value === "object" && value !== null && "label" in value;
@@ -21,6 +21,11 @@ function ToastItem({ entry, lifecycle, props, index, count }) {
21
21
  const type = item.type === "normal" || item.type === "default" ? undefined : item.type;
22
22
  const iconKey = type && type in fallbackIcons ? type : undefined;
23
23
  const icon = item.icon !== undefined ? item.icon : iconKey ? props.icons?.[iconKey] !== undefined ? props.icons[iconKey] : fallbackIcons[iconKey] : undefined;
24
+ const custom = Boolean(item.jsx);
25
+ const alert = lifecycle.alertRole(entry, custom);
26
+ // After every render: a new toast, or new words in one (a promise that settles), is read once
27
+ useLayoutEffect(() => { if (node.current)
28
+ lifecycle.speak(item.id, node.current, custom); });
24
29
  useLayoutEffect(() => {
25
30
  const element = node.current;
26
31
  if (!element)
@@ -37,7 +42,10 @@ function ToastItem({ entry, lifecycle, props, index, count }) {
37
42
  observer?.observe(element);
38
43
  for (const child of element.children)
39
44
  observer?.observe(child);
40
- return () => { observer?.disconnect(); lifecycle.setNode(item.id, null); };
45
+ // A custom toast that changes its own words, without a new render here, is read again too
46
+ const words = typeof MutationObserver !== "undefined" ? new MutationObserver(() => lifecycle.speak(item.id, element, Boolean(item.jsx))) : null;
47
+ words?.observe(element, { childList: true, characterData: true, subtree: true });
48
+ return () => { observer?.disconnect(); words?.disconnect(); lifecycle.setNode(item.id, null); };
41
49
  }, [item, lifecycle]);
42
50
  const actionButton = (kind) => {
43
51
  const action = item[kind];
@@ -54,7 +62,7 @@ function ToastItem({ entry, lifecycle, props, index, count }) {
54
62
  lifecycle.close(item.id, "action");
55
63
  }, children: action.label });
56
64
  };
57
- return _jsxs("li", { ref: node, tabIndex: visible && !entry.removed ? 0 : -1, inert: !visible || entry.removed || undefined, "aria-hidden": !visible || entry.removed || undefined, className: clsx(props.toastOptions?.className, item.className, slot("toast"), slot("default"), type && slot(type)), "data-sonner-toast": "", "data-rich-colors": item.richColors ?? props.richColors, "data-styled": !Boolean(item.jsx || item.unstyled || props.toastOptions?.unstyled), "data-mounted": entry.mounted, "data-promise": Boolean(item.promise), "data-swiped": Boolean(entry.x || entry.y), "data-removed": entry.removed, "data-visible": visible, "data-y-position": y, "data-x-position": x, "data-index": index, "data-front": index === 0, "data-swiping": entry.swiping, "data-dismissible": item.dismissible !== false, "data-type": type, "data-invert": item.invert || props.invert, "data-swipe-out": Boolean(entry.swipeOut), "data-swipe-direction": entry.swipeOut, "data-expanded": lifecycle.expanded || Boolean(props.expand && entry.mounted), "data-testid": item.testId, style: { "--index": index, "--toasts-before": index, "--z-index": count - index, "--offset": `${lifecycle.offset(entry)}px`, "--initial-height": props.expand ? "auto" : `${entry.height}px`, "--swipe-amount-x": `${entry.x}px`, "--swipe-amount-y": `${entry.y}px`, ...props.toastOptions?.style, ...item.style }, onPointerDown: (event) => lifecycle.pointerDown(item.id, event.nativeEvent), onPointerMove: (event) => lifecycle.pointerMove(item.id, event.nativeEvent), onPointerUp: (event) => lifecycle.pointerEnd(item.id, event.nativeEvent), onPointerCancel: (event) => lifecycle.pointerEnd(item.id, event.nativeEvent, true), onLostPointerCapture: (event) => lifecycle.pointerEnd(item.id, event.nativeEvent, true), children: [(item.closeButton ?? props.toastOptions?.closeButton ?? props.closeButton) && !item.jsx && item.type !== "loading" && _jsx("button", { type: "button", "aria-label": props.toastOptions?.closeButtonAriaLabel ?? "Close toast", "data-disabled": disabled, disabled: disabled, "data-close-button": "true", className: slot("closeButton"), onClick: () => lifecycle.close(item.id, "dismiss"), children: props.icons?.close ?? _jsx(CloseIcon, {}) }), (type || item.icon || item.promise) && item.icon !== null && icon !== null && _jsxs("div", { "data-icon": "", className: slot("icon"), children: [item.promise || item.type === "loading" ? item.icon ?? _jsx("div", { className: clsx("sonner-loading-wrapper", slot("loader")), "data-visible": item.type === "loading", children: props.icons?.loading ? _jsx("div", { className: "sonner-loader", "data-visible": item.type === "loading", children: props.icons.loading }) : _jsx("div", { className: "sonner-spinner", children: Array.from({ length: 12 }, (_, i) => _jsx("div", { className: "sonner-loading-bar" }, i)) }) }) : null, item.type !== "loading" ? icon : null] }), _jsxs("div", { "data-content": "", className: slot("content"), children: [_jsx("div", { "data-title": "", className: slot("title"), children: item.jsx ?? content(item.title) }), item.description ? _jsx("div", { "data-description": "", className: clsx(props.toastOptions?.descriptionClassName, item.descriptionClassName, slot("description")), children: content(item.description) }) : null] }), actionButton("cancel"), actionButton("action")] });
65
+ return _jsxs("li", { ref: node, tabIndex: visible && !entry.removed ? 0 : -1, inert: !visible || entry.removed || undefined, "aria-hidden": !visible || entry.removed || undefined, className: clsx(props.toastOptions?.className, item.className, slot("toast"), slot("default"), type && slot(type)), "data-sonner-toast": "", "data-rich-colors": item.richColors ?? props.richColors, "data-styled": !Boolean(item.jsx || item.unstyled || props.toastOptions?.unstyled), "data-mounted": entry.mounted, "data-promise": Boolean(item.promise), "data-swiped": Boolean(entry.x || entry.y), "data-removed": entry.removed, "data-visible": visible, "data-y-position": y, "data-x-position": x, "data-index": index, "data-front": index === 0, "data-swiping": entry.swiping, "data-dismissible": item.dismissible !== false, "data-type": type, "data-invert": item.invert || props.invert, "data-swipe-out": Boolean(entry.swipeOut), "data-swipe-direction": entry.swipeOut, "data-expanded": lifecycle.expanded || Boolean(props.expand && entry.mounted), "data-testid": item.testId, style: { "--index": index, "--toasts-before": index, "--z-index": count - index, "--offset": `${lifecycle.offset(entry)}px`, "--initial-height": props.expand ? "auto" : `${entry.height}px`, "--swipe-amount-x": `${entry.x}px`, "--swipe-amount-y": `${entry.y}px`, ...props.toastOptions?.style, ...item.style }, onPointerDown: (event) => lifecycle.pointerDown(item.id, event.nativeEvent), onPointerMove: (event) => lifecycle.pointerMove(item.id, event.nativeEvent), onPointerUp: (event) => lifecycle.pointerEnd(item.id, event.nativeEvent), onPointerCancel: (event) => lifecycle.pointerEnd(item.id, event.nativeEvent, true), onLostPointerCapture: (event) => lifecycle.pointerEnd(item.id, event.nativeEvent, true), children: [(item.closeButton ?? props.toastOptions?.closeButton ?? props.closeButton) && !item.jsx && item.type !== "loading" && _jsx("button", { type: "button", "aria-label": props.toastOptions?.closeButtonAriaLabel ?? "Close toast", "data-disabled": disabled, disabled: disabled, "data-close-button": "true", className: slot("closeButton"), onClick: () => lifecycle.close(item.id, "dismiss"), children: props.icons?.close ?? _jsx(CloseIcon, {}) }), (type || item.icon || item.promise) && item.icon !== null && icon !== null && _jsxs("div", { "data-icon": "", className: slot("icon"), children: [item.promise || item.type === "loading" ? item.icon ?? _jsx("div", { className: clsx("sonner-loading-wrapper", slot("loader")), "data-visible": item.type === "loading", children: props.icons?.loading ? _jsx("div", { className: "sonner-loader", "data-visible": item.type === "loading", children: props.icons.loading }) : _jsx("div", { className: "sonner-spinner", children: Array.from({ length: 12 }, (_, i) => _jsx("div", { className: "sonner-loading-bar" }, i)) }) }) : null, item.type !== "loading" ? icon : null] }), _jsxs("div", { "data-content": "", role: alert ? "alert" : undefined, className: slot("content"), children: [_jsx("div", { "data-title": "", className: slot("title"), children: item.jsx ?? content(item.title) }), item.description ? _jsx("div", { "data-description": "", className: clsx(props.toastOptions?.descriptionClassName, item.descriptionClassName, slot("description")), children: content(item.description) }) : null] }), actionButton("cancel"), actionButton("action")] });
58
66
  }
59
67
  /** Owns presentation/interaction only; Sonner remains the public toast store. */
60
68
  export function ToastRenderer(props) {
@@ -75,12 +83,17 @@ export function ToastRenderer(props) {
75
83
  useEffect(() => {
76
84
  lifecycle.sync(toasts, { id: props.id, position: props.position ?? "bottom-right", duration: props.toastOptions?.duration ?? props.duration ?? 4000, gap: props.gap ?? 14, visibleToasts: props.visibleToasts ?? 3, expand: props.expand, swipeDirections: props.swipeDirections });
77
85
  }, [lifecycle, toasts, props.id, props.position, props.duration, props.toastOptions?.duration, props.gap, props.visibleToasts, props.expand, props.swipeDirections]);
86
+ const region = useCallback((node) => lifecycle.setRegion(node), [lifecycle]);
87
+ const polite = useCallback((node) => lifecycle.setAnnouncer("polite", node), [lifecycle]);
88
+ const assertive = useCallback((node) => lifecycle.setAnnouncer("assertive", node), [lifecycle]);
78
89
  const positions = [...new Set(lifecycle.entries.map((entry) => lifecycle.position(entry)))];
79
90
  const dir = props.dir === "auto" || !props.dir ? documentDirection(typeof document === "undefined" ? undefined : document) : props.dir;
80
- return _jsx("section", { "aria-label": `${props.containerAriaLabel ?? "Notifications"} ${hotkeyKey.replace(/Key|Digit/g, "")}`, tabIndex: -1, "aria-live": "polite", "aria-relevant": "additions text", "aria-atomic": false, children: positions.map((position) => {
81
- const entries = lifecycle.at(position);
82
- const [y, x] = position.split("-");
83
- return _jsx("ol", { ref: (node) => lifecycle.setList(position, node), dir: dir, tabIndex: -1, className: props.className, "data-sonner-toaster": "true", "data-sonner-theme": props.theme ?? "light", "data-y-position": y, "data-x-position": x, style: { "--front-toast-height": `${entries.find((entry) => !entry.removed)?.height ?? 0}px`, "--width": "356px", "--gap": `${props.gap ?? 14}px`, ...props.style, ...offsetStyles(props.offset, props.mobileOffset) }, onFocus: (event) => lifecycle.focusIn(event.nativeEvent), onBlur: (event) => lifecycle.focusOut(event.nativeEvent), onPointerEnter: (event) => lifecycle.pointerEnter(event.nativeEvent), onMouseEnter: () => lifecycle.hover(true), onMouseMove: () => lifecycle.hover(true), onMouseLeave: () => lifecycle.hover(false), children: entries.map((entry, index) => _jsx(ToastItem, { entry: entry, lifecycle: lifecycle, props: props, index: index, count: entries.length }, entry.toast.id)) }, position);
84
- }) });
91
+ // aria-live="off": not a live region itself (an announcer or an alert's role speaks, once), but a modal's
92
+ // aria-hidden on everything else (Radix and Reka call aria-hidden's hideOthers) keeps any [aria-live]
93
+ return _jsxs("section", { ref: region, "aria-label": `${props.containerAriaLabel ?? "Notifications"} ${hotkeyKey.replace(/Key|Digit/g, "")}`, tabIndex: -1, "aria-live": "off", children: [_jsx("div", { ref: polite, role: "status", "aria-live": "polite", "aria-atomic": "false", "data-toast-announcer": "polite", style: announcerStyle }), _jsx("div", { ref: assertive, role: "alert", "aria-live": "assertive", "aria-atomic": "false", "data-toast-announcer": "assertive", style: announcerStyle }), positions.map((position) => {
94
+ const entries = lifecycle.at(position);
95
+ const [y, x] = position.split("-");
96
+ return _jsx("ol", { ref: (node) => lifecycle.setList(position, node), dir: dir, tabIndex: -1, className: props.className, "data-sonner-toaster": "true", "data-sonner-theme": props.theme ?? "light", "data-y-position": y, "data-x-position": x, style: { "--front-toast-height": `${entries.find((entry) => !entry.removed)?.height ?? 0}px`, "--width": "356px", "--gap": `${props.gap ?? 14}px`, ...props.style, ...offsetStyles(props.offset, props.mobileOffset) }, onFocus: (event) => lifecycle.focusIn(event.nativeEvent), onBlur: (event) => lifecycle.focusOut(event.nativeEvent), onPointerEnter: (event) => lifecycle.pointerEnter(event.nativeEvent), onMouseEnter: () => lifecycle.hover(true), onMouseMove: () => lifecycle.hover(true), onMouseLeave: () => lifecycle.hover(false), children: entries.map((entry, index) => _jsx(ToastItem, { entry: entry, lifecycle: lifecycle, props: props, index: index, count: entries.length }, entry.toast.id)) }, position);
97
+ })] });
85
98
  }
86
99
  //# sourceMappingURL=ToastRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToastRenderer.js","sourceRoot":"","sources":["../../../../src/components/Toast/ToastRenderer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,oB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AC,KAAK,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,EAAmB,EACvO,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,EAClH,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,YACpM,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAC,SAAS,IAAsB,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,IAArG,KAAK,CAAC,KAAK,CAAC,EAAE,CAA2F,CAAC,IAL3I,QAAQ,CAMnB,CAAA;QACP,CAAC,CAAC,GACM,CAAA;AACZ,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { isValidElement, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode } from \"react\"\nimport { toast, useSonner, type Action, type ToastT, type ToasterProps } from \"sonner\"\nimport { CheckCircle, InfoCircle, Warning, XCircle } from \"../Icon\"\nimport { documentDirection, offsetStyles, ToastLifecycle, type Position, type ToastEntry } from \"./toastLifecycle\"\n\nconst CloseIcon = () => <svg xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" /><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" /></svg>\nconst fallbackIcons = { success: <CheckCircle aria-hidden=\"true\" />, error: <XCircle aria-hidden=\"true\" />, warning: <Warning aria-hidden=\"true\" />, info: <InfoCircle aria-hidden=\"true\" /> }\nconst actionObject = (value: Action | ReactNode): value is Action => typeof value === \"object\" && value !== null && \"label\" in value\nconst content = (value: ToastT[\"title\"]) => typeof value === \"function\" ? value() : value\n\nfunction ToastItem({ entry, lifecycle, props, index, count }: { entry: ToastEntry<ToastT>; lifecycle: ToastLifecycle<ToastT>; props: ToasterProps; index: number; count: number }) {\n const node = useRef<HTMLLIElement>(null)\n const item = entry.toast\n const classes = props.toastOptions?.classNames\n const slot = (name: keyof NonNullable<typeof classes>) => clsx(classes?.[name], item.classNames?.[name])\n const position = lifecycle.position(entry)\n const [y, x] = position.split(\"-\")\n const visible = index < (props.visibleToasts ?? 3)\n const disabled = item.dismissible === false || item.type === \"loading\"\n const type = item.type === \"normal\" || item.type === \"default\" ? undefined : item.type\n const iconKey = type && type in fallbackIcons ? type as keyof typeof fallbackIcons : undefined\n const icon = item.icon !== undefined ? item.icon : iconKey ? props.icons?.[iconKey] !== undefined ? props.icons[iconKey] : fallbackIcons[iconKey] : undefined\n useLayoutEffect(() => {\n const element = node.current\n if (!element) return\n lifecycle.setNode(item.id, element)\n const measure = () => {\n const height = element.style.height\n element.style.height = \"auto\"\n lifecycle.measure(item.id, element.offsetHeight || element.getBoundingClientRect().height)\n element.style.height = height\n }\n measure()\n const observer = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(measure) : null\n observer?.observe(element)\n for (const child of element.children) observer?.observe(child)\n return () => { observer?.disconnect(); lifecycle.setNode(item.id, null) }\n }, [item, lifecycle])\n const actionButton = (kind: \"action\" | \"cancel\") => {\n const action = item[kind]\n if (isValidElement(action)) return action\n if (!actionObject(action)) return null\n return <button type=\"button\" data-button=\"true\" {...{ [`data-${kind}`]: \"true\" }} disabled={kind === \"cancel\" && disabled}\n className={slot(kind === \"action\" ? \"actionButton\" : \"cancelButton\")}\n style={kind === \"action\" ? item.actionButtonStyle ?? props.toastOptions?.actionButtonStyle : item.cancelButtonStyle ?? props.toastOptions?.cancelButtonStyle}\n onClick={(event) => {\n if (kind === \"cancel\" && disabled) return\n action.onClick(event)\n if (kind === \"action\" && event.defaultPrevented) return\n lifecycle.close(item.id, \"action\")\n }}>{action.label}</button>\n }\n return <li ref={node} tabIndex={visible && !entry.removed ? 0 : -1} inert={!visible || entry.removed || undefined}\n aria-hidden={!visible || entry.removed || undefined}\n className={clsx(props.toastOptions?.className, item.className, slot(\"toast\"), slot(\"default\"), type && slot(type as keyof NonNullable<typeof classes>))}\n data-sonner-toast=\"\" data-rich-colors={item.richColors ?? props.richColors} data-styled={!Boolean(item.jsx || item.unstyled || props.toastOptions?.unstyled)}\n data-mounted={entry.mounted} data-promise={Boolean(item.promise)} data-swiped={Boolean(entry.x || entry.y)} data-removed={entry.removed}\n data-visible={visible} data-y-position={y} data-x-position={x} data-index={index} data-front={index === 0} data-swiping={entry.swiping}\n data-dismissible={item.dismissible !== false} data-type={type} data-invert={item.invert || props.invert}\n data-swipe-out={Boolean(entry.swipeOut)} data-swipe-direction={entry.swipeOut} data-expanded={lifecycle.expanded || Boolean(props.expand && entry.mounted)} data-testid={item.testId}\n style={{ \"--index\": index, \"--toasts-before\": index, \"--z-index\": count - index, \"--offset\": `${lifecycle.offset(entry)}px`, \"--initial-height\": props.expand ? \"auto\" : `${entry.height}px`, \"--swipe-amount-x\": `${entry.x}px`, \"--swipe-amount-y\": `${entry.y}px`, ...props.toastOptions?.style, ...item.style } as CSSProperties}\n onPointerDown={(event) => lifecycle.pointerDown(item.id, event.nativeEvent)} onPointerMove={(event) => lifecycle.pointerMove(item.id, event.nativeEvent)}\n onPointerUp={(event) => lifecycle.pointerEnd(item.id, event.nativeEvent)} onPointerCancel={(event) => lifecycle.pointerEnd(item.id, event.nativeEvent, true)}\n onLostPointerCapture={(event) => lifecycle.pointerEnd(item.id, event.nativeEvent, true)}>\n {(item.closeButton ?? props.toastOptions?.closeButton ?? props.closeButton) && !item.jsx && item.type !== \"loading\" && <button type=\"button\" aria-label={props.toastOptions?.closeButtonAriaLabel ?? \"Close toast\"} data-disabled={disabled} disabled={disabled} data-close-button=\"true\" className={slot(\"closeButton\")} onClick={() => lifecycle.close(item.id, \"dismiss\")}>{props.icons?.close ?? <CloseIcon />}</button>}\n {(type || item.icon || item.promise) && item.icon !== null && icon !== null && <div data-icon=\"\" className={slot(\"icon\")}>\n {item.promise || item.type === \"loading\" ? item.icon ?? <div className={clsx(\"sonner-loading-wrapper\", slot(\"loader\"))} data-visible={item.type === \"loading\"}>\n {props.icons?.loading ? <div className=\"sonner-loader\" data-visible={item.type === \"loading\"}>{props.icons.loading}</div> : <div className=\"sonner-spinner\">{Array.from({ length: 12 }, (_, i) => <div key={i} className=\"sonner-loading-bar\" />)}</div>}\n </div> : null}\n {item.type !== \"loading\" ? icon : null}\n </div>}\n <div data-content=\"\" className={slot(\"content\")}><div data-title=\"\" className={slot(\"title\")}>{item.jsx ?? content(item.title)}</div>\n {item.description ? <div data-description=\"\" className={clsx(props.toastOptions?.descriptionClassName, item.descriptionClassName, slot(\"description\"))}>{content(item.description)}</div> : null}</div>\n {actionButton(\"cancel\")}{actionButton(\"action\")}\n </li>\n}\n\n/** Owns presentation/interaction only; Sonner remains the public toast store. */\nexport function ToastRenderer(props: ToasterProps) {\n const { toasts } = useSonner()\n const [lifecycle] = useState(() => new ToastLifecycle<ToastT>(toast.dismiss, (reason, item) => reason === \"auto\" ? item.onAutoClose?.(item) : item.onDismiss?.(item)))\n useSyncExternalStore(lifecycle.subscribe, lifecycle.snapshot, lifecycle.snapshot)\n const hotkey = props.hotkey ?? [\"altKey\", \"KeyT\"]\n const hotkeyKey = hotkey.join(\"+\")\n useEffect(() => {\n lifecycle.connect(document)\n return () => lifecycle.disconnect()\n }, [lifecycle])\n useEffect(() => {\n const keydown = (event: KeyboardEvent) => lifecycle.keyDown(event, hotkeyKey ? hotkeyKey.split(\"+\") : [])\n document.addEventListener(\"keydown\", keydown)\n return () => document.removeEventListener(\"keydown\", keydown)\n }, [lifecycle, hotkeyKey])\n useEffect(() => {\n lifecycle.sync(toasts, { id: props.id, position: props.position ?? \"bottom-right\", duration: props.toastOptions?.duration ?? props.duration ?? 4000, gap: props.gap ?? 14, visibleToasts: props.visibleToasts ?? 3, expand: props.expand, swipeDirections: props.swipeDirections })\n }, [lifecycle, toasts, props.id, props.position, props.duration, props.toastOptions?.duration, props.gap, props.visibleToasts, props.expand, props.swipeDirections])\n const positions = [...new Set(lifecycle.entries.map((entry) => lifecycle.position(entry)))]\n const dir = props.dir === \"auto\" || !props.dir ? documentDirection(typeof document === \"undefined\" ? undefined : document) : props.dir\n return <section aria-label={`${props.containerAriaLabel ?? \"Notifications\"} ${hotkeyKey.replace(/Key|Digit/g, \"\")}`} tabIndex={-1} aria-live=\"polite\" aria-relevant=\"additions text\" aria-atomic={false}>\n {positions.map((position: Position) => {\n const entries = lifecycle.at(position)\n const [y, x] = position.split(\"-\")\n return <ol key={position} ref={(node) => lifecycle.setList(position, node)} dir={dir} tabIndex={-1} className={props.className}\n data-sonner-toaster=\"true\" data-sonner-theme={props.theme ?? \"light\"} data-y-position={y} data-x-position={x}\n style={{ \"--front-toast-height\": `${entries.find((entry) => !entry.removed)?.height ?? 0}px`, \"--width\": \"356px\", \"--gap\": `${props.gap ?? 14}px`, ...props.style, ...offsetStyles(props.offset, props.mobileOffset) } as CSSProperties}\n onFocus={(event) => lifecycle.focusIn(event.nativeEvent)} onBlur={(event) => lifecycle.focusOut(event.nativeEvent)}\n onPointerEnter={(event) => lifecycle.pointerEnter(event.nativeEvent)} onMouseEnter={() => lifecycle.hover(true)} onMouseMove={() => lifecycle.hover(true)} onMouseLeave={() => lifecycle.hover(false)}>\n {entries.map((entry, index) => <ToastItem key={entry.toast.id} entry={entry} lifecycle={lifecycle} props={props} index={index} count={entries.length} />)}\n </ol>\n })}\n </section>\n}\n"]}
1
+ {"version":3,"file":"ToastRenderer.js","sourceRoot":"","sources":["../../../../src/components/Toast/ToastRenderer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAsC,MAAM,OAAO,CAAA;AAC3J,OAAO,EAAE,KAAK,EAAE,SAAS,EAA+C,MAAM,QAAQ,CAAA;AACtF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,cAAc,EAAkC,MAAM,kBAAkB,CAAA;AAElI,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,eAAK,KAAK,EAAC,4BAA4B,iBAAa,MAAM,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,KAAK,EAAC,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,aAAC,eAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,GAAG,EAAA,eAAM,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,GAAG,IAAM,CAAA;AACjT,MAAM,aAAa,GA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I,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,YACpM,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAC,SAAS,IAAsB,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,IAArG,KAAK,CAAC,KAAK,CAAC,EAAE,CAA2F,CAAC,IAL3I,QAAQ,CAMnB,CAAA;YACP,CAAC,CAAC,IACM,CAAA;AACZ,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { isValidElement, useCallback, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode } from \"react\"\nimport { toast, useSonner, type Action, type ToastT, type ToasterProps } from \"sonner\"\nimport { CheckCircle, InfoCircle, Warning, XCircle } from \"../Icon\"\nimport { announcerStyle, documentDirection, offsetStyles, ToastLifecycle, type Position, type ToastEntry } from \"./toastLifecycle\"\n\nconst CloseIcon = () => <svg xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" /><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" /></svg>\nconst fallbackIcons = { success: <CheckCircle aria-hidden=\"true\" />, error: <XCircle aria-hidden=\"true\" />, warning: <Warning aria-hidden=\"true\" />, info: <InfoCircle aria-hidden=\"true\" /> }\nconst actionObject = (value: Action | ReactNode): value is Action => typeof value === \"object\" && value !== null && \"label\" in value\nconst content = (value: ToastT[\"title\"]) => typeof value === \"function\" ? value() : value\n\nfunction ToastItem({ entry, lifecycle, props, index, count }: { entry: ToastEntry<ToastT>; lifecycle: ToastLifecycle<ToastT>; props: ToasterProps; index: number; count: number }) {\n const node = useRef<HTMLLIElement>(null)\n const item = entry.toast\n const classes = props.toastOptions?.classNames\n const slot = (name: keyof NonNullable<typeof classes>) => clsx(classes?.[name], item.classNames?.[name])\n const position = lifecycle.position(entry)\n const [y, x] = position.split(\"-\")\n const visible = index < (props.visibleToasts ?? 3)\n const disabled = item.dismissible === false || item.type === \"loading\"\n const type = item.type === \"normal\" || item.type === \"default\" ? undefined : item.type\n const iconKey = type && type in fallbackIcons ? type as keyof typeof fallbackIcons : undefined\n const icon = item.icon !== undefined ? item.icon : iconKey ? props.icons?.[iconKey] !== undefined ? props.icons[iconKey] : fallbackIcons[iconKey] : undefined\n const custom = Boolean(item.jsx)\n const alert = lifecycle.alertRole(entry, custom)\n // After every render: a new toast, or new words in one (a promise that settles), is read once\n useLayoutEffect(() => { if (node.current) lifecycle.speak(item.id, node.current, custom) })\n useLayoutEffect(() => {\n const element = node.current\n if (!element) return\n lifecycle.setNode(item.id, element)\n const measure = () => {\n const height = element.style.height\n element.style.height = \"auto\"\n lifecycle.measure(item.id, element.offsetHeight || element.getBoundingClientRect().height)\n element.style.height = height\n }\n measure()\n const observer = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(measure) : null\n observer?.observe(element)\n for (const child of element.children) observer?.observe(child)\n // A custom toast that changes its own words, without a new render here, is read again too\n const words = typeof MutationObserver !== \"undefined\" ? new MutationObserver(() => lifecycle.speak(item.id, element, Boolean(item.jsx))) : null\n words?.observe(element, { childList: true, characterData: true, subtree: true })\n return () => { observer?.disconnect(); words?.disconnect(); lifecycle.setNode(item.id, null) }\n }, [item, lifecycle])\n const actionButton = (kind: \"action\" | \"cancel\") => {\n const action = item[kind]\n if (isValidElement(action)) return action\n if (!actionObject(action)) return null\n return <button type=\"button\" data-button=\"true\" {...{ [`data-${kind}`]: \"true\" }} disabled={kind === \"cancel\" && disabled}\n className={slot(kind === \"action\" ? \"actionButton\" : \"cancelButton\")}\n style={kind === \"action\" ? item.actionButtonStyle ?? props.toastOptions?.actionButtonStyle : item.cancelButtonStyle ?? props.toastOptions?.cancelButtonStyle}\n onClick={(event) => {\n if (kind === \"cancel\" && disabled) return\n action.onClick(event)\n if (kind === \"action\" && event.defaultPrevented) return\n lifecycle.close(item.id, \"action\")\n }}>{action.label}</button>\n }\n return <li ref={node} tabIndex={visible && !entry.removed ? 0 : -1} inert={!visible || entry.removed || undefined}\n aria-hidden={!visible || entry.removed || undefined}\n className={clsx(props.toastOptions?.className, item.className, slot(\"toast\"), slot(\"default\"), type && slot(type as keyof NonNullable<typeof classes>))}\n data-sonner-toast=\"\" data-rich-colors={item.richColors ?? props.richColors} data-styled={!Boolean(item.jsx || item.unstyled || props.toastOptions?.unstyled)}\n data-mounted={entry.mounted} data-promise={Boolean(item.promise)} data-swiped={Boolean(entry.x || entry.y)} data-removed={entry.removed}\n data-visible={visible} data-y-position={y} data-x-position={x} data-index={index} data-front={index === 0} data-swiping={entry.swiping}\n data-dismissible={item.dismissible !== false} data-type={type} data-invert={item.invert || props.invert}\n data-swipe-out={Boolean(entry.swipeOut)} data-swipe-direction={entry.swipeOut} data-expanded={lifecycle.expanded || Boolean(props.expand && entry.mounted)} data-testid={item.testId}\n style={{ \"--index\": index, \"--toasts-before\": index, \"--z-index\": count - index, \"--offset\": `${lifecycle.offset(entry)}px`, \"--initial-height\": props.expand ? \"auto\" : `${entry.height}px`, \"--swipe-amount-x\": `${entry.x}px`, \"--swipe-amount-y\": `${entry.y}px`, ...props.toastOptions?.style, ...item.style } as CSSProperties}\n onPointerDown={(event) => lifecycle.pointerDown(item.id, event.nativeEvent)} onPointerMove={(event) => lifecycle.pointerMove(item.id, event.nativeEvent)}\n onPointerUp={(event) => lifecycle.pointerEnd(item.id, event.nativeEvent)} onPointerCancel={(event) => lifecycle.pointerEnd(item.id, event.nativeEvent, true)}\n onLostPointerCapture={(event) => lifecycle.pointerEnd(item.id, event.nativeEvent, true)}>\n {(item.closeButton ?? props.toastOptions?.closeButton ?? props.closeButton) && !item.jsx && item.type !== \"loading\" && <button type=\"button\" aria-label={props.toastOptions?.closeButtonAriaLabel ?? \"Close toast\"} data-disabled={disabled} disabled={disabled} data-close-button=\"true\" className={slot(\"closeButton\")} onClick={() => lifecycle.close(item.id, \"dismiss\")}>{props.icons?.close ?? <CloseIcon />}</button>}\n {(type || item.icon || item.promise) && item.icon !== null && icon !== null && <div data-icon=\"\" className={slot(\"icon\")}>\n {item.promise || item.type === \"loading\" ? item.icon ?? <div className={clsx(\"sonner-loading-wrapper\", slot(\"loader\"))} data-visible={item.type === \"loading\"}>\n {props.icons?.loading ? <div className=\"sonner-loader\" data-visible={item.type === \"loading\"}>{props.icons.loading}</div> : <div className=\"sonner-spinner\">{Array.from({ length: 12 }, (_, i) => <div key={i} className=\"sonner-loading-bar\" />)}</div>}\n </div> : null}\n {item.type !== \"loading\" ? icon : null}\n </div>}\n <div data-content=\"\" role={alert ? \"alert\" : undefined} className={slot(\"content\")}><div data-title=\"\" className={slot(\"title\")}>{item.jsx ?? content(item.title)}</div>\n {item.description ? <div data-description=\"\" className={clsx(props.toastOptions?.descriptionClassName, item.descriptionClassName, slot(\"description\"))}>{content(item.description)}</div> : null}</div>\n {actionButton(\"cancel\")}{actionButton(\"action\")}\n </li>\n}\n\n/** Owns presentation/interaction only; Sonner remains the public toast store. */\nexport function ToastRenderer(props: ToasterProps) {\n const { toasts } = useSonner()\n const [lifecycle] = useState(() => new ToastLifecycle<ToastT>(toast.dismiss, (reason, item) => reason === \"auto\" ? item.onAutoClose?.(item) : item.onDismiss?.(item)))\n useSyncExternalStore(lifecycle.subscribe, lifecycle.snapshot, lifecycle.snapshot)\n const hotkey = props.hotkey ?? [\"altKey\", \"KeyT\"]\n const hotkeyKey = hotkey.join(\"+\")\n useEffect(() => {\n lifecycle.connect(document)\n return () => lifecycle.disconnect()\n }, [lifecycle])\n useEffect(() => {\n const keydown = (event: KeyboardEvent) => lifecycle.keyDown(event, hotkeyKey ? hotkeyKey.split(\"+\") : [])\n document.addEventListener(\"keydown\", keydown)\n return () => document.removeEventListener(\"keydown\", keydown)\n }, [lifecycle, hotkeyKey])\n useEffect(() => {\n lifecycle.sync(toasts, { id: props.id, position: props.position ?? \"bottom-right\", duration: props.toastOptions?.duration ?? props.duration ?? 4000, gap: props.gap ?? 14, visibleToasts: props.visibleToasts ?? 3, expand: props.expand, swipeDirections: props.swipeDirections })\n }, [lifecycle, toasts, props.id, props.position, props.duration, props.toastOptions?.duration, props.gap, props.visibleToasts, props.expand, props.swipeDirections])\n const region = useCallback((node: HTMLElement | null) => lifecycle.setRegion(node), [lifecycle])\n const polite = useCallback((node: HTMLElement | null) => lifecycle.setAnnouncer(\"polite\", node), [lifecycle])\n const assertive = useCallback((node: HTMLElement | null) => lifecycle.setAnnouncer(\"assertive\", node), [lifecycle])\n const positions = [...new Set(lifecycle.entries.map((entry) => lifecycle.position(entry)))]\n const dir = props.dir === \"auto\" || !props.dir ? documentDirection(typeof document === \"undefined\" ? undefined : document) : props.dir\n // aria-live=\"off\": not a live region itself (an announcer or an alert's role speaks, once), but a modal's\n // aria-hidden on everything else (Radix and Reka call aria-hidden's hideOthers) keeps any [aria-live]\n return <section ref={region} aria-label={`${props.containerAriaLabel ?? \"Notifications\"} ${hotkeyKey.replace(/Key|Digit/g, \"\")}`} tabIndex={-1} aria-live=\"off\">\n <div ref={polite} role=\"status\" aria-live=\"polite\" aria-atomic=\"false\" data-toast-announcer=\"polite\" style={announcerStyle} />\n <div ref={assertive} role=\"alert\" aria-live=\"assertive\" aria-atomic=\"false\" data-toast-announcer=\"assertive\" style={announcerStyle} />\n {positions.map((position: Position) => {\n const entries = lifecycle.at(position)\n const [y, x] = position.split(\"-\")\n return <ol key={position} ref={(node) => lifecycle.setList(position, node)} dir={dir} tabIndex={-1} className={props.className}\n data-sonner-toaster=\"true\" data-sonner-theme={props.theme ?? \"light\"} data-y-position={y} data-x-position={x}\n style={{ \"--front-toast-height\": `${entries.find((entry) => !entry.removed)?.height ?? 0}px`, \"--width\": \"356px\", \"--gap\": `${props.gap ?? 14}px`, ...props.style, ...offsetStyles(props.offset, props.mobileOffset) } as CSSProperties}\n onFocus={(event) => lifecycle.focusIn(event.nativeEvent)} onBlur={(event) => lifecycle.focusOut(event.nativeEvent)}\n onPointerEnter={(event) => lifecycle.pointerEnter(event.nativeEvent)} onMouseEnter={() => lifecycle.hover(true)} onMouseMove={() => lifecycle.hover(true)} onMouseLeave={() => lifecycle.hover(false)}>\n {entries.map((entry, index) => <ToastItem key={entry.toast.id} entry={entry} lifecycle={lifecycle} props={props} index={index} count={entries.length} />)}\n </ol>\n })}\n </section>\n}\n"]}
@@ -21,13 +21,24 @@ const subscribeTheme = (onChange) => {
21
21
  };
22
22
  // Keep a gutter outside the safe area; explicit offsets override each supplied
23
23
  // edge, while omitted edges retain the safe default. Sonner applies these only
24
- // at its mobile breakpoint, so desktop positioning is unchanged.
24
+ // at its mobile breakpoint (600px), where a toast fills the width between the
25
+ // side gutters: 14, as the iOS 27 kit's notifications on a phone (Notification -
26
+ // Collapsed - List 135:73247, 374 of 402). A page moves the top and bottom edges
27
+ // with --toast-mobile-offset-top / -bottom (below its own top bar, say), and
28
+ // --toast-offset-top / -bottom above the breakpoint.
25
29
  const safeMobileOffset = {
26
- top: "calc(16px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))",
27
- right: "calc(16px + var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))",
28
- bottom: "calc(16px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))",
29
- left: "calc(16px + var(--safe-area-inset-left, env(safe-area-inset-left, 0px)))",
30
+ top: "var(--toast-mobile-offset-top, calc(16px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px))))",
31
+ right: "calc(14px + var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))",
32
+ bottom: "var(--toast-mobile-offset-bottom, calc(16px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))))",
33
+ left: "calc(14px + var(--safe-area-inset-left, env(safe-area-inset-left, 0px)))",
30
34
  };
35
+ const pageOffset = {
36
+ top: "var(--toast-offset-top, 32px)",
37
+ bottom: "var(--toast-offset-bottom, 32px)",
38
+ };
39
+ const resolveOffset = (offset) => typeof offset === "number" || typeof offset === "string"
40
+ ? offset
41
+ : { ...offset, top: offset?.top ?? pageOffset.top, bottom: offset?.bottom ?? pageOffset.bottom };
31
42
  const resolveMobileOffset = (offset) => typeof offset === "number" || typeof offset === "string"
32
43
  ? offset
33
44
  : {
@@ -48,7 +59,7 @@ const toasterStyle = {
48
59
  };
49
60
  export const Toaster = ({ position = "top-center", duration = 3000, offset, mobileOffset, gap, ...restProps }) => {
50
61
  const theme = useSyncExternalStore(subscribeTheme, readTheme, () => "light");
51
- return (_jsx(SonnerToaster, { theme: theme, position: position, duration: duration, offset: offset, mobileOffset: resolveMobileOffset(mobileOffset), gap: gap, className: s.Toaster, style: toasterStyle, icons: {
62
+ return (_jsx(SonnerToaster, { theme: theme, position: position, duration: duration, offset: resolveOffset(offset), mobileOffset: resolveMobileOffset(mobileOffset), gap: gap, className: s.Toaster, style: toasterStyle, icons: {
52
63
  success: _jsx(CheckCircle, { "aria-hidden": "true" }),
53
64
  error: _jsx(XCircle, { "aria-hidden": "true" }),
54
65
  warning: _jsx(Warning, { "aria-hidden": "true" }),
@@ -1 +1 @@
1
- {"version":3,"file":"Toaster.js","sourceRoot":"","sources":["../../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAsB,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAChE,OAAO,EAA2C,MAAM,QAAQ,CAAA;AAChE,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,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E,CAAC,CAAC,YAAY;gBAC5B,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,IAAI,EAAE,CAAC,CAAC,IAAI;aACb;SACF,KACG,SAAS,GACb,CACH,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport { type CSSProperties, useSyncExternalStore } from \"react\"\nimport { type ToasterProps as SonnerToasterProps } from \"sonner\"\nimport { ToastRenderer as SonnerToaster } from \"./ToastRenderer\"\nimport { CheckCircle, InfoCircle, Warning, XCircle } from \"../Icon\"\nimport s from \"@plexui/styles/components/Toast/Toast.module.css\"\n\n/**\n * Spread into any `toast(...)` options to get a shrink-to-fit, centered\n * layout: `toast(\"Saved\", compact)`, `toast.success(\"Done\", { ...compact, description })`.\n */\nexport const compact = { className: s.Compact } as const\n\ntype PlexTheme = \"light\" | \"dark\"\n\nexport type ToasterProps = {\n position?: SonnerToasterProps[\"position\"]\n duration?: SonnerToasterProps[\"duration\"]\n offset?: SonnerToasterProps[\"offset\"]\n /** Mobile gutter outside the safe area; explicit edges override the safe defaults. */\n mobileOffset?: SonnerToasterProps[\"mobileOffset\"]\n gap?: SonnerToasterProps[\"gap\"]\n} & Omit<\n SonnerToasterProps,\n | \"position\"\n | \"duration\"\n | \"closeButton\"\n | \"offset\"\n | \"mobileOffset\"\n | \"gap\"\n | \"theme\"\n | \"richColors\"\n | \"toastOptions\"\n | \"style\"\n>\n\nconst readTheme = (): PlexTheme =>\n document.documentElement.getAttribute(\"data-theme\") === \"dark\" ? \"dark\" : \"light\"\n\nconst subscribeTheme = (onChange: () => void) => {\n const observer = new MutationObserver(onChange)\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"data-theme\"],\n })\n return () => observer.disconnect()\n}\n\n// Keep a gutter outside the safe area; explicit offsets override each supplied\n// edge, while omitted edges retain the safe default. Sonner applies these only\n// at its mobile breakpoint, so desktop positioning is unchanged.\nconst safeMobileOffset = {\n top: \"calc(16px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))\",\n right: \"calc(16px + var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))\",\n bottom: \"calc(16px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))\",\n left: \"calc(16px + var(--safe-area-inset-left, env(safe-area-inset-left, 0px)))\",\n}\n\nconst resolveMobileOffset = (offset: SonnerToasterProps[\"mobileOffset\"]) =>\n typeof offset === \"number\" || typeof offset === \"string\"\n ? offset\n : {\n top: offset?.top ?? safeMobileOffset.top,\n right: offset?.right ?? safeMobileOffset.right,\n bottom: offset?.bottom ?? safeMobileOffset.bottom,\n left: offset?.left ?? safeMobileOffset.left,\n }\n\n/* Maps PlexUI semantic tokens onto sonner's CSS-variable hooks. Sonner's own\n stylesheet reads these for every toast, so the base look stays aligned with\n <Popover> / <Menu> without overriding each slot. */\nconst toasterStyle: CSSProperties = {\n \"--normal-bg\": \"var(--color-surface-elevated)\",\n \"--normal-text\": \"var(--color-text)\",\n \"--normal-border\": \"transparent\",\n \"--border-radius\": \"var(--radius-xl)\",\n \"--width\": \"400px\",\n} as CSSProperties\n\nexport const Toaster = ({\n position = \"top-center\",\n duration = 3000,\n offset,\n mobileOffset,\n gap,\n ...restProps\n}: ToasterProps) => {\n const theme = useSyncExternalStore(subscribeTheme, readTheme, (): PlexTheme => \"light\")\n\n return (\n <SonnerToaster\n theme={theme}\n position={position}\n duration={duration}\n offset={offset}\n mobileOffset={resolveMobileOffset(mobileOffset)}\n gap={gap}\n className={s.Toaster}\n style={toasterStyle}\n icons={{\n success: <CheckCircle aria-hidden=\"true\" />,\n error: <XCircle aria-hidden=\"true\" />,\n warning: <Warning aria-hidden=\"true\" />,\n info: <InfoCircle aria-hidden=\"true\" />,\n }}\n toastOptions={{\n classNames: {\n toast: s.Toast,\n title: s.Title,\n description: s.Description,\n content: s.Content,\n icon: s.Icon,\n actionButton: s.ActionButton,\n cancelButton: s.CancelButton,\n success: s.Success,\n error: s.Error,\n warning: s.Warning,\n info: s.Info,\n },\n }}\n {...restProps}\n />\n )\n}\n"]}
1
+ {"version":3,"file":"Toaster.js","sourceRoot":"","sources":["../../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAsB,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAChE,OAAO,EAA2C,MAAM,QAAQ,CAAA;AAChE,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACnE,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAW,CAAA;AAyBxD,MAAM,SAAS,GAAG,GAAc,EAAE,CAChC,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAA;AAEnF,MAAM,cAAc,GAAG,CAAC,QAAoB,EAAE,EAAE;IAC9C,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAC/C,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE;QACzC,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,CAAC,YAAY,CAAC;KAChC,CAAC,CAAA;IACF,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;AACpC,CAAC,CAAA;AAED,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,iFAAiF;AACjF,iFAAiF;AACjF,6EAA6E;AAC7E,qDAAqD;AACrD,MAAM,gBAAgB,GAAG;IACvB,GAAG,EAAE,wGAAwG;IAC7G,KAAK,EA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E;IACjB,MAAM,KAAK,GAAG,oBAAoB,CAAC,cAAc,EAAE,SAAS,EAAE,GAAc,EAAE,CAAC,OAAO,CAAC,CAAA;IAEvF,OAAO,CACL,KAAC,aAAa,IACZ,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,EAC7B,YAAY,EAAE,mBAAmB,CAAC,YAAY,CAAC,EAC/C,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,CAAC,CAAC,OAAO,EACpB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE;YACL,OAAO,EAAE,KAAC,WAAW,mBAAa,MAAM,GAAG;YAC3C,KAAK,EAAE,KAAC,OAAO,mBAAa,MAAM,GAAG;YACrC,OAAO,EAAE,KAAC,OAAO,mBAAa,MAAM,GAAG;YACvC,IAAI,EAAE,KAAC,UAAU,mBAAa,MAAM,GAAG;SACxC,EACD,YAAY,EAAE;YACZ,UAAU,EAAE;gBACV,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,YAAY,EAAE,CAAC,CAAC,YAAY;gBAC5B,YAAY,EAAE,CAAC,CAAC,YAAY;gBAC5B,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,IAAI,EAAE,CAAC,CAAC,IAAI;aACb;SACF,KACG,SAAS,GACb,CACH,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport { type CSSProperties, useSyncExternalStore } from \"react\"\nimport { type ToasterProps as SonnerToasterProps } from \"sonner\"\nimport { ToastRenderer as SonnerToaster } from \"./ToastRenderer\"\nimport { CheckCircle, InfoCircle, Warning, XCircle } from \"../Icon\"\nimport s from \"@plexui/styles/components/Toast/Toast.module.css\"\n\n/**\n * Spread into any `toast(...)` options to get a shrink-to-fit, centered\n * layout: `toast(\"Saved\", compact)`, `toast.success(\"Done\", { ...compact, description })`.\n */\nexport const compact = { className: s.Compact } as const\n\ntype PlexTheme = \"light\" | \"dark\"\n\nexport type ToasterProps = {\n position?: SonnerToasterProps[\"position\"]\n duration?: SonnerToasterProps[\"duration\"]\n offset?: SonnerToasterProps[\"offset\"]\n /** Mobile gutter outside the safe area; explicit edges override the safe defaults. */\n mobileOffset?: SonnerToasterProps[\"mobileOffset\"]\n gap?: SonnerToasterProps[\"gap\"]\n} & Omit<\n SonnerToasterProps,\n | \"position\"\n | \"duration\"\n | \"closeButton\"\n | \"offset\"\n | \"mobileOffset\"\n | \"gap\"\n | \"theme\"\n | \"richColors\"\n | \"toastOptions\"\n | \"style\"\n>\n\nconst readTheme = (): PlexTheme =>\n document.documentElement.getAttribute(\"data-theme\") === \"dark\" ? \"dark\" : \"light\"\n\nconst subscribeTheme = (onChange: () => void) => {\n const observer = new MutationObserver(onChange)\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"data-theme\"],\n })\n return () => observer.disconnect()\n}\n\n// Keep a gutter outside the safe area; explicit offsets override each supplied\n// edge, while omitted edges retain the safe default. Sonner applies these only\n// at its mobile breakpoint (600px), where a toast fills the width between the\n// side gutters: 14, as the iOS 27 kit's notifications on a phone (Notification -\n// Collapsed - List 135:73247, 374 of 402). A page moves the top and bottom edges\n// with --toast-mobile-offset-top / -bottom (below its own top bar, say), and\n// --toast-offset-top / -bottom above the breakpoint.\nconst safeMobileOffset = {\n top: \"var(--toast-mobile-offset-top, calc(16px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px))))\",\n right: \"calc(14px + var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))\",\n bottom: \"var(--toast-mobile-offset-bottom, calc(16px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))))\",\n left: \"calc(14px + var(--safe-area-inset-left, env(safe-area-inset-left, 0px)))\",\n}\n\nconst pageOffset = {\n top: \"var(--toast-offset-top, 32px)\",\n bottom: \"var(--toast-offset-bottom, 32px)\",\n}\n\nconst resolveOffset = (offset: SonnerToasterProps[\"offset\"]) =>\n typeof offset === \"number\" || typeof offset === \"string\"\n ? offset\n : { ...offset, top: offset?.top ?? pageOffset.top, bottom: offset?.bottom ?? pageOffset.bottom }\n\nconst resolveMobileOffset = (offset: SonnerToasterProps[\"mobileOffset\"]) =>\n typeof offset === \"number\" || typeof offset === \"string\"\n ? offset\n : {\n top: offset?.top ?? safeMobileOffset.top,\n right: offset?.right ?? safeMobileOffset.right,\n bottom: offset?.bottom ?? safeMobileOffset.bottom,\n left: offset?.left ?? safeMobileOffset.left,\n }\n\n/* Maps PlexUI semantic tokens onto sonner's CSS-variable hooks. Sonner's own\n stylesheet reads these for every toast, so the base look stays aligned with\n <Popover> / <Menu> without overriding each slot. */\nconst toasterStyle: CSSProperties = {\n \"--normal-bg\": \"var(--color-surface-elevated)\",\n \"--normal-text\": \"var(--color-text)\",\n \"--normal-border\": \"transparent\",\n \"--border-radius\": \"var(--radius-xl)\",\n \"--width\": \"400px\",\n} as CSSProperties\n\nexport const Toaster = ({\n position = \"top-center\",\n duration = 3000,\n offset,\n mobileOffset,\n gap,\n ...restProps\n}: ToasterProps) => {\n const theme = useSyncExternalStore(subscribeTheme, readTheme, (): PlexTheme => \"light\")\n\n return (\n <SonnerToaster\n theme={theme}\n position={position}\n duration={duration}\n offset={resolveOffset(offset)}\n mobileOffset={resolveMobileOffset(mobileOffset)}\n gap={gap}\n className={s.Toaster}\n style={toasterStyle}\n icons={{\n success: <CheckCircle aria-hidden=\"true\" />,\n error: <XCircle aria-hidden=\"true\" />,\n warning: <Warning aria-hidden=\"true\" />,\n info: <InfoCircle aria-hidden=\"true\" />,\n }}\n toastOptions={{\n classNames: {\n toast: s.Toast,\n title: s.Title,\n description: s.Description,\n content: s.Content,\n icon: s.Icon,\n actionButton: s.ActionButton,\n cancelButton: s.CancelButton,\n success: s.Success,\n error: s.Error,\n warning: s.Warning,\n info: s.Info,\n },\n }}\n {...restProps}\n />\n )\n}\n"]}
@@ -1,4 +1,6 @@
1
1
  const EXIT_DURATION = 200;
2
+ /** How long an announced line stays in the polite region before it leaves the DOM */
3
+ const ANNOUNCE_DURATION = 7000;
2
4
  export class ToastLifecycle {
3
5
  dismissStore;
4
6
  notify;
@@ -16,6 +18,14 @@ export class ToastLifecycle {
16
18
  lists = new Map();
17
19
  suppressed = new Map();
18
20
  lastPointerType = "";
21
+ region = null;
22
+ announcers = { polite: null, assertive: null };
23
+ announced = new Map();
24
+ /** Alerts read by the assertive announcer: shown behind the stack, their own role could not speak */
25
+ assertive = new Set();
26
+ announceTimers = new Set();
27
+ pending = new Map();
28
+ flushTimer;
19
29
  constructor(dismissStore, notify) {
20
30
  this.dismissStore = dismissStore;
21
31
  this.notify = notify;
@@ -25,10 +35,95 @@ export class ToastLifecycle {
25
35
  emit() { this.revision++; this.listeners.forEach((listener) => listener()); }
26
36
  get expanded() { return this.hovered || this.focused; }
27
37
  get paused() { return this.expanded || Boolean(this.gesture) || this.hidden; }
28
- connect(doc) { this.doc = doc; this.hidden = doc.hidden; doc.addEventListener("visibilitychange", this.visibility); this.refreshTimers(); }
38
+ connect(doc) {
39
+ this.doc = doc;
40
+ this.hidden = doc.hidden;
41
+ doc.addEventListener("visibilitychange", this.visibility);
42
+ for (const type of ISOLATED_EVENTS)
43
+ doc.addEventListener(type, this.isolate);
44
+ this.refreshTimers();
45
+ }
29
46
  visibility = () => { this.hidden = Boolean(this.doc?.hidden); this.refreshTimers(); this.emit(); };
47
+ /* The region is a layer of its own, above any modal. A modal layer (Radix, Reka) listens on the
48
+ document for focus and presses outside it: it would pull focus back out of a toast and close
49
+ on a press of its close or action. This listener, added when the Toaster mounts and so before a
50
+ Dialog opens, runs after the framework's own (React delegates to its root, Vue binds to the
51
+ element) and stops the ones added after it, only while a modal layer has turned the page's
52
+ pointer events off: then nothing under the toast should hear it. Without a modal, a Popover a
53
+ custom toast opened still hears a press elsewhere in the toast. */
54
+ isolate = (event) => {
55
+ const region = this.region;
56
+ if (!region || this.doc?.body.style.pointerEvents !== "none")
57
+ return;
58
+ const related = event.type === "focusout" ? event.relatedTarget : null;
59
+ if (event.target instanceof Node && region.contains(event.target) || related instanceof Node && region.contains(related))
60
+ event.stopImmediatePropagation();
61
+ };
62
+ setRegion(node) { this.region = node; }
63
+ setAnnouncer(kind, node) { this.announcers[kind] = node; }
64
+ /** An error that waits to be closed interrupts as an alert; every other toast is read politely. */
65
+ alert(entry) { return entry.toast.type === "error" && (entry.toast.duration || this.config.duration) === Infinity; }
66
+ /** Whether a toast's content carries role="alert": an alert, unless it came in behind the stack and the assertive announcer read it. */
67
+ alertRole(entry, custom) { return !custom && this.alert(entry) && !this.assertive.has(entry.toast.id); }
68
+ visible(entry) { return this.at(this.position(entry)).indexOf(entry) < this.config.visibleToasts; }
69
+ /** Reads a toast's words once, and again only when they change (a promise that settles, a custom toast's own state). */
70
+ speak(id, node, custom) {
71
+ const entry = this.entries.find((item) => item.toast.id === id);
72
+ if (!entry || entry.removed)
73
+ return;
74
+ const text = toastText(node);
75
+ const alert = this.alert(entry) && !custom;
76
+ // An alert speaks at once, never also politely: words still waiting to be read politely are read as the alert
77
+ if (alert && this.pending.get(id)?.assertive === false) {
78
+ this.pending.delete(id);
79
+ this.announced.delete(id);
80
+ }
81
+ if (!text || this.announced.get(id) === text)
82
+ return;
83
+ this.announced.set(id, text);
84
+ // A shown alert reads itself by its role; one that came in behind the stack (inert, aria-hidden) cannot
85
+ if (alert && this.visible(entry) && !this.assertive.has(id))
86
+ return;
87
+ this.pending.set(id, { text, assertive: alert });
88
+ // Its content then drops role="alert", so it does not speak again once the stack brings it forward
89
+ if (alert && !this.assertive.has(id)) {
90
+ this.assertive.add(id);
91
+ this.emit();
92
+ }
93
+ // Toasts shown together are read together, the oldest first, whichever framework renders them first
94
+ if (this.flushTimer === undefined)
95
+ this.flushTimer = setTimeout(this.flush, 0);
96
+ }
97
+ flush = () => {
98
+ this.flushTimer = undefined;
99
+ const order = this.entries.map((entry) => entry.toast.id).reverse();
100
+ const lines = [...this.pending].sort(([a], [b]) => order.indexOf(a) - order.indexOf(b));
101
+ this.pending.clear();
102
+ for (const [, { text, assertive }] of lines) {
103
+ const node = this.announcers[assertive ? "assertive" : "polite"];
104
+ if (!node)
105
+ continue;
106
+ const line = node.ownerDocument.createElement("div");
107
+ line.textContent = text;
108
+ node.append(line);
109
+ const timer = setTimeout(() => { line.remove(); this.announceTimers.delete(timer); }, ANNOUNCE_DURATION);
110
+ this.announceTimers.add(timer);
111
+ }
112
+ };
30
113
  disconnect() {
31
114
  this.doc?.removeEventListener("visibilitychange", this.visibility);
115
+ for (const type of ISOLATED_EVENTS)
116
+ this.doc?.removeEventListener(type, this.isolate);
117
+ for (const timer of this.announceTimers)
118
+ clearTimeout(timer);
119
+ clearTimeout(this.flushTimer);
120
+ this.flushTimer = undefined;
121
+ this.announceTimers.clear();
122
+ this.announced.clear();
123
+ this.assertive.clear();
124
+ this.pending.clear();
125
+ this.announcers.polite?.replaceChildren();
126
+ this.announcers.assertive?.replaceChildren();
32
127
  for (const entry of this.entries) {
33
128
  clearTimeout(entry.timer);
34
129
  clearTimeout(entry.exitTimer);
@@ -141,6 +236,9 @@ export class ToastLifecycle {
141
236
  return;
142
237
  entry.exitOffset = this.offset(entry);
143
238
  entry.removed = true;
239
+ this.announced.delete(id);
240
+ this.assertive.delete(id);
241
+ this.pending.delete(id);
144
242
  entry.detached = reason === "detach";
145
243
  this.pause(entry);
146
244
  if (this.gesture?.id === id)
@@ -264,6 +362,20 @@ export class ToastLifecycle {
264
362
  this.emit();
265
363
  }
266
364
  }
365
+ const ISOLATED_EVENTS = ["focusin", "focusout", "pointerdown"];
366
+ /** The words a toast says: its title and description, or a custom toast's text. */
367
+ export const toastText = (node) => {
368
+ const words = (element) => element?.textContent?.replace(/\s+/g, " ").trim() ?? "";
369
+ if (!node.querySelector("[data-content]"))
370
+ return words(node);
371
+ const title = words(node.querySelector("[data-title]"));
372
+ const description = words(node.querySelector("[data-description]"));
373
+ if (!title || !description)
374
+ return title || description;
375
+ return `${/[.!?…:;。!?]$/u.test(title) ? title : `${title}.`} ${description}`;
376
+ };
377
+ /** Hides the polite announcer from sight, not from a screen reader. */
378
+ export const announcerStyle = { position: "absolute", width: "1px", height: "1px", margin: "-1px", padding: "0", overflow: "hidden", clip: "rect(0 0 0 0)", clipPath: "inset(50%)", whiteSpace: "nowrap", border: "0" };
267
379
  export const offsetStyles = (offset, mobileOffset) => {
268
380
  const style = {};
269
381
  for (const [prefix, value, fallback] of [["--offset", offset, "32px"], ["--mobile-offset", mobileOffset, "16px"]]) {