@hanzogui/toast 2.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.
Files changed (151) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/Toast.cjs +170 -0
  3. package/dist/cjs/Toast.native.js +174 -0
  4. package/dist/cjs/Toast.native.js.map +1 -0
  5. package/dist/cjs/ToastAnnounce.cjs +97 -0
  6. package/dist/cjs/ToastAnnounce.native.js +105 -0
  7. package/dist/cjs/ToastAnnounce.native.js.map +1 -0
  8. package/dist/cjs/ToastImperative.cjs +100 -0
  9. package/dist/cjs/ToastImperative.native.js +122 -0
  10. package/dist/cjs/ToastImperative.native.js.map +1 -0
  11. package/dist/cjs/ToastImpl.cjs +292 -0
  12. package/dist/cjs/ToastImpl.native.js +326 -0
  13. package/dist/cjs/ToastImpl.native.js.map +1 -0
  14. package/dist/cjs/ToastPortal.cjs +44 -0
  15. package/dist/cjs/ToastPortal.native.js +47 -0
  16. package/dist/cjs/ToastPortal.native.js.map +1 -0
  17. package/dist/cjs/ToastProvider.cjs +146 -0
  18. package/dist/cjs/ToastProvider.native.js +159 -0
  19. package/dist/cjs/ToastProvider.native.js.map +1 -0
  20. package/dist/cjs/ToastViewport.cjs +278 -0
  21. package/dist/cjs/ToastViewport.native.js +315 -0
  22. package/dist/cjs/ToastViewport.native.js.map +1 -0
  23. package/dist/cjs/constants.cjs +28 -0
  24. package/dist/cjs/constants.native.js +31 -0
  25. package/dist/cjs/constants.native.js.map +1 -0
  26. package/dist/cjs/createNativeToast.cjs +51 -0
  27. package/dist/cjs/createNativeToast.native.js +48 -0
  28. package/dist/cjs/createNativeToast.native.js.map +1 -0
  29. package/dist/cjs/index.cjs +18 -0
  30. package/dist/cjs/index.native.js +21 -0
  31. package/dist/cjs/index.native.js.map +1 -0
  32. package/dist/cjs/types.cjs +16 -0
  33. package/dist/cjs/types.native.js +19 -0
  34. package/dist/cjs/types.native.js.map +1 -0
  35. package/dist/esm/Toast.mjs +131 -0
  36. package/dist/esm/Toast.mjs.map +1 -0
  37. package/dist/esm/Toast.native.js +132 -0
  38. package/dist/esm/Toast.native.js.map +1 -0
  39. package/dist/esm/ToastAnnounce.mjs +62 -0
  40. package/dist/esm/ToastAnnounce.mjs.map +1 -0
  41. package/dist/esm/ToastAnnounce.native.js +67 -0
  42. package/dist/esm/ToastAnnounce.native.js.map +1 -0
  43. package/dist/esm/ToastImperative.mjs +63 -0
  44. package/dist/esm/ToastImperative.mjs.map +1 -0
  45. package/dist/esm/ToastImperative.native.js +82 -0
  46. package/dist/esm/ToastImperative.native.js.map +1 -0
  47. package/dist/esm/ToastImpl.mjs +256 -0
  48. package/dist/esm/ToastImpl.mjs.map +1 -0
  49. package/dist/esm/ToastImpl.native.js +287 -0
  50. package/dist/esm/ToastImpl.native.js.map +1 -0
  51. package/dist/esm/ToastPortal.mjs +21 -0
  52. package/dist/esm/ToastPortal.mjs.map +1 -0
  53. package/dist/esm/ToastPortal.native.js +21 -0
  54. package/dist/esm/ToastPortal.native.js.map +1 -0
  55. package/dist/esm/ToastProvider.mjs +108 -0
  56. package/dist/esm/ToastProvider.mjs.map +1 -0
  57. package/dist/esm/ToastProvider.native.js +118 -0
  58. package/dist/esm/ToastProvider.native.js.map +1 -0
  59. package/dist/esm/ToastViewport.mjs +241 -0
  60. package/dist/esm/ToastViewport.mjs.map +1 -0
  61. package/dist/esm/ToastViewport.native.js +275 -0
  62. package/dist/esm/ToastViewport.native.js.map +1 -0
  63. package/dist/esm/constants.mjs +4 -0
  64. package/dist/esm/constants.mjs.map +1 -0
  65. package/dist/esm/constants.native.js +4 -0
  66. package/dist/esm/constants.native.js.map +1 -0
  67. package/dist/esm/createNativeToast.mjs +27 -0
  68. package/dist/esm/createNativeToast.mjs.map +1 -0
  69. package/dist/esm/createNativeToast.native.js +21 -0
  70. package/dist/esm/createNativeToast.native.js.map +1 -0
  71. package/dist/esm/index.js +2 -0
  72. package/dist/esm/index.js.map +1 -0
  73. package/dist/esm/index.mjs +2 -0
  74. package/dist/esm/index.mjs.map +1 -0
  75. package/dist/esm/index.native.js +2 -0
  76. package/dist/esm/index.native.js.map +1 -0
  77. package/dist/esm/types.mjs +2 -0
  78. package/dist/esm/types.mjs.map +1 -0
  79. package/dist/esm/types.native.js +2 -0
  80. package/dist/esm/types.native.js.map +1 -0
  81. package/dist/jsx/Toast.mjs +131 -0
  82. package/dist/jsx/Toast.mjs.map +1 -0
  83. package/dist/jsx/Toast.native.js +174 -0
  84. package/dist/jsx/Toast.native.js.map +1 -0
  85. package/dist/jsx/ToastAnnounce.mjs +62 -0
  86. package/dist/jsx/ToastAnnounce.mjs.map +1 -0
  87. package/dist/jsx/ToastAnnounce.native.js +105 -0
  88. package/dist/jsx/ToastAnnounce.native.js.map +1 -0
  89. package/dist/jsx/ToastImperative.mjs +63 -0
  90. package/dist/jsx/ToastImperative.mjs.map +1 -0
  91. package/dist/jsx/ToastImperative.native.js +122 -0
  92. package/dist/jsx/ToastImperative.native.js.map +1 -0
  93. package/dist/jsx/ToastImpl.mjs +256 -0
  94. package/dist/jsx/ToastImpl.mjs.map +1 -0
  95. package/dist/jsx/ToastImpl.native.js +326 -0
  96. package/dist/jsx/ToastImpl.native.js.map +1 -0
  97. package/dist/jsx/ToastPortal.mjs +21 -0
  98. package/dist/jsx/ToastPortal.mjs.map +1 -0
  99. package/dist/jsx/ToastPortal.native.js +47 -0
  100. package/dist/jsx/ToastPortal.native.js.map +1 -0
  101. package/dist/jsx/ToastProvider.mjs +108 -0
  102. package/dist/jsx/ToastProvider.mjs.map +1 -0
  103. package/dist/jsx/ToastProvider.native.js +159 -0
  104. package/dist/jsx/ToastProvider.native.js.map +1 -0
  105. package/dist/jsx/ToastViewport.mjs +241 -0
  106. package/dist/jsx/ToastViewport.mjs.map +1 -0
  107. package/dist/jsx/ToastViewport.native.js +315 -0
  108. package/dist/jsx/ToastViewport.native.js.map +1 -0
  109. package/dist/jsx/constants.mjs +4 -0
  110. package/dist/jsx/constants.mjs.map +1 -0
  111. package/dist/jsx/constants.native.js +31 -0
  112. package/dist/jsx/constants.native.js.map +1 -0
  113. package/dist/jsx/createNativeToast.mjs +27 -0
  114. package/dist/jsx/createNativeToast.mjs.map +1 -0
  115. package/dist/jsx/createNativeToast.native.js +48 -0
  116. package/dist/jsx/createNativeToast.native.js.map +1 -0
  117. package/dist/jsx/index.js +2 -0
  118. package/dist/jsx/index.js.map +1 -0
  119. package/dist/jsx/index.mjs +2 -0
  120. package/dist/jsx/index.mjs.map +1 -0
  121. package/dist/jsx/index.native.js +21 -0
  122. package/dist/jsx/index.native.js.map +1 -0
  123. package/dist/jsx/types.mjs +2 -0
  124. package/dist/jsx/types.mjs.map +1 -0
  125. package/dist/jsx/types.native.js +19 -0
  126. package/dist/jsx/types.native.js.map +1 -0
  127. package/package.json +66 -0
  128. package/src/Toast.tsx +219 -0
  129. package/src/ToastAnnounce.tsx +103 -0
  130. package/src/ToastImperative.tsx +192 -0
  131. package/src/ToastImpl.tsx +502 -0
  132. package/src/ToastPortal.tsx +19 -0
  133. package/src/ToastProvider.tsx +197 -0
  134. package/src/ToastViewport.tsx +429 -0
  135. package/src/constants.ts +2 -0
  136. package/src/createNativeToast.native.tsx +29 -0
  137. package/src/createNativeToast.tsx +48 -0
  138. package/src/index.ts +3 -0
  139. package/src/types.ts +71 -0
  140. package/types/Toast.d.ts +84 -0
  141. package/types/ToastAnnounce.d.ts +18 -0
  142. package/types/ToastImperative.d.ts +95 -0
  143. package/types/ToastImpl.d.ts +109 -0
  144. package/types/ToastPortal.d.ts +8 -0
  145. package/types/ToastProvider.d.ts +92 -0
  146. package/types/ToastViewport.d.ts +75 -0
  147. package/types/constants.d.ts +3 -0
  148. package/types/createNativeToast.d.ts +4 -0
  149. package/types/createNativeToast.native.d.ts +4 -0
  150. package/types/index.d.ts +4 -0
  151. package/types/types.d.ts +61 -0
