@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,319 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: true
30
- }) : target, mod));
31
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: true
33
- }), mod);
34
- var ToastViewport_exports = {};
35
- __export(ToastViewport_exports, {
36
- ToastViewport: () => ToastViewport,
37
- VIEWPORT_DEFAULT_HOTKEY: () => VIEWPORT_DEFAULT_HOTKEY,
38
- VIEWPORT_PAUSE: () => VIEWPORT_PAUSE,
39
- VIEWPORT_RESUME: () => VIEWPORT_RESUME
40
- });
41
- module.exports = __toCommonJS(ToastViewport_exports);
42
- var import_animate_presence = require("@hanzogui/animate-presence");
43
- var import_compose_refs = require("@hanzogui/compose-refs");
44
- var import_constants = require("@hanzogui/constants");
45
- var import_core = require("@hanzogui/core");
46
- var import_portal = require("@hanzogui/portal");
47
- var import_stacks = require("@hanzogui/stacks");
48
- var import_visually_hidden = require("@hanzogui/visually-hidden");
49
- var React = __toESM(require("react"), 1);
50
- var import_constants2 = require("./constants.cjs");
51
- var import_ToastPortal = require("./ToastPortal.cjs");
52
- var import_ToastProvider = require("./ToastProvider.cjs");
53
- var import_jsx_runtime = require("react/jsx-runtime");
54
- const VIEWPORT_NAME = "ToastViewport";
55
- const VIEWPORT_DEFAULT_HOTKEY = ["F8"];
56
- const VIEWPORT_PAUSE = "toast.viewportPause";
57
- const VIEWPORT_RESUME = "toast.viewportResume";
58
- const ToastViewportWrapperFrame = (0, import_core.styled)(import_stacks.YStack, {
59
- name: "ViewportWrapper",
60
- variants: {
61
- unstyled: {
62
- false: {
63
- pointerEvents: "box-none",
64
- top: 0,
65
- bottom: 0,
66
- left: 0,
67
- right: 0,
68
- position: import_constants.isWeb ? "fixed" : "absolute",
69
- maxWidth: "100%",
70
- tabIndex: 0,
71
- zIndex: 1e5
72
- }
73
- }
74
- },
75
- defaultVariants: {
76
- unstyled: process.env.GUI_HEADLESS === "1"
77
- }
78
- });
79
- const ToastViewportFrame = (0, import_core.styled)(import_stacks.YStack, {
80
- name: VIEWPORT_NAME,
81
- variants: {
82
- unstyled: {
83
- false: {
84
- pointerEvents: "box-none",
85
- position: import_constants.isWeb ? "fixed" : "absolute",
86
- maxWidth: "100%"
87
- }
88
- }
89
- },
90
- defaultVariants: {
91
- unstyled: process.env.GUI_HEADLESS === "1"
92
- }
93
- });
94
- const ToastViewport = React.memo(React.forwardRef((props, forwardedRef) => {
95
- const {
96
- scope,
97
- hotkey = VIEWPORT_DEFAULT_HOTKEY,
98
- label = "Notifications ({hotkey})",
99
- name = "default",
100
- multipleToasts,
101
- zIndex,
102
- portalToRoot,
103
- ...viewportProps
104
- } = props;
105
- const context = (0, import_ToastProvider.useToastProviderContext)(scope);
106
- const getItems = (0, import_ToastProvider.useCollection)(scope || import_constants2.TOAST_CONTEXT);
107
- const headFocusProxyRef = React.useRef(null);
108
- const tailFocusProxyRef = React.useRef(null);
109
- const wrapperRef = React.useRef(null);
110
- const ref = React.useRef(null);
111
- const onViewportChange = React.useCallback(el => {
112
- if (context.viewports[name] !== el) context.onViewportChange(name, el);
113
- }, [name, context.viewports]);
114
- const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, onViewportChange);
115
- const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
116
- const hasToasts = context.toastCount > 0;
117
- React.useEffect(() => {
118
- if (!import_constants.isWeb) return;
119
- if (context.toastCount === 0) return;
120
- const handleKeyDown = event => {
121
- const isHotkeyPressed = hotkey.every(key => event[key] || event.code === key);
122
- if (isHotkeyPressed) ref.current?.focus();
123
- };
124
- document.addEventListener("keydown", handleKeyDown);
125
- return () => {
126
- document.removeEventListener("keydown", handleKeyDown);
127
- };
128
- }, [hotkey, context.toastCount]);
129
- React.useEffect(() => {
130
- if (!import_constants.isWeb) return;
131
- if (context.toastCount === 0) return;
132
- const wrapper = wrapperRef.current;
133
- const viewport = ref.current;
134
- if (hasToasts && wrapper && viewport) {
135
- const handlePause = () => {
136
- if (!context.isClosePausedRef.current) {
137
- const pauseEvent = new CustomEvent(VIEWPORT_PAUSE);
138
- viewport.dispatchEvent(pauseEvent);
139
- context.isClosePausedRef.current = true;
140
- }
141
- };
142
- const handleResume = () => {
143
- if (context.isClosePausedRef.current) {
144
- const resumeEvent = new CustomEvent(VIEWPORT_RESUME);
145
- viewport.dispatchEvent(resumeEvent);
146
- context.isClosePausedRef.current = false;
147
- }
148
- };
149
- const handleFocusOutResume = event => {
150
- const isFocusMovingOutside = !wrapper.contains(event.relatedTarget);
151
- if (isFocusMovingOutside) handleResume();
152
- };
153
- const handlePointerLeaveResume = () => {
154
- const isFocusInside = wrapper.contains(document.activeElement);
155
- if (!isFocusInside) handleResume();
156
- };
157
- wrapper.addEventListener("focusin", handlePause);
158
- wrapper.addEventListener("focusout", handleFocusOutResume);
159
- wrapper.addEventListener("pointermove", handlePause);
160
- wrapper.addEventListener("pointerleave", handlePointerLeaveResume);
161
- window.addEventListener("blur", handlePause);
162
- window.addEventListener("focus", handleResume);
163
- return () => {
164
- wrapper.removeEventListener("focusin", handlePause);
165
- wrapper.removeEventListener("focusout", handleFocusOutResume);
166
- wrapper.removeEventListener("pointermove", handlePause);
167
- wrapper.removeEventListener("pointerleave", handlePointerLeaveResume);
168
- window.removeEventListener("blur", handlePause);
169
- window.removeEventListener("focus", handleResume);
170
- };
171
- }
172
- }, [hasToasts, context.isClosePausedRef, context.toastCount]);
173
- const getSortedTabbableCandidates = React.useCallback(({
174
- tabbingDirection
175
- }) => {
176
- const toastItems = getItems();
177
- const tabbableCandidates = toastItems.map(toastItem => {
178
- const toastNode = toastItem.ref.current;
179
- const toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];
180
- return tabbingDirection === "forwards" ? toastTabbableCandidates : toastTabbableCandidates.reverse();
181
- });
182
- return (tabbingDirection === "forwards" ? tabbableCandidates.reverse() : tabbableCandidates).flat();
183
- }, [getItems]);
184
- React.useEffect(() => {
185
- if (!import_constants.isWeb) return;
186
- if (context.toastCount === 0) return;
187
- const viewport = ref.current;
188
- if (viewport) {
189
- const handleKeyDown = event => {
190
- const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
191
- const isTabKey = event.key === "Tab" && !isMetaKey;
192
- if (isTabKey) {
193
- const focusedElement = document.activeElement;
194
- const isTabbingBackwards = event.shiftKey;
195
- const targetIsViewport = event.target === viewport;
196
- if (targetIsViewport && isTabbingBackwards) {
197
- headFocusProxyRef.current?.focus();
198
- return;
199
- }
200
- const tabbingDirection = isTabbingBackwards ? "backwards" : "forwards";
201
- const sortedCandidates = getSortedTabbableCandidates({
202
- tabbingDirection
203
- });
204
- const index = sortedCandidates.findIndex(candidate => candidate === focusedElement);
205
- if (focusFirst(sortedCandidates.slice(index + 1))) {
206
- event.preventDefault();
207
- } else {
208
- isTabbingBackwards ?
209
- // @ts-ignore ali TODO type
210
- headFocusProxyRef.current?.focus() :
211
- // @ts-ignore ali TODO type
212
- tailFocusProxyRef.current?.focus();
213
- }
214
- }
215
- };
216
- viewport.addEventListener("keydown", handleKeyDown);
217
- return () => viewport.removeEventListener("keydown", handleKeyDown);
218
- }
219
- }, [getItems, getSortedTabbableCandidates, context.toastCount]);
220
- const contents = /* @__PURE__ */(0, import_jsx_runtime.jsxs)(ToastViewportWrapperFrame, {
221
- ref: wrapperRef,
222
- role: "region",
223
- "aria-label": label.replace("{hotkey}", hotkeyLabel),
224
- tabIndex: -1,
225
- children: [hasToasts && /* @__PURE__ */(0, import_jsx_runtime.jsx)(FocusProxy, {
226
- context,
227
- viewportName: name,
228
- ref: headFocusProxyRef,
229
- onFocusFromOutsideViewport: () => {
230
- const tabbableCandidates = getSortedTabbableCandidates({
231
- tabbingDirection: "forwards"
232
- });
233
- focusFirst(tabbableCandidates);
234
- }
235
- }), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.Slot, {
236
- scope: context.toastScope,
237
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastViewportFrame, {
238
- focusable: context.toastCount > 0,
239
- ref: composedRefs,
240
- ...viewportProps,
241
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.PortalHost, {
242
- render: children => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
243
- exitBeforeEnter: !multipleToasts,
244
- children
245
- }),
246
- name: name ?? "default"
247
- })
248
- })
249
- }), hasToasts && /* @__PURE__ */(0, import_jsx_runtime.jsx)(FocusProxy, {
250
- context,
251
- viewportName: name,
252
- ref: tailFocusProxyRef,
253
- onFocusFromOutsideViewport: () => {
254
- const tabbableCandidates = getSortedTabbableCandidates({
255
- tabbingDirection: "backwards"
256
- });
257
- focusFirst(tabbableCandidates);
258
- }
259
- })]
260
- });
261
- if (portalToRoot) {
262
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastPortal.ToastPortal, {
263
- context,
264
- ...(typeof zIndex === "number" ? {
265
- zIndex
266
- } : {}),
267
- children: contents
268
- });
269
- }
270
- return contents;
271
- }));
272
- ToastViewport.displayName = VIEWPORT_NAME;
273
- const FOCUS_PROXY_NAME = "ToastFocusProxy";
274
- const FocusProxy = React.forwardRef((props, forwardedRef) => {
275
- const {
276
- onFocusFromOutsideViewport,
277
- viewportName,
278
- context,
279
- ...proxyProps
280
- } = props;
281
- const viewport = context.viewports[viewportName];
282
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_visually_hidden.VisuallyHidden, {
283
- "aria-hidden": true,
284
- tabIndex: 0,
285
- ...proxyProps,
286
- ref: forwardedRef,
287
- position: import_constants.isWeb ? "fixed" : "absolute",
288
- onFocus: event => {
289
- if (!import_constants.isWeb) return;
290
- const prevFocusedElement = event.relatedTarget;
291
- const isFocusFromOutsideViewport = !viewport?.contains(prevFocusedElement);
292
- if (isFocusFromOutsideViewport) onFocusFromOutsideViewport();
293
- }
294
- });
295
- });
296
- FocusProxy.displayName = FOCUS_PROXY_NAME;
297
- function focusFirst(candidates) {
298
- if (!import_constants.isWeb) return;
299
- const previouslyFocusedElement = document.activeElement;
300
- return candidates.some(candidate => {
301
- if (candidate === previouslyFocusedElement) return true;
302
- candidate.focus();
303
- return document.activeElement !== previouslyFocusedElement;
304
- });
305
- }
306
- function getTabbableCandidates(container) {
307
- if (!import_constants.isWeb) return [];
308
- const containerHtml = container;
309
- const nodes = [];
310
- const walker = document.createTreeWalker(containerHtml, NodeFilter.SHOW_ELEMENT, {
311
- acceptNode: node => {
312
- const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
313
- if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
314
- return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
315
- }
316
- });
317
- while (walker.nextNode()) nodes.push(walker.currentNode);
318
- return nodes;
319
- }
@@ -1,343 +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 ToastViewport_exports = {};
37
- __export(ToastViewport_exports, {
38
- ToastViewport: () => ToastViewport,
39
- VIEWPORT_DEFAULT_HOTKEY: () => VIEWPORT_DEFAULT_HOTKEY,
40
- VIEWPORT_PAUSE: () => VIEWPORT_PAUSE,
41
- VIEWPORT_RESUME: () => VIEWPORT_RESUME
42
- });
43
- module.exports = __toCommonJS(ToastViewport_exports);
44
- var import_jsx_runtime = require("react/jsx-runtime");
45
- var import_animate_presence = require("@hanzogui/animate-presence");
46
- var import_compose_refs = require("@hanzogui/compose-refs");
47
- var import_constants = require("@hanzogui/constants");
48
- var import_core = require("@hanzogui/core");
49
- var import_portal = require("@hanzogui/portal");
50
- var import_stacks = require("@hanzogui/stacks");
51
- var import_visually_hidden = require("@hanzogui/visually-hidden");
52
- var React = __toESM(require("react"), 1);
53
- var import_constants2 = require("./constants.native.js");
54
- var import_ToastPortal = require("./ToastPortal.native.js");
55
- var import_ToastProvider = require("./ToastProvider.native.js");
56
- var VIEWPORT_NAME = "ToastViewport";
57
- var VIEWPORT_DEFAULT_HOTKEY = ["F8"];
58
- var VIEWPORT_PAUSE = "toast.viewportPause";
59
- var VIEWPORT_RESUME = "toast.viewportResume";
60
- var ToastViewportWrapperFrame = (0, import_core.styled)(import_stacks.YStack, {
61
- name: "ViewportWrapper",
62
- variants: {
63
- unstyled: {
64
- false: {
65
- pointerEvents: "box-none",
66
- top: 0,
67
- bottom: 0,
68
- left: 0,
69
- right: 0,
70
- position: import_constants.isWeb ? "fixed" : "absolute",
71
- maxWidth: "100%",
72
- tabIndex: 0,
73
- zIndex: 1e5
74
- }
75
- }
76
- },
77
- defaultVariants: {
78
- unstyled: process.env.GUI_HEADLESS === "1"
79
- }
80
- });
81
- var ToastViewportFrame = (0, import_core.styled)(import_stacks.YStack, {
82
- name: VIEWPORT_NAME,
83
- variants: {
84
- unstyled: {
85
- false: {
86
- pointerEvents: "box-none",
87
- position: import_constants.isWeb ? "fixed" : "absolute",
88
- maxWidth: "100%"
89
- }
90
- }
91
- },
92
- defaultVariants: {
93
- unstyled: process.env.GUI_HEADLESS === "1"
94
- }
95
- });
96
- var ToastViewport = /* @__PURE__ */React.memo(/* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
97
- var {
98
- scope,
99
- hotkey = VIEWPORT_DEFAULT_HOTKEY,
100
- label = "Notifications ({hotkey})",
101
- name = "default",
102
- multipleToasts,
103
- zIndex,
104
- portalToRoot,
105
- ...viewportProps
106
- } = props;
107
- var context = (0, import_ToastProvider.useToastProviderContext)(scope);
108
- var getItems = (0, import_ToastProvider.useCollection)(scope || import_constants2.TOAST_CONTEXT);
109
- var headFocusProxyRef = React.useRef(null);
110
- var tailFocusProxyRef = React.useRef(null);
111
- var wrapperRef = React.useRef(null);
112
- var ref = React.useRef(null);
113
- var onViewportChange = React.useCallback(function (el) {
114
- if (context.viewports[name] !== el) context.onViewportChange(name, el);
115
- }, [name, context.viewports]);
116
- var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, onViewportChange);
117
- var hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
118
- var hasToasts = context.toastCount > 0;
119
- React.useEffect(function () {
120
- if (!import_constants.isWeb) return;
121
- if (context.toastCount === 0) return;
122
- var handleKeyDown = function (event) {
123
- var _ref_current;
124
- var isHotkeyPressed = hotkey.every(function (key) {
125
- return event[key] || event.code === key;
126
- });
127
- if (isHotkeyPressed) (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
128
- };
129
- document.addEventListener("keydown", handleKeyDown);
130
- return function () {
131
- document.removeEventListener("keydown", handleKeyDown);
132
- };
133
- }, [hotkey, context.toastCount]);
134
- React.useEffect(function () {
135
- if (!import_constants.isWeb) return;
136
- if (context.toastCount === 0) return;
137
- var wrapper = wrapperRef.current;
138
- var viewport = ref.current;
139
- if (hasToasts && wrapper && viewport) {
140
- var handlePause = function () {
141
- if (!context.isClosePausedRef.current) {
142
- var pauseEvent = new CustomEvent(VIEWPORT_PAUSE);
143
- viewport.dispatchEvent(pauseEvent);
144
- context.isClosePausedRef.current = true;
145
- }
146
- };
147
- var handleResume = function () {
148
- if (context.isClosePausedRef.current) {
149
- var resumeEvent = new CustomEvent(VIEWPORT_RESUME);
150
- viewport.dispatchEvent(resumeEvent);
151
- context.isClosePausedRef.current = false;
152
- }
153
- };
154
- var handleFocusOutResume = function (event) {
155
- var isFocusMovingOutside = !wrapper.contains(event.relatedTarget);
156
- if (isFocusMovingOutside) handleResume();
157
- };
158
- var handlePointerLeaveResume = function () {
159
- var isFocusInside = wrapper.contains(document.activeElement);
160
- if (!isFocusInside) handleResume();
161
- };
162
- wrapper.addEventListener("focusin", handlePause);
163
- wrapper.addEventListener("focusout", handleFocusOutResume);
164
- wrapper.addEventListener("pointermove", handlePause);
165
- wrapper.addEventListener("pointerleave", handlePointerLeaveResume);
166
- window.addEventListener("blur", handlePause);
167
- window.addEventListener("focus", handleResume);
168
- return function () {
169
- wrapper.removeEventListener("focusin", handlePause);
170
- wrapper.removeEventListener("focusout", handleFocusOutResume);
171
- wrapper.removeEventListener("pointermove", handlePause);
172
- wrapper.removeEventListener("pointerleave", handlePointerLeaveResume);
173
- window.removeEventListener("blur", handlePause);
174
- window.removeEventListener("focus", handleResume);
175
- };
176
- }
177
- }, [hasToasts, context.isClosePausedRef, context.toastCount]);
178
- var getSortedTabbableCandidates = React.useCallback(function (param) {
179
- var {
180
- tabbingDirection
181
- } = param;
182
- var toastItems = getItems();
183
- var tabbableCandidates = toastItems.map(function (toastItem) {
184
- var toastNode = toastItem.ref.current;
185
- var toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];
186
- return tabbingDirection === "forwards" ? toastTabbableCandidates : toastTabbableCandidates.reverse();
187
- });
188
- return (tabbingDirection === "forwards" ? tabbableCandidates.reverse() : tabbableCandidates).flat();
189
- }, [getItems]);
190
- React.useEffect(function () {
191
- if (!import_constants.isWeb) return;
192
- if (context.toastCount === 0) return;
193
- var viewport = ref.current;
194
- if (viewport) {
195
- var handleKeyDown = function (event) {
196
- var isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
197
- var isTabKey = event.key === "Tab" && !isMetaKey;
198
- if (isTabKey) {
199
- var focusedElement = document.activeElement;
200
- var isTabbingBackwards = event.shiftKey;
201
- var targetIsViewport = event.target === viewport;
202
- if (targetIsViewport && isTabbingBackwards) {
203
- var _headFocusProxyRef_current;
204
- (_headFocusProxyRef_current = headFocusProxyRef.current) === null || _headFocusProxyRef_current === void 0 ? void 0 : _headFocusProxyRef_current.focus();
205
- return;
206
- }
207
- var tabbingDirection = isTabbingBackwards ? "backwards" : "forwards";
208
- var sortedCandidates = getSortedTabbableCandidates({
209
- tabbingDirection
210
- });
211
- var index = sortedCandidates.findIndex(function (candidate) {
212
- return candidate === focusedElement;
213
- });
214
- if (focusFirst(sortedCandidates.slice(index + 1))) {
215
- event.preventDefault();
216
- } else {
217
- var _headFocusProxyRef_current1, _tailFocusProxyRef_current;
218
- isTabbingBackwards ? (_headFocusProxyRef_current1 = headFocusProxyRef.current) === null || _headFocusProxyRef_current1 === void 0 ? void 0 : _headFocusProxyRef_current1.focus() : (_tailFocusProxyRef_current = tailFocusProxyRef.current) === null || _tailFocusProxyRef_current === void 0 ? void 0 : _tailFocusProxyRef_current.focus();
219
- }
220
- }
221
- };
222
- viewport.addEventListener("keydown", handleKeyDown);
223
- return function () {
224
- return viewport.removeEventListener("keydown", handleKeyDown);
225
- };
226
- }
227
- }, [getItems, getSortedTabbableCandidates, context.toastCount]);
228
- var contents = /* @__PURE__ */(0, import_jsx_runtime.jsxs)(ToastViewportWrapperFrame, {
229
- ref: wrapperRef,
230
- // biome-ignore lint/a11y/useSemanticElements: <explanation>
231
- role: "region",
232
- "aria-label": label.replace("{hotkey}", hotkeyLabel),
233
- // // Ensure virtual cursor from landmarks menus triggers focus/blur for pause/resume
234
- tabIndex: -1,
235
- children: [
236
- // // incase list has size when empty (e.g. padding), we remove pointer events so
237
- // // it doesn't prevent interactions with page elements that it overlays
238
- // pointerEvents={hasToasts ? undefined : 'none'}
239
- hasToasts && /* @__PURE__ */(0, import_jsx_runtime.jsx)(FocusProxy, {
240
- context,
241
- viewportName: name,
242
- ref: headFocusProxyRef,
243
- onFocusFromOutsideViewport: function () {
244
- var tabbableCandidates = getSortedTabbableCandidates({
245
- tabbingDirection: "forwards"
246
- });
247
- focusFirst(tabbableCandidates);
248
- }
249
- }),
250
- /**
251
- * tabindex on the the list so that it can be focused when items are removed. we focus
252
- * the list instead of the viewport so it announces number of items remaining.
253
- */
254
- /* @__PURE__ */
255
- (0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.Slot, {
256
- scope: context.toastScope,
257
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastViewportFrame, {
258
- focusable: context.toastCount > 0,
259
- ref: composedRefs,
260
- ...viewportProps,
261
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.PortalHost, {
262
- render: function (children) {
263
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
264
- exitBeforeEnter: !multipleToasts,
265
- children
266
- });
267
- },
268
- name: name !== null && name !== void 0 ? name : "default"
269
- })
270
- })
271
- }), hasToasts && /* @__PURE__ */(0, import_jsx_runtime.jsx)(FocusProxy, {
272
- context,
273
- viewportName: name,
274
- ref: tailFocusProxyRef,
275
- onFocusFromOutsideViewport: function () {
276
- var tabbableCandidates = getSortedTabbableCandidates({
277
- tabbingDirection: "backwards"
278
- });
279
- focusFirst(tabbableCandidates);
280
- }
281
- })]
282
- });
283
- if (portalToRoot) {
284
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastPortal.ToastPortal, {
285
- context,
286
- ...(typeof zIndex === "number" ? {
287
- zIndex
288
- } : {}),
289
- children: contents
290
- });
291
- }
292
- return contents;
293
- }));
294
- ToastViewport.displayName = VIEWPORT_NAME;
295
- var FOCUS_PROXY_NAME = "ToastFocusProxy";
296
- var FocusProxy = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
297
- var {
298
- onFocusFromOutsideViewport,
299
- viewportName,
300
- context,
301
- ...proxyProps
302
- } = props;
303
- var viewport = context.viewports[viewportName];
304
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_visually_hidden.VisuallyHidden, {
305
- "aria-hidden": true,
306
- tabIndex: 0,
307
- ...proxyProps,
308
- ref: forwardedRef,
309
- // Avoid page scrolling when focus is on the focus proxy
310
- position: import_constants.isWeb ? "fixed" : "absolute",
311
- onFocus: function (event) {
312
- if (!import_constants.isWeb) return;
313
- var prevFocusedElement = event.relatedTarget;
314
- var isFocusFromOutsideViewport = !(viewport === null || viewport === void 0 ? void 0 : viewport.contains(prevFocusedElement));
315
- if (isFocusFromOutsideViewport) onFocusFromOutsideViewport();
316
- }
317
- });
318
- });
319
- FocusProxy.displayName = FOCUS_PROXY_NAME;
320
- function focusFirst(candidates) {
321
- if (!import_constants.isWeb) return;
322
- var previouslyFocusedElement = document.activeElement;
323
- return candidates.some(function (candidate) {
324
- if (candidate === previouslyFocusedElement) return true;
325
- candidate.focus();
326
- return document.activeElement !== previouslyFocusedElement;
327
- });
328
- }
329
- function getTabbableCandidates(container) {
330
- if (!import_constants.isWeb) return [];
331
- var containerHtml = container;
332
- var nodes = [];
333
- var walker = document.createTreeWalker(containerHtml, NodeFilter.SHOW_ELEMENT, {
334
- acceptNode: function (node) {
335
- var isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
336
- if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
337
- return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
338
- }
339
- });
340
- while (walker.nextNode()) nodes.push(walker.currentNode);
341
- return nodes;
342
- }
343
- //# sourceMappingURL=ToastViewport.native.js.map