@tamagui/toast 2.7.7 → 3.0.0-beta.643.1

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 (303) hide show
  1. package/dist/cjs/ToastComposable.cjs +773 -882
  2. package/dist/cjs/ToastComposable.native.cjs +924 -0
  3. package/dist/cjs/ToastComposable.native.js +854 -966
  4. package/dist/cjs/ToastComposable.native.js.map +1 -1
  5. package/dist/cjs/ToastItemFrame.cjs +48 -119
  6. package/dist/cjs/ToastItemFrame.native.cjs +76 -0
  7. package/dist/cjs/ToastItemFrame.native.js +50 -120
  8. package/dist/cjs/ToastItemFrame.native.js.map +1 -1
  9. package/dist/cjs/ToastState.cjs +281 -290
  10. package/dist/cjs/ToastState.native.cjs +312 -0
  11. package/dist/cjs/ToastState.native.js +280 -290
  12. package/dist/cjs/ToastState.native.js.map +1 -1
  13. package/dist/cjs/createNativeToast.cjs +38 -44
  14. package/dist/cjs/createNativeToast.native.cjs +54 -0
  15. package/dist/cjs/createNativeToast.native.js +36 -40
  16. package/dist/cjs/createNativeToast.native.js.map +1 -1
  17. package/dist/cjs/dispatchNativeToast.cjs +32 -35
  18. package/dist/cjs/dispatchNativeToast.native.cjs +48 -0
  19. package/dist/cjs/dispatchNativeToast.native.js +34 -36
  20. package/dist/cjs/dispatchNativeToast.native.js.map +1 -1
  21. package/dist/cjs/index.cjs +25 -12
  22. package/dist/cjs/index.native.cjs +35 -0
  23. package/dist/cjs/index.native.js +26 -12
  24. package/dist/cjs/index.native.js.map +1 -1
  25. package/dist/cjs/types.cjs +10 -11
  26. package/dist/cjs/types.native.cjs +19 -0
  27. package/dist/cjs/types.native.js +10 -10
  28. package/dist/cjs/types.native.js.map +1 -1
  29. package/dist/cjs/useAnimatedDragGesture.cjs +197 -194
  30. package/dist/cjs/useAnimatedDragGesture.native.cjs +210 -0
  31. package/dist/cjs/useAnimatedDragGesture.native.js +179 -191
  32. package/dist/cjs/useAnimatedDragGesture.native.js.map +1 -1
  33. package/dist/cjs/useReducedMotion.cjs +47 -55
  34. package/dist/cjs/useReducedMotion.native.cjs +74 -0
  35. package/dist/cjs/useReducedMotion.native.js +53 -60
  36. package/dist/cjs/useReducedMotion.native.js.map +1 -1
  37. package/dist/cjs/useToastAnimations.cjs +198 -270
  38. package/dist/cjs/useToastAnimations.native.cjs +229 -0
  39. package/dist/cjs/useToastAnimations.native.js +205 -276
  40. package/dist/cjs/useToastAnimations.native.js.map +1 -1
  41. package/dist/esm/ToastComposable.mjs +752 -854
  42. package/dist/esm/ToastComposable.mjs.map +1 -1
  43. package/dist/esm/ToastComposable.native.js +834 -940
  44. package/dist/esm/ToastComposable.native.js.map +1 -1
  45. package/dist/esm/ToastItemFrame.mjs +31 -99
  46. package/dist/esm/ToastItemFrame.mjs.map +1 -1
  47. package/dist/esm/ToastItemFrame.native.js +34 -102
  48. package/dist/esm/ToastItemFrame.native.js.map +1 -1
  49. package/dist/esm/ToastState.mjs +266 -273
  50. package/dist/esm/ToastState.mjs.map +1 -1
  51. package/dist/esm/ToastState.native.js +265 -274
  52. package/dist/esm/ToastState.native.js.map +1 -1
  53. package/dist/esm/createNativeToast.mjs +22 -26
  54. package/dist/esm/createNativeToast.mjs.map +1 -1
  55. package/dist/esm/createNativeToast.native.js +21 -23
  56. package/dist/esm/createNativeToast.native.js.map +1 -1
  57. package/dist/esm/dispatchNativeToast.mjs +19 -17
  58. package/dist/esm/dispatchNativeToast.mjs.map +1 -1
  59. package/dist/esm/dispatchNativeToast.native.js +21 -19
  60. package/dist/esm/dispatchNativeToast.native.js.map +1 -1
  61. package/dist/esm/index.js +5 -2
  62. package/dist/esm/index.mjs +5 -2
  63. package/dist/esm/index.native.js +5 -2
  64. package/dist/esm/types.mjs +0 -2
  65. package/dist/esm/types.native.js +0 -2
  66. package/dist/esm/useAnimatedDragGesture.mjs +181 -168
  67. package/dist/esm/useAnimatedDragGesture.mjs.map +1 -1
  68. package/dist/esm/useAnimatedDragGesture.native.js +163 -166
  69. package/dist/esm/useAnimatedDragGesture.native.js.map +1 -1
  70. package/dist/esm/useReducedMotion.mjs +31 -29
  71. package/dist/esm/useReducedMotion.mjs.map +1 -1
  72. package/dist/esm/useReducedMotion.native.js +37 -35
  73. package/dist/esm/useReducedMotion.native.js.map +1 -1
  74. package/dist/esm/useToastAnimations.mjs +183 -245
  75. package/dist/esm/useToastAnimations.mjs.map +1 -1
  76. package/dist/esm/useToastAnimations.native.js +190 -252
  77. package/dist/esm/useToastAnimations.native.js.map +1 -1
  78. package/dist/jsx/ToastComposable.mjs +752 -854
  79. package/dist/jsx/ToastComposable.mjs.map +1 -1
  80. package/dist/jsx/ToastComposable.native.cjs +924 -0
  81. package/dist/jsx/ToastComposable.native.js +854 -966
  82. package/dist/jsx/ToastComposable.native.js.map +1 -1
  83. package/dist/jsx/ToastItemFrame.mjs +31 -99
  84. package/dist/jsx/ToastItemFrame.mjs.map +1 -1
  85. package/dist/jsx/ToastItemFrame.native.cjs +76 -0
  86. package/dist/jsx/ToastItemFrame.native.js +50 -120
  87. package/dist/jsx/ToastItemFrame.native.js.map +1 -1
  88. package/dist/jsx/ToastState.mjs +266 -273
  89. package/dist/jsx/ToastState.mjs.map +1 -1
  90. package/dist/jsx/ToastState.native.cjs +312 -0
  91. package/dist/jsx/ToastState.native.js +280 -290
  92. package/dist/jsx/ToastState.native.js.map +1 -1
  93. package/dist/jsx/createNativeToast.mjs +22 -26
  94. package/dist/jsx/createNativeToast.mjs.map +1 -1
  95. package/dist/jsx/createNativeToast.native.cjs +54 -0
  96. package/dist/jsx/createNativeToast.native.js +36 -40
  97. package/dist/jsx/createNativeToast.native.js.map +1 -1
  98. package/dist/jsx/dispatchNativeToast.mjs +19 -17
  99. package/dist/jsx/dispatchNativeToast.mjs.map +1 -1
  100. package/dist/jsx/dispatchNativeToast.native.cjs +48 -0
  101. package/dist/jsx/dispatchNativeToast.native.js +34 -36
  102. package/dist/jsx/dispatchNativeToast.native.js.map +1 -1
  103. package/dist/jsx/index.js +5 -2
  104. package/dist/jsx/index.mjs +5 -2
  105. package/dist/jsx/index.native.cjs +35 -0
  106. package/dist/jsx/index.native.js +26 -12
  107. package/dist/jsx/index.native.js.map +1 -1
  108. package/dist/jsx/types.mjs +0 -2
  109. package/dist/jsx/types.native.cjs +19 -0
  110. package/dist/jsx/types.native.js +10 -10
  111. package/dist/jsx/types.native.js.map +1 -1
  112. package/dist/jsx/useAnimatedDragGesture.mjs +181 -168
  113. package/dist/jsx/useAnimatedDragGesture.mjs.map +1 -1
  114. package/dist/jsx/useAnimatedDragGesture.native.cjs +210 -0
  115. package/dist/jsx/useAnimatedDragGesture.native.js +179 -191
  116. package/dist/jsx/useAnimatedDragGesture.native.js.map +1 -1
  117. package/dist/jsx/useReducedMotion.mjs +31 -29
  118. package/dist/jsx/useReducedMotion.mjs.map +1 -1
  119. package/dist/jsx/useReducedMotion.native.cjs +74 -0
  120. package/dist/jsx/useReducedMotion.native.js +53 -60
  121. package/dist/jsx/useReducedMotion.native.js.map +1 -1
  122. package/dist/jsx/useToastAnimations.mjs +183 -245
  123. package/dist/jsx/useToastAnimations.mjs.map +1 -1
  124. package/dist/jsx/useToastAnimations.native.cjs +229 -0
  125. package/dist/jsx/useToastAnimations.native.js +205 -276
  126. package/dist/jsx/useToastAnimations.native.js.map +1 -1
  127. package/package.json +20 -37
  128. package/src/ToastComposable.tsx +55 -97
  129. package/src/ToastItemFrame.tsx +22 -81
  130. package/src/ToastState.ts +1 -0
  131. package/src/index.ts +34 -2
  132. package/src/types.ts +11 -0
  133. package/src/useAnimatedDragGesture.native.ts +1 -1
  134. package/src/useAnimatedDragGesture.ts +1 -1
  135. package/src/useToastAnimations.ts +20 -36
  136. package/types/ToastComposable.d.ts +124 -47
  137. package/types/ToastComposable.d.ts.map +1 -1
  138. package/types/ToastItemFrame.d.ts +52 -21
  139. package/types/ToastItemFrame.d.ts.map +1 -1
  140. package/types/ToastState.d.ts +15 -11
  141. package/types/ToastState.d.ts.map +1 -1
  142. package/types/index.d.ts +6 -2
  143. package/types/index.d.ts.map +1 -1
  144. package/types/types.d.ts +1 -0
  145. package/types/types.d.ts.map +1 -1
  146. package/types/useAnimatedDragGesture.d.ts +1 -1
  147. package/types/useAnimatedDragGesture.d.ts.map +1 -1
  148. package/types/useAnimatedDragGesture.native.d.ts +1 -1
  149. package/types/useAnimatedDragGesture.native.d.ts.map +1 -1
  150. package/types/useToastAnimations.d.ts +2 -8
  151. package/types/useToastAnimations.d.ts.map +1 -1
  152. package/dist/cjs/Toast.cjs +0 -178
  153. package/dist/cjs/Toast.native.js +0 -181
  154. package/dist/cjs/Toast.native.js.map +0 -1
  155. package/dist/cjs/ToastAnnounce.cjs +0 -103
  156. package/dist/cjs/ToastAnnounce.native.js +0 -111
  157. package/dist/cjs/ToastAnnounce.native.js.map +0 -1
  158. package/dist/cjs/ToastImperative.cjs +0 -119
  159. package/dist/cjs/ToastImperative.native.js +0 -130
  160. package/dist/cjs/ToastImperative.native.js.map +0 -1
  161. package/dist/cjs/ToastImpl.cjs +0 -354
  162. package/dist/cjs/ToastImpl.native.js +0 -364
  163. package/dist/cjs/ToastImpl.native.js.map +0 -1
  164. package/dist/cjs/ToastPortal.cjs +0 -49
  165. package/dist/cjs/ToastPortal.native.js +0 -52
  166. package/dist/cjs/ToastPortal.native.js.map +0 -1
  167. package/dist/cjs/ToastProvider.cjs +0 -150
  168. package/dist/cjs/ToastProvider.native.js +0 -161
  169. package/dist/cjs/ToastProvider.native.js.map +0 -1
  170. package/dist/cjs/ToastViewport.cjs +0 -319
  171. package/dist/cjs/ToastViewport.native.js +0 -343
  172. package/dist/cjs/ToastViewport.native.js.map +0 -1
  173. package/dist/cjs/Toaster.cjs +0 -87
  174. package/dist/cjs/Toaster.native.js +0 -91
  175. package/dist/cjs/Toaster.native.js.map +0 -1
  176. package/dist/cjs/constants.cjs +0 -30
  177. package/dist/cjs/constants.native.js +0 -33
  178. package/dist/cjs/constants.native.js.map +0 -1
  179. package/dist/cjs/v2.cjs +0 -36
  180. package/dist/cjs/v2.native.js +0 -39
  181. package/dist/cjs/v2.native.js.map +0 -1
  182. package/dist/esm/Toast.mjs +0 -137
  183. package/dist/esm/Toast.mjs.map +0 -1
  184. package/dist/esm/Toast.native.js +0 -137
  185. package/dist/esm/Toast.native.js.map +0 -1
  186. package/dist/esm/ToastAnnounce.mjs +0 -66
  187. package/dist/esm/ToastAnnounce.mjs.map +0 -1
  188. package/dist/esm/ToastAnnounce.native.js +0 -71
  189. package/dist/esm/ToastAnnounce.native.js.map +0 -1
  190. package/dist/esm/ToastImperative.mjs +0 -80
  191. package/dist/esm/ToastImperative.mjs.map +0 -1
  192. package/dist/esm/ToastImperative.native.js +0 -88
  193. package/dist/esm/ToastImperative.native.js.map +0 -1
  194. package/dist/esm/ToastImpl.mjs +0 -316
  195. package/dist/esm/ToastImpl.mjs.map +0 -1
  196. package/dist/esm/ToastImpl.native.js +0 -329
  197. package/dist/esm/ToastImpl.native.js.map +0 -1
  198. package/dist/esm/ToastPortal.mjs +0 -24
  199. package/dist/esm/ToastPortal.mjs.map +0 -1
  200. package/dist/esm/ToastPortal.native.js +0 -24
  201. package/dist/esm/ToastPortal.native.js.map +0 -1
  202. package/dist/esm/ToastProvider.mjs +0 -110
  203. package/dist/esm/ToastProvider.mjs.map +0 -1
  204. package/dist/esm/ToastProvider.native.js +0 -118
  205. package/dist/esm/ToastProvider.native.js.map +0 -1
  206. package/dist/esm/ToastViewport.mjs +0 -280
  207. package/dist/esm/ToastViewport.mjs.map +0 -1
  208. package/dist/esm/ToastViewport.native.js +0 -301
  209. package/dist/esm/ToastViewport.native.js.map +0 -1
  210. package/dist/esm/Toaster.mjs +0 -51
  211. package/dist/esm/Toaster.mjs.map +0 -1
  212. package/dist/esm/Toaster.native.js +0 -52
  213. package/dist/esm/Toaster.native.js.map +0 -1
  214. package/dist/esm/constants.mjs +0 -4
  215. package/dist/esm/constants.mjs.map +0 -1
  216. package/dist/esm/constants.native.js +0 -4
  217. package/dist/esm/constants.native.js.map +0 -1
  218. package/dist/esm/index.js.map +0 -1
  219. package/dist/esm/index.mjs.map +0 -1
  220. package/dist/esm/index.native.js.map +0 -1
  221. package/dist/esm/types.mjs.map +0 -1
  222. package/dist/esm/types.native.js.map +0 -1
  223. package/dist/esm/v2.mjs +0 -6
  224. package/dist/esm/v2.mjs.map +0 -1
  225. package/dist/esm/v2.native.js +0 -6
  226. package/dist/esm/v2.native.js.map +0 -1
  227. package/dist/jsx/Toast.mjs +0 -137
  228. package/dist/jsx/Toast.mjs.map +0 -1
  229. package/dist/jsx/Toast.native.js +0 -181
  230. package/dist/jsx/Toast.native.js.map +0 -1
  231. package/dist/jsx/ToastAnnounce.mjs +0 -66
  232. package/dist/jsx/ToastAnnounce.mjs.map +0 -1
  233. package/dist/jsx/ToastAnnounce.native.js +0 -111
  234. package/dist/jsx/ToastAnnounce.native.js.map +0 -1
  235. package/dist/jsx/ToastImperative.mjs +0 -80
  236. package/dist/jsx/ToastImperative.mjs.map +0 -1
  237. package/dist/jsx/ToastImperative.native.js +0 -130
  238. package/dist/jsx/ToastImperative.native.js.map +0 -1
  239. package/dist/jsx/ToastImpl.mjs +0 -316
  240. package/dist/jsx/ToastImpl.mjs.map +0 -1
  241. package/dist/jsx/ToastImpl.native.js +0 -364
  242. package/dist/jsx/ToastImpl.native.js.map +0 -1
  243. package/dist/jsx/ToastPortal.mjs +0 -24
  244. package/dist/jsx/ToastPortal.mjs.map +0 -1
  245. package/dist/jsx/ToastPortal.native.js +0 -52
  246. package/dist/jsx/ToastPortal.native.js.map +0 -1
  247. package/dist/jsx/ToastProvider.mjs +0 -110
  248. package/dist/jsx/ToastProvider.mjs.map +0 -1
  249. package/dist/jsx/ToastProvider.native.js +0 -161
  250. package/dist/jsx/ToastProvider.native.js.map +0 -1
  251. package/dist/jsx/ToastViewport.mjs +0 -280
  252. package/dist/jsx/ToastViewport.mjs.map +0 -1
  253. package/dist/jsx/ToastViewport.native.js +0 -343
  254. package/dist/jsx/ToastViewport.native.js.map +0 -1
  255. package/dist/jsx/Toaster.mjs +0 -51
  256. package/dist/jsx/Toaster.mjs.map +0 -1
  257. package/dist/jsx/Toaster.native.js +0 -91
  258. package/dist/jsx/Toaster.native.js.map +0 -1
  259. package/dist/jsx/constants.mjs +0 -4
  260. package/dist/jsx/constants.mjs.map +0 -1
  261. package/dist/jsx/constants.native.js +0 -33
  262. package/dist/jsx/constants.native.js.map +0 -1
  263. package/dist/jsx/index.js.map +0 -1
  264. package/dist/jsx/index.mjs.map +0 -1
  265. package/dist/jsx/types.mjs.map +0 -1
  266. package/dist/jsx/v2.mjs +0 -6
  267. package/dist/jsx/v2.mjs.map +0 -1
  268. package/dist/jsx/v2.native.js +0 -39
  269. package/dist/jsx/v2.native.js.map +0 -1
  270. package/src/Toast.tsx +0 -219
  271. package/src/ToastAnnounce.tsx +0 -103
  272. package/src/ToastImperative.tsx +0 -192
  273. package/src/ToastImpl.tsx +0 -514
  274. package/src/ToastPortal.tsx +0 -19
  275. package/src/ToastProvider.tsx +0 -204
  276. package/src/ToastViewport.tsx +0 -430
  277. package/src/Toaster.tsx +0 -181
  278. package/src/constants.ts +0 -2
  279. package/src/v2.ts +0 -31
  280. package/types/Toast.d.ts +0 -84
  281. package/types/Toast.d.ts.map +0 -1
  282. package/types/ToastAnnounce.d.ts +0 -18
  283. package/types/ToastAnnounce.d.ts.map +0 -1
  284. package/types/ToastImperative.d.ts +0 -95
  285. package/types/ToastImperative.d.ts.map +0 -1
  286. package/types/ToastImpl.d.ts +0 -109
  287. package/types/ToastImpl.d.ts.map +0 -1
  288. package/types/ToastPortal.d.ts +0 -8
  289. package/types/ToastPortal.d.ts.map +0 -1
  290. package/types/ToastProvider.d.ts +0 -92
  291. package/types/ToastProvider.d.ts.map +0 -1
  292. package/types/ToastViewport.d.ts +0 -75
  293. package/types/ToastViewport.d.ts.map +0 -1
  294. package/types/Toaster.d.ts +0 -112
  295. package/types/Toaster.d.ts.map +0 -1
  296. package/types/constants.d.ts +0 -3
  297. package/types/constants.d.ts.map +0 -1
  298. package/types/v2.d.ts +0 -10
  299. package/types/v2.d.ts.map +0 -1
  300. package/v2/index.cjs +0 -2
  301. package/v2/index.js +0 -2
  302. package/v2/index.native.cjs +0 -2
  303. package/v2/index.native.js +0 -2
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,44 +8,38 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getProtoOf = Object.getPrototypeOf;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
10
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
14
15
  };
