@hanzogui/toast 3.0.2 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +42 -25
- package/src/Toast.tsx +5 -5
- package/src/ToastAnnounce.tsx +2 -2
- package/src/ToastComposable.tsx +1380 -0
- package/src/ToastImpl.tsx +19 -7
- package/src/ToastItemFrame.tsx +136 -0
- package/src/ToastPortal.tsx +2 -2
- package/src/ToastProvider.tsx +13 -6
- package/src/ToastState.ts +398 -0
- package/src/ToastViewport.tsx +11 -10
- package/src/Toaster.tsx +181 -0
- package/src/createNativeToast.native.tsx +4 -0
- package/src/createNativeToast.tsx +18 -24
- package/src/dispatchNativeToast.ts +43 -0
- package/src/useAnimatedDragGesture.native.ts +255 -0
- package/src/useAnimatedDragGesture.ts +319 -0
- package/src/useReducedMotion.ts +59 -0
- package/src/useToastAnimations.ts +377 -0
- package/src/v2.ts +31 -0
- package/types/Toast.d.ts +36 -36
- package/types/ToastAnnounce.d.ts +4 -4
- package/types/ToastComposable.d.ts +199 -0
- package/types/ToastImperative.d.ts +2 -2
- package/types/ToastImpl.d.ts +12 -12
- package/types/ToastItemFrame.d.ts +25 -0
- package/types/ToastProvider.d.ts +8 -8
- package/types/ToastState.d.ts +179 -0
- package/types/ToastViewport.d.ts +12 -12
- package/types/Toaster.d.ts +112 -0
- package/types/createNativeToast.d.ts +5 -0
- package/types/createNativeToast.native.d.ts +1 -0
- package/types/dispatchNativeToast.d.ts +12 -0
- package/types/useAnimatedDragGesture.d.ts +33 -0
- package/types/useAnimatedDragGesture.native.d.ts +33 -0
- package/types/useReducedMotion.d.ts +6 -0
- package/types/useToastAnimations.d.ts +50 -0
- package/types/v2.d.ts +10 -0
- package/v2/index.cjs +2 -0
- package/v2/index.js +2 -0
- package/v2/index.native.cjs +2 -0
- package/v2/index.native.js +2 -0
- package/LICENSE +0 -21
- package/dist/cjs/Toast.cjs +0 -170
- package/dist/cjs/Toast.native.js +0 -174
- package/dist/cjs/Toast.native.js.map +0 -1
- package/dist/cjs/ToastAnnounce.cjs +0 -97
- package/dist/cjs/ToastAnnounce.native.js +0 -105
- package/dist/cjs/ToastAnnounce.native.js.map +0 -1
- package/dist/cjs/ToastImperative.cjs +0 -100
- package/dist/cjs/ToastImperative.native.js +0 -122
- package/dist/cjs/ToastImperative.native.js.map +0 -1
- package/dist/cjs/ToastImpl.cjs +0 -292
- package/dist/cjs/ToastImpl.native.js +0 -326
- package/dist/cjs/ToastImpl.native.js.map +0 -1
- package/dist/cjs/ToastPortal.cjs +0 -44
- package/dist/cjs/ToastPortal.native.js +0 -47
- package/dist/cjs/ToastPortal.native.js.map +0 -1
- package/dist/cjs/ToastProvider.cjs +0 -146
- package/dist/cjs/ToastProvider.native.js +0 -159
- package/dist/cjs/ToastProvider.native.js.map +0 -1
- package/dist/cjs/ToastViewport.cjs +0 -278
- package/dist/cjs/ToastViewport.native.js +0 -315
- package/dist/cjs/ToastViewport.native.js.map +0 -1
- package/dist/cjs/constants.cjs +0 -28
- package/dist/cjs/constants.native.js +0 -31
- package/dist/cjs/constants.native.js.map +0 -1
- package/dist/cjs/createNativeToast.cjs +0 -51
- package/dist/cjs/createNativeToast.native.js +0 -48
- package/dist/cjs/createNativeToast.native.js.map +0 -1
- package/dist/cjs/index.cjs +0 -18
- package/dist/cjs/index.native.js +0 -21
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/cjs/types.cjs +0 -16
- package/dist/cjs/types.native.js +0 -19
- package/dist/cjs/types.native.js.map +0 -1
- package/dist/esm/Toast.mjs +0 -131
- package/dist/esm/Toast.mjs.map +0 -1
- package/dist/esm/Toast.native.js +0 -132
- package/dist/esm/Toast.native.js.map +0 -1
- package/dist/esm/ToastAnnounce.mjs +0 -62
- package/dist/esm/ToastAnnounce.mjs.map +0 -1
- package/dist/esm/ToastAnnounce.native.js +0 -67
- package/dist/esm/ToastAnnounce.native.js.map +0 -1
- package/dist/esm/ToastImperative.mjs +0 -63
- package/dist/esm/ToastImperative.mjs.map +0 -1
- package/dist/esm/ToastImperative.native.js +0 -82
- package/dist/esm/ToastImperative.native.js.map +0 -1
- package/dist/esm/ToastImpl.mjs +0 -256
- package/dist/esm/ToastImpl.mjs.map +0 -1
- package/dist/esm/ToastImpl.native.js +0 -287
- package/dist/esm/ToastImpl.native.js.map +0 -1
- package/dist/esm/ToastPortal.mjs +0 -21
- package/dist/esm/ToastPortal.mjs.map +0 -1
- package/dist/esm/ToastPortal.native.js +0 -21
- package/dist/esm/ToastPortal.native.js.map +0 -1
- package/dist/esm/ToastProvider.mjs +0 -108
- package/dist/esm/ToastProvider.mjs.map +0 -1
- package/dist/esm/ToastProvider.native.js +0 -118
- package/dist/esm/ToastProvider.native.js.map +0 -1
- package/dist/esm/ToastViewport.mjs +0 -241
- package/dist/esm/ToastViewport.mjs.map +0 -1
- package/dist/esm/ToastViewport.native.js +0 -275
- package/dist/esm/ToastViewport.native.js.map +0 -1
- package/dist/esm/constants.mjs +0 -4
- package/dist/esm/constants.mjs.map +0 -1
- package/dist/esm/constants.native.js +0 -4
- package/dist/esm/constants.native.js.map +0 -1
- package/dist/esm/createNativeToast.mjs +0 -27
- package/dist/esm/createNativeToast.mjs.map +0 -1
- package/dist/esm/createNativeToast.native.js +0 -21
- package/dist/esm/createNativeToast.native.js.map +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs +0 -2
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js +0 -2
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js +0 -2
- package/dist/esm/types.native.js.map +0 -1
- package/dist/jsx/Toast.mjs +0 -131
- package/dist/jsx/Toast.mjs.map +0 -1
- package/dist/jsx/Toast.native.js +0 -174
- package/dist/jsx/Toast.native.js.map +0 -1
- package/dist/jsx/ToastAnnounce.mjs +0 -62
- package/dist/jsx/ToastAnnounce.mjs.map +0 -1
- package/dist/jsx/ToastAnnounce.native.js +0 -105
- package/dist/jsx/ToastAnnounce.native.js.map +0 -1
- package/dist/jsx/ToastImperative.mjs +0 -63
- package/dist/jsx/ToastImperative.mjs.map +0 -1
- package/dist/jsx/ToastImperative.native.js +0 -122
- package/dist/jsx/ToastImperative.native.js.map +0 -1
- package/dist/jsx/ToastImpl.mjs +0 -256
- package/dist/jsx/ToastImpl.mjs.map +0 -1
- package/dist/jsx/ToastImpl.native.js +0 -326
- package/dist/jsx/ToastImpl.native.js.map +0 -1
- package/dist/jsx/ToastPortal.mjs +0 -21
- package/dist/jsx/ToastPortal.mjs.map +0 -1
- package/dist/jsx/ToastPortal.native.js +0 -47
- package/dist/jsx/ToastPortal.native.js.map +0 -1
- package/dist/jsx/ToastProvider.mjs +0 -108
- package/dist/jsx/ToastProvider.mjs.map +0 -1
- package/dist/jsx/ToastProvider.native.js +0 -159
- package/dist/jsx/ToastProvider.native.js.map +0 -1
- package/dist/jsx/ToastViewport.mjs +0 -241
- package/dist/jsx/ToastViewport.mjs.map +0 -1
- package/dist/jsx/ToastViewport.native.js +0 -315
- package/dist/jsx/ToastViewport.native.js.map +0 -1
- package/dist/jsx/constants.mjs +0 -4
- package/dist/jsx/constants.mjs.map +0 -1
- package/dist/jsx/constants.native.js +0 -31
- package/dist/jsx/constants.native.js.map +0 -1
- package/dist/jsx/createNativeToast.mjs +0 -27
- package/dist/jsx/createNativeToast.mjs.map +0 -1
- package/dist/jsx/createNativeToast.native.js +0 -48
- package/dist/jsx/createNativeToast.native.js.map +0 -1
- package/dist/jsx/index.js +0 -2
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs +0 -2
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/index.native.js +0 -21
- package/dist/jsx/index.native.js.map +0 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.mjs.map +0 -1
- package/dist/jsx/types.native.js +0 -19
- package/dist/jsx/types.native.js.map +0 -1
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: !0
|
|
11
|
-
});
|
|
12
|
-
},
|
|
13
|
-
__copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
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", {
|
|
26
|
-
value: mod,
|
|
27
|
-
enumerable: !0
|
|
28
|
-
}) : target, mod)),
|
|
29
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
-
value: !0
|
|
31
|
-
}), mod);
|
|
32
|
-
var ToastViewport_exports = {};
|
|
33
|
-
__export(ToastViewport_exports, {
|
|
34
|
-
ToastViewport: () => ToastViewport,
|
|
35
|
-
VIEWPORT_DEFAULT_HOTKEY: () => VIEWPORT_DEFAULT_HOTKEY,
|
|
36
|
-
VIEWPORT_PAUSE: () => VIEWPORT_PAUSE,
|
|
37
|
-
VIEWPORT_RESUME: () => VIEWPORT_RESUME
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(ToastViewport_exports);
|
|
40
|
-
var import_gui_animate_presence = require("@hanzogui/animate-presence"),
|
|
41
|
-
import_gui_compose_refs = require("@hanzogui/compose-refs"),
|
|
42
|
-
import_gui_constants = require("@hanzogui/constants"),
|
|
43
|
-
import_gui_core = require("@hanzogui/core"),
|
|
44
|
-
import_gui_portal = require("@hanzogui/portal"),
|
|
45
|
-
import_gui_stacks = require("@hanzogui/stacks"),
|
|
46
|
-
import_gui_visually_hidden = require("@hanzogui/visually-hidden"),
|
|
47
|
-
React = __toESM(require("react"), 1),
|
|
48
|
-
import_constants = require("./constants.cjs"),
|
|
49
|
-
import_ToastPortal = require("./ToastPortal.cjs"),
|
|
50
|
-
import_ToastProvider = require("./ToastProvider.cjs"),
|
|
51
|
-
import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
-
const VIEWPORT_NAME = "ToastViewport",
|
|
53
|
-
VIEWPORT_DEFAULT_HOTKEY = ["F8"],
|
|
54
|
-
VIEWPORT_PAUSE = "toast.viewportPause",
|
|
55
|
-
VIEWPORT_RESUME = "toast.viewportResume",
|
|
56
|
-
ToastViewportWrapperFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
|
|
57
|
-
name: "ViewportWrapper",
|
|
58
|
-
variants: {
|
|
59
|
-
unstyled: {
|
|
60
|
-
false: {
|
|
61
|
-
pointerEvents: "box-none",
|
|
62
|
-
top: 0,
|
|
63
|
-
bottom: 0,
|
|
64
|
-
left: 0,
|
|
65
|
-
right: 0,
|
|
66
|
-
position: "fixed",
|
|
67
|
-
maxWidth: "100%",
|
|
68
|
-
tabIndex: 0,
|
|
69
|
-
zIndex: 1e5
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
defaultVariants: {
|
|
74
|
-
unstyled: process.env.HANZO_GUI_HEADLESS === "1"
|
|
75
|
-
}
|
|
76
|
-
}),
|
|
77
|
-
ToastViewportFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
|
|
78
|
-
name: VIEWPORT_NAME,
|
|
79
|
-
variants: {
|
|
80
|
-
unstyled: {
|
|
81
|
-
false: {
|
|
82
|
-
pointerEvents: "box-none",
|
|
83
|
-
position: "fixed",
|
|
84
|
-
maxWidth: "100%"
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
defaultVariants: {
|
|
89
|
-
unstyled: process.env.HANZO_GUI_HEADLESS === "1"
|
|
90
|
-
}
|
|
91
|
-
}),
|
|
92
|
-
ToastViewport = React.memo(React.forwardRef((props, forwardedRef) => {
|
|
93
|
-
const {
|
|
94
|
-
scope,
|
|
95
|
-
hotkey = VIEWPORT_DEFAULT_HOTKEY,
|
|
96
|
-
label = "Notifications ({hotkey})",
|
|
97
|
-
name = "default",
|
|
98
|
-
multipleToasts,
|
|
99
|
-
zIndex,
|
|
100
|
-
portalToRoot,
|
|
101
|
-
...viewportProps
|
|
102
|
-
} = props,
|
|
103
|
-
context = (0, import_ToastProvider.useToastProviderContext)(scope),
|
|
104
|
-
getItems = (0, import_ToastProvider.useCollection)(scope || import_constants.TOAST_CONTEXT),
|
|
105
|
-
headFocusProxyRef = React.useRef(null),
|
|
106
|
-
tailFocusProxyRef = React.useRef(null),
|
|
107
|
-
wrapperRef = React.useRef(null),
|
|
108
|
-
ref = React.useRef(null),
|
|
109
|
-
onViewportChange = React.useCallback(el => {
|
|
110
|
-
context.viewports[name] !== el && context.onViewportChange(name, el);
|
|
111
|
-
}, [name, context.viewports]),
|
|
112
|
-
composedRefs = (0, import_gui_compose_refs.useComposedRefs)(forwardedRef, ref, onViewportChange),
|
|
113
|
-
hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, ""),
|
|
114
|
-
hasToasts = context.toastCount > 0;
|
|
115
|
-
React.useEffect(() => {
|
|
116
|
-
if (!import_gui_constants.isWeb || context.toastCount === 0) return;
|
|
117
|
-
const handleKeyDown = event => {
|
|
118
|
-
hotkey.every(key => event[key] || event.code === key) && ref.current?.focus();
|
|
119
|
-
};
|
|
120
|
-
return document.addEventListener("keydown", handleKeyDown), () => {
|
|
121
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
122
|
-
};
|
|
123
|
-
}, [hotkey, context.toastCount]), React.useEffect(() => {
|
|
124
|
-
if (!import_gui_constants.isWeb || context.toastCount === 0) return;
|
|
125
|
-
const wrapper = wrapperRef.current,
|
|
126
|
-
viewport = ref.current;
|
|
127
|
-
if (hasToasts && wrapper && viewport) {
|
|
128
|
-
const handlePause = () => {
|
|
129
|
-
if (!context.isClosePausedRef.current) {
|
|
130
|
-
const pauseEvent = new CustomEvent(VIEWPORT_PAUSE);
|
|
131
|
-
viewport.dispatchEvent(pauseEvent), context.isClosePausedRef.current = !0;
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
handleResume = () => {
|
|
135
|
-
if (context.isClosePausedRef.current) {
|
|
136
|
-
const resumeEvent = new CustomEvent(VIEWPORT_RESUME);
|
|
137
|
-
viewport.dispatchEvent(resumeEvent), context.isClosePausedRef.current = !1;
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
handleFocusOutResume = event => {
|
|
141
|
-
!wrapper.contains(event.relatedTarget) && handleResume();
|
|
142
|
-
},
|
|
143
|
-
handlePointerLeaveResume = () => {
|
|
144
|
-
wrapper.contains(document.activeElement) || handleResume();
|
|
145
|
-
};
|
|
146
|
-
return wrapper.addEventListener("focusin", handlePause), wrapper.addEventListener("focusout", handleFocusOutResume), wrapper.addEventListener("pointermove", handlePause), wrapper.addEventListener("pointerleave", handlePointerLeaveResume), window.addEventListener("blur", handlePause), window.addEventListener("focus", handleResume), () => {
|
|
147
|
-
wrapper.removeEventListener("focusin", handlePause), wrapper.removeEventListener("focusout", handleFocusOutResume), wrapper.removeEventListener("pointermove", handlePause), wrapper.removeEventListener("pointerleave", handlePointerLeaveResume), window.removeEventListener("blur", handlePause), window.removeEventListener("focus", handleResume);
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
}, [hasToasts, context.isClosePausedRef, context.toastCount]);
|
|
151
|
-
const getSortedTabbableCandidates = React.useCallback(({
|
|
152
|
-
tabbingDirection
|
|
153
|
-
}) => {
|
|
154
|
-
const tabbableCandidates = getItems().map(toastItem => {
|
|
155
|
-
const toastNode = toastItem.ref.current,
|
|
156
|
-
toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];
|
|
157
|
-
return tabbingDirection === "forwards" ? toastTabbableCandidates : toastTabbableCandidates.reverse();
|
|
158
|
-
});
|
|
159
|
-
return (tabbingDirection === "forwards" ? tabbableCandidates.reverse() : tabbableCandidates).flat();
|
|
160
|
-
}, [getItems]);
|
|
161
|
-
React.useEffect(() => {
|
|
162
|
-
if (!import_gui_constants.isWeb || context.toastCount === 0) return;
|
|
163
|
-
const viewport = ref.current;
|
|
164
|
-
if (viewport) {
|
|
165
|
-
const handleKeyDown = event => {
|
|
166
|
-
const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
|
|
167
|
-
if (event.key === "Tab" && !isMetaKey) {
|
|
168
|
-
const focusedElement = document.activeElement,
|
|
169
|
-
isTabbingBackwards = event.shiftKey;
|
|
170
|
-
if (event.target === viewport && isTabbingBackwards) {
|
|
171
|
-
headFocusProxyRef.current?.focus();
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const sortedCandidates = getSortedTabbableCandidates({
|
|
175
|
-
tabbingDirection: isTabbingBackwards ? "backwards" : "forwards"
|
|
176
|
-
}),
|
|
177
|
-
index = sortedCandidates.findIndex(candidate => candidate === focusedElement);
|
|
178
|
-
focusFirst(sortedCandidates.slice(index + 1)) ? event.preventDefault() : isTabbingBackwards ?
|
|
179
|
-
// @ts-ignore ali TODO type
|
|
180
|
-
headFocusProxyRef.current?.focus() :
|
|
181
|
-
// @ts-ignore ali TODO type
|
|
182
|
-
tailFocusProxyRef.current?.focus();
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
return viewport.addEventListener("keydown", handleKeyDown), () => viewport.removeEventListener("keydown", handleKeyDown);
|
|
186
|
-
}
|
|
187
|
-
}, [getItems, getSortedTabbableCandidates, context.toastCount]);
|
|
188
|
-
const contents = /* @__PURE__ */(0, import_jsx_runtime.jsxs)(ToastViewportWrapperFrame, {
|
|
189
|
-
ref: wrapperRef,
|
|
190
|
-
role: "region",
|
|
191
|
-
"aria-label": label.replace("{hotkey}", hotkeyLabel),
|
|
192
|
-
tabIndex: -1,
|
|
193
|
-
children: [hasToasts && /* @__PURE__ */(0, import_jsx_runtime.jsx)(FocusProxy, {
|
|
194
|
-
context,
|
|
195
|
-
viewportName: name,
|
|
196
|
-
ref: headFocusProxyRef,
|
|
197
|
-
onFocusFromOutsideViewport: () => {
|
|
198
|
-
const tabbableCandidates = getSortedTabbableCandidates({
|
|
199
|
-
tabbingDirection: "forwards"
|
|
200
|
-
});
|
|
201
|
-
focusFirst(tabbableCandidates);
|
|
202
|
-
}
|
|
203
|
-
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.Slot, {
|
|
204
|
-
scope: context.toastScope,
|
|
205
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastViewportFrame, {
|
|
206
|
-
focusable: context.toastCount > 0,
|
|
207
|
-
ref: composedRefs,
|
|
208
|
-
...viewportProps,
|
|
209
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_portal.PortalHost, {
|
|
210
|
-
render: children => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_animate_presence.AnimatePresence, {
|
|
211
|
-
exitBeforeEnter: !multipleToasts,
|
|
212
|
-
children
|
|
213
|
-
}),
|
|
214
|
-
name: name ?? "default"
|
|
215
|
-
})
|
|
216
|
-
})
|
|
217
|
-
}), hasToasts && /* @__PURE__ */(0, import_jsx_runtime.jsx)(FocusProxy, {
|
|
218
|
-
context,
|
|
219
|
-
viewportName: name,
|
|
220
|
-
ref: tailFocusProxyRef,
|
|
221
|
-
onFocusFromOutsideViewport: () => {
|
|
222
|
-
const tabbableCandidates = getSortedTabbableCandidates({
|
|
223
|
-
tabbingDirection: "backwards"
|
|
224
|
-
});
|
|
225
|
-
focusFirst(tabbableCandidates);
|
|
226
|
-
}
|
|
227
|
-
})]
|
|
228
|
-
});
|
|
229
|
-
return portalToRoot ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastPortal.ToastPortal, {
|
|
230
|
-
context,
|
|
231
|
-
...(typeof zIndex == "number" ? {
|
|
232
|
-
zIndex
|
|
233
|
-
} : {}),
|
|
234
|
-
children: contents
|
|
235
|
-
}) : contents;
|
|
236
|
-
}));
|
|
237
|
-
ToastViewport.displayName = VIEWPORT_NAME;
|
|
238
|
-
const FOCUS_PROXY_NAME = "ToastFocusProxy",
|
|
239
|
-
FocusProxy = React.forwardRef((props, forwardedRef) => {
|
|
240
|
-
const {
|
|
241
|
-
onFocusFromOutsideViewport,
|
|
242
|
-
viewportName,
|
|
243
|
-
context,
|
|
244
|
-
...proxyProps
|
|
245
|
-
} = props,
|
|
246
|
-
viewport = context.viewports[viewportName];
|
|
247
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_visually_hidden.VisuallyHidden, {
|
|
248
|
-
"aria-hidden": !0,
|
|
249
|
-
tabIndex: 0,
|
|
250
|
-
...proxyProps,
|
|
251
|
-
ref: forwardedRef,
|
|
252
|
-
position: "fixed",
|
|
253
|
-
onFocus: event => {
|
|
254
|
-
if (!import_gui_constants.isWeb) return;
|
|
255
|
-
const prevFocusedElement = event.relatedTarget;
|
|
256
|
-
!viewport?.contains(prevFocusedElement) && onFocusFromOutsideViewport();
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
FocusProxy.displayName = FOCUS_PROXY_NAME;
|
|
261
|
-
function focusFirst(candidates) {
|
|
262
|
-
if (!import_gui_constants.isWeb) return;
|
|
263
|
-
const previouslyFocusedElement = document.activeElement;
|
|
264
|
-
return candidates.some(candidate => candidate === previouslyFocusedElement ? !0 : (candidate.focus(), document.activeElement !== previouslyFocusedElement));
|
|
265
|
-
}
|
|
266
|
-
function getTabbableCandidates(container) {
|
|
267
|
-
if (!import_gui_constants.isWeb) return [];
|
|
268
|
-
const containerHtml = container,
|
|
269
|
-
nodes = [],
|
|
270
|
-
walker = document.createTreeWalker(containerHtml, NodeFilter.SHOW_ELEMENT, {
|
|
271
|
-
acceptNode: node => {
|
|
272
|
-
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
273
|
-
return node.disabled || node.hidden || isHiddenInput ? NodeFilter.FILTER_SKIP : node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
for (; walker.nextNode();) nodes.push(walker.currentNode);
|
|
277
|
-
return nodes;
|
|
278
|
-
}
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all) __defProp(target, name, {
|
|
11
|
-
get: all[name],
|
|
12
|
-
enumerable: !0
|
|
13
|
-
});
|
|
14
|
-
},
|
|
15
|
-
__copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
17
|
-
get: () => from[key],
|
|
18
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
-
});
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: !0
|
|
30
|
-
}) : target, mod)),
|
|
31
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: !0
|
|
33
|
-
}), mod);
|
|
34
|
-
var ToastViewport_exports = {};
|
|
35
|
-
__export(ToastViewport_exports, {
|
|
36
|
-
ToastViewport: () => ToastViewport,
|
|
37
|
-
VIEWPORT_DEFAULT_HOTKEY: () => VIEWPORT_DEFAULT_HOTKEY,
|
|
38
|
-
VIEWPORT_PAUSE: () => VIEWPORT_PAUSE,
|
|
39
|
-
VIEWPORT_RESUME: () => VIEWPORT_RESUME
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(ToastViewport_exports);
|
|
42
|
-
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
43
|
-
import_gui_animate_presence = require("@hanzogui/animate-presence"),
|
|
44
|
-
import_gui_compose_refs = require("@hanzogui/compose-refs"),
|
|
45
|
-
import_gui_constants = require("@hanzogui/constants"),
|
|
46
|
-
import_gui_core = require("@hanzogui/core"),
|
|
47
|
-
import_gui_portal = require("@hanzogui/portal"),
|
|
48
|
-
import_gui_stacks = require("@hanzogui/stacks"),
|
|
49
|
-
import_gui_visually_hidden = require("@hanzogui/visually-hidden"),
|
|
50
|
-
React = __toESM(require("react"), 1),
|
|
51
|
-
import_constants = require("./constants.native.js"),
|
|
52
|
-
import_ToastPortal = require("./ToastPortal.native.js"),
|
|
53
|
-
import_ToastProvider = require("./ToastProvider.native.js"),
|
|
54
|
-
VIEWPORT_NAME = "ToastViewport",
|
|
55
|
-
VIEWPORT_DEFAULT_HOTKEY = ["F8"],
|
|
56
|
-
VIEWPORT_PAUSE = "toast.viewportPause",
|
|
57
|
-
VIEWPORT_RESUME = "toast.viewportResume",
|
|
58
|
-
ToastViewportWrapperFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
|
|
59
|
-
name: "ViewportWrapper",
|
|
60
|
-
variants: {
|
|
61
|
-
unstyled: {
|
|
62
|
-
false: {
|
|
63
|
-
pointerEvents: "box-none",
|
|
64
|
-
top: 0,
|
|
65
|
-
bottom: 0,
|
|
66
|
-
left: 0,
|
|
67
|
-
right: 0,
|
|
68
|
-
position: "fixed",
|
|
69
|
-
maxWidth: "100%",
|
|
70
|
-
tabIndex: 0,
|
|
71
|
-
zIndex: 1e5
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
defaultVariants: {
|
|
76
|
-
unstyled: process.env.HANZO_GUI_HEADLESS === "1"
|
|
77
|
-
}
|
|
78
|
-
}),
|
|
79
|
-
ToastViewportFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
|
|
80
|
-
name: VIEWPORT_NAME,
|
|
81
|
-
variants: {
|
|
82
|
-
unstyled: {
|
|
83
|
-
false: {
|
|
84
|
-
pointerEvents: "box-none",
|
|
85
|
-
position: "fixed",
|
|
86
|
-
maxWidth: "100%"
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
defaultVariants: {
|
|
91
|
-
unstyled: process.env.HANZO_GUI_HEADLESS === "1"
|
|
92
|
-
}
|
|
93
|
-
}),
|
|
94
|
-
ToastViewport = /* @__PURE__ */React.memo(/* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
95
|
-
var {
|
|
96
|
-
scope,
|
|
97
|
-
hotkey = VIEWPORT_DEFAULT_HOTKEY,
|
|
98
|
-
label = "Notifications ({hotkey})",
|
|
99
|
-
name = "default",
|
|
100
|
-
multipleToasts,
|
|
101
|
-
zIndex,
|
|
102
|
-
portalToRoot,
|
|
103
|
-
...viewportProps
|
|
104
|
-
} = props,
|
|
105
|
-
context = (0, import_ToastProvider.useToastProviderContext)(scope),
|
|
106
|
-
getItems = (0, import_ToastProvider.useCollection)(scope || import_constants.TOAST_CONTEXT),
|
|
107
|
-
headFocusProxyRef = React.useRef(null),
|
|
108
|
-
tailFocusProxyRef = React.useRef(null),
|
|
109
|
-
wrapperRef = React.useRef(null),
|
|
110
|
-
ref = React.useRef(null),
|
|
111
|
-
onViewportChange = React.useCallback(function (el) {
|
|
112
|
-
context.viewports[name] !== el && context.onViewportChange(name, el);
|
|
113
|
-
}, [name, context.viewports]),
|
|
114
|
-
composedRefs = (0, import_gui_compose_refs.useComposedRefs)(forwardedRef, ref, onViewportChange),
|
|
115
|
-
hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, ""),
|
|
116
|
-
hasToasts = context.toastCount > 0;
|
|
117
|
-
React.useEffect(function () {
|
|
118
|
-
if (import_gui_constants.isWeb && context.toastCount !== 0) {
|
|
119
|
-
var handleKeyDown = function (event) {
|
|
120
|
-
var _ref_current,
|
|
121
|
-
isHotkeyPressed = hotkey.every(function (key) {
|
|
122
|
-
return event[key] || event.code === key;
|
|
123
|
-
});
|
|
124
|
-
isHotkeyPressed && ((_ref_current = ref.current) === null || _ref_current === void 0 || _ref_current.focus());
|
|
125
|
-
};
|
|
126
|
-
return document.addEventListener("keydown", handleKeyDown), function () {
|
|
127
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}, [hotkey, context.toastCount]), React.useEffect(function () {
|
|
131
|
-
if (import_gui_constants.isWeb && context.toastCount !== 0) {
|
|
132
|
-
var wrapper = wrapperRef.current,
|
|
133
|
-
viewport = ref.current;
|
|
134
|
-
if (hasToasts && wrapper && viewport) {
|
|
135
|
-
var handlePause = function () {
|
|
136
|
-
if (!context.isClosePausedRef.current) {
|
|
137
|
-
var pauseEvent = new CustomEvent(VIEWPORT_PAUSE);
|
|
138
|
-
viewport.dispatchEvent(pauseEvent), context.isClosePausedRef.current = !0;
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
handleResume = function () {
|
|
142
|
-
if (context.isClosePausedRef.current) {
|
|
143
|
-
var resumeEvent = new CustomEvent(VIEWPORT_RESUME);
|
|
144
|
-
viewport.dispatchEvent(resumeEvent), context.isClosePausedRef.current = !1;
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
handleFocusOutResume = function (event) {
|
|
148
|
-
var isFocusMovingOutside = !wrapper.contains(event.relatedTarget);
|
|
149
|
-
isFocusMovingOutside && handleResume();
|
|
150
|
-
},
|
|
151
|
-
handlePointerLeaveResume = function () {
|
|
152
|
-
var isFocusInside = wrapper.contains(document.activeElement);
|
|
153
|
-
isFocusInside || handleResume();
|
|
154
|
-
};
|
|
155
|
-
return wrapper.addEventListener("focusin", handlePause), wrapper.addEventListener("focusout", handleFocusOutResume), wrapper.addEventListener("pointermove", handlePause), wrapper.addEventListener("pointerleave", handlePointerLeaveResume), window.addEventListener("blur", handlePause), window.addEventListener("focus", handleResume), function () {
|
|
156
|
-
wrapper.removeEventListener("focusin", handlePause), wrapper.removeEventListener("focusout", handleFocusOutResume), wrapper.removeEventListener("pointermove", handlePause), wrapper.removeEventListener("pointerleave", handlePointerLeaveResume), window.removeEventListener("blur", handlePause), window.removeEventListener("focus", handleResume);
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}, [hasToasts, context.isClosePausedRef, context.toastCount]);
|
|
161
|
-
var getSortedTabbableCandidates = React.useCallback(function (param) {
|
|
162
|
-
var {
|
|
163
|
-
tabbingDirection
|
|
164
|
-
} = param,
|
|
165
|
-
toastItems = getItems(),
|
|
166
|
-
tabbableCandidates = toastItems.map(function (toastItem) {
|
|
167
|
-
var toastNode = toastItem.ref.current,
|
|
168
|
-
toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];
|
|
169
|
-
return tabbingDirection === "forwards" ? toastTabbableCandidates : toastTabbableCandidates.reverse();
|
|
170
|
-
});
|
|
171
|
-
return (tabbingDirection === "forwards" ? tabbableCandidates.reverse() : tabbableCandidates).flat();
|
|
172
|
-
}, [getItems]);
|
|
173
|
-
React.useEffect(function () {
|
|
174
|
-
if (import_gui_constants.isWeb && context.toastCount !== 0) {
|
|
175
|
-
var viewport = ref.current;
|
|
176
|
-
if (viewport) {
|
|
177
|
-
var handleKeyDown = function (event) {
|
|
178
|
-
var isMetaKey = event.altKey || event.ctrlKey || event.metaKey,
|
|
179
|
-
isTabKey = event.key === "Tab" && !isMetaKey;
|
|
180
|
-
if (isTabKey) {
|
|
181
|
-
var focusedElement = document.activeElement,
|
|
182
|
-
isTabbingBackwards = event.shiftKey,
|
|
183
|
-
targetIsViewport = event.target === viewport;
|
|
184
|
-
if (targetIsViewport && isTabbingBackwards) {
|
|
185
|
-
var _headFocusProxyRef_current;
|
|
186
|
-
(_headFocusProxyRef_current = headFocusProxyRef.current) === null || _headFocusProxyRef_current === void 0 || _headFocusProxyRef_current.focus();
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
var tabbingDirection = isTabbingBackwards ? "backwards" : "forwards",
|
|
190
|
-
sortedCandidates = getSortedTabbableCandidates({
|
|
191
|
-
tabbingDirection
|
|
192
|
-
}),
|
|
193
|
-
index = sortedCandidates.findIndex(function (candidate) {
|
|
194
|
-
return candidate === focusedElement;
|
|
195
|
-
});
|
|
196
|
-
if (focusFirst(sortedCandidates.slice(index + 1))) event.preventDefault();else {
|
|
197
|
-
var _headFocusProxyRef_current1, _tailFocusProxyRef_current;
|
|
198
|
-
isTabbingBackwards ? (_headFocusProxyRef_current1 = headFocusProxyRef.current) === null || _headFocusProxyRef_current1 === void 0 || _headFocusProxyRef_current1.focus() : (_tailFocusProxyRef_current = tailFocusProxyRef.current) === null || _tailFocusProxyRef_current === void 0 || _tailFocusProxyRef_current.focus();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
return viewport.addEventListener("keydown", handleKeyDown), function () {
|
|
203
|
-
return viewport.removeEventListener("keydown", handleKeyDown);
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}, [getItems, getSortedTabbableCandidates, context.toastCount]);
|
|
208
|
-
var contents = /* @__PURE__ */(0, import_jsx_runtime.jsxs)(ToastViewportWrapperFrame, {
|
|
209
|
-
ref: wrapperRef,
|
|
210
|
-
role: "region",
|
|
211
|
-
"aria-label": label.replace("{hotkey}", hotkeyLabel),
|
|
212
|
-
// // Ensure virtual cursor from landmarks menus triggers focus/blur for pause/resume
|
|
213
|
-
tabIndex: -1,
|
|
214
|
-
children: [
|
|
215
|
-
// // incase list has size when empty (e.g. padding), we remove pointer events so
|
|
216
|
-
// // it doesn't prevent interactions with page elements that it overlays
|
|
217
|
-
// pointerEvents={hasToasts ? undefined : 'none'}
|
|
218
|
-
hasToasts && /* @__PURE__ */(0, import_jsx_runtime.jsx)(FocusProxy, {
|
|
219
|
-
context,
|
|
220
|
-
viewportName: name,
|
|
221
|
-
ref: headFocusProxyRef,
|
|
222
|
-
onFocusFromOutsideViewport: function () {
|
|
223
|
-
var tabbableCandidates = getSortedTabbableCandidates({
|
|
224
|
-
tabbingDirection: "forwards"
|
|
225
|
-
});
|
|
226
|
-
focusFirst(tabbableCandidates);
|
|
227
|
-
}
|
|
228
|
-
}),
|
|
229
|
-
/**
|
|
230
|
-
* tabindex on the the list so that it can be focused when items are removed. we focus
|
|
231
|
-
* the list instead of the viewport so it announces number of items remaining.
|
|
232
|
-
*/
|
|
233
|
-
/* @__PURE__ */
|
|
234
|
-
(0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.Slot, {
|
|
235
|
-
scope: context.toastScope,
|
|
236
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastViewportFrame, {
|
|
237
|
-
focusable: context.toastCount > 0,
|
|
238
|
-
ref: composedRefs,
|
|
239
|
-
...viewportProps,
|
|
240
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_portal.PortalHost, {
|
|
241
|
-
render: function (children) {
|
|
242
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_animate_presence.AnimatePresence, {
|
|
243
|
-
exitBeforeEnter: !multipleToasts,
|
|
244
|
-
children
|
|
245
|
-
});
|
|
246
|
-
},
|
|
247
|
-
name: name ?? "default"
|
|
248
|
-
})
|
|
249
|
-
})
|
|
250
|
-
}), hasToasts && /* @__PURE__ */(0, import_jsx_runtime.jsx)(FocusProxy, {
|
|
251
|
-
context,
|
|
252
|
-
viewportName: name,
|
|
253
|
-
ref: tailFocusProxyRef,
|
|
254
|
-
onFocusFromOutsideViewport: function () {
|
|
255
|
-
var tabbableCandidates = getSortedTabbableCandidates({
|
|
256
|
-
tabbingDirection: "backwards"
|
|
257
|
-
});
|
|
258
|
-
focusFirst(tabbableCandidates);
|
|
259
|
-
}
|
|
260
|
-
})]
|
|
261
|
-
});
|
|
262
|
-
return portalToRoot ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastPortal.ToastPortal, {
|
|
263
|
-
context,
|
|
264
|
-
...(typeof zIndex == "number" ? {
|
|
265
|
-
zIndex
|
|
266
|
-
} : {}),
|
|
267
|
-
children: contents
|
|
268
|
-
}) : contents;
|
|
269
|
-
}));
|
|
270
|
-
ToastViewport.displayName = VIEWPORT_NAME;
|
|
271
|
-
var FOCUS_PROXY_NAME = "ToastFocusProxy",
|
|
272
|
-
FocusProxy = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
273
|
-
var {
|
|
274
|
-
onFocusFromOutsideViewport,
|
|
275
|
-
viewportName,
|
|
276
|
-
context,
|
|
277
|
-
...proxyProps
|
|
278
|
-
} = props,
|
|
279
|
-
viewport = context.viewports[viewportName];
|
|
280
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_visually_hidden.VisuallyHidden, {
|
|
281
|
-
"aria-hidden": !0,
|
|
282
|
-
tabIndex: 0,
|
|
283
|
-
...proxyProps,
|
|
284
|
-
ref: forwardedRef,
|
|
285
|
-
// Avoid page scrolling when focus is on the focus proxy
|
|
286
|
-
position: "fixed",
|
|
287
|
-
onFocus: function (event) {
|
|
288
|
-
if (import_gui_constants.isWeb) {
|
|
289
|
-
var prevFocusedElement = event.relatedTarget,
|
|
290
|
-
isFocusFromOutsideViewport = !viewport?.contains(prevFocusedElement);
|
|
291
|
-
isFocusFromOutsideViewport && onFocusFromOutsideViewport();
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
FocusProxy.displayName = FOCUS_PROXY_NAME;
|
|
297
|
-
function focusFirst(candidates) {
|
|
298
|
-
if (import_gui_constants.isWeb) {
|
|
299
|
-
var previouslyFocusedElement = document.activeElement;
|
|
300
|
-
return candidates.some(function (candidate) {
|
|
301
|
-
return candidate === previouslyFocusedElement ? !0 : (candidate.focus(), document.activeElement !== previouslyFocusedElement);
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function getTabbableCandidates(container) {
|
|
306
|
-
if (!import_gui_constants.isWeb) return [];
|
|
307
|
-
for (var containerHtml = container, nodes = [], walker = document.createTreeWalker(containerHtml, NodeFilter.SHOW_ELEMENT, {
|
|
308
|
-
acceptNode: function (node) {
|
|
309
|
-
var isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
310
|
-
return node.disabled || node.hidden || isHiddenInput ? NodeFilter.FILTER_SKIP : node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
311
|
-
}
|
|
312
|
-
}); walker.nextNode();) nodes.push(walker.currentNode);
|
|
313
|
-
return nodes;
|
|
314
|
-
}
|
|
315
|
-
//# sourceMappingURL=ToastViewport.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","ToastViewport_exports","__export","ToastViewport","VIEWPORT_DEFAULT_HOTKEY","VIEWPORT_PAUSE","VIEWPORT_RESUME","module","exports","import_jsx_runtime","require","import_gui_animate_presence","import_gui_compose_refs","import_gui_constants","import_gui_core","import_gui_portal","import_gui_stacks","import_gui_visually_hidden","React","__toESM","import_constants","import_ToastPortal","import_ToastProvider","VIEWPORT_NAME","ToastViewportWrapperFrame","styled","YStack","name","variants","unstyled","false","pointerEvents","top","bottom","left","right","position","maxWidth","tabIndex","zIndex","defaultVariants","process","env","HANZO_GUI_HEADLESS","ToastViewportFrame","memo","forwardRef","props","forwardedRef","scope","hotkey","label","multipleToasts","portalToRoot","viewportProps","context","useToastProviderContext","getItems","useCollection","TOAST_CONTEXT","headFocusProxyRef","useRef","tailFocusProxyRef","wrapperRef","ref","onViewportChange","useCallback","el","viewports","composedRefs","useComposedRefs","hotkeyLabel","join","replace","hasToasts","toastCount","useEffect","isWeb","handleKeyDown","event","_ref_current","isHotkeyPressed","every","key","code","current","focus","document","addEventListener","removeEventListener","wrapper","viewport","handlePause","isClosePausedRef","pauseEvent","CustomEvent","dispatchEvent","handleResume","resumeEvent","handleFocusOutResume","isFocusMovingOutside","contains","relatedTarget","handlePointerLeaveResume","isFocusInside","activeElement","window","getSortedTabbableCandidates","param","tabbingDirection","toastItems","tabbableCandidates","map","toastItem","toastNode","toastTabbableCandidates","getTabbableCandidates","reverse","flat","isMetaKey","altKey","ctrlKey","metaKey","isTabKey","focusedElement","isTabbingBackwards","shiftKey","targetIsViewport","target","_headFocusProxyRef_current","sortedCandidates","index","findIndex","candidate","focusFirst","slice","preventDefault","_headFocusProxyRef_current1","_tailFocusProxyRef_current","contents","jsxs","role","children","jsx","FocusProxy","viewportName","onFocusFromOutsideViewport","Collection","Slot","toastScope","focusable","PortalHost","render","AnimatePresence","exitBeforeEnter","ToastPortal","displayName","FOCUS_PROXY_NAME","proxyProps","VisuallyHidden","onFocus","prevFocusedElement","isFocusFromOutsideViewport","candidates","previouslyFocusedElement","some","container","containerHtml","nodes","walker","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","node"],"sources":["../../src/ToastViewport.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,uBAAA,EAAAA,CAAA,KAAAA,uBAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA,cAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAZ,YAAA,CAAAK,qBAAgC;AAchC,IAAAQ,kBAAsB,GAAAC,OAAA,oBAChB;EAAAC,2BACA,GAAAD,OAAiB,8BACjB;EAAAE,uBAAkB,GAAAF,OAElB;EAA4BG,oBAAA,GAAAH,OAAO,uBAAQ;EAAAI,eAAA,GAAAJ,OAAA;EAAAK,iBAAA,GAAAL,OAAA;EAAAM,iBAAA,GAAAN,OAAA;EAAAO,0BAAA,GAAAP,OAAA;EAAAQ,KAAA,GAAAC,OAAA,CAAAT,OAAA;EAAAU,gBAAA,GAAAV,OAAA;EAAAW,kBAAA,GAAAX,OAAA;EAAAY,oBAAA,GAAAZ,OAAA;EAAAa,aAAA;EAAAnB,uBAAA,IAC/C,KAAM;EAENC,cAAU;EAAAC,eAAA;EAAAkB,yBAAA,OAAAV,eAAA,CAAAW,MAAA,EAAAT,iBAAA,CAAAU,MAAA;IAAAC,IACR,mBAAU;IAAAC,QACR;MAAOC,QACL;QAAe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AApC,OAAA,CAAAa,SAAA,CAAA6E,YAAA;IAAA,OACJ,eAAK,IAAAxI,kBAAA,CAAAsI,GAAA,EAAA9H,0BAAA,CAAA8I,cAAA;MAAA,aAEL,EAAS;MAAAzH,QACT;MACE,GAAAwH,UAAK;MACL9F,GAAA,EAAAhB,YAAM;MAEN;MAA2DZ,QAC7D;MAAA4H,OAAA,WAAAA,CAAAjF,KAAA;QACF,IAAAlE,oBAAA,CAAAgE,KAAA;UAEJ,IAAAoF,kBAAA,GAAAlF,KAAA,CAAAuB,aAAA;YAAA4D,0BAAA,IAAAvE,QAAA,EAAAU,QAAA,CAAA4D,kBAAA;UACFC,0BAAA,IAAAhB,0BAAA;QAEA;MAIA;IACE;EACA;AACAF,UAAO,CAAAY,WAAW,GAAKC,gBAEjB;AAIR,SAAAvB,WAAA6B,UAAA;EAYA,IAAAtJ,oBAAS,CAAAgE,KAAsB;IAC7B,IAAKuF,wBAAA,GAAO7E,QAAQ,CAAAkB,aAAA;IACpB,OAAM0D,UAAA,CAAAE,IAAgB,WAChBhC,SAAwB,EACxB;MACJ,OAAAA,SAAa,KAAc+B,wBAAA,SAAA/B,SAAA,CAAA/C,KAAA,IAAAC,QAAA,CAAAkB,aAAA,KAAA2D,wBAAA;IACzB;EACA;AAIkE;AACpE,SACDhD,sBAAAkD,SAAA;EACD,KAAAzJ,oBAAuB,CAAAgE,KAAG,SAAW;EAGrC,SAAO0F,aAAA,GAAAD,SAAA,EAAAE,KAAA,OAAAC,MAAA,GAAAlF,QAAA,CAAAmF,gBAAA,CAAAH,aAAA,EAAAI,UAAA,CAAAC,YAAA;MACTC,UAAA,WAAAA,CAAAC,IAAA","ignoreList":[]}
|
package/dist/cjs/constants.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all) __defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: !0
|
|
9
|
-
});
|
|
10
|
-
},
|
|
11
|
-
__copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
-
get: () => from[key],
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value: !0
|
|
20
|
-
}), mod);
|
|
21
|
-
var constants_exports = {};
|
|
22
|
-
__export(constants_exports, {
|
|
23
|
-
TOAST_CONTEXT: () => TOAST_CONTEXT,
|
|
24
|
-
TOAST_NAME: () => TOAST_NAME
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(constants_exports);
|
|
27
|
-
const TOAST_NAME = "Toast",
|
|
28
|
-
TOAST_CONTEXT = "Toast";
|