@tamagui/v2-toast 2.0.0-1769464493958

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 (307) hide show
  1. package/dist/cjs/Toast.cjs +170 -0
  2. package/dist/cjs/Toast.js +119 -0
  3. package/dist/cjs/Toast.js.map +6 -0
  4. package/dist/cjs/Toast.native.js +174 -0
  5. package/dist/cjs/Toast.native.js.map +1 -0
  6. package/dist/cjs/ToastAnnounce.cjs +97 -0
  7. package/dist/cjs/ToastAnnounce.js +72 -0
  8. package/dist/cjs/ToastAnnounce.js.map +6 -0
  9. package/dist/cjs/ToastAnnounce.native.js +105 -0
  10. package/dist/cjs/ToastAnnounce.native.js.map +1 -0
  11. package/dist/cjs/ToastImperative.cjs +100 -0
  12. package/dist/cjs/ToastImperative.js +71 -0
  13. package/dist/cjs/ToastImperative.js.map +6 -0
  14. package/dist/cjs/ToastImperative.native.js +122 -0
  15. package/dist/cjs/ToastImperative.native.js.map +1 -0
  16. package/dist/cjs/ToastImpl.cjs +292 -0
  17. package/dist/cjs/ToastImpl.js +227 -0
  18. package/dist/cjs/ToastImpl.js.map +6 -0
  19. package/dist/cjs/ToastImpl.native.js +327 -0
  20. package/dist/cjs/ToastImpl.native.js.map +1 -0
  21. package/dist/cjs/ToastItem.cjs +466 -0
  22. package/dist/cjs/ToastItem.js +356 -0
  23. package/dist/cjs/ToastItem.js.map +6 -0
  24. package/dist/cjs/ToastItem.native.js +547 -0
  25. package/dist/cjs/ToastItem.native.js.map +1 -0
  26. package/dist/cjs/ToastPortal.cjs +44 -0
  27. package/dist/cjs/ToastPortal.js +26 -0
  28. package/dist/cjs/ToastPortal.js.map +6 -0
  29. package/dist/cjs/ToastPortal.native.js +47 -0
  30. package/dist/cjs/ToastPortal.native.js.map +1 -0
  31. package/dist/cjs/ToastProvider.cjs +146 -0
  32. package/dist/cjs/ToastProvider.js +105 -0
  33. package/dist/cjs/ToastProvider.js.map +6 -0
  34. package/dist/cjs/ToastProvider.native.js +159 -0
  35. package/dist/cjs/ToastProvider.native.js.map +1 -0
  36. package/dist/cjs/ToastState.cjs +248 -0
  37. package/dist/cjs/ToastState.js +160 -0
  38. package/dist/cjs/ToastState.js.map +6 -0
  39. package/dist/cjs/ToastState.native.js +257 -0
  40. package/dist/cjs/ToastState.native.js.map +1 -0
  41. package/dist/cjs/ToastViewport.cjs +278 -0
  42. package/dist/cjs/ToastViewport.js +263 -0
  43. package/dist/cjs/ToastViewport.js.map +6 -0
  44. package/dist/cjs/ToastViewport.native.js +316 -0
  45. package/dist/cjs/ToastViewport.native.js.map +1 -0
  46. package/dist/cjs/Toaster.cjs +219 -0
  47. package/dist/cjs/Toaster.js +177 -0
  48. package/dist/cjs/Toaster.js.map +6 -0
  49. package/dist/cjs/Toaster.native.js +279 -0
  50. package/dist/cjs/Toaster.native.js.map +1 -0
  51. package/dist/cjs/constants.cjs +28 -0
  52. package/dist/cjs/constants.js +22 -0
  53. package/dist/cjs/constants.js.map +6 -0
  54. package/dist/cjs/constants.native.js +31 -0
  55. package/dist/cjs/constants.native.js.map +1 -0
  56. package/dist/cjs/createNativeToast.cjs +51 -0
  57. package/dist/cjs/createNativeToast.js +44 -0
  58. package/dist/cjs/createNativeToast.js.map +6 -0
  59. package/dist/cjs/createNativeToast.native.js +47 -0
  60. package/dist/cjs/createNativeToast.native.js.map +1 -0
  61. package/dist/cjs/index.cjs +28 -0
  62. package/dist/cjs/index.js +22 -0
  63. package/dist/cjs/index.js.map +6 -0
  64. package/dist/cjs/index.native.js +31 -0
  65. package/dist/cjs/index.native.js.map +1 -0
  66. package/dist/cjs/types.cjs +16 -0
  67. package/dist/cjs/types.js +14 -0
  68. package/dist/cjs/types.js.map +6 -0
  69. package/dist/cjs/types.native.js +19 -0
  70. package/dist/cjs/types.native.js.map +1 -0
  71. package/dist/cjs/useDragGesture.cjs +129 -0
  72. package/dist/cjs/useDragGesture.js +100 -0
  73. package/dist/cjs/useDragGesture.js.map +6 -0
  74. package/dist/cjs/useDragGesture.native.js +146 -0
  75. package/dist/cjs/useDragGesture.native.js.map +1 -0
  76. package/dist/esm/Toast.js +107 -0
  77. package/dist/esm/Toast.js.map +6 -0
  78. package/dist/esm/Toast.mjs +131 -0
  79. package/dist/esm/Toast.mjs.map +1 -0
  80. package/dist/esm/Toast.native.js +132 -0
  81. package/dist/esm/Toast.native.js.map +1 -0
  82. package/dist/esm/ToastAnnounce.js +55 -0
  83. package/dist/esm/ToastAnnounce.js.map +6 -0
  84. package/dist/esm/ToastAnnounce.mjs +62 -0
  85. package/dist/esm/ToastAnnounce.mjs.map +1 -0
  86. package/dist/esm/ToastAnnounce.native.js +67 -0
  87. package/dist/esm/ToastAnnounce.native.js.map +1 -0
  88. package/dist/esm/ToastImperative.js +50 -0
  89. package/dist/esm/ToastImperative.js.map +6 -0
  90. package/dist/esm/ToastImperative.mjs +63 -0
  91. package/dist/esm/ToastImperative.mjs.map +1 -0
  92. package/dist/esm/ToastImperative.native.js +82 -0
  93. package/dist/esm/ToastImperative.native.js.map +1 -0
  94. package/dist/esm/ToastImpl.js +225 -0
  95. package/dist/esm/ToastImpl.js.map +6 -0
  96. package/dist/esm/ToastImpl.mjs +256 -0
  97. package/dist/esm/ToastImpl.mjs.map +1 -0
  98. package/dist/esm/ToastImpl.native.js +288 -0
  99. package/dist/esm/ToastImpl.native.js.map +1 -0
  100. package/dist/esm/ToastItem.js +339 -0
  101. package/dist/esm/ToastItem.js.map +6 -0
  102. package/dist/esm/ToastItem.mjs +432 -0
  103. package/dist/esm/ToastItem.mjs.map +1 -0
  104. package/dist/esm/ToastItem.native.js +510 -0
  105. package/dist/esm/ToastItem.native.js.map +1 -0
  106. package/dist/esm/ToastPortal.js +13 -0
  107. package/dist/esm/ToastPortal.js.map +6 -0
  108. package/dist/esm/ToastPortal.mjs +21 -0
  109. package/dist/esm/ToastPortal.mjs.map +1 -0
  110. package/dist/esm/ToastPortal.native.js +21 -0
  111. package/dist/esm/ToastPortal.native.js.map +1 -0
  112. package/dist/esm/ToastProvider.js +87 -0
  113. package/dist/esm/ToastProvider.js.map +6 -0
  114. package/dist/esm/ToastProvider.mjs +108 -0
  115. package/dist/esm/ToastProvider.mjs.map +1 -0
  116. package/dist/esm/ToastProvider.native.js +118 -0
  117. package/dist/esm/ToastProvider.native.js.map +1 -0
  118. package/dist/esm/ToastState.js +144 -0
  119. package/dist/esm/ToastState.js.map +6 -0
  120. package/dist/esm/ToastState.mjs +224 -0
  121. package/dist/esm/ToastState.mjs.map +1 -0
  122. package/dist/esm/ToastState.native.js +230 -0
  123. package/dist/esm/ToastState.native.js.map +1 -0
  124. package/dist/esm/ToastViewport.js +250 -0
  125. package/dist/esm/ToastViewport.js.map +6 -0
  126. package/dist/esm/ToastViewport.mjs +241 -0
  127. package/dist/esm/ToastViewport.mjs.map +1 -0
  128. package/dist/esm/ToastViewport.native.js +276 -0
  129. package/dist/esm/ToastViewport.native.js.map +1 -0
  130. package/dist/esm/Toaster.js +160 -0
  131. package/dist/esm/Toaster.js.map +6 -0
  132. package/dist/esm/Toaster.mjs +185 -0
  133. package/dist/esm/Toaster.mjs.map +1 -0
  134. package/dist/esm/Toaster.native.js +242 -0
  135. package/dist/esm/Toaster.native.js.map +1 -0
  136. package/dist/esm/constants.js +6 -0
  137. package/dist/esm/constants.js.map +6 -0
  138. package/dist/esm/constants.mjs +4 -0
  139. package/dist/esm/constants.mjs.map +1 -0
  140. package/dist/esm/constants.native.js +4 -0
  141. package/dist/esm/constants.native.js.map +1 -0
  142. package/dist/esm/createNativeToast.js +28 -0
  143. package/dist/esm/createNativeToast.js.map +6 -0
  144. package/dist/esm/createNativeToast.mjs +27 -0
  145. package/dist/esm/createNativeToast.mjs.map +1 -0
  146. package/dist/esm/createNativeToast.native.js +20 -0
  147. package/dist/esm/createNativeToast.native.js.map +1 -0
  148. package/dist/esm/index.js +7 -0
  149. package/dist/esm/index.js.map +6 -0
  150. package/dist/esm/index.mjs +4 -0
  151. package/dist/esm/index.mjs.map +1 -0
  152. package/dist/esm/index.native.js +4 -0
  153. package/dist/esm/index.native.js.map +1 -0
  154. package/dist/esm/types.js +1 -0
  155. package/dist/esm/types.js.map +6 -0
  156. package/dist/esm/types.mjs +2 -0
  157. package/dist/esm/types.mjs.map +1 -0
  158. package/dist/esm/types.native.js +2 -0
  159. package/dist/esm/types.native.js.map +1 -0
  160. package/dist/esm/useDragGesture.js +76 -0
  161. package/dist/esm/useDragGesture.js.map +6 -0
  162. package/dist/esm/useDragGesture.mjs +95 -0
  163. package/dist/esm/useDragGesture.mjs.map +1 -0
  164. package/dist/esm/useDragGesture.native.js +109 -0
  165. package/dist/esm/useDragGesture.native.js.map +1 -0
  166. package/dist/jsx/Toast.js +107 -0
  167. package/dist/jsx/Toast.js.map +6 -0
  168. package/dist/jsx/Toast.mjs +131 -0
  169. package/dist/jsx/Toast.mjs.map +1 -0
  170. package/dist/jsx/Toast.native.js +174 -0
  171. package/dist/jsx/Toast.native.js.map +1 -0
  172. package/dist/jsx/ToastAnnounce.js +55 -0
  173. package/dist/jsx/ToastAnnounce.js.map +6 -0
  174. package/dist/jsx/ToastAnnounce.mjs +62 -0
  175. package/dist/jsx/ToastAnnounce.mjs.map +1 -0
  176. package/dist/jsx/ToastAnnounce.native.js +105 -0
  177. package/dist/jsx/ToastAnnounce.native.js.map +1 -0
  178. package/dist/jsx/ToastImperative.js +50 -0
  179. package/dist/jsx/ToastImperative.js.map +6 -0
  180. package/dist/jsx/ToastImperative.mjs +63 -0
  181. package/dist/jsx/ToastImperative.mjs.map +1 -0
  182. package/dist/jsx/ToastImperative.native.js +122 -0
  183. package/dist/jsx/ToastImperative.native.js.map +1 -0
  184. package/dist/jsx/ToastImpl.js +225 -0
  185. package/dist/jsx/ToastImpl.js.map +6 -0
  186. package/dist/jsx/ToastImpl.mjs +256 -0
  187. package/dist/jsx/ToastImpl.mjs.map +1 -0
  188. package/dist/jsx/ToastImpl.native.js +327 -0
  189. package/dist/jsx/ToastImpl.native.js.map +1 -0
  190. package/dist/jsx/ToastItem.js +339 -0
  191. package/dist/jsx/ToastItem.js.map +6 -0
  192. package/dist/jsx/ToastItem.mjs +432 -0
  193. package/dist/jsx/ToastItem.mjs.map +1 -0
  194. package/dist/jsx/ToastItem.native.js +547 -0
  195. package/dist/jsx/ToastItem.native.js.map +1 -0
  196. package/dist/jsx/ToastPortal.js +13 -0
  197. package/dist/jsx/ToastPortal.js.map +6 -0
  198. package/dist/jsx/ToastPortal.mjs +21 -0
  199. package/dist/jsx/ToastPortal.mjs.map +1 -0
  200. package/dist/jsx/ToastPortal.native.js +47 -0
  201. package/dist/jsx/ToastPortal.native.js.map +1 -0
  202. package/dist/jsx/ToastProvider.js +87 -0
  203. package/dist/jsx/ToastProvider.js.map +6 -0
  204. package/dist/jsx/ToastProvider.mjs +108 -0
  205. package/dist/jsx/ToastProvider.mjs.map +1 -0
  206. package/dist/jsx/ToastProvider.native.js +159 -0
  207. package/dist/jsx/ToastProvider.native.js.map +1 -0
  208. package/dist/jsx/ToastState.js +144 -0
  209. package/dist/jsx/ToastState.js.map +6 -0
  210. package/dist/jsx/ToastState.mjs +224 -0
  211. package/dist/jsx/ToastState.mjs.map +1 -0
  212. package/dist/jsx/ToastState.native.js +257 -0
  213. package/dist/jsx/ToastState.native.js.map +1 -0
  214. package/dist/jsx/ToastViewport.js +250 -0
  215. package/dist/jsx/ToastViewport.js.map +6 -0
  216. package/dist/jsx/ToastViewport.mjs +241 -0
  217. package/dist/jsx/ToastViewport.mjs.map +1 -0
  218. package/dist/jsx/ToastViewport.native.js +316 -0
  219. package/dist/jsx/ToastViewport.native.js.map +1 -0
  220. package/dist/jsx/Toaster.js +160 -0
  221. package/dist/jsx/Toaster.js.map +6 -0
  222. package/dist/jsx/Toaster.mjs +185 -0
  223. package/dist/jsx/Toaster.mjs.map +1 -0
  224. package/dist/jsx/Toaster.native.js +279 -0
  225. package/dist/jsx/Toaster.native.js.map +1 -0
  226. package/dist/jsx/constants.js +6 -0
  227. package/dist/jsx/constants.js.map +6 -0
  228. package/dist/jsx/constants.mjs +4 -0
  229. package/dist/jsx/constants.mjs.map +1 -0
  230. package/dist/jsx/constants.native.js +31 -0
  231. package/dist/jsx/constants.native.js.map +1 -0
  232. package/dist/jsx/createNativeToast.js +28 -0
  233. package/dist/jsx/createNativeToast.js.map +6 -0
  234. package/dist/jsx/createNativeToast.mjs +27 -0
  235. package/dist/jsx/createNativeToast.mjs.map +1 -0
  236. package/dist/jsx/createNativeToast.native.js +47 -0
  237. package/dist/jsx/createNativeToast.native.js.map +1 -0
  238. package/dist/jsx/index.js +7 -0
  239. package/dist/jsx/index.js.map +6 -0
  240. package/dist/jsx/index.mjs +4 -0
  241. package/dist/jsx/index.mjs.map +1 -0
  242. package/dist/jsx/index.native.js +31 -0
  243. package/dist/jsx/index.native.js.map +1 -0
  244. package/dist/jsx/types.js +1 -0
  245. package/dist/jsx/types.js.map +6 -0
  246. package/dist/jsx/types.mjs +2 -0
  247. package/dist/jsx/types.mjs.map +1 -0
  248. package/dist/jsx/types.native.js +19 -0
  249. package/dist/jsx/types.native.js.map +1 -0
  250. package/dist/jsx/useDragGesture.js +76 -0
  251. package/dist/jsx/useDragGesture.js.map +6 -0
  252. package/dist/jsx/useDragGesture.mjs +95 -0
  253. package/dist/jsx/useDragGesture.mjs.map +1 -0
  254. package/dist/jsx/useDragGesture.native.js +146 -0
  255. package/dist/jsx/useDragGesture.native.js.map +1 -0
  256. package/package.json +77 -0
  257. package/src/Toast.tsx +219 -0
  258. package/src/ToastAnnounce.tsx +102 -0
  259. package/src/ToastImperative.tsx +190 -0
  260. package/src/ToastImpl.tsx +503 -0
  261. package/src/ToastItem.tsx +694 -0
  262. package/src/ToastPortal.tsx +19 -0
  263. package/src/ToastProvider.tsx +197 -0
  264. package/src/ToastState.ts +397 -0
  265. package/src/ToastViewport.tsx +430 -0
  266. package/src/Toaster.tsx +445 -0
  267. package/src/constants.ts +2 -0
  268. package/src/createNativeToast.native.tsx +22 -0
  269. package/src/createNativeToast.tsx +48 -0
  270. package/src/index.ts +17 -0
  271. package/src/types.ts +71 -0
  272. package/src/useDragGesture.native.ts +199 -0
  273. package/src/useDragGesture.ts +218 -0
  274. package/types/Toast.d.ts +84 -0
  275. package/types/Toast.d.ts.map +1 -0
  276. package/types/ToastAnnounce.d.ts +18 -0
  277. package/types/ToastAnnounce.d.ts.map +1 -0
  278. package/types/ToastImperative.d.ts +95 -0
  279. package/types/ToastImperative.d.ts.map +1 -0
  280. package/types/ToastImpl.d.ts +109 -0
  281. package/types/ToastImpl.d.ts.map +1 -0
  282. package/types/ToastItem.d.ts +34 -0
  283. package/types/ToastItem.d.ts.map +1 -0
  284. package/types/ToastPortal.d.ts +8 -0
  285. package/types/ToastPortal.d.ts.map +1 -0
  286. package/types/ToastProvider.d.ts +92 -0
  287. package/types/ToastProvider.d.ts.map +1 -0
  288. package/types/ToastState.d.ts +177 -0
  289. package/types/ToastState.d.ts.map +1 -0
  290. package/types/ToastViewport.d.ts +75 -0
  291. package/types/ToastViewport.d.ts.map +1 -0
  292. package/types/Toaster.d.ts +120 -0
  293. package/types/Toaster.d.ts.map +1 -0
  294. package/types/constants.d.ts +3 -0
  295. package/types/constants.d.ts.map +1 -0
  296. package/types/createNativeToast.d.ts +4 -0
  297. package/types/createNativeToast.d.ts.map +1 -0
  298. package/types/createNativeToast.native.d.ts +4 -0
  299. package/types/createNativeToast.native.d.ts.map +1 -0
  300. package/types/index.d.ts +7 -0
  301. package/types/index.d.ts.map +1 -0
  302. package/types/types.d.ts +61 -0
  303. package/types/types.d.ts.map +1 -0
  304. package/types/useDragGesture.d.ts +32 -0
  305. package/types/useDragGesture.d.ts.map +1 -0
  306. package/types/useDragGesture.native.d.ts +26 -0
  307. package/types/useDragGesture.native.d.ts.map +1 -0
