@hanzogui/toast 7.0.0 → 7.3.0

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 (268) hide show
  1. package/dist/cjs/Toast.cjs +178 -0
  2. package/dist/cjs/Toast.native.js +181 -0
  3. package/dist/cjs/Toast.native.js.map +1 -0
  4. package/dist/cjs/ToastAnnounce.cjs +103 -0
  5. package/dist/cjs/ToastAnnounce.native.js +111 -0
  6. package/dist/cjs/ToastAnnounce.native.js.map +1 -0
  7. package/dist/cjs/ToastComposable.cjs +933 -0
  8. package/dist/cjs/ToastComposable.native.js +1025 -0
  9. package/dist/cjs/ToastComposable.native.js.map +1 -0
  10. package/dist/cjs/ToastImperative.cjs +119 -0
  11. package/dist/cjs/ToastImperative.native.js +130 -0
  12. package/dist/cjs/ToastImperative.native.js.map +1 -0
  13. package/dist/cjs/ToastImpl.cjs +354 -0
  14. package/dist/cjs/ToastImpl.native.js +364 -0
  15. package/dist/cjs/ToastImpl.native.js.map +1 -0
  16. package/dist/cjs/ToastItemFrame.cjs +143 -0
  17. package/dist/cjs/ToastItemFrame.native.js +148 -0
  18. package/dist/cjs/ToastItemFrame.native.js.map +1 -0
  19. package/dist/cjs/ToastPortal.cjs +49 -0
  20. package/dist/cjs/ToastPortal.native.js +52 -0
  21. package/dist/cjs/ToastPortal.native.js.map +1 -0
  22. package/dist/cjs/ToastProvider.cjs +150 -0
  23. package/dist/cjs/ToastProvider.native.js +161 -0
  24. package/dist/cjs/ToastProvider.native.js.map +1 -0
  25. package/dist/cjs/ToastState.cjs +311 -0
  26. package/dist/cjs/ToastState.native.js +324 -0
  27. package/dist/cjs/ToastState.native.js.map +1 -0
  28. package/dist/cjs/ToastViewport.cjs +319 -0
  29. package/dist/cjs/ToastViewport.native.js +343 -0
  30. package/dist/cjs/ToastViewport.native.js.map +1 -0
  31. package/dist/cjs/Toaster.cjs +87 -0
  32. package/dist/cjs/Toaster.native.js +91 -0
  33. package/dist/cjs/Toaster.native.js.map +1 -0
  34. package/dist/cjs/constants.cjs +30 -0
  35. package/dist/cjs/constants.native.js +33 -0
  36. package/dist/cjs/constants.native.js.map +1 -0
  37. package/dist/cjs/createNativeToast.cjs +59 -0
  38. package/dist/cjs/createNativeToast.native.js +60 -0
  39. package/dist/cjs/createNativeToast.native.js.map +1 -0
  40. package/dist/cjs/dispatchNativeToast.cjs +47 -0
  41. package/dist/cjs/dispatchNativeToast.native.js +52 -0
  42. package/dist/cjs/dispatchNativeToast.native.js.map +1 -0
  43. package/dist/cjs/index.cjs +20 -0
  44. package/dist/cjs/index.native.js +23 -0
  45. package/dist/cjs/index.native.js.map +1 -0
  46. package/dist/cjs/types.cjs +18 -0
  47. package/dist/cjs/types.native.js +21 -0
  48. package/dist/cjs/types.native.js.map +1 -0
  49. package/dist/cjs/useAnimatedDragGesture.cjs +214 -0
  50. package/dist/cjs/useAnimatedDragGesture.native.js +224 -0
  51. package/dist/cjs/useAnimatedDragGesture.native.js.map +1 -0
  52. package/dist/cjs/useReducedMotion.cjs +74 -0
  53. package/dist/cjs/useReducedMotion.native.js +83 -0
  54. package/dist/cjs/useReducedMotion.native.js.map +1 -0
  55. package/dist/cjs/useToastAnimations.cjs +294 -0
  56. package/dist/cjs/useToastAnimations.native.js +304 -0
  57. package/dist/cjs/useToastAnimations.native.js.map +1 -0
  58. package/dist/cjs/v2.cjs +36 -0
  59. package/dist/cjs/v2.native.js +39 -0
  60. package/dist/cjs/v2.native.js.map +1 -0
  61. package/dist/esm/Toast.mjs +137 -0
  62. package/dist/esm/Toast.mjs.map +1 -0
  63. package/dist/esm/Toast.native.js +137 -0
  64. package/dist/esm/Toast.native.js.map +1 -0
  65. package/dist/esm/ToastAnnounce.mjs +66 -0
  66. package/dist/esm/ToastAnnounce.mjs.map +1 -0
  67. package/dist/esm/ToastAnnounce.native.js +71 -0
  68. package/dist/esm/ToastAnnounce.native.js.map +1 -0
  69. package/dist/esm/ToastComposable.mjs +895 -0
  70. package/dist/esm/ToastComposable.mjs.map +1 -0
  71. package/dist/esm/ToastComposable.native.js +984 -0
  72. package/dist/esm/ToastComposable.native.js.map +1 -0
  73. package/dist/esm/ToastImperative.mjs +80 -0
  74. package/dist/esm/ToastImperative.mjs.map +1 -0
  75. package/dist/esm/ToastImperative.native.js +88 -0
  76. package/dist/esm/ToastImperative.native.js.map +1 -0
  77. package/dist/esm/ToastImpl.mjs +316 -0
  78. package/dist/esm/ToastImpl.mjs.map +1 -0
  79. package/dist/esm/ToastImpl.native.js +323 -0
  80. package/dist/esm/ToastImpl.native.js.map +1 -0
  81. package/dist/esm/ToastItemFrame.mjs +114 -0
  82. package/dist/esm/ToastItemFrame.mjs.map +1 -0
  83. package/dist/esm/ToastItemFrame.native.js +116 -0
  84. package/dist/esm/ToastItemFrame.native.js.map +1 -0
  85. package/dist/esm/ToastPortal.mjs +24 -0
  86. package/dist/esm/ToastPortal.mjs.map +1 -0
  87. package/dist/esm/ToastPortal.native.js +24 -0
  88. package/dist/esm/ToastPortal.native.js.map +1 -0
  89. package/dist/esm/ToastProvider.mjs +110 -0
  90. package/dist/esm/ToastProvider.mjs.map +1 -0
  91. package/dist/esm/ToastProvider.native.js +118 -0
  92. package/dist/esm/ToastProvider.native.js.map +1 -0
  93. package/dist/esm/ToastState.mjs +285 -0
  94. package/dist/esm/ToastState.mjs.map +1 -0
  95. package/dist/esm/ToastState.native.js +295 -0
  96. package/dist/esm/ToastState.native.js.map +1 -0
  97. package/dist/esm/ToastViewport.mjs +280 -0
  98. package/dist/esm/ToastViewport.mjs.map +1 -0
  99. package/dist/esm/ToastViewport.native.js +301 -0
  100. package/dist/esm/ToastViewport.native.js.map +1 -0
  101. package/dist/esm/Toaster.mjs +51 -0
  102. package/dist/esm/Toaster.mjs.map +1 -0
  103. package/dist/esm/Toaster.native.js +52 -0
  104. package/dist/esm/Toaster.native.js.map +1 -0
  105. package/dist/esm/constants.mjs +4 -0
  106. package/dist/esm/constants.mjs.map +1 -0
  107. package/dist/esm/constants.native.js +4 -0
  108. package/dist/esm/constants.native.js.map +1 -0
  109. package/dist/esm/createNativeToast.mjs +32 -0
  110. package/dist/esm/createNativeToast.mjs.map +1 -0
  111. package/dist/esm/createNativeToast.native.js +30 -0
  112. package/dist/esm/createNativeToast.native.js.map +1 -0
  113. package/dist/esm/dispatchNativeToast.mjs +22 -0
  114. package/dist/esm/dispatchNativeToast.mjs.map +1 -0
  115. package/dist/esm/dispatchNativeToast.native.js +24 -0
  116. package/dist/esm/dispatchNativeToast.native.js.map +1 -0
  117. package/dist/esm/index.js +2 -0
  118. package/dist/esm/index.js.map +1 -0
  119. package/dist/esm/index.mjs +2 -0
  120. package/dist/esm/index.mjs.map +1 -0
  121. package/dist/esm/index.native.js +2 -0
  122. package/dist/esm/index.native.js.map +1 -0
  123. package/dist/esm/types.mjs +2 -0
  124. package/dist/esm/types.mjs.map +1 -0
  125. package/dist/esm/types.native.js +2 -0
  126. package/dist/esm/types.native.js.map +1 -0
  127. package/dist/esm/useAnimatedDragGesture.mjs +178 -0
  128. package/dist/esm/useAnimatedDragGesture.mjs.map +1 -0
  129. package/dist/esm/useAnimatedDragGesture.native.js +185 -0
  130. package/dist/esm/useAnimatedDragGesture.native.js.map +1 -0
  131. package/dist/esm/useReducedMotion.mjs +38 -0
  132. package/dist/esm/useReducedMotion.mjs.map +1 -0
  133. package/dist/esm/useReducedMotion.native.js +44 -0
  134. package/dist/esm/useReducedMotion.native.js.map +1 -0
  135. package/dist/esm/useToastAnimations.mjs +258 -0
  136. package/dist/esm/useToastAnimations.mjs.map +1 -0
  137. package/dist/esm/useToastAnimations.native.js +265 -0
  138. package/dist/esm/useToastAnimations.native.js.map +1 -0
  139. package/dist/esm/v2.mjs +6 -0
  140. package/dist/esm/v2.mjs.map +1 -0
  141. package/dist/esm/v2.native.js +6 -0
  142. package/dist/esm/v2.native.js.map +1 -0
  143. package/dist/jsx/Toast.mjs +137 -0
  144. package/dist/jsx/Toast.mjs.map +1 -0
  145. package/dist/jsx/Toast.native.js +181 -0
  146. package/dist/jsx/Toast.native.js.map +1 -0
  147. package/dist/jsx/ToastAnnounce.mjs +66 -0
  148. package/dist/jsx/ToastAnnounce.mjs.map +1 -0
  149. package/dist/jsx/ToastAnnounce.native.js +111 -0
  150. package/dist/jsx/ToastAnnounce.native.js.map +1 -0
  151. package/dist/jsx/ToastComposable.mjs +895 -0
  152. package/dist/jsx/ToastComposable.mjs.map +1 -0
  153. package/dist/jsx/ToastComposable.native.js +1025 -0
  154. package/dist/jsx/ToastComposable.native.js.map +1 -0
  155. package/dist/jsx/ToastImperative.mjs +80 -0
  156. package/dist/jsx/ToastImperative.mjs.map +1 -0
  157. package/dist/jsx/ToastImperative.native.js +130 -0
  158. package/dist/jsx/ToastImperative.native.js.map +1 -0
  159. package/dist/jsx/ToastImpl.mjs +316 -0
  160. package/dist/jsx/ToastImpl.mjs.map +1 -0
  161. package/dist/jsx/ToastImpl.native.js +364 -0
  162. package/dist/jsx/ToastImpl.native.js.map +1 -0
  163. package/dist/jsx/ToastItemFrame.mjs +114 -0
  164. package/dist/jsx/ToastItemFrame.mjs.map +1 -0
  165. package/dist/jsx/ToastItemFrame.native.js +148 -0
  166. package/dist/jsx/ToastItemFrame.native.js.map +1 -0
  167. package/dist/jsx/ToastPortal.mjs +24 -0
  168. package/dist/jsx/ToastPortal.mjs.map +1 -0
  169. package/dist/jsx/ToastPortal.native.js +52 -0
  170. package/dist/jsx/ToastPortal.native.js.map +1 -0
  171. package/dist/jsx/ToastProvider.mjs +110 -0
  172. package/dist/jsx/ToastProvider.mjs.map +1 -0
  173. package/dist/jsx/ToastProvider.native.js +161 -0
  174. package/dist/jsx/ToastProvider.native.js.map +1 -0
  175. package/dist/jsx/ToastState.mjs +285 -0
  176. package/dist/jsx/ToastState.mjs.map +1 -0
  177. package/dist/jsx/ToastState.native.js +324 -0
  178. package/dist/jsx/ToastState.native.js.map +1 -0
  179. package/dist/jsx/ToastViewport.mjs +280 -0
  180. package/dist/jsx/ToastViewport.mjs.map +1 -0
  181. package/dist/jsx/ToastViewport.native.js +343 -0
  182. package/dist/jsx/ToastViewport.native.js.map +1 -0
  183. package/dist/jsx/Toaster.mjs +51 -0
  184. package/dist/jsx/Toaster.mjs.map +1 -0
  185. package/dist/jsx/Toaster.native.js +91 -0
  186. package/dist/jsx/Toaster.native.js.map +1 -0
  187. package/dist/jsx/constants.mjs +4 -0
  188. package/dist/jsx/constants.mjs.map +1 -0
  189. package/dist/jsx/constants.native.js +33 -0
  190. package/dist/jsx/constants.native.js.map +1 -0
  191. package/dist/jsx/createNativeToast.mjs +32 -0
  192. package/dist/jsx/createNativeToast.mjs.map +1 -0
  193. package/dist/jsx/createNativeToast.native.js +60 -0
  194. package/dist/jsx/createNativeToast.native.js.map +1 -0
  195. package/dist/jsx/dispatchNativeToast.mjs +22 -0
  196. package/dist/jsx/dispatchNativeToast.mjs.map +1 -0
  197. package/dist/jsx/dispatchNativeToast.native.js +52 -0
  198. package/dist/jsx/dispatchNativeToast.native.js.map +1 -0
  199. package/dist/jsx/index.js +2 -0
  200. package/dist/jsx/index.js.map +1 -0
  201. package/dist/jsx/index.mjs +2 -0
  202. package/dist/jsx/index.mjs.map +1 -0
  203. package/dist/jsx/index.native.js +23 -0
  204. package/dist/jsx/index.native.js.map +1 -0
  205. package/dist/jsx/types.mjs +2 -0
  206. package/dist/jsx/types.mjs.map +1 -0
  207. package/dist/jsx/types.native.js +21 -0
  208. package/dist/jsx/types.native.js.map +1 -0
  209. package/dist/jsx/useAnimatedDragGesture.mjs +178 -0
  210. package/dist/jsx/useAnimatedDragGesture.mjs.map +1 -0
  211. package/dist/jsx/useAnimatedDragGesture.native.js +224 -0
  212. package/dist/jsx/useAnimatedDragGesture.native.js.map +1 -0
  213. package/dist/jsx/useReducedMotion.mjs +38 -0
  214. package/dist/jsx/useReducedMotion.mjs.map +1 -0
  215. package/dist/jsx/useReducedMotion.native.js +83 -0
  216. package/dist/jsx/useReducedMotion.native.js.map +1 -0
  217. package/dist/jsx/useToastAnimations.mjs +258 -0
  218. package/dist/jsx/useToastAnimations.mjs.map +1 -0
  219. package/dist/jsx/useToastAnimations.native.js +304 -0
  220. package/dist/jsx/useToastAnimations.native.js.map +1 -0
  221. package/dist/jsx/v2.mjs +6 -0
  222. package/dist/jsx/v2.mjs.map +1 -0
  223. package/dist/jsx/v2.native.js +39 -0
  224. package/dist/jsx/v2.native.js.map +1 -0
  225. package/package.json +26 -24
  226. package/src/Toast.tsx +5 -5
  227. package/src/ToastAnnounce.tsx +2 -2
  228. package/src/ToastComposable.tsx +8 -8
  229. package/src/ToastImpl.tsx +6 -6
  230. package/src/ToastItemFrame.tsx +4 -4
  231. package/src/ToastProvider.tsx +5 -5
  232. package/src/ToastViewport.tsx +7 -7
  233. package/src/Toaster.tsx +2 -2
  234. package/src/useToastAnimations.ts +3 -3
  235. package/types/Toast.d.ts +14 -14
  236. package/types/Toast.d.ts.map +1 -0
  237. package/types/ToastAnnounce.d.ts +3 -3
  238. package/types/ToastAnnounce.d.ts.map +1 -0
  239. package/types/ToastComposable.d.ts +15 -15
  240. package/types/ToastComposable.d.ts.map +1 -0
  241. package/types/ToastImperative.d.ts +1 -1
  242. package/types/ToastImperative.d.ts.map +1 -0
  243. package/types/ToastImpl.d.ts +4 -4
  244. package/types/ToastImpl.d.ts.map +1 -0
  245. package/types/ToastItemFrame.d.ts +5 -5
  246. package/types/ToastItemFrame.d.ts.map +1 -0
  247. package/types/ToastPortal.d.ts +1 -1
  248. package/types/ToastPortal.d.ts.map +1 -0
  249. package/types/ToastProvider.d.ts +7 -7
  250. package/types/ToastProvider.d.ts.map +1 -0
  251. package/types/ToastState.d.ts.map +1 -0
  252. package/types/ToastViewport.d.ts +5 -5
  253. package/types/ToastViewport.d.ts.map +1 -0
  254. package/types/Toaster.d.ts +2 -2
  255. package/types/Toaster.d.ts.map +1 -0
  256. package/types/constants.d.ts.map +1 -0
  257. package/types/createNativeToast.d.ts.map +1 -0
  258. package/types/createNativeToast.native.d.ts.map +1 -0
  259. package/types/dispatchNativeToast.d.ts.map +1 -0
  260. package/types/index.d.ts.map +1 -0
  261. package/types/types.d.ts.map +1 -0
  262. package/types/useAnimatedDragGesture.d.ts.map +1 -0
  263. package/types/useAnimatedDragGesture.native.d.ts.map +1 -0
  264. package/types/useReducedMotion.d.ts.map +1 -0
  265. package/types/useToastAnimations.d.ts.map +1 -0
  266. package/types/v2.d.ts.map +1 -0
  267. package/v2/index.cjs +1 -1
  268. package/v2/index.native.cjs +1 -1
