@radix-ui/react-toast 1.2.20 → 1.2.21-rc.1784603841447
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +14 -10
- package/dist/index.d.ts +14 -10
- package/dist/index.js +25 -19
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +25 -19
- package/dist/index.mjs.map +3 -3
- package/package.json +15 -15
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,18 @@ import * as React from 'react';
|
|
|
3
3
|
import * as DismissableLayer from '@radix-ui/react-dismissable-layer';
|
|
4
4
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
declare const SwipeDirection: {
|
|
7
|
+
readonly Up: "up";
|
|
8
|
+
readonly Down: "down";
|
|
9
|
+
readonly Left: "left";
|
|
10
|
+
readonly Right: "right";
|
|
11
|
+
};
|
|
12
|
+
type SwipeDirection = (typeof SwipeDirection)[keyof typeof SwipeDirection];
|
|
13
|
+
declare const ToastType: {
|
|
14
|
+
readonly Foreground: "foreground";
|
|
15
|
+
readonly Background: "background";
|
|
16
|
+
};
|
|
17
|
+
type ToastType = (typeof ToastType)[keyof typeof ToastType];
|
|
7
18
|
declare const createToastScope: _radix_ui_react_context.CreateScope;
|
|
8
19
|
interface ToastProviderProps {
|
|
9
20
|
children?: React.ReactNode;
|
|
@@ -81,7 +92,7 @@ type ToastImplPrivateProps = {
|
|
|
81
92
|
};
|
|
82
93
|
type PrimitiveListItemProps = React.ComponentPropsWithoutRef<typeof Primitive.li>;
|
|
83
94
|
interface ToastImplProps extends ToastImplPrivateProps, PrimitiveListItemProps {
|
|
84
|
-
type?:
|
|
95
|
+
type?: ToastType;
|
|
85
96
|
/**
|
|
86
97
|
* Time in milliseconds that toast should remain visible for. Overrides value
|
|
87
98
|
* given to `ToastProvider`.
|
|
@@ -116,12 +127,5 @@ type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.butt
|
|
|
116
127
|
interface ToastCloseProps extends PrimitiveButtonProps {
|
|
117
128
|
}
|
|
118
129
|
declare const ToastClose: React.ForwardRefExoticComponent<ToastCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
119
|
-
declare const Provider: React.FC<ToastProviderProps>;
|
|
120
|
-
declare const Viewport: React.ForwardRefExoticComponent<ToastViewportProps & React.RefAttributes<HTMLOListElement>>;
|
|
121
|
-
declare const Root: React.ForwardRefExoticComponent<ToastProps & React.RefAttributes<HTMLLIElement>>;
|
|
122
|
-
declare const Title: React.ForwardRefExoticComponent<ToastTitleProps & React.RefAttributes<HTMLDivElement>>;
|
|
123
|
-
declare const Description: React.ForwardRefExoticComponent<ToastDescriptionProps & React.RefAttributes<HTMLDivElement>>;
|
|
124
|
-
declare const Action: React.ForwardRefExoticComponent<ToastActionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
125
|
-
declare const Close: React.ForwardRefExoticComponent<ToastCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
126
130
|
|
|
127
|
-
export { Action, Close, Description, Provider, Root, Title, Toast, ToastAction, type ToastActionProps, ToastClose, type ToastCloseProps, ToastDescription, type ToastDescriptionProps, type ToastProps, ToastProvider, type ToastProviderProps, ToastTitle, type ToastTitleProps, ToastViewport, type ToastViewportProps, Viewport, createToastScope };
|
|
131
|
+
export { ToastAction as Action, ToastClose as Close, ToastDescription as Description, ToastProvider as Provider, Toast as Root, ToastTitle as Title, Toast, ToastAction, type ToastActionProps, ToastClose, type ToastCloseProps, ToastDescription, type ToastDescriptionProps, type ToastProps, ToastProvider, type ToastProviderProps, ToastTitle, type ToastTitleProps, ToastViewport, type ToastViewportProps, ToastViewport as Viewport, createToastScope };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,18 @@ import * as React from 'react';
|
|
|
3
3
|
import * as DismissableLayer from '@radix-ui/react-dismissable-layer';
|
|
4
4
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
declare const SwipeDirection: {
|
|
7
|
+
readonly Up: "up";
|
|
8
|
+
readonly Down: "down";
|
|
9
|
+
readonly Left: "left";
|
|
10
|
+
readonly Right: "right";
|
|
11
|
+
};
|
|
12
|
+
type SwipeDirection = (typeof SwipeDirection)[keyof typeof SwipeDirection];
|
|
13
|
+
declare const ToastType: {
|
|
14
|
+
readonly Foreground: "foreground";
|
|
15
|
+
readonly Background: "background";
|
|
16
|
+
};
|
|
17
|
+
type ToastType = (typeof ToastType)[keyof typeof ToastType];
|
|
7
18
|
declare const createToastScope: _radix_ui_react_context.CreateScope;
|
|
8
19
|
interface ToastProviderProps {
|
|
9
20
|
children?: React.ReactNode;
|
|
@@ -81,7 +92,7 @@ type ToastImplPrivateProps = {
|
|
|
81
92
|
};
|
|
82
93
|
type PrimitiveListItemProps = React.ComponentPropsWithoutRef<typeof Primitive.li>;
|
|
83
94
|
interface ToastImplProps extends ToastImplPrivateProps, PrimitiveListItemProps {
|
|
84
|
-
type?:
|
|
95
|
+
type?: ToastType;
|
|
85
96
|
/**
|
|
86
97
|
* Time in milliseconds that toast should remain visible for. Overrides value
|
|
87
98
|
* given to `ToastProvider`.
|
|
@@ -116,12 +127,5 @@ type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.butt
|
|
|
116
127
|
interface ToastCloseProps extends PrimitiveButtonProps {
|
|
117
128
|
}
|
|
118
129
|
declare const ToastClose: React.ForwardRefExoticComponent<ToastCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
119
|
-
declare const Provider: React.FC<ToastProviderProps>;
|
|
120
|
-
declare const Viewport: React.ForwardRefExoticComponent<ToastViewportProps & React.RefAttributes<HTMLOListElement>>;
|
|
121
|
-
declare const Root: React.ForwardRefExoticComponent<ToastProps & React.RefAttributes<HTMLLIElement>>;
|
|
122
|
-
declare const Title: React.ForwardRefExoticComponent<ToastTitleProps & React.RefAttributes<HTMLDivElement>>;
|
|
123
|
-
declare const Description: React.ForwardRefExoticComponent<ToastDescriptionProps & React.RefAttributes<HTMLDivElement>>;
|
|
124
|
-
declare const Action: React.ForwardRefExoticComponent<ToastActionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
125
|
-
declare const Close: React.ForwardRefExoticComponent<ToastCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
126
130
|
|
|
127
|
-
export { Action, Close, Description, Provider, Root, Title, Toast, ToastAction, type ToastActionProps, ToastClose, type ToastCloseProps, ToastDescription, type ToastDescriptionProps, type ToastProps, ToastProvider, type ToastProviderProps, ToastTitle, type ToastTitleProps, ToastViewport, type ToastViewportProps, Viewport, createToastScope };
|
|
131
|
+
export { ToastAction as Action, ToastClose as Close, ToastDescription as Description, ToastProvider as Provider, Toast as Root, ToastTitle as Title, Toast, ToastAction, type ToastActionProps, ToastClose, type ToastCloseProps, ToastDescription, type ToastDescriptionProps, type ToastProps, ToastProvider, type ToastProviderProps, ToastTitle, type ToastTitleProps, ToastViewport, type ToastViewportProps, ToastViewport as Viewport, createToastScope };
|
package/dist/index.js
CHANGED
|
@@ -32,12 +32,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
32
32
|
// src/index.ts
|
|
33
33
|
var index_exports = {};
|
|
34
34
|
__export(index_exports, {
|
|
35
|
-
Action: () =>
|
|
36
|
-
Close: () =>
|
|
37
|
-
Description: () =>
|
|
38
|
-
Provider: () =>
|
|
39
|
-
Root: () =>
|
|
40
|
-
Title: () =>
|
|
35
|
+
Action: () => ToastAction,
|
|
36
|
+
Close: () => ToastClose,
|
|
37
|
+
Description: () => ToastDescription,
|
|
38
|
+
Provider: () => ToastProvider,
|
|
39
|
+
Root: () => Toast,
|
|
40
|
+
Title: () => ToastTitle,
|
|
41
41
|
Toast: () => Toast,
|
|
42
42
|
ToastAction: () => ToastAction,
|
|
43
43
|
ToastClose: () => ToastClose,
|
|
@@ -45,7 +45,7 @@ __export(index_exports, {
|
|
|
45
45
|
ToastProvider: () => ToastProvider,
|
|
46
46
|
ToastTitle: () => ToastTitle,
|
|
47
47
|
ToastViewport: () => ToastViewport,
|
|
48
|
-
Viewport: () =>
|
|
48
|
+
Viewport: () => ToastViewport,
|
|
49
49
|
createToastScope: () => createToastScope
|
|
50
50
|
});
|
|
51
51
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -68,6 +68,16 @@ var import_react_visually_hidden = require("@radix-ui/react-visually-hidden");
|
|
|
68
68
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
69
69
|
var PROVIDER_NAME = "ToastProvider";
|
|
70
70
|
var [Collection, useCollection, createCollectionScope] = (0, import_react_collection.createCollection)("Toast");
|
|
71
|
+
var SwipeDirection = {
|
|
72
|
+
Up: "up",
|
|
73
|
+
Down: "down",
|
|
74
|
+
Left: "left",
|
|
75
|
+
Right: "right"
|
|
76
|
+
};
|
|
77
|
+
var ToastType = {
|
|
78
|
+
Foreground: "foreground",
|
|
79
|
+
Background: "background"
|
|
80
|
+
};
|
|
71
81
|
var [createToastContext, createToastScope] = (0, import_react_context.createContextScope)("Toast", [createCollectionScope]);
|
|
72
82
|
var [ToastProviderProvider, useToastProviderContext] = createToastContext(PROVIDER_NAME);
|
|
73
83
|
var ToastProvider = /* @__PURE__ */ __name((props) => {
|
|
@@ -75,7 +85,7 @@ var ToastProvider = /* @__PURE__ */ __name((props) => {
|
|
|
75
85
|
__scopeToast,
|
|
76
86
|
label = "Notification",
|
|
77
87
|
duration = 5e3,
|
|
78
|
-
swipeDirection =
|
|
88
|
+
swipeDirection = SwipeDirection.Right,
|
|
79
89
|
swipeThreshold = 50,
|
|
80
90
|
announcerContainer,
|
|
81
91
|
children
|
|
@@ -340,7 +350,7 @@ var ToastImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
340
350
|
/* @__PURE__ */ __name(function ToastImpl2(props, forwardedRef) {
|
|
341
351
|
const {
|
|
342
352
|
__scopeToast,
|
|
343
|
-
type =
|
|
353
|
+
type = ToastType.Foreground,
|
|
344
354
|
duration: durationProp,
|
|
345
355
|
open,
|
|
346
356
|
onClose,
|
|
@@ -400,7 +410,10 @@ var ToastImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
400
410
|
}
|
|
401
411
|
}, [context.viewport, duration, onPause, onResume, startTimer]);
|
|
402
412
|
React.useEffect(() => {
|
|
403
|
-
|
|
413
|
+
closeTimerRemainingTimeRef.current = duration;
|
|
414
|
+
if (open && !context.isClosePausedRef.current) {
|
|
415
|
+
startTimer(duration);
|
|
416
|
+
}
|
|
404
417
|
}, [open, duration, context.isClosePausedRef, startTimer]);
|
|
405
418
|
React.useEffect(() => {
|
|
406
419
|
return () => {
|
|
@@ -421,7 +434,7 @@ var ToastImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
421
434
|
{
|
|
422
435
|
__scopeToast,
|
|
423
436
|
role: "status",
|
|
424
|
-
"aria-live": type ===
|
|
437
|
+
"aria-live": type === ToastType.Foreground ? "assertive" : "polite",
|
|
425
438
|
children: announceTextContent
|
|
426
439
|
}
|
|
427
440
|
),
|
|
@@ -630,7 +643,7 @@ var isDeltaInDirection = /* @__PURE__ */ __name((delta, direction, threshold = 0
|
|
|
630
643
|
const deltaX = Math.abs(delta.x);
|
|
631
644
|
const deltaY = Math.abs(delta.y);
|
|
632
645
|
const isDeltaX = deltaX > deltaY;
|
|
633
|
-
if (direction ===
|
|
646
|
+
if (direction === SwipeDirection.Left || direction === SwipeDirection.Right) {
|
|
634
647
|
return isDeltaX && deltaX > threshold;
|
|
635
648
|
} else {
|
|
636
649
|
return !isDeltaX && deltaY > threshold;
|
|
@@ -676,11 +689,4 @@ function focusFirst(candidates) {
|
|
|
676
689
|
});
|
|
677
690
|
}
|
|
678
691
|
__name(focusFirst, "focusFirst");
|
|
679
|
-
var Provider = ToastProvider;
|
|
680
|
-
var Viewport = ToastViewport;
|
|
681
|
-
var Root2 = Toast;
|
|
682
|
-
var Title = ToastTitle;
|
|
683
|
-
var Description = ToastDescription;
|
|
684
|
-
var Action = ToastAction;
|
|
685
|
-
var Close = ToastClose;
|
|
686
692
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/toast.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\nexport {\n createToastScope,\n //\n ToastProvider,\n ToastViewport,\n Toast,\n ToastTitle,\n ToastDescription,\n ToastAction,\n ToastClose,\n //\n Provider,\n Viewport,\n Root,\n Title,\n Description,\n Action,\n Close,\n} from './toast';\nexport type {\n ToastProviderProps,\n ToastViewportProps,\n ToastProps,\n ToastTitleProps,\n ToastDescriptionProps,\n ToastActionProps,\n ToastCloseProps,\n} from './toast';\n", "import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createCollection } from '@radix-ui/react-collection';\nimport { createContextScope } from '@radix-ui/react-context';\nimport * as DismissableLayer from '@radix-ui/react-dismissable-layer';\nimport { Portal } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive, dispatchDiscreteCustomEvent } from '@radix-ui/react-primitive';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { VisuallyHidden } from '@radix-ui/react-visually-hidden';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * ToastProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'ToastProvider';\n\nconst [Collection, useCollection, createCollectionScope] = createCollection<ToastElement>('Toast');\n\ntype SwipeDirection = 'up' | 'down' | 'left' | 'right';\ntype ToastProviderContextValue = {\n label: string;\n duration: number;\n swipeDirection: SwipeDirection;\n swipeThreshold: number;\n toastCount: number;\n viewport: ToastViewportElement | null;\n onViewportChange(viewport: ToastViewportElement): void;\n onToastAdd(): void;\n onToastRemove(): void;\n isClosePausedRef: React.MutableRefObject<boolean>;\n announcerContainer?: Element | DocumentFragment;\n};\n\ntype ScopedProps<P> = P & { __scopeToast?: Scope };\nconst [createToastContext, createToastScope] = createContextScope('Toast', [createCollectionScope]);\nconst [ToastProviderProvider, useToastProviderContext] =\n createToastContext<ToastProviderContextValue>(PROVIDER_NAME);\n\ninterface ToastProviderProps {\n children?: React.ReactNode;\n /**\n * An author-localized label for each toast. Used to help screen reader users\n * associate the interruption with a toast.\n * @defaultValue 'Notification'\n */\n label?: string;\n /**\n * Time in milliseconds that each toast should remain visible for.\n * @defaultValue 5000\n */\n duration?: number;\n /**\n * Direction of pointer swipe that should close the toast.\n * @defaultValue 'right'\n */\n swipeDirection?: SwipeDirection;\n /**\n * Distance in pixels that the swipe must pass before a close is triggered.\n * @defaultValue 50\n */\n swipeThreshold?: number;\n /**\n * An optional container where the toast announcements should be appended.\n * This is useful when working with focus traps or modal dialogs that make\n * other elements inert.\n * @defaultValue document.body\n */\n announcerContainer?: Element | DocumentFragment;\n}\n\nconst ToastProvider: React.FC<ToastProviderProps> = (props: ScopedProps<ToastProviderProps>) => {\n const {\n __scopeToast,\n label = 'Notification',\n duration = 5000,\n swipeDirection = 'right',\n swipeThreshold = 50,\n announcerContainer,\n children,\n } = props;\n const [viewport, setViewport] = React.useState<ToastViewportElement | null>(null);\n const [toastCount, setToastCount] = React.useState(0);\n const isClosePausedRef = React.useRef(false);\n\n if (!label.trim()) {\n console.error(\n `Invalid prop \\`label\\` supplied to \\`${PROVIDER_NAME}\\`. Expected non-empty \\`string\\`.`,\n );\n }\n\n return (\n <Collection.Provider scope={__scopeToast}>\n <ToastProviderProvider\n scope={__scopeToast}\n label={label}\n duration={duration}\n swipeDirection={swipeDirection}\n swipeThreshold={swipeThreshold}\n toastCount={toastCount}\n viewport={viewport}\n onViewportChange={setViewport}\n onToastAdd={React.useCallback(() => setToastCount((prevCount) => prevCount + 1), [])}\n onToastRemove={React.useCallback(() => setToastCount((prevCount) => prevCount - 1), [])}\n isClosePausedRef={isClosePausedRef}\n announcerContainer={announcerContainer}\n >\n {children}\n </ToastProviderProvider>\n </Collection.Provider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ToastViewport\n * -----------------------------------------------------------------------------------------------*/\n\nconst VIEWPORT_NAME = 'ToastViewport';\nconst VIEWPORT_DEFAULT_HOTKEY = ['F8'];\nconst VIEWPORT_PAUSE = 'toast.viewportPause';\nconst VIEWPORT_RESUME = 'toast.viewportResume';\n\ntype ToastViewportElement = React.ComponentRef<typeof Primitive.ol>;\ntype PrimitiveOrderedListProps = React.ComponentPropsWithoutRef<typeof Primitive.ol>;\ninterface ToastViewportProps extends PrimitiveOrderedListProps {\n /**\n * The keys to use as the keyboard shortcut that will move focus to the toast viewport.\n * @defaultValue ['F8']\n */\n hotkey?: string[];\n /**\n * An author-localized label for the toast viewport to provide context for screen reader users\n * when navigating page landmarks. The available `{hotkey}` placeholder will be replaced for you.\n * @defaultValue 'Notifications ({hotkey})'\n */\n label?: string;\n}\n\nconst ToastViewport = /* @__PURE__ */ React.forwardRef<ToastViewportElement, ToastViewportProps>(\n function ToastViewport(props: ScopedProps<ToastViewportProps>, forwardedRef) {\n const {\n __scopeToast,\n hotkey = VIEWPORT_DEFAULT_HOTKEY,\n label = 'Notifications ({hotkey})',\n ...viewportProps\n } = props;\n const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast);\n const getItems = useCollection(__scopeToast);\n const wrapperRef = React.useRef<HTMLDivElement>(null);\n const headFocusProxyRef = React.useRef<FocusProxyElement>(null);\n const tailFocusProxyRef = React.useRef<FocusProxyElement>(null);\n const ref = React.useRef<ToastViewportElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange);\n const hotkeyLabel = hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '');\n const hasToasts = context.toastCount > 0;\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n // we use `event.code` as it is consistent regardless of meta keys that were pressed.\n // for example, `event.key` for `Control+Alt+t` is `\u2020` and `t !== \u2020`\n const isHotkeyPressed =\n hotkey.length !== 0 && hotkey.every((key) => (event as any)[key] || event.code === key);\n if (isHotkeyPressed) ref.current?.focus();\n };\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [hotkey]);\n\n React.useEffect(() => {\n const wrapper = wrapperRef.current;\n const viewport = ref.current;\n if (hasToasts && wrapper && viewport) {\n const handlePause = () => {\n if (!context.isClosePausedRef.current) {\n const pauseEvent = new CustomEvent(VIEWPORT_PAUSE);\n viewport.dispatchEvent(pauseEvent);\n context.isClosePausedRef.current = true;\n }\n };\n\n const handleResume = () => {\n if (context.isClosePausedRef.current) {\n const resumeEvent = new CustomEvent(VIEWPORT_RESUME);\n viewport.dispatchEvent(resumeEvent);\n context.isClosePausedRef.current = false;\n }\n };\n\n const handleFocusOutResume = (event: FocusEvent) => {\n const isFocusMovingOutside = !wrapper.contains(event.relatedTarget as HTMLElement);\n if (isFocusMovingOutside) handleResume();\n };\n\n const handlePointerLeaveResume = () => {\n const isFocusInside = wrapper.contains(document.activeElement);\n if (!isFocusInside) handleResume();\n };\n\n // Toasts are not in the viewport React tree so we need to bind DOM events\n wrapper.addEventListener('focusin', handlePause);\n wrapper.addEventListener('focusout', handleFocusOutResume);\n wrapper.addEventListener('pointermove', handlePause);\n wrapper.addEventListener('pointerleave', handlePointerLeaveResume);\n window.addEventListener('blur', handlePause);\n window.addEventListener('focus', handleResume);\n return () => {\n wrapper.removeEventListener('focusin', handlePause);\n wrapper.removeEventListener('focusout', handleFocusOutResume);\n wrapper.removeEventListener('pointermove', handlePause);\n wrapper.removeEventListener('pointerleave', handlePointerLeaveResume);\n window.removeEventListener('blur', handlePause);\n window.removeEventListener('focus', handleResume);\n };\n }\n }, [hasToasts, context.isClosePausedRef]);\n\n const getSortedTabbableCandidates = React.useCallback(\n ({ tabbingDirection }: { tabbingDirection: 'forwards' | 'backwards' }) => {\n const toastItems = getItems();\n const tabbableCandidates = toastItems.map((toastItem) => {\n const toastNode = toastItem.ref.current!;\n const toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];\n return tabbingDirection === 'forwards'\n ? toastTabbableCandidates\n : toastTabbableCandidates.reverse();\n });\n return (\n tabbingDirection === 'forwards' ? tabbableCandidates.reverse() : tabbableCandidates\n ).flat();\n },\n [getItems],\n );\n\n React.useEffect(() => {\n const viewport = ref.current;\n // We programmatically manage tabbing as we are unable to influence\n // the source order with portals, this allows us to reverse the\n // tab order so that it runs from most recent toast to least\n if (viewport) {\n const handleKeyDown = (event: KeyboardEvent) => {\n const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;\n const isTabKey = event.key === 'Tab' && !isMetaKey;\n\n if (isTabKey) {\n const focusedElement = document.activeElement;\n const isTabbingBackwards = event.shiftKey;\n const targetIsViewport = event.target === viewport;\n\n // If we're back tabbing after jumping to the viewport then we simply\n // proxy focus out to the preceding document\n if (targetIsViewport && isTabbingBackwards) {\n headFocusProxyRef.current?.focus();\n return;\n }\n\n const tabbingDirection = isTabbingBackwards ? 'backwards' : 'forwards';\n const sortedCandidates = getSortedTabbableCandidates({ tabbingDirection });\n const index = sortedCandidates.findIndex((candidate) => candidate === focusedElement);\n if (focusFirst(sortedCandidates.slice(index + 1))) {\n event.preventDefault();\n } else {\n // If we can't focus that means we're at the edges so we\n // proxy to the corresponding exit point and let the browser handle\n // tab/shift+tab keypress and implicitly pass focus to the next valid element in the document\n isTabbingBackwards\n ? headFocusProxyRef.current?.focus()\n : tailFocusProxyRef.current?.focus();\n }\n }\n };\n\n // Toasts are not in the viewport React tree so we need to bind DOM events\n viewport.addEventListener('keydown', handleKeyDown);\n return () => viewport.removeEventListener('keydown', handleKeyDown);\n }\n }, [getItems, getSortedTabbableCandidates]);\n\n return (\n <DismissableLayer.Branch\n ref={wrapperRef}\n role=\"region\"\n aria-label={label.replace('{hotkey}', hotkeyLabel)}\n // Ensure virtual cursor from landmarks menus triggers focus/blur for pause/resume\n tabIndex={-1}\n // incase list has size when empty (e.g. padding), we remove pointer events so\n // it doesn't prevent interactions with page elements that it overlays\n style={{ pointerEvents: hasToasts ? undefined : 'none' }}\n >\n {hasToasts && (\n <FocusProxy\n ref={headFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'forwards',\n });\n focusFirst(tabbableCandidates);\n }}\n />\n )}\n {/**\n * tabindex on the the list so that it can be focused when items are removed. we focus\n * the list instead of the viewport so it announces number of items remaining.\n */}\n <Collection.Slot scope={__scopeToast}>\n <Primitive.ol tabIndex={-1} {...viewportProps} ref={composedRefs} />\n </Collection.Slot>\n {hasToasts && (\n <FocusProxy\n ref={tailFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'backwards',\n });\n focusFirst(tabbableCandidates);\n }}\n />\n )}\n </DismissableLayer.Branch>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst FOCUS_PROXY_NAME = 'ToastFocusProxy';\n\ntype FocusProxyElement = React.ComponentRef<typeof VisuallyHidden>;\ntype VisuallyHiddenProps = React.ComponentPropsWithoutRef<typeof VisuallyHidden>;\ninterface FocusProxyProps extends VisuallyHiddenProps {\n onFocusFromOutsideViewport(): void;\n}\n\nconst FocusProxy = /* @__PURE__ */ React.forwardRef<\n FocusProxyElement,\n ScopedProps<FocusProxyProps>\n>(\n // blank line to reduce diff noise\n function ToastFocusProxy(props, forwardedRef) {\n const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props;\n const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast);\n\n return (\n <VisuallyHidden\n tabIndex={0}\n {...proxyProps}\n ref={forwardedRef}\n // Avoid page scrolling when focus is on the focus proxy\n style={{ position: 'fixed' }}\n onFocus={(event) => {\n const prevFocusedElement = event.relatedTarget as HTMLElement | null;\n const isFocusFromOutsideViewport = !context.viewport?.contains(prevFocusedElement);\n if (isFocusFromOutsideViewport) onFocusFromOutsideViewport();\n }}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOAST_NAME = 'Toast';\nconst TOAST_SWIPE_START = 'toast.swipeStart';\nconst TOAST_SWIPE_MOVE = 'toast.swipeMove';\nconst TOAST_SWIPE_CANCEL = 'toast.swipeCancel';\nconst TOAST_SWIPE_END = 'toast.swipeEnd';\n\ntype ToastElement = ToastImplElement;\ninterface ToastProps extends Omit<ToastImplProps, keyof ToastImplPrivateProps> {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst Toast = /* @__PURE__ */ React.forwardRef<ToastElement, ToastProps>(\n // blank line to reduce diff noise\n function Toast(props: ScopedProps<ToastProps>, forwardedRef) {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props;\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n caller: TOAST_NAME,\n });\n return (\n <Presence present={forceMount || open}>\n <ToastImpl\n open={open}\n {...toastProps}\n ref={forwardedRef}\n onClose={() => setOpen(false)}\n onPause={useCallbackRef(props.onPause)}\n onResume={useCallbackRef(props.onResume)}\n onSwipeStart={composeEventHandlers(props.onSwipeStart, (event) => {\n event.currentTarget.setAttribute('data-swipe', 'start');\n })}\n onSwipeMove={composeEventHandlers(props.onSwipeMove, (event) => {\n const { x, y } = event.detail.delta;\n event.currentTarget.setAttribute('data-swipe', 'move');\n event.currentTarget.style.setProperty('--radix-toast-swipe-move-x', `${x}px`);\n event.currentTarget.style.setProperty('--radix-toast-swipe-move-y', `${y}px`);\n })}\n onSwipeCancel={composeEventHandlers(props.onSwipeCancel, (event) => {\n event.currentTarget.setAttribute('data-swipe', 'cancel');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-y');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-end-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-end-y');\n })}\n onSwipeEnd={composeEventHandlers(props.onSwipeEnd, (event) => {\n const { x, y } = event.detail.delta;\n event.currentTarget.setAttribute('data-swipe', 'end');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-y');\n event.currentTarget.style.setProperty('--radix-toast-swipe-end-x', `${x}px`);\n event.currentTarget.style.setProperty('--radix-toast-swipe-end-y', `${y}px`);\n setOpen(false);\n })}\n />\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype SwipeEvent = { currentTarget: EventTarget & ToastElement } & Omit<\n CustomEvent<{ originalEvent: React.PointerEvent; delta: { x: number; y: number } }>,\n 'currentTarget'\n>;\n\nconst [ToastInteractiveProvider, useToastInteractiveContext] = createToastContext(TOAST_NAME, {\n onClose() {},\n});\n\ntype ToastImplElement = React.ComponentRef<typeof Primitive.li>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer.Root>;\ntype ToastImplPrivateProps = { open: boolean; onClose(): void };\ntype PrimitiveListItemProps = React.ComponentPropsWithoutRef<typeof Primitive.li>;\ninterface ToastImplProps extends ToastImplPrivateProps, PrimitiveListItemProps {\n type?: 'foreground' | 'background';\n /**\n * Time in milliseconds that toast should remain visible for. Overrides value\n * given to `ToastProvider`.\n */\n duration?: number;\n onEscapeKeyDown?: DismissableLayerProps['onEscapeKeyDown'];\n onPause?(): void;\n onResume?(): void;\n onSwipeStart?(event: SwipeEvent): void;\n onSwipeMove?(event: SwipeEvent): void;\n onSwipeCancel?(event: SwipeEvent): void;\n onSwipeEnd?(event: SwipeEvent): void;\n}\n\nconst ToastImpl = /* @__PURE__ */ React.forwardRef<ToastImplElement, ToastImplProps>(\n function ToastImpl(props: ScopedProps<ToastImplProps>, forwardedRef) {\n const {\n __scopeToast,\n type = 'foreground',\n duration: durationProp,\n open,\n onClose,\n onEscapeKeyDown,\n onPause,\n onResume,\n onSwipeStart,\n onSwipeMove,\n onSwipeCancel,\n onSwipeEnd,\n ...toastProps\n } = props;\n const context = useToastProviderContext(TOAST_NAME, __scopeToast);\n const getItems = useCollection(__scopeToast);\n const [node, setNode] = React.useState<ToastImplElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setNode);\n const pointerStartRef = React.useRef<{ x: number; y: number } | null>(null);\n const swipeDeltaRef = React.useRef<{ x: number; y: number } | null>(null);\n const duration = durationProp || context.duration;\n const closeTimerStartTimeRef = React.useRef(0);\n const closeTimerRemainingTimeRef = React.useRef(duration);\n const closeTimerRef = React.useRef(0);\n const { onToastAdd, onToastRemove } = context;\n const handleClose = useCallbackRef(() => {\n // focus viewport if focus is within toast to read the remaining toast\n // count to SR users and ensure focus isn't lost\n const isFocusInToast = node?.contains(document.activeElement);\n if (isFocusInToast) context.viewport?.focus();\n onClose();\n });\n\n const startTimer = React.useCallback(\n (duration: number) => {\n if (!duration || duration === Infinity) return;\n window.clearTimeout(closeTimerRef.current);\n closeTimerStartTimeRef.current = new Date().getTime();\n closeTimerRef.current = window.setTimeout(handleClose, duration);\n },\n [handleClose],\n );\n\n React.useEffect(() => {\n const viewport = context.viewport;\n if (viewport) {\n const handleResume = () => {\n startTimer(closeTimerRemainingTimeRef.current);\n onResume?.();\n };\n const handlePause = () => {\n const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current;\n closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime;\n window.clearTimeout(closeTimerRef.current);\n onPause?.();\n };\n viewport.addEventListener(VIEWPORT_PAUSE, handlePause);\n viewport.addEventListener(VIEWPORT_RESUME, handleResume);\n return () => {\n viewport.removeEventListener(VIEWPORT_PAUSE, handlePause);\n viewport.removeEventListener(VIEWPORT_RESUME, handleResume);\n };\n }\n }, [context.viewport, duration, onPause, onResume, startTimer]);\n\n // start timer when toast opens or duration changes.\n // we include `open` in deps because closed !== unmounted when animating\n // so it could reopen before being completely unmounted\n React.useEffect(() => {\n if (open && !context.isClosePausedRef.current) startTimer(duration);\n }, [open, duration, context.isClosePausedRef, startTimer]);\n\n // Clear close timer on unmount to prevent memory leaks and errors in test environments\n React.useEffect(() => {\n return () => {\n window.clearTimeout(closeTimerRef.current);\n };\n }, []);\n\n React.useEffect(() => {\n onToastAdd();\n return () => onToastRemove();\n }, [onToastAdd, onToastRemove]);\n\n const announceTextContent = React.useMemo(() => {\n return node ? getAnnounceTextContent(node) : null;\n }, [node]);\n\n if (!context.viewport) return null;\n\n return (\n <>\n {announceTextContent && (\n <ToastAnnounce\n __scopeToast={__scopeToast}\n // Toasts are always role=status to avoid stuttering issues with role=alert in SRs.\n role=\"status\"\n aria-live={type === 'foreground' ? 'assertive' : 'polite'}\n >\n {announceTextContent}\n </ToastAnnounce>\n )}\n\n <ToastInteractiveProvider scope={__scopeToast} onClose={handleClose}>\n {ReactDOM.createPortal(\n <Collection.ItemSlot scope={__scopeToast}>\n <DismissableLayer.Root\n asChild\n onEscapeKeyDown={composeEventHandlers(onEscapeKeyDown, (event) => {\n // Only the highest layer (most recent toast) registers the\n // escape listener, and it runs in the capture phase. If the\n // key press originated from within a focused toast, that\n // toast closes itself via `onKeyDown` below, so we must not\n // also close this (top-most) toast. Otherwise, close it.\n // See: https://github.com/radix-ui/primitives/issues/2906\n const isFocusInToast = getItems().some((item) =>\n item.ref.current?.contains(event.target as Node | null),\n );\n if (!isFocusInToast) {\n handleClose();\n }\n })}\n >\n <Primitive.li\n tabIndex={0}\n data-state={open ? 'open' : 'closed'}\n data-swipe-direction={context.swipeDirection}\n {...toastProps}\n ref={composedRefs}\n style={{ userSelect: 'none', touchAction: 'none', ...props.style }}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (event.key !== 'Escape') return;\n onEscapeKeyDown?.(event.nativeEvent);\n if (!event.nativeEvent.defaultPrevented) {\n handleClose();\n }\n })}\n onPointerDown={composeEventHandlers(props.onPointerDown, (event) => {\n if (event.button !== 0) return;\n pointerStartRef.current = { x: event.clientX, y: event.clientY };\n })}\n onPointerMove={composeEventHandlers(props.onPointerMove, (event) => {\n if (!pointerStartRef.current) return;\n const x = event.clientX - pointerStartRef.current.x;\n const y = event.clientY - pointerStartRef.current.y;\n const hasSwipeMoveStarted = Boolean(swipeDeltaRef.current);\n const isHorizontalSwipe = ['left', 'right'].includes(context.swipeDirection);\n const clamp = ['left', 'up'].includes(context.swipeDirection)\n ? Math.min\n : Math.max;\n const clampedX = isHorizontalSwipe ? clamp(0, x) : 0;\n const clampedY = !isHorizontalSwipe ? clamp(0, y) : 0;\n const moveStartBuffer = event.pointerType === 'touch' ? 10 : 2;\n const delta = { x: clampedX, y: clampedY };\n const eventDetail = { originalEvent: event, delta };\n if (hasSwipeMoveStarted) {\n swipeDeltaRef.current = delta;\n handleAndDispatchCustomEvent(TOAST_SWIPE_MOVE, onSwipeMove, eventDetail, {\n discrete: false,\n });\n } else if (isDeltaInDirection(delta, context.swipeDirection, moveStartBuffer)) {\n swipeDeltaRef.current = delta;\n handleAndDispatchCustomEvent(TOAST_SWIPE_START, onSwipeStart, eventDetail, {\n discrete: false,\n });\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n } else if (Math.abs(x) > moveStartBuffer || Math.abs(y) > moveStartBuffer) {\n // User is swiping in wrong direction so we disable swipe gesture\n // for the current pointer down interaction\n pointerStartRef.current = null;\n }\n })}\n onPointerUp={composeEventHandlers(props.onPointerUp, (event) => {\n const delta = swipeDeltaRef.current;\n const target = event.target as HTMLElement;\n if (target.hasPointerCapture(event.pointerId)) {\n target.releasePointerCapture(event.pointerId);\n }\n swipeDeltaRef.current = null;\n pointerStartRef.current = null;\n if (delta) {\n const toast = event.currentTarget;\n const eventDetail = { originalEvent: event, delta };\n if (\n isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)\n ) {\n handleAndDispatchCustomEvent(TOAST_SWIPE_END, onSwipeEnd, eventDetail, {\n discrete: true,\n });\n } else {\n handleAndDispatchCustomEvent(\n TOAST_SWIPE_CANCEL,\n onSwipeCancel,\n eventDetail,\n {\n discrete: true,\n },\n );\n }\n // Prevent click event from triggering on items within the toast when\n // pointer up is part of a swipe gesture\n toast.addEventListener('click', (event) => event.preventDefault(), {\n once: true,\n });\n }\n })}\n />\n </DismissableLayer.Root>\n </Collection.ItemSlot>,\n context.viewport,\n )}\n </ToastInteractiveProvider>\n </>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ninterface ToastAnnounceProps\n extends\n Omit<React.ComponentPropsWithoutRef<'div'>, 'children'>,\n ScopedProps<{ children: string[] }> {}\n\nconst ToastAnnounce: React.FC<ToastAnnounceProps> = (props: ScopedProps<ToastAnnounceProps>) => {\n const { __scopeToast, children, ...announceProps } = props;\n const context = useToastProviderContext(TOAST_NAME, __scopeToast);\n const [renderAnnounceText, setRenderAnnounceText] = React.useState(false);\n const [isAnnounced, setIsAnnounced] = React.useState(false);\n\n // render text content in the next frame to ensure toast is announced in NVDA\n useNextFrame(() => setRenderAnnounceText(true));\n\n // cleanup after announcing\n React.useEffect(() => {\n const timer = window.setTimeout(() => setIsAnnounced(true), 1000);\n return () => window.clearTimeout(timer);\n }, []);\n\n return isAnnounced ? null : (\n <Portal asChild container={context.announcerContainer || undefined}>\n <VisuallyHidden {...announceProps}>\n {renderAnnounceText && (\n <>\n {context.label} {children}\n </>\n )}\n </VisuallyHidden>\n </Portal>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\ntype ToastTitleElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ToastTitleProps extends PrimitiveDivProps {}\n\nconst ToastTitle = /* @__PURE__ */ React.forwardRef<ToastTitleElement, ToastTitleProps>(\n function ToastTitle(props: ScopedProps<ToastTitleProps>, forwardedRef) {\n const { __scopeToast, ...titleProps } = props;\n return <Primitive.div {...titleProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\ntype ToastDescriptionElement = React.ComponentRef<typeof Primitive.div>;\ninterface ToastDescriptionProps extends PrimitiveDivProps {}\n\nconst ToastDescription = /* @__PURE__ */ React.forwardRef<\n ToastDescriptionElement,\n ToastDescriptionProps\n>(\n // blank line to reduce diff noise\n function ToastDescription(props: ScopedProps<ToastDescriptionProps>, forwardedRef) {\n const { __scopeToast, ...descriptionProps } = props;\n return <Primitive.div {...descriptionProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction';\n\ntype ToastActionElement = ToastCloseElement;\ninterface ToastActionProps extends ToastCloseProps {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to upgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string;\n}\n\nconst ToastAction = /* @__PURE__ */ React.forwardRef<ToastActionElement, ToastActionProps>(\n function ToastAction(props: ScopedProps<ToastActionProps>, forwardedRef) {\n const { altText, ...actionProps } = props;\n\n if (!altText.trim()) {\n console.error(\n `Invalid prop \\`altText\\` supplied to \\`${ACTION_NAME}\\`. Expected non-empty \\`string\\`.`,\n );\n return null;\n }\n\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose';\n\ntype ToastCloseElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface ToastCloseProps extends PrimitiveButtonProps {}\n\nconst ToastClose = /* @__PURE__ */ React.forwardRef<ToastCloseElement, ToastCloseProps>(\n function ToastClose(props: ScopedProps<ToastCloseProps>, forwardedRef) {\n const { __scopeToast, ...closeProps } = props;\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast);\n\n return (\n <ToastAnnounceExclude asChild>\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n );\n },\n);\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype ToastAnnounceExcludeElement = React.ComponentRef<typeof Primitive.div>;\ninterface ToastAnnounceExcludeProps extends PrimitiveDivProps {\n altText?: string;\n}\n\nconst ToastAnnounceExclude = /* @__PURE__ */ React.forwardRef<\n ToastAnnounceExcludeElement,\n ToastAnnounceExcludeProps\n>(function ToastAnnounceExclude(props: ScopedProps<ToastAnnounceExcludeProps>, forwardedRef) {\n const { __scopeToast, altText, ...announceExcludeProps } = props;\n\n return (\n <Primitive.div\n data-radix-toast-announce-exclude=\"\"\n data-radix-toast-announce-alt={altText || undefined}\n {...announceExcludeProps}\n ref={forwardedRef}\n />\n );\n});\n\nfunction getAnnounceTextContent(container: HTMLElement) {\n const textContent: string[] = [];\n const childNodes = Array.from(container.childNodes);\n\n childNodes.forEach((node) => {\n if (node.nodeType === node.TEXT_NODE && node.textContent) textContent.push(node.textContent);\n if (isHTMLElement(node)) {\n const isHidden = node.ariaHidden || node.hidden || node.style.display === 'none';\n const isExcluded = node.dataset.radixToastAnnounceExclude === '';\n\n if (!isHidden) {\n if (isExcluded) {\n const altText = node.dataset.radixToastAnnounceAlt;\n if (altText) textContent.push(altText);\n } else {\n textContent.push(...getAnnounceTextContent(node));\n }\n }\n }\n });\n\n // We return a collection of text rather than a single concatenated string.\n // This allows SR VO to naturally pause break between nodes while announcing.\n return textContent;\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction handleAndDispatchCustomEvent<\n E extends CustomEvent,\n ReactEvent extends React.SyntheticEvent,\n>(\n name: string,\n handler: ((event: E) => void) | undefined,\n detail: { originalEvent: ReactEvent } & (E extends CustomEvent<infer D> ? D : never),\n { discrete }: { discrete: boolean },\n) {\n const currentTarget = detail.originalEvent.currentTarget as HTMLElement;\n const event = new CustomEvent(name, { bubbles: true, cancelable: true, detail });\n if (handler) currentTarget.addEventListener(name, handler as EventListener, { once: true });\n\n if (discrete) {\n dispatchDiscreteCustomEvent(currentTarget, event);\n } else {\n currentTarget.dispatchEvent(event);\n }\n}\n\nconst isDeltaInDirection = (\n delta: { x: number; y: number },\n direction: SwipeDirection,\n threshold = 0,\n) => {\n const deltaX = Math.abs(delta.x);\n const deltaY = Math.abs(delta.y);\n const isDeltaX = deltaX > deltaY;\n if (direction === 'left' || direction === 'right') {\n return isDeltaX && deltaX > threshold;\n } else {\n return !isDeltaX && deltaY > threshold;\n }\n};\n\nfunction useNextFrame(callback = () => {}) {\n const fn = useCallbackRef(callback);\n useLayoutEffect(() => {\n let raf1 = 0;\n let raf2 = 0;\n raf1 = window.requestAnimationFrame(() => (raf2 = window.requestAnimationFrame(fn)));\n return () => {\n window.cancelAnimationFrame(raf1);\n window.cancelAnimationFrame(raf2);\n };\n }, [fn]);\n}\n\nfunction isHTMLElement(node: any): node is HTMLElement {\n return node.nodeType === node.ELEMENT_NODE;\n}\n\n/**\n * Returns a list of potential tabbable candidates.\n *\n * NOTE: This is only a close approximation. For example it doesn't take into account cases like when\n * elements are not visible. This cannot be worked out easily by just reading a property, but rather\n * necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker\n * Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1\n */\nfunction getTabbableCandidates(container: HTMLElement) {\n const nodes: HTMLElement[] = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: any) => {\n const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden';\n if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;\n // `.tabIndex` is not the same as the `tabindex` attribute. It works on the\n // runtime's understanding of tabbability, so this automatically accounts\n // for any kind of element that could be tabbed to.\n return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n },\n });\n while (walker.nextNode()) nodes.push(walker.currentNode as HTMLElement);\n // we do not take into account the order of nodes with positive `tabIndex` as it\n // hinders accessibility to have tab order different from visual order.\n return nodes;\n}\n\nfunction focusFirst(candidates: HTMLElement[]) {\n const previouslyFocusedElement = document.activeElement;\n return candidates.some((candidate) => {\n // if focus is already where we want to go, we don't want to keep going through the candidates\n if (candidate === previouslyFocusedElement) return true;\n candidate.focus();\n return document.activeElement !== previouslyFocusedElement;\n });\n}\n\nconst Provider = ToastProvider;\nconst Viewport = ToastViewport;\nconst Root = Toast;\nconst Title = ToastTitle;\nconst Description = ToastDescription;\nconst Action = ToastAction;\nconst Close = ToastClose;\n\nexport {\n createToastScope,\n //\n ToastProvider,\n ToastViewport,\n Toast,\n ToastTitle,\n ToastDescription,\n ToastAction,\n ToastClose,\n //\n Provider,\n Viewport,\n Root,\n Title,\n Description,\n Action,\n Close,\n};\nexport type {\n ToastProviderProps,\n ToastViewportProps,\n ToastProps,\n ToastTitleProps,\n ToastDescriptionProps,\n ToastActionProps,\n ToastCloseProps,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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;AACb,IAAM,QAAQ;AACd,IAAM,cAAc;AACpB,IAAM,SAAS;AACf,IAAM,QAAQ;",
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["'use client';\nexport {\n createToastScope,\n //\n ToastProvider,\n ToastViewport,\n Toast,\n ToastTitle,\n ToastDescription,\n ToastAction,\n ToastClose,\n //\n Provider,\n Viewport,\n Root,\n Title,\n Description,\n Action,\n Close,\n} from './toast';\nexport type {\n ToastProviderProps,\n ToastViewportProps,\n ToastProps,\n ToastTitleProps,\n ToastDescriptionProps,\n ToastActionProps,\n ToastCloseProps,\n} from './toast';\n", "import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createCollection } from '@radix-ui/react-collection';\nimport { createContextScope } from '@radix-ui/react-context';\nimport * as DismissableLayer from '@radix-ui/react-dismissable-layer';\nimport { Portal } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive, dispatchDiscreteCustomEvent } from '@radix-ui/react-primitive';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { VisuallyHidden } from '@radix-ui/react-visually-hidden';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * ToastProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'ToastProvider';\n\nconst [Collection, useCollection, createCollectionScope] = createCollection<ToastElement>('Toast');\n\nconst SwipeDirection = {\n Up: 'up',\n Down: 'down',\n Left: 'left',\n Right: 'right',\n} as const;\n\nconst ToastType = {\n Foreground: 'foreground',\n Background: 'background',\n} as const;\n\ntype SwipeDirection = (typeof SwipeDirection)[keyof typeof SwipeDirection];\ntype ToastType = (typeof ToastType)[keyof typeof ToastType];\n\ntype ToastProviderContextValue = {\n label: string;\n duration: number;\n swipeDirection: SwipeDirection;\n swipeThreshold: number;\n toastCount: number;\n viewport: ToastViewportElement | null;\n onViewportChange(viewport: ToastViewportElement): void;\n onToastAdd(): void;\n onToastRemove(): void;\n isClosePausedRef: React.MutableRefObject<boolean>;\n announcerContainer?: Element | DocumentFragment;\n};\n\ntype ScopedProps<P> = P & { __scopeToast?: Scope };\nconst [createToastContext, createToastScope] = createContextScope('Toast', [createCollectionScope]);\nconst [ToastProviderProvider, useToastProviderContext] =\n createToastContext<ToastProviderContextValue>(PROVIDER_NAME);\n\ninterface ToastProviderProps {\n children?: React.ReactNode;\n /**\n * An author-localized label for each toast. Used to help screen reader users\n * associate the interruption with a toast.\n * @defaultValue 'Notification'\n */\n label?: string;\n /**\n * Time in milliseconds that each toast should remain visible for.\n * @defaultValue 5000\n */\n duration?: number;\n /**\n * Direction of pointer swipe that should close the toast.\n * @defaultValue 'right'\n */\n swipeDirection?: SwipeDirection;\n /**\n * Distance in pixels that the swipe must pass before a close is triggered.\n * @defaultValue 50\n */\n swipeThreshold?: number;\n /**\n * An optional container where the toast announcements should be appended.\n * This is useful when working with focus traps or modal dialogs that make\n * other elements inert.\n * @defaultValue document.body\n */\n announcerContainer?: Element | DocumentFragment;\n}\n\nconst ToastProvider: React.FC<ToastProviderProps> = (props: ScopedProps<ToastProviderProps>) => {\n const {\n __scopeToast,\n label = 'Notification',\n duration = 5000,\n swipeDirection = SwipeDirection.Right,\n swipeThreshold = 50,\n announcerContainer,\n children,\n } = props;\n const [viewport, setViewport] = React.useState<ToastViewportElement | null>(null);\n const [toastCount, setToastCount] = React.useState(0);\n const isClosePausedRef = React.useRef(false);\n\n if (!label.trim()) {\n console.error(\n `Invalid prop \\`label\\` supplied to \\`${PROVIDER_NAME}\\`. Expected non-empty \\`string\\`.`,\n );\n }\n\n return (\n <Collection.Provider scope={__scopeToast}>\n <ToastProviderProvider\n scope={__scopeToast}\n label={label}\n duration={duration}\n swipeDirection={swipeDirection}\n swipeThreshold={swipeThreshold}\n toastCount={toastCount}\n viewport={viewport}\n onViewportChange={setViewport}\n onToastAdd={React.useCallback(() => setToastCount((prevCount) => prevCount + 1), [])}\n onToastRemove={React.useCallback(() => setToastCount((prevCount) => prevCount - 1), [])}\n isClosePausedRef={isClosePausedRef}\n announcerContainer={announcerContainer}\n >\n {children}\n </ToastProviderProvider>\n </Collection.Provider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ToastViewport\n * -----------------------------------------------------------------------------------------------*/\n\nconst VIEWPORT_NAME = 'ToastViewport';\nconst VIEWPORT_DEFAULT_HOTKEY = ['F8'];\nconst VIEWPORT_PAUSE = 'toast.viewportPause';\nconst VIEWPORT_RESUME = 'toast.viewportResume';\n\ntype ToastViewportElement = React.ComponentRef<typeof Primitive.ol>;\ntype PrimitiveOrderedListProps = React.ComponentPropsWithoutRef<typeof Primitive.ol>;\ninterface ToastViewportProps extends PrimitiveOrderedListProps {\n /**\n * The keys to use as the keyboard shortcut that will move focus to the toast viewport.\n * @defaultValue ['F8']\n */\n hotkey?: string[];\n /**\n * An author-localized label for the toast viewport to provide context for screen reader users\n * when navigating page landmarks. The available `{hotkey}` placeholder will be replaced for you.\n * @defaultValue 'Notifications ({hotkey})'\n */\n label?: string;\n}\n\nconst ToastViewport = /* @__PURE__ */ React.forwardRef<ToastViewportElement, ToastViewportProps>(\n function ToastViewport(props: ScopedProps<ToastViewportProps>, forwardedRef) {\n const {\n __scopeToast,\n hotkey = VIEWPORT_DEFAULT_HOTKEY,\n label = 'Notifications ({hotkey})',\n ...viewportProps\n } = props;\n const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast);\n const getItems = useCollection(__scopeToast);\n const wrapperRef = React.useRef<HTMLDivElement>(null);\n const headFocusProxyRef = React.useRef<FocusProxyElement>(null);\n const tailFocusProxyRef = React.useRef<FocusProxyElement>(null);\n const ref = React.useRef<ToastViewportElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange);\n const hotkeyLabel = hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '');\n const hasToasts = context.toastCount > 0;\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n // we use `event.code` as it is consistent regardless of meta keys that were pressed.\n // for example, `event.key` for `Control+Alt+t` is `\u2020` and `t !== \u2020`\n const isHotkeyPressed =\n hotkey.length !== 0 && hotkey.every((key) => (event as any)[key] || event.code === key);\n if (isHotkeyPressed) ref.current?.focus();\n };\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [hotkey]);\n\n React.useEffect(() => {\n const wrapper = wrapperRef.current;\n const viewport = ref.current;\n if (hasToasts && wrapper && viewport) {\n const handlePause = () => {\n if (!context.isClosePausedRef.current) {\n const pauseEvent = new CustomEvent(VIEWPORT_PAUSE);\n viewport.dispatchEvent(pauseEvent);\n context.isClosePausedRef.current = true;\n }\n };\n\n const handleResume = () => {\n if (context.isClosePausedRef.current) {\n const resumeEvent = new CustomEvent(VIEWPORT_RESUME);\n viewport.dispatchEvent(resumeEvent);\n context.isClosePausedRef.current = false;\n }\n };\n\n const handleFocusOutResume = (event: FocusEvent) => {\n const isFocusMovingOutside = !wrapper.contains(event.relatedTarget as HTMLElement);\n if (isFocusMovingOutside) handleResume();\n };\n\n const handlePointerLeaveResume = () => {\n const isFocusInside = wrapper.contains(document.activeElement);\n if (!isFocusInside) handleResume();\n };\n\n // Toasts are not in the viewport React tree so we need to bind DOM events\n wrapper.addEventListener('focusin', handlePause);\n wrapper.addEventListener('focusout', handleFocusOutResume);\n wrapper.addEventListener('pointermove', handlePause);\n wrapper.addEventListener('pointerleave', handlePointerLeaveResume);\n window.addEventListener('blur', handlePause);\n window.addEventListener('focus', handleResume);\n return () => {\n wrapper.removeEventListener('focusin', handlePause);\n wrapper.removeEventListener('focusout', handleFocusOutResume);\n wrapper.removeEventListener('pointermove', handlePause);\n wrapper.removeEventListener('pointerleave', handlePointerLeaveResume);\n window.removeEventListener('blur', handlePause);\n window.removeEventListener('focus', handleResume);\n };\n }\n }, [hasToasts, context.isClosePausedRef]);\n\n const getSortedTabbableCandidates = React.useCallback(\n ({ tabbingDirection }: { tabbingDirection: 'forwards' | 'backwards' }) => {\n const toastItems = getItems();\n const tabbableCandidates = toastItems.map((toastItem) => {\n const toastNode = toastItem.ref.current!;\n const toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];\n return tabbingDirection === 'forwards'\n ? toastTabbableCandidates\n : toastTabbableCandidates.reverse();\n });\n return (\n tabbingDirection === 'forwards' ? tabbableCandidates.reverse() : tabbableCandidates\n ).flat();\n },\n [getItems],\n );\n\n React.useEffect(() => {\n const viewport = ref.current;\n // We programmatically manage tabbing as we are unable to influence\n // the source order with portals, this allows us to reverse the\n // tab order so that it runs from most recent toast to least\n if (viewport) {\n const handleKeyDown = (event: KeyboardEvent) => {\n const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;\n const isTabKey = event.key === 'Tab' && !isMetaKey;\n\n if (isTabKey) {\n const focusedElement = document.activeElement;\n const isTabbingBackwards = event.shiftKey;\n const targetIsViewport = event.target === viewport;\n\n // If we're back tabbing after jumping to the viewport then we simply\n // proxy focus out to the preceding document\n if (targetIsViewport && isTabbingBackwards) {\n headFocusProxyRef.current?.focus();\n return;\n }\n\n const tabbingDirection = isTabbingBackwards ? 'backwards' : 'forwards';\n const sortedCandidates = getSortedTabbableCandidates({ tabbingDirection });\n const index = sortedCandidates.findIndex((candidate) => candidate === focusedElement);\n if (focusFirst(sortedCandidates.slice(index + 1))) {\n event.preventDefault();\n } else {\n // If we can't focus that means we're at the edges so we\n // proxy to the corresponding exit point and let the browser handle\n // tab/shift+tab keypress and implicitly pass focus to the next valid element in the document\n isTabbingBackwards\n ? headFocusProxyRef.current?.focus()\n : tailFocusProxyRef.current?.focus();\n }\n }\n };\n\n // Toasts are not in the viewport React tree so we need to bind DOM events\n viewport.addEventListener('keydown', handleKeyDown);\n return () => viewport.removeEventListener('keydown', handleKeyDown);\n }\n }, [getItems, getSortedTabbableCandidates]);\n\n return (\n <DismissableLayer.Branch\n ref={wrapperRef}\n role=\"region\"\n aria-label={label.replace('{hotkey}', hotkeyLabel)}\n // Ensure virtual cursor from landmarks menus triggers focus/blur for pause/resume\n tabIndex={-1}\n // incase list has size when empty (e.g. padding), we remove pointer events so\n // it doesn't prevent interactions with page elements that it overlays\n style={{ pointerEvents: hasToasts ? undefined : 'none' }}\n >\n {hasToasts && (\n <FocusProxy\n ref={headFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'forwards',\n });\n focusFirst(tabbableCandidates);\n }}\n />\n )}\n {/**\n * tabindex on the the list so that it can be focused when items are removed. we focus\n * the list instead of the viewport so it announces number of items remaining.\n */}\n <Collection.Slot scope={__scopeToast}>\n <Primitive.ol tabIndex={-1} {...viewportProps} ref={composedRefs} />\n </Collection.Slot>\n {hasToasts && (\n <FocusProxy\n ref={tailFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'backwards',\n });\n focusFirst(tabbableCandidates);\n }}\n />\n )}\n </DismissableLayer.Branch>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst FOCUS_PROXY_NAME = 'ToastFocusProxy';\n\ntype FocusProxyElement = React.ComponentRef<typeof VisuallyHidden>;\ntype VisuallyHiddenProps = React.ComponentPropsWithoutRef<typeof VisuallyHidden>;\ninterface FocusProxyProps extends VisuallyHiddenProps {\n onFocusFromOutsideViewport(): void;\n}\n\nconst FocusProxy = /* @__PURE__ */ React.forwardRef<\n FocusProxyElement,\n ScopedProps<FocusProxyProps>\n>(\n // blank line to reduce diff noise\n function ToastFocusProxy(props, forwardedRef) {\n const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props;\n const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast);\n\n return (\n <VisuallyHidden\n tabIndex={0}\n {...proxyProps}\n ref={forwardedRef}\n // Avoid page scrolling when focus is on the focus proxy\n style={{ position: 'fixed' }}\n onFocus={(event) => {\n const prevFocusedElement = event.relatedTarget as HTMLElement | null;\n const isFocusFromOutsideViewport = !context.viewport?.contains(prevFocusedElement);\n if (isFocusFromOutsideViewport) onFocusFromOutsideViewport();\n }}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOAST_NAME = 'Toast';\nconst TOAST_SWIPE_START = 'toast.swipeStart';\nconst TOAST_SWIPE_MOVE = 'toast.swipeMove';\nconst TOAST_SWIPE_CANCEL = 'toast.swipeCancel';\nconst TOAST_SWIPE_END = 'toast.swipeEnd';\n\ntype ToastElement = ToastImplElement;\ninterface ToastProps extends Omit<ToastImplProps, keyof ToastImplPrivateProps> {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst Toast = /* @__PURE__ */ React.forwardRef<ToastElement, ToastProps>(\n // blank line to reduce diff noise\n function Toast(props: ScopedProps<ToastProps>, forwardedRef) {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props;\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n caller: TOAST_NAME,\n });\n return (\n <Presence present={forceMount || open}>\n <ToastImpl\n open={open}\n {...toastProps}\n ref={forwardedRef}\n onClose={() => setOpen(false)}\n onPause={useCallbackRef(props.onPause)}\n onResume={useCallbackRef(props.onResume)}\n onSwipeStart={composeEventHandlers(props.onSwipeStart, (event) => {\n event.currentTarget.setAttribute('data-swipe', 'start');\n })}\n onSwipeMove={composeEventHandlers(props.onSwipeMove, (event) => {\n const { x, y } = event.detail.delta;\n event.currentTarget.setAttribute('data-swipe', 'move');\n event.currentTarget.style.setProperty('--radix-toast-swipe-move-x', `${x}px`);\n event.currentTarget.style.setProperty('--radix-toast-swipe-move-y', `${y}px`);\n })}\n onSwipeCancel={composeEventHandlers(props.onSwipeCancel, (event) => {\n event.currentTarget.setAttribute('data-swipe', 'cancel');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-y');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-end-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-end-y');\n })}\n onSwipeEnd={composeEventHandlers(props.onSwipeEnd, (event) => {\n const { x, y } = event.detail.delta;\n event.currentTarget.setAttribute('data-swipe', 'end');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-y');\n event.currentTarget.style.setProperty('--radix-toast-swipe-end-x', `${x}px`);\n event.currentTarget.style.setProperty('--radix-toast-swipe-end-y', `${y}px`);\n setOpen(false);\n })}\n />\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype SwipeEvent = { currentTarget: EventTarget & ToastElement } & Omit<\n CustomEvent<{ originalEvent: React.PointerEvent; delta: { x: number; y: number } }>,\n 'currentTarget'\n>;\n\nconst [ToastInteractiveProvider, useToastInteractiveContext] = createToastContext(TOAST_NAME, {\n onClose() {},\n});\n\ntype ToastImplElement = React.ComponentRef<typeof Primitive.li>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer.Root>;\ntype ToastImplPrivateProps = { open: boolean; onClose(): void };\ntype PrimitiveListItemProps = React.ComponentPropsWithoutRef<typeof Primitive.li>;\ninterface ToastImplProps extends ToastImplPrivateProps, PrimitiveListItemProps {\n type?: ToastType;\n /**\n * Time in milliseconds that toast should remain visible for. Overrides value\n * given to `ToastProvider`.\n */\n duration?: number;\n onEscapeKeyDown?: DismissableLayerProps['onEscapeKeyDown'];\n onPause?(): void;\n onResume?(): void;\n onSwipeStart?(event: SwipeEvent): void;\n onSwipeMove?(event: SwipeEvent): void;\n onSwipeCancel?(event: SwipeEvent): void;\n onSwipeEnd?(event: SwipeEvent): void;\n}\n\nconst ToastImpl = /* @__PURE__ */ React.forwardRef<ToastImplElement, ToastImplProps>(\n function ToastImpl(props: ScopedProps<ToastImplProps>, forwardedRef) {\n const {\n __scopeToast,\n type = ToastType.Foreground,\n duration: durationProp,\n open,\n onClose,\n onEscapeKeyDown,\n onPause,\n onResume,\n onSwipeStart,\n onSwipeMove,\n onSwipeCancel,\n onSwipeEnd,\n ...toastProps\n } = props;\n const context = useToastProviderContext(TOAST_NAME, __scopeToast);\n const getItems = useCollection(__scopeToast);\n const [node, setNode] = React.useState<ToastImplElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setNode);\n const pointerStartRef = React.useRef<{ x: number; y: number } | null>(null);\n const swipeDeltaRef = React.useRef<{ x: number; y: number } | null>(null);\n const duration = durationProp || context.duration;\n const closeTimerStartTimeRef = React.useRef(0);\n const closeTimerRemainingTimeRef = React.useRef(duration);\n const closeTimerRef = React.useRef(0);\n const { onToastAdd, onToastRemove } = context;\n const handleClose = useCallbackRef(() => {\n // focus viewport if focus is within toast to read the remaining toast\n // count to SR users and ensure focus isn't lost\n const isFocusInToast = node?.contains(document.activeElement);\n if (isFocusInToast) context.viewport?.focus();\n onClose();\n });\n\n const startTimer = React.useCallback(\n (duration: number) => {\n if (!duration || duration === Infinity) return;\n window.clearTimeout(closeTimerRef.current);\n closeTimerStartTimeRef.current = new Date().getTime();\n closeTimerRef.current = window.setTimeout(handleClose, duration);\n },\n [handleClose],\n );\n\n React.useEffect(() => {\n const viewport = context.viewport;\n if (viewport) {\n const handleResume = () => {\n startTimer(closeTimerRemainingTimeRef.current);\n onResume?.();\n };\n const handlePause = () => {\n const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current;\n closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime;\n window.clearTimeout(closeTimerRef.current);\n onPause?.();\n };\n viewport.addEventListener(VIEWPORT_PAUSE, handlePause);\n viewport.addEventListener(VIEWPORT_RESUME, handleResume);\n return () => {\n viewport.removeEventListener(VIEWPORT_PAUSE, handlePause);\n viewport.removeEventListener(VIEWPORT_RESUME, handleResume);\n };\n }\n }, [context.viewport, duration, onPause, onResume, startTimer]);\n\n // start timer when toast opens or duration changes.\n // we include `open` in deps because closed !== unmounted when animating\n // so it could reopen before being completely unmounted\n React.useEffect(() => {\n // Reset the remaining time to the duration so a stale value isn't reused\n // when the timer resumes. Without this, a toast that was paused while its\n // duration was `Infinity` (eg. a loading toast) would keep that\n // remaining time after being updated to a finite duration, so it would\n // never close on resume.\n // See https://github.com/radix-ui/primitives/issues/2233\n closeTimerRemainingTimeRef.current = duration;\n if (open && !context.isClosePausedRef.current) {\n startTimer(duration);\n }\n }, [open, duration, context.isClosePausedRef, startTimer]);\n\n // Clear close timer on unmount to prevent memory leaks and errors in test environments\n React.useEffect(() => {\n return () => {\n window.clearTimeout(closeTimerRef.current);\n };\n }, []);\n\n React.useEffect(() => {\n onToastAdd();\n return () => onToastRemove();\n }, [onToastAdd, onToastRemove]);\n\n const announceTextContent = React.useMemo(() => {\n return node ? getAnnounceTextContent(node) : null;\n }, [node]);\n\n if (!context.viewport) return null;\n\n return (\n <>\n {announceTextContent && (\n <ToastAnnounce\n __scopeToast={__scopeToast}\n // Toasts are always role=status to avoid stuttering issues with role=alert in SRs.\n role=\"status\"\n aria-live={type === ToastType.Foreground ? 'assertive' : 'polite'}\n >\n {announceTextContent}\n </ToastAnnounce>\n )}\n\n <ToastInteractiveProvider scope={__scopeToast} onClose={handleClose}>\n {ReactDOM.createPortal(\n <Collection.ItemSlot scope={__scopeToast}>\n <DismissableLayer.Root\n asChild\n onEscapeKeyDown={composeEventHandlers(onEscapeKeyDown, (event) => {\n // Only the highest layer (most recent toast) registers the\n // escape listener, and it runs in the capture phase. If the\n // key press originated from within a focused toast, that\n // toast closes itself via `onKeyDown` below, so we must not\n // also close this (top-most) toast. Otherwise, close it.\n // See: https://github.com/radix-ui/primitives/issues/2906\n const isFocusInToast = getItems().some((item) =>\n item.ref.current?.contains(event.target as Node | null),\n );\n if (!isFocusInToast) {\n handleClose();\n }\n })}\n >\n <Primitive.li\n tabIndex={0}\n data-state={open ? 'open' : 'closed'}\n data-swipe-direction={context.swipeDirection}\n {...toastProps}\n ref={composedRefs}\n style={{ userSelect: 'none', touchAction: 'none', ...props.style }}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (event.key !== 'Escape') return;\n onEscapeKeyDown?.(event.nativeEvent);\n if (!event.nativeEvent.defaultPrevented) {\n handleClose();\n }\n })}\n onPointerDown={composeEventHandlers(props.onPointerDown, (event) => {\n if (event.button !== 0) return;\n pointerStartRef.current = { x: event.clientX, y: event.clientY };\n })}\n onPointerMove={composeEventHandlers(props.onPointerMove, (event) => {\n if (!pointerStartRef.current) return;\n const x = event.clientX - pointerStartRef.current.x;\n const y = event.clientY - pointerStartRef.current.y;\n const hasSwipeMoveStarted = Boolean(swipeDeltaRef.current);\n const isHorizontalSwipe = ['left', 'right'].includes(context.swipeDirection);\n const clamp = ['left', 'up'].includes(context.swipeDirection)\n ? Math.min\n : Math.max;\n const clampedX = isHorizontalSwipe ? clamp(0, x) : 0;\n const clampedY = !isHorizontalSwipe ? clamp(0, y) : 0;\n const moveStartBuffer = event.pointerType === 'touch' ? 10 : 2;\n const delta = { x: clampedX, y: clampedY };\n const eventDetail = { originalEvent: event, delta };\n if (hasSwipeMoveStarted) {\n swipeDeltaRef.current = delta;\n handleAndDispatchCustomEvent(TOAST_SWIPE_MOVE, onSwipeMove, eventDetail, {\n discrete: false,\n });\n } else if (isDeltaInDirection(delta, context.swipeDirection, moveStartBuffer)) {\n swipeDeltaRef.current = delta;\n handleAndDispatchCustomEvent(TOAST_SWIPE_START, onSwipeStart, eventDetail, {\n discrete: false,\n });\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n } else if (Math.abs(x) > moveStartBuffer || Math.abs(y) > moveStartBuffer) {\n // User is swiping in wrong direction so we disable swipe gesture\n // for the current pointer down interaction\n pointerStartRef.current = null;\n }\n })}\n onPointerUp={composeEventHandlers(props.onPointerUp, (event) => {\n const delta = swipeDeltaRef.current;\n const target = event.target as HTMLElement;\n if (target.hasPointerCapture(event.pointerId)) {\n target.releasePointerCapture(event.pointerId);\n }\n swipeDeltaRef.current = null;\n pointerStartRef.current = null;\n if (delta) {\n const toast = event.currentTarget;\n const eventDetail = { originalEvent: event, delta };\n if (\n isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)\n ) {\n handleAndDispatchCustomEvent(TOAST_SWIPE_END, onSwipeEnd, eventDetail, {\n discrete: true,\n });\n } else {\n handleAndDispatchCustomEvent(\n TOAST_SWIPE_CANCEL,\n onSwipeCancel,\n eventDetail,\n {\n discrete: true,\n },\n );\n }\n // Prevent click event from triggering on items within the toast when\n // pointer up is part of a swipe gesture\n toast.addEventListener('click', (event) => event.preventDefault(), {\n once: true,\n });\n }\n })}\n />\n </DismissableLayer.Root>\n </Collection.ItemSlot>,\n context.viewport,\n )}\n </ToastInteractiveProvider>\n </>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ninterface ToastAnnounceProps\n extends\n Omit<React.ComponentPropsWithoutRef<'div'>, 'children'>,\n ScopedProps<{ children: string[] }> {}\n\nconst ToastAnnounce: React.FC<ToastAnnounceProps> = (props: ScopedProps<ToastAnnounceProps>) => {\n const { __scopeToast, children, ...announceProps } = props;\n const context = useToastProviderContext(TOAST_NAME, __scopeToast);\n const [renderAnnounceText, setRenderAnnounceText] = React.useState(false);\n const [isAnnounced, setIsAnnounced] = React.useState(false);\n\n // render text content in the next frame to ensure toast is announced in NVDA\n useNextFrame(() => setRenderAnnounceText(true));\n\n // cleanup after announcing\n React.useEffect(() => {\n const timer = window.setTimeout(() => setIsAnnounced(true), 1000);\n return () => window.clearTimeout(timer);\n }, []);\n\n return isAnnounced ? null : (\n <Portal asChild container={context.announcerContainer || undefined}>\n <VisuallyHidden {...announceProps}>\n {renderAnnounceText && (\n <>\n {context.label} {children}\n </>\n )}\n </VisuallyHidden>\n </Portal>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\ntype ToastTitleElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ToastTitleProps extends PrimitiveDivProps {}\n\nconst ToastTitle = /* @__PURE__ */ React.forwardRef<ToastTitleElement, ToastTitleProps>(\n function ToastTitle(props: ScopedProps<ToastTitleProps>, forwardedRef) {\n const { __scopeToast, ...titleProps } = props;\n return <Primitive.div {...titleProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\ntype ToastDescriptionElement = React.ComponentRef<typeof Primitive.div>;\ninterface ToastDescriptionProps extends PrimitiveDivProps {}\n\nconst ToastDescription = /* @__PURE__ */ React.forwardRef<\n ToastDescriptionElement,\n ToastDescriptionProps\n>(\n // blank line to reduce diff noise\n function ToastDescription(props: ScopedProps<ToastDescriptionProps>, forwardedRef) {\n const { __scopeToast, ...descriptionProps } = props;\n return <Primitive.div {...descriptionProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction';\n\ntype ToastActionElement = ToastCloseElement;\ninterface ToastActionProps extends ToastCloseProps {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to upgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string;\n}\n\nconst ToastAction = /* @__PURE__ */ React.forwardRef<ToastActionElement, ToastActionProps>(\n function ToastAction(props: ScopedProps<ToastActionProps>, forwardedRef) {\n const { altText, ...actionProps } = props;\n\n if (!altText.trim()) {\n console.error(\n `Invalid prop \\`altText\\` supplied to \\`${ACTION_NAME}\\`. Expected non-empty \\`string\\`.`,\n );\n return null;\n }\n\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose';\n\ntype ToastCloseElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface ToastCloseProps extends PrimitiveButtonProps {}\n\nconst ToastClose = /* @__PURE__ */ React.forwardRef<ToastCloseElement, ToastCloseProps>(\n function ToastClose(props: ScopedProps<ToastCloseProps>, forwardedRef) {\n const { __scopeToast, ...closeProps } = props;\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast);\n\n return (\n <ToastAnnounceExclude asChild>\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n );\n },\n);\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype ToastAnnounceExcludeElement = React.ComponentRef<typeof Primitive.div>;\ninterface ToastAnnounceExcludeProps extends PrimitiveDivProps {\n altText?: string;\n}\n\nconst ToastAnnounceExclude = /* @__PURE__ */ React.forwardRef<\n ToastAnnounceExcludeElement,\n ToastAnnounceExcludeProps\n>(function ToastAnnounceExclude(props: ScopedProps<ToastAnnounceExcludeProps>, forwardedRef) {\n const { __scopeToast, altText, ...announceExcludeProps } = props;\n\n return (\n <Primitive.div\n data-radix-toast-announce-exclude=\"\"\n data-radix-toast-announce-alt={altText || undefined}\n {...announceExcludeProps}\n ref={forwardedRef}\n />\n );\n});\n\nfunction getAnnounceTextContent(container: HTMLElement) {\n const textContent: string[] = [];\n const childNodes = Array.from(container.childNodes);\n\n childNodes.forEach((node) => {\n if (node.nodeType === node.TEXT_NODE && node.textContent) textContent.push(node.textContent);\n if (isHTMLElement(node)) {\n const isHidden = node.ariaHidden || node.hidden || node.style.display === 'none';\n const isExcluded = node.dataset.radixToastAnnounceExclude === '';\n\n if (!isHidden) {\n if (isExcluded) {\n const altText = node.dataset.radixToastAnnounceAlt;\n if (altText) textContent.push(altText);\n } else {\n textContent.push(...getAnnounceTextContent(node));\n }\n }\n }\n });\n\n // We return a collection of text rather than a single concatenated string.\n // This allows SR VO to naturally pause break between nodes while announcing.\n return textContent;\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction handleAndDispatchCustomEvent<\n E extends CustomEvent,\n ReactEvent extends React.SyntheticEvent,\n>(\n name: string,\n handler: ((event: E) => void) | undefined,\n detail: { originalEvent: ReactEvent } & (E extends CustomEvent<infer D> ? D : never),\n { discrete }: { discrete: boolean },\n) {\n const currentTarget = detail.originalEvent.currentTarget as HTMLElement;\n const event = new CustomEvent(name, { bubbles: true, cancelable: true, detail });\n if (handler) currentTarget.addEventListener(name, handler as EventListener, { once: true });\n\n if (discrete) {\n dispatchDiscreteCustomEvent(currentTarget, event);\n } else {\n currentTarget.dispatchEvent(event);\n }\n}\n\nconst isDeltaInDirection = (\n delta: { x: number; y: number },\n direction: SwipeDirection,\n threshold = 0,\n) => {\n const deltaX = Math.abs(delta.x);\n const deltaY = Math.abs(delta.y);\n const isDeltaX = deltaX > deltaY;\n if (direction === SwipeDirection.Left || direction === SwipeDirection.Right) {\n return isDeltaX && deltaX > threshold;\n } else {\n return !isDeltaX && deltaY > threshold;\n }\n};\n\nfunction useNextFrame(callback = () => {}) {\n const fn = useCallbackRef(callback);\n useLayoutEffect(() => {\n let raf1 = 0;\n let raf2 = 0;\n raf1 = window.requestAnimationFrame(() => (raf2 = window.requestAnimationFrame(fn)));\n return () => {\n window.cancelAnimationFrame(raf1);\n window.cancelAnimationFrame(raf2);\n };\n }, [fn]);\n}\n\nfunction isHTMLElement(node: any): node is HTMLElement {\n return node.nodeType === node.ELEMENT_NODE;\n}\n\n/**\n * Returns a list of potential tabbable candidates.\n *\n * NOTE: This is only a close approximation. For example it doesn't take into account cases like when\n * elements are not visible. This cannot be worked out easily by just reading a property, but rather\n * necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker\n * Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1\n */\nfunction getTabbableCandidates(container: HTMLElement) {\n const nodes: HTMLElement[] = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: any) => {\n const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden';\n if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;\n // `.tabIndex` is not the same as the `tabindex` attribute. It works on the\n // runtime's understanding of tabbability, so this automatically accounts\n // for any kind of element that could be tabbed to.\n return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n },\n });\n while (walker.nextNode()) nodes.push(walker.currentNode as HTMLElement);\n // we do not take into account the order of nodes with positive `tabIndex` as it\n // hinders accessibility to have tab order different from visual order.\n return nodes;\n}\n\nfunction focusFirst(candidates: HTMLElement[]) {\n const previouslyFocusedElement = document.activeElement;\n return candidates.some((candidate) => {\n // if focus is already where we want to go, we don't want to keep going through the candidates\n if (candidate === previouslyFocusedElement) return true;\n candidate.focus();\n return document.activeElement !== previouslyFocusedElement;\n });\n}\n\nexport {\n createToastScope,\n //\n ToastProvider,\n ToastViewport,\n Toast,\n ToastTitle,\n ToastDescription,\n ToastAction,\n ToastClose,\n //\n ToastProvider as Provider,\n ToastViewport as Viewport,\n Toast as Root,\n ToastTitle as Title,\n ToastDescription as Description,\n ToastAction as Action,\n ToastClose as Close,\n};\nexport type {\n ToastProviderProps,\n ToastViewportProps,\n ToastProps,\n ToastTitleProps,\n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AK,UAAU,cAAe,QAAO,WAAW;AAIrE,aAAO,KAAK,YAAY,IAAI,WAAW,gBAAgB,WAAW;AAAA,IACpE,GAPY;AAAA,EAQd,CAAC;AACD,SAAO,OAAO,SAAS,EAAG,OAAM,KAAK,OAAO,WAA0B;AAGtE,SAAO;AACT;AAhBS;AAkBT,SAAS,WAAW,YAA2B;AAC7C,QAAM,2BAA2B,SAAS;AAC1C,SAAO,WAAW,KAAK,CAAC,cAAc;AAEpC,QAAI,cAAc,yBAA0B,QAAO;AACnD,cAAU,MAAM;AAChB,WAAO,SAAS,kBAAkB;AAAA,EACpC,CAAC;AACH;AARS;",
|
|
6
|
+
"names": ["ToastViewport", "Toast", "ToastImpl", "duration", "event", "ToastTitle", "ToastDescription", "ToastAction", "ToastClose", "ToastAnnounceExclude"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -20,6 +20,16 @@ import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
|
|
|
20
20
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
21
|
var PROVIDER_NAME = "ToastProvider";
|
|
22
22
|
var [Collection, useCollection, createCollectionScope] = createCollection("Toast");
|
|
23
|
+
var SwipeDirection = {
|
|
24
|
+
Up: "up",
|
|
25
|
+
Down: "down",
|
|
26
|
+
Left: "left",
|
|
27
|
+
Right: "right"
|
|
28
|
+
};
|
|
29
|
+
var ToastType = {
|
|
30
|
+
Foreground: "foreground",
|
|
31
|
+
Background: "background"
|
|
32
|
+
};
|
|
23
33
|
var [createToastContext, createToastScope] = createContextScope("Toast", [createCollectionScope]);
|
|
24
34
|
var [ToastProviderProvider, useToastProviderContext] = createToastContext(PROVIDER_NAME);
|
|
25
35
|
var ToastProvider = /* @__PURE__ */ __name((props) => {
|
|
@@ -27,7 +37,7 @@ var ToastProvider = /* @__PURE__ */ __name((props) => {
|
|
|
27
37
|
__scopeToast,
|
|
28
38
|
label = "Notification",
|
|
29
39
|
duration = 5e3,
|
|
30
|
-
swipeDirection =
|
|
40
|
+
swipeDirection = SwipeDirection.Right,
|
|
31
41
|
swipeThreshold = 50,
|
|
32
42
|
announcerContainer,
|
|
33
43
|
children
|
|
@@ -292,7 +302,7 @@ var ToastImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
292
302
|
/* @__PURE__ */ __name(function ToastImpl2(props, forwardedRef) {
|
|
293
303
|
const {
|
|
294
304
|
__scopeToast,
|
|
295
|
-
type =
|
|
305
|
+
type = ToastType.Foreground,
|
|
296
306
|
duration: durationProp,
|
|
297
307
|
open,
|
|
298
308
|
onClose,
|
|
@@ -352,7 +362,10 @@ var ToastImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
352
362
|
}
|
|
353
363
|
}, [context.viewport, duration, onPause, onResume, startTimer]);
|
|
354
364
|
React.useEffect(() => {
|
|
355
|
-
|
|
365
|
+
closeTimerRemainingTimeRef.current = duration;
|
|
366
|
+
if (open && !context.isClosePausedRef.current) {
|
|
367
|
+
startTimer(duration);
|
|
368
|
+
}
|
|
356
369
|
}, [open, duration, context.isClosePausedRef, startTimer]);
|
|
357
370
|
React.useEffect(() => {
|
|
358
371
|
return () => {
|
|
@@ -373,7 +386,7 @@ var ToastImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
373
386
|
{
|
|
374
387
|
__scopeToast,
|
|
375
388
|
role: "status",
|
|
376
|
-
"aria-live": type ===
|
|
389
|
+
"aria-live": type === ToastType.Foreground ? "assertive" : "polite",
|
|
377
390
|
children: announceTextContent
|
|
378
391
|
}
|
|
379
392
|
),
|
|
@@ -582,7 +595,7 @@ var isDeltaInDirection = /* @__PURE__ */ __name((delta, direction, threshold = 0
|
|
|
582
595
|
const deltaX = Math.abs(delta.x);
|
|
583
596
|
const deltaY = Math.abs(delta.y);
|
|
584
597
|
const isDeltaX = deltaX > deltaY;
|
|
585
|
-
if (direction ===
|
|
598
|
+
if (direction === SwipeDirection.Left || direction === SwipeDirection.Right) {
|
|
586
599
|
return isDeltaX && deltaX > threshold;
|
|
587
600
|
} else {
|
|
588
601
|
return !isDeltaX && deltaY > threshold;
|
|
@@ -628,20 +641,13 @@ function focusFirst(candidates) {
|
|
|
628
641
|
});
|
|
629
642
|
}
|
|
630
643
|
__name(focusFirst, "focusFirst");
|
|
631
|
-
var Provider = ToastProvider;
|
|
632
|
-
var Viewport = ToastViewport;
|
|
633
|
-
var Root2 = Toast;
|
|
634
|
-
var Title = ToastTitle;
|
|
635
|
-
var Description = ToastDescription;
|
|
636
|
-
var Action = ToastAction;
|
|
637
|
-
var Close = ToastClose;
|
|
638
644
|
export {
|
|
639
|
-
Action,
|
|
640
|
-
Close,
|
|
641
|
-
Description,
|
|
642
|
-
Provider,
|
|
643
|
-
|
|
644
|
-
Title,
|
|
645
|
+
ToastAction as Action,
|
|
646
|
+
ToastClose as Close,
|
|
647
|
+
ToastDescription as Description,
|
|
648
|
+
ToastProvider as Provider,
|
|
649
|
+
Toast as Root,
|
|
650
|
+
ToastTitle as Title,
|
|
645
651
|
Toast,
|
|
646
652
|
ToastAction,
|
|
647
653
|
ToastClose,
|
|
@@ -649,7 +655,7 @@ export {
|
|
|
649
655
|
ToastProvider,
|
|
650
656
|
ToastTitle,
|
|
651
657
|
ToastViewport,
|
|
652
|
-
Viewport,
|
|
658
|
+
ToastViewport as Viewport,
|
|
653
659
|
createToastScope
|
|
654
660
|
};
|
|
655
661
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/toast.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createCollection } from '@radix-ui/react-collection';\nimport { createContextScope } from '@radix-ui/react-context';\nimport * as DismissableLayer from '@radix-ui/react-dismissable-layer';\nimport { Portal } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive, dispatchDiscreteCustomEvent } from '@radix-ui/react-primitive';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { VisuallyHidden } from '@radix-ui/react-visually-hidden';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * ToastProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'ToastProvider';\n\nconst [Collection, useCollection, createCollectionScope] = createCollection<ToastElement>('Toast');\n\ntype SwipeDirection = 'up' | 'down' | 'left' | 'right';\ntype ToastProviderContextValue = {\n label: string;\n duration: number;\n swipeDirection: SwipeDirection;\n swipeThreshold: number;\n toastCount: number;\n viewport: ToastViewportElement | null;\n onViewportChange(viewport: ToastViewportElement): void;\n onToastAdd(): void;\n onToastRemove(): void;\n isClosePausedRef: React.MutableRefObject<boolean>;\n announcerContainer?: Element | DocumentFragment;\n};\n\ntype ScopedProps<P> = P & { __scopeToast?: Scope };\nconst [createToastContext, createToastScope] = createContextScope('Toast', [createCollectionScope]);\nconst [ToastProviderProvider, useToastProviderContext] =\n createToastContext<ToastProviderContextValue>(PROVIDER_NAME);\n\ninterface ToastProviderProps {\n children?: React.ReactNode;\n /**\n * An author-localized label for each toast. Used to help screen reader users\n * associate the interruption with a toast.\n * @defaultValue 'Notification'\n */\n label?: string;\n /**\n * Time in milliseconds that each toast should remain visible for.\n * @defaultValue 5000\n */\n duration?: number;\n /**\n * Direction of pointer swipe that should close the toast.\n * @defaultValue 'right'\n */\n swipeDirection?: SwipeDirection;\n /**\n * Distance in pixels that the swipe must pass before a close is triggered.\n * @defaultValue 50\n */\n swipeThreshold?: number;\n /**\n * An optional container where the toast announcements should be appended.\n * This is useful when working with focus traps or modal dialogs that make\n * other elements inert.\n * @defaultValue document.body\n */\n announcerContainer?: Element | DocumentFragment;\n}\n\nconst ToastProvider: React.FC<ToastProviderProps> = (props: ScopedProps<ToastProviderProps>) => {\n const {\n __scopeToast,\n label = 'Notification',\n duration = 5000,\n swipeDirection = 'right',\n swipeThreshold = 50,\n announcerContainer,\n children,\n } = props;\n const [viewport, setViewport] = React.useState<ToastViewportElement | null>(null);\n const [toastCount, setToastCount] = React.useState(0);\n const isClosePausedRef = React.useRef(false);\n\n if (!label.trim()) {\n console.error(\n `Invalid prop \\`label\\` supplied to \\`${PROVIDER_NAME}\\`. Expected non-empty \\`string\\`.`,\n );\n }\n\n return (\n <Collection.Provider scope={__scopeToast}>\n <ToastProviderProvider\n scope={__scopeToast}\n label={label}\n duration={duration}\n swipeDirection={swipeDirection}\n swipeThreshold={swipeThreshold}\n toastCount={toastCount}\n viewport={viewport}\n onViewportChange={setViewport}\n onToastAdd={React.useCallback(() => setToastCount((prevCount) => prevCount + 1), [])}\n onToastRemove={React.useCallback(() => setToastCount((prevCount) => prevCount - 1), [])}\n isClosePausedRef={isClosePausedRef}\n announcerContainer={announcerContainer}\n >\n {children}\n </ToastProviderProvider>\n </Collection.Provider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ToastViewport\n * -----------------------------------------------------------------------------------------------*/\n\nconst VIEWPORT_NAME = 'ToastViewport';\nconst VIEWPORT_DEFAULT_HOTKEY = ['F8'];\nconst VIEWPORT_PAUSE = 'toast.viewportPause';\nconst VIEWPORT_RESUME = 'toast.viewportResume';\n\ntype ToastViewportElement = React.ComponentRef<typeof Primitive.ol>;\ntype PrimitiveOrderedListProps = React.ComponentPropsWithoutRef<typeof Primitive.ol>;\ninterface ToastViewportProps extends PrimitiveOrderedListProps {\n /**\n * The keys to use as the keyboard shortcut that will move focus to the toast viewport.\n * @defaultValue ['F8']\n */\n hotkey?: string[];\n /**\n * An author-localized label for the toast viewport to provide context for screen reader users\n * when navigating page landmarks. The available `{hotkey}` placeholder will be replaced for you.\n * @defaultValue 'Notifications ({hotkey})'\n */\n label?: string;\n}\n\nconst ToastViewport = /* @__PURE__ */ React.forwardRef<ToastViewportElement, ToastViewportProps>(\n function ToastViewport(props: ScopedProps<ToastViewportProps>, forwardedRef) {\n const {\n __scopeToast,\n hotkey = VIEWPORT_DEFAULT_HOTKEY,\n label = 'Notifications ({hotkey})',\n ...viewportProps\n } = props;\n const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast);\n const getItems = useCollection(__scopeToast);\n const wrapperRef = React.useRef<HTMLDivElement>(null);\n const headFocusProxyRef = React.useRef<FocusProxyElement>(null);\n const tailFocusProxyRef = React.useRef<FocusProxyElement>(null);\n const ref = React.useRef<ToastViewportElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange);\n const hotkeyLabel = hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '');\n const hasToasts = context.toastCount > 0;\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n // we use `event.code` as it is consistent regardless of meta keys that were pressed.\n // for example, `event.key` for `Control+Alt+t` is `\u2020` and `t !== \u2020`\n const isHotkeyPressed =\n hotkey.length !== 0 && hotkey.every((key) => (event as any)[key] || event.code === key);\n if (isHotkeyPressed) ref.current?.focus();\n };\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [hotkey]);\n\n React.useEffect(() => {\n const wrapper = wrapperRef.current;\n const viewport = ref.current;\n if (hasToasts && wrapper && viewport) {\n const handlePause = () => {\n if (!context.isClosePausedRef.current) {\n const pauseEvent = new CustomEvent(VIEWPORT_PAUSE);\n viewport.dispatchEvent(pauseEvent);\n context.isClosePausedRef.current = true;\n }\n };\n\n const handleResume = () => {\n if (context.isClosePausedRef.current) {\n const resumeEvent = new CustomEvent(VIEWPORT_RESUME);\n viewport.dispatchEvent(resumeEvent);\n context.isClosePausedRef.current = false;\n }\n };\n\n const handleFocusOutResume = (event: FocusEvent) => {\n const isFocusMovingOutside = !wrapper.contains(event.relatedTarget as HTMLElement);\n if (isFocusMovingOutside) handleResume();\n };\n\n const handlePointerLeaveResume = () => {\n const isFocusInside = wrapper.contains(document.activeElement);\n if (!isFocusInside) handleResume();\n };\n\n // Toasts are not in the viewport React tree so we need to bind DOM events\n wrapper.addEventListener('focusin', handlePause);\n wrapper.addEventListener('focusout', handleFocusOutResume);\n wrapper.addEventListener('pointermove', handlePause);\n wrapper.addEventListener('pointerleave', handlePointerLeaveResume);\n window.addEventListener('blur', handlePause);\n window.addEventListener('focus', handleResume);\n return () => {\n wrapper.removeEventListener('focusin', handlePause);\n wrapper.removeEventListener('focusout', handleFocusOutResume);\n wrapper.removeEventListener('pointermove', handlePause);\n wrapper.removeEventListener('pointerleave', handlePointerLeaveResume);\n window.removeEventListener('blur', handlePause);\n window.removeEventListener('focus', handleResume);\n };\n }\n }, [hasToasts, context.isClosePausedRef]);\n\n const getSortedTabbableCandidates = React.useCallback(\n ({ tabbingDirection }: { tabbingDirection: 'forwards' | 'backwards' }) => {\n const toastItems = getItems();\n const tabbableCandidates = toastItems.map((toastItem) => {\n const toastNode = toastItem.ref.current!;\n const toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];\n return tabbingDirection === 'forwards'\n ? toastTabbableCandidates\n : toastTabbableCandidates.reverse();\n });\n return (\n tabbingDirection === 'forwards' ? tabbableCandidates.reverse() : tabbableCandidates\n ).flat();\n },\n [getItems],\n );\n\n React.useEffect(() => {\n const viewport = ref.current;\n // We programmatically manage tabbing as we are unable to influence\n // the source order with portals, this allows us to reverse the\n // tab order so that it runs from most recent toast to least\n if (viewport) {\n const handleKeyDown = (event: KeyboardEvent) => {\n const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;\n const isTabKey = event.key === 'Tab' && !isMetaKey;\n\n if (isTabKey) {\n const focusedElement = document.activeElement;\n const isTabbingBackwards = event.shiftKey;\n const targetIsViewport = event.target === viewport;\n\n // If we're back tabbing after jumping to the viewport then we simply\n // proxy focus out to the preceding document\n if (targetIsViewport && isTabbingBackwards) {\n headFocusProxyRef.current?.focus();\n return;\n }\n\n const tabbingDirection = isTabbingBackwards ? 'backwards' : 'forwards';\n const sortedCandidates = getSortedTabbableCandidates({ tabbingDirection });\n const index = sortedCandidates.findIndex((candidate) => candidate === focusedElement);\n if (focusFirst(sortedCandidates.slice(index + 1))) {\n event.preventDefault();\n } else {\n // If we can't focus that means we're at the edges so we\n // proxy to the corresponding exit point and let the browser handle\n // tab/shift+tab keypress and implicitly pass focus to the next valid element in the document\n isTabbingBackwards\n ? headFocusProxyRef.current?.focus()\n : tailFocusProxyRef.current?.focus();\n }\n }\n };\n\n // Toasts are not in the viewport React tree so we need to bind DOM events\n viewport.addEventListener('keydown', handleKeyDown);\n return () => viewport.removeEventListener('keydown', handleKeyDown);\n }\n }, [getItems, getSortedTabbableCandidates]);\n\n return (\n <DismissableLayer.Branch\n ref={wrapperRef}\n role=\"region\"\n aria-label={label.replace('{hotkey}', hotkeyLabel)}\n // Ensure virtual cursor from landmarks menus triggers focus/blur for pause/resume\n tabIndex={-1}\n // incase list has size when empty (e.g. padding), we remove pointer events so\n // it doesn't prevent interactions with page elements that it overlays\n style={{ pointerEvents: hasToasts ? undefined : 'none' }}\n >\n {hasToasts && (\n <FocusProxy\n ref={headFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'forwards',\n });\n focusFirst(tabbableCandidates);\n }}\n />\n )}\n {/**\n * tabindex on the the list so that it can be focused when items are removed. we focus\n * the list instead of the viewport so it announces number of items remaining.\n */}\n <Collection.Slot scope={__scopeToast}>\n <Primitive.ol tabIndex={-1} {...viewportProps} ref={composedRefs} />\n </Collection.Slot>\n {hasToasts && (\n <FocusProxy\n ref={tailFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'backwards',\n });\n focusFirst(tabbableCandidates);\n }}\n />\n )}\n </DismissableLayer.Branch>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst FOCUS_PROXY_NAME = 'ToastFocusProxy';\n\ntype FocusProxyElement = React.ComponentRef<typeof VisuallyHidden>;\ntype VisuallyHiddenProps = React.ComponentPropsWithoutRef<typeof VisuallyHidden>;\ninterface FocusProxyProps extends VisuallyHiddenProps {\n onFocusFromOutsideViewport(): void;\n}\n\nconst FocusProxy = /* @__PURE__ */ React.forwardRef<\n FocusProxyElement,\n ScopedProps<FocusProxyProps>\n>(\n // blank line to reduce diff noise\n function ToastFocusProxy(props, forwardedRef) {\n const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props;\n const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast);\n\n return (\n <VisuallyHidden\n tabIndex={0}\n {...proxyProps}\n ref={forwardedRef}\n // Avoid page scrolling when focus is on the focus proxy\n style={{ position: 'fixed' }}\n onFocus={(event) => {\n const prevFocusedElement = event.relatedTarget as HTMLElement | null;\n const isFocusFromOutsideViewport = !context.viewport?.contains(prevFocusedElement);\n if (isFocusFromOutsideViewport) onFocusFromOutsideViewport();\n }}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOAST_NAME = 'Toast';\nconst TOAST_SWIPE_START = 'toast.swipeStart';\nconst TOAST_SWIPE_MOVE = 'toast.swipeMove';\nconst TOAST_SWIPE_CANCEL = 'toast.swipeCancel';\nconst TOAST_SWIPE_END = 'toast.swipeEnd';\n\ntype ToastElement = ToastImplElement;\ninterface ToastProps extends Omit<ToastImplProps, keyof ToastImplPrivateProps> {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst Toast = /* @__PURE__ */ React.forwardRef<ToastElement, ToastProps>(\n // blank line to reduce diff noise\n function Toast(props: ScopedProps<ToastProps>, forwardedRef) {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props;\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n caller: TOAST_NAME,\n });\n return (\n <Presence present={forceMount || open}>\n <ToastImpl\n open={open}\n {...toastProps}\n ref={forwardedRef}\n onClose={() => setOpen(false)}\n onPause={useCallbackRef(props.onPause)}\n onResume={useCallbackRef(props.onResume)}\n onSwipeStart={composeEventHandlers(props.onSwipeStart, (event) => {\n event.currentTarget.setAttribute('data-swipe', 'start');\n })}\n onSwipeMove={composeEventHandlers(props.onSwipeMove, (event) => {\n const { x, y } = event.detail.delta;\n event.currentTarget.setAttribute('data-swipe', 'move');\n event.currentTarget.style.setProperty('--radix-toast-swipe-move-x', `${x}px`);\n event.currentTarget.style.setProperty('--radix-toast-swipe-move-y', `${y}px`);\n })}\n onSwipeCancel={composeEventHandlers(props.onSwipeCancel, (event) => {\n event.currentTarget.setAttribute('data-swipe', 'cancel');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-y');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-end-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-end-y');\n })}\n onSwipeEnd={composeEventHandlers(props.onSwipeEnd, (event) => {\n const { x, y } = event.detail.delta;\n event.currentTarget.setAttribute('data-swipe', 'end');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-y');\n event.currentTarget.style.setProperty('--radix-toast-swipe-end-x', `${x}px`);\n event.currentTarget.style.setProperty('--radix-toast-swipe-end-y', `${y}px`);\n setOpen(false);\n })}\n />\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype SwipeEvent = { currentTarget: EventTarget & ToastElement } & Omit<\n CustomEvent<{ originalEvent: React.PointerEvent; delta: { x: number; y: number } }>,\n 'currentTarget'\n>;\n\nconst [ToastInteractiveProvider, useToastInteractiveContext] = createToastContext(TOAST_NAME, {\n onClose() {},\n});\n\ntype ToastImplElement = React.ComponentRef<typeof Primitive.li>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer.Root>;\ntype ToastImplPrivateProps = { open: boolean; onClose(): void };\ntype PrimitiveListItemProps = React.ComponentPropsWithoutRef<typeof Primitive.li>;\ninterface ToastImplProps extends ToastImplPrivateProps, PrimitiveListItemProps {\n type?: 'foreground' | 'background';\n /**\n * Time in milliseconds that toast should remain visible for. Overrides value\n * given to `ToastProvider`.\n */\n duration?: number;\n onEscapeKeyDown?: DismissableLayerProps['onEscapeKeyDown'];\n onPause?(): void;\n onResume?(): void;\n onSwipeStart?(event: SwipeEvent): void;\n onSwipeMove?(event: SwipeEvent): void;\n onSwipeCancel?(event: SwipeEvent): void;\n onSwipeEnd?(event: SwipeEvent): void;\n}\n\nconst ToastImpl = /* @__PURE__ */ React.forwardRef<ToastImplElement, ToastImplProps>(\n function ToastImpl(props: ScopedProps<ToastImplProps>, forwardedRef) {\n const {\n __scopeToast,\n type = 'foreground',\n duration: durationProp,\n open,\n onClose,\n onEscapeKeyDown,\n onPause,\n onResume,\n onSwipeStart,\n onSwipeMove,\n onSwipeCancel,\n onSwipeEnd,\n ...toastProps\n } = props;\n const context = useToastProviderContext(TOAST_NAME, __scopeToast);\n const getItems = useCollection(__scopeToast);\n const [node, setNode] = React.useState<ToastImplElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setNode);\n const pointerStartRef = React.useRef<{ x: number; y: number } | null>(null);\n const swipeDeltaRef = React.useRef<{ x: number; y: number } | null>(null);\n const duration = durationProp || context.duration;\n const closeTimerStartTimeRef = React.useRef(0);\n const closeTimerRemainingTimeRef = React.useRef(duration);\n const closeTimerRef = React.useRef(0);\n const { onToastAdd, onToastRemove } = context;\n const handleClose = useCallbackRef(() => {\n // focus viewport if focus is within toast to read the remaining toast\n // count to SR users and ensure focus isn't lost\n const isFocusInToast = node?.contains(document.activeElement);\n if (isFocusInToast) context.viewport?.focus();\n onClose();\n });\n\n const startTimer = React.useCallback(\n (duration: number) => {\n if (!duration || duration === Infinity) return;\n window.clearTimeout(closeTimerRef.current);\n closeTimerStartTimeRef.current = new Date().getTime();\n closeTimerRef.current = window.setTimeout(handleClose, duration);\n },\n [handleClose],\n );\n\n React.useEffect(() => {\n const viewport = context.viewport;\n if (viewport) {\n const handleResume = () => {\n startTimer(closeTimerRemainingTimeRef.current);\n onResume?.();\n };\n const handlePause = () => {\n const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current;\n closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime;\n window.clearTimeout(closeTimerRef.current);\n onPause?.();\n };\n viewport.addEventListener(VIEWPORT_PAUSE, handlePause);\n viewport.addEventListener(VIEWPORT_RESUME, handleResume);\n return () => {\n viewport.removeEventListener(VIEWPORT_PAUSE, handlePause);\n viewport.removeEventListener(VIEWPORT_RESUME, handleResume);\n };\n }\n }, [context.viewport, duration, onPause, onResume, startTimer]);\n\n // start timer when toast opens or duration changes.\n // we include `open` in deps because closed !== unmounted when animating\n // so it could reopen before being completely unmounted\n React.useEffect(() => {\n if (open && !context.isClosePausedRef.current) startTimer(duration);\n }, [open, duration, context.isClosePausedRef, startTimer]);\n\n // Clear close timer on unmount to prevent memory leaks and errors in test environments\n React.useEffect(() => {\n return () => {\n window.clearTimeout(closeTimerRef.current);\n };\n }, []);\n\n React.useEffect(() => {\n onToastAdd();\n return () => onToastRemove();\n }, [onToastAdd, onToastRemove]);\n\n const announceTextContent = React.useMemo(() => {\n return node ? getAnnounceTextContent(node) : null;\n }, [node]);\n\n if (!context.viewport) return null;\n\n return (\n <>\n {announceTextContent && (\n <ToastAnnounce\n __scopeToast={__scopeToast}\n // Toasts are always role=status to avoid stuttering issues with role=alert in SRs.\n role=\"status\"\n aria-live={type === 'foreground' ? 'assertive' : 'polite'}\n >\n {announceTextContent}\n </ToastAnnounce>\n )}\n\n <ToastInteractiveProvider scope={__scopeToast} onClose={handleClose}>\n {ReactDOM.createPortal(\n <Collection.ItemSlot scope={__scopeToast}>\n <DismissableLayer.Root\n asChild\n onEscapeKeyDown={composeEventHandlers(onEscapeKeyDown, (event) => {\n // Only the highest layer (most recent toast) registers the\n // escape listener, and it runs in the capture phase. If the\n // key press originated from within a focused toast, that\n // toast closes itself via `onKeyDown` below, so we must not\n // also close this (top-most) toast. Otherwise, close it.\n // See: https://github.com/radix-ui/primitives/issues/2906\n const isFocusInToast = getItems().some((item) =>\n item.ref.current?.contains(event.target as Node | null),\n );\n if (!isFocusInToast) {\n handleClose();\n }\n })}\n >\n <Primitive.li\n tabIndex={0}\n data-state={open ? 'open' : 'closed'}\n data-swipe-direction={context.swipeDirection}\n {...toastProps}\n ref={composedRefs}\n style={{ userSelect: 'none', touchAction: 'none', ...props.style }}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (event.key !== 'Escape') return;\n onEscapeKeyDown?.(event.nativeEvent);\n if (!event.nativeEvent.defaultPrevented) {\n handleClose();\n }\n })}\n onPointerDown={composeEventHandlers(props.onPointerDown, (event) => {\n if (event.button !== 0) return;\n pointerStartRef.current = { x: event.clientX, y: event.clientY };\n })}\n onPointerMove={composeEventHandlers(props.onPointerMove, (event) => {\n if (!pointerStartRef.current) return;\n const x = event.clientX - pointerStartRef.current.x;\n const y = event.clientY - pointerStartRef.current.y;\n const hasSwipeMoveStarted = Boolean(swipeDeltaRef.current);\n const isHorizontalSwipe = ['left', 'right'].includes(context.swipeDirection);\n const clamp = ['left', 'up'].includes(context.swipeDirection)\n ? Math.min\n : Math.max;\n const clampedX = isHorizontalSwipe ? clamp(0, x) : 0;\n const clampedY = !isHorizontalSwipe ? clamp(0, y) : 0;\n const moveStartBuffer = event.pointerType === 'touch' ? 10 : 2;\n const delta = { x: clampedX, y: clampedY };\n const eventDetail = { originalEvent: event, delta };\n if (hasSwipeMoveStarted) {\n swipeDeltaRef.current = delta;\n handleAndDispatchCustomEvent(TOAST_SWIPE_MOVE, onSwipeMove, eventDetail, {\n discrete: false,\n });\n } else if (isDeltaInDirection(delta, context.swipeDirection, moveStartBuffer)) {\n swipeDeltaRef.current = delta;\n handleAndDispatchCustomEvent(TOAST_SWIPE_START, onSwipeStart, eventDetail, {\n discrete: false,\n });\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n } else if (Math.abs(x) > moveStartBuffer || Math.abs(y) > moveStartBuffer) {\n // User is swiping in wrong direction so we disable swipe gesture\n // for the current pointer down interaction\n pointerStartRef.current = null;\n }\n })}\n onPointerUp={composeEventHandlers(props.onPointerUp, (event) => {\n const delta = swipeDeltaRef.current;\n const target = event.target as HTMLElement;\n if (target.hasPointerCapture(event.pointerId)) {\n target.releasePointerCapture(event.pointerId);\n }\n swipeDeltaRef.current = null;\n pointerStartRef.current = null;\n if (delta) {\n const toast = event.currentTarget;\n const eventDetail = { originalEvent: event, delta };\n if (\n isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)\n ) {\n handleAndDispatchCustomEvent(TOAST_SWIPE_END, onSwipeEnd, eventDetail, {\n discrete: true,\n });\n } else {\n handleAndDispatchCustomEvent(\n TOAST_SWIPE_CANCEL,\n onSwipeCancel,\n eventDetail,\n {\n discrete: true,\n },\n );\n }\n // Prevent click event from triggering on items within the toast when\n // pointer up is part of a swipe gesture\n toast.addEventListener('click', (event) => event.preventDefault(), {\n once: true,\n });\n }\n })}\n />\n </DismissableLayer.Root>\n </Collection.ItemSlot>,\n context.viewport,\n )}\n </ToastInteractiveProvider>\n </>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ninterface ToastAnnounceProps\n extends\n Omit<React.ComponentPropsWithoutRef<'div'>, 'children'>,\n ScopedProps<{ children: string[] }> {}\n\nconst ToastAnnounce: React.FC<ToastAnnounceProps> = (props: ScopedProps<ToastAnnounceProps>) => {\n const { __scopeToast, children, ...announceProps } = props;\n const context = useToastProviderContext(TOAST_NAME, __scopeToast);\n const [renderAnnounceText, setRenderAnnounceText] = React.useState(false);\n const [isAnnounced, setIsAnnounced] = React.useState(false);\n\n // render text content in the next frame to ensure toast is announced in NVDA\n useNextFrame(() => setRenderAnnounceText(true));\n\n // cleanup after announcing\n React.useEffect(() => {\n const timer = window.setTimeout(() => setIsAnnounced(true), 1000);\n return () => window.clearTimeout(timer);\n }, []);\n\n return isAnnounced ? null : (\n <Portal asChild container={context.announcerContainer || undefined}>\n <VisuallyHidden {...announceProps}>\n {renderAnnounceText && (\n <>\n {context.label} {children}\n </>\n )}\n </VisuallyHidden>\n </Portal>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\ntype ToastTitleElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ToastTitleProps extends PrimitiveDivProps {}\n\nconst ToastTitle = /* @__PURE__ */ React.forwardRef<ToastTitleElement, ToastTitleProps>(\n function ToastTitle(props: ScopedProps<ToastTitleProps>, forwardedRef) {\n const { __scopeToast, ...titleProps } = props;\n return <Primitive.div {...titleProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\ntype ToastDescriptionElement = React.ComponentRef<typeof Primitive.div>;\ninterface ToastDescriptionProps extends PrimitiveDivProps {}\n\nconst ToastDescription = /* @__PURE__ */ React.forwardRef<\n ToastDescriptionElement,\n ToastDescriptionProps\n>(\n // blank line to reduce diff noise\n function ToastDescription(props: ScopedProps<ToastDescriptionProps>, forwardedRef) {\n const { __scopeToast, ...descriptionProps } = props;\n return <Primitive.div {...descriptionProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction';\n\ntype ToastActionElement = ToastCloseElement;\ninterface ToastActionProps extends ToastCloseProps {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to upgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string;\n}\n\nconst ToastAction = /* @__PURE__ */ React.forwardRef<ToastActionElement, ToastActionProps>(\n function ToastAction(props: ScopedProps<ToastActionProps>, forwardedRef) {\n const { altText, ...actionProps } = props;\n\n if (!altText.trim()) {\n console.error(\n `Invalid prop \\`altText\\` supplied to \\`${ACTION_NAME}\\`. Expected non-empty \\`string\\`.`,\n );\n return null;\n }\n\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose';\n\ntype ToastCloseElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface ToastCloseProps extends PrimitiveButtonProps {}\n\nconst ToastClose = /* @__PURE__ */ React.forwardRef<ToastCloseElement, ToastCloseProps>(\n function ToastClose(props: ScopedProps<ToastCloseProps>, forwardedRef) {\n const { __scopeToast, ...closeProps } = props;\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast);\n\n return (\n <ToastAnnounceExclude asChild>\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n );\n },\n);\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype ToastAnnounceExcludeElement = React.ComponentRef<typeof Primitive.div>;\ninterface ToastAnnounceExcludeProps extends PrimitiveDivProps {\n altText?: string;\n}\n\nconst ToastAnnounceExclude = /* @__PURE__ */ React.forwardRef<\n ToastAnnounceExcludeElement,\n ToastAnnounceExcludeProps\n>(function ToastAnnounceExclude(props: ScopedProps<ToastAnnounceExcludeProps>, forwardedRef) {\n const { __scopeToast, altText, ...announceExcludeProps } = props;\n\n return (\n <Primitive.div\n data-radix-toast-announce-exclude=\"\"\n data-radix-toast-announce-alt={altText || undefined}\n {...announceExcludeProps}\n ref={forwardedRef}\n />\n );\n});\n\nfunction getAnnounceTextContent(container: HTMLElement) {\n const textContent: string[] = [];\n const childNodes = Array.from(container.childNodes);\n\n childNodes.forEach((node) => {\n if (node.nodeType === node.TEXT_NODE && node.textContent) textContent.push(node.textContent);\n if (isHTMLElement(node)) {\n const isHidden = node.ariaHidden || node.hidden || node.style.display === 'none';\n const isExcluded = node.dataset.radixToastAnnounceExclude === '';\n\n if (!isHidden) {\n if (isExcluded) {\n const altText = node.dataset.radixToastAnnounceAlt;\n if (altText) textContent.push(altText);\n } else {\n textContent.push(...getAnnounceTextContent(node));\n }\n }\n }\n });\n\n // We return a collection of text rather than a single concatenated string.\n // This allows SR VO to naturally pause break between nodes while announcing.\n return textContent;\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction handleAndDispatchCustomEvent<\n E extends CustomEvent,\n ReactEvent extends React.SyntheticEvent,\n>(\n name: string,\n handler: ((event: E) => void) | undefined,\n detail: { originalEvent: ReactEvent } & (E extends CustomEvent<infer D> ? D : never),\n { discrete }: { discrete: boolean },\n) {\n const currentTarget = detail.originalEvent.currentTarget as HTMLElement;\n const event = new CustomEvent(name, { bubbles: true, cancelable: true, detail });\n if (handler) currentTarget.addEventListener(name, handler as EventListener, { once: true });\n\n if (discrete) {\n dispatchDiscreteCustomEvent(currentTarget, event);\n } else {\n currentTarget.dispatchEvent(event);\n }\n}\n\nconst isDeltaInDirection = (\n delta: { x: number; y: number },\n direction: SwipeDirection,\n threshold = 0,\n) => {\n const deltaX = Math.abs(delta.x);\n const deltaY = Math.abs(delta.y);\n const isDeltaX = deltaX > deltaY;\n if (direction === 'left' || direction === 'right') {\n return isDeltaX && deltaX > threshold;\n } else {\n return !isDeltaX && deltaY > threshold;\n }\n};\n\nfunction useNextFrame(callback = () => {}) {\n const fn = useCallbackRef(callback);\n useLayoutEffect(() => {\n let raf1 = 0;\n let raf2 = 0;\n raf1 = window.requestAnimationFrame(() => (raf2 = window.requestAnimationFrame(fn)));\n return () => {\n window.cancelAnimationFrame(raf1);\n window.cancelAnimationFrame(raf2);\n };\n }, [fn]);\n}\n\nfunction isHTMLElement(node: any): node is HTMLElement {\n return node.nodeType === node.ELEMENT_NODE;\n}\n\n/**\n * Returns a list of potential tabbable candidates.\n *\n * NOTE: This is only a close approximation. For example it doesn't take into account cases like when\n * elements are not visible. This cannot be worked out easily by just reading a property, but rather\n * necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker\n * Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1\n */\nfunction getTabbableCandidates(container: HTMLElement) {\n const nodes: HTMLElement[] = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: any) => {\n const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden';\n if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;\n // `.tabIndex` is not the same as the `tabindex` attribute. It works on the\n // runtime's understanding of tabbability, so this automatically accounts\n // for any kind of element that could be tabbed to.\n return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n },\n });\n while (walker.nextNode()) nodes.push(walker.currentNode as HTMLElement);\n // we do not take into account the order of nodes with positive `tabIndex` as it\n // hinders accessibility to have tab order different from visual order.\n return nodes;\n}\n\nfunction focusFirst(candidates: HTMLElement[]) {\n const previouslyFocusedElement = document.activeElement;\n return candidates.some((candidate) => {\n // if focus is already where we want to go, we don't want to keep going through the candidates\n if (candidate === previouslyFocusedElement) return true;\n candidate.focus();\n return document.activeElement !== previouslyFocusedElement;\n });\n}\n\nconst Provider = ToastProvider;\nconst Viewport = ToastViewport;\nconst Root = Toast;\nconst Title = ToastTitle;\nconst Description = ToastDescription;\nconst Action = ToastAction;\nconst Close = ToastClose;\n\nexport {\n createToastScope,\n //\n ToastProvider,\n ToastViewport,\n Toast,\n ToastTitle,\n ToastDescription,\n ToastAction,\n ToastClose,\n //\n Provider,\n Viewport,\n Root,\n Title,\n Description,\n Action,\n Close,\n};\nexport type {\n ToastProviderProps,\n ToastViewportProps,\n ToastProps,\n ToastTitleProps,\n ToastDescriptionProps,\n ToastActionProps,\n ToastCloseProps,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,YAAY,cAAc;AAC1B,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,YAAY,sBAAsB;AAClC,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,WAAW,mCAAmC;AACvD,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAsFzB,SA8cA,UA9cA,KAyLA,YAzLA;AA9EN,IAAM,gBAAgB;AAEtB,IAAM,CAAC,YAAY,eAAe,qBAAqB,IAAI,iBAA+B,OAAO;AAkBjG,IAAM,CAAC,oBAAoB,gBAAgB,IAAI,mBAAmB,SAAS,CAAC,qBAAqB,CAAC;AAClG,IAAM,CAAC,uBAAuB,uBAAuB,IACnD,mBAA8C,aAAa;AAkC7D,IAAM,gBAA8C,wBAAC,UAA2C;AAC9F,QAAM;AAAA,IACJ;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,CAAC,UAAU,WAAW,IAAU,eAAsC,IAAI;AAChF,QAAM,CAAC,YAAY,aAAa,IAAU,eAAS,CAAC;AACpD,QAAM,mBAAyB,aAAO,KAAK;AA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UAAI,KAAK,YAAY,KAAK,UAAU,cAAe,QAAO,WAAW;AAIrE,aAAO,KAAK,YAAY,IAAI,WAAW,gBAAgB,WAAW;AAAA,IACpE,GAPY;AAAA,EAQd,CAAC;AACD,SAAO,OAAO,SAAS,EAAG,OAAM,KAAK,OAAO,WAA0B;AAGtE,SAAO;AACT;AAhBS;AAkBT,SAAS,WAAW,YAA2B;AAC7C,QAAM,2BAA2B,SAAS;AAC1C,SAAO,WAAW,KAAK,CAAC,cAAc;AAEpC,QAAI,cAAc,yBAA0B,QAAO;AACnD,cAAU,MAAM;AAChB,WAAO,SAAS,kBAAkB;AAAA,EACpC,CAAC;AACH;AARS;AAUT,IAAM,WAAW;AACjB,IAAM,WAAW;AACjB,IAAMC,QAAO;AACb,IAAM,QAAQ;AACd,IAAM,cAAc;AACpB,IAAM,SAAS;AACf,IAAM,QAAQ;",
|
|
6
|
-
"names": ["ToastViewport", "Toast", "ToastImpl", "duration", "event", "ToastTitle", "ToastDescription", "ToastAction", "ToastClose", "ToastAnnounceExclude"
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createCollection } from '@radix-ui/react-collection';\nimport { createContextScope } from '@radix-ui/react-context';\nimport * as DismissableLayer from '@radix-ui/react-dismissable-layer';\nimport { Portal } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive, dispatchDiscreteCustomEvent } from '@radix-ui/react-primitive';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { VisuallyHidden } from '@radix-ui/react-visually-hidden';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * ToastProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'ToastProvider';\n\nconst [Collection, useCollection, createCollectionScope] = createCollection<ToastElement>('Toast');\n\nconst SwipeDirection = {\n Up: 'up',\n Down: 'down',\n Left: 'left',\n Right: 'right',\n} as const;\n\nconst ToastType = {\n Foreground: 'foreground',\n Background: 'background',\n} as const;\n\ntype SwipeDirection = (typeof SwipeDirection)[keyof typeof SwipeDirection];\ntype ToastType = (typeof ToastType)[keyof typeof ToastType];\n\ntype ToastProviderContextValue = {\n label: string;\n duration: number;\n swipeDirection: SwipeDirection;\n swipeThreshold: number;\n toastCount: number;\n viewport: ToastViewportElement | null;\n onViewportChange(viewport: ToastViewportElement): void;\n onToastAdd(): void;\n onToastRemove(): void;\n isClosePausedRef: React.MutableRefObject<boolean>;\n announcerContainer?: Element | DocumentFragment;\n};\n\ntype ScopedProps<P> = P & { __scopeToast?: Scope };\nconst [createToastContext, createToastScope] = createContextScope('Toast', [createCollectionScope]);\nconst [ToastProviderProvider, useToastProviderContext] =\n createToastContext<ToastProviderContextValue>(PROVIDER_NAME);\n\ninterface ToastProviderProps {\n children?: React.ReactNode;\n /**\n * An author-localized label for each toast. Used to help screen reader users\n * associate the interruption with a toast.\n * @defaultValue 'Notification'\n */\n label?: string;\n /**\n * Time in milliseconds that each toast should remain visible for.\n * @defaultValue 5000\n */\n duration?: number;\n /**\n * Direction of pointer swipe that should close the toast.\n * @defaultValue 'right'\n */\n swipeDirection?: SwipeDirection;\n /**\n * Distance in pixels that the swipe must pass before a close is triggered.\n * @defaultValue 50\n */\n swipeThreshold?: number;\n /**\n * An optional container where the toast announcements should be appended.\n * This is useful when working with focus traps or modal dialogs that make\n * other elements inert.\n * @defaultValue document.body\n */\n announcerContainer?: Element | DocumentFragment;\n}\n\nconst ToastProvider: React.FC<ToastProviderProps> = (props: ScopedProps<ToastProviderProps>) => {\n const {\n __scopeToast,\n label = 'Notification',\n duration = 5000,\n swipeDirection = SwipeDirection.Right,\n swipeThreshold = 50,\n announcerContainer,\n children,\n } = props;\n const [viewport, setViewport] = React.useState<ToastViewportElement | null>(null);\n const [toastCount, setToastCount] = React.useState(0);\n const isClosePausedRef = React.useRef(false);\n\n if (!label.trim()) {\n console.error(\n `Invalid prop \\`label\\` supplied to \\`${PROVIDER_NAME}\\`. Expected non-empty \\`string\\`.`,\n );\n }\n\n return (\n <Collection.Provider scope={__scopeToast}>\n <ToastProviderProvider\n scope={__scopeToast}\n label={label}\n duration={duration}\n swipeDirection={swipeDirection}\n swipeThreshold={swipeThreshold}\n toastCount={toastCount}\n viewport={viewport}\n onViewportChange={setViewport}\n onToastAdd={React.useCallback(() => setToastCount((prevCount) => prevCount + 1), [])}\n onToastRemove={React.useCallback(() => setToastCount((prevCount) => prevCount - 1), [])}\n isClosePausedRef={isClosePausedRef}\n announcerContainer={announcerContainer}\n >\n {children}\n </ToastProviderProvider>\n </Collection.Provider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ToastViewport\n * -----------------------------------------------------------------------------------------------*/\n\nconst VIEWPORT_NAME = 'ToastViewport';\nconst VIEWPORT_DEFAULT_HOTKEY = ['F8'];\nconst VIEWPORT_PAUSE = 'toast.viewportPause';\nconst VIEWPORT_RESUME = 'toast.viewportResume';\n\ntype ToastViewportElement = React.ComponentRef<typeof Primitive.ol>;\ntype PrimitiveOrderedListProps = React.ComponentPropsWithoutRef<typeof Primitive.ol>;\ninterface ToastViewportProps extends PrimitiveOrderedListProps {\n /**\n * The keys to use as the keyboard shortcut that will move focus to the toast viewport.\n * @defaultValue ['F8']\n */\n hotkey?: string[];\n /**\n * An author-localized label for the toast viewport to provide context for screen reader users\n * when navigating page landmarks. The available `{hotkey}` placeholder will be replaced for you.\n * @defaultValue 'Notifications ({hotkey})'\n */\n label?: string;\n}\n\nconst ToastViewport = /* @__PURE__ */ React.forwardRef<ToastViewportElement, ToastViewportProps>(\n function ToastViewport(props: ScopedProps<ToastViewportProps>, forwardedRef) {\n const {\n __scopeToast,\n hotkey = VIEWPORT_DEFAULT_HOTKEY,\n label = 'Notifications ({hotkey})',\n ...viewportProps\n } = props;\n const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast);\n const getItems = useCollection(__scopeToast);\n const wrapperRef = React.useRef<HTMLDivElement>(null);\n const headFocusProxyRef = React.useRef<FocusProxyElement>(null);\n const tailFocusProxyRef = React.useRef<FocusProxyElement>(null);\n const ref = React.useRef<ToastViewportElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange);\n const hotkeyLabel = hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '');\n const hasToasts = context.toastCount > 0;\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n // we use `event.code` as it is consistent regardless of meta keys that were pressed.\n // for example, `event.key` for `Control+Alt+t` is `\u2020` and `t !== \u2020`\n const isHotkeyPressed =\n hotkey.length !== 0 && hotkey.every((key) => (event as any)[key] || event.code === key);\n if (isHotkeyPressed) ref.current?.focus();\n };\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [hotkey]);\n\n React.useEffect(() => {\n const wrapper = wrapperRef.current;\n const viewport = ref.current;\n if (hasToasts && wrapper && viewport) {\n const handlePause = () => {\n if (!context.isClosePausedRef.current) {\n const pauseEvent = new CustomEvent(VIEWPORT_PAUSE);\n viewport.dispatchEvent(pauseEvent);\n context.isClosePausedRef.current = true;\n }\n };\n\n const handleResume = () => {\n if (context.isClosePausedRef.current) {\n const resumeEvent = new CustomEvent(VIEWPORT_RESUME);\n viewport.dispatchEvent(resumeEvent);\n context.isClosePausedRef.current = false;\n }\n };\n\n const handleFocusOutResume = (event: FocusEvent) => {\n const isFocusMovingOutside = !wrapper.contains(event.relatedTarget as HTMLElement);\n if (isFocusMovingOutside) handleResume();\n };\n\n const handlePointerLeaveResume = () => {\n const isFocusInside = wrapper.contains(document.activeElement);\n if (!isFocusInside) handleResume();\n };\n\n // Toasts are not in the viewport React tree so we need to bind DOM events\n wrapper.addEventListener('focusin', handlePause);\n wrapper.addEventListener('focusout', handleFocusOutResume);\n wrapper.addEventListener('pointermove', handlePause);\n wrapper.addEventListener('pointerleave', handlePointerLeaveResume);\n window.addEventListener('blur', handlePause);\n window.addEventListener('focus', handleResume);\n return () => {\n wrapper.removeEventListener('focusin', handlePause);\n wrapper.removeEventListener('focusout', handleFocusOutResume);\n wrapper.removeEventListener('pointermove', handlePause);\n wrapper.removeEventListener('pointerleave', handlePointerLeaveResume);\n window.removeEventListener('blur', handlePause);\n window.removeEventListener('focus', handleResume);\n };\n }\n }, [hasToasts, context.isClosePausedRef]);\n\n const getSortedTabbableCandidates = React.useCallback(\n ({ tabbingDirection }: { tabbingDirection: 'forwards' | 'backwards' }) => {\n const toastItems = getItems();\n const tabbableCandidates = toastItems.map((toastItem) => {\n const toastNode = toastItem.ref.current!;\n const toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];\n return tabbingDirection === 'forwards'\n ? toastTabbableCandidates\n : toastTabbableCandidates.reverse();\n });\n return (\n tabbingDirection === 'forwards' ? tabbableCandidates.reverse() : tabbableCandidates\n ).flat();\n },\n [getItems],\n );\n\n React.useEffect(() => {\n const viewport = ref.current;\n // We programmatically manage tabbing as we are unable to influence\n // the source order with portals, this allows us to reverse the\n // tab order so that it runs from most recent toast to least\n if (viewport) {\n const handleKeyDown = (event: KeyboardEvent) => {\n const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;\n const isTabKey = event.key === 'Tab' && !isMetaKey;\n\n if (isTabKey) {\n const focusedElement = document.activeElement;\n const isTabbingBackwards = event.shiftKey;\n const targetIsViewport = event.target === viewport;\n\n // If we're back tabbing after jumping to the viewport then we simply\n // proxy focus out to the preceding document\n if (targetIsViewport && isTabbingBackwards) {\n headFocusProxyRef.current?.focus();\n return;\n }\n\n const tabbingDirection = isTabbingBackwards ? 'backwards' : 'forwards';\n const sortedCandidates = getSortedTabbableCandidates({ tabbingDirection });\n const index = sortedCandidates.findIndex((candidate) => candidate === focusedElement);\n if (focusFirst(sortedCandidates.slice(index + 1))) {\n event.preventDefault();\n } else {\n // If we can't focus that means we're at the edges so we\n // proxy to the corresponding exit point and let the browser handle\n // tab/shift+tab keypress and implicitly pass focus to the next valid element in the document\n isTabbingBackwards\n ? headFocusProxyRef.current?.focus()\n : tailFocusProxyRef.current?.focus();\n }\n }\n };\n\n // Toasts are not in the viewport React tree so we need to bind DOM events\n viewport.addEventListener('keydown', handleKeyDown);\n return () => viewport.removeEventListener('keydown', handleKeyDown);\n }\n }, [getItems, getSortedTabbableCandidates]);\n\n return (\n <DismissableLayer.Branch\n ref={wrapperRef}\n role=\"region\"\n aria-label={label.replace('{hotkey}', hotkeyLabel)}\n // Ensure virtual cursor from landmarks menus triggers focus/blur for pause/resume\n tabIndex={-1}\n // incase list has size when empty (e.g. padding), we remove pointer events so\n // it doesn't prevent interactions with page elements that it overlays\n style={{ pointerEvents: hasToasts ? undefined : 'none' }}\n >\n {hasToasts && (\n <FocusProxy\n ref={headFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'forwards',\n });\n focusFirst(tabbableCandidates);\n }}\n />\n )}\n {/**\n * tabindex on the the list so that it can be focused when items are removed. we focus\n * the list instead of the viewport so it announces number of items remaining.\n */}\n <Collection.Slot scope={__scopeToast}>\n <Primitive.ol tabIndex={-1} {...viewportProps} ref={composedRefs} />\n </Collection.Slot>\n {hasToasts && (\n <FocusProxy\n ref={tailFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'backwards',\n });\n focusFirst(tabbableCandidates);\n }}\n />\n )}\n </DismissableLayer.Branch>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst FOCUS_PROXY_NAME = 'ToastFocusProxy';\n\ntype FocusProxyElement = React.ComponentRef<typeof VisuallyHidden>;\ntype VisuallyHiddenProps = React.ComponentPropsWithoutRef<typeof VisuallyHidden>;\ninterface FocusProxyProps extends VisuallyHiddenProps {\n onFocusFromOutsideViewport(): void;\n}\n\nconst FocusProxy = /* @__PURE__ */ React.forwardRef<\n FocusProxyElement,\n ScopedProps<FocusProxyProps>\n>(\n // blank line to reduce diff noise\n function ToastFocusProxy(props, forwardedRef) {\n const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props;\n const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast);\n\n return (\n <VisuallyHidden\n tabIndex={0}\n {...proxyProps}\n ref={forwardedRef}\n // Avoid page scrolling when focus is on the focus proxy\n style={{ position: 'fixed' }}\n onFocus={(event) => {\n const prevFocusedElement = event.relatedTarget as HTMLElement | null;\n const isFocusFromOutsideViewport = !context.viewport?.contains(prevFocusedElement);\n if (isFocusFromOutsideViewport) onFocusFromOutsideViewport();\n }}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOAST_NAME = 'Toast';\nconst TOAST_SWIPE_START = 'toast.swipeStart';\nconst TOAST_SWIPE_MOVE = 'toast.swipeMove';\nconst TOAST_SWIPE_CANCEL = 'toast.swipeCancel';\nconst TOAST_SWIPE_END = 'toast.swipeEnd';\n\ntype ToastElement = ToastImplElement;\ninterface ToastProps extends Omit<ToastImplProps, keyof ToastImplPrivateProps> {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst Toast = /* @__PURE__ */ React.forwardRef<ToastElement, ToastProps>(\n // blank line to reduce diff noise\n function Toast(props: ScopedProps<ToastProps>, forwardedRef) {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props;\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n caller: TOAST_NAME,\n });\n return (\n <Presence present={forceMount || open}>\n <ToastImpl\n open={open}\n {...toastProps}\n ref={forwardedRef}\n onClose={() => setOpen(false)}\n onPause={useCallbackRef(props.onPause)}\n onResume={useCallbackRef(props.onResume)}\n onSwipeStart={composeEventHandlers(props.onSwipeStart, (event) => {\n event.currentTarget.setAttribute('data-swipe', 'start');\n })}\n onSwipeMove={composeEventHandlers(props.onSwipeMove, (event) => {\n const { x, y } = event.detail.delta;\n event.currentTarget.setAttribute('data-swipe', 'move');\n event.currentTarget.style.setProperty('--radix-toast-swipe-move-x', `${x}px`);\n event.currentTarget.style.setProperty('--radix-toast-swipe-move-y', `${y}px`);\n })}\n onSwipeCancel={composeEventHandlers(props.onSwipeCancel, (event) => {\n event.currentTarget.setAttribute('data-swipe', 'cancel');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-y');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-end-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-end-y');\n })}\n onSwipeEnd={composeEventHandlers(props.onSwipeEnd, (event) => {\n const { x, y } = event.detail.delta;\n event.currentTarget.setAttribute('data-swipe', 'end');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-x');\n event.currentTarget.style.removeProperty('--radix-toast-swipe-move-y');\n event.currentTarget.style.setProperty('--radix-toast-swipe-end-x', `${x}px`);\n event.currentTarget.style.setProperty('--radix-toast-swipe-end-y', `${y}px`);\n setOpen(false);\n })}\n />\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype SwipeEvent = { currentTarget: EventTarget & ToastElement } & Omit<\n CustomEvent<{ originalEvent: React.PointerEvent; delta: { x: number; y: number } }>,\n 'currentTarget'\n>;\n\nconst [ToastInteractiveProvider, useToastInteractiveContext] = createToastContext(TOAST_NAME, {\n onClose() {},\n});\n\ntype ToastImplElement = React.ComponentRef<typeof Primitive.li>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer.Root>;\ntype ToastImplPrivateProps = { open: boolean; onClose(): void };\ntype PrimitiveListItemProps = React.ComponentPropsWithoutRef<typeof Primitive.li>;\ninterface ToastImplProps extends ToastImplPrivateProps, PrimitiveListItemProps {\n type?: ToastType;\n /**\n * Time in milliseconds that toast should remain visible for. Overrides value\n * given to `ToastProvider`.\n */\n duration?: number;\n onEscapeKeyDown?: DismissableLayerProps['onEscapeKeyDown'];\n onPause?(): void;\n onResume?(): void;\n onSwipeStart?(event: SwipeEvent): void;\n onSwipeMove?(event: SwipeEvent): void;\n onSwipeCancel?(event: SwipeEvent): void;\n onSwipeEnd?(event: SwipeEvent): void;\n}\n\nconst ToastImpl = /* @__PURE__ */ React.forwardRef<ToastImplElement, ToastImplProps>(\n function ToastImpl(props: ScopedProps<ToastImplProps>, forwardedRef) {\n const {\n __scopeToast,\n type = ToastType.Foreground,\n duration: durationProp,\n open,\n onClose,\n onEscapeKeyDown,\n onPause,\n onResume,\n onSwipeStart,\n onSwipeMove,\n onSwipeCancel,\n onSwipeEnd,\n ...toastProps\n } = props;\n const context = useToastProviderContext(TOAST_NAME, __scopeToast);\n const getItems = useCollection(__scopeToast);\n const [node, setNode] = React.useState<ToastImplElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setNode);\n const pointerStartRef = React.useRef<{ x: number; y: number } | null>(null);\n const swipeDeltaRef = React.useRef<{ x: number; y: number } | null>(null);\n const duration = durationProp || context.duration;\n const closeTimerStartTimeRef = React.useRef(0);\n const closeTimerRemainingTimeRef = React.useRef(duration);\n const closeTimerRef = React.useRef(0);\n const { onToastAdd, onToastRemove } = context;\n const handleClose = useCallbackRef(() => {\n // focus viewport if focus is within toast to read the remaining toast\n // count to SR users and ensure focus isn't lost\n const isFocusInToast = node?.contains(document.activeElement);\n if (isFocusInToast) context.viewport?.focus();\n onClose();\n });\n\n const startTimer = React.useCallback(\n (duration: number) => {\n if (!duration || duration === Infinity) return;\n window.clearTimeout(closeTimerRef.current);\n closeTimerStartTimeRef.current = new Date().getTime();\n closeTimerRef.current = window.setTimeout(handleClose, duration);\n },\n [handleClose],\n );\n\n React.useEffect(() => {\n const viewport = context.viewport;\n if (viewport) {\n const handleResume = () => {\n startTimer(closeTimerRemainingTimeRef.current);\n onResume?.();\n };\n const handlePause = () => {\n const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current;\n closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime;\n window.clearTimeout(closeTimerRef.current);\n onPause?.();\n };\n viewport.addEventListener(VIEWPORT_PAUSE, handlePause);\n viewport.addEventListener(VIEWPORT_RESUME, handleResume);\n return () => {\n viewport.removeEventListener(VIEWPORT_PAUSE, handlePause);\n viewport.removeEventListener(VIEWPORT_RESUME, handleResume);\n };\n }\n }, [context.viewport, duration, onPause, onResume, startTimer]);\n\n // start timer when toast opens or duration changes.\n // we include `open` in deps because closed !== unmounted when animating\n // so it could reopen before being completely unmounted\n React.useEffect(() => {\n // Reset the remaining time to the duration so a stale value isn't reused\n // when the timer resumes. Without this, a toast that was paused while its\n // duration was `Infinity` (eg. a loading toast) would keep that\n // remaining time after being updated to a finite duration, so it would\n // never close on resume.\n // See https://github.com/radix-ui/primitives/issues/2233\n closeTimerRemainingTimeRef.current = duration;\n if (open && !context.isClosePausedRef.current) {\n startTimer(duration);\n }\n }, [open, duration, context.isClosePausedRef, startTimer]);\n\n // Clear close timer on unmount to prevent memory leaks and errors in test environments\n React.useEffect(() => {\n return () => {\n window.clearTimeout(closeTimerRef.current);\n };\n }, []);\n\n React.useEffect(() => {\n onToastAdd();\n return () => onToastRemove();\n }, [onToastAdd, onToastRemove]);\n\n const announceTextContent = React.useMemo(() => {\n return node ? getAnnounceTextContent(node) : null;\n }, [node]);\n\n if (!context.viewport) return null;\n\n return (\n <>\n {announceTextContent && (\n <ToastAnnounce\n __scopeToast={__scopeToast}\n // Toasts are always role=status to avoid stuttering issues with role=alert in SRs.\n role=\"status\"\n aria-live={type === ToastType.Foreground ? 'assertive' : 'polite'}\n >\n {announceTextContent}\n </ToastAnnounce>\n )}\n\n <ToastInteractiveProvider scope={__scopeToast} onClose={handleClose}>\n {ReactDOM.createPortal(\n <Collection.ItemSlot scope={__scopeToast}>\n <DismissableLayer.Root\n asChild\n onEscapeKeyDown={composeEventHandlers(onEscapeKeyDown, (event) => {\n // Only the highest layer (most recent toast) registers the\n // escape listener, and it runs in the capture phase. If the\n // key press originated from within a focused toast, that\n // toast closes itself via `onKeyDown` below, so we must not\n // also close this (top-most) toast. Otherwise, close it.\n // See: https://github.com/radix-ui/primitives/issues/2906\n const isFocusInToast = getItems().some((item) =>\n item.ref.current?.contains(event.target as Node | null),\n );\n if (!isFocusInToast) {\n handleClose();\n }\n })}\n >\n <Primitive.li\n tabIndex={0}\n data-state={open ? 'open' : 'closed'}\n data-swipe-direction={context.swipeDirection}\n {...toastProps}\n ref={composedRefs}\n style={{ userSelect: 'none', touchAction: 'none', ...props.style }}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (event.key !== 'Escape') return;\n onEscapeKeyDown?.(event.nativeEvent);\n if (!event.nativeEvent.defaultPrevented) {\n handleClose();\n }\n })}\n onPointerDown={composeEventHandlers(props.onPointerDown, (event) => {\n if (event.button !== 0) return;\n pointerStartRef.current = { x: event.clientX, y: event.clientY };\n })}\n onPointerMove={composeEventHandlers(props.onPointerMove, (event) => {\n if (!pointerStartRef.current) return;\n const x = event.clientX - pointerStartRef.current.x;\n const y = event.clientY - pointerStartRef.current.y;\n const hasSwipeMoveStarted = Boolean(swipeDeltaRef.current);\n const isHorizontalSwipe = ['left', 'right'].includes(context.swipeDirection);\n const clamp = ['left', 'up'].includes(context.swipeDirection)\n ? Math.min\n : Math.max;\n const clampedX = isHorizontalSwipe ? clamp(0, x) : 0;\n const clampedY = !isHorizontalSwipe ? clamp(0, y) : 0;\n const moveStartBuffer = event.pointerType === 'touch' ? 10 : 2;\n const delta = { x: clampedX, y: clampedY };\n const eventDetail = { originalEvent: event, delta };\n if (hasSwipeMoveStarted) {\n swipeDeltaRef.current = delta;\n handleAndDispatchCustomEvent(TOAST_SWIPE_MOVE, onSwipeMove, eventDetail, {\n discrete: false,\n });\n } else if (isDeltaInDirection(delta, context.swipeDirection, moveStartBuffer)) {\n swipeDeltaRef.current = delta;\n handleAndDispatchCustomEvent(TOAST_SWIPE_START, onSwipeStart, eventDetail, {\n discrete: false,\n });\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n } else if (Math.abs(x) > moveStartBuffer || Math.abs(y) > moveStartBuffer) {\n // User is swiping in wrong direction so we disable swipe gesture\n // for the current pointer down interaction\n pointerStartRef.current = null;\n }\n })}\n onPointerUp={composeEventHandlers(props.onPointerUp, (event) => {\n const delta = swipeDeltaRef.current;\n const target = event.target as HTMLElement;\n if (target.hasPointerCapture(event.pointerId)) {\n target.releasePointerCapture(event.pointerId);\n }\n swipeDeltaRef.current = null;\n pointerStartRef.current = null;\n if (delta) {\n const toast = event.currentTarget;\n const eventDetail = { originalEvent: event, delta };\n if (\n isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)\n ) {\n handleAndDispatchCustomEvent(TOAST_SWIPE_END, onSwipeEnd, eventDetail, {\n discrete: true,\n });\n } else {\n handleAndDispatchCustomEvent(\n TOAST_SWIPE_CANCEL,\n onSwipeCancel,\n eventDetail,\n {\n discrete: true,\n },\n );\n }\n // Prevent click event from triggering on items within the toast when\n // pointer up is part of a swipe gesture\n toast.addEventListener('click', (event) => event.preventDefault(), {\n once: true,\n });\n }\n })}\n />\n </DismissableLayer.Root>\n </Collection.ItemSlot>,\n context.viewport,\n )}\n </ToastInteractiveProvider>\n </>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ninterface ToastAnnounceProps\n extends\n Omit<React.ComponentPropsWithoutRef<'div'>, 'children'>,\n ScopedProps<{ children: string[] }> {}\n\nconst ToastAnnounce: React.FC<ToastAnnounceProps> = (props: ScopedProps<ToastAnnounceProps>) => {\n const { __scopeToast, children, ...announceProps } = props;\n const context = useToastProviderContext(TOAST_NAME, __scopeToast);\n const [renderAnnounceText, setRenderAnnounceText] = React.useState(false);\n const [isAnnounced, setIsAnnounced] = React.useState(false);\n\n // render text content in the next frame to ensure toast is announced in NVDA\n useNextFrame(() => setRenderAnnounceText(true));\n\n // cleanup after announcing\n React.useEffect(() => {\n const timer = window.setTimeout(() => setIsAnnounced(true), 1000);\n return () => window.clearTimeout(timer);\n }, []);\n\n return isAnnounced ? null : (\n <Portal asChild container={context.announcerContainer || undefined}>\n <VisuallyHidden {...announceProps}>\n {renderAnnounceText && (\n <>\n {context.label} {children}\n </>\n )}\n </VisuallyHidden>\n </Portal>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\ntype ToastTitleElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ToastTitleProps extends PrimitiveDivProps {}\n\nconst ToastTitle = /* @__PURE__ */ React.forwardRef<ToastTitleElement, ToastTitleProps>(\n function ToastTitle(props: ScopedProps<ToastTitleProps>, forwardedRef) {\n const { __scopeToast, ...titleProps } = props;\n return <Primitive.div {...titleProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\ntype ToastDescriptionElement = React.ComponentRef<typeof Primitive.div>;\ninterface ToastDescriptionProps extends PrimitiveDivProps {}\n\nconst ToastDescription = /* @__PURE__ */ React.forwardRef<\n ToastDescriptionElement,\n ToastDescriptionProps\n>(\n // blank line to reduce diff noise\n function ToastDescription(props: ScopedProps<ToastDescriptionProps>, forwardedRef) {\n const { __scopeToast, ...descriptionProps } = props;\n return <Primitive.div {...descriptionProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction';\n\ntype ToastActionElement = ToastCloseElement;\ninterface ToastActionProps extends ToastCloseProps {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to upgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string;\n}\n\nconst ToastAction = /* @__PURE__ */ React.forwardRef<ToastActionElement, ToastActionProps>(\n function ToastAction(props: ScopedProps<ToastActionProps>, forwardedRef) {\n const { altText, ...actionProps } = props;\n\n if (!altText.trim()) {\n console.error(\n `Invalid prop \\`altText\\` supplied to \\`${ACTION_NAME}\\`. Expected non-empty \\`string\\`.`,\n );\n return null;\n }\n\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose';\n\ntype ToastCloseElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface ToastCloseProps extends PrimitiveButtonProps {}\n\nconst ToastClose = /* @__PURE__ */ React.forwardRef<ToastCloseElement, ToastCloseProps>(\n function ToastClose(props: ScopedProps<ToastCloseProps>, forwardedRef) {\n const { __scopeToast, ...closeProps } = props;\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast);\n\n return (\n <ToastAnnounceExclude asChild>\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n );\n },\n);\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype ToastAnnounceExcludeElement = React.ComponentRef<typeof Primitive.div>;\ninterface ToastAnnounceExcludeProps extends PrimitiveDivProps {\n altText?: string;\n}\n\nconst ToastAnnounceExclude = /* @__PURE__ */ React.forwardRef<\n ToastAnnounceExcludeElement,\n ToastAnnounceExcludeProps\n>(function ToastAnnounceExclude(props: ScopedProps<ToastAnnounceExcludeProps>, forwardedRef) {\n const { __scopeToast, altText, ...announceExcludeProps } = props;\n\n return (\n <Primitive.div\n data-radix-toast-announce-exclude=\"\"\n data-radix-toast-announce-alt={altText || undefined}\n {...announceExcludeProps}\n ref={forwardedRef}\n />\n );\n});\n\nfunction getAnnounceTextContent(container: HTMLElement) {\n const textContent: string[] = [];\n const childNodes = Array.from(container.childNodes);\n\n childNodes.forEach((node) => {\n if (node.nodeType === node.TEXT_NODE && node.textContent) textContent.push(node.textContent);\n if (isHTMLElement(node)) {\n const isHidden = node.ariaHidden || node.hidden || node.style.display === 'none';\n const isExcluded = node.dataset.radixToastAnnounceExclude === '';\n\n if (!isHidden) {\n if (isExcluded) {\n const altText = node.dataset.radixToastAnnounceAlt;\n if (altText) textContent.push(altText);\n } else {\n textContent.push(...getAnnounceTextContent(node));\n }\n }\n }\n });\n\n // We return a collection of text rather than a single concatenated string.\n // This allows SR VO to naturally pause break between nodes while announcing.\n return textContent;\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction handleAndDispatchCustomEvent<\n E extends CustomEvent,\n ReactEvent extends React.SyntheticEvent,\n>(\n name: string,\n handler: ((event: E) => void) | undefined,\n detail: { originalEvent: ReactEvent } & (E extends CustomEvent<infer D> ? D : never),\n { discrete }: { discrete: boolean },\n) {\n const currentTarget = detail.originalEvent.currentTarget as HTMLElement;\n const event = new CustomEvent(name, { bubbles: true, cancelable: true, detail });\n if (handler) currentTarget.addEventListener(name, handler as EventListener, { once: true });\n\n if (discrete) {\n dispatchDiscreteCustomEvent(currentTarget, event);\n } else {\n currentTarget.dispatchEvent(event);\n }\n}\n\nconst isDeltaInDirection = (\n delta: { x: number; y: number },\n direction: SwipeDirection,\n threshold = 0,\n) => {\n const deltaX = Math.abs(delta.x);\n const deltaY = Math.abs(delta.y);\n const isDeltaX = deltaX > deltaY;\n if (direction === SwipeDirection.Left || direction === SwipeDirection.Right) {\n return isDeltaX && deltaX > threshold;\n } else {\n return !isDeltaX && deltaY > threshold;\n }\n};\n\nfunction useNextFrame(callback = () => {}) {\n const fn = useCallbackRef(callback);\n useLayoutEffect(() => {\n let raf1 = 0;\n let raf2 = 0;\n raf1 = window.requestAnimationFrame(() => (raf2 = window.requestAnimationFrame(fn)));\n return () => {\n window.cancelAnimationFrame(raf1);\n window.cancelAnimationFrame(raf2);\n };\n }, [fn]);\n}\n\nfunction isHTMLElement(node: any): node is HTMLElement {\n return node.nodeType === node.ELEMENT_NODE;\n}\n\n/**\n * Returns a list of potential tabbable candidates.\n *\n * NOTE: This is only a close approximation. For example it doesn't take into account cases like when\n * elements are not visible. This cannot be worked out easily by just reading a property, but rather\n * necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker\n * Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1\n */\nfunction getTabbableCandidates(container: HTMLElement) {\n const nodes: HTMLElement[] = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: any) => {\n const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden';\n if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;\n // `.tabIndex` is not the same as the `tabindex` attribute. It works on the\n // runtime's understanding of tabbability, so this automatically accounts\n // for any kind of element that could be tabbed to.\n return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n },\n });\n while (walker.nextNode()) nodes.push(walker.currentNode as HTMLElement);\n // we do not take into account the order of nodes with positive `tabIndex` as it\n // hinders accessibility to have tab order different from visual order.\n return nodes;\n}\n\nfunction focusFirst(candidates: HTMLElement[]) {\n const previouslyFocusedElement = document.activeElement;\n return candidates.some((candidate) => {\n // if focus is already where we want to go, we don't want to keep going through the candidates\n if (candidate === previouslyFocusedElement) return true;\n candidate.focus();\n return document.activeElement !== previouslyFocusedElement;\n });\n}\n\nexport {\n createToastScope,\n //\n ToastProvider,\n ToastViewport,\n Toast,\n ToastTitle,\n ToastDescription,\n ToastAction,\n ToastClose,\n //\n ToastProvider as Provider,\n ToastViewport as Viewport,\n Toast as Root,\n ToastTitle as Title,\n ToastDescription as Description,\n ToastAction as Action,\n ToastClose as Close,\n};\nexport type {\n ToastProviderProps,\n ToastViewportProps,\n ToastProps,\n ToastTitleProps,\n ToastDescriptionProps,\n ToastActionProps,\n ToastCloseProps,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,YAAY,cAAc;AAC1B,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,YAAY,sBAAsB;AAClC,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,WAAW,mCAAmC;AACvD,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAoGzB,SAudA,UAvdA,KAyLA,YAzLA;AA5FN,IAAM,gBAAgB;AAEtB,IAAM,CAAC,YAAY,eAAe,qBAAqB,IAAI,iBAA+B,OAAO;AAEjG,IAAM,iBAAiB;AAAA,EACrB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAEA,IAAM,YAAY;AAAA,EAChB,YAAY;AAAA,EACZ,YAAY;AACd;AAoBA,IAAM,CAAC,oBAAoB,gBAAgB,IAAI,mBAAmB,SAAS,CAAC,qBAAqB,CAAC;AAClG,IAAM,CAAC,uBAAuB,uBAAuB,IACnD,mBAA8C,aAAa;AAkC7D,IAAM,gBAA8C,wBAAC,UAA2C;AAC9F,QAAM;AAAA,IACJ;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,iBAAiB,eAAe;AAAA,IAChC,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,EACF,IA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ChC;AAFS;AAcT,SAAS,sBAAsB,WAAwB;AACrD,QAAM,QAAuB,CAAC;AAC9B,QAAM,SAAS,SAAS,iBAAiB,WAAW,WAAW,cAAc;AAAA,IAC3E,YAAY,wBAAC,SAAc;AACzB,YAAM,gBAAgB,KAAK,YAAY,WAAW,KAAK,SAAS;AAChE,UAAI,KAAK,YAAY,KAAK,UAAU,cAAe,QAAO,WAAW;AAIrE,aAAO,KAAK,YAAY,IAAI,WAAW,gBAAgB,WAAW;AAAA,IACpE,GAPY;AAAA,EAQd,CAAC;AACD,SAAO,OAAO,SAAS,EAAG,OAAM,KAAK,OAAO,WAA0B;AAGtE,SAAO;AACT;AAhBS;AAkBT,SAAS,WAAW,YAA2B;AAC7C,QAAM,2BAA2B,SAAS;AAC1C,SAAO,WAAW,KAAK,CAAC,cAAc;AAEpC,QAAI,cAAc,yBAA0B,QAAO;AACnD,cAAU,MAAM;AAChB,WAAO,SAAS,kBAAkB;AAAA,EACpC,CAAC;AACH;AARS;",
|
|
6
|
+
"names": ["ToastViewport", "Toast", "ToastImpl", "duration", "event", "ToastTitle", "ToastDescription", "ToastAction", "ToastClose", "ToastAnnounceExclude"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-toast",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.21-rc.1784603841447",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,27 +12,27 @@
|
|
|
12
12
|
"sideEffects": false,
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@radix-ui/primitive": "1.1.6",
|
|
15
|
-
"@radix-ui/react-collection": "1.1.
|
|
15
|
+
"@radix-ui/react-collection": "1.1.13-rc.1784603841447",
|
|
16
16
|
"@radix-ui/react-compose-refs": "1.1.3",
|
|
17
17
|
"@radix-ui/react-context": "1.2.0",
|
|
18
|
-
"@radix-ui/react-
|
|
19
|
-
"@radix-ui/react-
|
|
20
|
-
"@radix-ui/react-
|
|
21
|
-
"@radix-ui/react-primitive": "2.1.
|
|
18
|
+
"@radix-ui/react-portal": "1.1.15-rc.1784603841447",
|
|
19
|
+
"@radix-ui/react-use-callback-ref": "1.1.2",
|
|
20
|
+
"@radix-ui/react-dismissable-layer": "1.1.17-rc.1784603841447",
|
|
21
|
+
"@radix-ui/react-primitive": "2.1.8-rc.1784603841447",
|
|
22
22
|
"@radix-ui/react-use-controllable-state": "1.2.4",
|
|
23
|
-
"@radix-ui/react-
|
|
24
|
-
"@radix-ui/react-
|
|
25
|
-
"@radix-ui/react-use-
|
|
23
|
+
"@radix-ui/react-visually-hidden": "1.2.9-rc.1784603841447",
|
|
24
|
+
"@radix-ui/react-presence": "1.1.9-rc.1784603841447",
|
|
25
|
+
"@radix-ui/react-use-layout-effect": "1.1.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/react": "^19.2.
|
|
29
|
-
"@types/react-dom": "^19.2.
|
|
30
|
-
"react": "^19.2.
|
|
31
|
-
"react-dom": "^19.2.
|
|
28
|
+
"@types/react": "^19.2.17",
|
|
29
|
+
"@types/react-dom": "^19.2.3",
|
|
30
|
+
"react": "^19.2.7",
|
|
31
|
+
"react-dom": "^19.2.7",
|
|
32
32
|
"typescript": "^5.9.3",
|
|
33
33
|
"@repo/builder": "0.0.0",
|
|
34
|
-
"@repo/
|
|
35
|
-
"@repo/
|
|
34
|
+
"@repo/test-utils": "0.0.0",
|
|
35
|
+
"@repo/typescript-config": "0.0.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@types/react": "*",
|