@hanzogui/toast 8.3.1 → 8.3.3

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 (400) hide show
  1. package/dist/cjs/Toast.js +122 -0
  2. package/dist/cjs/Toast.js.map +1 -0
  3. package/dist/cjs/ToastAnnounce.js +55 -0
  4. package/dist/cjs/ToastAnnounce.js.map +1 -0
  5. package/dist/cjs/ToastComposable.js +849 -0
  6. package/dist/cjs/ToastComposable.js.map +1 -0
  7. package/dist/cjs/ToastImperative.js +90 -0
  8. package/dist/cjs/ToastImperative.js.map +1 -0
  9. package/dist/cjs/ToastImpl.js +307 -0
  10. package/dist/cjs/ToastImpl.js.map +1 -0
  11. package/dist/cjs/ToastItemFrame.js +121 -0
  12. package/dist/cjs/ToastItemFrame.js.map +1 -0
  13. package/dist/cjs/ToastPortal.js +16 -0
  14. package/dist/cjs/ToastPortal.js.map +1 -0
  15. package/dist/cjs/ToastProvider.js +72 -0
  16. package/dist/cjs/ToastProvider.js.map +1 -0
  17. package/dist/cjs/ToastState.js +284 -0
  18. package/dist/cjs/ToastState.js.map +1 -0
  19. package/dist/cjs/ToastViewport.js +289 -0
  20. package/dist/cjs/ToastViewport.js.map +1 -0
  21. package/dist/cjs/Toaster.js +13 -0
  22. package/dist/cjs/Toaster.js.map +1 -0
  23. package/dist/cjs/constants.js +6 -0
  24. package/dist/cjs/constants.js.map +1 -0
  25. package/dist/cjs/createNativeToast.js +42 -0
  26. package/dist/cjs/createNativeToast.js.map +1 -0
  27. package/dist/cjs/dispatchNativeToast.js +31 -0
  28. package/dist/cjs/dispatchNativeToast.js.map +1 -0
  29. package/dist/cjs/index.js +5 -0
  30. package/dist/cjs/index.js.map +1 -0
  31. package/dist/cjs/package.json +1 -0
  32. package/dist/cjs/types.js +3 -0
  33. package/dist/cjs/types.js.map +1 -0
  34. package/dist/cjs/useAnimatedDragGesture.js +251 -0
  35. package/dist/cjs/useAnimatedDragGesture.js.map +1 -0
  36. package/dist/cjs/useReducedMotion.js +52 -0
  37. package/dist/cjs/useReducedMotion.js.map +1 -0
  38. package/dist/cjs/useToastAnimations.js +252 -0
  39. package/dist/cjs/useToastAnimations.js.map +1 -0
  40. package/dist/cjs/v2.js +17 -0
  41. package/dist/cjs/v2.js.map +1 -0
  42. package/dist/esm/Toast.js +117 -0
  43. package/dist/esm/Toast.js.map +1 -0
  44. package/dist/esm/ToastAnnounce.js +50 -0
  45. package/dist/esm/ToastAnnounce.js.map +1 -0
  46. package/dist/esm/ToastComposable.js +843 -0
  47. package/dist/esm/ToastComposable.js.map +1 -0
  48. package/dist/esm/ToastImperative.js +82 -0
  49. package/dist/esm/ToastImperative.js.map +1 -0
  50. package/dist/esm/ToastImpl.js +301 -0
  51. package/dist/esm/ToastImpl.js.map +1 -0
  52. package/dist/esm/ToastItemFrame.js +117 -0
  53. package/dist/esm/ToastItemFrame.js.map +1 -0
  54. package/dist/esm/ToastPortal.js +13 -0
  55. package/dist/esm/ToastPortal.js.map +1 -0
  56. package/dist/esm/ToastProvider.js +64 -0
  57. package/dist/esm/ToastProvider.js.map +1 -0
  58. package/dist/esm/ToastState.js +281 -0
  59. package/dist/esm/ToastState.js.map +1 -0
  60. package/dist/esm/ToastViewport.js +282 -0
  61. package/dist/esm/ToastViewport.js.map +1 -0
  62. package/dist/esm/Toaster.js +9 -0
  63. package/dist/esm/Toaster.js.map +1 -0
  64. package/dist/esm/constants.js +3 -0
  65. package/dist/esm/constants.js.map +1 -0
  66. package/dist/esm/createNativeToast.js +36 -0
  67. package/dist/esm/createNativeToast.js.map +1 -0
  68. package/dist/esm/dispatchNativeToast.js +28 -0
  69. package/dist/esm/dispatchNativeToast.js.map +1 -0
  70. package/dist/esm/index.js +2 -2
  71. package/dist/esm/index.js.map +1 -1
  72. package/dist/esm/types.js +2 -0
  73. package/dist/esm/types.js.map +1 -0
  74. package/dist/esm/useAnimatedDragGesture.js +247 -0
  75. package/dist/esm/useAnimatedDragGesture.js.map +1 -0
  76. package/dist/esm/useReducedMotion.js +48 -0
  77. package/dist/esm/useReducedMotion.js.map +1 -0
  78. package/dist/esm/useToastAnimations.js +248 -0
  79. package/dist/esm/useToastAnimations.js.map +1 -0
  80. package/dist/esm/v2.js +8 -0
  81. package/dist/esm/v2.js.map +1 -0
  82. package/dist/native/Toast.js +117 -0
  83. package/dist/native/Toast.js.map +1 -0
  84. package/dist/native/ToastAnnounce.js +50 -0
  85. package/dist/native/ToastAnnounce.js.map +1 -0
  86. package/dist/native/ToastComposable.js +843 -0
  87. package/dist/native/ToastComposable.js.map +1 -0
  88. package/dist/native/ToastImperative.js +82 -0
  89. package/dist/native/ToastImperative.js.map +1 -0
  90. package/dist/native/ToastImpl.js +301 -0
  91. package/dist/native/ToastImpl.js.map +1 -0
  92. package/dist/native/ToastItemFrame.js +117 -0
  93. package/dist/native/ToastItemFrame.js.map +1 -0
  94. package/dist/native/ToastPortal.js +13 -0
  95. package/dist/native/ToastPortal.js.map +1 -0
  96. package/dist/native/ToastProvider.js +64 -0
  97. package/dist/native/ToastProvider.js.map +1 -0
  98. package/dist/native/ToastState.js +281 -0
  99. package/dist/native/ToastState.js.map +1 -0
  100. package/dist/native/ToastViewport.js +282 -0
  101. package/dist/native/ToastViewport.js.map +1 -0
  102. package/dist/native/Toaster.js +9 -0
  103. package/dist/native/Toaster.js.map +1 -0
  104. package/dist/native/constants.js +3 -0
  105. package/dist/native/constants.js.map +1 -0
  106. package/dist/native/createNativeToast.js +25 -0
  107. package/dist/native/createNativeToast.js.map +1 -0
  108. package/dist/native/dispatchNativeToast.js +28 -0
  109. package/dist/native/dispatchNativeToast.js.map +1 -0
  110. package/dist/native/index.js +2 -0
  111. package/dist/native/index.js.map +1 -0
  112. package/dist/native/types.js +2 -0
  113. package/dist/native/types.js.map +1 -0
  114. package/dist/native/useAnimatedDragGesture.js +210 -0
  115. package/dist/native/useAnimatedDragGesture.js.map +1 -0
  116. package/dist/native/useReducedMotion.js +48 -0
  117. package/dist/native/useReducedMotion.js.map +1 -0
  118. package/dist/native/useToastAnimations.js +248 -0
  119. package/dist/native/useToastAnimations.js.map +1 -0
  120. package/dist/native/v2.js +8 -0
  121. package/dist/native/v2.js.map +1 -0
  122. package/package.json +48 -44
  123. package/src/Toast.tsx +9 -9
  124. package/src/ToastAnnounce.tsx +2 -2
  125. package/src/ToastComposable.tsx +9 -9
  126. package/src/ToastImperative.tsx +2 -2
  127. package/src/ToastImpl.tsx +5 -5
  128. package/src/ToastPortal.tsx +4 -1
  129. package/src/ToastProvider.tsx +4 -4
  130. package/src/ToastState.ts +1 -1
  131. package/src/ToastViewport.tsx +4 -4
  132. package/src/Toaster.tsx +5 -5
  133. package/src/createNativeToast.native.tsx +1 -1
  134. package/src/createNativeToast.tsx +1 -1
  135. package/src/dispatchNativeToast.ts +3 -3
  136. package/src/index.ts +7 -3
  137. package/src/useAnimatedDragGesture.native.ts +1 -1
  138. package/src/useAnimatedDragGesture.ts +1 -1
  139. package/src/v2.ts +13 -9
  140. package/types/Toast.d.ts +19 -19
  141. package/types/Toast.d.ts.map +1 -1
  142. package/types/ToastAnnounce.d.ts +1 -1
  143. package/types/ToastAnnounce.d.ts.map +1 -1
  144. package/types/ToastComposable.d.ts +14 -14
  145. package/types/ToastComposable.d.ts.map +1 -1
  146. package/types/ToastImperative.d.ts +3 -3
  147. package/types/ToastImperative.d.ts.map +1 -1
  148. package/types/ToastImpl.d.ts +7 -7
  149. package/types/ToastImpl.d.ts.map +1 -1
  150. package/types/ToastItemFrame.d.ts +4 -4
  151. package/types/ToastItemFrame.d.ts.map +1 -1
  152. package/types/ToastPortal.d.ts +2 -2
  153. package/types/ToastPortal.d.ts.map +1 -1
  154. package/types/ToastProvider.d.ts +3 -3
  155. package/types/ToastProvider.d.ts.map +1 -1
  156. package/types/ToastState.d.ts +15 -12
  157. package/types/ToastState.d.ts.map +1 -1
  158. package/types/ToastViewport.d.ts +5 -5
  159. package/types/Toaster.d.ts +4 -4
  160. package/types/Toaster.d.ts.map +1 -1
  161. package/types/createNativeToast.d.ts +1 -1
  162. package/types/createNativeToast.d.ts.map +1 -1
  163. package/types/createNativeToast.native.d.ts +1 -1
  164. package/types/createNativeToast.native.d.ts.map +1 -1
  165. package/types/dispatchNativeToast.d.ts +2 -2
  166. package/types/dispatchNativeToast.d.ts.map +1 -1
  167. package/types/index.d.ts +3 -3
  168. package/types/index.d.ts.map +1 -1
  169. package/types/useAnimatedDragGesture.d.ts +1 -1
  170. package/types/useAnimatedDragGesture.d.ts.map +1 -1
  171. package/types/useAnimatedDragGesture.native.d.ts +1 -1
  172. package/types/useAnimatedDragGesture.native.d.ts.map +1 -1
  173. package/types/v2.d.ts +9 -9
  174. package/types/v2.d.ts.map +1 -1
  175. package/dist/cjs/Toast.cjs +0 -178
  176. package/dist/cjs/Toast.native.js +0 -181
  177. package/dist/cjs/Toast.native.js.map +0 -1
  178. package/dist/cjs/ToastAnnounce.cjs +0 -103
  179. package/dist/cjs/ToastAnnounce.native.js +0 -111
  180. package/dist/cjs/ToastAnnounce.native.js.map +0 -1
  181. package/dist/cjs/ToastComposable.cjs +0 -947
  182. package/dist/cjs/ToastComposable.native.js +0 -1055
  183. package/dist/cjs/ToastComposable.native.js.map +0 -1
  184. package/dist/cjs/ToastImperative.cjs +0 -119
  185. package/dist/cjs/ToastImperative.native.js +0 -130
  186. package/dist/cjs/ToastImperative.native.js.map +0 -1
  187. package/dist/cjs/ToastImpl.cjs +0 -354
  188. package/dist/cjs/ToastImpl.native.js +0 -364
  189. package/dist/cjs/ToastImpl.native.js.map +0 -1
  190. package/dist/cjs/ToastItemFrame.cjs +0 -143
  191. package/dist/cjs/ToastItemFrame.native.js +0 -148
  192. package/dist/cjs/ToastItemFrame.native.js.map +0 -1
  193. package/dist/cjs/ToastPortal.cjs +0 -49
  194. package/dist/cjs/ToastPortal.native.js +0 -52
  195. package/dist/cjs/ToastPortal.native.js.map +0 -1
  196. package/dist/cjs/ToastProvider.cjs +0 -150
  197. package/dist/cjs/ToastProvider.native.js +0 -161
  198. package/dist/cjs/ToastProvider.native.js.map +0 -1
  199. package/dist/cjs/ToastState.cjs +0 -311
  200. package/dist/cjs/ToastState.native.js +0 -324
  201. package/dist/cjs/ToastState.native.js.map +0 -1
  202. package/dist/cjs/ToastViewport.cjs +0 -319
  203. package/dist/cjs/ToastViewport.native.js +0 -343
  204. package/dist/cjs/ToastViewport.native.js.map +0 -1
  205. package/dist/cjs/Toaster.cjs +0 -87
  206. package/dist/cjs/Toaster.native.js +0 -91
  207. package/dist/cjs/Toaster.native.js.map +0 -1
  208. package/dist/cjs/constants.cjs +0 -30
  209. package/dist/cjs/constants.native.js +0 -33
  210. package/dist/cjs/constants.native.js.map +0 -1
  211. package/dist/cjs/createNativeToast.cjs +0 -59
  212. package/dist/cjs/createNativeToast.native.js +0 -60
  213. package/dist/cjs/createNativeToast.native.js.map +0 -1
  214. package/dist/cjs/dispatchNativeToast.cjs +0 -47
  215. package/dist/cjs/dispatchNativeToast.native.js +0 -52
  216. package/dist/cjs/dispatchNativeToast.native.js.map +0 -1
  217. package/dist/cjs/index.cjs +0 -20
  218. package/dist/cjs/index.native.js +0 -23
  219. package/dist/cjs/index.native.js.map +0 -1
  220. package/dist/cjs/types.cjs +0 -18
  221. package/dist/cjs/types.native.js +0 -21
  222. package/dist/cjs/types.native.js.map +0 -1
  223. package/dist/cjs/useAnimatedDragGesture.cjs +0 -214
  224. package/dist/cjs/useAnimatedDragGesture.native.js +0 -224
  225. package/dist/cjs/useAnimatedDragGesture.native.js.map +0 -1
  226. package/dist/cjs/useReducedMotion.cjs +0 -74
  227. package/dist/cjs/useReducedMotion.native.js +0 -83
  228. package/dist/cjs/useReducedMotion.native.js.map +0 -1
  229. package/dist/cjs/useToastAnimations.cjs +0 -292
  230. package/dist/cjs/useToastAnimations.native.js +0 -302
  231. package/dist/cjs/useToastAnimations.native.js.map +0 -1
  232. package/dist/cjs/v2.cjs +0 -36
  233. package/dist/cjs/v2.native.js +0 -39
  234. package/dist/cjs/v2.native.js.map +0 -1
  235. package/dist/esm/Toast.mjs +0 -137
  236. package/dist/esm/Toast.mjs.map +0 -1
  237. package/dist/esm/Toast.native.js +0 -137
  238. package/dist/esm/Toast.native.js.map +0 -1
  239. package/dist/esm/ToastAnnounce.mjs +0 -66
  240. package/dist/esm/ToastAnnounce.mjs.map +0 -1
  241. package/dist/esm/ToastAnnounce.native.js +0 -71
  242. package/dist/esm/ToastAnnounce.native.js.map +0 -1
  243. package/dist/esm/ToastComposable.mjs +0 -909
  244. package/dist/esm/ToastComposable.mjs.map +0 -1
  245. package/dist/esm/ToastComposable.native.js +0 -1014
  246. package/dist/esm/ToastComposable.native.js.map +0 -1
  247. package/dist/esm/ToastImperative.mjs +0 -80
  248. package/dist/esm/ToastImperative.mjs.map +0 -1
  249. package/dist/esm/ToastImperative.native.js +0 -88
  250. package/dist/esm/ToastImperative.native.js.map +0 -1
  251. package/dist/esm/ToastImpl.mjs +0 -316
  252. package/dist/esm/ToastImpl.mjs.map +0 -1
  253. package/dist/esm/ToastImpl.native.js +0 -329
  254. package/dist/esm/ToastImpl.native.js.map +0 -1
  255. package/dist/esm/ToastItemFrame.mjs +0 -114
  256. package/dist/esm/ToastItemFrame.mjs.map +0 -1
  257. package/dist/esm/ToastItemFrame.native.js +0 -116
  258. package/dist/esm/ToastItemFrame.native.js.map +0 -1
  259. package/dist/esm/ToastPortal.mjs +0 -24
  260. package/dist/esm/ToastPortal.mjs.map +0 -1
  261. package/dist/esm/ToastPortal.native.js +0 -24
  262. package/dist/esm/ToastPortal.native.js.map +0 -1
  263. package/dist/esm/ToastProvider.mjs +0 -110
  264. package/dist/esm/ToastProvider.mjs.map +0 -1
  265. package/dist/esm/ToastProvider.native.js +0 -118
  266. package/dist/esm/ToastProvider.native.js.map +0 -1
  267. package/dist/esm/ToastState.mjs +0 -285
  268. package/dist/esm/ToastState.mjs.map +0 -1
  269. package/dist/esm/ToastState.native.js +0 -295
  270. package/dist/esm/ToastState.native.js.map +0 -1
  271. package/dist/esm/ToastViewport.mjs +0 -280
  272. package/dist/esm/ToastViewport.mjs.map +0 -1
  273. package/dist/esm/ToastViewport.native.js +0 -301
  274. package/dist/esm/ToastViewport.native.js.map +0 -1
  275. package/dist/esm/Toaster.mjs +0 -51
  276. package/dist/esm/Toaster.mjs.map +0 -1
  277. package/dist/esm/Toaster.native.js +0 -52
  278. package/dist/esm/Toaster.native.js.map +0 -1
  279. package/dist/esm/constants.mjs +0 -4
  280. package/dist/esm/constants.mjs.map +0 -1
  281. package/dist/esm/constants.native.js +0 -4
  282. package/dist/esm/constants.native.js.map +0 -1
  283. package/dist/esm/createNativeToast.mjs +0 -32
  284. package/dist/esm/createNativeToast.mjs.map +0 -1
  285. package/dist/esm/createNativeToast.native.js +0 -30
  286. package/dist/esm/createNativeToast.native.js.map +0 -1
  287. package/dist/esm/dispatchNativeToast.mjs +0 -22
  288. package/dist/esm/dispatchNativeToast.mjs.map +0 -1
  289. package/dist/esm/dispatchNativeToast.native.js +0 -24
  290. package/dist/esm/dispatchNativeToast.native.js.map +0 -1
  291. package/dist/esm/index.mjs +0 -2
  292. package/dist/esm/index.mjs.map +0 -1
  293. package/dist/esm/index.native.js +0 -2
  294. package/dist/esm/index.native.js.map +0 -1
  295. package/dist/esm/types.mjs +0 -2
  296. package/dist/esm/types.mjs.map +0 -1
  297. package/dist/esm/types.native.js +0 -2
  298. package/dist/esm/types.native.js.map +0 -1
  299. package/dist/esm/useAnimatedDragGesture.mjs +0 -178
  300. package/dist/esm/useAnimatedDragGesture.mjs.map +0 -1
  301. package/dist/esm/useAnimatedDragGesture.native.js +0 -185
  302. package/dist/esm/useAnimatedDragGesture.native.js.map +0 -1
  303. package/dist/esm/useReducedMotion.mjs +0 -38
  304. package/dist/esm/useReducedMotion.mjs.map +0 -1
  305. package/dist/esm/useReducedMotion.native.js +0 -44
  306. package/dist/esm/useReducedMotion.native.js.map +0 -1
  307. package/dist/esm/useToastAnimations.mjs +0 -256
  308. package/dist/esm/useToastAnimations.mjs.map +0 -1
  309. package/dist/esm/useToastAnimations.native.js +0 -263
  310. package/dist/esm/useToastAnimations.native.js.map +0 -1
  311. package/dist/esm/v2.mjs +0 -6
  312. package/dist/esm/v2.mjs.map +0 -1
  313. package/dist/esm/v2.native.js +0 -6
  314. package/dist/esm/v2.native.js.map +0 -1
  315. package/dist/jsx/Toast.mjs +0 -137
  316. package/dist/jsx/Toast.mjs.map +0 -1
  317. package/dist/jsx/Toast.native.js +0 -181
  318. package/dist/jsx/Toast.native.js.map +0 -1
  319. package/dist/jsx/ToastAnnounce.mjs +0 -66
  320. package/dist/jsx/ToastAnnounce.mjs.map +0 -1
  321. package/dist/jsx/ToastAnnounce.native.js +0 -111
  322. package/dist/jsx/ToastAnnounce.native.js.map +0 -1
  323. package/dist/jsx/ToastComposable.mjs +0 -909
  324. package/dist/jsx/ToastComposable.mjs.map +0 -1
  325. package/dist/jsx/ToastComposable.native.js +0 -1055
  326. package/dist/jsx/ToastComposable.native.js.map +0 -1
  327. package/dist/jsx/ToastImperative.mjs +0 -80
  328. package/dist/jsx/ToastImperative.mjs.map +0 -1
  329. package/dist/jsx/ToastImperative.native.js +0 -130
  330. package/dist/jsx/ToastImperative.native.js.map +0 -1
  331. package/dist/jsx/ToastImpl.mjs +0 -316
  332. package/dist/jsx/ToastImpl.mjs.map +0 -1
  333. package/dist/jsx/ToastImpl.native.js +0 -364
  334. package/dist/jsx/ToastImpl.native.js.map +0 -1
  335. package/dist/jsx/ToastItemFrame.mjs +0 -114
  336. package/dist/jsx/ToastItemFrame.mjs.map +0 -1
  337. package/dist/jsx/ToastItemFrame.native.js +0 -148
  338. package/dist/jsx/ToastItemFrame.native.js.map +0 -1
  339. package/dist/jsx/ToastPortal.mjs +0 -24
  340. package/dist/jsx/ToastPortal.mjs.map +0 -1
  341. package/dist/jsx/ToastPortal.native.js +0 -52
  342. package/dist/jsx/ToastPortal.native.js.map +0 -1
  343. package/dist/jsx/ToastProvider.mjs +0 -110
  344. package/dist/jsx/ToastProvider.mjs.map +0 -1
  345. package/dist/jsx/ToastProvider.native.js +0 -161
  346. package/dist/jsx/ToastProvider.native.js.map +0 -1
  347. package/dist/jsx/ToastState.mjs +0 -285
  348. package/dist/jsx/ToastState.mjs.map +0 -1
  349. package/dist/jsx/ToastState.native.js +0 -324
  350. package/dist/jsx/ToastState.native.js.map +0 -1
  351. package/dist/jsx/ToastViewport.mjs +0 -280
  352. package/dist/jsx/ToastViewport.mjs.map +0 -1
  353. package/dist/jsx/ToastViewport.native.js +0 -343
  354. package/dist/jsx/ToastViewport.native.js.map +0 -1
  355. package/dist/jsx/Toaster.mjs +0 -51
  356. package/dist/jsx/Toaster.mjs.map +0 -1
  357. package/dist/jsx/Toaster.native.js +0 -91
  358. package/dist/jsx/Toaster.native.js.map +0 -1
  359. package/dist/jsx/constants.mjs +0 -4
  360. package/dist/jsx/constants.mjs.map +0 -1
  361. package/dist/jsx/constants.native.js +0 -33
  362. package/dist/jsx/constants.native.js.map +0 -1
  363. package/dist/jsx/createNativeToast.mjs +0 -32
  364. package/dist/jsx/createNativeToast.mjs.map +0 -1
  365. package/dist/jsx/createNativeToast.native.js +0 -60
  366. package/dist/jsx/createNativeToast.native.js.map +0 -1
  367. package/dist/jsx/dispatchNativeToast.mjs +0 -22
  368. package/dist/jsx/dispatchNativeToast.mjs.map +0 -1
  369. package/dist/jsx/dispatchNativeToast.native.js +0 -52
  370. package/dist/jsx/dispatchNativeToast.native.js.map +0 -1
  371. package/dist/jsx/index.js +0 -2
  372. package/dist/jsx/index.js.map +0 -1
  373. package/dist/jsx/index.mjs +0 -2
  374. package/dist/jsx/index.mjs.map +0 -1
  375. package/dist/jsx/index.native.js +0 -23
  376. package/dist/jsx/index.native.js.map +0 -1
  377. package/dist/jsx/types.mjs +0 -2
  378. package/dist/jsx/types.mjs.map +0 -1
  379. package/dist/jsx/types.native.js +0 -21
  380. package/dist/jsx/types.native.js.map +0 -1
  381. package/dist/jsx/useAnimatedDragGesture.mjs +0 -178
  382. package/dist/jsx/useAnimatedDragGesture.mjs.map +0 -1
  383. package/dist/jsx/useAnimatedDragGesture.native.js +0 -224
  384. package/dist/jsx/useAnimatedDragGesture.native.js.map +0 -1
  385. package/dist/jsx/useReducedMotion.mjs +0 -38
  386. package/dist/jsx/useReducedMotion.mjs.map +0 -1
  387. package/dist/jsx/useReducedMotion.native.js +0 -83
  388. package/dist/jsx/useReducedMotion.native.js.map +0 -1
  389. package/dist/jsx/useToastAnimations.mjs +0 -256
  390. package/dist/jsx/useToastAnimations.mjs.map +0 -1
  391. package/dist/jsx/useToastAnimations.native.js +0 -302
  392. package/dist/jsx/useToastAnimations.native.js.map +0 -1
  393. package/dist/jsx/v2.mjs +0 -6
  394. package/dist/jsx/v2.mjs.map +0 -1
  395. package/dist/jsx/v2.native.js +0 -39
  396. package/dist/jsx/v2.native.js.map +0 -1
  397. package/v2/index.cjs +0 -2
  398. package/v2/index.js +0 -2
  399. package/v2/index.native.cjs +0 -2
  400. package/v2/index.native.js +0 -2
