@tamagui/toast 3.0.0-beta.924.1 → 3.0.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 (52) hide show
  1. package/dist/cjs/ToastComposable.cjs +61 -68
  2. package/dist/cjs/ToastComposable.native.cjs +80 -94
  3. package/dist/cjs/ToastComposable.native.js +80 -94
  4. package/dist/cjs/ToastComposable.native.js.map +1 -1
  5. package/dist/cjs/ToastItemFrame.cjs +4 -3
  6. package/dist/cjs/ToastItemFrame.native.cjs +4 -3
  7. package/dist/cjs/ToastItemFrame.native.js +4 -3
  8. package/dist/cjs/ToastItemFrame.native.js.map +1 -1
  9. package/dist/cjs/ToastState.cjs +1 -0
  10. package/dist/cjs/ToastState.native.cjs +3 -13
  11. package/dist/cjs/ToastState.native.js +3 -13
  12. package/dist/cjs/ToastState.native.js.map +1 -1
  13. package/dist/esm/ToastComposable.mjs +62 -69
  14. package/dist/esm/ToastComposable.mjs.map +1 -1
  15. package/dist/esm/ToastComposable.native.js +81 -95
  16. package/dist/esm/ToastComposable.native.js.map +1 -1
  17. package/dist/esm/ToastItemFrame.mjs +4 -3
  18. package/dist/esm/ToastItemFrame.mjs.map +1 -1
  19. package/dist/esm/ToastItemFrame.native.js +4 -3
  20. package/dist/esm/ToastItemFrame.native.js.map +1 -1
  21. package/dist/esm/ToastState.mjs +1 -0
  22. package/dist/esm/ToastState.mjs.map +1 -1
  23. package/dist/esm/ToastState.native.js +3 -13
  24. package/dist/esm/ToastState.native.js.map +1 -1
  25. package/dist/jsx/ToastComposable.mjs +62 -69
  26. package/dist/jsx/ToastComposable.mjs.map +1 -1
  27. package/dist/jsx/ToastComposable.native.cjs +80 -94
  28. package/dist/jsx/ToastComposable.native.js +80 -94
  29. package/dist/jsx/ToastComposable.native.js.map +1 -1
  30. package/dist/jsx/ToastItemFrame.mjs +4 -3
  31. package/dist/jsx/ToastItemFrame.mjs.map +1 -1
  32. package/dist/jsx/ToastItemFrame.native.cjs +4 -3
  33. package/dist/jsx/ToastItemFrame.native.js +4 -3
  34. package/dist/jsx/ToastItemFrame.native.js.map +1 -1
  35. package/dist/jsx/ToastState.mjs +1 -0
  36. package/dist/jsx/ToastState.mjs.map +1 -1
  37. package/dist/jsx/ToastState.native.cjs +3 -13
  38. package/dist/jsx/ToastState.native.js +3 -13
  39. package/dist/jsx/ToastState.native.js.map +1 -1
  40. package/package.json +22 -20
  41. package/src/ToastComposable.tsx +107 -113
  42. package/src/ToastItemFrame.tsx +7 -3
  43. package/src/ToastState.ts +4 -1
  44. package/src/useToastAnimations.ts +3 -4
  45. package/types/ToastComposable.d.ts +32 -72
  46. package/types/ToastComposable.d.ts.map +1 -1
  47. package/types/ToastItemFrame.d.ts +12 -36
  48. package/types/ToastItemFrame.d.ts.map +1 -1
  49. package/types/ToastState.d.ts.map +1 -1
  50. package/types/useAnimatedDragGesture.native.d.ts +1 -1
  51. package/types/useToastAnimations.d.ts +2 -3
  52. package/types/useToastAnimations.d.ts.map +1 -1
@@ -86,7 +86,7 @@ function resolveSwipeDirection(direction, position) {
86
86
  return "horizontal";
87
87
  }