@@ -0,0 +1,304 @@
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 useToastAnimations_exports = {};
37
+ __export(useToastAnimations_exports, {
38
+ useToastAnimations: () => useToastAnimations
39
+ });
40
+ module.exports = __toCommonJS(useToastAnimations_exports);
41
+ var import_constants = require("@hanzogui/constants");
42
+ var import_core = require("@hanzogui/core");
43
+ var React = __toESM(require("react"), 1);
44
+ var SPRING_CONFIG = {
45
+ type: "spring",
46
+ damping: 30,
47
+ stiffness: 400,
48
+ mass: 0.5
49
+ };
50
+ var EXIT_DISTANCE = 200;
51
+ function animateSpring(element, fromX, fromY, toX, toY, config, onComplete) {
52
+ var {
53
+ damping = 30,
54
+ stiffness = 400,
55
+ mass = 0.5,
56
+ initialVelocityX = 0,
57
+ initialVelocityY = 0,
58
+ fadeOut = false
59
+ } = config;
60
+ var x = fromX;
61
+ var y = fromY;
62
+ var velocityX = initialVelocityX;
63
+ var velocityY = initialVelocityY;
64
+ var animationId = null;
65
+ var targetX = toX;
66
+ var targetY = toY;
67
+ var totalDistance = Math.sqrt(Math.pow(toX - fromX, 2) + Math.pow(toY - fromY, 2)) || 1;
68
+ function step() {
69
+ var forceX = -stiffness * (x - targetX);
70
+ var forceY = -stiffness * (y - targetY);
71
+ var dampingForceX = -damping * velocityX;
72
+ var dampingForceY = -damping * velocityY;
73
+ var accelerationX = (forceX + dampingForceX) / mass;
74
+ var accelerationY = (forceY + dampingForceY) / mass;
75
+ velocityX += accelerationX * 0.016;
76
+ velocityY += accelerationY * 0.016;
77
+ x += velocityX * 0.016;
78
+ y += velocityY * 0.016;
79
+ element.style.transform = `translate3d(${x}px, ${y}px, 0)`;
80
+ if (fadeOut) {
81
+ var distanceTraveled = Math.sqrt(Math.pow(x - fromX, 2) + Math.pow(y - fromY, 2));
82
+ var progress = Math.min(distanceTraveled / totalDistance, 1);
83
+ element.style.opacity = String(1 - progress);
84
+ }
85
+ var distanceX = Math.abs(x - targetX);
86
+ var distanceY = Math.abs(y - targetY);
87
+ var speed = Math.sqrt(velocityX * velocityX + velocityY * velocityY);
88
+ if (distanceX < 0.5 && distanceY < 0.5 && speed < 0.5) {
89
+ element.style.transform = `translate3d(${targetX}px, ${targetY}px, 0)`;
90
+ if (fadeOut) {
91
+ element.style.opacity = "0";
92
+ }
93
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete();
94
+ return;
95
+ }
96
+ animationId = requestAnimationFrame(step);
97
+ }
98
+ animationId = requestAnimationFrame(step);
99
+ return function () {
100
+ if (animationId) {
101
+ cancelAnimationFrame(animationId);
102
+ }
103
+ };
104
+ }
105
+ function useToastAnimations() {
106
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
107
+ var {
108
+ onExitComplete,
109
+ reducedMotion,
110
+ swipeAxis = "horizontal"
111
+ } = options;
112
+ var {
113
+ animationDriver
114
+ } = (0, import_core.useConfiguration)();
115
+ if (!animationDriver) {
116
+ throw new Error("Toast requires an animation driver to be set in GuiProvider");
117
+ }
118
+ var {
119
+ useAnimatedNumber,
120
+ useAnimatedNumberStyle,
121
+ useAnimatedNumbersStyle
122
+ } = animationDriver;
123
+ var _animationDriver_View;
124
+ var AnimatedView = (_animationDriver_View = animationDriver.View) !== null && _animationDriver_View !== void 0 ? _animationDriver_View : import_core.View;
125
+ var dragRef = React.useRef(null);
126
+ var cancelAnimationRef = React.useRef(null);
127
+ var currentOffsetRef = React.useRef({
128
+ x: 0,
129
+ y: 0
130
+ });
131
+ var useDirectDom = import_constants.isWeb;
132
+ var translateX = useAnimatedNumber(0);
133
+ var translateY = useAnimatedNumber(0);
134
+ var animatedStyleMulti = useAnimatedNumbersStyle ? useAnimatedNumbersStyle([translateX, translateY], function (x, y) {
135
+ "worklet";
136
+
137
+ return {
138
+ transform: [{
139
+ translateX: x
140
+ }, {
141
+ translateY: y
142
+ }]
143
+ };
144
+ }) : null;
145
+ var animatedStyleFallback = useAnimatedNumberStyle(swipeAxis === "vertical" ? translateY : translateX, function (primary) {
146
+ "worklet";
147
+
148
+ var secondary = swipeAxis === "vertical" ? translateX.getValue() : translateY.getValue();
149
+ return swipeAxis === "vertical" ? {
150
+ transform: [{
151
+ translateX: secondary
152
+ }, {
153
+ translateY: primary
154
+ }]
155
+ } : {
156
+ transform: [{
157
+ translateX: primary
158
+ }, {
159
+ translateY: secondary
160
+ }]
161
+ };
162
+ });
163
+ var animatedStyle = animatedStyleMulti !== null && animatedStyleMulti !== void 0 ? animatedStyleMulti : animatedStyleFallback;
164
+ var setDragOffset = (0, import_core.useEvent)(function (x, y) {
165
+ var _cancelAnimationRef_current;
166
+ (_cancelAnimationRef_current = cancelAnimationRef.current) === null || _cancelAnimationRef_current === void 0 ? void 0 : _cancelAnimationRef_current.call(cancelAnimationRef);
167
+ cancelAnimationRef.current = null;
168
+ currentOffsetRef.current = {
169
+ x,
170
+ y
171
+ };
172
+ if (useDirectDom && dragRef.current) {
173
+ dragRef.current.style.transform = `translate3d(${x}px, ${y}px, 0)`;
174
+ dragRef.current.style.opacity = "1";
175
+ } else {
176
+ translateX.setValue(x, {
177
+ type: "direct"
178
+ });
179
+ translateY.setValue(y, {
180
+ type: "direct"
181
+ });
182
+ }
183
+ });
184
+ var springBack = (0, import_core.useEvent)(function (onComplete) {
185
+ var _cancelAnimationRef_current;
186
+ (_cancelAnimationRef_current = cancelAnimationRef.current) === null || _cancelAnimationRef_current === void 0 ? void 0 : _cancelAnimationRef_current.call(cancelAnimationRef);
187
+ if (reducedMotion) {
188
+ if (useDirectDom && dragRef.current) {
189
+ dragRef.current.style.transform = "translate3d(0px, 0px, 0)";
190
+ } else {
191
+ translateX.setValue(0, {
192
+ type: "direct"
193
+ });
194
+ translateY.setValue(0, {
195
+ type: "direct"
196
+ });
197
+ }
198
+ currentOffsetRef.current = {
199
+ x: 0,
200
+ y: 0
201
+ };
202
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete();
203
+ return;
204
+ }
205
+ if (useDirectDom && dragRef.current) {
206
+ var {
207
+ x,
208
+ y
209
+ } = currentOffsetRef.current;
210
+ cancelAnimationRef.current = animateSpring(dragRef.current, x, y, 0, 0, SPRING_CONFIG, function () {
211
+ currentOffsetRef.current = {
212
+ x: 0,
213
+ y: 0
214
+ };
215
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete();
216
+ });
217
+ } else {
218
+ translateX.setValue(0, SPRING_CONFIG);
219
+ translateY.setValue(0, SPRING_CONFIG, onComplete);
220
+ }
221
+ });
222
+ var animateOut = (0, import_core.useEvent)(function (direction, velocity, onComplete) {
223
+ var _cancelAnimationRef_current;
224
+ (_cancelAnimationRef_current = cancelAnimationRef.current) === null || _cancelAnimationRef_current === void 0 ? void 0 : _cancelAnimationRef_current.call(cancelAnimationRef);
225
+ var {
226
+ x: curX,
227
+ y: curY
228
+ } = currentOffsetRef.current;
229
+ var exitX = direction === "left" ? -EXIT_DISTANCE : direction === "right" ? EXIT_DISTANCE : 0;
230
+ var exitY = direction === "up" ? -EXIT_DISTANCE : direction === "down" ? EXIT_DISTANCE : 0;
231
+ if (direction === "left" && curX < exitX) exitX = curX - 50;else if (direction === "right" && curX > exitX) exitX = curX + 50;
232
+ if (direction === "up" && curY < exitY) exitY = curY - 50;else if (direction === "down" && curY > exitY) exitY = curY + 50;
233
+ if (reducedMotion) {
234
+ if (useDirectDom && dragRef.current) {
235
+ dragRef.current.style.transform = `translate3d(${exitX}px, ${exitY}px, 0)`;
236
+ } else {
237
+ translateX.setValue(exitX, {
238
+ type: "direct"
239
+ });
240
+ translateY.setValue(exitY, {
241
+ type: "direct"
242
+ });
243
+ }
244
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete();
245
+ onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
246
+ return;
247
+ }
248
+ var velocityScale = (velocity !== null && velocity !== void 0 ? velocity : 0) * 500;
249
+ var initialVelocityX = direction === "left" ? -velocityScale : direction === "right" ? velocityScale : 0;
250
+ var initialVelocityY = direction === "up" ? -velocityScale : direction === "down" ? velocityScale : 0;
251
+ var exitConfig = {
252
+ damping: 25,
253
+ stiffness: 350,
254
+ mass: 0.4,
255
+ initialVelocityX,
256
+ initialVelocityY,
257
+ fadeOut: true
258
+ };
259
+ if (useDirectDom && dragRef.current) {
260
+ var {
261
+ x,
262
+ y
263
+ } = currentOffsetRef.current;
264
+ cancelAnimationRef.current = animateSpring(dragRef.current, x, y, exitX, exitY, exitConfig, function () {
265
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete();
266
+ onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
267
+ });
268
+ } else {
269
+ var springConfig = {
270
+ type: "spring",
271
+ damping: 25,
272
+ stiffness: 350,
273
+ mass: 0.4
274
+ };
275
+ translateX.setValue(exitX, springConfig);
276
+ translateY.setValue(exitY, springConfig, function () {
277
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete();
278
+ onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
279
+ });
280
+ }
281
+ });
282
+ var stop = (0, import_core.useEvent)(function () {
283
+ var _cancelAnimationRef_current;
284
+ (_cancelAnimationRef_current = cancelAnimationRef.current) === null || _cancelAnimationRef_current === void 0 ? void 0 : _cancelAnimationRef_current.call(cancelAnimationRef);
285
+ translateX.stop();
286
+ translateY.stop();
287
+ });
288
+ React.useEffect(function () {
289
+ return function () {
290
+ var _cancelAnimationRef_current;
291
+ (_cancelAnimationRef_current = cancelAnimationRef.current) === null || _cancelAnimationRef_current === void 0 ? void 0 : _cancelAnimationRef_current.call(cancelAnimationRef);
292
+ };
293
+ }, []);
294
+ return {
295
+ setDragOffset,
296
+ springBack,
297
+ animateOut,
298
+ stop,
299
+ animatedStyle,
300
+ AnimatedView,
301
+ dragRef
302
+ };
303
+ }
304
+ //# sourceMappingURL=useToastAnimations.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","useToastAnimations_exports","useToastAnimations","module","exports","import_constants","require","import_core","React","SPRING_CONFIG","type","damping","stiffness","mass","EXIT_DISTANCE","animateSpring","element","fromX","fromY","toX","toY","config","onComplete","initialVelocityX","initialVelocityY","fadeOut","x","y","velocityX","velocityY","animationId","targetX","targetY","totalDistance","Math","sqrt","pow","step","forceX","forceY","dampingForceX","dampingForceY","accelerationX","accelerationY","style","transform","distanceTraveled","progress","min","opacity","String","distanceX","abs","distanceY","speed","requestAnimationFrame","cancelAnimationFrame","options","arguments","length","onExitComplete","reducedMotion","swipeAxis","animationDriver","useConfiguration","Error","useAnimatedNumber","useAnimatedNumberStyle","useAnimatedNumbersStyle","_animationDriver_View","AnimatedView","View","dragRef","useRef","cancelAnimationRef","currentOffsetRef","useDirectDom","isWeb","translateX","translateY","animatedStyleMulti","animatedStyleFallback","primary","secondary","getValue","animatedStyle","setDragOffset","useEvent","_cancelAnimationRef_current","current","setValue","springBack","animateOut","direction","velocity","curX","curY","exitX","exitY"],"sources":["../../src/useToastAnimations.ts"],"sourcesContent":[null],"mappings":"AAgBA,YAAS;;AACT,IAAAA,QAAS,GAAAC,MAAA,CAAAC,MAAkB;AAC3B,IAAAC,SAAY,GAAAF,MAAA,CAAWG,cAAA;AAyCvB,IAAAC,gBAAM,GAAgBJ,MAAA,CAAAK,wBAAA;AAAA,IACpBC,iBAAM,GAAAN,MAAA,CAAAO,mBAAA;AAAA,IACNC,YAAS,GAAAR,MAAA,CAAAS,cAAA;AAAA,IACTC,YAAW,GAAAV,MAAA,CAAAW,SAAA,CAAAC,cAAA;AAAA,IACXC,QAAM,GAAAA,CAAAC,MAAA,EAAAC,GAAA;EACR,SAAAC,IAAA,IAAAD,GAAA,EAEAb,SAAM,CAAAY,MAAA,EAAgBE,IAAA;IAAAC,GAAA,EAAAF,GAAA,CAAAC,IAAA;IAAAE,UAAA;EAAA;AAGtB;AAgBE,IAAAC,WAAM,GAAAA,CAAAC,EAAA,EAAAC,IAAA,EAAAC,MAAA,EAA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}
@@ -0,0 +1,6 @@
1
+ import { Toast, useToasts, useToastItem } from "./ToastComposable.mjs";
2
+ import { toast } from "./ToastState.mjs";
3
+ import { Toaster } from "./Toaster.mjs";
4
+ import { requestNotificationPermission } from "./createNativeToast.mjs";
5
+ export { Toast, Toaster, requestNotificationPermission, toast, useToastItem, useToasts };
6
+ //# sourceMappingURL=v2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Toast","useToasts","useToastItem","toast","Toaster","requestNotificationPermission"],"sources":["../../src/v2.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,KAAA,EAAOC,SAAA,EAAWC,YAAA,QAAoB;AAY/C,SAASC,KAAA,QAAa;AAYtB,SAASC,OAAA,QAAe;AAKxB,SAASC,6BAAA,QAAqC","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var v2_exports = {};
26
+ __export(v2_exports, {
27
+ Toast: () => import_ToastComposable.Toast,
28
+ Toaster: () => import_Toaster.Toaster,
29
+ requestNotificationPermission: () => import_createNativeToast.requestNotificationPermission,
30
+ toast: () => import_ToastState.toast,
31
+ useToastItem: () => import_ToastComposable.useToastItem,
32
+ useToasts: () => import_ToastComposable.useToasts
33
+ });
34
+ module.exports = __toCommonJS(v2_exports);
35
+ var import_ToastComposable = require("./ToastComposable.native.js");
36
+ var import_ToastState = require("./ToastState.native.js");
37
+ var import_Toaster = require("./Toaster.native.js");
38
+ var import_createNativeToast = require("./createNativeToast.native.js");
39
+ //# sourceMappingURL=v2.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames"],"sources":["../../src/v2.ts"],"sourcesContent":[null],"mappings":"AACA,YAAS;;AAYT,IAAAA,SAAS,GAAAC,MAAa,CAAAC,cAAA;AAYtB,IAAAC,gBAAS,GAAAF,MAAe,CAAAG,wBAAA;AAKxB,IAAAC,iBAAS,GAAAJ,MAAA,CAAAK,mBAAqC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzogui/toast",
3
- "version": "7.0.0",
3
+ "version": "7.3.0",
4
4
  "source": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -40,31 +40,31 @@