@@ -0,0 +1,466 @@
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
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var ToastItem_exports = {};
33
+ __export(ToastItem_exports, {
34
+ ToastItem: () => ToastItem
35
+ });
36
+ module.exports = __toCommonJS(ToastItem_exports);
37
+ var import_constants = require("@tamagui/constants"),
38
+ import_core = require("@tamagui/core"),
39
+ import_stacks = require("@tamagui/stacks"),
40
+ import_text = require("@tamagui/text"),
41
+ React = __toESM(require("react"), 1),
42
+ import_useDragGesture = require("./useDragGesture.cjs"),
43
+ import_createNativeToast = require("./createNativeToast.cjs"),
44
+ import_jsx_runtime = require("react/jsx-runtime");
45
+ const TIME_BEFORE_UNMOUNT = 200,
46
+ ToastItemFrame = (0, import_core.styled)(import_stacks.YStack, {
47
+ name: "ToastItem",
48
+ focusable: !0,
49
+ pointerEvents: "auto",
50
+ position: "absolute",
51
+ left: 0,
52
+ right: 0,
53
+ // for stacking animation - default visible state
54
+ opacity: 1,
55
+ scale: 1,
56
+ y: 0,
57
+ x: 0,
58
+ variants: {
59
+ unstyled: {
60
+ false: {
61
+ backgroundColor: "$background",
62
+ borderRadius: "$4",
63
+ paddingHorizontal: "$4",
64
+ paddingVertical: "$3",
65
+ // shadow using elevation for cross-platform
66
+ elevation: "$4",
67
+ shadowColor: "$shadowColor",
68
+ shadowOffset: {
69
+ width: 0,
70
+ height: 4
71
+ },
72
+ shadowOpacity: 0.15,
73
+ shadowRadius: 12,
74
+ borderWidth: 1,
75
+ borderColor: "$borderColor",
76
+ // only show focus outline on keyboard navigation, not on click/tap
77
+ focusVisibleStyle: {
78
+ outlineStyle: "solid",
79
+ outlineWidth: 2,
80
+ outlineColor: "$outlineColor"
81
+ }
82
+ }
83
+ }
84
+ },
85
+ defaultVariants: {
86
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
87
+ }
88
+ }),
89
+ ToastItemTitle = (0, import_core.styled)(import_text.SizableText, {
90
+ name: "ToastItemTitle",
91
+ variants: {
92
+ unstyled: {
93
+ false: {
94
+ fontWeight: "600",
95
+ color: "$color",
96
+ size: "$4"
97
+ }
98
+ }
99
+ },
100
+ defaultVariants: {
101
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
102
+ }
103
+ }),
104
+ ToastItemDescription = (0, import_core.styled)(import_text.SizableText, {
105
+ name: "ToastItemDescription",
106
+ variants: {
107
+ unstyled: {
108
+ false: {
109
+ color: "$color11",
110
+ size: "$2",
111
+ marginTop: "$1"
112
+ }
113
+ }
114
+ },
115
+ defaultVariants: {
116
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
117
+ }
118
+ }),
119
+ ToastCloseButton = (0, import_core.styled)(import_stacks.XStack, {
120
+ name: "ToastCloseButton",
121
+ render: "button",
122
+ alignItems: "center",
123
+ justifyContent: "center",
124
+ cursor: "pointer",
125
+ variants: {
126
+ unstyled: {
127
+ false: {
128
+ width: 20,
129
+ height: 20,
130
+ borderRadius: "$10",
131
+ backgroundColor: "$color5",
132
+ hoverStyle: {
133
+ backgroundColor: "$color6"
134
+ },
135
+ pressStyle: {
136
+ backgroundColor: "$color7"
137
+ }
138
+ }
139
+ }
140
+ },
141
+ defaultVariants: {
142
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
143
+ }
144
+ }),
145
+ ToastActionButton = (0, import_core.styled)(import_stacks.XStack, {
146
+ name: "ToastActionButton",
147
+ render: "button",
148
+ alignItems: "center",
149
+ justifyContent: "center",
150
+ cursor: "pointer",
151
+ variants: {
152
+ unstyled: {
153
+ false: {
154
+ borderRadius: "$2",
155
+ paddingHorizontal: "$2",
156
+ height: 24,
157
+ backgroundColor: "$color5",
158
+ hoverStyle: {
159
+ backgroundColor: "$color6"
160
+ },
161
+ pressStyle: {
162
+ backgroundColor: "$color7"
163
+ }
164
+ }
165
+ },
166
+ // primary action button style
167
+ primary: {
168
+ true: {
169
+ backgroundColor: "$color12",
170
+ hoverStyle: {
171
+ backgroundColor: "$color11"
172
+ },
173
+ pressStyle: {
174
+ backgroundColor: "$color10"
175
+ }
176
+ }
177
+ }
178
+ },
179
+ defaultVariants: {
180
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
181
+ }
182
+ }),
183
+ DefaultCloseIcon = () => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.SizableText, {
184
+ size: "$1",
185
+ color: "$color11",
186
+ children: "\u2715"
187
+ }),
188
+ DefaultSuccessIcon = () => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.SizableText, {
189
+ size: "$5",
190
+ color: "$green10",
191
+ children: "\u2713"
192
+ }),
193
+ DefaultErrorIcon = () => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.SizableText, {
194
+ size: "$5",
195
+ color: "$red10",
196
+ children: "\u2715"
197
+ }),
198
+ DefaultWarningIcon = () => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.SizableText, {
199
+ size: "$5",
200
+ color: "$yellow10",
201
+ children: "\u26A0"
202
+ }),
203
+ DefaultInfoIcon = () => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.SizableText, {
204
+ size: "$5",
205
+ color: "$blue10",
206
+ children: "\u2139"
207
+ }),
208
+ DefaultLoadingIcon = () => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.SizableText, {
209
+ size: "$5",
210
+ color: "$color11",
211
+ children: "\u27F3"
212
+ }),
213
+ ToastItem = React.memo(function (props) {
214
+ const {
215
+ toast,
216
+ index,
217
+ expanded,
218
+ interacting,
219
+ position,
220
+ visibleToasts,
221
+ removeToast,
222
+ heights,
223
+ setHeights,
224
+ duration,
225
+ gap,
226
+ swipeDirection,
227
+ swipeThreshold,
228
+ closeButton,
229
+ icons,
230
+ disableNative,
231
+ burntOptions,
232
+ notificationOptions
233
+ } = props,
234
+ [mounted, setMounted] = React.useState(!1),
235
+ [removed, setRemoved] = React.useState(!1),
236
+ [swipeOut, setSwipeOut] = React.useState(!1),
237
+ toastRef = React.useRef(null),
238
+ closeTimerRef = React.useRef(null),
239
+ closeTimerStartRef = React.useRef(0),
240
+ lastPauseTimeRef = React.useRef(0),
241
+ remainingTimeRef = React.useRef(duration),
242
+ isFront = index === 0,
243
+ isVisible = index < visibleToasts,
244
+ toastType = toast.type ?? "default",
245
+ dismissible = toast.dismissible !== !1,
246
+ heightIndex = React.useMemo(() => heights.findIndex(h => h.toastId === toast.id) || 0, [heights, toast.id]),
247
+ toastsHeightBefore = React.useMemo(() => heights.reduce((prev, curr, reducerIndex) => reducerIndex >= heightIndex ? prev : prev + curr.height, 0), [heights, heightIndex]),
248
+ offset = heightIndex * gap + toastsHeightBefore,
249
+ [yPosition] = position.split("-"),
250
+ isTop = yPosition === "top";
251
+ React.useEffect(() => {
252
+ if (!disableNative && !import_constants.isWeb) {
253
+ const titleText = typeof toast.title == "function" ? toast.title() : toast.title,
254
+ descText = typeof toast.description == "function" ? toast.description() : toast.description;
255
+ typeof titleText == "string" && (0, import_createNativeToast.createNativeToast)(titleText, {
256
+ message: typeof descText == "string" ? descText : void 0,
257
+ duration,
258
+ burntOptions,
259
+ notificationOptions
260
+ });
261
+ }
262
+ }, []), React.useEffect(() => {
263
+ setMounted(!0);
264
+ }, []), React.useEffect(() => {
265
+ toast.delete && (setRemoved(!0), setTimeout(() => {
266
+ removeToast(toast);
267
+ }, TIME_BEFORE_UNMOUNT));
268
+ }, [toast.delete, toast, removeToast]);
269
+ const startTimer = React.useCallback(() => {
270
+ duration === Number.POSITIVE_INFINITY || toastType === "loading" || (closeTimerStartRef.current = Date.now(), closeTimerRef.current = setTimeout(() => {
271
+ toast.onAutoClose?.(toast), setRemoved(!0), setTimeout(() => {
272
+ removeToast(toast);
273
+ }, TIME_BEFORE_UNMOUNT);
274
+ }, remainingTimeRef.current));
275
+ }, [duration, toastType, toast, removeToast]),
276
+ pauseTimer = (0, import_core.useEvent)(() => {
277
+ if (closeTimerRef.current && clearTimeout(closeTimerRef.current), lastPauseTimeRef.current < closeTimerStartRef.current) {
278
+ const elapsed = Date.now() - closeTimerStartRef.current;
279
+ remainingTimeRef.current = Math.max(0, remainingTimeRef.current - elapsed);
280
+ }
281
+ lastPauseTimeRef.current = Date.now();
282
+ }),
283
+ resumeTimer = (0, import_core.useEvent)(() => {
284
+ startTimer();
285
+ });
286
+ React.useEffect(() => (expanded || interacting ? pauseTimer() : startTimer(), () => {
287
+ closeTimerRef.current && clearTimeout(closeTimerRef.current);
288
+ }), [expanded, interacting, startTimer]), React.useEffect(() => {
289
+ remainingTimeRef.current = duration;
290
+ }, [duration]);
291
+ const {
292
+ dragState,
293
+ gestureHandlers
294
+ } = (0, import_useDragGesture.useDragGesture)({
295
+ direction: swipeDirection,
296
+ threshold: swipeThreshold,
297
+ disabled: !dismissible || toastType === "loading",
298
+ onDragStart: pauseTimer,
299
+ onDragEnd: dismissed => {
300
+ dismissed && (setSwipeOut(!0), toast.onDismiss?.(toast), setRemoved(!0), setTimeout(() => {
301
+ removeToast(toast);
302
+ }, TIME_BEFORE_UNMOUNT));
303
+ },
304
+ onDragCancel: resumeTimer
305
+ }),
306
+ handleLayout = React.useCallback(event => {
307
+ const {
308
+ height
309
+ } = event.nativeEvent.layout;
310
+ setHeights(prev => prev.find(h => h.toastId === toast.id) ? prev.map(h => h.toastId === toast.id ? {
311
+ ...h,
312
+ height
313
+ } : h) : [{
314
+ toastId: toast.id,
315
+ height,
316
+ position
317
+ }, ...prev]);
318
+ }, [toast.id, position, setHeights]);
319
+ React.useEffect(() => () => {
320
+ setHeights(prev => prev.filter(h => h.toastId !== toast.id));
321
+ }, [toast.id, setHeights]);
322
+ const handleClose = React.useCallback(() => {
323
+ dismissible && (toast.onDismiss?.(toast), setRemoved(!0), setTimeout(() => {
324
+ removeToast(toast);
325
+ }, TIME_BEFORE_UNMOUNT));
326
+ }, [dismissible, toast, removeToast]),
327
+ icon = toast.icon !== void 0 ? toast.icon : {
328
+ default: null,
329
+ success: icons?.success ?? /* @__PURE__ */(0, import_jsx_runtime.jsx)(DefaultSuccessIcon, {}),
330
+ error: icons?.error ?? /* @__PURE__ */(0, import_jsx_runtime.jsx)(DefaultErrorIcon, {}),
331
+ warning: icons?.warning ?? /* @__PURE__ */(0, import_jsx_runtime.jsx)(DefaultWarningIcon, {}),
332
+ info: icons?.info ?? /* @__PURE__ */(0, import_jsx_runtime.jsx)(DefaultInfoIcon, {}),
333
+ loading: icons?.loading ?? /* @__PURE__ */(0, import_jsx_runtime.jsx)(DefaultLoadingIcon, {})
334
+ }[toastType],
335
+ isHorizontalSwipe = swipeDirection === "left" || swipeDirection === "right" || swipeDirection === "horizontal",
336
+ isVerticalSwipe = swipeDirection === "up" || swipeDirection === "down" || swipeDirection === "vertical",
337
+ dragOffsetX = isHorizontalSwipe ? dragState.offsetX : 0,
338
+ dragOffsetY = isVerticalSwipe ? dragState.offsetY : 0,
339
+ stackScale = !expanded && !isFront ? 1 - index * 0.05 : 1,
340
+ frontToastHeight = heights.length > 0 ? heights[0]?.height ?? 55 : 55,
341
+ baseOffset = isTop ? offset : -offset,
342
+ liftPerToast = 10,
343
+ computedY = (expanded ? baseOffset : isFront ? 0 : isTop ? liftPerToast * index : -liftPerToast * index) + dragOffsetY,
344
+ computedX = dragOffsetX,
345
+ computedScale = stackScale;
346
+ let computedOpacity = 1;
347
+ index >= visibleToasts ? computedOpacity = 0 : !expanded && index === visibleToasts - 1 && (computedOpacity = 0.5);
348
+ const computedZIndex = visibleToasts - index,
349
+ computedHeight = !expanded && !isFront ? frontToastHeight : void 0,
350
+ computedPointerEvents = index >= visibleToasts ? "none" : "auto";
351
+ if (toast.jsx) return toast.jsx;
352
+ const title = typeof toast.title == "function" ? toast.title() : toast.title,
353
+ description = typeof toast.description == "function" ? toast.description() : toast.description,
354
+ dataSet = {
355
+ mounted: mounted ? "true" : "false",
356
+ removed: removed ? "true" : "false",
357
+ swipeOut: swipeOut ? "true" : "false",
358
+ visible: isVisible ? "true" : "false",
359
+ front: isFront ? "true" : "false",
360
+ index: String(index),
361
+ type: toastType,
362
+ expanded: expanded ? "true" : "false"
363
+ },
364
+ gapFillerHeight = expanded ? gap + 1 : 0;
365
+ return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(ToastItemFrame, {
366
+ ref: toastRef,
367
+ role: "status",
368
+ "aria-live": "polite",
369
+ "aria-atomic": !0,
370
+ tabIndex: 0,
371
+ dataSet,
372
+ "data-expanded": expanded ? "true" : "false",
373
+ onLayout: handleLayout,
374
+ transition: dragState.isDragging ? void 0 : "quick",
375
+ y: computedY,
376
+ x: computedX,
377
+ scale: computedScale,
378
+ opacity: computedOpacity,
379
+ zIndex: computedZIndex,
380
+ height: computedHeight,
381
+ overflow: computedHeight ? "hidden" : void 0,
382
+ pointerEvents: computedPointerEvents,
383
+ top: isTop ? 0 : void 0,
384
+ bottom: isTop ? void 0 : 0,
385
+ ...(import_constants.isWeb && !isFront && !expanded && {
386
+ style: {
387
+ transformOrigin: isTop ? "top center" : "bottom center"
388
+ }
389
+ }),
390
+ enterStyle: {
391
+ opacity: 0,
392
+ y: isTop ? -10 : 10,
393
+ scale: 0.95
394
+ },
395
+ exitStyle: {
396
+ opacity: 0,
397
+ // for swipe dismissal, continue in swipe direction with subtle movement
398
+ x: isHorizontalSwipe && swipeOut ? swipeDirection === "left" ? -30 : 30 : 0,
399
+ y: isVerticalSwipe && swipeOut ? swipeDirection === "up" ? -30 : 30 : isTop ? -10 : 10,
400
+ scale: 0.95
401
+ },
402
+ ...gestureHandlers,
403
+ ...(import_constants.isWeb && {
404
+ onKeyDown: event => {
405
+ event.key === "Escape" && dismissible && handleClose();
406
+ }
407
+ }),
408
+ children: [expanded && gapFillerHeight > 0 && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
409
+ position: "absolute",
410
+ left: 0,
411
+ right: 0,
412
+ height: gapFillerHeight,
413
+ pointerEvents: "auto",
414
+ ...(isTop ? {
415
+ top: "100%"
416
+ } : {
417
+ bottom: "100%"
418
+ })
419
+ }), /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_stacks.XStack, {
420
+ alignItems: "flex-start",
421
+ gap: "$3",
422
+ children: [icon && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
423
+ flexShrink: 0,
424
+ marginTop: "$0.5",
425
+ children: icon
426
+ }), /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_stacks.YStack, {
427
+ flex: 1,
428
+ gap: "$1",
429
+ children: [title && /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastItemTitle, {
430
+ children: title
431
+ }), description && /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastItemDescription, {
432
+ children: description
433
+ })]
434
+ }), closeButton && dismissible && /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastCloseButton, {
435
+ onPress: handleClose,
436
+ "aria-label": "Close toast",
437
+ children: icons?.close ?? /* @__PURE__ */(0, import_jsx_runtime.jsx)(DefaultCloseIcon, {})
438
+ })]
439
+ }), (toast.action || toast.cancel) && /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_stacks.XStack, {
440
+ marginTop: "$3",
441
+ gap: "$2",
442
+ justifyContent: "flex-end",
443
+ children: [toast.cancel && /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastActionButton, {
444
+ onPress: event => {
445
+ toast.cancel?.onClick?.(event), handleClose();
446
+ },
447
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.SizableText, {
448
+ size: "$2",
449
+ children: toast.cancel.label
450
+ })
451
+ }), toast.action && /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastActionButton, {
452
+ primary: !0,
453
+ onPress: event => {
454
+ toast.action?.onClick?.(event), event.defaultPrevented || handleClose();
455
+ },
456
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.SizableText, {
457
+ size: "$2",
458
+ fontWeight: "600",
459
+ color: "$background",
460
+ children: toast.action.label
461
+ })
462
+ })]
463
+ })]
464
+ });
465
+ });
466
+ ToastItem.displayName = "ToastItem";