@tamagui/toast 2.0.0-rc.9 → 2.0.0

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