40
40
  "access": "public"
41
41
  },
42
42
  "scripts": {
43
- "build": "hanzogui-build",
44
- "watch": "hanzogui-build --watch",
45
- "clean": "hanzogui-build clean",
46
- "clean:build": "hanzogui-build clean:build"
43
+ "build": "gui-build",
44
+ "watch": "gui-build --watch",
45
+ "clean": "gui-build clean",
46
+ "clean:build": "gui-build clean:build"
47
47
  },
48
48
  "dependencies": {
49
- "@hanzogui/animate-presence": "^7.0.0",
50
- "@hanzogui/collection": "^7.0.0",
51
- "@hanzogui/compose-refs": "^7.0.0",
52
- "@hanzogui/constants": "^7.0.0",
53
- "@hanzogui/core": "^7.0.0",
54
- "@hanzogui/create-context": "^7.0.0",
55
- "@hanzogui/dismissable": "^7.0.0",
56
- "@hanzogui/helpers": "^7.0.0",
57
- "@hanzogui/native": "^7.0.0",
58
- "@hanzogui/polyfill-dev": "^7.0.0",
59
- "@hanzogui/portal": "^7.0.0",
60
- "@hanzogui/stacks": "^7.0.0",
61
- "@hanzogui/start-transition": "^7.0.0",
62
- "@hanzogui/text": "^7.0.0",
63
- "@hanzogui/use-controllable-state": "^7.0.0",
64
- "@hanzogui/visually-hidden": "^7.0.0"
49
+ "@hanzogui/animate-presence": "7.3.0",
50
+ "@hanzogui/collection": "7.3.0",
51
+ "@hanzogui/compose-refs": "7.3.0",
52
+ "@hanzogui/constants": "7.3.0",
53
+ "@hanzogui/core": "7.3.0",
54
+ "@hanzogui/create-context": "7.3.0",
55
+ "@hanzogui/dismissable": "7.3.0",
56
+ "@hanzogui/helpers": "7.3.0",
57
+ "@hanzogui/native": "7.3.0",
58
+ "@hanzogui/polyfill-dev": "7.3.0",
59
+ "@hanzogui/portal": "7.3.0",
60
+ "@hanzogui/stacks": "7.3.0",
61
+ "@hanzogui/start-transition": "7.3.0",
62
+ "@hanzogui/text": "7.3.0",
63
+ "@hanzogui/use-controllable-state": "7.3.0",
64
+ "@hanzogui/visually-hidden": "7.3.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@hanzogui/build": "^7.0.0",
67
+ "@hanzogui/build": "7.3.0",
68
68
  "react": ">=19",
69
69
  "react-native": "0.83.2"
70
70
  },