15
16
  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, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- return to;
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
23
24
  };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
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
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
32
28
  }) : target, mod));
33
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
- value: true
35
- }), mod);
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
30
  var ToastComposable_exports = {};
37
31
  __export(ToastComposable_exports, {
38
- Toast: () => Toast,
39
- useToastItem: () => useToastItem,
40
- useToasts: () => useToasts
32
+ Toast: () => Toast,
33
+ useToastItem: () => useToastItem,
34
+ useToasts: () => useToasts
41
35
  });
42
36
  module.exports = __toCommonJS(ToastComposable_exports);
43
37
  var import_jsx_runtime = require("react/jsx-runtime");
38
+ var import_core = require("@tamagui/core");
44
39
  var import_animate_presence = require("@tamagui/animate-presence");
45
40
  var import_constants = require("@tamagui/constants");
46
41
  var import_native = require("@tamagui/native");
47
- var import_core = require("@tamagui/core");
42
+ var import_core2 = require("@tamagui/core");
48
43
  var import_helpers = require("@tamagui/helpers");
49
44
  var import_portal = require("@tamagui/portal");
50
45
  var import_stacks = require("@tamagui/stacks");
@@ -57,9 +52,8 @@ var import_useToastAnimations = require("./useToastAnimations.native.js");
57
52
  var import_useReducedMotion = require("./useReducedMotion.native.js");
58
53
  var import_ToastItemFrame = require("./ToastItemFrame.native.js");
59
54
  function _type_of(obj) {
60
- "@swc/helpers - typeof";
61
-
62
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
55
+ "@swc/helpers - typeof";
56
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
63
57
  }
64
58
  var VISIBLE_TOASTS_AMOUNT = 4;
65
59
  var VIEWPORT_OFFSET = 16;
@@ -68,971 +62,865 @@ var TOAST_LIFETIME = 4e3;
68
62
  var FIXED_TOAST_HEIGHT = 72;
69
63
  var TIME_BEFORE_UNMOUNT = 200;
70
64
  var DEFAULT_HOTKEY = ["altKey", "KeyT"];
71
- var ToastContext = (0, import_core.createStyledContext)({}, "Toast__");
65
+ var ToastContext = (0, import_core2.createStyledContext)({}, "Toast__");
72
66
  var useToastContextValue = ToastContext.useStyledContext;
73
67
  function hasToastContext(ctx) {
74
- return !!ctx && Array.isArray(ctx.toasts) && typeof ctx.setToastHeight === "function" && typeof ctx.removeToast === "function";
68
+ return !!ctx && Array.isArray(ctx.toasts) && typeof ctx.setToastHeight === "function" && typeof ctx.removeToast === "function";
75
69
  }
76
70
  function useToastContext(consumerName) {
77
- var ctx = useToastContextValue();
78
- if (!hasToastContext(ctx)) {
79
- throw new Error(`\`${consumerName}\` must be used within \`Toast\``);
80
- }
81
- return ctx;
71
+ var ctx = useToastContextValue();
72
+ if (!hasToastContext(ctx)) {
73
+ throw new Error(`\`${consumerName}\` must be used within \`Toast\``);
74
+ }
75
+ return ctx;
82
76
  }
83
- var ToastItemContext = /* @__PURE__ */React.createContext(null);
77
+ var ToastItemContext = /* @__PURE__ */ React.createContext(null);
84
78
  function useToastItemContext() {
85
- var ctx = React.useContext(ToastItemContext);
86
- if (!ctx) {
87
- throw new Error("useToastItemContext must be used within Toast.Item or Toast.List");
88
- }
89
- return ctx;
79
+ var ctx = React.useContext(ToastItemContext);
80
+ if (!ctx) {
81
+ throw new Error("useToastItemContext must be used within Toast.Item or Toast.List");
82
+ }
83
+ return ctx;
90
84
  }
