@octanejs/radix 0.1.32 → 0.1.33
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/cjs/AccessibleIcon.cjs +56 -0
- package/dist/cjs/Accordion.cjs +272 -0
- package/dist/cjs/AlertDialog.cjs +144 -0
- package/dist/cjs/Arrow.cjs +43 -0
- package/dist/cjs/AspectRatio.cjs +56 -0
- package/dist/cjs/Avatar.cjs +150 -0
- package/dist/cjs/Checkbox.cjs +281 -0
- package/dist/cjs/Collapsible.cjs +176 -0
- package/dist/cjs/ContextMenu.cjs +315 -0
- package/dist/cjs/Dialog.cjs +291 -0
- package/dist/cjs/DismissableLayer.cjs +382 -0
- package/dist/cjs/DropdownMenu.cjs +296 -0
- package/dist/cjs/FocusScope.cjs +257 -0
- package/dist/cjs/Form.cjs +537 -0
- package/dist/cjs/HoverCard.cjs +309 -0
- package/dist/cjs/Label.cjs +42 -0
- package/dist/cjs/Menu.cjs +925 -0
- package/dist/cjs/Menubar.cjs +475 -0
- package/dist/cjs/NavigationMenu.cjs +942 -0
- package/dist/cjs/OneTimePasswordField.cjs +729 -0
- package/dist/cjs/PasswordToggleField.cjs +377 -0
- package/dist/cjs/Popover.cjs +340 -0
- package/dist/cjs/Popper.cjs +368 -0
- package/dist/cjs/Portal.cjs +40 -0
- package/dist/cjs/Presence.cjs +183 -0
- package/dist/cjs/Primitive.cjs +63 -0
- package/dist/cjs/Progress.cjs +111 -0
- package/dist/cjs/Radio.cjs +240 -0
- package/dist/cjs/RadioGroup.cjs +216 -0
- package/dist/cjs/RovingFocusGroup.cjs +253 -0
- package/dist/cjs/ScrollArea.cjs +828 -0
- package/dist/cjs/Select.cjs +1429 -0
- package/dist/cjs/Separator.cjs +51 -0
- package/dist/cjs/Slider.cjs +634 -0
- package/dist/cjs/Slot.cjs +97 -0
- package/dist/cjs/Switch.cjs +253 -0
- package/dist/cjs/Tabs.cjs +195 -0
- package/dist/cjs/Toast.cjs +733 -0
- package/dist/cjs/Toggle.cjs +54 -0
- package/dist/cjs/ToggleGroup.cjs +174 -0
- package/dist/cjs/Toolbar.cjs +165 -0
- package/dist/cjs/Tooltip.cjs +628 -0
- package/dist/cjs/VisuallyHidden.cjs +52 -0
- package/dist/cjs/collection.cjs +95 -0
- package/dist/cjs/compose-event-handlers.cjs +35 -0
- package/dist/cjs/compose-refs.cjs +68 -0
- package/dist/cjs/context.cjs +96 -0
- package/dist/cjs/direction.cjs +41 -0
- package/dist/cjs/focus-guards.cjs +76 -0
- package/dist/cjs/index.cjs +174 -0
- package/dist/cjs/internal.cjs +51 -0
- package/dist/cjs/scroll-lock.cjs +67 -0
- package/dist/cjs/use-callback-ref.cjs +47 -0
- package/dist/cjs/use-effect-event.cjs +52 -0
- package/dist/cjs/use-is-hydrated.cjs +43 -0
- package/dist/cjs/use-previous.cjs +47 -0
- package/dist/cjs/use-size.cjs +69 -0
- package/dist/cjs/useControllableState.cjs +80 -0
- package/dist/cjs/useId.cjs +36 -0
- package/package.json +14 -7
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Toast_exports = {};
|
|
20
|
+
__export(Toast_exports, {
|
|
21
|
+
Action: () => Action,
|
|
22
|
+
Close: () => Close,
|
|
23
|
+
Description: () => Description,
|
|
24
|
+
Provider: () => Provider,
|
|
25
|
+
Root: () => Root,
|
|
26
|
+
Title: () => Title,
|
|
27
|
+
Toast: () => Root,
|
|
28
|
+
ToastAction: () => Action,
|
|
29
|
+
ToastClose: () => Close,
|
|
30
|
+
ToastDescription: () => Description,
|
|
31
|
+
ToastProvider: () => Provider,
|
|
32
|
+
ToastTitle: () => Title,
|
|
33
|
+
ToastViewport: () => Viewport,
|
|
34
|
+
Viewport: () => Viewport,
|
|
35
|
+
createToastScope: () => createToastScope
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(Toast_exports);
|
|
38
|
+
var import_octane = require("octane");
|
|
39
|
+
var import_collection = require("./collection.cjs");
|
|
40
|
+
var import_compose_event_handlers = require("./compose-event-handlers.cjs");
|
|
41
|
+
var import_compose_refs = require("./compose-refs.cjs");
|
|
42
|
+
var import_context = require("./context.cjs");
|
|
43
|
+
var import_DismissableLayer = require("./DismissableLayer.cjs");
|
|
44
|
+
var import_internal = require("./internal.cjs");
|
|
45
|
+
var import_Portal = require("./Portal.cjs");
|
|
46
|
+
var import_Presence = require("./Presence.cjs");
|
|
47
|
+
var import_Primitive = require("./Primitive.cjs");
|
|
48
|
+
var import_use_callback_ref = require("./use-callback-ref.cjs");
|
|
49
|
+
var import_useControllableState = require("./useControllableState.cjs");
|
|
50
|
+
var import_VisuallyHidden = require("./VisuallyHidden.cjs");
|
|
51
|
+
const PROVIDER_NAME = "ToastProvider";
|
|
52
|
+
const [Collection, useCollection, createCollectionScope] = (0, import_collection.createCollection)("Toast");
|
|
53
|
+
const [createToastContext, createToastScope] = (0, import_context.createContextScope)("Toast", [createCollectionScope]);
|
|
54
|
+
const [ToastProviderProvider, useToastProviderContext] = createToastContext(PROVIDER_NAME);
|
|
55
|
+
function Provider(props) {
|
|
56
|
+
const slot = (0, import_internal.S)("Toast.Provider");
|
|
57
|
+
const {
|
|
58
|
+
__scopeToast,
|
|
59
|
+
label = "Notification",
|
|
60
|
+
duration = 5e3,
|
|
61
|
+
swipeDirection = "right",
|
|
62
|
+
swipeThreshold = 50,
|
|
63
|
+
announcerContainer,
|
|
64
|
+
children
|
|
65
|
+
} = props ?? {};
|
|
66
|
+
const [viewport, setViewport] = (0, import_octane.useState)(null, (0, import_internal.subSlot)(slot, "viewport"));
|
|
67
|
+
const [toastCount, setToastCount] = (0, import_octane.useState)(0, (0, import_internal.subSlot)(slot, "count"));
|
|
68
|
+
const isFocusedToastEscapeKeyDownRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "escKeyDown"));
|
|
69
|
+
const isClosePausedRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "paused"));
|
|
70
|
+
return (0, import_octane.createElement)(Collection.Provider, {
|
|
71
|
+
scope: __scopeToast,
|
|
72
|
+
children: (0, import_octane.createElement)(ToastProviderProvider, {
|
|
73
|
+
scope: __scopeToast,
|
|
74
|
+
label,
|
|
75
|
+
duration,
|
|
76
|
+
swipeDirection,
|
|
77
|
+
swipeThreshold,
|
|
78
|
+
toastCount,
|
|
79
|
+
viewport,
|
|
80
|
+
onViewportChange: setViewport,
|
|
81
|
+
onToastAdd: (0, import_octane.useCallback)(
|
|
82
|
+
() => setToastCount((prevCount) => prevCount + 1),
|
|
83
|
+
[],
|
|
84
|
+
(0, import_internal.subSlot)(slot, "add")
|
|
85
|
+
),
|
|
86
|
+
onToastRemove: (0, import_octane.useCallback)(
|
|
87
|
+
() => setToastCount((prevCount) => prevCount - 1),
|
|
88
|
+
[],
|
|
89
|
+
(0, import_internal.subSlot)(slot, "remove")
|
|
90
|
+
),
|
|
91
|
+
isFocusedToastEscapeKeyDownRef,
|
|
92
|
+
isClosePausedRef,
|
|
93
|
+
announcerContainer,
|
|
94
|
+
children
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const VIEWPORT_NAME = "ToastViewport";
|
|
99
|
+
const VIEWPORT_DEFAULT_HOTKEY = ["F8"];
|
|
100
|
+
const VIEWPORT_PAUSE = "toast.viewportPause";
|
|
101
|
+
const VIEWPORT_RESUME = "toast.viewportResume";
|
|
102
|
+
function Viewport(props) {
|
|
103
|
+
const slot = (0, import_internal.S)("Toast.Viewport");
|
|
104
|
+
const {
|
|
105
|
+
__scopeToast,
|
|
106
|
+
hotkey = VIEWPORT_DEFAULT_HOTKEY,
|
|
107
|
+
label = "Notifications ({hotkey})",
|
|
108
|
+
ref: forwardedRef,
|
|
109
|
+
...viewportProps
|
|
110
|
+
} = props ?? {};
|
|
111
|
+
const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast);
|
|
112
|
+
const getItems = useCollection(__scopeToast, (0, import_internal.subSlot)(slot, "items"));
|
|
113
|
+
const wrapperRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "wrapper"));
|
|
114
|
+
const headFocusProxyRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "head"));
|
|
115
|
+
const tailFocusProxyRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "tail"));
|
|
116
|
+
const ref = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "ref"));
|
|
117
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(
|
|
118
|
+
forwardedRef,
|
|
119
|
+
ref,
|
|
120
|
+
context.onViewportChange,
|
|
121
|
+
(0, import_internal.subSlot)(slot, "refs")
|
|
122
|
+
);
|
|
123
|
+
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
124
|
+
const hasToasts = context.toastCount > 0;
|
|
125
|
+
(0, import_octane.useEffect)(
|
|
126
|
+
() => {
|
|
127
|
+
const handleKeyDown = (event) => {
|
|
128
|
+
const isHotkeyPressed = hotkey.length !== 0 && hotkey.every((key) => event[key] || event.code === key);
|
|
129
|
+
if (isHotkeyPressed) ref.current?.focus();
|
|
130
|
+
};
|
|
131
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
132
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
133
|
+
},
|
|
134
|
+
[hotkey],
|
|
135
|
+
(0, import_internal.subSlot)(slot, "e:hotkey")
|
|
136
|
+
);
|
|
137
|
+
(0, import_octane.useEffect)(
|
|
138
|
+
() => {
|
|
139
|
+
const wrapper = wrapperRef.current;
|
|
140
|
+
const viewport = ref.current;
|
|
141
|
+
if (hasToasts && wrapper && viewport) {
|
|
142
|
+
const handlePause = () => {
|
|
143
|
+
if (!context.isClosePausedRef.current) {
|
|
144
|
+
const pauseEvent = new CustomEvent(VIEWPORT_PAUSE);
|
|
145
|
+
viewport.dispatchEvent(pauseEvent);
|
|
146
|
+
context.isClosePausedRef.current = true;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const handleResume = () => {
|
|
150
|
+
if (context.isClosePausedRef.current) {
|
|
151
|
+
const resumeEvent = new CustomEvent(VIEWPORT_RESUME);
|
|
152
|
+
viewport.dispatchEvent(resumeEvent);
|
|
153
|
+
context.isClosePausedRef.current = false;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const handleFocusOutResume = (event) => {
|
|
157
|
+
const isFocusMovingOutside = !wrapper.contains(event.relatedTarget);
|
|
158
|
+
if (isFocusMovingOutside) handleResume();
|
|
159
|
+
};
|
|
160
|
+
const handlePointerLeaveResume = () => {
|
|
161
|
+
const isFocusInside = wrapper.contains(document.activeElement);
|
|
162
|
+
if (!isFocusInside) handleResume();
|
|
163
|
+
};
|
|
164
|
+
wrapper.addEventListener("focusin", handlePause);
|
|
165
|
+
wrapper.addEventListener("focusout", handleFocusOutResume);
|
|
166
|
+
wrapper.addEventListener("pointermove", handlePause);
|
|
167
|
+
wrapper.addEventListener("pointerleave", handlePointerLeaveResume);
|
|
168
|
+
window.addEventListener("blur", handlePause);
|
|
169
|
+
window.addEventListener("focus", handleResume);
|
|
170
|
+
return () => {
|
|
171
|
+
wrapper.removeEventListener("focusin", handlePause);
|
|
172
|
+
wrapper.removeEventListener("focusout", handleFocusOutResume);
|
|
173
|
+
wrapper.removeEventListener("pointermove", handlePause);
|
|
174
|
+
wrapper.removeEventListener("pointerleave", handlePointerLeaveResume);
|
|
175
|
+
window.removeEventListener("blur", handlePause);
|
|
176
|
+
window.removeEventListener("focus", handleResume);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
[hasToasts, context.isClosePausedRef],
|
|
181
|
+
(0, import_internal.subSlot)(slot, "e:pause")
|
|
182
|
+
);
|
|
183
|
+
const getSortedTabbableCandidates = (0, import_octane.useCallback)(
|
|
184
|
+
({ tabbingDirection }) => {
|
|
185
|
+
const toastItems = getItems();
|
|
186
|
+
const tabbableCandidates = toastItems.map((toastItem) => {
|
|
187
|
+
const toastNode = toastItem.ref.current;
|
|
188
|
+
const toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];
|
|
189
|
+
return tabbingDirection === "forwards" ? toastTabbableCandidates : toastTabbableCandidates.reverse();
|
|
190
|
+
});
|
|
191
|
+
return (tabbingDirection === "forwards" ? tabbableCandidates.reverse() : tabbableCandidates).flat();
|
|
192
|
+
},
|
|
193
|
+
[getItems],
|
|
194
|
+
(0, import_internal.subSlot)(slot, "sorted")
|
|
195
|
+
);
|
|
196
|
+
(0, import_octane.useEffect)(
|
|
197
|
+
() => {
|
|
198
|
+
const viewport = ref.current;
|
|
199
|
+
if (viewport) {
|
|
200
|
+
const handleKeyDown = (event) => {
|
|
201
|
+
const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
|
|
202
|
+
const isTabKey = event.key === "Tab" && !isMetaKey;
|
|
203
|
+
if (isTabKey) {
|
|
204
|
+
const focusedElement = document.activeElement;
|
|
205
|
+
const isTabbingBackwards = event.shiftKey;
|
|
206
|
+
const targetIsViewport = event.target === viewport;
|
|
207
|
+
if (targetIsViewport && isTabbingBackwards) {
|
|
208
|
+
headFocusProxyRef.current?.focus();
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const tabbingDirection = isTabbingBackwards ? "backwards" : "forwards";
|
|
212
|
+
const sortedCandidates = getSortedTabbableCandidates({ tabbingDirection });
|
|
213
|
+
const index = sortedCandidates.findIndex(
|
|
214
|
+
(candidate) => candidate === focusedElement
|
|
215
|
+
);
|
|
216
|
+
if (focusFirst(sortedCandidates.slice(index + 1))) {
|
|
217
|
+
event.preventDefault();
|
|
218
|
+
} else {
|
|
219
|
+
isTabbingBackwards ? headFocusProxyRef.current?.focus() : tailFocusProxyRef.current?.focus();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
viewport.addEventListener("keydown", handleKeyDown);
|
|
224
|
+
return () => viewport.removeEventListener("keydown", handleKeyDown);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
[getItems, getSortedTabbableCandidates],
|
|
228
|
+
(0, import_internal.subSlot)(slot, "e:tab")
|
|
229
|
+
);
|
|
230
|
+
return (0, import_octane.createElement)(import_DismissableLayer.DismissableLayerBranch, {
|
|
231
|
+
ref: wrapperRef,
|
|
232
|
+
role: "region",
|
|
233
|
+
"aria-label": label.replace("{hotkey}", hotkeyLabel),
|
|
234
|
+
// Ensure virtual cursor from landmarks menus triggers focus/blur for pause/resume
|
|
235
|
+
tabIndex: -1,
|
|
236
|
+
// incase list has size when empty (e.g. padding), we remove pointer events so
|
|
237
|
+
// it doesn't prevent interactions with page elements that it overlays
|
|
238
|
+
style: { pointerEvents: hasToasts ? void 0 : "none" },
|
|
239
|
+
children: [
|
|
240
|
+
hasToasts ? (0, import_octane.createElement)(FocusProxy, {
|
|
241
|
+
key: "head",
|
|
242
|
+
__scopeToast,
|
|
243
|
+
ref: headFocusProxyRef,
|
|
244
|
+
onFocusFromOutsideViewport: () => {
|
|
245
|
+
const tabbableCandidates = getSortedTabbableCandidates({
|
|
246
|
+
tabbingDirection: "forwards"
|
|
247
|
+
});
|
|
248
|
+
focusFirst(tabbableCandidates);
|
|
249
|
+
}
|
|
250
|
+
}) : null,
|
|
251
|
+
/**
|
|
252
|
+
* tabindex on the the list so that it can be focused when items are removed. we focus
|
|
253
|
+
* the list instead of the viewport so it announces number of items remaining.
|
|
254
|
+
*/
|
|
255
|
+
(0, import_octane.createElement)(Collection.Slot, {
|
|
256
|
+
key: "list",
|
|
257
|
+
scope: __scopeToast,
|
|
258
|
+
children: (0, import_octane.createElement)(import_Primitive.Primitive.ol, {
|
|
259
|
+
tabIndex: -1,
|
|
260
|
+
...viewportProps,
|
|
261
|
+
ref: composedRefs,
|
|
262
|
+
// the runtime doesn't clobber the portalled toasts on re-render.
|
|
263
|
+
children: viewportProps.children
|
|
264
|
+
})
|
|
265
|
+
}),
|
|
266
|
+
hasToasts ? (0, import_octane.createElement)(FocusProxy, {
|
|
267
|
+
key: "tail",
|
|
268
|
+
__scopeToast,
|
|
269
|
+
ref: tailFocusProxyRef,
|
|
270
|
+
onFocusFromOutsideViewport: () => {
|
|
271
|
+
const tabbableCandidates = getSortedTabbableCandidates({
|
|
272
|
+
tabbingDirection: "backwards"
|
|
273
|
+
});
|
|
274
|
+
focusFirst(tabbableCandidates);
|
|
275
|
+
}
|
|
276
|
+
}) : null
|
|
277
|
+
]
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
const FOCUS_PROXY_NAME = "ToastFocusProxy";
|
|
281
|
+
function FocusProxy(props) {
|
|
282
|
+
const {
|
|
283
|
+
__scopeToast,
|
|
284
|
+
onFocusFromOutsideViewport,
|
|
285
|
+
ref: forwardedRef,
|
|
286
|
+
...proxyProps
|
|
287
|
+
} = props ?? {};
|
|
288
|
+
const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast);
|
|
289
|
+
return (0, import_octane.createElement)(import_VisuallyHidden.VisuallyHidden, {
|
|
290
|
+
tabIndex: 0,
|
|
291
|
+
...proxyProps,
|
|
292
|
+
ref: forwardedRef,
|
|
293
|
+
// Avoid page scrolling when focus is on the focus proxy
|
|
294
|
+
style: { position: "fixed" },
|
|
295
|
+
onFocus: (event) => {
|
|
296
|
+
const prevFocusedElement = event.relatedTarget;
|
|
297
|
+
const isFocusFromOutsideViewport = !context.viewport?.contains(prevFocusedElement);
|
|
298
|
+
if (isFocusFromOutsideViewport) onFocusFromOutsideViewport();
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
const TOAST_NAME = "Toast";
|
|
303
|
+
const TOAST_SWIPE_START = "toast.swipeStart";
|
|
304
|
+
const TOAST_SWIPE_MOVE = "toast.swipeMove";
|
|
305
|
+
const TOAST_SWIPE_CANCEL = "toast.swipeCancel";
|
|
306
|
+
const TOAST_SWIPE_END = "toast.swipeEnd";
|
|
307
|
+
function Root(props) {
|
|
308
|
+
const slot = (0, import_internal.S)("Toast.Root");
|
|
309
|
+
const {
|
|
310
|
+
forceMount,
|
|
311
|
+
open: openProp,
|
|
312
|
+
defaultOpen,
|
|
313
|
+
onOpenChange,
|
|
314
|
+
ref: forwardedRef,
|
|
315
|
+
...toastProps
|
|
316
|
+
} = props ?? {};
|
|
317
|
+
const [open, setOpen] = (0, import_useControllableState.useControllableState)(
|
|
318
|
+
{ prop: openProp, defaultProp: defaultOpen ?? true, onChange: onOpenChange },
|
|
319
|
+
(0, import_internal.subSlot)(slot, "open")
|
|
320
|
+
);
|
|
321
|
+
return (0, import_octane.createElement)(import_Presence.Presence, {
|
|
322
|
+
present: forceMount || open,
|
|
323
|
+
children: (0, import_octane.createElement)(ToastImpl, {
|
|
324
|
+
open,
|
|
325
|
+
...toastProps,
|
|
326
|
+
ref: forwardedRef,
|
|
327
|
+
onClose: () => setOpen(false),
|
|
328
|
+
onPause: (0, import_use_callback_ref.useCallbackRef)(props?.onPause, (0, import_internal.subSlot)(slot, "pause")),
|
|
329
|
+
onResume: (0, import_use_callback_ref.useCallbackRef)(props?.onResume, (0, import_internal.subSlot)(slot, "resume")),
|
|
330
|
+
onSwipeStart: (0, import_compose_event_handlers.composeEventHandlers)(props?.onSwipeStart, (event) => {
|
|
331
|
+
event.currentTarget.setAttribute("data-swipe", "start");
|
|
332
|
+
}),
|
|
333
|
+
onSwipeMove: (0, import_compose_event_handlers.composeEventHandlers)(props?.onSwipeMove, (event) => {
|
|
334
|
+
const { x, y } = event.detail.delta;
|
|
335
|
+
event.currentTarget.setAttribute("data-swipe", "move");
|
|
336
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${x}px`);
|
|
337
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${y}px`);
|
|
338
|
+
}),
|
|
339
|
+
onSwipeCancel: (0, import_compose_event_handlers.composeEventHandlers)(props?.onSwipeCancel, (event) => {
|
|
340
|
+
event.currentTarget.setAttribute("data-swipe", "cancel");
|
|
341
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-x");
|
|
342
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-y");
|
|
343
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-end-x");
|
|
344
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-end-y");
|
|
345
|
+
}),
|
|
346
|
+
onSwipeEnd: (0, import_compose_event_handlers.composeEventHandlers)(props?.onSwipeEnd, (event) => {
|
|
347
|
+
const { x, y } = event.detail.delta;
|
|
348
|
+
event.currentTarget.setAttribute("data-swipe", "end");
|
|
349
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-x");
|
|
350
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-y");
|
|
351
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${x}px`);
|
|
352
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${y}px`);
|
|
353
|
+
setOpen(false);
|
|
354
|
+
})
|
|
355
|
+
})
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
const [ToastInteractiveProvider, useToastInteractiveContext] = createToastContext(TOAST_NAME, {
|
|
359
|
+
onClose() {
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
function ToastImpl(props) {
|
|
363
|
+
const slot = (0, import_internal.S)("Toast.Impl");
|
|
364
|
+
const {
|
|
365
|
+
__scopeToast,
|
|
366
|
+
type = "foreground",
|
|
367
|
+
duration: durationProp,
|
|
368
|
+
open,
|
|
369
|
+
onClose,
|
|
370
|
+
onEscapeKeyDown,
|
|
371
|
+
onPause,
|
|
372
|
+
onResume,
|
|
373
|
+
onSwipeStart,
|
|
374
|
+
onSwipeMove,
|
|
375
|
+
onSwipeCancel,
|
|
376
|
+
onSwipeEnd,
|
|
377
|
+
ref: forwardedRef,
|
|
378
|
+
...toastProps
|
|
379
|
+
} = props ?? {};
|
|
380
|
+
const context = useToastProviderContext(TOAST_NAME, __scopeToast);
|
|
381
|
+
const [node, setNode] = (0, import_octane.useState)(null, (0, import_internal.subSlot)(slot, "node"));
|
|
382
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, setNode, (0, import_internal.subSlot)(slot, "refs"));
|
|
383
|
+
const pointerStartRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "pStart"));
|
|
384
|
+
const swipeDeltaRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "delta"));
|
|
385
|
+
const duration = durationProp || context.duration;
|
|
386
|
+
const closeTimerStartTimeRef = (0, import_octane.useRef)(0, (0, import_internal.subSlot)(slot, "timerStart"));
|
|
387
|
+
const closeTimerRemainingTimeRef = (0, import_octane.useRef)(duration, (0, import_internal.subSlot)(slot, "timerRemaining"));
|
|
388
|
+
const closeTimerRef = (0, import_octane.useRef)(0, (0, import_internal.subSlot)(slot, "timer"));
|
|
389
|
+
const { onToastAdd, onToastRemove } = context;
|
|
390
|
+
const handleClose = (0, import_use_callback_ref.useCallbackRef)(
|
|
391
|
+
() => {
|
|
392
|
+
const isFocusInToast = node?.contains(document.activeElement);
|
|
393
|
+
if (isFocusInToast) context.viewport?.focus();
|
|
394
|
+
onClose();
|
|
395
|
+
},
|
|
396
|
+
(0, import_internal.subSlot)(slot, "close")
|
|
397
|
+
);
|
|
398
|
+
const startTimer = (0, import_octane.useCallback)(
|
|
399
|
+
(duration2) => {
|
|
400
|
+
if (!duration2 || duration2 === Infinity) return;
|
|
401
|
+
window.clearTimeout(closeTimerRef.current);
|
|
402
|
+
closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
403
|
+
closeTimerRef.current = window.setTimeout(handleClose, duration2);
|
|
404
|
+
},
|
|
405
|
+
[handleClose],
|
|
406
|
+
(0, import_internal.subSlot)(slot, "startTimer")
|
|
407
|
+
);
|
|
408
|
+
(0, import_octane.useEffect)(
|
|
409
|
+
() => {
|
|
410
|
+
const viewport = context.viewport;
|
|
411
|
+
if (viewport) {
|
|
412
|
+
const handleResume = () => {
|
|
413
|
+
startTimer(closeTimerRemainingTimeRef.current);
|
|
414
|
+
onResume?.();
|
|
415
|
+
};
|
|
416
|
+
const handlePause = () => {
|
|
417
|
+
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
|
|
418
|
+
closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime;
|
|
419
|
+
window.clearTimeout(closeTimerRef.current);
|
|
420
|
+
onPause?.();
|
|
421
|
+
};
|
|
422
|
+
viewport.addEventListener(VIEWPORT_PAUSE, handlePause);
|
|
423
|
+
viewport.addEventListener(VIEWPORT_RESUME, handleResume);
|
|
424
|
+
return () => {
|
|
425
|
+
viewport.removeEventListener(VIEWPORT_PAUSE, handlePause);
|
|
426
|
+
viewport.removeEventListener(VIEWPORT_RESUME, handleResume);
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
[context.viewport, duration, onPause, onResume, startTimer],
|
|
431
|
+
(0, import_internal.subSlot)(slot, "e:viewport")
|
|
432
|
+
);
|
|
433
|
+
(0, import_octane.useEffect)(
|
|
434
|
+
() => {
|
|
435
|
+
if (open && !context.isClosePausedRef.current) startTimer(duration);
|
|
436
|
+
},
|
|
437
|
+
[open, duration, context.isClosePausedRef, startTimer],
|
|
438
|
+
(0, import_internal.subSlot)(slot, "e:open")
|
|
439
|
+
);
|
|
440
|
+
(0, import_octane.useEffect)(
|
|
441
|
+
() => {
|
|
442
|
+
return () => {
|
|
443
|
+
window.clearTimeout(closeTimerRef.current);
|
|
444
|
+
};
|
|
445
|
+
},
|
|
446
|
+
[],
|
|
447
|
+
(0, import_internal.subSlot)(slot, "e:clear")
|
|
448
|
+
);
|
|
449
|
+
(0, import_octane.useEffect)(
|
|
450
|
+
() => {
|
|
451
|
+
onToastAdd();
|
|
452
|
+
return () => onToastRemove();
|
|
453
|
+
},
|
|
454
|
+
[onToastAdd, onToastRemove],
|
|
455
|
+
(0, import_internal.subSlot)(slot, "e:count")
|
|
456
|
+
);
|
|
457
|
+
const announceTextContent = (0, import_octane.useMemo)(
|
|
458
|
+
() => node ? getAnnounceTextContent(node) : null,
|
|
459
|
+
[node],
|
|
460
|
+
(0, import_internal.subSlot)(slot, "announce")
|
|
461
|
+
);
|
|
462
|
+
if (!context.viewport) return null;
|
|
463
|
+
return [
|
|
464
|
+
announceTextContent ? (0, import_octane.createElement)(ToastAnnounce, {
|
|
465
|
+
key: "announce",
|
|
466
|
+
__scopeToast,
|
|
467
|
+
// Toasts are always role=status to avoid stuttering issues with role=alert in SRs.
|
|
468
|
+
role: "status",
|
|
469
|
+
"aria-live": type === "foreground" ? "assertive" : "polite",
|
|
470
|
+
children: announceTextContent
|
|
471
|
+
}) : null,
|
|
472
|
+
(0, import_octane.createElement)(ToastInteractiveProvider, {
|
|
473
|
+
key: "toast",
|
|
474
|
+
scope: __scopeToast,
|
|
475
|
+
onClose: handleClose,
|
|
476
|
+
children: (0, import_octane.createPortal)(
|
|
477
|
+
(0, import_octane.createElement)(Collection.ItemSlot, {
|
|
478
|
+
scope: __scopeToast,
|
|
479
|
+
children: (0, import_octane.createElement)(import_DismissableLayer.DismissableLayer, {
|
|
480
|
+
asChild: true,
|
|
481
|
+
onEscapeKeyDown: (0, import_compose_event_handlers.composeEventHandlers)(onEscapeKeyDown, () => {
|
|
482
|
+
if (!context.isFocusedToastEscapeKeyDownRef.current) handleClose();
|
|
483
|
+
context.isFocusedToastEscapeKeyDownRef.current = false;
|
|
484
|
+
}),
|
|
485
|
+
children: (0, import_octane.createElement)(import_Primitive.Primitive.li, {
|
|
486
|
+
// Ensure toasts are announced as status list or status when focused
|
|
487
|
+
tabIndex: 0,
|
|
488
|
+
"data-state": open ? "open" : "closed",
|
|
489
|
+
"data-swipe-direction": context.swipeDirection,
|
|
490
|
+
...toastProps,
|
|
491
|
+
ref: composedRefs,
|
|
492
|
+
style: { userSelect: "none", touchAction: "none", ...props?.style },
|
|
493
|
+
onKeyDown: (0, import_compose_event_handlers.composeEventHandlers)(toastProps.onKeyDown, (event) => {
|
|
494
|
+
if (event.key !== "Escape") return;
|
|
495
|
+
onEscapeKeyDown?.(event);
|
|
496
|
+
if (!event.defaultPrevented) {
|
|
497
|
+
context.isFocusedToastEscapeKeyDownRef.current = true;
|
|
498
|
+
handleClose();
|
|
499
|
+
}
|
|
500
|
+
}),
|
|
501
|
+
onPointerDown: (0, import_compose_event_handlers.composeEventHandlers)(
|
|
502
|
+
toastProps.onPointerDown,
|
|
503
|
+
(event) => {
|
|
504
|
+
if (event.button !== 0) return;
|
|
505
|
+
pointerStartRef.current = { x: event.clientX, y: event.clientY };
|
|
506
|
+
}
|
|
507
|
+
),
|
|
508
|
+
onPointerMove: (0, import_compose_event_handlers.composeEventHandlers)(
|
|
509
|
+
toastProps.onPointerMove,
|
|
510
|
+
(event) => {
|
|
511
|
+
if (!pointerStartRef.current) return;
|
|
512
|
+
const x = event.clientX - pointerStartRef.current.x;
|
|
513
|
+
const y = event.clientY - pointerStartRef.current.y;
|
|
514
|
+
const hasSwipeMoveStarted = Boolean(swipeDeltaRef.current);
|
|
515
|
+
const isHorizontalSwipe = ["left", "right"].includes(context.swipeDirection);
|
|
516
|
+
const clamp = ["left", "up"].includes(context.swipeDirection) ? Math.min : Math.max;
|
|
517
|
+
const clampedX = isHorizontalSwipe ? clamp(0, x) : 0;
|
|
518
|
+
const clampedY = !isHorizontalSwipe ? clamp(0, y) : 0;
|
|
519
|
+
const moveStartBuffer = event.pointerType === "touch" ? 10 : 2;
|
|
520
|
+
const delta = { x: clampedX, y: clampedY };
|
|
521
|
+
const eventDetail = { originalEvent: event, delta };
|
|
522
|
+
if (hasSwipeMoveStarted) {
|
|
523
|
+
swipeDeltaRef.current = delta;
|
|
524
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_MOVE, onSwipeMove, eventDetail, {
|
|
525
|
+
discrete: false
|
|
526
|
+
});
|
|
527
|
+
} else if (isDeltaInDirection(delta, context.swipeDirection, moveStartBuffer)) {
|
|
528
|
+
swipeDeltaRef.current = delta;
|
|
529
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_START, onSwipeStart, eventDetail, {
|
|
530
|
+
discrete: false
|
|
531
|
+
});
|
|
532
|
+
event.target.setPointerCapture(event.pointerId);
|
|
533
|
+
} else if (Math.abs(x) > moveStartBuffer || Math.abs(y) > moveStartBuffer) {
|
|
534
|
+
pointerStartRef.current = null;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
),
|
|
538
|
+
onPointerUp: (0, import_compose_event_handlers.composeEventHandlers)(toastProps.onPointerUp, (event) => {
|
|
539
|
+
const delta = swipeDeltaRef.current;
|
|
540
|
+
const target = event.target;
|
|
541
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
|
542
|
+
target.releasePointerCapture(event.pointerId);
|
|
543
|
+
}
|
|
544
|
+
swipeDeltaRef.current = null;
|
|
545
|
+
pointerStartRef.current = null;
|
|
546
|
+
if (delta) {
|
|
547
|
+
const toast = event.currentTarget;
|
|
548
|
+
const eventDetail = { originalEvent: event, delta };
|
|
549
|
+
if (isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)) {
|
|
550
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_END, onSwipeEnd, eventDetail, {
|
|
551
|
+
discrete: true
|
|
552
|
+
});
|
|
553
|
+
} else {
|
|
554
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_CANCEL, onSwipeCancel, eventDetail, {
|
|
555
|
+
discrete: true
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
toast.addEventListener("click", (event2) => event2.preventDefault(), {
|
|
559
|
+
once: true
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
})
|
|
563
|
+
})
|
|
564
|
+
})
|
|
565
|
+
}),
|
|
566
|
+
context.viewport
|
|
567
|
+
)
|
|
568
|
+
})
|
|
569
|
+
];
|
|
570
|
+
}
|
|
571
|
+
function ToastAnnounce(props) {
|
|
572
|
+
const slot = (0, import_internal.S)("Toast.Announce");
|
|
573
|
+
const { __scopeToast, children, ...announceProps } = props ?? {};
|
|
574
|
+
const context = useToastProviderContext(TOAST_NAME, __scopeToast);
|
|
575
|
+
const [renderAnnounceText, setRenderAnnounceText] = (0, import_octane.useState)(false, (0, import_internal.subSlot)(slot, "render"));
|
|
576
|
+
const [isAnnounced, setIsAnnounced] = (0, import_octane.useState)(false, (0, import_internal.subSlot)(slot, "announced"));
|
|
577
|
+
useNextFrame(() => setRenderAnnounceText(true), (0, import_internal.subSlot)(slot, "frame"));
|
|
578
|
+
(0, import_octane.useEffect)(
|
|
579
|
+
() => {
|
|
580
|
+
const timer = window.setTimeout(() => setIsAnnounced(true), 1e3);
|
|
581
|
+
return () => window.clearTimeout(timer);
|
|
582
|
+
},
|
|
583
|
+
[],
|
|
584
|
+
(0, import_internal.subSlot)(slot, "e:cleanup")
|
|
585
|
+
);
|
|
586
|
+
return isAnnounced ? null : (0, import_octane.createElement)(import_Portal.Portal, {
|
|
587
|
+
asChild: true,
|
|
588
|
+
container: context.announcerContainer || void 0,
|
|
589
|
+
children: (0, import_octane.createElement)(import_VisuallyHidden.VisuallyHidden, {
|
|
590
|
+
...announceProps,
|
|
591
|
+
children: renderAnnounceText ? [context.label, " ", ...Array.isArray(children) ? children : [children]] : null
|
|
592
|
+
})
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
function Title(props) {
|
|
596
|
+
const { __scopeToast, ...titleProps } = props ?? {};
|
|
597
|
+
return (0, import_octane.createElement)(import_Primitive.Primitive.div, { ...titleProps });
|
|
598
|
+
}
|
|
599
|
+
function Description(props) {
|
|
600
|
+
const { __scopeToast, ...descriptionProps } = props ?? {};
|
|
601
|
+
return (0, import_octane.createElement)(import_Primitive.Primitive.div, { ...descriptionProps });
|
|
602
|
+
}
|
|
603
|
+
function Action(props) {
|
|
604
|
+
const { altText, ref: forwardedRef, ...actionProps } = props ?? {};
|
|
605
|
+
if (!altText || !String(altText).trim()) {
|
|
606
|
+
return null;
|
|
607
|
+
}
|
|
608
|
+
return (0, import_octane.createElement)(ToastAnnounceExclude, {
|
|
609
|
+
altText,
|
|
610
|
+
asChild: true,
|
|
611
|
+
children: (0, import_octane.createElement)(Close, { ...actionProps, ref: forwardedRef })
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
const CLOSE_NAME = "ToastClose";
|
|
615
|
+
function Close(props) {
|
|
616
|
+
const { __scopeToast, ref: forwardedRef, ...closeProps } = props ?? {};
|
|
617
|
+
const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast);
|
|
618
|
+
return (0, import_octane.createElement)(ToastAnnounceExclude, {
|
|
619
|
+
asChild: true,
|
|
620
|
+
children: (0, import_octane.createElement)(import_Primitive.Primitive.button, {
|
|
621
|
+
type: "button",
|
|
622
|
+
...closeProps,
|
|
623
|
+
ref: forwardedRef,
|
|
624
|
+
onClick: (0, import_compose_event_handlers.composeEventHandlers)(props?.onClick, interactiveContext.onClose)
|
|
625
|
+
})
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
function ToastAnnounceExclude(props) {
|
|
629
|
+
const { __scopeToast, altText, ref: forwardedRef, ...announceExcludeProps } = props ?? {};
|
|
630
|
+
return (0, import_octane.createElement)(import_Primitive.Primitive.div, {
|
|
631
|
+
"data-radix-toast-announce-exclude": "",
|
|
632
|
+
"data-radix-toast-announce-alt": altText || void 0,
|
|
633
|
+
...announceExcludeProps,
|
|
634
|
+
ref: forwardedRef
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
function getAnnounceTextContent(container) {
|
|
638
|
+
const textContent = [];
|
|
639
|
+
const childNodes = Array.from(container.childNodes);
|
|
640
|
+
childNodes.forEach((node) => {
|
|
641
|
+
if (node.nodeType === node.TEXT_NODE && node.textContent) textContent.push(node.textContent);
|
|
642
|
+
if (isHTMLElement(node)) {
|
|
643
|
+
const isHidden = node.ariaHidden || node.hidden || node.style.display === "none";
|
|
644
|
+
const isExcluded = node.dataset.radixToastAnnounceExclude === "";
|
|
645
|
+
if (!isHidden) {
|
|
646
|
+
if (isExcluded) {
|
|
647
|
+
const altText = node.dataset.radixToastAnnounceAlt;
|
|
648
|
+
if (altText) textContent.push(altText);
|
|
649
|
+
} else {
|
|
650
|
+
textContent.push(...getAnnounceTextContent(node));
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
return textContent;
|
|
656
|
+
}
|
|
657
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
658
|
+
const currentTarget = detail.originalEvent.currentTarget;
|
|
659
|
+
const event = new CustomEvent(name, { bubbles: true, cancelable: true, detail });
|
|
660
|
+
if (handler) currentTarget.addEventListener(name, handler, { once: true });
|
|
661
|
+
if (discrete) {
|
|
662
|
+
(0, import_Primitive.dispatchDiscreteCustomEvent)(currentTarget, event);
|
|
663
|
+
} else {
|
|
664
|
+
currentTarget.dispatchEvent(event);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
const isDeltaInDirection = (delta, direction, threshold = 0) => {
|
|
668
|
+
const deltaX = Math.abs(delta.x);
|
|
669
|
+
const deltaY = Math.abs(delta.y);
|
|
670
|
+
const isDeltaX = deltaX > deltaY;
|
|
671
|
+
if (direction === "left" || direction === "right") {
|
|
672
|
+
return isDeltaX && deltaX > threshold;
|
|
673
|
+
} else {
|
|
674
|
+
return !isDeltaX && deltaY > threshold;
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
function useNextFrame(callback, slot) {
|
|
678
|
+
const fn = (0, import_use_callback_ref.useCallbackRef)(callback, (0, import_internal.subSlot)(slot, "cb"));
|
|
679
|
+
(0, import_octane.useLayoutEffect)(
|
|
680
|
+
() => {
|
|
681
|
+
let raf1 = 0;
|
|
682
|
+
let raf2 = 0;
|
|
683
|
+
raf1 = window.requestAnimationFrame(() => raf2 = window.requestAnimationFrame(fn));
|
|
684
|
+
return () => {
|
|
685
|
+
window.cancelAnimationFrame(raf1);
|
|
686
|
+
window.cancelAnimationFrame(raf2);
|
|
687
|
+
};
|
|
688
|
+
},
|
|
689
|
+
[fn],
|
|
690
|
+
(0, import_internal.subSlot)(slot, "e")
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
function isHTMLElement(node) {
|
|
694
|
+
return node.nodeType === node.ELEMENT_NODE;
|
|
695
|
+
}
|
|
696
|
+
function getTabbableCandidates(container) {
|
|
697
|
+
const nodes = [];
|
|
698
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
699
|
+
acceptNode: (node) => {
|
|
700
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
701
|
+
if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
|
|
702
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
while (walker.nextNode()) nodes.push(walker.currentNode);
|
|
706
|
+
return nodes;
|
|
707
|
+
}
|
|
708
|
+
function focusFirst(candidates) {
|
|
709
|
+
const previouslyFocusedElement = document.activeElement;
|
|
710
|
+
return candidates.some((candidate) => {
|
|
711
|
+
if (candidate === previouslyFocusedElement) return true;
|
|
712
|
+
candidate.focus();
|
|
713
|
+
return document.activeElement !== previouslyFocusedElement;
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
717
|
+
0 && (module.exports = {
|
|
718
|
+
Action,
|
|
719
|
+
Close,
|
|
720
|
+
Description,
|
|
721
|
+
Provider,
|
|
722
|
+
Root,
|
|
723
|
+
Title,
|
|
724
|
+
Toast,
|
|
725
|
+
ToastAction,
|
|
726
|
+
ToastClose,
|
|
727
|
+
ToastDescription,
|
|
728
|
+
ToastProvider,
|
|
729
|
+
ToastTitle,
|
|
730
|
+
ToastViewport,
|
|
731
|
+
Viewport,
|
|
732
|
+
createToastScope
|
|
733
|
+
});
|