@@ -0,0 +1,843 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AnimatePresence } from '@hanzogui/animate-presence';
3
+ import { isWeb } from '@hanzogui/constants';
4
+ import { getGestureHandler } from '@hanzogui/native';
5
+ import { createStyledContext, styled, Theme, useConfiguration, useEvent, useThemeName, View, } from '@hanzogui/core';
6
+ import { withStaticProperties } from '@hanzogui/helpers';
7
+ import { Portal } from '@hanzogui/portal';
8
+ import { XStack, YStack } from '@hanzogui/stacks';
9
+ import { SizableText } from '@hanzogui/text';
10
+ import * as React from 'react';
11
+ import { ToastState } from './ToastState.js';
12
+ import { dispatchNativeToast } from './dispatchNativeToast.js';
13
+ import { useAnimatedDragGesture } from './useAnimatedDragGesture.js';
14
+ import { useToastAnimations } from './useToastAnimations.js';
15
+ import { useReducedMotion } from './useReducedMotion.js';
16
+ import { DefaultCloseIcon, ToastActionFrame, ToastCloseFrame, ToastItemFrame, ToastPositionWrapper, } from './ToastItemFrame.js';
17
+ // defaults
18
+ const VISIBLE_TOASTS_AMOUNT = 4;
19
+ const VIEWPORT_OFFSET = 16;
20
+ const TOAST_GAP = 14;
21
+ const TOAST_LIFETIME = 4000;
22
+ const FIXED_TOAST_HEIGHT = 72;
23
+ const TIME_BEFORE_UNMOUNT = 200;
24
+ const DEFAULT_HOTKEY = ['altKey', 'KeyT'];
25
+ const ToastContext = createStyledContext({}, 'Toast__');
26
+ const useToastContextValue = ToastContext.useStyledContext;
27
+ function hasToastContext(ctx) {
28
+ return (!!ctx &&
29
+ Array.isArray(ctx.toasts) &&
30
+ typeof ctx.setToastHeight === 'function' &&
31
+ typeof ctx.removeToast === 'function');
32
+ }
33
+ function useToastContext(consumerName) {
34
+ const ctx = useToastContextValue();
35
+ if (!hasToastContext(ctx)) {
36
+ throw new Error(`\`${consumerName}\` must be used within \`Toast\``);
37
+ }
38
+ return ctx;
39
+ }
40
+ const ToastItemContext = React.createContext(null);
41
+ function useToastItemContext() {
42
+ const ctx = React.useContext(ToastItemContext);
43
+ if (!ctx) {
44
+ throw new Error('useToastItemContext must be used within Toast.Item or Toast.List');
45
+ }
46
+ return ctx;
47
+ }
48
+ function resolveSwipeDirection(direction, position) {
49
+ if (direction !== 'auto')
50
+ return direction;
51
+ const [yPosition, xPosition] = position.split('-');
52
+ if (!isWeb) {
53
+ // on native, always use vertical swipe to avoid conflicting with
54
+ // iOS/Android navigation back gesture (horizontal edge swipe)
55
+ return yPosition === 'top' ? 'up' : 'down';
56
+ }
57
+ if (xPosition === 'left')
58
+ return 'left';
59
+ if (xPosition === 'right')
60
+ return 'right';
61
+ // center positions: horizontal swipe feels most natural
62
+ return 'horizontal';
63
+ }
64
+ const ToastRoot = React.forwardRef(function ToastRoot(props, _ref) {
65
+ const { children, 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;
66
+ const reducedMotion = useReducedMotion(reducedMotionProp);
67
+ const [toasts, setToasts] = React.useState([]);
68
+ const [heights, setHeights] = React.useState({});
69
+ const [localExpanded, setExpanded] = React.useState(false);
70
+ const expanded = expand || localExpanded;
71
+ const [interacting, setInteracting] = React.useState(false);
72
+ // Lock height updates during expand/collapse CSS transition to prevent
73
+ // font-loading onLayout corrections from restarting the animation mid-flight.
74
+ // useLayoutEffect fires before paint, so the lock is set before any onLayout callbacks.
75
+ const heightsLockedRef = React.useRef(false);
76
+ const prevExpandedRef = React.useRef(expanded);
77
+ React.useLayoutEffect(() => {
78
+ if (prevExpandedRef.current !== expanded) {
79
+ heightsLockedRef.current = true;
80
+ prevExpandedRef.current = expanded;
81
+ }
82
+ const timer = setTimeout(() => {
83
+ heightsLockedRef.current = false;
84
+ }, 350);
85
+ return () => clearTimeout(timer);
86
+ }, [expanded]);
87
+ // Round + skip small changes to prevent cascading re-renders from
88
+ // sub-pixel onLayout jitter during font loading or CSS transitions
89
+ const setToastHeight = React.useCallback((toastId, height) => {
90
+ if (heightsLockedRef.current)
91
+ return;
92
+ const rounded = Math.round(height);
93
+ setHeights((prev) => {
94
+ const existing = prev[toastId];
95
+ if (existing != null && Math.abs(existing - rounded) <= 2)
96
+ return prev;
97
+ return { ...prev, [toastId]: rounded };
98
+ });
99
+ }, []);
100
+ const removeToastHeight = React.useCallback((toastId) => {
101
+ setHeights((prev) => {
102
+ if (!(toastId in prev))
103
+ return prev;
104
+ const next = { ...prev };
105
+ delete next[toastId];
106
+ return next;
107
+ });
108
+ }, []);
109
+ // Cooldown after dismiss - prevents collapse while stack rebalances
110
+ const dismissCooldownRef = React.useRef(false);
111
+ const dismissCooldownTimerRef = React.useRef(null);
112
+ const triggerDismissCooldown = React.useCallback(() => {
113
+ dismissCooldownRef.current = true;
114
+ if (dismissCooldownTimerRef.current) {
115
+ clearTimeout(dismissCooldownTimerRef.current);
116
+ }
117
+ dismissCooldownTimerRef.current = setTimeout(() => {
118
+ dismissCooldownRef.current = false;
119
+ }, 800);
120
+ }, []);
121
+ const isInDismissCooldown = React.useCallback(() => dismissCooldownRef.current, []);
122
+ // Store object props in refs so the subscription effect doesn't
123
+ // re-subscribe on every render when consumers pass inline objects.
124
+ const burntOptionsRef = React.useRef(burntOptions);
125
+ const notificationOptionsRef = React.useRef(notificationOptions);
126
+ React.useEffect(() => {
127
+ burntOptionsRef.current = burntOptions;
128
+ }, [burntOptions]);
129
+ React.useEffect(() => {
130
+ notificationOptionsRef.current = notificationOptions;
131
+ }, [notificationOptions]);
132
+ // subscribe to toast state
133
+ React.useEffect(() => {
134
+ return ToastState.subscribe((toast) => {
135
+ if (toast.dismiss) {
136
+ setToasts((toasts) => toasts.map((t) => (t.id === toast.id ? { ...t, delete: true } : t)));
137
+ return;
138
+ }
139
+ // Native dispatch: intercept before entering state so no in-app toast renders.
140
+ // On failure (e.g. permission denied), falls through to in-app.
141
+ if (native) {
142
+ const handled = dispatchNativeToast(toast, {
143
+ duration,
144
+ burntOptions: burntOptionsRef.current,
145
+ notificationOptions: notificationOptionsRef.current,
146
+ });
147
+ if (handled)
148
+ return;
149
+ }
150
+ setToasts((toasts) => {
151
+ const idx = toasts.findIndex((t) => t.id === toast.id);
152
+ if (idx !== -1) {
153
+ return [
154
+ ...toasts.slice(0, idx),
155
+ { ...toasts[idx], ...toast },
156
+ ...toasts.slice(idx + 1),
157
+ ];
158
+ }
159
+ return [toast, ...toasts];
160
+ });
161
+ });
162
+ }, [native, duration]);
163
+ // collapse when 1 toast left, or when a new toast is added while expanded
164
+ const prevToastCountRef = React.useRef(toasts.length);
165
+ React.useEffect(() => {
166
+ const prevCount = prevToastCountRef.current;
167
+ prevToastCountRef.current = toasts.length;
168
+ if (toasts.length <= 1 && !dismissCooldownRef.current) {
169
+ setExpanded(false);
170
+ }
171
+ else if (toasts.length > prevCount && expanded) {
172
+ // new toast added while expanded — collapse to show the new front toast
173
+ setExpanded(false);
174
+ }
175
+ }, [toasts.length, expanded]);
176
+ const removeToast = React.useCallback((toastToRemove) => {
177
+ setToasts((toasts) => {
178
+ if (!toasts.find((t) => t.id === toastToRemove.id)?.delete) {
179
+ ToastState.dismiss(toastToRemove.id);
180
+ }
181
+ return toasts.filter(({ id }) => id !== toastToRemove.id);
182
+ });
183
+ }, []);
184
+ const swipeDirection = resolveSwipeDirection(swipeDirectionProp, position);
185
+ const currentTheme = useThemeName();
186
+ const resolvedTheme = themeProp === 'system' || !themeProp
187
+ ? currentTheme?.includes('dark')
188
+ ? 'dark'
189
+ : 'light'
190
+ : themeProp;
191
+ const contextValue = {
192
+ toasts,
193
+ heights,
194
+ setToastHeight,
195
+ removeToastHeight,
196
+ expanded,
197
+ setExpanded,
198
+ interacting,
199
+ setInteracting,
200
+ triggerDismissCooldown,
201
+ isInDismissCooldown,
202
+ removeToast,
203
+ position,
204
+ duration,
205
+ gap,
206
+ visibleToasts,
207
+ swipeDirection,
208
+ swipeThreshold,
209
+ toastHeight,
210
+ closeButton,
211
+ reducedMotion,
212
+ native,
213
+ burntOptions,
214
+ notificationOptions,
215
+ icons,
216
+ };
217
+ return (_jsx(ToastContext.Provider, { ...contextValue, children: _jsx(Theme, { name: resolvedTheme, children: children }) }));
218
+ });
219
+ /* -------------------------------------------------------------------------------------------------
220
+ * ToastViewport
221
+ * -----------------------------------------------------------------------------------------------*/
222
+ const ToastViewportFrame = styled(View, {
223
+ name: 'ToastViewport',
224
+ variants: {
225
+ unstyled: {
226
+ false: {
227
+ position: isWeb ? 'fixed' : 'absolute',
228
+ zIndex: 100000,
229
+ pointerEvents: 'box-none',
230
+ maxWidth: '100%',
231
+ ...(isWeb && { width: 356 }),
232
+ minHeight: 1,
233
+ },
234
+ },
235
+ },
236
+ defaultVariants: {
237
+ unstyled: process.env.GUI_HEADLESS === '1',
238
+ },
239
+ });
240
+ const ToastViewport = ToastViewportFrame.styleable(function ToastViewport(props, ref) {
241
+ const { offset = VIEWPORT_OFFSET, hotkey = DEFAULT_HOTKEY, label = 'Notifications', portalToRoot = true, portalZIndex = Number.MAX_SAFE_INTEGER, children, ...rest } = props;
242
+ const ctx = useToastContext('Toast.Viewport');
243
+ const listRef = React.useRef(null);
244
+ const hoverTimeoutRef = React.useRef(null);
245
+ const hoverCooldownRef = React.useRef(false);
246
+ const deferredCollapseRef = React.useRef(null);
247
+ const mouseInsideRef = React.useRef(false);
248
+ const [yPosition, xPosition] = ctx.position.split('-');
249
+ // offset styles
250
+ // on native, get safe area insets to avoid status bar / Dynamic Island / home indicator
251
+ // use insets from GuiProvider (passed via useConfiguration)
252
+ // same pattern as Slider — works on native when GuiProvider has insets prop
253
+ const { insets: safeInsets } = useConfiguration();
254
+ const offsetStyles = React.useMemo(() => {
255
+ const styles = {};
256
+ const defaultOffset = typeof offset === 'number' ? offset : VIEWPORT_OFFSET;
257
+ const offsetObj = typeof offset === 'object'
258
+ ? offset
259
+ : {
260
+ top: defaultOffset,
261
+ right: defaultOffset,
262
+ bottom: defaultOffset,
263
+ left: defaultOffset,
264
+ };
265
+ const safeTop = safeInsets?.top ?? 0;
266
+ const safeBottom = safeInsets?.bottom ?? 0;
267
+ // if safe area already provides spacing, skip the offset to avoid double padding
268
+ const topOffset = safeTop > 0 ? safeTop : (offsetObj.top ?? defaultOffset);
269
+ const bottomOffset = safeBottom > 0 ? safeBottom : (offsetObj.bottom ?? defaultOffset);
270
+ if (yPosition === 'top')
271
+ styles.top = topOffset;
272
+ else
273
+ styles.bottom = bottomOffset;
274
+ if (isWeb) {
275
+ if (xPosition === 'left')
276
+ styles.left = offsetObj.left ?? defaultOffset;
277
+ else if (xPosition === 'right')
278
+ styles.right = offsetObj.right ?? defaultOffset;
279
+ else {
280
+ styles.left = '50%';
281
+ styles.transform = 'translateX(-50%)';
282
+ }
283
+ }
284
+ else {
285
+ // native: always set both left + right so viewport fills screen
286
+ // (no fixed width on native — left/right offsets define the width)
287
+ styles.left = offsetObj.left ?? defaultOffset;
288
+ styles.right = offsetObj.right ?? defaultOffset;
289
+ }
290
+ return styles;
291
+ }, [offset, yPosition, xPosition]);
292
+ // hotkey
293
+ React.useEffect(() => {
294
+ if (!isWeb)
295
+ return;
296
+ const handleKeyDown = (event) => {
297
+ const isHotkeyPressed = hotkey.length > 0 &&
298
+ hotkey.every((key) => event[key] || event.code === key);
299
+ if (isHotkeyPressed) {
300
+ ctx.setExpanded(true);
301
+ listRef.current?.focus();
302
+ }
303
+ // Escape is handled by individual toast items via onKeyDown
304
+ // which dismisses the focused toast with cooldown (keeps stack expanded)
305
+ };
306
+ document.addEventListener('keydown', handleKeyDown);
307
+ return () => document.removeEventListener('keydown', handleKeyDown);
308
+ }, [hotkey]);
309
+ if (ctx.toasts.length === 0)
310
+ return null;
311
+ const hotkeyLabel = hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '');
312
+ const content = (_jsx(ToastViewportFrame, { ref: listRef, "aria-label": `${label} ${hotkeyLabel}`, tabIndex: -1, "aria-live": "polite", style: offsetStyles, "data-y-position": yPosition, "data-x-position": xPosition, ...(isWeb
313
+ ? {
314
+ onMouseEnter: () => {
315
+ mouseInsideRef.current = true;
316
+ if (deferredCollapseRef.current) {
317
+ clearTimeout(deferredCollapseRef.current);
318
+ deferredCollapseRef.current = null;
319
+ }
320
+ if (ctx.toasts.length > 1 &&
321
+ !ctx.interacting &&
322
+ !hoverCooldownRef.current) {
323
+ hoverTimeoutRef.current = setTimeout(() => ctx.setExpanded(true), 50);
324
+ }
325
+ },
326
+ onMouseLeave: () => {
327
+ mouseInsideRef.current = false;
328
+ if (hoverTimeoutRef.current) {
329
+ clearTimeout(hoverTimeoutRef.current);
330
+ hoverTimeoutRef.current = null;
331
+ }
332
+ if (!ctx.interacting && !ctx.isInDismissCooldown()) {
333
+ ctx.setExpanded(false);
334
+ }
335
+ else if (ctx.isInDismissCooldown()) {
336
+ // During dismiss cooldown, defer collapse until well after
337
+ // the exit animation completes to prevent mid-animation bounce.
338
+ // The cooldown is 800ms, spring exit is ~500ms — 1200ms covers both.
339
+ if (deferredCollapseRef.current) {
340
+ clearTimeout(deferredCollapseRef.current);
341
+ }
342
+ deferredCollapseRef.current = setTimeout(() => {
343
+ deferredCollapseRef.current = null;
344
+ if (!mouseInsideRef.current) {
345
+ ctx.setExpanded(false);
346
+ }
347
+ }, 1200);
348
+ }
349
+ },
350
+ onPointerDown: () => {
351
+ if (hoverTimeoutRef.current) {
352
+ clearTimeout(hoverTimeoutRef.current);
353
+ hoverTimeoutRef.current = null;
354
+ }
355
+ ctx.setInteracting(true);
356
+ },
357
+ onPointerUp: () => ctx.setInteracting(false),
358
+ onPointerCancel: () => ctx.setInteracting(false),
359
+ }
360
+ : {
361
+ onPress: () => {
362
+ if (ctx.toasts.length > 1) {
363
+ ctx.setExpanded((prev) => !prev);
364
+ }
365
+ },
366
+ }), ...(isWeb && {
367
+ onFocus: (event) => {
368
+ // keyboard focus entered — expand stack and pause timers
369
+ if (!event.currentTarget.contains(event.relatedTarget)) {
370
+ if (ctx.toasts.length > 1) {
371
+ ctx.setExpanded(true);
372
+ }
373
+ ctx.setInteracting(true);
374
+ }
375
+ },
376
+ onBlur: (event) => {
377
+ // focus left the toaster — collapse and resume timers
378
+ if (!event.currentTarget.contains(event.relatedTarget)) {
379
+ ctx.setInteracting(false);
380
+ if (!ctx.isInDismissCooldown()) {
381
+ ctx.setExpanded(false);
382
+ }
383
+ }
384
+ },
385
+ }), ...rest, children: children }));
386
+ if (portalToRoot) {
387
+ return (_jsx(Portal, { zIndex: portalZIndex, children: _jsx(ToastContext.Provider, { ...ctx, children: content }) }));
388
+ }
389
+ return content;
390
+ });
391
+ function ToastList({ renderItem }) {
392
+ const ctx = useToastContext('Toast.List');
393
+ // render all toasts — hidden ones have opacity 0 but stay mounted
394
+ // so they smoothly transition when visible toasts are dismissed
395
+ const maxRender = ctx.toasts.length;
396
+ return (_jsx(AnimatePresence, { children: ctx.toasts.slice(0, maxRender).map((toast, index) => {
397
+ const handleClose = () => {
398
+ if (toast.dismissible === false)
399
+ return;
400
+ toast.onDismiss?.(toast);
401
+ ctx.removeToast(toast);
402
+ };
403
+ const itemContextValue = {
404
+ toast,
405
+ handleClose,
406
+ };
407
+ if (!renderItem) {
408
+ return (_jsx(ToastItemContext.Provider, { value: itemContextValue, children: _jsx(ToastItemInner, { toast: toast, index: index, children: _jsx(DefaultToastContent, { toast: toast }) }) }, toast.id));
409
+ }
410
+ return (_jsx(ToastItemContext.Provider, { value: itemContextValue, children: renderItem({ toast, index, handleClose }) }, toast.id));
411
+ }) }));
412
+ }
413
+ /* -------------------------------------------------------------------------------------------------
414
+ * DefaultToastContent - default rendering for toast items
415
+ * -----------------------------------------------------------------------------------------------*/
416
+ function DefaultToastContent({ toast }) {
417
+ const ctx = useToastContext('Toast.Item');
418
+ const { handleClose } = useToastItemContext();
419
+ const toastType = toast.type ?? 'default';
420
+ const dismissible = toast.dismissible !== false;
421
+ const title = typeof toast.title === 'function' ? toast.title() : toast.title;
422
+ const description = typeof toast.description === 'function' ? toast.description() : toast.description;
423
+ return (_jsxs(XStack, { alignItems: "flex-start", gap: "$3", children: [_jsx(ToastIcon, {}), _jsxs(YStack, { flex: 1, gap: "$1", children: [title && _jsx(ToastTitle, { children: title }), description && _jsx(ToastDescription, { children: description }), (toast.action || toast.cancel) && (_jsxs(XStack, { gap: "$2", marginTop: "$2", children: [toast.cancel && (_jsx(ToastActionFrame, { backgroundColor: "transparent", onPress: (e) => {
424
+ toast.cancel?.onClick?.(e);
425
+ handleClose();
426
+ }, children: _jsx(SizableText, { size: "$2", color: "$color11", children: toast.cancel.label }) })), toast.action && (_jsx(ToastActionFrame, { backgroundColor: "$color12", hoverStyle: { backgroundColor: '$color11' }, pressStyle: { backgroundColor: '$color10' }, onPress: (e) => {
427
+ toast.action?.onClick?.(e);
428
+ if (!e.defaultPrevented) {
429
+ handleClose();
430
+ }
431
+ }, children: _jsx(SizableText, { size: "$2", fontWeight: "600", color: "$background", children: toast.action.label }) }))] }))] }), ctx.closeButton && dismissible && _jsx(ToastClose, {})] }));
432
+ }
433
+ function DragWrapper({ animatedStyle, gestureHandlers, gesture, AnimatedView, dragRef, children, }) {
434
+ if (isWeb) {
435
+ return (_jsx("div", { ref: dragRef, style: {
436
+ flex: 1,
437
+ display: 'flex',
438
+ flexDirection: 'column',
439
+ userSelect: 'none',
440
+ WebkitUserSelect: 'none',
441
+ touchAction: 'none',
442
+ cursor: 'default',
443
+ }, ...gestureHandlers, children: children }));
444
+ }
445
+ // when RNGH gesture is available, wrap with GestureDetector + plain View
446
+ // (GestureDetector needs a native View to attach handlers to)
447
+ if (gesture) {
448
+ const gh = getGestureHandler();
449
+ const GestureDetector = gh.state.GestureDetector;
450
+ if (GestureDetector) {
451
+ return (_jsx(GestureDetector, { gesture: gesture, children: _jsx(View, { style: { flex: 1 }, ...{ collapsable: false }, children: _jsx(AnimatedView, { style: [{ flex: 1 }, animatedStyle], children: children }) }) }));
452
+ }
453
+ }
454
+ // fallback: PanResponder handlers
455
+ return (_jsx(AnimatedView, { style: [{ flex: 1 }, animatedStyle], ...gestureHandlers, children: children }));
456
+ }
457
+ const ToastItemInner = ToastItemFrame.styleable(function ToastItem(props, ref) {
458
+ const { toast, index, children, ...rest } = props;
459
+ const ctx = useToastContext('Toast.Item');
460
+ const [mounted, setMounted] = React.useState(false);
461
+ const [removed, setRemoved] = React.useState(false);
462
+ const [swipeOut, setSwipeOut] = React.useState(false);
463
+ // Freeze the Y offset when dismiss starts so the exiting toast doesn't jump
464
+ // as other toasts rebalance
465
+ const [offsetBeforeRemove, setOffsetBeforeRemove] = React.useState(0);
466
+ // Freeze stackY at swipe time — context re-renders recalculate stackY
467
+ // but the exiting toast should stay at its pre-removal position
468
+ const swipeExitYRef = React.useRef(null);
469
+ const closeTimerRef = React.useRef(null);
470
+ const closeTimerStartRef = React.useRef(0);
471
+ const lastPauseTimeRef = React.useRef(0);
472
+ const remainingTimeRef = React.useRef(toast.duration ?? ctx.duration);
473
+ const isFront = index === 0;
474
+ const isVisible = index < ctx.visibleToasts;
475
+ const toastType = toast.type ?? 'default';
476
+ const dismissible = toast.dismissible !== false;
477
+ const duration = toast.duration ?? ctx.duration;
478
+ const [yPosition] = ctx.position.split('-');
479
+ const isTop = yPosition === 'top';
480
+ // web: dynamic heights (CSS transitions run off main thread, no FPS concern)
481
+ // native: fixed height (avoids React state re-render cascade on JS thread)
482
+ const expandedOffset = isWeb
483
+ ? (() => {
484
+ let totalHeight = 0;
485
+ let activeCount = 0;
486
+ for (let i = 0; i < index; i++) {
487
+ const toastId = ctx.toasts[i]?.id;
488
+ if (toastId == null)
489
+ continue;
490
+ const h = ctx.heights[toastId];
491
+ if (h === 0)
492
+ continue;
493
+ totalHeight += h ?? ctx.toastHeight;
494
+ activeCount++;
495
+ }
496
+ return totalHeight + activeCount * ctx.gap;
497
+ })()
498
+ : index * (ctx.toastHeight + ctx.gap);
499
+ // Refs for stable access in callbacks — avoids putting expandedOffset/expanded
500
+ // in deps which would cause timer restarts on every height measurement
501
+ const expandedOffsetRef = React.useRef(expandedOffset);
502
+ expandedOffsetRef.current = expandedOffset;
503
+ const isExpandedRef = React.useRef(ctx.expanded);
504
+ isExpandedRef.current = ctx.expanded;
505
+ // timer — no height-zeroing needed here because auto-dismiss only fires
506
+ // when not expanded/interacting (timer is paused during hover)
507
+ const startTimer = React.useCallback(() => {
508
+ if (duration === Number.POSITIVE_INFINITY || toastType === 'loading')
509
+ return;
510
+ closeTimerStartRef.current = Date.now();
511
+ closeTimerRef.current = setTimeout(() => {
512
+ toast.onAutoClose?.(toast);
513
+ setRemoved(true);
514
+ setTimeout(() => ctx.removeToast(toast), TIME_BEFORE_UNMOUNT);
515
+ }, remainingTimeRef.current);
516
+ }, [duration, toastType, toast, ctx.removeToast]);
517
+ const pauseTimer = useEvent(() => {
518
+ if (closeTimerRef.current) {
519
+ clearTimeout(closeTimerRef.current);
520
+ }
521
+ if (lastPauseTimeRef.current < closeTimerStartRef.current) {
522
+ const elapsed = Date.now() - closeTimerStartRef.current;
523
+ remainingTimeRef.current = Math.max(0, remainingTimeRef.current - elapsed);
524
+ }
525
+ lastPauseTimeRef.current = Date.now();
526
+ });
527
+ const resumeTimer = useEvent(() => {
528
+ if (ctx.expanded || ctx.interacting)
529
+ return;
530
+ remainingTimeRef.current = duration;
531
+ startTimer();
532
+ });
533
+ React.useEffect(() => {
534
+ setMounted(true);
535
+ }, []);
536
+ // handle deletion — only zero height when expanded (Sonner rebalance)
537
+ React.useEffect(() => {
538
+ if (toast.delete) {
539
+ setRemoved(true);
540
+ if (isExpandedRef.current) {
541
+ setOffsetBeforeRemove(expandedOffsetRef.current);
542
+ }
543
+ setTimeout(() => ctx.removeToast(toast), TIME_BEFORE_UNMOUNT);
544
+ }
545
+ }, [toast.delete, toast, ctx.removeToast]);
546
+ React.useEffect(() => {
547
+ // all toasts have independent timers (same as Sonner)
548
+ // stagger comes from creation time differences
549
+ if (ctx.expanded || ctx.interacting) {
550
+ pauseTimer();
551
+ }
552
+ else {
553
+ startTimer();
554
+ }
555
+ return () => {
556
+ if (closeTimerRef.current)
557
+ clearTimeout(closeTimerRef.current);
558
+ };
559
+ }, [ctx.expanded, ctx.interacting, startTimer]);
560
+ // reset remaining time when duration changes
561
+ React.useEffect(() => {
562
+ remainingTimeRef.current = duration;
563
+ }, [duration]);
564
+ // animations
565
+ const { setDragOffset, springBack, animateOut, animatedStyle, AnimatedView, dragRef, } = useToastAnimations({
566
+ reducedMotion: ctx.reducedMotion,
567
+ swipeAxis: ctx.swipeDirection === 'up' ||
568
+ ctx.swipeDirection === 'down' ||
569
+ ctx.swipeDirection === 'vertical'
570
+ ? 'vertical'
571
+ : 'horizontal',
572
+ });
573
+ const { isDragging, gestureHandlers, gesture } = useAnimatedDragGesture({
574
+ direction: ctx.swipeDirection,
575
+ threshold: ctx.swipeThreshold,
576
+ disabled: !dismissible || toastType === 'loading',
577
+ expanded: ctx.expanded,
578
+ onDragStart: pauseTimer,
579
+ onDragMove: setDragOffset,
580
+ onDismiss: (exitDirection, velocity) => {
581
+ // Trigger cooldown to prevent collapse while stack rebalances
582
+ ctx.triggerDismissCooldown();
583
+ setSwipeOut(true);
584
+ toast.onDismiss?.(toast);
585
+ // freeze stackY at swipe time — after removeToast, context re-renders
586
+ // recalculate expandedOffset with the wrong toast array
587
+ swipeExitYRef.current = isExpandedRef.current
588
+ ? isTop
589
+ ? expandedOffsetRef.current
590
+ : -expandedOffsetRef.current
591
+ : isFront
592
+ ? 0
593
+ : isTop
594
+ ? ctx.gap * index
595
+ : -ctx.gap * index;
596
+ setRemoved(true);
597
+ ctx.removeToast(toast);
598
+ animateOut(exitDirection, velocity);
599
+ },
600
+ onCancel: () => {
601
+ springBack(() => {
602
+ resumeTimer();
603
+ });
604
+ },
605
+ });
606
+ // measure height (web only — native uses fixed height)
607
+ const handleLayout = React.useCallback((event) => {
608
+ if (!isWeb)
609
+ return;
610
+ if (removed)
611
+ return;
612
+ if (!ctx.expanded && index !== 0)
613
+ return;
614
+ const { height } = event.nativeEvent.layout;
615
+ ctx.setToastHeight(toast.id, height);
616
+ }, [toast.id, ctx.setToastHeight, index, ctx.expanded, removed]);
617
+ // remove height on unmount (web only)
618
+ React.useEffect(() => {
619
+ if (!isWeb)
620
+ return;
621
+ return () => {
622
+ ctx.removeToastHeight(toast.id);
623
+ };
624
+ }, [toast.id, ctx.removeToastHeight]);
625
+ const handleClose = React.useCallback(() => {
626
+ if (!dismissible)
627
+ return;
628
+ ctx.triggerDismissCooldown();
629
+ toast.onDismiss?.(toast);
630
+ setRemoved(true);
631
+ if (isExpandedRef.current) {
632
+ setOffsetBeforeRemove(expandedOffsetRef.current);
633
+ }
634
+ setTimeout(() => ctx.removeToast(toast), TIME_BEFORE_UNMOUNT);
635
+ }, [dismissible, toast, ctx.removeToast, ctx.triggerDismissCooldown]);
636
+ const itemContextValue = React.useMemo(() => ({ toast, handleClose }), [toast, handleClose]);
637
+ // front toast height for collapsed stacking (web only)
638
+ let frontToastHeight = -1;
639
+ if (isWeb) {
640
+ for (const t of ctx.toasts) {
641
+ const h = ctx.heights[t.id];
642
+ if (h != null && h > 0) {
643
+ frontToastHeight = h;
644
+ break;
645
+ }
646
+ }
647
+ }
648
+ const stackScale = !ctx.expanded && !isFront ? 1 - index * 0.05 : 1;
649
+ // When removed, freeze Y at the saved offset so the exiting toast doesn't jump
650
+ // as other toasts rebalance (Sonner: --offset uses offsetBeforeRemove when removed)
651
+ const activeExpandedOffset = removed ? offsetBeforeRemove : expandedOffset;
652
+ const stackY = ctx.expanded
653
+ ? isTop
654
+ ? activeExpandedOffset
655
+ : -activeExpandedOffset
656
+ : isFront
657
+ ? 0
658
+ : isTop
659
+ ? ctx.gap * index
660
+ : -ctx.gap * index;
661
+ const computedOpacity = removed && !swipeOut ? 0 : index >= ctx.visibleToasts ? 0 : 1;
662
+ const computedZIndex = removed ? 0 : ctx.visibleToasts - index + 1;
663
+ // web: use measured height for smooth expand/collapse transitions
664
+ // native: fixed height, no constraint needed
665
+ const computedHeight = isWeb
666
+ ? ctx.expanded
667
+ ? ctx.heights[toast.id] || undefined
668
+ : !isFront && frontToastHeight > 0
669
+ ? frontToastHeight
670
+ : undefined
671
+ : undefined;
672
+ const computedPointerEvents = index >= ctx.visibleToasts ? 'none' : 'auto';
673
+ // gap filler for hover stability
674
+ const gapFillerHeight = ctx.expanded ? ctx.gap + 1 : 0;
675
+ // data attributes
676
+ const dataAttributes = {
677
+ 'data-mounted': mounted ? 'true' : 'false',
678
+ 'data-removed': removed ? 'true' : 'false',
679
+ 'data-swipe-out': swipeOut ? 'true' : 'false',
680
+ 'data-visible': isVisible ? 'true' : 'false',
681
+ 'data-front': isFront ? 'true' : 'false',
682
+ 'data-index': String(index),
683
+ 'data-type': toastType,
684
+ 'data-expanded': ctx.expanded ? 'true' : 'false',
685
+ };
686
+ return (_jsx(ToastPositionWrapper, { ref: ref, testID: rest.testID, accessibilityLabel: rest.accessibilityLabel, ...dataAttributes, transition: isDragging || ctx.reducedMotion ? undefined : removed ? '200ms' : '400ms', animateOnly: isWeb ? ['transform', 'opacity', 'height'] : ['transform', 'opacity'], y: stackY, scale: stackScale, opacity: computedOpacity, zIndex: computedZIndex, height: computedHeight, overflow: "visible", pointerEvents: computedPointerEvents, top: isTop ? 0 : undefined, bottom: isTop ? undefined : 0, ...(isWeb &&
687
+ !isFront && {
688
+ style: { transformOrigin: isTop ? 'top center' : 'bottom center' },
689
+ }), enterStyle: ctx.reducedMotion ? { opacity: 0 } : { opacity: 0, y: isTop ? -80 : 80 }, exitStyle: ctx.reducedMotion
690
+ ? { opacity: 0 }
691
+ : swipeOut
692
+ ? { opacity: 0, y: swipeExitYRef.current ?? stackY, scale: stackScale }
693
+ : { opacity: 0, y: stackY, scale: stackScale }, children: _jsx(DragWrapper, { animatedStyle: animatedStyle, gestureHandlers: gestureHandlers, gesture: gesture, AnimatedView: AnimatedView, dragRef: dragRef, children: _jsxs(ToastItemFrame
694
+ // The one hook a stylesheet can reach a toast by.
695
+ //
696
+ // A toast is floating chrome — it is over the page or it is nothing
697
+ // — so a design system wants to give it the same material every
698
+ // other floating surface wears. It had no handle at all: `Toaster`
699
+ // accepts sonner's `className`/`style`/`classNames` and documents
700
+ // them as INERT, and nothing else here reaches the DOM node. So the
701
+ // one surface that is unambiguously floating was the one surface a
702
+ // sheet could not select, and it kept a hand-rolled
703
+ // `rgba(0,0,0,0.15)` drop that is very nearly invisible on a dark
704
+ // ground — the exact defect an elevation ladder exists to end.
705
+ //
706
+ // `data-slot` rather than a class or a prop because it needs no
707
+ // decision from a call site: a toast is glass because it IS a toast.
708
+ // gui forwards unrecognised props to the DOM node and native drops
709
+ // them, which is what makes this cross-platform safe.
710
+ , { "data-slot": "toast", role: "status", "aria-live": "polite", "aria-atomic": true, tabIndex: 0, onLayout: handleLayout, ...(isWeb && {
711
+ onKeyDown: (event) => {
712
+ if (event.key === 'Escape' && dismissible) {
713
+ // move focus to the next toast before dismissing
714
+ const current = event.currentTarget;
715
+ const container = current.closest('[aria-label]');
716
+ if (container) {
717
+ const focusables = container.querySelectorAll('[tabindex="0"]');
718
+ const arr = Array.from(focusables);
719
+ const idx = arr.indexOf(current);
720
+ const next = arr[idx + 1] || arr[idx - 1];
721
+ next?.focus();
722
+ }
723
+ handleClose();
724
+ }
725
+ },
726
+ }), ...rest, children: [ctx.expanded && gapFillerHeight > 0 && (_jsx(View, { position: "absolute", left: 0, right: 0, height: gapFillerHeight, pointerEvents: "auto", ...(isTop ? { top: '100%' } : { bottom: '100%' }) })), _jsx(ToastItemContext.Provider, { value: itemContextValue, children: children })] }) }) }));
727
+ });
728
+ /* -------------------------------------------------------------------------------------------------
729
+ * ToastTitle
730
+ * -----------------------------------------------------------------------------------------------*/
731
+ const ToastTitle = styled(SizableText, {
732
+ name: 'ToastTitle',
733
+ variants: {
734
+ unstyled: {
735
+ false: {
736
+ color: '$color',
737
+ fontWeight: '600',
738
+ size: '$4',
739
+ },
740
+ },
741
+ },
742
+ defaultVariants: {
743
+ unstyled: process.env.GUI_HEADLESS === '1',
744
+ },
745
+ });
746
+ /* -------------------------------------------------------------------------------------------------
747
+ * ToastDescription
748
+ * -----------------------------------------------------------------------------------------------*/
749
+ const ToastDescription = styled(SizableText, {
750
+ name: 'ToastDescription',
751
+ variants: {
752
+ unstyled: {
753
+ false: {
754
+ color: '$color11',
755
+ size: '$2',
756
+ },
757
+ },
758
+ },
759
+ defaultVariants: {
760
+ unstyled: process.env.GUI_HEADLESS === '1',
761
+ },
762
+ });
763
+ /* -------------------------------------------------------------------------------------------------
764
+ * ToastClose - auto-wired to dismiss current toast
765
+ * -----------------------------------------------------------------------------------------------*/
766
+ const ToastClose = ToastCloseFrame.styleable(function ToastClose(props, ref) {
767
+ // try to get handleClose from context, but allow manual override
768
+ let handleClose;
769
+ try {
770
+ const itemCtx = useToastItemContext();
771
+ handleClose = itemCtx.handleClose;
772
+ }
773
+ catch {
774
+ // not inside a Toast.Item context, require manual onPress
775
+ }
776
+ const ctx = useToastContext('Toast.Close');
777
+ return (_jsx(ToastCloseFrame, { ref: ref, "aria-label": "Close toast", onPress: handleClose, ...props, children: props.children ?? ctx.icons?.close ?? _jsx(DefaultCloseIcon, {}) }));
778
+ });
779
+ /* -------------------------------------------------------------------------------------------------
780
+ * ToastAction
781
+ * -----------------------------------------------------------------------------------------------*/
782
+ const ToastAction = ToastActionFrame.styleable(function ToastAction(props, ref) {
783
+ return _jsx(ToastActionFrame, { ref: ref, ...props });
784
+ });
785
+ /* -------------------------------------------------------------------------------------------------
786
+ * ToastIcon - renders icon based on toast type
787
+ * -----------------------------------------------------------------------------------------------*/
788
+ function ToastIcon(props) {
789
+ const ctx = useToastContext('Toast.Icon');
790
+ let toast;
791
+ try {
792
+ const itemCtx = useToastItemContext();
793
+ toast = itemCtx.toast;
794
+ }
795
+ catch {
796
+ // not inside a Toast.Item context
797
+ return null;
798
+ }
799
+ if (!toast)
800
+ return null;
801
+ // if custom icon provided on toast, use it
802
+ if (toast.icon !== undefined) {
803
+ return (_jsx(View, { flexShrink: 0, marginTop: "$0.5", children: toast.icon }));
804
+ }
805
+ const toastType = toast.type ?? 'default';
806
+ // only show icons if explicitly provided via icons prop (no built-in defaults)
807
+ const icon = ctx.icons?.[toastType] ?? null;
808
+ if (!icon)
809
+ return null;
810
+ return (_jsx(View, { flexShrink: 0, marginTop: "$0.5", children: icon }));
811
+ }
812
+ /* -------------------------------------------------------------------------------------------------
813
+ * useToasts hook for rendering
814
+ * -----------------------------------------------------------------------------------------------*/
815
+ export function useToasts() {
816
+ const ctx = useToastContext('useToasts');
817
+ return {
818
+ toasts: ctx.toasts,
819
+ expanded: ctx.expanded,
820
+ position: ctx.position,
821
+ };
822
+ }
823
+ /* -------------------------------------------------------------------------------------------------
824
+ * useToastItem hook for accessing current toast in custom content
825
+ * -----------------------------------------------------------------------------------------------*/
826
+ export function useToastItem() {
827
+ return useToastItemContext();
828
+ }
829
+ /* -------------------------------------------------------------------------------------------------
830
+ * Export
831
+ * -----------------------------------------------------------------------------------------------*/
832
+ ToastRoot.displayName = 'Toast';
833
+ export const Toast = withStaticProperties(ToastRoot, {
834
+ Viewport: ToastViewport,
835
+ List: ToastList,
836
+ Item: ToastItemInner,
837
+ Title: ToastTitle,
838
+ Description: ToastDescription,
839
+ Close: ToastClose,
840
+ Action: ToastAction,
841
+ Icon: ToastIcon,
842
+ });
843
+ //# sourceMappingURL=ToastComposable.js.map