91
85
  function resolveSwipeDirection(direction, position) {
92
- if (direction !== "auto") return direction;
93
- var [yPosition, xPosition] = position.split("-");
94
- if (!import_constants.isWeb) {
95
- return yPosition === "top" ? "up" : "down";
96
- }
97
- if (xPosition === "left") return "left";
98
- if (xPosition === "right") return "right";
99
- return "horizontal";
86
+ if (direction !== "auto") return direction;
87
+ var [yPosition, xPosition] = position.split("-");
88
+ if (!import_constants.isWeb) {
89
+ return yPosition === "top" ? "up" : "down";
90
+ }
91
+ if (xPosition === "left") return "left";
92
+ if (xPosition === "right") return "right";
93
+ return "horizontal";
100
94
  }
101
- var ToastRoot = /* @__PURE__ */React.forwardRef(function ToastRoot2(props, _ref) {
102
- var {
103
- children,
104
- position = "bottom-right",
105
- duration = TOAST_LIFETIME,
106
- gap = TOAST_GAP,
107
- visibleToasts = VISIBLE_TOASTS_AMOUNT,
108
- swipeDirection: swipeDirectionProp = "auto",
109
- swipeThreshold = 50,
110
- toastHeight = FIXED_TOAST_HEIGHT,
111
- closeButton = false,
112
- expand = false,
113
- theme: themeProp,
114
- reducedMotion: reducedMotionProp,
115
- native = false,
116
- burntOptions,
117
- notificationOptions,
118
- icons
119
- } = props;
120
- var reducedMotion = (0, import_useReducedMotion.useReducedMotion)(reducedMotionProp);
121
- var [toasts, setToasts] = React.useState([]);
122
- var [heights, setHeights] = React.useState({});
123
- var [localExpanded, setExpanded] = React.useState(false);
124
- var expanded = expand || localExpanded;
125
- var [interacting, setInteracting] = React.useState(false);
126
- var heightsLockedRef = React.useRef(false);
127
- var prevExpandedRef = React.useRef(expanded);
128
- React.useLayoutEffect(function () {
129
- if (prevExpandedRef.current !== expanded) {
130
- heightsLockedRef.current = true;
131
- prevExpandedRef.current = expanded;
132
- }
133
- var timer = setTimeout(function () {
134
- heightsLockedRef.current = false;
135
- }, 350);
136
- return function () {
137
- return clearTimeout(timer);
138
- };
139
- }, [expanded]);
140
- var setToastHeight = React.useCallback(function (toastId, height) {
141
- if (heightsLockedRef.current) return;
142
- var rounded = Math.round(height);
143
- setHeights(function (prev) {
144
- var existing = prev[toastId];
145
- if (existing != null && Math.abs(existing - rounded) <= 2) return prev;
146
- return {
147
- ...prev,
148
- [toastId]: rounded
149
- };
150
- });
151
- }, []);
152
- var removeToastHeight = React.useCallback(function (toastId) {
153
- setHeights(function (prev) {
154
- if (!(toastId in prev)) return prev;
155
- var next = {
156
- ...prev
157
- };
158
- delete next[toastId];
159
- return next;
160
- });
161
- }, []);
162
- var dismissCooldownRef = React.useRef(false);
163
- var dismissCooldownTimerRef = React.useRef(null);
164
- var triggerDismissCooldown = React.useCallback(function () {
165
- dismissCooldownRef.current = true;
166
- if (dismissCooldownTimerRef.current) {
167
- clearTimeout(dismissCooldownTimerRef.current);
168
- }
169
- dismissCooldownTimerRef.current = setTimeout(function () {
170
- dismissCooldownRef.current = false;
171
- }, 800);
172
- }, []);
173
- var isInDismissCooldown = React.useCallback(function () {
174
- return dismissCooldownRef.current;
175
- }, []);
176
- var burntOptionsRef = React.useRef(burntOptions);
177
- var notificationOptionsRef = React.useRef(notificationOptions);
178
- React.useEffect(function () {
179
- burntOptionsRef.current = burntOptions;
180
- }, [burntOptions]);
181
- React.useEffect(function () {
182
- notificationOptionsRef.current = notificationOptions;
183
- }, [notificationOptions]);
184
- React.useEffect(function () {
185
- return import_ToastState.ToastState.subscribe(function (toast) {
186
- if (toast.dismiss) {
187
- setToasts(function (toasts2) {
188
- return toasts2.map(function (t) {
189
- return t.id === toast.id ? {
190
- ...t,
191
- delete: true
192
- } : t;
193
- });
194
- });
195
- return;
196
- }
197
- if (native) {
198
- var handled = (0, import_dispatchNativeToast.dispatchNativeToast)(toast, {
199
- duration,
200
- burntOptions: burntOptionsRef.current,
201
- notificationOptions: notificationOptionsRef.current
202
- });
203
- if (handled) return;
204
- }
205
- setToasts(function (toasts2) {
206
- var idx = toasts2.findIndex(function (t) {
207
- return t.id === toast.id;
208
- });
209
- if (idx !== -1) {
210
- return [...toasts2.slice(0, idx), {
211
- ...toasts2[idx],
212
- ...toast
213
- }, ...toasts2.slice(idx + 1)];
214
- }
215
- return [toast, ...toasts2];
216
- });
217
- });
218
- }, [native, duration]);
219
- var prevToastCountRef = React.useRef(toasts.length);
220
- React.useEffect(function () {
221
- var prevCount = prevToastCountRef.current;
222
- prevToastCountRef.current = toasts.length;
223
- if (toasts.length <= 1 && !dismissCooldownRef.current) {
224
- setExpanded(false);
225
- } else if (toasts.length > prevCount && expanded) {
226
- setExpanded(false);
227
- }
228
- }, [toasts.length, expanded]);
229
- var removeToast = React.useCallback(function (toastToRemove) {
230
- setToasts(function (toasts2) {
231
- var _toasts_find;
232
- if (!((_toasts_find = toasts2.find(function (t) {
233
- return t.id === toastToRemove.id;
234
- })) === null || _toasts_find === void 0 ? void 0 : _toasts_find.delete)) {
235
- import_ToastState.ToastState.dismiss(toastToRemove.id);
236
- }
237
- return toasts2.filter(function (param) {
238
- var {
239
- id
240
- } = param;
241
- return id !== toastToRemove.id;
242
- });
243
- });
244
- }, []);
245
- var swipeDirection = resolveSwipeDirection(swipeDirectionProp, position);
246
- var currentTheme = (0, import_core.useThemeName)();
247
- var resolvedTheme = themeProp === "system" || !themeProp ? (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.includes("dark")) ? "dark" : "light" : themeProp;
248
- var contextValue = {
249
- toasts,
250
- heights,
251
- setToastHeight,
252
- removeToastHeight,
253
- expanded,
254
- setExpanded,
255
- interacting,
256
- setInteracting,
257
- triggerDismissCooldown,
258
- isInDismissCooldown,
259
- removeToast,
260
- position,
261
- duration,
262
- gap,
263
- visibleToasts,
264
- swipeDirection,
265
- swipeThreshold,
266
- toastHeight,
267
- closeButton,
268
- reducedMotion,
269
- native,
270
- burntOptions,
271
- notificationOptions,
272
- icons
273
- };
274
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastContext.Provider, {
275
- ...contextValue,
276
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Theme, {
277
- name: resolvedTheme,
278
- children
279
- })
280
- });
95
+ var ToastRoot = (0, import_core.createRefComponent)(function ToastRoot2(props, _ref) {
96
+ var { children, toasterId, position = "bottom-right", duration = TOAST_LIFETIME, gap = TOAST_GAP, visibleToasts = VISIBLE_TOASTS_AMOUNT, swipeDirection: swipeDirectionProp = "auto", swipeThreshold = 50, toastHeight = FIXED_TOAST_HEIGHT, closeButton = false, expand = false, theme: themeProp, reducedMotion: reducedMotionProp, native = false, burntOptions, notificationOptions, icons } = props;
97
+ var reducedMotion = (0, import_useReducedMotion.useReducedMotion)(reducedMotionProp);
98
+ var [toasts, setToasts] = React.useState([]);
99
+ var [heights, setHeights] = React.useState({});
100
+ var [localExpanded, setExpanded] = React.useState(false);
101
+ var expanded = expand || localExpanded;
102
+ var [interacting, setInteracting] = React.useState(false);
103
+ var heightsLockedRef = React.useRef(false);
104
+ var prevExpandedRef = React.useRef(expanded);
105
+ React.useLayoutEffect(function() {
106
+ if (prevExpandedRef.current !== expanded) {
107
+ heightsLockedRef.current = true;
108
+ prevExpandedRef.current = expanded;
109
+ }
110
+ var timer = setTimeout(function() {
111
+ heightsLockedRef.current = false;
112
+ }, 350);
113
+ return function() {
114
+ return clearTimeout(timer);
115
+ };
116
+ }, [expanded]);
117
+ var setToastHeight = React.useCallback(function(toastId, height) {
118
+ if (heightsLockedRef.current) return;
119
+ var rounded = Math.round(height);
120
+ setHeights(function(prev) {
121
+ var existing = prev[toastId];
122
+ if (existing != null && Math.abs(existing - rounded) <= 2) return prev;
123
+ return {
124
+ ...prev,
125
+ [toastId]: rounded
126
+ };
127
+ });
128
+ }, []);
129
+ var removeToastHeight = React.useCallback(function(toastId) {
130
+ setHeights(function(prev) {
131
+ if (!(toastId in prev)) return prev;
132
+ var next = { ...prev };
133
+ delete next[toastId];
134
+ return next;
135
+ });
136
+ }, []);
137
+ var dismissCooldownRef = React.useRef(false);
138
+ var dismissCooldownTimerRef = React.useRef(null);
139
+ var triggerDismissCooldown = React.useCallback(function() {
140
+ dismissCooldownRef.current = true;
141
+ if (dismissCooldownTimerRef.current) {
142
+ clearTimeout(dismissCooldownTimerRef.current);
143
+ }
144
+ dismissCooldownTimerRef.current = setTimeout(function() {
145
+ dismissCooldownRef.current = false;
146
+ }, 800);
147
+ }, []);
148
+ var isInDismissCooldown = React.useCallback(function() {
149
+ return dismissCooldownRef.current;
150
+ }, []);
151
+ var burntOptionsRef = React.useRef(burntOptions);
152
+ var notificationOptionsRef = React.useRef(notificationOptions);
153
+ React.useEffect(function() {
154
+ burntOptionsRef.current = burntOptions;
155
+ }, [burntOptions]);
156
+ React.useEffect(function() {
157
+ notificationOptionsRef.current = notificationOptions;
158
+ }, [notificationOptions]);
159
+ React.useEffect(function() {
160
+ return import_ToastState.ToastState.subscribe(function(toast) {
161
+ if (toast.dismiss) {
162
+ setToasts(function(toasts2) {
163
+ return toasts2.map(function(t) {
164
+ return t.id === toast.id ? {
165
+ ...t,
166
+ delete: true
167
+ } : t;
168
+ });
169
+ });
170
+ return;
171
+ }
172
+ if (toast.toasterId !== toasterId) {
173
+ return;
174
+ }
175
+ if (native) {
176
+ var handled = (0, import_dispatchNativeToast.dispatchNativeToast)(toast, {
177
+ duration,
178
+ burntOptions: burntOptionsRef.current,
179
+ notificationOptions: notificationOptionsRef.current
180
+ });
181
+ if (handled) return;
182
+ }
183
+ setToasts(function(toasts2) {
184
+ var idx = toasts2.findIndex(function(t) {
185
+ return t.id === toast.id;
186
+ });
187
+ if (idx !== -1) {
188
+ return [
189
+ ...toasts2.slice(0, idx),
190
+ {
191
+ ...toasts2[idx],
192
+ ...toast
193
+ },
194
+ ...toasts2.slice(idx + 1)
195
+ ];
196
+ }
197
+ return [toast, ...toasts2];
198
+ });
199
+ });
200
+ }, [
201
+ native,
202
+ duration,
203
+ toasterId
204
+ ]);
205
+ var prevToastCountRef = React.useRef(toasts.length);
206
+ React.useEffect(function() {
207
+ var prevCount = prevToastCountRef.current;
208
+ prevToastCountRef.current = toasts.length;
209
+ if (toasts.length <= 1 && !dismissCooldownRef.current) {
210
+ setExpanded(false);
211
+ } else if (toasts.length > prevCount && expanded) {
212
+ setExpanded(false);
213
+ }
214
+ }, [toasts.length, expanded]);
215
+ var removeToast = React.useCallback(function(toastToRemove) {
216
+ setToasts(function(toasts2) {
217
+ var _toasts_find;
218
+ if (!((_toasts_find = toasts2.find(function(t) {
219
+ return t.id === toastToRemove.id;
220
+ })) === null || _toasts_find === void 0 ? void 0 : _toasts_find.delete)) {
221
+ import_ToastState.ToastState.dismiss(toastToRemove.id);
222
+ }
223
+ return toasts2.filter(function(param) {
224
+ var { id } = param;
225
+ return id !== toastToRemove.id;
226
+ });
227
+ });
228
+ }, []);
229
+ var swipeDirection = resolveSwipeDirection(swipeDirectionProp, position);
230
+ var currentTheme = (0, import_core2.useThemeName)();
231
+ var resolvedTheme = themeProp === "system" || !themeProp ? (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.includes("dark")) ? "dark" : "light" : themeProp;
232
+ var contextValue = {
233
+ toasts,
234
+ heights,
235
+ setToastHeight,
236
+ removeToastHeight,
237
+ expanded,
238
+ setExpanded,
239
+ interacting,
240
+ setInteracting,
241
+ triggerDismissCooldown,
242
+ isInDismissCooldown,
243
+ removeToast,
244
+ position,
245
+ duration,
246
+ gap,
247
+ visibleToasts,
248
+ swipeDirection,
249
+ swipeThreshold,
250
+ toastHeight,
251
+ closeButton,
252
+ reducedMotion,
253
+ native,
254
+ burntOptions,
255
+ notificationOptions,
256
+ icons
257
+ };
258
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContext.Provider, {
259
+ ...contextValue,
260
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Theme, {
261
+ name: resolvedTheme,
262
+ children
263
+ })
264
+ });
281
265
  });