@@ -0,0 +1,315 @@
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("@hanzo/gui-animate-presence"),
44
+ import_gui_compose_refs = require("@hanzo/gui-compose-refs"),
45
+ import_gui_constants = require("@hanzo/gui-constants"),
46
+ import_gui_core = require("@hanzo/gui-core"),
47
+ import_gui_portal = require("@hanzo/gui-portal"),
48
+ import_gui_stacks = require("@hanzo/gui-stacks"),
49
+ import_gui_visually_hidden = require("@hanzo/gui-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
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","ToastViewport_exports","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","import_constants","import_ToastPortal","import_ToastProvider","VIEWPORT_NAME","ToastViewportWrapperFrame","styled","YStack","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","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","_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"],"sources":["../../src/ToastViewport.tsx"],"sourcesContent":[null],"mappings":"AAAA,YAAS;;AACT,IAAAA,QAAS,GAAAC,MAAA,CAAAC,MAAA;AACT,IAAAC,SAAS,GAAAF,MAAa,CAAAG,cAAA;AAEtB,IAAAC,gBAAS,GAAcJ,MAAA,CAAAK,wBAAA;AACvB,IAAAC,iBAAS,GAAAN,MAAkB,CAAAO,mBAAA;AAC3B,IAAAC,YAAS,GAAA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ST_CONTEXT"],"sources":["../../src/constants.ts"],"sourcesContent":[null],"mappings":"AAAO,MAAMA,UAAA,GAAa;EACbC,aAAA,GAAgB","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __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 __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var constants_exports = {};
24
+ __export(constants_exports, {
25
+ TOAST_CONTEXT: () => TOAST_CONTEXT,
26
+ TOAST_NAME: () => TOAST_NAME
27
+ });
28
+ module.exports = __toCommonJS(constants_exports);
29
+ var TOAST_NAME = "Toast",
30
+ TOAST_CONTEXT = "Toast";
31
+ //# sourceMappingURL=constants.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/constants.ts"],"sourcesContent":[null],"mappings":"AAAO,YAAM","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ const createNativeToast = (title, {
2
+ message,
3
+ notificationOptions
4
+ }) => {
5
+ if (!("Notification" in window)) return console.error("This browser does not support notifications"), !1;
6
+ if (Notification.permission === "denied") return !1;
7
+ const showNotification = () => new Notification(title, {
8
+ body: message,
9
+ ...notificationOptions
10
+ });
11
+ return Notification.permission === "granted" ? {
12
+ nativeToastRef: showNotification()
13
+ } : (Notification.requestPermission().then(permission => {
14
+ if (permission === "granted") return {
15
+ nativeToastRef: showNotification()
16
+ };
17
+ }), !0);
18
+ },
19
+ hideNativeToast = ref => {
20
+ if (!("Notification" in window)) {
21
+ console.error("This browser does not support notifications");
22
+ return;
23
+ }
24
+ ref && ref.close();
25
+ };
26
+ export { createNativeToast, hideNativeToast };
27
+ //# sourceMappingURL=createNativeToast.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createNativeToast","title","message","notificationOptions","window","console","error","Notification","permission","showNotification","body","nativeToastRef","requestPermission","then","hideNativeToast","ref","close"],"sources":["../../src/createNativeToast.tsx"],"sourcesContent":[null],"mappings":"AAEO,MAAMA,iBAAA,GAA0CA,CACrDC,KAAA,EACA;IAAEC,OAAA;IAASC;EAAoB,MAC5B;IACH,IAAI,EAAE,kBAAkBC,MAAA,GACtB,OAAAC,OAAA,CAAQC,KAAA,CAAM,6CAA6C,GACpD;IAGT,IAAIC,YAAA,CAAaC,UAAA,KAAe,UAAU,OAAO;IACjD,MAAMC,gBAAA,GAAmBA,CAAA,KACF,IAAIF,YAAA,CAAaN,KAAA,EAAO;MAC3CS,IAAA,EAAMR,OAAA;MACN,GAAGC;IACL,CAAC;IAKH,OAAII,YAAA,CAAaC,UAAA,KAAe,YAEvB;MACLG,cAAA,EAFmBF,gBAAA,CAAiB;IAGtC,KAEFF,YAAA,CAAaK,iBAAA,CAAkB,EAAEC,IAAA,CAAML,UAAA,IAAe;MACpD,IAAIA,UAAA,KAAe,WAEjB,OAAO;QACLG,cAAA,EAFmBF,gBAAA,CAAiB;MAGtC;IAEJ,CAAC,GACM;EACT;EAEaK,eAAA,GAAuCC,GAAA,IAAQ;IAC1D,IAAI,EAAE,kBAAkBX,MAAA,GAAS;MAC/BC,OAAA,CAAQC,KAAA,CAAM,6CAA6C;MAC3D;IACF;IAEIS,GAAA,IACFA,GAAA,CAAIC,KAAA,CAAM;EAEd","ignoreList":[]}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __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 __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var createNativeToast_native_exports = {};
24
+ __export(createNativeToast_native_exports, {
25
+ createNativeToast: () => createNativeToast,
26
+ hideNativeToast: () => hideNativeToast
27
+ });
28
+ module.exports = __toCommonJS(createNativeToast_native_exports);
29
+ var import_gui_native = require("@hanzo/gui-native"),
30
+ createNativeToast = function (title, param) {
31
+ var {
32
+ message,
33
+ duration,
34
+ burntOptions
35
+ } = param,
36
+ burnt = (0, import_gui_native.getBurnt)();
37
+ return burnt.isEnabled ? (burnt.state.toast({
38
+ title,
39
+ message,
40
+ duration: duration ? duration / 1e3 : void 0,
41
+ ...burntOptions
42
+ }), !0) : (console.warn("Warning: Must call import '@hanzo/gui-native/setup-burnt' at your app entry point to use native toasts"), !1);
43
+ },
44
+ hideNativeToast = function () {
45
+ var burnt = (0, import_gui_native.getBurnt)();
46
+ burnt.isEnabled && burnt.state.dismissAllAlerts();
47
+ };
48
+ //# sourceMappingURL=createNativeToast.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createNativeToast_native_exports","__export","createNativeToast","hideNativeToast","module","exports","__toCommonJS","import_gui_native","require","title","param","message","duration","burntOptions","burnt","getBurnt","isEnabled","state","toast","console","warn","dismissAllAlerts"],"sources":["../../src/createNativeToast.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gCAAA;AAAAC,QAAA,CAAAD,gCAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAN,gCAAA;AAAA,IAAAO,iBAAA,GAAyBC,OAAA;EACdN,iBAAA,GAAoB,SAAAA,CAASO,KAAA,EAAOC,KAAA,EAAO;IAClD,IAAI;QAAEC,OAAA;QAASC,QAAA;QAAUC;MAAa,IAAIH,KAAA;MACtCI,KAAA,OAAQP,iBAAA,CAAAQ,QAAA,EAAS;IACrB,OAAKD,KAAA,CAAME,SAAA,IAIXF,KAAA,CAAMG,KAAA,CAAMC,KAAA,CAAM;MACdT,KAAA;MACAE,OAAA;MACAC,QAAA,EAAUA,QAAA,GAAWA,QAAA,GAAW,MAAO;MACvC,GAAGC;IACP,CAAC,GACM,OATHM,OAAA,CAAQC,IAAA,CAAK,wGAAwG,GAC9G;EASf;EACWjB,eAAA,GAAkB,SAAAA,CAAA,EAAW;IACpC,IAAIW,KAAA,OAAQP,iBAAA,CAAAQ,QAAA,EAAS;IAChBD,KAAA,CAAME,SAAA,IACXF,KAAA,CAAMG,KAAA,CAAMI,gBAAA,CAAiB;EACjC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./Toast.mjs";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./Toast.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
+ get: () => from[key],
10
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
+ });
12
+ return to;
13
+ },
14
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
+ value: !0
17
+ }), mod);
18
+ var index_exports = {};
19
+ module.exports = __toCommonJS(index_exports);
20
+ __reExport(index_exports, require("./Toast.native.js"), module.exports);
21
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
+ get: () => from[key],
10
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
+ });
12
+ return to;
13
+ };
14
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
15
+ value: !0
16
+ }), mod);
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
19
+ //# sourceMappingURL=types.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@hanzogui/toast",
3
+ "version": "2.0.0",
4
+ "source": "src/index.ts",
5
+ "files": [
6
+ "src",
7
+ "types",
8
+ "dist"
9
+ ],
10
+ "type": "module",
11
+ "sideEffects": [
12
+ "*.css"
13
+ ],
14
+ "main": "dist/cjs",
15
+ "module": "dist/esm",
16
+ "types": "./types/index.d.ts",
17
+ "exports": {
18
+ "./package.json": "./package.json",
19
+ ".": {
20
+ "types": "./types/index.d.ts",
21
+ "react-native": "./dist/esm/index.native.js",
22
+ "browser": "./dist/esm/index.mjs",
23
+ "module": "./dist/esm/index.mjs",
24
+ "import": "./dist/esm/index.mjs",
25
+ "require": "./dist/cjs/index.cjs",
26
+ "default": "./dist/esm/index.mjs"
27
+ }
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "build": "hanzo-gui-build",
34
+ "watch": "hanzo-gui-build --watch",
35
+ "clean": "hanzo-gui-build clean",
36
+ "clean:build": "hanzo-gui-build clean:build"
37
+ },
38
+ "dependencies": {
39
+ "@hanzogui/animate-presence": "2.0.0",
40
+ "@hanzogui/collection": "2.0.0",
41
+ "@hanzogui/compose-refs": "2.0.0-rc.29",
42
+ "@hanzogui/constants": "2.0.0-rc.29",
43
+ "@hanzogui/core": "2.0.0-rc.29",
44
+ "@hanzogui/create-context": "2.0.0-rc.29",
45
+ "@hanzogui/dismissable": "2.0.0",
46
+ "@hanzogui/helpers": "2.0.0-rc.29",
47
+ "@hanzogui/native": "2.0.0-rc.29",
48
+ "@hanzogui/polyfill-dev": "2.0.0-rc.29",
49
+ "@hanzogui/portal": "2.0.0",
50
+ "@hanzogui/stacks": "2.0.0",
51
+ "@hanzogui/start-transition": "2.0.0-rc.29",
52
+ "@hanzogui/text": "2.0.0",
53
+ "@hanzogui/use-controllable-state": "2.0.0-rc.29",
54
+ "@hanzogui/visually-hidden": "2.0.0"
55
+ },
56
+ "devDependencies": {
57
+ "@hanzogui/build": "2.0.0-rc.29",
58
+ "react": ">=19",
59
+ "react-native": "0.83.2"
60
+ },
61
+ "peerDependencies": {
62
+ "react": ">=19",
63
+ "react-native": "*"
64
+ },
65
+ "module:jsx": "dist/jsx"
66
+ }