@hanzogui/toast 8.3.1 → 8.3.3

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