282
- var ToastViewportFrame = (0, import_core.styled)(import_core.View, {
283
- name: "ToastViewport",
284
- variants: {
285
- unstyled: {
286
- false: {
287
- position: import_constants.isWeb ? "fixed" : "absolute",
288
- zIndex: 1e5,
289
- pointerEvents: "box-none",
290
- maxWidth: "100%",
291
- ...(import_constants.isWeb && {
292
- width: 356
293
- }),
294
- minHeight: 1
295
- }
296
- }
297
- },
298
- defaultVariants: {
299
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
300
- }
266
+ var ToastViewportFrame = (0, import_core2.styled)(import_core2.View, {
267
+ displayName: "ToastViewport",
268
+ position: import_constants.isWeb ? "fixed" : "absolute",
269
+ zIndex: 1e5,
270
+ pointerEvents: "box-none",
271
+ maxWidth: "100%",
272
+ ...import_constants.isWeb && { width: 356 },
273
+ minHeight: 1
301
274
  });
302
- var ToastViewport = ToastViewportFrame.styleable(function ToastViewport2(props, ref) {
303
- var {
304
- offset = VIEWPORT_OFFSET,
305
- hotkey = DEFAULT_HOTKEY,
306
- label = "Notifications",
307
- portalToRoot = true,
308
- portalZIndex = Number.MAX_SAFE_INTEGER,
309
- children,
310
- ...rest
311
- } = props;
312
- var ctx = useToastContext("Toast.Viewport");
313
- var listRef = React.useRef(null);
314
- var hoverTimeoutRef = React.useRef(null);
315
- var hoverCooldownRef = React.useRef(false);
316
- var deferredCollapseRef = React.useRef(null);
317
- var mouseInsideRef = React.useRef(false);
318
- var [yPosition, xPosition] = ctx.position.split("-");
319
- var {
320
- insets: safeInsets
321
- } = (0, import_core.useConfiguration)();
322
- var offsetStyles = React.useMemo(function () {
323
- var styles = {};
324
- var defaultOffset = typeof offset === "number" ? offset : VIEWPORT_OFFSET;
325
- var offsetObj = (typeof offset === "undefined" ? "undefined" : _type_of(offset)) === "object" ? offset : {
326
- top: defaultOffset,
327
- right: defaultOffset,
328
- bottom: defaultOffset,
329
- left: defaultOffset
330
- };
331
- var _safeInsets_top;
332
- var safeTop = (_safeInsets_top = safeInsets === null || safeInsets === void 0 ? void 0 : safeInsets.top) !== null && _safeInsets_top !== void 0 ? _safeInsets_top : 0;
333
- var _safeInsets_bottom;
334
- var safeBottom = (_safeInsets_bottom = safeInsets === null || safeInsets === void 0 ? void 0 : safeInsets.bottom) !== null && _safeInsets_bottom !== void 0 ? _safeInsets_bottom : 0;
335
- var _offsetObj_top;
336
- var topOffset = safeTop > 0 ? safeTop : (_offsetObj_top = offsetObj.top) !== null && _offsetObj_top !== void 0 ? _offsetObj_top : defaultOffset;
337
- var _offsetObj_bottom;
338
- var bottomOffset = safeBottom > 0 ? safeBottom : (_offsetObj_bottom = offsetObj.bottom) !== null && _offsetObj_bottom !== void 0 ? _offsetObj_bottom : defaultOffset;
339
- if (yPosition === "top") styles.top = topOffset;else styles.bottom = bottomOffset;
340
- if (import_constants.isWeb) {
341
- var _offsetObj_left, _offsetObj_right;
342
- if (xPosition === "left") styles.left = (_offsetObj_left = offsetObj.left) !== null && _offsetObj_left !== void 0 ? _offsetObj_left : defaultOffset;else if (xPosition === "right") styles.right = (_offsetObj_right = offsetObj.right) !== null && _offsetObj_right !== void 0 ? _offsetObj_right : defaultOffset;else {
343
- styles.left = "50%";
344
- styles.transform = "translateX(-50%)";
345
- }
346
- } else {
347
- var _offsetObj_left1;
348
- styles.left = (_offsetObj_left1 = offsetObj.left) !== null && _offsetObj_left1 !== void 0 ? _offsetObj_left1 : defaultOffset;
349
- var _offsetObj_right1;
350
- styles.right = (_offsetObj_right1 = offsetObj.right) !== null && _offsetObj_right1 !== void 0 ? _offsetObj_right1 : defaultOffset;
351
- }
352
- return styles;
353
- }, [offset, yPosition, xPosition]);
354
- React.useEffect(function () {
355
- if (!import_constants.isWeb) return;
356
- var handleKeyDown = function (event) {
357
- var isHotkeyPressed = hotkey.length > 0 && hotkey.every(function (key) {
358
- return event[key] || event.code === key;
359
- });
360
- if (isHotkeyPressed) {
361
- var _listRef_current;
362
- ctx.setExpanded(true);
363
- (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current.focus();
364
- }
365
- };
366
- document.addEventListener("keydown", handleKeyDown);
367
- return function () {
368
- return document.removeEventListener("keydown", handleKeyDown);
369
- };
370
- }, [hotkey]);
371
- if (ctx.toasts.length === 0) return null;
372
- var hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
373
- var content = /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastViewportFrame, {
374
- ref: listRef,
375
- "aria-label": `${label} ${hotkeyLabel}`,
376
- tabIndex: -1,
377
- "aria-live": "polite",
378
- style: offsetStyles,
379
- "data-y-position": yPosition,
380
- "data-x-position": xPosition,
381
- ...(import_constants.isWeb ? {
382
- onMouseEnter: function () {
383
- mouseInsideRef.current = true;
384
- if (deferredCollapseRef.current) {
385
- clearTimeout(deferredCollapseRef.current);
386
- deferredCollapseRef.current = null;
387
- }
388
- if (ctx.toasts.length > 1 && !ctx.interacting && !hoverCooldownRef.current) {
389
- hoverTimeoutRef.current = setTimeout(function () {
390
- return ctx.setExpanded(true);
391
- }, 50);
392
- }
393
- },
394
- onMouseLeave: function () {
395
- mouseInsideRef.current = false;
396
- if (hoverTimeoutRef.current) {
397
- clearTimeout(hoverTimeoutRef.current);
398
- hoverTimeoutRef.current = null;
399
- }
400
- if (!ctx.interacting && !ctx.isInDismissCooldown()) {
401
- ctx.setExpanded(false);
402
- } else if (ctx.isInDismissCooldown()) {
403
- if (deferredCollapseRef.current) {
404
- clearTimeout(deferredCollapseRef.current);
405
- }
406
- deferredCollapseRef.current = setTimeout(function () {
407
- deferredCollapseRef.current = null;
408
- if (!mouseInsideRef.current) {
409
- ctx.setExpanded(false);
410
- }
411
- }, 1200);
412
- }
413
- },
414
- onPointerDown: function () {
415
- if (hoverTimeoutRef.current) {
416
- clearTimeout(hoverTimeoutRef.current);
417
- hoverTimeoutRef.current = null;
418
- }
419
- ctx.setInteracting(true);
420
- },
421
- onPointerUp: function () {
422
- return ctx.setInteracting(false);
423
- },
424
- onPointerCancel: function () {
425
- return ctx.setInteracting(false);
426
- }
427
- } : {
428
- onPress: function () {
429
- if (ctx.toasts.length > 1) {
430
- ctx.setExpanded(function (prev) {
431
- return !prev;
432
- });
433
- }
434
- }
435
- }),
436
- ...(import_constants.isWeb && {
437
- onFocus: function (event) {
438
- if (!event.currentTarget.contains(event.relatedTarget)) {
439
- if (ctx.toasts.length > 1) {
440
- ctx.setExpanded(true);
441
- }
442
- ctx.setInteracting(true);
443
- }
444
- },
445
- onBlur: function (event) {
446
- if (!event.currentTarget.contains(event.relatedTarget)) {
447
- ctx.setInteracting(false);
448
- if (!ctx.isInDismissCooldown()) {
449
- ctx.setExpanded(false);
450
- }
451
- }
452
- }
453
- }),
454
- ...rest,
455
- children
456
- });
457
- if (portalToRoot) {
458
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.Portal, {
459
- zIndex: portalZIndex,
460
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastContext.Provider, {
461
- ...ctx,
462
- children: content
463
- })
464
- });
465
- }
466
- return content;
275
+ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, function ToastViewport2(props, ref) {
276
+ var { offset = VIEWPORT_OFFSET, hotkey = DEFAULT_HOTKEY, label = "Notifications", portalToRoot = true, portalZIndex = Number.MAX_SAFE_INTEGER, children, ...rest } = props;
277
+ var ctx = useToastContext("Toast.Viewport");
278
+ var listRef = React.useRef(null);
279
+ var hoverTimeoutRef = React.useRef(null);
280
+ var hoverCooldownRef = React.useRef(false);
281
+ var deferredCollapseRef = React.useRef(null);
282
+ var mouseInsideRef = React.useRef(false);
283
+ var [yPosition, xPosition] = ctx.position.split("-");
284
+ var { insets: safeInsets } = (0, import_core2.useConfiguration)();
285
+ var offsetStyles = React.useMemo(function() {
286
+ var styles = {};
287
+ var defaultOffset = typeof offset === "number" ? offset : VIEWPORT_OFFSET;
288
+ var offsetObj = (typeof offset === "undefined" ? "undefined" : _type_of(offset)) === "object" ? offset : {
289
+ top: defaultOffset,
290
+ right: defaultOffset,
291
+ bottom: defaultOffset,
292
+ left: defaultOffset
293
+ };
294
+ var _safeInsets_top;
295
+ var safeTop = (_safeInsets_top = safeInsets === null || safeInsets === void 0 ? void 0 : safeInsets.top) !== null && _safeInsets_top !== void 0 ? _safeInsets_top : 0;
296
+ var _safeInsets_bottom;
297
+ var safeBottom = (_safeInsets_bottom = safeInsets === null || safeInsets === void 0 ? void 0 : safeInsets.bottom) !== null && _safeInsets_bottom !== void 0 ? _safeInsets_bottom : 0;
298
+ var _offsetObj_top;
299
+ var topOffset = safeTop > 0 ? safeTop : (_offsetObj_top = offsetObj.top) !== null && _offsetObj_top !== void 0 ? _offsetObj_top : defaultOffset;
300
+ var _offsetObj_bottom;
301
+ var bottomOffset = safeBottom > 0 ? safeBottom : (_offsetObj_bottom = offsetObj.bottom) !== null && _offsetObj_bottom !== void 0 ? _offsetObj_bottom : defaultOffset;
302
+ if (yPosition === "top") styles.top = topOffset;
303
+ else styles.bottom = bottomOffset;
304
+ if (import_constants.isWeb) {
305
+ var _offsetObj_left, _offsetObj_right;
306
+ if (xPosition === "left") styles.left = (_offsetObj_left = offsetObj.left) !== null && _offsetObj_left !== void 0 ? _offsetObj_left : defaultOffset;
307
+ else if (xPosition === "right") styles.right = (_offsetObj_right = offsetObj.right) !== null && _offsetObj_right !== void 0 ? _offsetObj_right : defaultOffset;
308
+ else {
309
+ styles.left = "50%";
310
+ styles.transform = "translateX(-50%)";
311
+ }
312
+ } else {
313
+ var _offsetObj_left1;
314
+ styles.left = (_offsetObj_left1 = offsetObj.left) !== null && _offsetObj_left1 !== void 0 ? _offsetObj_left1 : defaultOffset;
315
+ var _offsetObj_right1;
316
+ styles.right = (_offsetObj_right1 = offsetObj.right) !== null && _offsetObj_right1 !== void 0 ? _offsetObj_right1 : defaultOffset;
317
+ }
318
+ return styles;
319
+ }, [
320
+ offset,
321
+ yPosition,
322
+ xPosition
323
+ ]);
324
+ React.useEffect(function() {
325
+ if (!import_constants.isWeb) return;
326
+ var handleKeyDown = function(event) {
327
+ var isHotkeyPressed = hotkey.length > 0 && hotkey.every(function(key) {
328
+ return event[key] || event.code === key;
329
+ });
330
+ if (isHotkeyPressed) {
331
+ var _listRef_current;
332
+ ctx.setExpanded(true);
333
+ (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current.focus();
334
+ }
335
+ };
336
+ document.addEventListener("keydown", handleKeyDown);
337
+ return function() {
338
+ return document.removeEventListener("keydown", handleKeyDown);
339
+ };
340
+ }, [hotkey]);
341
+ if (ctx.toasts.length === 0) return null;
342
+ var hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
343
+ var content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastViewportFrame, {
344
+ ref: listRef,
345
+ "aria-label": `${label} ${hotkeyLabel}`,
346
+ tabIndex: -1,
347
+ "aria-live": "polite",
348
+ style: offsetStyles,
349
+ "data-y-position": yPosition,
350
+ "data-x-position": xPosition,
351
+ ...import_constants.isWeb ? {
352
+ onMouseEnter: function() {
353
+ mouseInsideRef.current = true;
354
+ if (deferredCollapseRef.current) {
355
+ clearTimeout(deferredCollapseRef.current);
356
+ deferredCollapseRef.current = null;
357
+ }
358
+ if (ctx.toasts.length > 1 && !ctx.interacting && !hoverCooldownRef.current) {
359
+ hoverTimeoutRef.current = setTimeout(function() {
360
+ return ctx.setExpanded(true);
361
+ }, 50);
362
+ }
363
+ },
364
+ onMouseLeave: function() {
365
+ mouseInsideRef.current = false;
366
+ if (hoverTimeoutRef.current) {
367
+ clearTimeout(hoverTimeoutRef.current);
368
+ hoverTimeoutRef.current = null;
369
+ }
370
+ if (!ctx.interacting && !ctx.isInDismissCooldown()) {
371
+ ctx.setExpanded(false);
372
+ } else if (ctx.isInDismissCooldown()) {
373
+ if (deferredCollapseRef.current) {
374
+ clearTimeout(deferredCollapseRef.current);
375
+ }
376
+ deferredCollapseRef.current = setTimeout(function() {
377
+ deferredCollapseRef.current = null;
378
+ if (!mouseInsideRef.current) {
379
+ ctx.setExpanded(false);
380
+ }
381
+ }, 1200);
382
+ }
383
+ },
384
+ onPointerDown: function() {
385
+ if (hoverTimeoutRef.current) {
386
+ clearTimeout(hoverTimeoutRef.current);
387
+ hoverTimeoutRef.current = null;
388
+ }
389
+ ctx.setInteracting(true);
390
+ },
391
+ onPointerUp: function() {
392
+ return ctx.setInteracting(false);
393
+ },
394
+ onPointerCancel: function() {
395
+ return ctx.setInteracting(false);
396
+ }
397
+ } : { onPress: function() {
398
+ if (ctx.toasts.length > 1) {
399
+ ctx.setExpanded(function(prev) {
400
+ return !prev;
401
+ });
402
+ }
403
+ } },
404
+ ...import_constants.isWeb && {
405
+ onFocus: function(event) {
406
+ if (!event.currentTarget.contains(event.relatedTarget)) {
407
+ if (ctx.toasts.length > 1) {
408
+ ctx.setExpanded(true);
409
+ }
410
+ ctx.setInteracting(true);
411
+ }
412
+ },
413
+ onBlur: function(event) {
414
+ if (!event.currentTarget.contains(event.relatedTarget)) {
415
+ ctx.setInteracting(false);
416
+ if (!ctx.isInDismissCooldown()) {
417
+ ctx.setExpanded(false);
418
+ }
419
+ }
420
+ }
421
+ },
422
+ ...rest,
423
+ children
424
+ });
425
+ if (portalToRoot) {
426
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, {
427
+ zIndex: portalZIndex,
428
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContext.Provider, {
429
+ ...ctx,
430
+ children: content
431
+ })
432
+ });
433
+ }
434
+ return content;
467
435
  });
