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