88
88
  const ToastRoot = (0, import_core.createRefComponent)(function ToastRoot2(props, _ref) {
89
- const { children, toasterId, position = "bottom-right", duration = TOAST_LIFETIME, gap = TOAST_GAP, visibleToasts = VISIBLE_TOASTS_AMOUNT, swipeDirection: swipeDirectionProp = "auto", swipeThreshold = 50, toastHeight = FIXED_TOAST_HEIGHT, closeButton = false, expand = false, theme: themeProp, reducedMotion: reducedMotionProp, native = false, burntOptions, notificationOptions, icons } = props;
89
+ const { children, toasterId, position = "bottom-right", duration = TOAST_LIFETIME, gap = TOAST_GAP, visibleToasts = VISIBLE_TOASTS_AMOUNT, swipeDirection: swipeDirectionProp = "auto", swipeThreshold = 50, toastHeight = FIXED_TOAST_HEIGHT, closeButton = false, expand = false, reducedMotion: reducedMotionProp, native = false, burntOptions, notificationOptions, icons } = props;
90
90
  const reducedMotion = (0, import_useReducedMotion.useReducedMotion)(reducedMotionProp);
91
91
  const [toasts, setToasts] = React.useState([]);
92
92
  const [heights, setHeights] = React.useState({});
@@ -172,7 +172,8 @@ const ToastRoot = (0, import_core.createRefComponent)(function ToastRoot2(props,
172
172
  ...toasts2.slice(0, idx),
173
173
  {
174
174
  ...toasts2[idx],
175
- ...toast
175
+ ...toast,
176
+ delete: false
176
177
  },
177
178
  ...toasts2.slice(idx + 1)
178
179
  ];
@@ -204,8 +205,6 @@ const ToastRoot = (0, import_core.createRefComponent)(function ToastRoot2(props,
204
205
  });
205
206
  }, []);
206
207
  const swipeDirection = resolveSwipeDirection(swipeDirectionProp, position);
207
- const currentTheme = (0, import_core2.useThemeName)();
208
- const resolvedTheme = themeProp === "system" || !themeProp ? currentTheme?.includes("dark") ? "dark" : "light" : themeProp;
209
208
  const contextValue = {
210
209
  toasts,
211
210
  heights,
@@ -234,10 +233,7 @@ const ToastRoot = (0, import_core.createRefComponent)(function ToastRoot2(props,
234
233
  };
235
234
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContext.Provider, {
236
235
  ...contextValue,
237
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Theme, {
238
- name: resolvedTheme,
239
- children
240
- })
236
+ children
241
237
  });
242
238
  });