468
436
  function ToastList(param) {
469
- var {
470
- renderItem
471
- } = param;
472
- var ctx = useToastContext("Toast.List");
473
- var maxRender = ctx.toasts.length;
474
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
475
- children: ctx.toasts.slice(0, maxRender).map(function (toast, index) {
476
- var handleClose = function () {
477
- var _toast_onDismiss;
478
- if (toast.dismissible === false) return;
479
- (_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
480
- ctx.removeToast(toast);
481
- };
482
- var itemContextValue = {
483
- toast,
484
- handleClose
485
- };
486
- if (!renderItem) {
487
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastItemContext.Provider, {
488
- value: itemContextValue,
489
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastItemInner, {
490
- toast,
491
- index,
492
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(DefaultToastContent, {
493
- toast
494
- })
495
- })
496
- }, toast.id);
497
- }
498
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastItemContext.Provider, {
499
- value: itemContextValue,
500
- children: renderItem({
501
- toast,
502
- index,
503
- handleClose
504
- })
505
- }, toast.id);
506
- })
507
- });
437
+ var { renderItem } = param;
438
+ var ctx = useToastContext("Toast.List");
439
+ var maxRender = ctx.toasts.length;
440
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { children: ctx.toasts.slice(0, maxRender).map(function(toast, index) {
441
+ var handleClose = function() {
442
+ var _toast_onDismiss;
443
+ if (toast.dismissible === false) return;
444
+ (_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
445
+ ctx.removeToast(toast);
446
+ };
447
+ var itemContextValue = {
448
+ toast,
449
+ handleClose
450
+ };
451
+ if (!renderItem) {
452
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastItemContext.Provider, {
453
+ value: itemContextValue,
454
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastItemInner, {
455
+ toast,
456
+ index,
457
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultToastContent, { toast })
458
+ })
459
+ }, toast.id);
460
+ }
461
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastItemContext.Provider, {
462
+ value: itemContextValue,
463
+ children: renderItem({
464
+ toast,
465
+ index,
466
+ handleClose
467
+ })
468
+ }, toast.id);
469
+ }) });
508
470
  }
509
471
  function DefaultToastContent(param) {
510
- var {
511
- toast
512
- } = param;
513
- var ctx = useToastContext("Toast.Item");
514
- var {
515
- handleClose
516
- } = useToastItemContext();
517
- var _toast_type;
518
- var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
519
- var dismissible = toast.dismissible !== false;
520
- var title = typeof toast.title === "function" ? toast.title() : toast.title;
521
- var description = typeof toast.description === "function" ? toast.description() : toast.description;
522
- return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_stacks.XStack, {
523
- alignItems: "flex-start",
524
- gap: "$3",
525
- children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastIcon, {}), /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_stacks.YStack, {
526
- flex: 1,
527
- gap: "$1",
528
- children: [title && /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastTitle, {
529
- children: title
530
- }), description && /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastDescription, {
531
- children: description
532
- }), (toast.action || toast.cancel) && /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_stacks.XStack, {
533
- gap: "$2",
534
- marginTop: "$2",
535
- children: [toast.cancel && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
536
- backgroundColor: "transparent",
537
- onPress: function (e) {
538
- var _toast_cancel_onClick, _toast_cancel;
539
- (_toast_cancel = toast.cancel) === null || _toast_cancel === void 0 ? void 0 : (_toast_cancel_onClick = _toast_cancel.onClick) === null || _toast_cancel_onClick === void 0 ? void 0 : _toast_cancel_onClick.call(_toast_cancel, e);
540
- handleClose();
541
- },
542
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.SizableText, {
543
- size: "$2",
544
- color: "$color11",
545
- children: toast.cancel.label
546
- })
547
- }), toast.action && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
548
- backgroundColor: "$color12",
549
- hoverStyle: {
550
- backgroundColor: "$color11"
551
- },
552
- pressStyle: {
553
- backgroundColor: "$color10"
554
- },
555
- onPress: function (e) {
556
- var _toast_action_onClick, _toast_action;
557
- (_toast_action = toast.action) === null || _toast_action === void 0 ? void 0 : (_toast_action_onClick = _toast_action.onClick) === null || _toast_action_onClick === void 0 ? void 0 : _toast_action_onClick.call(_toast_action, e);
558
- if (!e.defaultPrevented) {
559
- handleClose();
560
- }
561
- },
562
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.SizableText, {
563
- size: "$2",
564
- fontWeight: "600",
565
- color: "$background",
566
- children: toast.action.label
567
- })
568
- })]
569
- })]
570
- }), ctx.closeButton && dismissible && /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastClose, {})]
571
- });
472
+ var { toast } = param;
473
+ var ctx = useToastContext("Toast.Item");
474
+ var { handleClose } = useToastItemContext();
475
+ var _toast_type;
476
+ var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
477
+ var dismissible = toast.dismissible !== false;
478
+ var title = typeof toast.title === "function" ? toast.title() : toast.title;
479
+ var description = typeof toast.description === "function" ? toast.description() : toast.description;
480
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stacks.XStack, {
481
+ alignItems: "flex-start",
482
+ gap: "3",
483
+ children: [
484
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastIcon, {}),
485
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stacks.YStack, {
486
+ flex: 1,
487
+ gap: "1",
488
+ children: [
489
+ title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastTitle, { children: title }),
490
+ description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastDescription, { children: description }),
491
+ (toast.action || toast.cancel) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stacks.XStack, {
492
+ gap: "2",
493
+ marginTop: "2",
494
+ children: [toast.cancel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
495
+ onPress: function(e) {
496
+ var _toast_cancel_onClick, _toast_cancel;
497
+ (_toast_cancel = toast.cancel) === null || _toast_cancel === void 0 ? void 0 : (_toast_cancel_onClick = _toast_cancel.onClick) === null || _toast_cancel_onClick === void 0 ? void 0 : _toast_cancel_onClick.call(_toast_cancel, e);
498
+ handleClose();
499
+ },
500
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text.SizableText, {
501
+ size: "2",
502
+ children: toast.cancel.label
503
+ })
504
+ }), toast.action && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
505
+ onPress: function(e) {
506
+ var _toast_action_onClick, _toast_action;
507
+ (_toast_action = toast.action) === null || _toast_action === void 0 ? void 0 : (_toast_action_onClick = _toast_action.onClick) === null || _toast_action_onClick === void 0 ? void 0 : _toast_action_onClick.call(_toast_action, e);
508
+ if (!e.defaultPrevented) {
509
+ handleClose();
510
+ }
511
+ },
512
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text.SizableText, {
513
+ size: "2",
514
+ children: toast.action.label
515
+ })
516
+ })]
517
+ })
518
+ ]
519
+ }),
520
+ ctx.closeButton && dismissible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastClose, {})
521
+ ]
522
+ });
572
523
  }
