@hanzogui/toast 8.3.1 → 8.3.2

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