@@ -79,5 +79,7 @@
79
79
  "./types/v2.d.ts"
80
80
  ]
81
81
  }
82
- }
83
- }
82
+ },
83
+ "license": "BSD-3-Clause",
84
+ "author": "Hanzo AI <dev@hanzo.ai>"
85
+ }
package/src/Toast.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AnimatePresence } from '@hanzogui/animate-presence'
2
- import type { GetProps, NativePlatform, NativeValue, HanzoguiElement } from '@hanzogui/core'
2
+ import type { GetProps, NativePlatform, NativeValue, GuiElement } from '@hanzogui/core'
3
3
  import { styled, useEvent } from '@hanzogui/core'
4
4
  import { composeEventHandlers, withStaticProperties } from '@hanzogui/helpers'
5
5
  import { YStack } from '@hanzogui/stacks'
@@ -35,7 +35,7 @@ const ToastTitle = styled(SizableText, {
35
35
  } as const,
36
36
 
37
37
  defaultVariants: {
38
- unstyled: process.env.HANZOGUI_HEADLESS === '1',
38
+ unstyled: process.env.GUI_HEADLESS === '1',
39
39
  },
40
40
  })
41
41
 
@@ -60,7 +60,7 @@ const ToastDescription = styled(SizableText, {
60
60
  } as const,
61
61
 
62
62
  defaultVariants: {
63
- unstyled: process.env.HANZOGUI_HEADLESS === '1',
63
+ unstyled: process.env.GUI_HEADLESS === '1',
64
64
  },
65
65
  })