573
524
  function DragWrapper(param) {
574
- var {
575
- animatedStyle,
576
- gestureHandlers,
577
- gesture,
578
- AnimatedView,
579
- dragRef,
580
- children
581
- } = param;
582
- if (import_constants.isWeb) {
583
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)("div", {
584
- ref: dragRef,
585
- style: {
586
- flex: 1,
587
- display: "flex",
588
- flexDirection: "column",
589
- userSelect: "none",
590
- WebkitUserSelect: "none",
591
- touchAction: "none",
592
- cursor: "default"
593
- },
594
- ...gestureHandlers,
595
- children
596
- });
597
- }
598
- if (gesture) {
599
- var gh = (0, import_native.getGestureHandler)();
600
- var GestureDetector = gh.state.GestureDetector;
601
- if (GestureDetector) {
602
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(GestureDetector, {
603
- gesture,
604
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
605
- style: {
606
- flex: 1
607
- },
608
- ...{
609
- collapsable: false
610
- },
611
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AnimatedView, {
612
- style: [{
613
- flex: 1
614
- }, animatedStyle],
615
- children
616
- })
617
- })
618
- });
619
- }
620
- }
621
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(AnimatedView, {
622
- style: [{
623
- flex: 1
624
- }, animatedStyle],
625
- ...gestureHandlers,
626
- children
627
- });
525
+ var { animatedStyle, gestureHandlers, gesture, AnimatedView, dragRef, children } = param;
526
+ if (import_constants.isWeb) {
527
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
528
+ ref: dragRef,
529
+ style: {
530
+ flex: 1,
531
+ display: "flex",
532
+ flexDirection: "column",
533
+ userSelect: "none",
534
+ WebkitUserSelect: "none",
535
+ touchAction: "none",
536
+ cursor: "default"
537
+ },
538
+ ...gestureHandlers,
539
+ children
540
+ });
541
+ }
542
+ if (gesture) {
543
+ var gh = (0, import_native.getGestureHandler)();
544
+ var GestureDetector = gh.state.GestureDetector;
545
+ if (GestureDetector) {
546
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GestureDetector, {
547
+ gesture,
548
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
549
+ style: { flex: 1 },
550
+ ...{ collapsable: false },
551
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnimatedView, {
552
+ style: [{ flex: 1 }, animatedStyle],
553
+ children
554
+ })
555
+ })
556
+ });
557
+ }
558
+ }
559
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnimatedView, {
560
+ style: [{ flex: 1 }, animatedStyle],
561
+ ...gestureHandlers,
562
+ children
563
+ });
628
564
  }
