@tamagui/toast 1.13.2 → 1.13.4
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/Toast.js +1 -181
- package/dist/cjs/Toast.js.map +3 -3
- package/dist/cjs/ToastAnnounce.js +1 -92
- package/dist/cjs/ToastAnnounce.js.map +2 -2
- package/dist/cjs/ToastImperative.js +1 -110
- package/dist/cjs/ToastImperative.js.map +2 -2
- package/dist/cjs/ToastImpl.js +1 -352
- package/dist/cjs/ToastImpl.js.map +2 -2
- package/dist/cjs/ToastProvider.js +1 -119
- package/dist/cjs/ToastProvider.js.map +2 -2
- package/dist/cjs/ToastViewport.js +1 -312
- package/dist/cjs/ToastViewport.js.map +2 -2
- package/dist/cjs/constants.js +1 -28
- package/dist/cjs/constants.js.map +2 -2
- package/dist/cjs/createNativeToast.js +1 -69
- package/dist/cjs/createNativeToast.js.map +2 -2
- package/dist/cjs/createNativeToast.native.js +1 -43
- package/dist/cjs/createNativeToast.native.js.map +2 -2
- package/dist/cjs/index.js +1 -18
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js +1 -16
- package/dist/cjs/types.js.map +2 -2
- package/dist/esm/Toast.js +1 -157
- package/dist/esm/Toast.js.map +3 -3
- package/dist/esm/Toast.mjs +1 -157
- package/dist/esm/Toast.mjs.map +3 -3
- package/dist/esm/ToastAnnounce.js +1 -63
- package/dist/esm/ToastAnnounce.js.map +2 -2
- package/dist/esm/ToastAnnounce.mjs +1 -63
- package/dist/esm/ToastAnnounce.mjs.map +2 -2
- package/dist/esm/ToastImperative.js +1 -73
- package/dist/esm/ToastImperative.js.map +2 -2
- package/dist/esm/ToastImperative.mjs +1 -73
- package/dist/esm/ToastImperative.mjs.map +2 -2
- package/dist/esm/ToastImpl.js +1 -328
- package/dist/esm/ToastImpl.js.map +2 -2
- package/dist/esm/ToastImpl.mjs +1 -328
- package/dist/esm/ToastImpl.mjs.map +2 -2
- package/dist/esm/ToastProvider.js +1 -80
- package/dist/esm/ToastProvider.js.map +2 -2
- package/dist/esm/ToastProvider.mjs +1 -80
- package/dist/esm/ToastProvider.mjs.map +2 -2
- package/dist/esm/ToastViewport.js +1 -279
- package/dist/esm/ToastViewport.js.map +2 -2
- package/dist/esm/ToastViewport.mjs +1 -279
- package/dist/esm/ToastViewport.mjs.map +2 -2
- package/dist/esm/constants.js +1 -4
- package/dist/esm/constants.js.map +2 -2
- package/dist/esm/constants.mjs +1 -4
- package/dist/esm/constants.mjs.map +2 -2
- package/dist/esm/createNativeToast.js +1 -44
- package/dist/esm/createNativeToast.js.map +2 -2
- package/dist/esm/createNativeToast.mjs +1 -44
- package/dist/esm/createNativeToast.mjs.map +2 -2
- package/dist/esm/createNativeToast.native.js +1 -18
- package/dist/esm/createNativeToast.native.js.map +2 -2
- package/dist/esm/createNativeToast.native.mjs +1 -18
- package/dist/esm/createNativeToast.native.mjs.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/jsx/Toast.js +1 -150
- package/dist/jsx/Toast.js.map +3 -3
- package/dist/jsx/Toast.mjs +1 -150
- package/dist/jsx/Toast.mjs.map +3 -3
- package/dist/jsx/ToastAnnounce.js +1 -59
- package/dist/jsx/ToastAnnounce.js.map +2 -2
- package/dist/jsx/ToastAnnounce.mjs +1 -59
- package/dist/jsx/ToastAnnounce.mjs.map +2 -2
- package/dist/jsx/ToastImperative.js +1 -72
- package/dist/jsx/ToastImperative.js.map +2 -2
- package/dist/jsx/ToastImperative.mjs +1 -72
- package/dist/jsx/ToastImperative.mjs.map +2 -2
- package/dist/jsx/ToastImpl.js +1 -307
- package/dist/jsx/ToastImpl.js.map +2 -2
- package/dist/jsx/ToastImpl.mjs +1 -307
- package/dist/jsx/ToastImpl.mjs.map +2 -2
- package/dist/jsx/ToastProvider.js +1 -75
- package/dist/jsx/ToastProvider.js.map +2 -2
- package/dist/jsx/ToastProvider.mjs +1 -75
- package/dist/jsx/ToastProvider.mjs.map +2 -2
- package/dist/jsx/ToastViewport.js +1 -259
- package/dist/jsx/ToastViewport.js.map +2 -2
- package/dist/jsx/ToastViewport.mjs +1 -259
- package/dist/jsx/ToastViewport.mjs.map +2 -2
- package/dist/jsx/constants.js +1 -4
- package/dist/jsx/constants.js.map +2 -2
- package/dist/jsx/constants.mjs +1 -4
- package/dist/jsx/constants.mjs.map +2 -2
- package/dist/jsx/createNativeToast.js +1 -44
- package/dist/jsx/createNativeToast.js.map +2 -2
- package/dist/jsx/createNativeToast.mjs +1 -44
- package/dist/jsx/createNativeToast.mjs.map +2 -2
- package/dist/jsx/createNativeToast.native.js +1 -18
- package/dist/jsx/createNativeToast.native.js.map +2 -2
- package/dist/jsx/createNativeToast.native.mjs +1 -18
- package/dist/jsx/createNativeToast.native.mjs.map +2 -2
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +1 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/package.json +13 -13
- package/src/Toast.tsx +9 -1
- package/types/Toast.d.ts +2 -2
- package/types/Toast.d.ts.map +1 -1
|
@@ -1,313 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var ToastViewport_exports = {};
|
|
30
|
-
__export(ToastViewport_exports, {
|
|
31
|
-
ToastViewport: () => ToastViewport,
|
|
32
|
-
VIEWPORT_DEFAULT_HOTKEY: () => VIEWPORT_DEFAULT_HOTKEY,
|
|
33
|
-
VIEWPORT_PAUSE: () => VIEWPORT_PAUSE,
|
|
34
|
-
VIEWPORT_RESUME: () => VIEWPORT_RESUME
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(ToastViewport_exports);
|
|
37
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
-
var import_animate_presence = require("@tamagui/animate-presence");
|
|
39
|
-
var import_compose_refs = require("@tamagui/compose-refs");
|
|
40
|
-
var import_core = require("@tamagui/core");
|
|
41
|
-
var import_portal = require("@tamagui/portal");
|
|
42
|
-
var import_stacks = require("@tamagui/stacks");
|
|
43
|
-
var import_visually_hidden = require("@tamagui/visually-hidden");
|
|
44
|
-
var React = __toESM(require("react"));
|
|
45
|
-
var import_ToastProvider = require("./ToastProvider");
|
|
46
|
-
const VIEWPORT_NAME = "ToastViewport";
|
|
47
|
-
const VIEWPORT_DEFAULT_HOTKEY = ["F8"];
|
|
48
|
-
const VIEWPORT_PAUSE = "toast.viewportPause";
|
|
49
|
-
const VIEWPORT_RESUME = "toast.viewportResume";
|
|
50
|
-
const ToastViewportWrapperFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
51
|
-
name: "ViewportWrapper",
|
|
52
|
-
pointerEvents: "box-none",
|
|
53
|
-
top: 0,
|
|
54
|
-
bottom: 0,
|
|
55
|
-
left: 0,
|
|
56
|
-
right: 0,
|
|
57
|
-
// @ts-ignore
|
|
58
|
-
position: import_core.isWeb ? "fixed" : "absolute",
|
|
59
|
-
maxWidth: "100%",
|
|
60
|
-
tabIndex: 0,
|
|
61
|
-
zIndex: 1e5
|
|
62
|
-
});
|
|
63
|
-
const ToastViewportFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
64
|
-
name: VIEWPORT_NAME,
|
|
65
|
-
pointerEvents: "box-none",
|
|
66
|
-
// @ts-ignore
|
|
67
|
-
position: import_core.isWeb ? "fixed" : "absolute",
|
|
68
|
-
maxWidth: "100%"
|
|
69
|
-
});
|
|
70
|
-
const ToastViewport = React.forwardRef(
|
|
71
|
-
(props, forwardedRef) => {
|
|
72
|
-
const {
|
|
73
|
-
__scopeToast,
|
|
74
|
-
hotkey = VIEWPORT_DEFAULT_HOTKEY,
|
|
75
|
-
label = "Notifications ({hotkey})",
|
|
76
|
-
name,
|
|
77
|
-
multipleToasts,
|
|
78
|
-
...viewportProps
|
|
79
|
-
} = props;
|
|
80
|
-
const context = (0, import_ToastProvider.useToastProviderContext)(VIEWPORT_NAME, __scopeToast);
|
|
81
|
-
const getItems = (0, import_ToastProvider.useCollection)(__scopeToast);
|
|
82
|
-
const headFocusProxyRef = React.useRef(null);
|
|
83
|
-
const tailFocusProxyRef = React.useRef(null);
|
|
84
|
-
const wrapperRef = React.useRef(null);
|
|
85
|
-
const ref = React.useRef(null);
|
|
86
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, context.onViewportChange);
|
|
87
|
-
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
88
|
-
const hasToasts = context.toastCount > 0;
|
|
89
|
-
React.useEffect(() => {
|
|
90
|
-
if (!import_core.isWeb)
|
|
91
|
-
return;
|
|
92
|
-
if (context.toastCount === 0)
|
|
93
|
-
return;
|
|
94
|
-
const handleKeyDown = (event) => {
|
|
95
|
-
var _a;
|
|
96
|
-
const isHotkeyPressed = hotkey.every(
|
|
97
|
-
(key) => event[key] || event.code === key
|
|
98
|
-
);
|
|
99
|
-
if (isHotkeyPressed)
|
|
100
|
-
(_a = ref.current) == null ? void 0 : _a.focus();
|
|
101
|
-
};
|
|
102
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
103
|
-
return () => {
|
|
104
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
105
|
-
};
|
|
106
|
-
}, [hotkey, context.toastCount]);
|
|
107
|
-
React.useEffect(() => {
|
|
108
|
-
if (!import_core.isWeb)
|
|
109
|
-
return;
|
|
110
|
-
if (context.toastCount === 0)
|
|
111
|
-
return;
|
|
112
|
-
const wrapper = wrapperRef.current;
|
|
113
|
-
const viewport = ref.current;
|
|
114
|
-
if (hasToasts && wrapper && viewport) {
|
|
115
|
-
const handlePause = () => {
|
|
116
|
-
if (!context.isClosePausedRef.current) {
|
|
117
|
-
const pauseEvent = new CustomEvent(VIEWPORT_PAUSE);
|
|
118
|
-
viewport.dispatchEvent(pauseEvent);
|
|
119
|
-
context.isClosePausedRef.current = true;
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
const handleResume = () => {
|
|
123
|
-
if (context.isClosePausedRef.current) {
|
|
124
|
-
const resumeEvent = new CustomEvent(VIEWPORT_RESUME);
|
|
125
|
-
viewport.dispatchEvent(resumeEvent);
|
|
126
|
-
context.isClosePausedRef.current = false;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const handleFocusOutResume = (event) => {
|
|
130
|
-
const isFocusMovingOutside = !wrapper.contains(
|
|
131
|
-
event.relatedTarget
|
|
132
|
-
);
|
|
133
|
-
if (isFocusMovingOutside)
|
|
134
|
-
handleResume();
|
|
135
|
-
};
|
|
136
|
-
const handlePointerLeaveResume = () => {
|
|
137
|
-
const isFocusInside = wrapper.contains(document.activeElement);
|
|
138
|
-
if (!isFocusInside)
|
|
139
|
-
handleResume();
|
|
140
|
-
};
|
|
141
|
-
wrapper.addEventListener("focusin", handlePause);
|
|
142
|
-
wrapper.addEventListener("focusout", handleFocusOutResume);
|
|
143
|
-
wrapper.addEventListener("pointermove", handlePause);
|
|
144
|
-
wrapper.addEventListener("pointerleave", handlePointerLeaveResume);
|
|
145
|
-
window.addEventListener("blur", handlePause);
|
|
146
|
-
window.addEventListener("focus", handleResume);
|
|
147
|
-
return () => {
|
|
148
|
-
wrapper.removeEventListener("focusin", handlePause);
|
|
149
|
-
wrapper.removeEventListener("focusout", handleFocusOutResume);
|
|
150
|
-
wrapper.removeEventListener("pointermove", handlePause);
|
|
151
|
-
wrapper.removeEventListener("pointerleave", handlePointerLeaveResume);
|
|
152
|
-
window.removeEventListener("blur", handlePause);
|
|
153
|
-
window.removeEventListener("focus", handleResume);
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}, [hasToasts, context.isClosePausedRef, context.toastCount]);
|
|
157
|
-
const getSortedTabbableCandidates = React.useCallback(
|
|
158
|
-
({ tabbingDirection }) => {
|
|
159
|
-
const toastItems = getItems();
|
|
160
|
-
const tabbableCandidates = toastItems.map((toastItem) => {
|
|
161
|
-
const toastNode = toastItem.ref.current;
|
|
162
|
-
const toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];
|
|
163
|
-
return tabbingDirection === "forwards" ? toastTabbableCandidates : toastTabbableCandidates.reverse();
|
|
164
|
-
});
|
|
165
|
-
return (tabbingDirection === "forwards" ? tabbableCandidates.reverse() : tabbableCandidates).flat();
|
|
166
|
-
},
|
|
167
|
-
[getItems]
|
|
168
|
-
);
|
|
169
|
-
React.useEffect(() => {
|
|
170
|
-
if (!import_core.isWeb)
|
|
171
|
-
return;
|
|
172
|
-
if (context.toastCount === 0)
|
|
173
|
-
return;
|
|
174
|
-
const viewport = ref.current;
|
|
175
|
-
if (viewport) {
|
|
176
|
-
const handleKeyDown = (event) => {
|
|
177
|
-
var _a, _b, _c;
|
|
178
|
-
const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
|
|
179
|
-
const isTabKey = event.key === "Tab" && !isMetaKey;
|
|
180
|
-
if (isTabKey) {
|
|
181
|
-
const focusedElement = document.activeElement;
|
|
182
|
-
const isTabbingBackwards = event.shiftKey;
|
|
183
|
-
const targetIsViewport = event.target === viewport;
|
|
184
|
-
if (targetIsViewport && isTabbingBackwards) {
|
|
185
|
-
(_a = headFocusProxyRef.current) == null ? void 0 : _a.focus();
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
const tabbingDirection = isTabbingBackwards ? "backwards" : "forwards";
|
|
189
|
-
const sortedCandidates = getSortedTabbableCandidates({ tabbingDirection });
|
|
190
|
-
const index = sortedCandidates.findIndex(
|
|
191
|
-
(candidate) => candidate === focusedElement
|
|
192
|
-
);
|
|
193
|
-
if (focusFirst(sortedCandidates.slice(index + 1))) {
|
|
194
|
-
event.preventDefault();
|
|
195
|
-
} else {
|
|
196
|
-
isTabbingBackwards ? (_b = headFocusProxyRef.current) == null ? void 0 : _b.focus() : (_c = tailFocusProxyRef.current) == null ? void 0 : _c.focus();
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
viewport.addEventListener("keydown", handleKeyDown);
|
|
201
|
-
return () => viewport.removeEventListener("keydown", handleKeyDown);
|
|
202
|
-
}
|
|
203
|
-
}, [getItems, getSortedTabbableCandidates, context.toastCount]);
|
|
204
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
205
|
-
ToastViewportWrapperFrame,
|
|
206
|
-
{
|
|
207
|
-
ref: wrapperRef,
|
|
208
|
-
role: "region",
|
|
209
|
-
"aria-label": label.replace("{hotkey}", hotkeyLabel),
|
|
210
|
-
tabIndex: -1,
|
|
211
|
-
children: [
|
|
212
|
-
hasToasts && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
213
|
-
FocusProxy,
|
|
214
|
-
{
|
|
215
|
-
ref: headFocusProxyRef,
|
|
216
|
-
onFocusFromOutsideViewport: () => {
|
|
217
|
-
const tabbableCandidates = getSortedTabbableCandidates({
|
|
218
|
-
tabbingDirection: "forwards"
|
|
219
|
-
});
|
|
220
|
-
focusFirst(tabbableCandidates);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
),
|
|
224
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.Slot, { scope: __scopeToast, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastViewportFrame, { ref: composedRefs, ...viewportProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
225
|
-
import_portal.PortalHost,
|
|
226
|
-
{
|
|
227
|
-
render: (children) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { exitBeforeEnter: !multipleToasts, children }),
|
|
228
|
-
name: name ?? "default"
|
|
229
|
-
}
|
|
230
|
-
) }) }),
|
|
231
|
-
hasToasts && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
232
|
-
FocusProxy,
|
|
233
|
-
{
|
|
234
|
-
ref: tailFocusProxyRef,
|
|
235
|
-
onFocusFromOutsideViewport: () => {
|
|
236
|
-
const tabbableCandidates = getSortedTabbableCandidates({
|
|
237
|
-
tabbingDirection: "backwards"
|
|
238
|
-
});
|
|
239
|
-
focusFirst(tabbableCandidates);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
)
|
|
243
|
-
]
|
|
244
|
-
}
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
);
|
|
248
|
-
ToastViewport.displayName = VIEWPORT_NAME;
|
|
249
|
-
const FOCUS_PROXY_NAME = "ToastFocusProxy";
|
|
250
|
-
const FocusProxy = React.forwardRef(
|
|
251
|
-
(props, forwardedRef) => {
|
|
252
|
-
const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props;
|
|
253
|
-
const context = (0, import_ToastProvider.useToastProviderContext)(FOCUS_PROXY_NAME, __scopeToast);
|
|
254
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
255
|
-
import_visually_hidden.VisuallyHidden,
|
|
256
|
-
{
|
|
257
|
-
"aria-hidden": true,
|
|
258
|
-
tabIndex: 0,
|
|
259
|
-
...proxyProps,
|
|
260
|
-
ref: forwardedRef,
|
|
261
|
-
position: import_core.isWeb ? "fixed" : "absolute",
|
|
262
|
-
onFocus: (event) => {
|
|
263
|
-
var _a;
|
|
264
|
-
if (!import_core.isWeb)
|
|
265
|
-
return;
|
|
266
|
-
const prevFocusedElement = event.relatedTarget;
|
|
267
|
-
const isFocusFromOutsideViewport = !((_a = context.viewport) == null ? void 0 : _a.contains(
|
|
268
|
-
prevFocusedElement
|
|
269
|
-
));
|
|
270
|
-
if (isFocusFromOutsideViewport)
|
|
271
|
-
onFocusFromOutsideViewport();
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
);
|
|
277
|
-
FocusProxy.displayName = FOCUS_PROXY_NAME;
|
|
278
|
-
function focusFirst(candidates) {
|
|
279
|
-
if (!import_core.isWeb)
|
|
280
|
-
return;
|
|
281
|
-
const previouslyFocusedElement = document.activeElement;
|
|
282
|
-
return candidates.some((candidate) => {
|
|
283
|
-
if (candidate === previouslyFocusedElement)
|
|
284
|
-
return true;
|
|
285
|
-
candidate.focus();
|
|
286
|
-
return document.activeElement !== previouslyFocusedElement;
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
function getTabbableCandidates(container) {
|
|
290
|
-
if (!import_core.isWeb)
|
|
291
|
-
return [];
|
|
292
|
-
const containerHtml = container;
|
|
293
|
-
const nodes = [];
|
|
294
|
-
const walker = document.createTreeWalker(containerHtml, NodeFilter.SHOW_ELEMENT, {
|
|
295
|
-
acceptNode: (node) => {
|
|
296
|
-
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
297
|
-
if (node.disabled || node.hidden || isHiddenInput)
|
|
298
|
-
return NodeFilter.FILTER_SKIP;
|
|
299
|
-
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
while (walker.nextNode())
|
|
303
|
-
nodes.push(walker.currentNode);
|
|
304
|
-
return nodes;
|
|
305
|
-
}
|
|
306
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
307
|
-
0 && (module.exports = {
|
|
308
|
-
ToastViewport,
|
|
309
|
-
VIEWPORT_DEFAULT_HOTKEY,
|
|
310
|
-
VIEWPORT_PAUSE,
|
|
311
|
-
VIEWPORT_RESUME
|
|
312
|
-
});
|
|
1
|
+
"use strict";var J=Object.create;var F=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var te=(t,o)=>{for(var s in o)F(t,s,{get:o[s],enumerable:!0})},D=(t,o,s,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of Z(o))!ee.call(t,r)&&r!==s&&F(t,r,{get:()=>o[r],enumerable:!(c=Q(o,r))||c.enumerable});return t};var oe=(t,o,s)=>(s=t!=null?J($(t)):{},D(o||!t||!t.__esModule?F(s,"default",{value:t,enumerable:!0}):s,t)),se=t=>D(F({},"__esModule",{value:!0}),t);var ae={};te(ae,{ToastViewport:()=>N,VIEWPORT_DEFAULT_HOTKEY:()=>k,VIEWPORT_PAUSE:()=>O,VIEWPORT_RESUME:()=>M});module.exports=se(ae);var p=require("react/jsx-runtime"),A=require("@tamagui/animate-presence"),U=require("@tamagui/compose-refs"),a=require("@tamagui/core"),G=require("@tamagui/portal"),H=require("@tamagui/stacks"),Y=require("@tamagui/visually-hidden"),l=oe(require("react")),w=require("./ToastProvider");const V="ToastViewport",k=["F8"],O="toast.viewportPause",M="toast.viewportResume",ne=(0,a.styled)(H.YStack,{name:"ViewportWrapper",pointerEvents:"box-none",top:0,bottom:0,left:0,right:0,position:a.isWeb?"fixed":"absolute",maxWidth:"100%",tabIndex:0,zIndex:1e5}),re=(0,a.styled)(H.YStack,{name:V,pointerEvents:"box-none",position:a.isWeb?"fixed":"absolute",maxWidth:"100%"}),N=l.forwardRef((t,o)=>{const{__scopeToast:s,hotkey:c=k,label:r="Notifications ({hotkey})",name:y,multipleToasts:g,...h}=t,i=(0,w.useToastProviderContext)(V,s),v=(0,w.useCollection)(s),x=l.useRef(null),K=l.useRef(null),_=l.useRef(null),b=l.useRef(null),z=(0,U.useComposedRefs)(o,b,i.onViewportChange),B=c.join("+").replace(/Key/g,"").replace(/Digit/g,""),T=i.toastCount>0;l.useEffect(()=>{if(!a.isWeb||i.toastCount===0)return;const e=d=>{var u;c.every(m=>d[m]||d.code===m)&&((u=b.current)==null||u.focus())};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[c,i.toastCount]),l.useEffect(()=>{if(!a.isWeb||i.toastCount===0)return;const e=_.current,d=b.current;if(T&&e&&d){const n=()=>{if(!i.isClosePausedRef.current){const f=new CustomEvent(O);d.dispatchEvent(f),i.isClosePausedRef.current=!0}},u=()=>{if(i.isClosePausedRef.current){const f=new CustomEvent(M);d.dispatchEvent(f),i.isClosePausedRef.current=!1}},m=f=>{!e.contains(f.relatedTarget)&&u()},E=()=>{e.contains(document.activeElement)||u()};return e.addEventListener("focusin",n),e.addEventListener("focusout",m),e.addEventListener("pointermove",n),e.addEventListener("pointerleave",E),window.addEventListener("blur",n),window.addEventListener("focus",u),()=>{e.removeEventListener("focusin",n),e.removeEventListener("focusout",m),e.removeEventListener("pointermove",n),e.removeEventListener("pointerleave",E),window.removeEventListener("blur",n),window.removeEventListener("focus",u)}}},[T,i.isClosePausedRef,i.toastCount]);const P=l.useCallback(({tabbingDirection:e})=>{const n=v().map(u=>{const m=u.ref.current,E=[m,...ie(m)];return e==="forwards"?E:E.reverse()});return(e==="forwards"?n.reverse():n).flat()},[v]);return l.useEffect(()=>{if(!a.isWeb||i.toastCount===0)return;const e=b.current;if(e){const d=n=>{var E,f,L;const u=n.altKey||n.ctrlKey||n.metaKey;if(n.key==="Tab"&&!u){const X=document.activeElement,R=n.shiftKey;if(n.target===e&&R){(E=x.current)==null||E.focus();return}const S=P({tabbingDirection:R?"backwards":"forwards"}),j=S.findIndex(q=>q===X);I(S.slice(j+1))?n.preventDefault():R?(f=x.current)==null||f.focus():(L=K.current)==null||L.focus()}};return e.addEventListener("keydown",d),()=>e.removeEventListener("keydown",d)}},[v,P,i.toastCount]),(0,p.jsxs)(ne,{ref:_,role:"region","aria-label":r.replace("{hotkey}",B),tabIndex:-1,children:[T&&(0,p.jsx)(C,{ref:x,onFocusFromOutsideViewport:()=>{const e=P({tabbingDirection:"forwards"});I(e)}}),(0,p.jsx)(w.Collection.Slot,{scope:s,children:(0,p.jsx)(re,{ref:z,...h,children:(0,p.jsx)(G.PortalHost,{render:e=>(0,p.jsx)(A.AnimatePresence,{exitBeforeEnter:!g,children:e}),name:y??"default"})})}),T&&(0,p.jsx)(C,{ref:K,onFocusFromOutsideViewport:()=>{const e=P({tabbingDirection:"backwards"});I(e)}})]})});N.displayName=V;const W="ToastFocusProxy",C=l.forwardRef((t,o)=>{const{__scopeToast:s,onFocusFromOutsideViewport:c,...r}=t,y=(0,w.useToastProviderContext)(W,s);return(0,p.jsx)(Y.VisuallyHidden,{"aria-hidden":!0,tabIndex:0,...r,ref:o,position:a.isWeb?"fixed":"absolute",onFocus:g=>{var v;if(!a.isWeb)return;const h=g.relatedTarget;!((v=y.viewport)!=null&&v.contains(h))&&c()}})});C.displayName=W;function I(t){if(!a.isWeb)return;const o=document.activeElement;return t.some(s=>s===o?!0:(s.focus(),document.activeElement!==o))}function ie(t){if(!a.isWeb)return[];const o=t,s=[],c=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const y=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||y?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;c.nextNode();)s.push(c.currentNode);return s}0&&(module.exports={ToastViewport,VIEWPORT_DEFAULT_HOTKEY,VIEWPORT_PAUSE,VIEWPORT_RESUME});
|
|
313
2
|
//# sourceMappingURL=ToastViewport.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ToastViewport.tsx"],
|
|
4
4
|
"sourcesContent": ["import { AnimatePresence } from '@tamagui/animate-presence'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport { GetProps, TamaguiElement, isWeb, styled } from '@tamagui/core'\nimport { PortalHost } from '@tamagui/portal'\nimport { YStack } from '@tamagui/stacks'\nimport { VisuallyHidden } from '@tamagui/visually-hidden'\nimport * as React from 'react'\n\nimport {\n Collection,\n ScopedProps,\n useCollection,\n useToastProviderContext,\n} from './ToastProvider'\n\nconst VIEWPORT_NAME = 'ToastViewport'\nconst VIEWPORT_DEFAULT_HOTKEY = ['F8']\nconst VIEWPORT_PAUSE = 'toast.viewportPause'\nconst VIEWPORT_RESUME = 'toast.viewportResume'\n\nconst ToastViewportWrapperFrame = styled(YStack, {\n name: 'ViewportWrapper',\n pointerEvents: 'box-none',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n // @ts-ignore\n position: isWeb ? 'fixed' : 'absolute',\n maxWidth: '100%',\n tabIndex: 0,\n zIndex: 100000,\n})\n\nconst ToastViewportFrame = styled(YStack, {\n name: VIEWPORT_NAME,\n pointerEvents: 'box-none',\n // @ts-ignore\n position: isWeb ? 'fixed' : 'absolute',\n maxWidth: '100%',\n})\ntype ToastViewportFrameProps = GetProps<typeof ToastViewportFrame>\ntype ToastViewportProps = ToastViewportFrameProps & {\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 * Used to reference the viewport if you want to have multiple viewports in the same provider.\n */\n name?: string\n /**\n * Pass this when you want to have multiple/duplicated toasts.\n */\n multipleToasts?: boolean\n}\n\nconst ToastViewport = React.forwardRef<HTMLDivElement, ToastViewportProps>(\n (props: ScopedProps<ToastViewportProps>, forwardedRef) => {\n const {\n __scopeToast,\n hotkey = VIEWPORT_DEFAULT_HOTKEY,\n label = 'Notifications ({hotkey})',\n name,\n multipleToasts,\n ...viewportProps\n } = props\n const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast)\n const getItems = useCollection(__scopeToast)\n const headFocusProxyRef = React.useRef<FocusProxyElement>(null)\n const tailFocusProxyRef = React.useRef<FocusProxyElement>(null)\n const wrapperRef = React.useRef<HTMLDivElement>(null)\n const ref = React.useRef<HTMLDivElement>(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 if (!isWeb) return\n if (context.toastCount === 0) return\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 = hotkey.every(\n (key) => (event as any)[key] || event.code === key\n )\n if (isHotkeyPressed) ref.current?.focus()\n }\n document.addEventListener('keydown', handleKeyDown)\n return () => {\n document.removeEventListener('keydown', handleKeyDown)\n }\n }, [hotkey, context.toastCount])\n\n React.useEffect(() => {\n if (!isWeb) return\n if (context.toastCount === 0) return\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(\n event.relatedTarget as HTMLElement\n )\n if (isFocusMovingOutside) handleResume()\n }\n\n const handlePointerLeaveResume = () => {\n const isFocusInside = wrapper.contains(document.activeElement)\n if (!isFocusInside) handleResume()\n }\n // Toasts are not in the viewport React tree so we need to bind DOM events\n\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, context.toastCount])\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'\n ? tabbableCandidates.reverse()\n : tabbableCandidates\n ).flat()\n },\n [getItems]\n )\n\n React.useEffect(() => {\n if (!isWeb) return\n if (context.toastCount === 0) return\n\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(\n (candidate) => candidate === focusedElement\n )\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, context.toastCount])\n\n return (\n <ToastViewportWrapperFrame\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 // 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 <ToastViewportFrame ref={composedRefs} {...viewportProps}>\n <PortalHost\n render={(children) => (\n <AnimatePresence exitBeforeEnter={!multipleToasts}>\n {children}\n </AnimatePresence>\n )}\n name={name ?? 'default'}\n />\n </ToastViewportFrame>\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 </ToastViewportWrapperFrame>\n )\n }\n)\n\nToastViewport.displayName = VIEWPORT_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst FOCUS_PROXY_NAME = 'ToastFocusProxy'\n\ntype FocusProxyElement = React.ElementRef<typeof VisuallyHidden>\ntype VisuallyHiddenProps = GetProps<typeof VisuallyHidden>\ninterface FocusProxyProps extends VisuallyHiddenProps {\n onFocusFromOutsideViewport(): void\n}\n\nconst FocusProxy = React.forwardRef<FocusProxyElement, ScopedProps<FocusProxyProps>>(\n (props, forwardedRef) => {\n const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props\n const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast)\n\n return (\n <VisuallyHidden\n aria-hidden\n tabIndex={0}\n {...proxyProps}\n ref={forwardedRef}\n // Avoid page scrolling when focus is on the focus proxy\n position={isWeb ? ('fixed' as any) : 'absolute'}\n onFocus={(event) => {\n if (!isWeb) return\n const prevFocusedElement = event.relatedTarget as HTMLElement | null\n const isFocusFromOutsideViewport = !(context.viewport as HTMLElement)?.contains(\n prevFocusedElement\n )\n if (isFocusFromOutsideViewport) onFocusFromOutsideViewport()\n }}\n />\n )\n }\n)\n\nFocusProxy.displayName = FOCUS_PROXY_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction focusFirst(candidates: TamaguiElement[]) {\n if (!isWeb) return\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\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: TamaguiElement) {\n if (!isWeb) return []\n const containerHtml = container as HTMLElement\n const nodes: HTMLElement[] = []\n const walker = document.createTreeWalker(containerHtml, 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\nexport {\n ToastViewport,\n ToastViewportProps,\n VIEWPORT_DEFAULT_HOTKEY,\n VIEWPORT_PAUSE,\n VIEWPORT_RESUME,\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
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AO,OACZ,MAAM+B,EAAqBhC,EAAM,cACE,GAAEC,EAAAX,EAAQ,WAAR,MAAAW,EAAkC,SACrE+B,KAE8BF,EAA2B,CAC7D,EACF,CAEJ,CACF,EAEAH,EAAW,YAAcE,EAIzB,SAASH,EAAWO,EAA8B,CAChD,GAAI,CAAC,QAAO,OACZ,MAAMC,EAA2B,SAAS,cAC1C,OAAOD,EAAW,KAAMR,GAElBA,IAAcS,EAAiC,IACnDT,EAAU,MAAM,EACT,SAAS,gBAAkBS,EACnC,CACH,CAYA,SAASjB,GAAsBkB,EAA2B,CACxD,GAAI,CAAC,QAAO,MAAO,CAAC,EACpB,MAAMC,EAAgBD,EAChBE,EAAuB,CAAC,EACxBC,EAAS,SAAS,iBAAiBF,EAAe,WAAW,aAAc,CAC/E,WAAaG,GAAc,CACzB,MAAMC,EAAgBD,EAAK,UAAY,SAAWA,EAAK,OAAS,SAChE,OAAIA,EAAK,UAAYA,EAAK,QAAUC,EAAsB,WAAW,YAI9DD,EAAK,UAAY,EAAI,WAAW,cAAgB,WAAW,WACpE,CACF,CAAC,EACD,KAAOD,EAAO,SAAS,GAAGD,EAAM,KAAKC,EAAO,WAA0B,EAGtE,OAAOD,CACT",
|
|
6
|
+
"names": ["ToastViewport_exports", "__export", "ToastViewport", "VIEWPORT_DEFAULT_HOTKEY", "VIEWPORT_PAUSE", "VIEWPORT_RESUME", "__toCommonJS", "import_jsx_runtime", "import_animate_presence", "import_compose_refs", "import_core", "import_portal", "import_stacks", "import_visually_hidden", "React", "import_ToastProvider", "VIEWPORT_NAME", "ToastViewportWrapperFrame", "ToastViewportFrame", "props", "forwardedRef", "__scopeToast", "hotkey", "label", "name", "multipleToasts", "viewportProps", "context", "getItems", "headFocusProxyRef", "tailFocusProxyRef", "wrapperRef", "ref", "composedRefs", "hotkeyLabel", "hasToasts", "handleKeyDown", "event", "_a", "key", "wrapper", "viewport", "handlePause", "pauseEvent", "handleResume", "resumeEvent", "handleFocusOutResume", "handlePointerLeaveResume", "getSortedTabbableCandidates", "tabbingDirection", "tabbableCandidates", "toastItem", "toastNode", "toastTabbableCandidates", "getTabbableCandidates", "_b", "_c", "isMetaKey", "focusedElement", "isTabbingBackwards", "sortedCandidates", "index", "candidate", "focusFirst", "FocusProxy", "children", "FOCUS_PROXY_NAME", "onFocusFromOutsideViewport", "proxyProps", "prevFocusedElement", "candidates", "previouslyFocusedElement", "container", "containerHtml", "nodes", "walker", "node", "isHiddenInput"]
|
|
7
7
|
}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,29 +1,2 @@
|
|
|
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 constants_exports = {};
|
|
20
|
-
__export(constants_exports, {
|
|
21
|
-
TOAST_NAME: () => TOAST_NAME
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(constants_exports);
|
|
24
|
-
const TOAST_NAME = "Toast";
|
|
25
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
-
0 && (module.exports = {
|
|
27
|
-
TOAST_NAME
|
|
28
|
-
});
|
|
1
|
+
"use strict";var A=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var e=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var p=(t,o)=>{for(var s in o)A(t,s,{get:o[s],enumerable:!0})},r=(t,o,s,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let T of e(o))!n.call(t,T)&&T!==s&&A(t,T,{get:()=>o[T],enumerable:!(a=c(o,T))||a.enumerable});return t};var x=t=>r(A({},"__esModule",{value:!0}),t);var M={};p(M,{TOAST_NAME:()=>E});module.exports=x(M);const E="Toast";0&&(module.exports={TOAST_NAME});
|
|
29
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/constants.ts"],
|
|
4
4
|
"sourcesContent": ["export const TOAST_NAME = 'Toast'\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAa",
|
|
6
|
+
"names": ["constants_exports", "__export", "TOAST_NAME", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,70 +1,2 @@
|
|
|
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 createNativeToast_exports = {};
|
|
20
|
-
__export(createNativeToast_exports, {
|
|
21
|
-
createNativeToast: () => createNativeToast,
|
|
22
|
-
hideNativeToast: () => hideNativeToast
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(createNativeToast_exports);
|
|
25
|
-
const createNativeToast = (title, { message, notificationOptions }) => {
|
|
26
|
-
if (!("Notification" in window)) {
|
|
27
|
-
console.error("This browser does not support notifications");
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if (Notification.permission === "denied")
|
|
31
|
-
false;
|
|
32
|
-
const showNotification = () => {
|
|
33
|
-
const notification = new Notification(title, {
|
|
34
|
-
body: message,
|
|
35
|
-
...notificationOptions
|
|
36
|
-
});
|
|
37
|
-
return notification;
|
|
38
|
-
};
|
|
39
|
-
if (Notification.permission === "granted") {
|
|
40
|
-
const notification = showNotification();
|
|
41
|
-
return {
|
|
42
|
-
nativeToastRef: notification
|
|
43
|
-
};
|
|
44
|
-
} else {
|
|
45
|
-
Notification.requestPermission().then((permission) => {
|
|
46
|
-
if (permission === "granted") {
|
|
47
|
-
const notification = showNotification();
|
|
48
|
-
return {
|
|
49
|
-
nativeToastRef: notification
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return true;
|
|
55
|
-
};
|
|
56
|
-
const hideNativeToast = (ref) => {
|
|
57
|
-
if (!("Notification" in window)) {
|
|
58
|
-
console.error("This browser does not support notifications");
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (ref) {
|
|
62
|
-
ref.close();
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
-
0 && (module.exports = {
|
|
67
|
-
createNativeToast,
|
|
68
|
-
hideNativeToast
|
|
69
|
-
});
|
|
1
|
+
"use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var f=(i,t)=>{for(var n in t)s(i,n,{get:t[n],enumerable:!0})},N=(i,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of r(t))!c.call(i,o)&&o!==n&&s(i,o,{get:()=>t[o],enumerable:!(e=a(t,o))||e.enumerable});return i};var d=i=>N(s({},"__esModule",{value:!0}),i);var p={};f(p,{createNativeToast:()=>u,hideNativeToast:()=>T});module.exports=d(p);const u=(i,{message:t,notificationOptions:n})=>{if(!("Notification"in window))return console.error("This browser does not support notifications"),!1;Notification.permission;const e=()=>new Notification(i,{body:t,...n});return Notification.permission==="granted"?{nativeToastRef:e()}:(Notification.requestPermission().then(o=>{if(o==="granted")return{nativeToastRef:e()}}),!0)},T=i=>{if(!("Notification"in window)){console.error("This browser does not support notifications");return}i&&i.close()};0&&(module.exports={createNativeToast,hideNativeToast});
|
|
70
2
|
//# sourceMappingURL=createNativeToast.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createNativeToast.tsx"],
|
|
4
4
|
"sourcesContent": ["import { CreateNativeToastsFn, HideNativeToastsFn } from './types'\n\nexport const createNativeToast: CreateNativeToastsFn = (\n title,\n { message, notificationOptions }\n) => {\n if (!('Notification' in window)) {\n console.error('This browser does not support notifications')\n return false\n }\n\n if (Notification.permission === 'denied') false\n const showNotification = () => {\n const notification = new Notification(title, {\n body: message,\n ...notificationOptions,\n })\n\n return notification\n }\n\n if (Notification.permission === 'granted') {\n const notification = showNotification()\n return {\n nativeToastRef: notification,\n }\n } else {\n Notification.requestPermission().then((permission) => {\n if (permission === 'granted') {\n const notification = showNotification()\n return {\n nativeToastRef: notification,\n }\n }\n })\n }\n return true\n}\n\nexport const hideNativeToast: HideNativeToastsFn = (ref) => {\n if (!('Notification' in window)) {\n console.error('This browser does not support notifications')\n return\n }\n\n if (ref) {\n ref.close()\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,GAEO,MAAME,EAA0C,CACrDG,EACA,CAAE,QAAAC,EAAS,oBAAAC,CAAoB,IAC5B,CACH,GAAI,EAAE,iBAAkB,QACtB,eAAQ,MAAM,6CAA6C,EACpD,GAGL,aAAa,WACjB,MAAMC,EAAmB,IACF,IAAI,aAAaH,EAAO,CAC3C,KAAMC,EACN,GAAGC,CACL,CAAC,EAKH,OAAI,aAAa,aAAe,UAEvB,CACL,eAFmBC,EAAiB,CAGtC,GAEA,aAAa,kBAAkB,EAAE,KAAMC,GAAe,CACpD,GAAIA,IAAe,UAEjB,MAAO,CACL,eAFmBD,EAAiB,CAGtC,CAEJ,CAAC,EAEI,GACT,EAEaL,EAAuCO,GAAQ,CAC1D,GAAI,EAAE,iBAAkB,QAAS,CAC/B,QAAQ,MAAM,6CAA6C,EAC3D,MACF,CAEIA,GACFA,EAAI,MAAM,CAEd",
|
|
6
|
+
"names": ["createNativeToast_exports", "__export", "createNativeToast", "hideNativeToast", "__toCommonJS", "title", "message", "notificationOptions", "showNotification", "permission", "ref"]
|
|
7
7
|
}
|
|
@@ -1,44 +1,2 @@
|
|
|
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 createNativeToast_native_exports = {};
|
|
20
|
-
__export(createNativeToast_native_exports, {
|
|
21
|
-
createNativeToast: () => createNativeToast,
|
|
22
|
-
hideNativeToast: () => hideNativeToast
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(createNativeToast_native_exports);
|
|
25
|
-
const createNativeToast = (title, { message, duration, burntOptions }) => {
|
|
26
|
-
const Burnt = require("burnt");
|
|
27
|
-
Burnt.toast({
|
|
28
|
-
title,
|
|
29
|
-
message,
|
|
30
|
-
duration: duration ? duration * 1e3 : void 0,
|
|
31
|
-
...burntOptions
|
|
32
|
-
});
|
|
33
|
-
return true;
|
|
34
|
-
};
|
|
35
|
-
const hideNativeToast = () => {
|
|
36
|
-
const Burnt = require("burnt");
|
|
37
|
-
Burnt.dismissAllAlerts();
|
|
38
|
-
};
|
|
39
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
createNativeToast,
|
|
42
|
-
hideNativeToast
|
|
43
|
-
});
|
|
1
|
+
"use strict";var a=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})},T=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of i(t))!u.call(e,s)&&s!==r&&a(e,s,{get:()=>t[s],enumerable:!(o=n(t,s))||o.enumerable});return e};var d=e=>T(a({},"__esModule",{value:!0}),e);var c={};p(c,{createNativeToast:()=>v,hideNativeToast:()=>N});module.exports=d(c);const v=(e,{message:t,duration:r,burntOptions:o})=>(require("burnt").toast({title:e,message:t,duration:r?r*1e3:void 0,...o}),!0),N=()=>{require("burnt").dismissAllAlerts()};0&&(module.exports={createNativeToast,hideNativeToast});
|
|
44
2
|
//# sourceMappingURL=createNativeToast.native.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createNativeToast.native.tsx"],
|
|
4
4
|
"sourcesContent": ["import { BurntToastOptions, CreateNativeToastsFn, HideNativeToastsFn } from './types'\n\nexport const createNativeToast: CreateNativeToastsFn = (\n title,\n { message, duration, burntOptions }\n) => {\n // import inline to allow lazy usage of native dependecy:\n const Burnt = require('burnt') as typeof import('burnt')\n\n Burnt.toast({\n title,\n message,\n duration: duration ? duration * 1000 : undefined,\n ...burntOptions,\n })\n return true\n}\n\nexport const hideNativeToast: HideNativeToastsFn = () => {\n const Burnt = require('burnt') as typeof import('burnt')\n Burnt.dismissAllAlerts()\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,GAEO,MAAME,EAA0C,CACrDG,EACA,CAAE,QAAAC,EAAS,SAAAC,EAAU,aAAAC,CAAa,KAGpB,QAAQ,OAAO,EAEvB,MAAM,CACV,MAAAH,EACA,QAAAC,EACA,SAAUC,EAAWA,EAAW,IAAO,OACvC,GAAGC,CACL,CAAC,EACM,IAGIL,EAAsC,IAAM,CACzC,QAAQ,OAAO,EACvB,iBAAiB,CACzB",
|
|
6
|
+
"names": ["createNativeToast_native_exports", "__export", "createNativeToast", "hideNativeToast", "__toCommonJS", "title", "message", "duration", "burntOptions"]
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var src_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(src_exports);
|
|
18
|
-
__reExport(src_exports, require("./Toast.js"), module.exports);
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("./Toast.js"),module.exports);
|
|
19
2
|
//# sourceMappingURL=index.js.map
|