@tamagui/toast 3.0.0-beta.924.1 → 3.0.1
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.
- package/dist/cjs/ToastComposable.cjs +61 -68
- package/dist/cjs/ToastComposable.native.cjs +80 -94
- package/dist/cjs/ToastComposable.native.js +80 -94
- package/dist/cjs/ToastComposable.native.js.map +1 -1
- package/dist/cjs/ToastItemFrame.cjs +4 -3
- package/dist/cjs/ToastItemFrame.native.cjs +4 -3
- package/dist/cjs/ToastItemFrame.native.js +4 -3
- package/dist/cjs/ToastItemFrame.native.js.map +1 -1
- package/dist/cjs/ToastState.cjs +1 -0
- package/dist/cjs/ToastState.native.cjs +3 -13
- package/dist/cjs/ToastState.native.js +3 -13
- package/dist/cjs/ToastState.native.js.map +1 -1
- package/dist/esm/ToastComposable.mjs +62 -69
- package/dist/esm/ToastComposable.mjs.map +1 -1
- package/dist/esm/ToastComposable.native.js +81 -95
- package/dist/esm/ToastComposable.native.js.map +1 -1
- package/dist/esm/ToastItemFrame.mjs +4 -3
- package/dist/esm/ToastItemFrame.mjs.map +1 -1
- package/dist/esm/ToastItemFrame.native.js +4 -3
- package/dist/esm/ToastItemFrame.native.js.map +1 -1
- package/dist/esm/ToastState.mjs +1 -0
- package/dist/esm/ToastState.mjs.map +1 -1
- package/dist/esm/ToastState.native.js +3 -13
- package/dist/esm/ToastState.native.js.map +1 -1
- package/dist/jsx/ToastComposable.mjs +62 -69
- package/dist/jsx/ToastComposable.mjs.map +1 -1
- package/dist/jsx/ToastComposable.native.cjs +80 -94
- package/dist/jsx/ToastComposable.native.js +80 -94
- package/dist/jsx/ToastComposable.native.js.map +1 -1
- package/dist/jsx/ToastItemFrame.mjs +4 -3
- package/dist/jsx/ToastItemFrame.mjs.map +1 -1
- package/dist/jsx/ToastItemFrame.native.cjs +4 -3
- package/dist/jsx/ToastItemFrame.native.js +4 -3
- package/dist/jsx/ToastItemFrame.native.js.map +1 -1
- package/dist/jsx/ToastState.mjs +1 -0
- package/dist/jsx/ToastState.mjs.map +1 -1
- package/dist/jsx/ToastState.native.cjs +3 -13
- package/dist/jsx/ToastState.native.js +3 -13
- package/dist/jsx/ToastState.native.js.map +1 -1
- package/package.json +22 -20
- package/src/ToastComposable.tsx +107 -113
- package/src/ToastItemFrame.tsx +7 -3
- package/src/ToastState.ts +4 -1
- package/src/useToastAnimations.ts +3 -4
- package/types/ToastComposable.d.ts +32 -72
- package/types/ToastComposable.d.ts.map +1 -1
- package/types/ToastItemFrame.d.ts +12 -36
- package/types/ToastItemFrame.d.ts.map +1 -1
- package/types/ToastState.d.ts.map +1 -1
- package/types/useAnimatedDragGesture.native.d.ts +1 -1
- package/types/useToastAnimations.d.ts +2 -3
- 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,
|
|
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
|
|
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
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
|
|
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(
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
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
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
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
|
|
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 :
|
|
708
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
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
|
|
284
|
-
var
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
|
|
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(
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
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
|
-
|
|
740
|
-
|
|
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
|
-
|
|
743
|
-
|
|
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
|
-
|
|
755
|
-
|
|
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
|
|
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 :
|
|
790
|
-
|
|
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
|
-
|
|
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",
|