629
- var ToastItemInner = import_ToastItemFrame.ToastItemFrame.styleable(function ToastItem(props, ref) {
630
- var {
631
- toast,
632
- index,
633
- children,
634
- ...rest
635
- } = props;
636
- var ctx = useToastContext("Toast.Item");
637
- var [mounted, setMounted] = React.useState(false);
638
- var [removed, setRemoved] = React.useState(false);
639
- var [swipeOut, setSwipeOut] = React.useState(false);
640
- var [offsetBeforeRemove, setOffsetBeforeRemove] = React.useState(0);
641
- var swipeExitYRef = React.useRef(null);
642
- var closeTimerRef = React.useRef(null);
643
- var closeTimerStartRef = React.useRef(0);
644
- var lastPauseTimeRef = React.useRef(0);
645
- var _toast_duration;
646
- var remainingTimeRef = React.useRef((_toast_duration = toast.duration) !== null && _toast_duration !== void 0 ? _toast_duration : ctx.duration);
647
- var isFront = index === 0;
648
- var isVisible = index < ctx.visibleToasts;
649
- var _toast_type;
650
- var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
651
- var dismissible = toast.dismissible !== false;
652
- var _toast_duration1;
653
- var duration = (_toast_duration1 = toast.duration) !== null && _toast_duration1 !== void 0 ? _toast_duration1 : ctx.duration;
654
- var [yPosition] = ctx.position.split("-");
655
- var isTop = yPosition === "top";
656
- var expandedOffset = import_constants.isWeb ? function () {
657
- var totalHeight = 0;
658
- var activeCount = 0;
659
- for (var i = 0; i < index; i++) {
660
- var _ctx_toasts_i;
661
- var toastId = (_ctx_toasts_i = ctx.toasts[i]) === null || _ctx_toasts_i === void 0 ? void 0 : _ctx_toasts_i.id;
662
- if (toastId == null) continue;
663
- var h2 = ctx.heights[toastId];
664
- if (h2 === 0) continue;
665
- totalHeight += h2 !== null && h2 !== void 0 ? h2 : ctx.toastHeight;
666
- activeCount++;
667
- }
668
- return totalHeight + activeCount * ctx.gap;
669
- }() : index * (ctx.toastHeight + ctx.gap);
670
- var expandedOffsetRef = React.useRef(expandedOffset);
671
- expandedOffsetRef.current = expandedOffset;
672
- var isExpandedRef = React.useRef(ctx.expanded);
673
- isExpandedRef.current = ctx.expanded;
674
- var startTimer = React.useCallback(function () {
675
- if (duration === Number.POSITIVE_INFINITY || toastType === "loading") return;
676
- closeTimerStartRef.current = Date.now();
677
- closeTimerRef.current = setTimeout(function () {
678
- var _toast_onAutoClose;
679
- (_toast_onAutoClose = toast.onAutoClose) === null || _toast_onAutoClose === void 0 ? void 0 : _toast_onAutoClose.call(toast, toast);
680
- setRemoved(true);
681
- setTimeout(function () {
682
- return ctx.removeToast(toast);
683
- }, TIME_BEFORE_UNMOUNT);
684
- }, remainingTimeRef.current);
685
- }, [duration, toastType, toast, ctx.removeToast]);
686
- var pauseTimer = (0, import_core.useEvent)(function () {
687
- if (closeTimerRef.current) {
688
- clearTimeout(closeTimerRef.current);
689
- }
690
- if (lastPauseTimeRef.current < closeTimerStartRef.current) {
691
- var elapsed = Date.now() - closeTimerStartRef.current;
692
- remainingTimeRef.current = Math.max(0, remainingTimeRef.current - elapsed);
693
- }
694
- lastPauseTimeRef.current = Date.now();
695
- });
696
- var resumeTimer = (0, import_core.useEvent)(function () {
697
- if (ctx.expanded || ctx.interacting) return;
698
- remainingTimeRef.current = duration;
699
- startTimer();
700
- });
701
- React.useEffect(function () {
702
- setMounted(true);
703
- }, []);
704
- React.useEffect(function () {
705
- if (toast.delete) {
706
- setRemoved(true);
707
- if (isExpandedRef.current) {
708
- setOffsetBeforeRemove(expandedOffsetRef.current);
709
- }
710
- setTimeout(function () {
711
- return ctx.removeToast(toast);
712
- }, TIME_BEFORE_UNMOUNT);
713
- }
714
- }, [toast.delete, toast, ctx.removeToast]);
715
- React.useEffect(function () {
716
- if (ctx.expanded || ctx.interacting) {
717
- pauseTimer();
718
- } else {
719
- startTimer();
720
- }
721
- return function () {
722
- if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
723
- };
724
- }, [ctx.expanded, ctx.interacting, startTimer]);
725
- React.useEffect(function () {
726
- remainingTimeRef.current = duration;
727
- }, [duration]);
728
- var {
729
- setDragOffset,
730
- springBack,
731
- animateOut,
732
- animatedStyle,
733
- AnimatedView,
734
- dragRef
735
- } = (0, import_useToastAnimations.useToastAnimations)({
736
- reducedMotion: ctx.reducedMotion,
737
- swipeAxis: ctx.swipeDirection === "up" || ctx.swipeDirection === "down" || ctx.swipeDirection === "vertical" ? "vertical" : "horizontal"
738
- });
739
- var {
740
- isDragging,
741
- gestureHandlers,
742
- gesture
743
- } = (0, import_useAnimatedDragGesture.useAnimatedDragGesture)({
744
- direction: ctx.swipeDirection,
745
- threshold: ctx.swipeThreshold,
746
- disabled: !dismissible || toastType === "loading",
747
- expanded: ctx.expanded,
748
- onDragStart: pauseTimer,
749
- onDragMove: setDragOffset,
750
- onDismiss: function (exitDirection, velocity) {
751
- var _toast_onDismiss;
752
- ctx.triggerDismissCooldown();
753
- setSwipeOut(true);
754
- (_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
755
- swipeExitYRef.current = isExpandedRef.current ? isTop ? expandedOffsetRef.current : -expandedOffsetRef.current : isFront ? 0 : isTop ? ctx.gap * index : -ctx.gap * index;
756
- setRemoved(true);
757
- ctx.removeToast(toast);
758
- animateOut(exitDirection, velocity);
759
- },
760
- onCancel: function () {
761
- springBack(function () {
762
- resumeTimer();
763
- });
764
- }
765
- });
766
- var handleLayout = React.useCallback(function (event) {
767
- if (!import_constants.isWeb) return;
768
- if (removed) return;
769
- if (!ctx.expanded && index !== 0) return;
770
- var {
771
- height
772
- } = event.nativeEvent.layout;
773
- ctx.setToastHeight(toast.id, height);
774
- }, [toast.id, ctx.setToastHeight, index, ctx.expanded, removed]);
775
- React.useEffect(function () {
776
- if (!import_constants.isWeb) return;
777
- return function () {
778
- ctx.removeToastHeight(toast.id);
779
- };
780
- }, [toast.id, ctx.removeToastHeight]);
781
- var handleClose = React.useCallback(function () {
782
- var _toast_onDismiss;
783
- if (!dismissible) return;
784
- ctx.triggerDismissCooldown();
785
- (_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
786
- setRemoved(true);
787
- if (isExpandedRef.current) {
788
- setOffsetBeforeRemove(expandedOffsetRef.current);
789
- }
790
- setTimeout(function () {
791
- return ctx.removeToast(toast);
792
- }, TIME_BEFORE_UNMOUNT);
793
- }, [dismissible, toast, ctx.removeToast, ctx.triggerDismissCooldown]);
794
- var itemContextValue = React.useMemo(function () {
795
- return {
796
- toast,
797
- handleClose
798
- };
799
- }, [toast, handleClose]);
800
- var frontToastHeight = -1;
801
- if (import_constants.isWeb) {
802
- var _iteratorNormalCompletion = true,
803
- _didIteratorError = false,
804
- _iteratorError = void 0;
805
- try {
806
- for (var _iterator = ctx.toasts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
807
- var t = _step.value;
808
- var h = ctx.heights[t.id];
809
- if (h != null && h > 0) {
810
- frontToastHeight = h;
811
- break;
812
- }
813
- }
814
- } catch (err) {
815
- _didIteratorError = true;
816
- _iteratorError = err;
817
- } finally {
818
- try {
819
- if (!_iteratorNormalCompletion && _iterator.return != null) {
820
- _iterator.return();
821
- }
822
- } finally {
823
- if (_didIteratorError) {
824
- throw _iteratorError;
825
- }
826
- }
827
- }
828
- }
829
- var stackScale = !ctx.expanded && !isFront ? 1 - index * 0.05 : 1;
830
- var activeExpandedOffset = removed ? offsetBeforeRemove : expandedOffset;
831
- var stackY = ctx.expanded ? isTop ? activeExpandedOffset : -activeExpandedOffset : isFront ? 0 : isTop ? ctx.gap * index : -ctx.gap * index;
832
- var computedOpacity = removed && !swipeOut ? 0 : index >= ctx.visibleToasts ? 0 : 1;
833
- var computedZIndex = removed ? 0 : ctx.visibleToasts - index + 1;
834
- var computedHeight = import_constants.isWeb ? ctx.expanded ? ctx.heights[toast.id] || void 0 : !isFront && frontToastHeight > 0 ? frontToastHeight : void 0 : void 0;
835
- var computedPointerEvents = index >= ctx.visibleToasts ? "none" : "auto";
836
- var gapFillerHeight = ctx.expanded ? ctx.gap + 1 : 0;
837
- var dataAttributes = {
838
- "data-mounted": mounted ? "true" : "false",
839
- "data-removed": removed ? "true" : "false",
840
- "data-swipe-out": swipeOut ? "true" : "false",
841
- "data-visible": isVisible ? "true" : "false",
842
- "data-front": isFront ? "true" : "false",
843
- "data-index": String(index),
844
- "data-type": toastType,
845
- "data-expanded": ctx.expanded ? "true" : "false"
846
- };
847
- var _swipeExitYRef_current;
848
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastPositionWrapper, {
849
- ref,
850
- testID: rest.testID,
851
- accessibilityLabel: rest.accessibilityLabel,
852
- ...dataAttributes,
853
- transition: isDragging || ctx.reducedMotion ? void 0 : removed ? "200ms" : "400ms",
854
- animateOnly: import_constants.isWeb ? ["transform", "opacity", "height"] : ["transform", "opacity"],
855
- y: stackY,
856
- scale: stackScale,
857
- opacity: computedOpacity,
858
- zIndex: computedZIndex,
859
- height: computedHeight,
860
- overflow: "visible",
861
- pointerEvents: computedPointerEvents,
862
- top: isTop ? 0 : void 0,
863
- bottom: isTop ? void 0 : 0,
864
- ...(import_constants.isWeb && !isFront && {
865
- style: {
866
- transformOrigin: isTop ? "top center" : "bottom center"
867
- }
868
- }),
869
- enterStyle: ctx.reducedMotion ? {
870
- opacity: 0
871
- } : {
872
- opacity: 0,
873
- y: isTop ? -80 : 80
874
- },
875
- exitStyle: ctx.reducedMotion ? {
876
- opacity: 0
877
- } : swipeOut ? {
878
- opacity: 0,
879
- y: (_swipeExitYRef_current = swipeExitYRef.current) !== null && _swipeExitYRef_current !== void 0 ? _swipeExitYRef_current : stackY,
880
- scale: stackScale
881
- } : {
882
- opacity: 0,
883
- y: stackY,
884
- scale: stackScale
885
- },
886
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(DragWrapper, {
887
- animatedStyle,
888
- gestureHandlers,
889
- gesture,
890
- AnimatedView,
891
- dragRef,
892
- children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_ToastItemFrame.ToastItemFrame, {
893
- role: "status",
894
- "aria-live": "polite",
895
- "aria-atomic": true,
896
- tabIndex: 0,
897
- onLayout: handleLayout,
898
- ...(import_constants.isWeb && {
899
- onKeyDown: function (event) {
900
- if (event.key === "Escape" && dismissible) {
901
- var current = event.currentTarget;
902
- var container = current.closest("[aria-label]");
903
- if (container) {
904
- var focusables = container.querySelectorAll('[tabindex="0"]');
905
- var arr = Array.from(focusables);
906
- var idx = arr.indexOf(current);
907
- var next = arr[idx + 1] || arr[idx - 1];
908
- next === null || next === void 0 ? void 0 : next.focus();
909
- }
910
- handleClose();
911
- }
912
- }
913
- }),
914
- ...rest,
915
- children: [/* gap filler to prevent hover flicker */
916
- ctx.expanded && gapFillerHeight > 0 && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
917
- position: "absolute",
918
- left: 0,
919
- right: 0,
920
- height: gapFillerHeight,
921
- pointerEvents: "auto",
922
- ...(isTop ? {
923
- top: "100%"
924
- } : {
925
- bottom: "100%"
926
- })
927
- }), /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastItemContext.Provider, {
928
- value: itemContextValue,
929
- children
930
- })]
931
- })
932
- })
933
- });
565
+ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastItemFrame, function ToastItem(props, ref) {
566
+ var { toast, index, children, ...rest } = props;
567
+ var ctx = useToastContext("Toast.Item");
568
+ var [mounted, setMounted] = React.useState(false);
569
+ var [removed, setRemoved] = React.useState(false);
570
+ var [swipeOut, setSwipeOut] = React.useState(false);
571
+ var [offsetBeforeRemove, setOffsetBeforeRemove] = React.useState(0);
572
+ var swipeExitYRef = React.useRef(null);
573
+ var closeTimerRef = React.useRef(null);
574
+ var closeTimerStartRef = React.useRef(0);
575
+ var lastPauseTimeRef = React.useRef(0);
576
+ var _toast_duration;
577
+ var remainingTimeRef = React.useRef((_toast_duration = toast.duration) !== null && _toast_duration !== void 0 ? _toast_duration : ctx.duration);
578
+ var isFront = index === 0;
579
+ var isVisible = index < ctx.visibleToasts;
580
+ var _toast_type;
581
+ var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
582
+ var dismissible = toast.dismissible !== false;
583
+ var _toast_duration1;
584
+ var duration = (_toast_duration1 = toast.duration) !== null && _toast_duration1 !== void 0 ? _toast_duration1 : ctx.duration;
585
+ var [yPosition] = ctx.position.split("-");
586
+ var isTop = yPosition === "top";
587
+ var expandedOffset = import_constants.isWeb ? (function() {
588
+ var totalHeight = 0;
589
+ var activeCount = 0;
590
+ for (var i = 0; i < index; i++) {
591
+ var _ctx_toasts_i;
592
+ var toastId = (_ctx_toasts_i = ctx.toasts[i]) === null || _ctx_toasts_i === void 0 ? void 0 : _ctx_toasts_i.id;
593
+ if (toastId == null) continue;
594
+ var h2 = ctx.heights[toastId];
595
+ if (h2 === 0) continue;
596
+ totalHeight += h2 !== null && h2 !== void 0 ? h2 : ctx.toastHeight;
597
+ activeCount++;
598
+ }
599
+ return totalHeight + activeCount * ctx.gap;
600
+ })() : index * (ctx.toastHeight + ctx.gap);
601
+ var expandedOffsetRef = React.useRef(expandedOffset);
602
+ expandedOffsetRef.current = expandedOffset;
603
+ var isExpandedRef = React.useRef(ctx.expanded);
604
+ isExpandedRef.current = ctx.expanded;
605
+ var startTimer = React.useCallback(function() {
606
+ if (duration === Number.POSITIVE_INFINITY || toastType === "loading") return;
607
+ closeTimerStartRef.current = Date.now();
608
+ closeTimerRef.current = setTimeout(function() {
609
+ var _toast_onAutoClose;
610
+ (_toast_onAutoClose = toast.onAutoClose) === null || _toast_onAutoClose === void 0 ? void 0 : _toast_onAutoClose.call(toast, toast);
611
+ setRemoved(true);
612
+ setTimeout(function() {
613
+ return ctx.removeToast(toast);
614
+ }, TIME_BEFORE_UNMOUNT);
615
+ }, remainingTimeRef.current);
616
+ }, [
617
+ duration,
618
+ toastType,
619
+ toast,
620
+ ctx.removeToast
621
+ ]);
622
+ var pauseTimer = (0, import_core2.useEvent)(function() {
623
+ if (closeTimerRef.current) {
624
+ clearTimeout(closeTimerRef.current);
625
+ }
626
+ if (lastPauseTimeRef.current < closeTimerStartRef.current) {
627
+ var elapsed = Date.now() - closeTimerStartRef.current;
628
+ remainingTimeRef.current = Math.max(0, remainingTimeRef.current - elapsed);
629
+ }
630
+ lastPauseTimeRef.current = Date.now();
631
+ });
632
+ var resumeTimer = (0, import_core2.useEvent)(function() {
633
+ if (ctx.expanded || ctx.interacting) return;
634
+ remainingTimeRef.current = duration;
635
+ startTimer();
636
+ });
637
+ React.useEffect(function() {
638
+ setMounted(true);
639
+ }, []);
640
+ React.useEffect(function() {
641
+ if (toast.delete) {
642
+ setRemoved(true);
643
+ if (isExpandedRef.current) {
644
+ setOffsetBeforeRemove(expandedOffsetRef.current);
645
+ }
646
+ setTimeout(function() {
647
+ return ctx.removeToast(toast);
648
+ }, TIME_BEFORE_UNMOUNT);
649
+ }
650
+ }, [
651
+ toast.delete,
652
+ toast,
653
+ ctx.removeToast
654
+ ]);
655
+ React.useEffect(function() {
656
+ if (ctx.expanded || ctx.interacting) {
657
+ pauseTimer();
658
+ } else {
659
+ startTimer();
660
+ }
661
+ return function() {
662
+ if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
663
+ };
664
+ }, [
665
+ ctx.expanded,
666
+ ctx.interacting,
667
+ startTimer
668
+ ]);
669
+ React.useEffect(function() {
670
+ remainingTimeRef.current = duration;
671
+ }, [duration]);
672
+ var { setDragOffset, springBack, animateOut, animatedStyle, AnimatedView, dragRef } = (0, import_useToastAnimations.useToastAnimations)({ reducedMotion: ctx.reducedMotion });
673
+ var { isDragging, gestureHandlers, gesture } = (0, import_useAnimatedDragGesture.useAnimatedDragGesture)({
674
+ direction: ctx.swipeDirection,
675
+ threshold: ctx.swipeThreshold,
676
+ disabled: !dismissible || toastType === "loading",
677
+ expanded: ctx.expanded,
678
+ onDragStart: pauseTimer,
679
+ onDragMove: setDragOffset,
680
+ onDismiss: function(exitDirection, velocity) {
681
+ var _toast_onDismiss;
682
+ ctx.triggerDismissCooldown();
683
+ setSwipeOut(true);
684
+ (_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
685
+ swipeExitYRef.current = isExpandedRef.current ? isTop ? expandedOffsetRef.current : -expandedOffsetRef.current : isFront ? 0 : isTop ? ctx.gap * index : -ctx.gap * index;
686
+ setRemoved(true);
687
+ ctx.removeToast(toast);
688
+ animateOut(exitDirection, velocity);
689
+ },
690
+ onCancel: function() {
691
+ springBack(function() {
692
+ resumeTimer();
693
+ });
694
+ }
695
+ });
696
+ var handleLayout = React.useCallback(function(event) {
697
+ if (!import_constants.isWeb) return;
698
+ if (removed) return;
699
+ if (!ctx.expanded && index !== 0) return;
700
+ var { height } = event.nativeEvent.layout;
701
+ ctx.setToastHeight(toast.id, height);
702
+ }, [
703
+ toast.id,
704
+ ctx.setToastHeight,
705
+ index,
706
+ ctx.expanded,
707
+ removed
708
+ ]);
709
+ React.useEffect(function() {
710
+ if (!import_constants.isWeb) return;
711
+ return function() {
712
+ ctx.removeToastHeight(toast.id);
713
+ };
714
+ }, [toast.id, ctx.removeToastHeight]);
715
+ var handleClose = React.useCallback(function() {
716
+ var _toast_onDismiss;
717
+ if (!dismissible) return;
718
+ ctx.triggerDismissCooldown();
719
+ (_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
720
+ setRemoved(true);
721
+ if (isExpandedRef.current) {
722
+ setOffsetBeforeRemove(expandedOffsetRef.current);
723
+ }
724
+ setTimeout(function() {
725
+ return ctx.removeToast(toast);
726
+ }, TIME_BEFORE_UNMOUNT);
727
+ }, [
728
+ dismissible,
729
+ toast,
730
+ ctx.removeToast,
731
+ ctx.triggerDismissCooldown
732
+ ]);
733
+ var itemContextValue = React.useMemo(function() {
734
+ return {
735
+ toast,
736
+ handleClose
737
+ };
738
+ }, [toast, handleClose]);
739
+ var frontToastHeight = -1;
740
+ if (import_constants.isWeb) {
741
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
742
+ try {
743
+ for (var _iterator = ctx.toasts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
744
+ var t = _step.value;
745
+ var h = ctx.heights[t.id];
746
+ if (h != null && h > 0) {
747
+ frontToastHeight = h;
748
+ break;
749
+ }
750
+ }
751
+ } catch (err) {
752
+ _didIteratorError = true;
753
+ _iteratorError = err;
754
+ } finally {
755
+ try {
756
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
757
+ _iterator.return();
758
+ }
759
+ } finally {
760
+ if (_didIteratorError) {
761
+ throw _iteratorError;
762
+ }
763
+ }
764
+ }
765
+ }
766
+ var stackScale = !ctx.expanded && !isFront ? 1 - index * .05 : 1;
767
+ var activeExpandedOffset = removed ? offsetBeforeRemove : expandedOffset;
768
+ var stackY = ctx.expanded ? isTop ? activeExpandedOffset : -activeExpandedOffset : isFront ? 0 : isTop ? ctx.gap * index : -ctx.gap * index;
769
+ var computedOpacity = removed && !swipeOut ? 0 : index >= ctx.visibleToasts ? 0 : 1;
770
+ var computedZIndex = removed ? 0 : ctx.visibleToasts - index + 1;
771
+ var computedHeight = import_constants.isWeb ? ctx.expanded ? ctx.heights[toast.id] || void 0 : !isFront && frontToastHeight > 0 ? frontToastHeight : void 0 : void 0;
772
+ var computedPointerEvents = index >= ctx.visibleToasts ? "none" : "auto";
773
+ var gapFillerHeight = ctx.expanded ? ctx.gap + 1 : 0;
774
+ var dataAttributes = {
775
+ "data-mounted": mounted ? "true" : "false",
776
+ "data-removed": removed ? "true" : "false",
777
+ "data-swipe-out": swipeOut ? "true" : "false",
778
+ "data-visible": isVisible ? "true" : "false",
779
+ "data-front": isFront ? "true" : "false",
780
+ "data-index": String(index),
781
+ "data-type": toastType,
782
+ "data-expanded": ctx.expanded ? "true" : "false"
783
+ };
784
+ var _swipeExitYRef_current;
785
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastPositionWrapper, {
786
+ ref,
787
+ testID: rest.testID,
788
+ "aria-label": rest["aria-label"],
789
+ ...dataAttributes,
790
+ transition: isDragging || ctx.reducedMotion ? void 0 : removed ? "200ms" : "400ms",
791
+ y: ctx.reducedMotion ? stackY : `${stackY} enter:${isTop ? -80 : 80}px exit:${swipeOut ? (_swipeExitYRef_current = swipeExitYRef.current) !== null && _swipeExitYRef_current !== void 0 ? _swipeExitYRef_current : stackY : stackY}px`,
792
+ scale: stackScale,
793
+ opacity: `${computedOpacity} enter:0 exit:0`,
794
+ zIndex: computedZIndex,
795
+ height: computedHeight,
796
+ overflow: "visible",
797
+ pointerEvents: computedPointerEvents,
798
+ top: isTop ? 0 : void 0,
799
+ bottom: isTop ? void 0 : 0,
800
+ ...import_constants.isWeb && !isFront && { style: { transformOrigin: isTop ? "top center" : "bottom center" } },
801
+ animateOnly: import_constants.isWeb ? [
802
+ "transform",
803
+ "opacity",
804
+ "height"
805
+ ] : ["transform", "opacity"],
806
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DragWrapper, {
807
+ animatedStyle,
808
+ gestureHandlers,
809
+ gesture,
810
+ AnimatedView,
811
+ dragRef,
812
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ToastItemFrame.ToastItemFrame, {
813
+ role: "status",
814
+ "aria-live": "polite",
815
+ "aria-atomic": true,
816
+ tabIndex: 0,
817
+ onLayout: handleLayout,
818
+ ...import_constants.isWeb && { onKeyDown: function(event) {
819
+ if (event.key === "Escape" && dismissible) {
820
+ var current = event.currentTarget;
821
+ var container = current.closest("[aria-label]");
822
+ if (container) {
823
+ var focusables = container.querySelectorAll("[tabindex=\"0\"]");
824
+ var arr = Array.from(focusables);
825
+ var idx = arr.indexOf(current);
826
+ var next = arr[idx + 1] || arr[idx - 1];
827
+ next === null || next === void 0 ? void 0 : next.focus();
828
+ }
829
+ handleClose();
830
+ }
831
+ } },
832
+ ...rest,
833
+ children: [ctx.expanded && gapFillerHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
834
+ position: "absolute",
835
+ left: 0,
836
+ right: 0,
837
+ height: gapFillerHeight,
838
+ pointerEvents: "auto",
839
+ ...isTop ? { top: "100%" } : { bottom: "100%" }
840
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastItemContext.Provider, {
841
+ value: itemContextValue,
842
+ children
843
+ })]
844
+ })
845
+ })
846
+ });
934
847
  });
