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