@hanzogui/toast 3.0.2 → 7.3.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 (270) hide show
  1. package/dist/cjs/Toast.cjs +149 -141
  2. package/dist/cjs/Toast.native.js +149 -142
  3. package/dist/cjs/Toast.native.js.map +1 -1
  4. package/dist/cjs/ToastAnnounce.cjs +81 -75
  5. package/dist/cjs/ToastAnnounce.native.js +86 -80
  6. package/dist/cjs/ToastAnnounce.native.js.map +1 -1
  7. package/dist/cjs/ToastComposable.cjs +933 -0
  8. package/dist/cjs/ToastComposable.native.js +1025 -0
  9. package/dist/cjs/ToastComposable.native.js.map +1 -0
  10. package/dist/cjs/ToastImperative.cjs +99 -80
  11. package/dist/cjs/ToastImperative.native.js +104 -96
  12. package/dist/cjs/ToastImperative.native.js.map +1 -1
  13. package/dist/cjs/ToastImpl.cjs +303 -241
  14. package/dist/cjs/ToastImpl.native.js +311 -273
  15. package/dist/cjs/ToastImpl.native.js.map +1 -1
  16. package/dist/cjs/ToastItemFrame.cjs +143 -0
  17. package/dist/cjs/ToastItemFrame.native.js +148 -0
  18. package/dist/cjs/ToastItemFrame.native.js.map +1 -0
  19. package/dist/cjs/ToastPortal.cjs +23 -18
  20. package/dist/cjs/ToastPortal.native.js +27 -22
  21. package/dist/cjs/ToastPortal.native.js.map +1 -1
  22. package/dist/cjs/ToastProvider.cjs +103 -99
  23. package/dist/cjs/ToastProvider.native.js +108 -106
  24. package/dist/cjs/ToastProvider.native.js.map +1 -1
  25. package/dist/cjs/ToastState.cjs +311 -0
  26. package/dist/cjs/ToastState.native.js +324 -0
  27. package/dist/cjs/ToastState.native.js.map +1 -0
  28. package/dist/cjs/ToastViewport.cjs +276 -235
  29. package/dist/cjs/ToastViewport.native.js +302 -274
  30. package/dist/cjs/ToastViewport.native.js.map +1 -1
  31. package/dist/cjs/Toaster.cjs +87 -0
  32. package/dist/cjs/Toaster.native.js +91 -0
  33. package/dist/cjs/Toaster.native.js.map +1 -0
  34. package/dist/cjs/constants.cjs +14 -12
  35. package/dist/cjs/constants.native.js +14 -12
  36. package/dist/cjs/constants.native.js.map +1 -1
  37. package/dist/cjs/createNativeToast.cjs +43 -35
  38. package/dist/cjs/createNativeToast.native.js +42 -30
  39. package/dist/cjs/createNativeToast.native.js.map +1 -1
  40. package/dist/cjs/dispatchNativeToast.cjs +47 -0
  41. package/dist/cjs/dispatchNativeToast.native.js +52 -0
  42. package/dist/cjs/dispatchNativeToast.native.js.map +1 -0
  43. package/dist/cjs/index.cjs +7 -5
  44. package/dist/cjs/index.native.js +7 -5
  45. package/dist/cjs/index.native.js.map +1 -1
  46. package/dist/cjs/types.cjs +7 -5
  47. package/dist/cjs/types.native.js +7 -5
  48. package/dist/cjs/types.native.js.map +1 -1
  49. package/dist/cjs/useAnimatedDragGesture.cjs +214 -0
  50. package/dist/cjs/useAnimatedDragGesture.native.js +224 -0
  51. package/dist/cjs/useAnimatedDragGesture.native.js.map +1 -0
  52. package/dist/cjs/useReducedMotion.cjs +74 -0
  53. package/dist/cjs/useReducedMotion.native.js +83 -0
  54. package/dist/cjs/useReducedMotion.native.js.map +1 -0
  55. package/dist/cjs/useToastAnimations.cjs +294 -0
  56. package/dist/cjs/useToastAnimations.native.js +304 -0
  57. package/dist/cjs/useToastAnimations.native.js.map +1 -0
  58. package/dist/cjs/v2.cjs +36 -0
  59. package/dist/cjs/v2.native.js +39 -0
  60. package/dist/cjs/v2.native.js.map +1 -0
  61. package/dist/esm/Toast.mjs +112 -106
  62. package/dist/esm/Toast.mjs.map +1 -1
  63. package/dist/esm/Toast.native.js +112 -107
  64. package/dist/esm/Toast.native.js.map +1 -1
  65. package/dist/esm/ToastAnnounce.mjs +46 -42
  66. package/dist/esm/ToastAnnounce.mjs.map +1 -1
  67. package/dist/esm/ToastAnnounce.native.js +52 -48
  68. package/dist/esm/ToastAnnounce.native.js.map +1 -1
  69. package/dist/esm/ToastComposable.mjs +895 -0
  70. package/dist/esm/ToastComposable.mjs.map +1 -0
  71. package/dist/esm/ToastComposable.native.js +984 -0
  72. package/dist/esm/ToastComposable.native.js.map +1 -0
  73. package/dist/esm/ToastImperative.mjs +71 -54
  74. package/dist/esm/ToastImperative.mjs.map +1 -1
  75. package/dist/esm/ToastImperative.native.js +76 -70
  76. package/dist/esm/ToastImperative.native.js.map +1 -1
  77. package/dist/esm/ToastImpl.mjs +261 -201
  78. package/dist/esm/ToastImpl.mjs.map +1 -1
  79. package/dist/esm/ToastImpl.native.js +270 -234
  80. package/dist/esm/ToastImpl.native.js.map +1 -1
  81. package/dist/esm/ToastItemFrame.mjs +114 -0
  82. package/dist/esm/ToastItemFrame.mjs.map +1 -0
  83. package/dist/esm/ToastItemFrame.native.js +116 -0
  84. package/dist/esm/ToastItemFrame.native.js.map +1 -0
  85. package/dist/esm/ToastPortal.mjs +8 -5
  86. package/dist/esm/ToastPortal.mjs.map +1 -1
  87. package/dist/esm/ToastPortal.native.js +12 -9
  88. package/dist/esm/ToastPortal.native.js.map +1 -1
  89. package/dist/esm/ToastProvider.mjs +71 -69
  90. package/dist/esm/ToastProvider.mjs.map +1 -1
  91. package/dist/esm/ToastProvider.native.js +77 -77
  92. package/dist/esm/ToastProvider.native.js.map +1 -1
  93. package/dist/esm/ToastState.mjs +285 -0
  94. package/dist/esm/ToastState.mjs.map +1 -0
  95. package/dist/esm/ToastState.native.js +295 -0
  96. package/dist/esm/ToastState.native.js.map +1 -0
  97. package/dist/esm/ToastViewport.mjs +238 -199
  98. package/dist/esm/ToastViewport.mjs.map +1 -1
  99. package/dist/esm/ToastViewport.native.js +265 -239
  100. package/dist/esm/ToastViewport.native.js.map +1 -1
  101. package/dist/esm/Toaster.mjs +51 -0
  102. package/dist/esm/Toaster.mjs.map +1 -0
  103. package/dist/esm/Toaster.native.js +52 -0
  104. package/dist/esm/Toaster.native.js.map +1 -0
  105. package/dist/esm/constants.mjs +2 -2
  106. package/dist/esm/constants.mjs.map +1 -1
  107. package/dist/esm/constants.native.js +2 -2
  108. package/dist/esm/constants.native.js.map +1 -1
  109. package/dist/esm/createNativeToast.mjs +29 -24
  110. package/dist/esm/createNativeToast.mjs.map +1 -1
  111. package/dist/esm/createNativeToast.native.js +27 -18
  112. package/dist/esm/createNativeToast.native.js.map +1 -1
  113. package/dist/esm/dispatchNativeToast.mjs +22 -0
  114. package/dist/esm/dispatchNativeToast.mjs.map +1 -0
  115. package/dist/esm/dispatchNativeToast.native.js +24 -0
  116. package/dist/esm/dispatchNativeToast.native.js.map +1 -0
  117. package/dist/esm/useAnimatedDragGesture.mjs +178 -0
  118. package/dist/esm/useAnimatedDragGesture.mjs.map +1 -0
  119. package/dist/esm/useAnimatedDragGesture.native.js +185 -0
  120. package/dist/esm/useAnimatedDragGesture.native.js.map +1 -0
  121. package/dist/esm/useReducedMotion.mjs +38 -0
  122. package/dist/esm/useReducedMotion.mjs.map +1 -0
  123. package/dist/esm/useReducedMotion.native.js +44 -0
  124. package/dist/esm/useReducedMotion.native.js.map +1 -0
  125. package/dist/esm/useToastAnimations.mjs +258 -0
  126. package/dist/esm/useToastAnimations.mjs.map +1 -0
  127. package/dist/esm/useToastAnimations.native.js +265 -0
  128. package/dist/esm/useToastAnimations.native.js.map +1 -0
  129. package/dist/esm/v2.mjs +6 -0
  130. package/dist/esm/v2.mjs.map +1 -0
  131. package/dist/esm/v2.native.js +6 -0
  132. package/dist/esm/v2.native.js.map +1 -0
  133. package/dist/jsx/Toast.mjs +112 -106
  134. package/dist/jsx/Toast.mjs.map +1 -1
  135. package/dist/jsx/Toast.native.js +149 -142
  136. package/dist/jsx/Toast.native.js.map +1 -1
  137. package/dist/jsx/ToastAnnounce.mjs +46 -42
  138. package/dist/jsx/ToastAnnounce.mjs.map +1 -1
  139. package/dist/jsx/ToastAnnounce.native.js +86 -80
  140. package/dist/jsx/ToastAnnounce.native.js.map +1 -1
  141. package/dist/jsx/ToastComposable.mjs +895 -0
  142. package/dist/jsx/ToastComposable.mjs.map +1 -0
  143. package/dist/jsx/ToastComposable.native.js +1025 -0
  144. package/dist/jsx/ToastComposable.native.js.map +1 -0
  145. package/dist/jsx/ToastImperative.mjs +71 -54
  146. package/dist/jsx/ToastImperative.mjs.map +1 -1
  147. package/dist/jsx/ToastImperative.native.js +104 -96
  148. package/dist/jsx/ToastImperative.native.js.map +1 -1
  149. package/dist/jsx/ToastImpl.mjs +261 -201
  150. package/dist/jsx/ToastImpl.mjs.map +1 -1
  151. package/dist/jsx/ToastImpl.native.js +311 -273
  152. package/dist/jsx/ToastImpl.native.js.map +1 -1
  153. package/dist/jsx/ToastItemFrame.mjs +114 -0
  154. package/dist/jsx/ToastItemFrame.mjs.map +1 -0
  155. package/dist/jsx/ToastItemFrame.native.js +148 -0
  156. package/dist/jsx/ToastItemFrame.native.js.map +1 -0
  157. package/dist/jsx/ToastPortal.mjs +8 -5
  158. package/dist/jsx/ToastPortal.mjs.map +1 -1
  159. package/dist/jsx/ToastPortal.native.js +27 -22
  160. package/dist/jsx/ToastPortal.native.js.map +1 -1
  161. package/dist/jsx/ToastProvider.mjs +71 -69
  162. package/dist/jsx/ToastProvider.mjs.map +1 -1
  163. package/dist/jsx/ToastProvider.native.js +108 -106
  164. package/dist/jsx/ToastProvider.native.js.map +1 -1
  165. package/dist/jsx/ToastState.mjs +285 -0
  166. package/dist/jsx/ToastState.mjs.map +1 -0
  167. package/dist/jsx/ToastState.native.js +324 -0
  168. package/dist/jsx/ToastState.native.js.map +1 -0
  169. package/dist/jsx/ToastViewport.mjs +238 -199
  170. package/dist/jsx/ToastViewport.mjs.map +1 -1
  171. package/dist/jsx/ToastViewport.native.js +302 -274
  172. package/dist/jsx/ToastViewport.native.js.map +1 -1
  173. package/dist/jsx/Toaster.mjs +51 -0
  174. package/dist/jsx/Toaster.mjs.map +1 -0
  175. package/dist/jsx/Toaster.native.js +91 -0
  176. package/dist/jsx/Toaster.native.js.map +1 -0
  177. package/dist/jsx/constants.mjs +2 -2
  178. package/dist/jsx/constants.mjs.map +1 -1
  179. package/dist/jsx/constants.native.js +14 -12
  180. package/dist/jsx/constants.native.js.map +1 -1
  181. package/dist/jsx/createNativeToast.mjs +29 -24
  182. package/dist/jsx/createNativeToast.mjs.map +1 -1
  183. package/dist/jsx/createNativeToast.native.js +42 -30
  184. package/dist/jsx/createNativeToast.native.js.map +1 -1
  185. package/dist/jsx/dispatchNativeToast.mjs +22 -0
  186. package/dist/jsx/dispatchNativeToast.mjs.map +1 -0
  187. package/dist/jsx/dispatchNativeToast.native.js +52 -0
  188. package/dist/jsx/dispatchNativeToast.native.js.map +1 -0
  189. package/dist/jsx/index.native.js +7 -5
  190. package/dist/jsx/types.native.js +7 -5
  191. package/dist/jsx/useAnimatedDragGesture.mjs +178 -0
  192. package/dist/jsx/useAnimatedDragGesture.mjs.map +1 -0
  193. package/dist/jsx/useAnimatedDragGesture.native.js +224 -0
  194. package/dist/jsx/useAnimatedDragGesture.native.js.map +1 -0
  195. package/dist/jsx/useReducedMotion.mjs +38 -0
  196. package/dist/jsx/useReducedMotion.mjs.map +1 -0
  197. package/dist/jsx/useReducedMotion.native.js +83 -0
  198. package/dist/jsx/useReducedMotion.native.js.map +1 -0
  199. package/dist/jsx/useToastAnimations.mjs +258 -0
  200. package/dist/jsx/useToastAnimations.mjs.map +1 -0
  201. package/dist/jsx/useToastAnimations.native.js +304 -0
  202. package/dist/jsx/useToastAnimations.native.js.map +1 -0
  203. package/dist/jsx/v2.mjs +6 -0
  204. package/dist/jsx/v2.mjs.map +1 -0
  205. package/dist/jsx/v2.native.js +39 -0
  206. package/dist/jsx/v2.native.js.map +1 -0
  207. package/package.json +43 -24
  208. package/src/Toast.tsx +2 -2
  209. package/src/ToastComposable.tsx +1380 -0
  210. package/src/ToastImpl.tsx +15 -3
  211. package/src/ToastItemFrame.tsx +136 -0
  212. package/src/ToastPortal.tsx +2 -2
  213. package/src/ToastProvider.tsx +8 -1
  214. package/src/ToastState.ts +398 -0
  215. package/src/ToastViewport.tsx +6 -5
  216. package/src/Toaster.tsx +181 -0
  217. package/src/createNativeToast.native.tsx +4 -0
  218. package/src/createNativeToast.tsx +18 -24
  219. package/src/dispatchNativeToast.ts +43 -0
  220. package/src/useAnimatedDragGesture.native.ts +255 -0
  221. package/src/useAnimatedDragGesture.ts +319 -0
  222. package/src/useReducedMotion.ts +59 -0
  223. package/src/useToastAnimations.ts +377 -0
  224. package/src/v2.ts +31 -0
  225. package/types/Toast.d.ts +34 -34
  226. package/types/Toast.d.ts.map +1 -0
  227. package/types/ToastAnnounce.d.ts +4 -4
  228. package/types/ToastAnnounce.d.ts.map +1 -0
  229. package/types/ToastComposable.d.ts +199 -0
  230. package/types/ToastComposable.d.ts.map +1 -0
  231. package/types/ToastImperative.d.ts +3 -3
  232. package/types/ToastImperative.d.ts.map +1 -0
  233. package/types/ToastImpl.d.ts +11 -11
  234. package/types/ToastImpl.d.ts.map +1 -0
  235. package/types/ToastItemFrame.d.ts +25 -0
  236. package/types/ToastItemFrame.d.ts.map +1 -0
  237. package/types/ToastPortal.d.ts +1 -1
  238. package/types/ToastPortal.d.ts.map +1 -0
  239. package/types/ToastProvider.d.ts +4 -4
  240. package/types/ToastProvider.d.ts.map +1 -0
  241. package/types/ToastState.d.ts +179 -0
  242. package/types/ToastState.d.ts.map +1 -0
  243. package/types/ToastViewport.d.ts +10 -10
  244. package/types/ToastViewport.d.ts.map +1 -0
  245. package/types/Toaster.d.ts +112 -0
  246. package/types/Toaster.d.ts.map +1 -0
  247. package/types/constants.d.ts.map +1 -0
  248. package/types/createNativeToast.d.ts +5 -0
  249. package/types/createNativeToast.d.ts.map +1 -0
  250. package/types/createNativeToast.native.d.ts +1 -0
  251. package/types/createNativeToast.native.d.ts.map +1 -0
  252. package/types/dispatchNativeToast.d.ts +12 -0
  253. package/types/dispatchNativeToast.d.ts.map +1 -0
  254. package/types/index.d.ts.map +1 -0
  255. package/types/types.d.ts.map +1 -0
  256. package/types/useAnimatedDragGesture.d.ts +33 -0
  257. package/types/useAnimatedDragGesture.d.ts.map +1 -0
  258. package/types/useAnimatedDragGesture.native.d.ts +33 -0
  259. package/types/useAnimatedDragGesture.native.d.ts.map +1 -0
  260. package/types/useReducedMotion.d.ts +6 -0
  261. package/types/useReducedMotion.d.ts.map +1 -0
  262. package/types/useToastAnimations.d.ts +50 -0
  263. package/types/useToastAnimations.d.ts.map +1 -0
  264. package/types/v2.d.ts +10 -0
  265. package/types/v2.d.ts.map +1 -0
  266. package/v2/index.cjs +2 -0
  267. package/v2/index.js +2 -0
  268. package/v2/index.native.cjs +2 -0
  269. package/v2/index.native.js +2 -0
  270. package/LICENSE +0 -21