243
239
  const ToastViewportFrame = (0, import_core2.styled)(import_core2.View, {
@@ -258,39 +254,36 @@ const ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, funct
258
254
  const deferredCollapseRef = React.useRef(null);
259
255
  const mouseInsideRef = React.useRef(false);
260
256
  const [yPosition, xPosition] = ctx.position.split("-");
261
- const { insets: safeInsets } = (0, import_core2.useConfiguration)();
262
- const offsetStyles = React.useMemo(() => {
263
- const styles = {};
264
- const defaultOffset = typeof offset === "number" ? offset : VIEWPORT_OFFSET;
265
- const offsetObj = typeof offset === "object" ? offset : {
266
- top: defaultOffset,
267
- right: defaultOffset,
268
- bottom: defaultOffset,
269
- left: defaultOffset
270
- };
271
- const safeTop = safeInsets?.top ?? 0;
272
- const safeBottom = safeInsets?.bottom ?? 0;
273
- const topOffset = safeTop > 0 ? safeTop : offsetObj.top ?? defaultOffset;
274
- const bottomOffset = safeBottom > 0 ? safeBottom : offsetObj.bottom ?? defaultOffset;
275
- if (yPosition === "top") styles.top = topOffset;
276
- else styles.bottom = bottomOffset;
277
- if (import_constants.isWeb) {
278
- if (xPosition === "left") styles.left = offsetObj.left ?? defaultOffset;
279
- else if (xPosition === "right") styles.right = offsetObj.right ?? defaultOffset;
280
- else {
281
- styles.left = "50%";
282
- styles.transform = "translateX(-50%)";
283
- }
284
- } else {
285
- styles.left = offsetObj.left ?? defaultOffset;
286
- styles.right = offsetObj.right ?? defaultOffset;
287
- }
288
- return styles;
289
- }, [
290
- offset,
291
- yPosition,
292
- xPosition
293
- ]);
257
+ const defaultOffset = typeof offset === "number" ? offset : VIEWPORT_OFFSET;
258
+ const offsetObj = typeof offset === "object" ? offset : {
259
+ top: defaultOffset,
260
+ right: defaultOffset,
261
+ bottom: defaultOffset,
262
+ left: defaultOffset
263
+ };
264
+ const edgeProps = yPosition === "top" ? {
265
+ top: "safe",
266
+ marginTop: offsetObj.top ?? defaultOffset
267
+ } : {
268
+ bottom: "safe",
269
+ marginBottom: offsetObj.bottom ?? defaultOffset
270
+ };
271
+ const sideProps = import_constants.isWeb ? xPosition === "left" ? {
272
+ left: "safe",
273
+ marginLeft: offsetObj.left ?? defaultOffset
274
+ } : xPosition === "right" ? {
275
+ right: "safe",
276
+ marginRight: offsetObj.right ?? defaultOffset
277
+ } : null : {
278
+ left: "safe",
279
+ marginLeft: offsetObj.left ?? defaultOffset,
280
+ right: "safe",
281
+ marginRight: offsetObj.right ?? defaultOffset
282
+ };
283
+ const centerStyle = import_constants.isWeb && xPosition === "center" ? {
284
+ left: "50%",
285
+ transform: "translateX(-50%)"
286
+ } : null;
294
287
  React.useEffect(() => {
295
288
  if (!import_constants.isWeb) return;
296
289
  const handleKeyDown = (event) => {
@@ -310,7 +303,9 @@ const ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, funct
310
303
  "aria-label": `${label} ${hotkeyLabel}`,
311
304
  tabIndex: -1,
312
305
  "aria-live": "polite",
313
- style: offsetStyles,
306
+ ...edgeProps,
307
+ ...sideProps,
308
+ ...centerStyle ? { style: centerStyle } : null,
314
309
  "data-y-position": yPosition,
315
310
  "data-x-position": xPosition,
316
311
  ...import_constants.isWeb ? {
@@ -581,13 +576,16 @@ const ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.To
581
576
  setMounted(true);
582
577
  }, []);
583
578
  React.useEffect(() => {
584
- if (toast.delete) {
585
- setRemoved(true);
586
- if (isExpandedRef.current) {
587
- setOffsetBeforeRemove(expandedOffsetRef.current);
588
- }
589
- setTimeout(() => ctx.removeToast(toast), TIME_BEFORE_UNMOUNT);
579
+ if (!toast.delete) {
580
+ setRemoved(false);
581
+ return;
582
+ }
583
+ setRemoved(true);
584
+ if (isExpandedRef.current) {
585
+ setOffsetBeforeRemove(expandedOffsetRef.current);
590
586
  }
587
+ const timer = setTimeout(() => ctx.removeToast(toast), TIME_BEFORE_UNMOUNT);
588
+ return () => clearTimeout(timer);
591
589
  }, [
592
590
  toast.delete,
593
591
  toast,
@@ -634,9 +632,8 @@ const ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.To
634
632
  }
635
633
  });
636
634
  const handleLayout = React.useCallback((event) => {
637
- if (!import_constants.isWeb) return;
638
635
  if (removed) return;
639
- if (!ctx.expanded && index !== 0) return;
636
+ if ((!import_constants.isWeb || !ctx.expanded) && index !== 0) return;
640
637
  const { height } = event.nativeEvent.layout;
641
638
  ctx.setToastHeight(toast.id, height);
642
639
  }, [
@@ -647,7 +644,6 @@ const ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.To
647
644
  removed
648
645
  ]);
649
646
  React.useEffect(() => {
650
- if (!import_constants.isWeb) return;
651
647
  return () => {
652
648
  ctx.removeToastHeight(toast.id);
653
649
  };
@@ -672,13 +668,11 @@ const ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.To
672
668
  handleClose
673
669
  }), [toast, handleClose]);
674
670
  let frontToastHeight = -1;
675
- if (import_constants.isWeb) {
676
- for (const t of ctx.toasts) {
677
- const h = ctx.heights[t.id];
678
- if (h != null && h > 0) {
679
- frontToastHeight = h;
680
- break;
681
- }
671
+ for (const t of ctx.toasts) {
672
+ const h = ctx.heights[t.id];
673
+ if (h != null && h > 0) {
674
+ frontToastHeight = h;
675
+ break;
682
676
  }
683
677
  }
684
678
  const stackScale = !ctx.expanded && !isFront ? 1 - index * .05 : 1;
@@ -686,7 +680,8 @@ const ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.To
686
680
  const stackY = ctx.expanded ? isTop ? activeExpandedOffset : -activeExpandedOffset : isFront ? 0 : isTop ? ctx.gap * index : -ctx.gap * index;
687
681
  const computedOpacity = removed && !swipeOut ? 0 : index >= ctx.visibleToasts ? 0 : 1;
688
682
  const computedZIndex = removed ? 0 : ctx.visibleToasts - index + 1;
689
- const computedHeight = import_constants.isWeb ? ctx.expanded ? ctx.heights[toast.id] || void 0 : !isFront && frontToastHeight > 0 ? frontToastHeight : void 0 : void 0;
683
+ const collapsedHeight = !isFront && frontToastHeight > 0 ? frontToastHeight : void 0;
684
+ const computedHeight = ctx.expanded ? import_constants.isWeb ? ctx.heights[toast.id] || void 0 : void 0 : collapsedHeight;
690
685
  const computedPointerEvents = index >= ctx.visibleToasts ? "none" : "auto";
691
686
  const gapFillerHeight = ctx.expanded ? ctx.gap + 1 : 0;
692
687
  const dataAttributes = {
@@ -702,10 +697,12 @@ const ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.To
702
697
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastPositionWrapper, {
703
698
  ref,
704
699
  testID: rest.testID,
705
- "aria-label": rest["aria-label"],
706
700
  ...dataAttributes,
707
- transition: isDragging || ctx.reducedMotion ? void 0 : removed ? "200ms" : "400ms",
708
- y: ctx.reducedMotion ? stackY : `${stackY} enter:${isTop ? -80 : 80}px exit:${swipeOut ? swipeExitYRef.current ?? stackY : stackY}px`,
701
+ transition: isDragging || ctx.reducedMotion ? void 0 : {
702
+ duration: removed ? 200 : 400,
703
+ properties: import_constants.isWeb ? "transform, opacity, height" : "transform, opacity"
704
+ },
705
+ y: ctx.reducedMotion ? stackY : `${stackY}px enter:${isTop ? -80 : 80}px exit:${swipeOut ? swipeExitYRef.current ?? stackY : stackY}px`,
709
706
  scale: stackScale,
710
707
  opacity: `${computedOpacity} enter:0 exit:0`,
711
708
  zIndex: computedZIndex,
@@ -714,12 +711,7 @@ const ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.To
714
711
  pointerEvents: computedPointerEvents,
715
712
  top: isTop ? 0 : void 0,
716
713
  bottom: isTop ? void 0 : 0,
717
- ...import_constants.isWeb && !isFront && { style: { transformOrigin: isTop ? "top center" : "bottom center" } },
718
- animateOnly: import_constants.isWeb ? [
719
- "transform",
720
- "opacity",
721
- "height"
722
- ] : ["transform", "opacity"],
714
+ ...!isFront && { style: { transformOrigin: isTop ? "top center" : "bottom center" } },
723
715
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DragWrapper, {
724
716
  animatedStyle,
725
717
  gestureHandlers,
@@ -746,6 +738,7 @@ const ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.To
746
738
  handleClose();
747
739
  }
748
740
  } },
741
+ ...!import_constants.isWeb && computedHeight != null && { flex: 1 },
749
742
  ...rest,
750
743
  children: [ctx.expanded && gapFillerHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
751
744
  position: "absolute",
@@ -50,10 +50,6 @@ var import_useAnimatedDragGesture = require("./useAnimatedDragGesture.native.js"
50
50
  var import_useToastAnimations = require("./useToastAnimations.native.js");
51
51
  var import_useReducedMotion = require("./useReducedMotion.native.js");
52
52
  var import_ToastItemFrame = require("./ToastItemFrame.native.js");
53
- function _type_of(obj) {
54
- "@swc/helpers - typeof";
55
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
56
- }
57
53
  var VISIBLE_TOASTS_AMOUNT = 4;
58
54
  var VIEWPORT_OFFSET = 16;
59
55
  var TOAST_GAP = 14;
@@ -92,7 +88,7 @@ function resolveSwipeDirection(direction, position) {
92
88
  return "horizontal";
93
89
  }
94
90
  var ToastRoot = (0, import_core.createRefComponent)(function ToastRoot2(props, _ref) {
95
- var { children, toasterId, position = "bottom-right", duration = TOAST_LIFETIME, gap = TOAST_GAP, visibleToasts = VISIBLE_TOASTS_AMOUNT, swipeDirection: swipeDirectionProp = "auto", swipeThreshold = 50, toastHeight = FIXED_TOAST_HEIGHT, closeButton = false, expand = false, theme: themeProp, reducedMotion: reducedMotionProp, native = false, burntOptions, notificationOptions, icons } = props;
91
+ var { children, toasterId, position = "bottom-right", duration = TOAST_LIFETIME, gap = TOAST_GAP, visibleToasts = VISIBLE_TOASTS_AMOUNT, swipeDirection: swipeDirectionProp = "auto", swipeThreshold = 50, toastHeight = FIXED_TOAST_HEIGHT, closeButton = false, expand = false, reducedMotion: reducedMotionProp, native = false, burntOptions, notificationOptions, icons } = props;
96
92
  var reducedMotion = (0, import_useReducedMotion.useReducedMotion)(reducedMotionProp);
97
93
  var [toasts, setToasts] = React.useState([]);
98
94
  var [heights, setHeights] = React.useState({});
@@ -188,7 +184,8 @@ var ToastRoot = (0, import_core.createRefComponent)(function ToastRoot2(props, _
188
184
  ...toasts2.slice(0, idx),
189
185
  {
190
186
  ...toasts2[idx],
191
- ...toast
187
+ ...toast,
188
+ delete: false
192
189
  },
193
190
  ...toasts2.slice(idx + 1)
194
191
  ];
@@ -226,8 +223,6 @@ var ToastRoot = (0, import_core.createRefComponent)(function ToastRoot2(props, _
226
223
  });
227
224
  }, []);
228
225
  var swipeDirection = resolveSwipeDirection(swipeDirectionProp, position);
229
- var currentTheme = (0, import_core2.useThemeName)();
230
- var resolvedTheme = themeProp === "system" || !themeProp ? (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.includes("dark")) ? "dark" : "light" : themeProp;
231
226
  var contextValue = {
232
227
  toasts,
233
228
  heights,
@@ -256,10 +251,7 @@ var ToastRoot = (0, import_core.createRefComponent)(function ToastRoot2(props, _
256
251
  };
257
252
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContext.Provider, {
258
253
  ...contextValue,
259
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Theme, {
260
- name: resolvedTheme,
261
- children
262
- })
254
+ children
263
255
  });
264
256
  });
265
257
  var ToastViewportFrame = (0, import_core2.styled)(import_core2.View, {
@@ -280,46 +272,38 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
280
272
  var deferredCollapseRef = React.useRef(null);
281
273
  var mouseInsideRef = React.useRef(false);
282
274
  var [yPosition, xPosition] = ctx.position.split("-");
283
- var { insets: safeInsets } = (0, import_core2.useConfiguration)();
284
- var offsetStyles = React.useMemo(function() {
285
- var styles = {};
286
- var defaultOffset = typeof offset === "number" ? offset : VIEWPORT_OFFSET;
287
- var offsetObj = (typeof offset === "undefined" ? "undefined" : _type_of(offset)) === "object" ? offset : {
288
- top: defaultOffset,
289
- right: defaultOffset,
290
- bottom: defaultOffset,
291
- left: defaultOffset
292
- };
293
- var _safeInsets_top;
294
- var safeTop = (_safeInsets_top = safeInsets === null || safeInsets === void 0 ? void 0 : safeInsets.top) !== null && _safeInsets_top !== void 0 ? _safeInsets_top : 0;
295
- var _safeInsets_bottom;
296
- var safeBottom = (_safeInsets_bottom = safeInsets === null || safeInsets === void 0 ? void 0 : safeInsets.bottom) !== null && _safeInsets_bottom !== void 0 ? _safeInsets_bottom : 0;
297
- var _offsetObj_top;
298
- var topOffset = safeTop > 0 ? safeTop : (_offsetObj_top = offsetObj.top) !== null && _offsetObj_top !== void 0 ? _offsetObj_top : defaultOffset;
299
- var _offsetObj_bottom;
300
- var bottomOffset = safeBottom > 0 ? safeBottom : (_offsetObj_bottom = offsetObj.bottom) !== null && _offsetObj_bottom !== void 0 ? _offsetObj_bottom : defaultOffset;
301
- if (yPosition === "top") styles.top = topOffset;
302
- else styles.bottom = bottomOffset;
303
- if (import_constants.isWeb) {
304
- var _offsetObj_left, _offsetObj_right;
305
- if (xPosition === "left") styles.left = (_offsetObj_left = offsetObj.left) !== null && _offsetObj_left !== void 0 ? _offsetObj_left : defaultOffset;
306
- else if (xPosition === "right") styles.right = (_offsetObj_right = offsetObj.right) !== null && _offsetObj_right !== void 0 ? _offsetObj_right : defaultOffset;
307
- else {
308
- styles.left = "50%";
309
- styles.transform = "translateX(-50%)";
310
- }
311
- } else {
312
- var _offsetObj_left1;
313
- styles.left = (_offsetObj_left1 = offsetObj.left) !== null && _offsetObj_left1 !== void 0 ? _offsetObj_left1 : defaultOffset;
314
- var _offsetObj_right1;
315
- styles.right = (_offsetObj_right1 = offsetObj.right) !== null && _offsetObj_right1 !== void 0 ? _offsetObj_right1 : defaultOffset;
316
- }
317
- return styles;
318
- }, [
319
- offset,
320
- yPosition,
321
- xPosition
322
- ]);
275
+ var defaultOffset = typeof offset === "number" ? offset : VIEWPORT_OFFSET;
276
+ var offsetObj = typeof offset === "object" ? offset : {
277
+ top: defaultOffset,
278
+ right: defaultOffset,
279
+ bottom: defaultOffset,
280
+ left: defaultOffset
281
+ };
282
+ var _offsetObj_top, _offsetObj_bottom;
283
+ var edgeProps = yPosition === "top" ? {
284
+ top: "safe",
285
+ marginTop: (_offsetObj_top = offsetObj.top) !== null && _offsetObj_top !== void 0 ? _offsetObj_top : defaultOffset
286
+ } : {
287
+ bottom: "safe",
288
+ marginBottom: (_offsetObj_bottom = offsetObj.bottom) !== null && _offsetObj_bottom !== void 0 ? _offsetObj_bottom : defaultOffset
289
+ };
290
+ var _offsetObj_left, _offsetObj_right, _offsetObj_left1, _offsetObj_right1;
291
+ var sideProps = import_constants.isWeb ? xPosition === "left" ? {
292
+ left: "safe",
293
+ marginLeft: (_offsetObj_left = offsetObj.left) !== null && _offsetObj_left !== void 0 ? _offsetObj_left : defaultOffset
294
+ } : xPosition === "right" ? {
295
+ right: "safe",
296
+ marginRight: (_offsetObj_right = offsetObj.right) !== null && _offsetObj_right !== void 0 ? _offsetObj_right : defaultOffset
297
+ } : null : {
298
+ left: "safe",
299
+ marginLeft: (_offsetObj_left1 = offsetObj.left) !== null && _offsetObj_left1 !== void 0 ? _offsetObj_left1 : defaultOffset,
300
+ right: "safe",
301
+ marginRight: (_offsetObj_right1 = offsetObj.right) !== null && _offsetObj_right1 !== void 0 ? _offsetObj_right1 : defaultOffset
302
+ };
303
+ var centerStyle = import_constants.isWeb && xPosition === "center" ? {
304
+ left: "50%",
305
+ transform: "translateX(-50%)"
306
+ } : null;
323
307
  React.useEffect(function() {
324
308
  if (!import_constants.isWeb) return;
325
309
  var handleKeyDown = function(event) {
@@ -344,7 +328,9 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
344
328
  "aria-label": `${label} ${hotkeyLabel}`,
345
329
  tabIndex: -1,
346
330
  "aria-live": "polite",
347
- style: offsetStyles,
331
+ ...edgeProps,
332
+ ...sideProps,
333
+ ...centerStyle ? { style: centerStyle } : null,
348
334
  "data-y-position": yPosition,
349
335
  "data-x-position": xPosition,
350
336
  ...import_constants.isWeb ? {
@@ -637,15 +623,20 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
637
623
  setMounted(true);
638
624
  }, []);
639
625
  React.useEffect(function() {
640
- if (toast.delete) {
641
- setRemoved(true);
642
- if (isExpandedRef.current) {
643
- setOffsetBeforeRemove(expandedOffsetRef.current);
644
- }
645
- setTimeout(function() {
646
- return ctx.removeToast(toast);
647
- }, TIME_BEFORE_UNMOUNT);
626
+ if (!toast.delete) {
627
+ setRemoved(false);
628
+ return;
629
+ }
630
+ setRemoved(true);
631
+ if (isExpandedRef.current) {
632
+ setOffsetBeforeRemove(expandedOffsetRef.current);
648
633
  }
634
+ var timer = setTimeout(function() {
635
+ return ctx.removeToast(toast);
636
+ }, TIME_BEFORE_UNMOUNT);
637
+ return function() {
638
+ return clearTimeout(timer);
639
+ };
649
640
  }, [
650
641
  toast.delete,
651
642
  toast,
@@ -693,9 +684,8 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
693
684
  }
694
685
  });
695
686
  var handleLayout = React.useCallback(function(event) {
696
- if (!import_constants.isWeb) return;
697
687
  if (removed) return;
698
- if (!ctx.expanded && index !== 0) return;
688
+ if ((!import_constants.isWeb || !ctx.expanded) && index !== 0) return;
699
689
  var { height } = event.nativeEvent.layout;
700
690
  ctx.setToastHeight(toast.id, height);
701
691
  }, [
@@ -706,7 +696,6 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
706
696
  removed
707
697
  ]);
708
698
  React.useEffect(function() {
709
- if (!import_constants.isWeb) return;
710
699
  return function() {
711
700
  ctx.removeToastHeight(toast.id);
712
701
  };
@@ -736,29 +725,27 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
736
725
  };
737
726
  }, [toast, handleClose]);
738
727
  var frontToastHeight = -1;
739
- if (import_constants.isWeb) {
740
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
728
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
729
+ try {
730
+ for (var _iterator = ctx.toasts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
731
+ var t = _step.value;
732
+ var h = ctx.heights[t.id];
733
+ if (h != null && h > 0) {
734
+ frontToastHeight = h;
735
+ break;
736
+ }
737
+ }
738
+ } catch (err) {
739
+ _didIteratorError = true;
740
+ _iteratorError = err;
741
+ } finally {
741
742
  try {
742
- for (var _iterator = ctx.toasts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
743
- var t = _step.value;
744
- var h = ctx.heights[t.id];
745
- if (h != null && h > 0) {
746
- frontToastHeight = h;
747
- break;
748
- }
743
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
744
+ _iterator.return();
749
745
  }
750
- } catch (err) {
751
- _didIteratorError = true;
752
- _iteratorError = err;
753
746
  } finally {
754
- try {
755
- if (!_iteratorNormalCompletion && _iterator.return != null) {
756
- _iterator.return();
757
- }
758
- } finally {
759
- if (_didIteratorError) {
760
- throw _iteratorError;
761
- }
747
+ if (_didIteratorError) {
748
+ throw _iteratorError;
762
749
  }
763
750
  }
764
751
  }
@@ -767,7 +754,8 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
767
754
  var stackY = ctx.expanded ? isTop ? activeExpandedOffset : -activeExpandedOffset : isFront ? 0 : isTop ? ctx.gap * index : -ctx.gap * index;
768
755
  var computedOpacity = removed && !swipeOut ? 0 : index >= ctx.visibleToasts ? 0 : 1;
769
756
  var computedZIndex = removed ? 0 : ctx.visibleToasts - index + 1;
770
- var computedHeight = import_constants.isWeb ? ctx.expanded ? ctx.heights[toast.id] || void 0 : !isFront && frontToastHeight > 0 ? frontToastHeight : void 0 : void 0;
757
+ var collapsedHeight = !isFront && frontToastHeight > 0 ? frontToastHeight : void 0;
758
+ var computedHeight = ctx.expanded ? import_constants.isWeb ? ctx.heights[toast.id] || void 0 : void 0 : collapsedHeight;
771
759
  var computedPointerEvents = index >= ctx.visibleToasts ? "none" : "auto";
772
760
  var gapFillerHeight = ctx.expanded ? ctx.gap + 1 : 0;
773
761
  var dataAttributes = {
@@ -784,10 +772,12 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
784
772
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastPositionWrapper, {
785
773
  ref,
786
774
  testID: rest.testID,
787
- "aria-label": rest["aria-label"],
788
775
  ...dataAttributes,
789
- transition: isDragging || ctx.reducedMotion ? void 0 : removed ? "200ms" : "400ms",
790
- y: ctx.reducedMotion ? stackY : `${stackY} enter:${isTop ? -80 : 80}px exit:${swipeOut ? (_swipeExitYRef_current = swipeExitYRef.current) !== null && _swipeExitYRef_current !== void 0 ? _swipeExitYRef_current : stackY : stackY}px`,
776
+ transition: isDragging || ctx.reducedMotion ? void 0 : {
777
+ duration: removed ? 200 : 400,
778
+ properties: import_constants.isWeb ? "transform, opacity, height" : "transform, opacity"
779
+ },
780
+ y: ctx.reducedMotion ? stackY : `${stackY}px enter:${isTop ? -80 : 80}px exit:${swipeOut ? (_swipeExitYRef_current = swipeExitYRef.current) !== null && _swipeExitYRef_current !== void 0 ? _swipeExitYRef_current : stackY : stackY}px`,
791
781
  scale: stackScale,
792
782
  opacity: `${computedOpacity} enter:0 exit:0`,
793
783
  zIndex: computedZIndex,
@@ -796,12 +786,7 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
796
786
  pointerEvents: computedPointerEvents,
797
787
  top: isTop ? 0 : void 0,
798
788
  bottom: isTop ? void 0 : 0,
799
- ...import_constants.isWeb && !isFront && { style: { transformOrigin: isTop ? "top center" : "bottom center" } },
800
- animateOnly: import_constants.isWeb ? [
801
- "transform",
802
- "opacity",
803
- "height"
804
- ] : ["transform", "opacity"],
789
+ ...!isFront && { style: { transformOrigin: isTop ? "top center" : "bottom center" } },
805
790
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DragWrapper, {
806
791
  animatedStyle,
807
792
  gestureHandlers,
@@ -828,6 +813,7 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
828
813
  handleClose();
829
814
  }
830
815
  } },
816
+ ...!import_constants.isWeb && computedHeight != null && { flex: 1 },
831
817
  ...rest,
832
818
  children: [ctx.expanded && gapFillerHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
833
819
  position: "absolute",