66
66
 
@@ -84,7 +84,7 @@ type ToastActionProps = ScopedProps<
84
84
  }
85
85
  >
86
86
 
87
- const ToastAction = React.forwardRef<HanzoguiElement, ScopedProps<ToastActionProps>>(
87
+ const ToastAction = React.forwardRef<GuiElement, ScopedProps<ToastActionProps>>(
88
88
  function ToastAction(props, forwardedRef) {
89
89
  const { altText, ...actionProps } = props
90
90
  if (!altText) return null
@@ -119,7 +119,7 @@ const ToastCloseFrame = styled(YStack, {
119
119
  type ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>
120
120
  type ToastCloseProps = ScopedProps<ToastCloseFrameProps & {}>
121
121
 
122
- const ToastClose = React.forwardRef<HanzoguiElement, ToastCloseProps>(
122
+ const ToastClose = React.forwardRef<GuiElement, ToastCloseProps>(
123
123
  function ToastClose(props, forwardedRef) {
124
124
  const { scope, ...closeProps } = props
125
125
  const interactiveContext = useToastInteractiveContext(scope)
@@ -1,5 +1,5 @@
1
1
  import { useIsomorphicLayoutEffect } from '@hanzogui/constants'
2
- import type { GetProps, HanzoguiElement } from '@hanzogui/core'
2
+ import type { GetProps, GuiElement } from '@hanzogui/core'
3
3
  import { View, Text, styled, useEvent } from '@hanzogui/core'
4
4
  import { Portal } from '@hanzogui/portal'
5
5
  import { startTransition } from '@hanzogui/start-transition'
@@ -22,7 +22,7 @@ type ToastAnnounceExcludeExtraProps = {
22
22
  type ToastAnnounceExcludeProps = ToastAnnounceExcludeFrameProps &
23
23
  ToastAnnounceExcludeExtraProps
24
24
 
25
- const ToastAnnounceExclude = React.forwardRef<HanzoguiElement, ToastAnnounceExcludeProps>(
25
+ const ToastAnnounceExclude = React.forwardRef<GuiElement, ToastAnnounceExcludeProps>(
26
26
  (props, forwardedRef) => {
27
27
  const { altText, ...announceExcludeProps } = props
28
28
 
@@ -1,7 +1,7 @@
1
1
  import { AnimatePresence } from '@hanzogui/animate-presence'
2
2
  import { isWeb } from '@hanzogui/constants'
3
3
  import { getGestureHandler } from '@hanzogui/native'
4
- import type { GetProps, HanzoguiElement } from '@hanzogui/core'
4
+ import type { GetProps, GuiElement } from '@hanzogui/core'
5
5
  import {
6
6
  createStyledContext,
7
7
  styled,
@@ -225,7 +225,7 @@ function resolveSwipeDirection(
225
225
  return 'horizontal'
226
226
  }
227
227
 
228
- const ToastRoot = React.forwardRef<HanzoguiElement, ToastRootProps>(
228
+ const ToastRoot = React.forwardRef<GuiElement, ToastRootProps>(
229
229
  function ToastRoot(props, _ref) {
230
230
  const {
231
231
  children,
@@ -447,7 +447,7 @@ const ToastViewportFrame = styled(View, {
447
447
  } as const,
448
448
 
449
449
  defaultVariants: {
450
- unstyled: process.env.HANZOGUI_HEADLESS === '1',
450
+ unstyled: process.env.GUI_HEADLESS === '1',
451
451
  },
452
452
  })
453
453
 
@@ -491,7 +491,7 @@ const ToastViewport = ToastViewportFrame.styleable<ToastViewportProps>(
491
491
  } = props
492
492
 
493
493
  const ctx = useToastContext()
494
- const listRef = React.useRef<HanzoguiElement>(null)
494
+ const listRef = React.useRef<GuiElement>(null)
495
495
  const hoverTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)
496
496
  const hoverCooldownRef = React.useRef(false)
497
497
  const deferredCollapseRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)
@@ -504,8 +504,8 @@ const ToastViewport = ToastViewportFrame.styleable<ToastViewportProps>(
504
504
 
505
505
  // offset styles
506
506
  // on native, get safe area insets to avoid status bar / Dynamic Island / home indicator
507
- // use insets from HanzoguiProvider (passed via useConfiguration)
508
- // same pattern as Slider — works on native when HanzoguiProvider has insets prop
507
+ // use insets from GuiProvider (passed via useConfiguration)
508
+ // same pattern as Slider — works on native when GuiProvider has insets prop
509
509
  const { insets: safeInsets } = useConfiguration()
510
510
 
511
511
  const offsetStyles = React.useMemo(() => {
@@ -1243,7 +1243,7 @@ const ToastTitle = styled(SizableText, {
1243
1243
  } as const,
1244
1244
 
1245
1245
  defaultVariants: {
1246
- unstyled: process.env.HANZOGUI_HEADLESS === '1',
1246
+ unstyled: process.env.GUI_HEADLESS === '1',
1247
1247
  },
1248
1248
  })
1249
1249
 
@@ -1264,7 +1264,7 @@ const ToastDescription = styled(SizableText, {
1264
1264
  } as const,
1265
1265
 
1266
1266
  defaultVariants: {
1267
- unstyled: process.env.HANZOGUI_HEADLESS === '1',
1267
+ unstyled: process.env.GUI_HEADLESS === '1',
1268
1268
  },
1269
1269
  })
1270
1270
 
package/src/ToastImpl.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import { useIsPresent } from '@hanzogui/animate-presence'
2
2
  import { useComposedRefs } from '@hanzogui/compose-refs'
3
3
  import { isWeb } from '@hanzogui/constants'
4
- import type { GetProps, HanzoguiElement } from '@hanzogui/core'
4
+ import type { GetProps, GuiElement } from '@hanzogui/core'
5
5
  import {
6
6
  View,
7
7
  Theme,
@@ -26,7 +26,7 @@ import type {
26
26
 
27
27
  // Lazy load PanResponder only on native to avoid SSR issues
28
28
  const getPanResponder = (): typeof PanResponderType | null => {
29
- if (process.env.TAMAGUI_TARGET === 'native') {
29
+ if (process.env.GUI_TARGET === 'native') {
30
30
  // eslint-disable-next-line @typescript-eslint/no-require-imports
31
31
  return require('react-native').PanResponder
32
32
  }
@@ -62,7 +62,7 @@ const ToastImplFrame = styled(YStack, {
62
62
  } as const,
63
63
 
64
64
  defaultVariants: {
65
- unstyled: process.env.HANZOGUI_HEADLESS === '1',
65
+ unstyled: process.env.GUI_HEADLESS === '1',
66
66
  },
67
67
  })
68
68
 
@@ -161,7 +161,7 @@ type ToastImplProps = ScopedProps<
161
161
  ToastImplPrivateProps & ToastImplFrameProps & ToastExtraProps
162
162
  >
163
163
 
164
- const ToastImpl = React.forwardRef<HanzoguiElement, ToastImplProps>(
164
+ const ToastImpl = React.forwardRef<GuiElement, ToastImplProps>(
165
165
  (props, forwardedRef) => {
166
166
  const {
167
167
  scope,
@@ -181,7 +181,7 @@ const ToastImpl = React.forwardRef<HanzoguiElement, ToastImplProps>(
181
181
  } = props
182
182
  const isPresent = useIsPresent()
183
183
  const context = useToastProviderContext(scope)
184
- const [node, setNode] = React.useState<HanzoguiElement | null>(null)
184
+ const [node, setNode] = React.useState<GuiElement | null>(null)
185
185
  const composedRefs = useComposedRefs(forwardedRef, setNode)
186
186
  const duration = durationProp || context.duration
187
187
  const closeTimerStartTimeRef = React.useRef(0)
@@ -270,7 +270,7 @@ const ToastImpl = React.forwardRef<HanzoguiElement, ToastImplProps>(
270
270
 
271
271
  const { animationDriver } = useConfiguration()
272
272
  if (!animationDriver) {
273
- throw new Error('Must set animations in hanzogui.config.ts')
273
+ throw new Error('Must set animations in gui.config.ts')
274
274
  }
275
275
 
276
276
  const { useAnimatedNumber, useAnimatedNumberStyle } = animationDriver
@@ -9,7 +9,7 @@ import { SizableText } from '@hanzogui/text'
9
9
 
10
10
  /* -------------------------------------------------------------------------------------------------
11
11
  * ToastPositionWrapper - handles absolute positioning and stacking animations
12
- * On web: uses Hanzogui transition/enterStyle/exitStyle
12
+ * On web: uses Gui transition/enterStyle/exitStyle
13
13
  * On native: replaced by Animated.View with useAnimatedStyle
14
14
  * -----------------------------------------------------------------------------------------------*/
15
15
 
@@ -58,7 +58,7 @@ export const ToastItemFrame = styled(YStack, {
58
58
  } as const,
59
59
 
60
60
  defaultVariants: {
61
- unstyled: process.env.HANZOGUI_HEADLESS === '1',
61
+ unstyled: process.env.GUI_HEADLESS === '1',
62
62
  },
63
63
  })
64
64
 
@@ -92,7 +92,7 @@ export const ToastCloseFrame = styled(XStack, {
92
92
  } as const,
93
93
 
94
94
  defaultVariants: {
95
- unstyled: process.env.HANZOGUI_HEADLESS === '1',
95
+ unstyled: process.env.GUI_HEADLESS === '1',
96
96
  },
97
97
  })
98
98
 
@@ -121,7 +121,7 @@ export const ToastActionFrame = styled(XStack, {
121
121
  } as const,
122
122
 
123
123
  defaultVariants: {
124
- unstyled: process.env.HANZOGUI_HEADLESS === '1',
124
+ unstyled: process.env.GUI_HEADLESS === '1',
125
125
  },
126
126
  })
127
127