@@ -4,33 +4,35 @@ var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf,
8
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
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, {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
18
  get: () => from[key],
18
19
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
20
  });
20
- return to;
21
- };
21
+ }
22
+ return to;
23
+ };
22
24
  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);
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
+ value: mod,
31
+ enumerable: true
32
+ }) : target, mod));
33
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
+ value: true
35
+ }), mod);
34
36
  var ToastViewport_exports = {};
35
37
  __export(ToastViewport_exports, {
36
38
  ToastViewport: () => ToastViewport,
@@ -39,277 +41,303 @@ __export(ToastViewport_exports, {
39
41
  VIEWPORT_RESUME: () => VIEWPORT_RESUME
40
42
  });
41
43
  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
- }
44
+ var import_jsx_runtime = require("react/jsx-runtime");
45
+ var import_animate_presence = require("@hanzogui/animate-presence");
46
+ var import_compose_refs = require("@hanzogui/compose-refs");
47
+ var import_constants = require("@hanzogui/constants");
48
+ var import_core = require("@hanzogui/core");
49
+ var import_portal = require("@hanzogui/portal");
50
+ var import_stacks = require("@hanzogui/stacks");
51
+ var import_visually_hidden = require("@hanzogui/visually-hidden");
52
+ var React = __toESM(require("react"), 1);
53
+ var import_constants2 = require("./constants.native.js");
54
+ var import_ToastPortal = require("./ToastPortal.native.js");
55
+ var import_ToastProvider = require("./ToastProvider.native.js");
56
+ var VIEWPORT_NAME = "ToastViewport";
57
+ var VIEWPORT_DEFAULT_HOTKEY = ["F8"];
58
+ var VIEWPORT_PAUSE = "toast.viewportPause";
59
+ var VIEWPORT_RESUME = "toast.viewportResume";
60
+ var ToastViewportWrapperFrame = (0, import_core.styled)(import_stacks.YStack, {
61
+ name: "ViewportWrapper",
62
+ variants: {
63
+ unstyled: {
64
+ false: {
65
+ pointerEvents: "box-none",
66
+ top: 0,
67
+ bottom: 0,
68
+ left: 0,
69
+ right: 0,
70
+ position: import_constants.isWeb ? "fixed" : "absolute",
71
+ maxWidth: "100%",
72
+ tabIndex: 0,
73
+ zIndex: 1e5
73
74
  }
74
- },
75
- defaultVariants: {
76
- unstyled: process.env.HANZO_GUI_HEADLESS === "1"
77
75
  }
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
- }
76
+ },
77
+ defaultVariants: {
78
+ unstyled: process.env.GUI_HEADLESS === "1"
79
+ }
80
+ });
81
+ var ToastViewportFrame = (0, import_core.styled)(import_stacks.YStack, {
82
+ name: VIEWPORT_NAME,
83
+ variants: {
84
+ unstyled: {
85
+ false: {
86
+ pointerEvents: "box-none",
87
+ position: import_constants.isWeb ? "fixed" : "absolute",
88
+ maxWidth: "100%"
88
89
  }
89
- },
90
- defaultVariants: {
91
- unstyled: process.env.HANZO_GUI_HEADLESS === "1"
92
90
  }
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
- };
91
+ },
92
+ defaultVariants: {
93
+ unstyled: process.env.GUI_HEADLESS === "1"
94
+ }
95
+ });
96
+ var ToastViewport = /* @__PURE__ */React.memo(/* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
97
+ var {
98
+ scope,
99
+ hotkey = VIEWPORT_DEFAULT_HOTKEY,
100
+ label = "Notifications ({hotkey})",
101
+ name = "default",
102
+ multipleToasts,
103
+ zIndex,
104
+ portalToRoot,
105
+ ...viewportProps
106
+ } = props;
107
+ var context = (0, import_ToastProvider.useToastProviderContext)(scope);
108
+ var getItems = (0, import_ToastProvider.useCollection)(scope || import_constants2.TOAST_CONTEXT);
109
+ var headFocusProxyRef = React.useRef(null);
110
+ var tailFocusProxyRef = React.useRef(null);
111
+ var wrapperRef = React.useRef(null);
112
+ var ref = React.useRef(null);
113
+ var onViewportChange = React.useCallback(function (el) {
114
+ if (context.viewports[name] !== el) context.onViewportChange(name, el);
115
+ }, [name, context.viewports]);
116
+ var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, onViewportChange);
117
+ var hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
118
+ var hasToasts = context.toastCount > 0;
119
+ React.useEffect(function () {
120
+ if (!import_constants.isWeb) return;
121
+ if (context.toastCount === 0) return;
122
+ var handleKeyDown = function (event) {
123
+ var _ref_current;
124
+ var isHotkeyPressed = hotkey.every(function (key) {
125
+ return event[key] || event.code === key;
126
+ });
127
+ if (isHotkeyPressed) (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
128
+ };
129
+ document.addEventListener("keydown", handleKeyDown);
130
+ return function () {
131
+ document.removeEventListener("keydown", handleKeyDown);
132
+ };
133
+ }, [hotkey, context.toastCount]);
134
+ React.useEffect(function () {
135
+ if (!import_constants.isWeb) return;
136
+ if (context.toastCount === 0) return;
137
+ var wrapper = wrapperRef.current;
138
+ var viewport = ref.current;
139
+ if (hasToasts && wrapper && viewport) {
140
+ var handlePause = function () {
141
+ if (!context.isClosePausedRef.current) {
142
+ var pauseEvent = new CustomEvent(VIEWPORT_PAUSE);
143
+ viewport.dispatchEvent(pauseEvent);
144
+ context.isClosePausedRef.current = true;
158
145
  }
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
- };
146
+ };
147
+ var handleResume = function () {
148
+ if (context.isClosePausedRef.current) {
149
+ var resumeEvent = new CustomEvent(VIEWPORT_RESUME);
150
+ viewport.dispatchEvent(resumeEvent);
151
+ context.isClosePausedRef.current = false;
205
152
  }
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"
153
+ };
154
+ var handleFocusOutResume = function (event) {
155
+ var isFocusMovingOutside = !wrapper.contains(event.relatedTarget);
156
+ if (isFocusMovingOutside) handleResume();
157
+ };
158
+ var handlePointerLeaveResume = function () {
159
+ var isFocusInside = wrapper.contains(document.activeElement);
160
+ if (!isFocusInside) handleResume();
161
+ };
162
+ wrapper.addEventListener("focusin", handlePause);
163
+ wrapper.addEventListener("focusout", handleFocusOutResume);
164
+ wrapper.addEventListener("pointermove", handlePause);
165
+ wrapper.addEventListener("pointerleave", handlePointerLeaveResume);
166
+ window.addEventListener("blur", handlePause);
167
+ window.addEventListener("focus", handleResume);
168
+ return function () {
169
+ wrapper.removeEventListener("focusin", handlePause);
170
+ wrapper.removeEventListener("focusout", handleFocusOutResume);
171
+ wrapper.removeEventListener("pointermove", handlePause);
172
+ wrapper.removeEventListener("pointerleave", handlePointerLeaveResume);
173
+ window.removeEventListener("blur", handlePause);
174
+ window.removeEventListener("focus", handleResume);
175
+ };
176
+ }
177
+ }, [hasToasts, context.isClosePausedRef, context.toastCount]);
178
+ var getSortedTabbableCandidates = React.useCallback(function (param) {
179
+ var {
180
+ tabbingDirection
181
+ } = param;
182
+ var toastItems = getItems();
183
+ var tabbableCandidates = toastItems.map(function (toastItem) {
184
+ var toastNode = toastItem.ref.current;
185
+ var toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];
186
+ return tabbingDirection === "forwards" ? toastTabbableCandidates : toastTabbableCandidates.reverse();
187
+ });
188
+ return (tabbingDirection === "forwards" ? tabbableCandidates.reverse() : tabbableCandidates).flat();
189
+ }, [getItems]);
190
+ React.useEffect(function () {
191
+ if (!import_constants.isWeb) return;
192
+ if (context.toastCount === 0) return;
193
+ var viewport = ref.current;
194
+ if (viewport) {
195
+ var handleKeyDown = function (event) {
196
+ var isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
197
+ var isTabKey = event.key === "Tab" && !isMetaKey;
198
+ if (isTabKey) {
199
+ var focusedElement = document.activeElement;
200
+ var isTabbingBackwards = event.shiftKey;
201
+ var targetIsViewport = event.target === viewport;
202
+ if (targetIsViewport && isTabbingBackwards) {
203
+ var _headFocusProxyRef_current;
204
+ (_headFocusProxyRef_current = headFocusProxyRef.current) === null || _headFocusProxyRef_current === void 0 ? void 0 : _headFocusProxyRef_current.focus();
205
+ return;
206
+ }
207
+ var tabbingDirection = isTabbingBackwards ? "backwards" : "forwards";
208
+ var sortedCandidates = getSortedTabbableCandidates({
209
+ tabbingDirection
225
210
  });
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"
211
+ var index = sortedCandidates.findIndex(function (candidate) {
212
+ return candidate === focusedElement;
257
213
  });
258
- focusFirst(tabbableCandidates);
214
+ if (focusFirst(sortedCandidates.slice(index + 1))) {
215
+ event.preventDefault();
216
+ } else {
217
+ var _headFocusProxyRef_current1, _tailFocusProxyRef_current;
218
+ isTabbingBackwards ? (_headFocusProxyRef_current1 = headFocusProxyRef.current) === null || _headFocusProxyRef_current1 === void 0 ? void 0 : _headFocusProxyRef_current1.focus() : (_tailFocusProxyRef_current = tailFocusProxyRef.current) === null || _tailFocusProxyRef_current === void 0 ? void 0 : _tailFocusProxyRef_current.focus();
219
+ }
259
220
  }
260
- })]
261
- });
262
- return portalToRoot ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastPortal.ToastPortal, {
221
+ };
222
+ viewport.addEventListener("keydown", handleKeyDown);
223
+ return function () {
224
+ return viewport.removeEventListener("keydown", handleKeyDown);
225
+ };
226
+ }
227
+ }, [getItems, getSortedTabbableCandidates, context.toastCount]);
228
+ var contents = /* @__PURE__ */(0, import_jsx_runtime.jsxs)(ToastViewportWrapperFrame, {
229
+ ref: wrapperRef,
230
+ // biome-ignore lint/a11y/useSemanticElements: <explanation>
231
+ role: "region",
232
+ "aria-label": label.replace("{hotkey}", hotkeyLabel),
233
+ // // Ensure virtual cursor from landmarks menus triggers focus/blur for pause/resume
234
+ tabIndex: -1,
235
+ children: [
236
+ // // incase list has size when empty (e.g. padding), we remove pointer events so
237
+ // // it doesn't prevent interactions with page elements that it overlays
238
+ // pointerEvents={hasToasts ? undefined : 'none'}
239
+ hasToasts && /* @__PURE__ */(0, import_jsx_runtime.jsx)(FocusProxy, {
240
+ context,
241
+ viewportName: name,
242
+ ref: headFocusProxyRef,
243
+ onFocusFromOutsideViewport: function () {
244
+ var tabbableCandidates = getSortedTabbableCandidates({
245
+ tabbingDirection: "forwards"
246
+ });
247
+ focusFirst(tabbableCandidates);
248
+ }
249
+ }),
250
+ /**
251
+ * tabindex on the the list so that it can be focused when items are removed. we focus
252
+ * the list instead of the viewport so it announces number of items remaining.
253
+ */
254
+ /* @__PURE__ */
255
+ (0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.Slot, {
256
+ scope: context.toastScope,
257
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastViewportFrame, {
258
+ focusable: context.toastCount > 0,
259
+ ref: composedRefs,
260
+ ...viewportProps,
261
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.PortalHost, {
262
+ render: function (children) {
263
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
264
+ exitBeforeEnter: !multipleToasts,
265
+ children
266
+ });
267
+ },
268
+ name: name !== null && name !== void 0 ? name : "default"
269
+ })
270
+ })
271
+ }), hasToasts && /* @__PURE__ */(0, import_jsx_runtime.jsx)(FocusProxy, {
263
272
  context,
264
- ...(typeof zIndex == "number" ? {
273
+ viewportName: name,
274
+ ref: tailFocusProxyRef,
275
+ onFocusFromOutsideViewport: function () {
276
+ var tabbableCandidates = getSortedTabbableCandidates({
277
+ tabbingDirection: "backwards"
278
+ });
279
+ focusFirst(tabbableCandidates);
280
+ }
281
+ })]
282
+ });
283
+ if (portalToRoot) {
284
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastPortal.ToastPortal, {
285
+ context,
286
+ ...(typeof zIndex === "number" ? {
265
287
  zIndex
266
288
  } : {}),
267
289
  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
290
  });