935
- var ToastTitle = (0, import_core.styled)(import_text.SizableText, {
936
- name: "ToastTitle",
937
- variants: {
938
- unstyled: {
939
- false: {
940
- color: "$color",
941
- fontWeight: "600",
942
- size: "$4"
943
- }
944
- }
945
- },
946
- defaultVariants: {
947
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
948
- }
848
+ var ToastTitle = (0, import_core2.styled)(import_text.SizableText, { displayName: "ToastTitle" });
849
+ var ToastDescription = (0, import_core2.styled)(import_text.SizableText, { displayName: "ToastDescription" });
850
+ var ToastClose = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastCloseFrame, function ToastClose2(props, ref) {
851
+ var _ctx_icons;
852
+ var handleClose;
853
+ try {
854
+ var itemCtx = useToastItemContext();
855
+ handleClose = itemCtx.handleClose;
856
+ } catch (e) {}
857
+ var ctx = useToastContext("Toast.Close");
858
+ var _props_children, _ref;
859
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastCloseFrame, {
860
+ ref,
861
+ "aria-label": "Close toast",
862
+ onPress: handleClose,
863
+ ...props,
864
+ children: (_ref = (_props_children = props.children) !== null && _props_children !== void 0 ? _props_children : (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons.close) !== null && _ref !== void 0 ? _ref : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.DefaultCloseIcon, {})
865
+ });
949
866
  });
950
- var ToastDescription = (0, import_core.styled)(import_text.SizableText, {
951
- name: "ToastDescription",
952
- variants: {
953
- unstyled: {
954
- false: {
955
- color: "$color11",
956
- size: "$2"
957
- }
958
- }
959
- },
960
- defaultVariants: {
961
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
962
- }
963
- });
964
- var ToastClose = import_ToastItemFrame.ToastCloseFrame.styleable(function ToastClose2(props, ref) {
965
- var _ctx_icons;
966
- var handleClose;
967
- try {
968
- var itemCtx = useToastItemContext();
969
- handleClose = itemCtx.handleClose;
970
- } catch (e) {}
971
- var ctx = useToastContext("Toast.Close");
972
- var _props_children, _ref;
973
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastCloseFrame, {
974
- ref,
975
- "aria-label": "Close toast",
976
- onPress: handleClose,
977
- ...props,
978
- children: (_ref = (_props_children = props.children) !== null && _props_children !== void 0 ? _props_children : (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons.close) !== null && _ref !== void 0 ? _ref : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastItemFrame.DefaultCloseIcon, {})
979
- });
980
- });
981
- var ToastAction = import_ToastItemFrame.ToastActionFrame.styleable(function ToastAction2(props, ref) {
982
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
983
- ref,
984
- ...props
985
- });
867
+ var ToastAction = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastActionFrame, function ToastAction2(props, ref) {
868
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
869
+ ref,
870
+ ...props
871
+ });
986
872
  });
987
873
  function ToastIcon(props) {
988
- var _ctx_icons;
989
- var ctx = useToastContext("Toast.Icon");
990
- var toast;
991
- try {
992
- var itemCtx = useToastItemContext();
993
- toast = itemCtx.toast;
994
- } catch (e) {
995
- return null;
996
- }
997
- if (!toast) return null;
998
- if (toast.icon !== void 0) {
999
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
1000
- flexShrink: 0,
1001
- marginTop: "$0.5",
1002
- children: toast.icon
1003
- });
1004
- }
1005
- var _toast_type;
1006
- var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
1007
- var _ctx_icons_toastType;
1008
- var icon = (_ctx_icons_toastType = (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons[toastType]) !== null && _ctx_icons_toastType !== void 0 ? _ctx_icons_toastType : null;
1009
- if (!icon) return null;
1010
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
1011
- flexShrink: 0,
1012
- marginTop: "$0.5",
1013
- children: icon
1014
- });
874
+ var _ctx_icons;
875
+ var ctx = useToastContext("Toast.Icon");
876
+ var toast;
877
+ try {
878
+ var itemCtx = useToastItemContext();
879
+ toast = itemCtx.toast;
880
+ } catch (e) {
881
+ return null;
882
+ }
883
+ if (!toast) return null;
884
+ if (toast.icon !== void 0) {
885
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
886
+ flexShrink: 0,
887
+ marginTop: "0-5",
888
+ children: toast.icon
889
+ });
890
+ }
891
+ var _toast_type;
892
+ var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
893
+ var _ctx_icons_toastType;
894
+ var icon = (_ctx_icons_toastType = (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons[toastType]) !== null && _ctx_icons_toastType !== void 0 ? _ctx_icons_toastType : null;
895
+ if (!icon) return null;
896
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
897
+ flexShrink: 0,
898
+ marginTop: "0-5",
899
+ children: icon
900
+ });
1015
901
  }
1016
902
  function useToasts() {
1017
- var ctx = useToastContext("useToasts");
1018
- return {
1019
- toasts: ctx.toasts,
1020
- expanded: ctx.expanded,
1021
- position: ctx.position
1022
- };
903
+ var ctx = useToastContext("useToasts");
904
+ return {
905
+ toasts: ctx.toasts,
906
+ expanded: ctx.expanded,
907
+ position: ctx.position,
908
+ closeButton: ctx.closeButton
909
+ };
1023
910
  }
1024
911
  function useToastItem() {
1025
- return useToastItemContext();
912
+ return useToastItemContext();
1026
913
  }
1027
914
  ToastRoot.displayName = "Toast";
1028
915
  var Toast = (0, import_helpers.withStaticProperties)(ToastRoot, {
1029
- Viewport: ToastViewport,
1030
- List: ToastList,
1031
- Item: ToastItemInner,
1032
- Title: ToastTitle,
1033
- Description: ToastDescription,
1034
- Close: ToastClose,
1035
- Action: ToastAction,
1036
- Icon: ToastIcon
916
+ Viewport: ToastViewport,
917
+ List: ToastList,
918
+ Item: ToastItemInner,
919
+ Title: ToastTitle,
920
+ Description: ToastDescription,
921
+ Close: ToastClose,
922
+ Action: ToastAction,
923
+ Icon: ToastIcon
1037
924
  });
925
+
1038
926
  //# sourceMappingURL=ToastComposable.native.js.map