291
+ }
292
+ return contents;
293
+ }));
294
+ ToastViewport.displayName = VIEWPORT_NAME;
295
+ var FOCUS_PROXY_NAME = "ToastFocusProxy";
296
+ var FocusProxy = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
297
+ var {
298
+ onFocusFromOutsideViewport,
299
+ viewportName,
300
+ context,
301
+ ...proxyProps
302
+ } = props;
303
+ var viewport = context.viewports[viewportName];
304
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_visually_hidden.VisuallyHidden, {
305
+ "aria-hidden": true,
306
+ tabIndex: 0,
307
+ ...proxyProps,
308
+ ref: forwardedRef,
309
+ // Avoid page scrolling when focus is on the focus proxy
310
+ position: import_constants.isWeb ? "fixed" : "absolute",
311
+ onFocus: function (event) {
312
+ if (!import_constants.isWeb) return;
313
+ var prevFocusedElement = event.relatedTarget;
314
+ var isFocusFromOutsideViewport = !(viewport === null || viewport === void 0 ? void 0 : viewport.contains(prevFocusedElement));
315
+ if (isFocusFromOutsideViewport) onFocusFromOutsideViewport();
316
+ }
295
317
  });
318
+ });
296
319
  FocusProxy.displayName = FOCUS_PROXY_NAME;
297
320
  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
- }
321
+ if (!import_constants.isWeb) return;
322
+ var previouslyFocusedElement = document.activeElement;
323
+ return candidates.some(function (candidate) {
324
+ if (candidate === previouslyFocusedElement) return true;
325
+ candidate.focus();
326
+ return document.activeElement !== previouslyFocusedElement;
327
+ });
304
328
  }
305
329
  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);
330
+ if (!import_constants.isWeb) return [];
331
+ var containerHtml = container;
332
+ var nodes = [];
333
+ var walker = document.createTreeWalker(containerHtml, NodeFilter.SHOW_ELEMENT, {
334
+ acceptNode: function (node) {
335
+ var isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
336
+ if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
337
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
338
+ }
339
+ });
340
+ while (walker.nextNode()) nodes.push(walker.currentNode);
313
341
  return nodes;
314
342
  }
315
343
  //# sourceMappingURL=ToastViewport.native.js.map