@tamagui/toast 3.0.7 → 3.0.8
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.native.cjs +23 -28
- package/dist/cjs/ToastComposable.native.js +23 -28
- package/dist/cjs/ToastComposable.native.js.map +1 -1
- package/dist/cjs/ToastItemFrame.native.cjs +1 -1
- package/dist/cjs/ToastItemFrame.native.js +1 -1
- package/dist/cjs/ToastItemFrame.native.js.map +1 -1
- package/dist/cjs/ToastState.native.cjs +9 -13
- package/dist/cjs/ToastState.native.js +9 -13
- package/dist/cjs/ToastState.native.js.map +1 -1
- package/dist/cjs/createNativeToast.native.cjs +2 -2
- package/dist/cjs/createNativeToast.native.js +2 -2
- package/dist/cjs/createNativeToast.native.js.map +1 -1
- package/dist/cjs/dispatchNativeToast.native.cjs +1 -2
- package/dist/cjs/dispatchNativeToast.native.js +1 -2
- package/dist/cjs/dispatchNativeToast.native.js.map +1 -1
- package/dist/cjs/useAnimatedDragGesture.native.cjs +9 -9
- package/dist/cjs/useAnimatedDragGesture.native.js +9 -9
- package/dist/cjs/useAnimatedDragGesture.native.js.map +1 -1
- package/dist/cjs/useReducedMotion.native.cjs +3 -3
- package/dist/cjs/useReducedMotion.native.js +3 -3
- package/dist/cjs/useReducedMotion.native.js.map +1 -1
- package/dist/cjs/useToastAnimations.native.cjs +1 -1
- package/dist/cjs/useToastAnimations.native.js +1 -1
- package/dist/cjs/useToastAnimations.native.js.map +1 -1
- package/dist/esm/ToastComposable.native.js +23 -28
- package/dist/esm/ToastComposable.native.js.map +1 -1
- package/dist/esm/ToastItemFrame.native.js +1 -1
- package/dist/esm/ToastItemFrame.native.js.map +1 -1
- package/dist/esm/ToastState.native.js +9 -13
- package/dist/esm/ToastState.native.js.map +1 -1
- package/dist/esm/createNativeToast.native.js +2 -2
- package/dist/esm/createNativeToast.native.js.map +1 -1
- package/dist/esm/dispatchNativeToast.native.js +1 -2
- package/dist/esm/dispatchNativeToast.native.js.map +1 -1
- package/dist/esm/useAnimatedDragGesture.native.js +9 -9
- package/dist/esm/useAnimatedDragGesture.native.js.map +1 -1
- package/dist/esm/useReducedMotion.native.js +3 -3
- package/dist/esm/useReducedMotion.native.js.map +1 -1
- package/dist/esm/useToastAnimations.native.js +1 -1
- package/dist/esm/useToastAnimations.native.js.map +1 -1
- package/dist/jsx/ToastComposable.native.cjs +23 -28
- package/dist/jsx/ToastComposable.native.js +23 -28
- package/dist/jsx/ToastComposable.native.js.map +1 -1
- package/dist/jsx/ToastItemFrame.native.cjs +1 -1
- package/dist/jsx/ToastItemFrame.native.js +1 -1
- package/dist/jsx/ToastItemFrame.native.js.map +1 -1
- package/dist/jsx/ToastState.native.cjs +9 -13
- package/dist/jsx/ToastState.native.js +9 -13
- package/dist/jsx/ToastState.native.js.map +1 -1
- package/dist/jsx/createNativeToast.native.cjs +2 -2
- package/dist/jsx/createNativeToast.native.js +2 -2
- package/dist/jsx/createNativeToast.native.js.map +1 -1
- package/dist/jsx/dispatchNativeToast.native.cjs +1 -2
- package/dist/jsx/dispatchNativeToast.native.js +1 -2
- package/dist/jsx/dispatchNativeToast.native.js.map +1 -1
- package/dist/jsx/useAnimatedDragGesture.native.cjs +9 -9
- package/dist/jsx/useAnimatedDragGesture.native.js +9 -9
- package/dist/jsx/useAnimatedDragGesture.native.js.map +1 -1
- package/dist/jsx/useReducedMotion.native.cjs +3 -3
- package/dist/jsx/useReducedMotion.native.js +3 -3
- package/dist/jsx/useReducedMotion.native.js.map +1 -1
- package/dist/jsx/useToastAnimations.native.cjs +1 -1
- package/dist/jsx/useToastAnimations.native.js +1 -1
- package/dist/jsx/useToastAnimations.native.js.map +1 -1
- package/package.json +19 -19
|
@@ -264,6 +264,7 @@ var ToastViewportFrame = (0, import_core2.styled)(import_core2.View, {
|
|
|
264
264
|
minHeight: 1
|
|
265
265
|
});
|
|
266
266
|
var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, function ToastViewport2(props, ref) {
|
|
267
|
+
var _offsetObj_top, _offsetObj_bottom, _offsetObj_left, _offsetObj_right, _offsetObj_left1, _offsetObj_right1;
|
|
267
268
|
var { offset = VIEWPORT_OFFSET, hotkey = DEFAULT_HOTKEY, label = "Notifications", portalToRoot = true, portalZIndex = Number.MAX_SAFE_INTEGER, children, ...rest } = props;
|
|
268
269
|
var ctx = useToastContext("Toast.Viewport");
|
|
269
270
|
var listRef = React.useRef(null);
|
|
@@ -279,7 +280,6 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
279
280
|
bottom: defaultOffset,
|
|
280
281
|
left: defaultOffset
|
|
281
282
|
};
|
|
282
|
-
var _offsetObj_top, _offsetObj_bottom;
|
|
283
283
|
var edgeProps = yPosition === "top" ? {
|
|
284
284
|
top: "safe",
|
|
285
285
|
marginTop: (_offsetObj_top = offsetObj.top) !== null && _offsetObj_top !== void 0 ? _offsetObj_top : defaultOffset
|
|
@@ -287,7 +287,6 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
287
287
|
bottom: "safe",
|
|
288
288
|
marginBottom: (_offsetObj_bottom = offsetObj.bottom) !== null && _offsetObj_bottom !== void 0 ? _offsetObj_bottom : defaultOffset
|
|
289
289
|
};
|
|
290
|
-
var _offsetObj_left, _offsetObj_right, _offsetObj_left1, _offsetObj_right1;
|
|
291
290
|
var sideProps = import_constants.isWeb ? xPosition === "left" ? {
|
|
292
291
|
left: "safe",
|
|
293
292
|
marginLeft: (_offsetObj_left = offsetObj.left) !== null && _offsetObj_left !== void 0 ? _offsetObj_left : defaultOffset
|
|
@@ -306,7 +305,7 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
306
305
|
} : null;
|
|
307
306
|
React.useEffect(function() {
|
|
308
307
|
if (!import_constants.isWeb) return;
|
|
309
|
-
var handleKeyDown = function(event) {
|
|
308
|
+
var handleKeyDown = function handleKeyDown2(event) {
|
|
310
309
|
var isHotkeyPressed = hotkey.length > 0 && hotkey.every(function(key) {
|
|
311
310
|
return event[key] || event.code === key;
|
|
312
311
|
});
|
|
@@ -334,7 +333,7 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
334
333
|
"data-y-position": yPosition,
|
|
335
334
|
"data-x-position": xPosition,
|
|
336
335
|
...import_constants.isWeb ? {
|
|
337
|
-
onMouseEnter: function() {
|
|
336
|
+
onMouseEnter: function onMouseEnter() {
|
|
338
337
|
mouseInsideRef.current = true;
|
|
339
338
|
if (deferredCollapseRef.current) {
|
|
340
339
|
clearTimeout(deferredCollapseRef.current);
|
|
@@ -346,7 +345,7 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
346
345
|
}, 50);
|
|
347
346
|
}
|
|
348
347
|
},
|
|
349
|
-
onMouseLeave: function() {
|
|
348
|
+
onMouseLeave: function onMouseLeave() {
|
|
350
349
|
mouseInsideRef.current = false;
|
|
351
350
|
if (hoverTimeoutRef.current) {
|
|
352
351
|
clearTimeout(hoverTimeoutRef.current);
|
|
@@ -366,20 +365,20 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
366
365
|
}, 1200);
|
|
367
366
|
}
|
|
368
367
|
},
|
|
369
|
-
onPointerDown: function() {
|
|
368
|
+
onPointerDown: function onPointerDown() {
|
|
370
369
|
if (hoverTimeoutRef.current) {
|
|
371
370
|
clearTimeout(hoverTimeoutRef.current);
|
|
372
371
|
hoverTimeoutRef.current = null;
|
|
373
372
|
}
|
|
374
373
|
ctx.setInteracting(true);
|
|
375
374
|
},
|
|
376
|
-
onPointerUp: function() {
|
|
375
|
+
onPointerUp: function onPointerUp() {
|
|
377
376
|
return ctx.setInteracting(false);
|
|
378
377
|
},
|
|
379
|
-
onPointerCancel: function() {
|
|
378
|
+
onPointerCancel: function onPointerCancel() {
|
|
380
379
|
return ctx.setInteracting(false);
|
|
381
380
|
}
|
|
382
|
-
} : { onPress: function() {
|
|
381
|
+
} : { onPress: function onPress() {
|
|
383
382
|
if (ctx.toasts.length > 1) {
|
|
384
383
|
ctx.setExpanded(function(prev) {
|
|
385
384
|
return !prev;
|
|
@@ -387,7 +386,7 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
387
386
|
}
|
|
388
387
|
} },
|
|
389
388
|
...import_constants.isWeb && {
|
|
390
|
-
onFocus: function(event) {
|
|
389
|
+
onFocus: function onFocus(event) {
|
|
391
390
|
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
392
391
|
if (ctx.toasts.length > 1) {
|
|
393
392
|
ctx.setExpanded(true);
|
|
@@ -395,7 +394,7 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
395
394
|
ctx.setInteracting(true);
|
|
396
395
|
}
|
|
397
396
|
},
|
|
398
|
-
onBlur: function(event) {
|
|
397
|
+
onBlur: function onBlur(event) {
|
|
399
398
|
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
400
399
|
ctx.setInteracting(false);
|
|
401
400
|
if (!ctx.isInDismissCooldown()) {
|
|
@@ -423,7 +422,7 @@ function ToastList(param) {
|
|
|
423
422
|
var ctx = useToastContext("Toast.List");
|
|
424
423
|
var maxRender = ctx.toasts.length;
|
|
425
424
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { children: ctx.toasts.slice(0, maxRender).map(function(toast, index) {
|
|
426
|
-
var handleClose = function() {
|
|
425
|
+
var handleClose = function handleClose2() {
|
|
427
426
|
var _toast_onDismiss;
|
|
428
427
|
if (toast.dismissible === false) return;
|
|
429
428
|
(_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
|
|
@@ -455,9 +454,9 @@ function ToastList(param) {
|
|
|
455
454
|
}
|
|
456
455
|
function DefaultToastContent(param) {
|
|
457
456
|
var { toast } = param;
|
|
457
|
+
var _toast_type;
|
|
458
458
|
var ctx = useToastContext("Toast.Item");
|
|
459
459
|
var { handleClose } = useToastItemContext();
|
|
460
|
-
var _toast_type;
|
|
461
460
|
var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
|
|
462
461
|
var dismissible = toast.dismissible !== false;
|
|
463
462
|
var title = typeof toast.title === "function" ? toast.title() : toast.title;
|
|
@@ -477,7 +476,7 @@ function DefaultToastContent(param) {
|
|
|
477
476
|
gap: "2",
|
|
478
477
|
marginTop: "2",
|
|
479
478
|
children: [toast.cancel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
|
|
480
|
-
onPress: function(e) {
|
|
479
|
+
onPress: function onPress(e) {
|
|
481
480
|
var _toast_cancel_onClick, _toast_cancel;
|
|
482
481
|
(_toast_cancel = toast.cancel) === null || _toast_cancel === void 0 ? void 0 : (_toast_cancel_onClick = _toast_cancel.onClick) === null || _toast_cancel_onClick === void 0 ? void 0 : _toast_cancel_onClick.call(_toast_cancel, e);
|
|
483
482
|
handleClose();
|
|
@@ -487,7 +486,7 @@ function DefaultToastContent(param) {
|
|
|
487
486
|
children: toast.cancel.label
|
|
488
487
|
})
|
|
489
488
|
}), toast.action && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
|
|
490
|
-
onPress: function(e) {
|
|
489
|
+
onPress: function onPress(e) {
|
|
491
490
|
var _toast_action_onClick, _toast_action;
|
|
492
491
|
(_toast_action = toast.action) === null || _toast_action === void 0 ? void 0 : (_toast_action_onClick = _toast_action.onClick) === null || _toast_action_onClick === void 0 ? void 0 : _toast_action_onClick.call(_toast_action, e);
|
|
493
492
|
if (!e.defaultPrevented) {
|
|
@@ -548,6 +547,7 @@ function DragWrapper(param) {
|
|
|
548
547
|
});
|
|
549
548
|
}
|
|
550
549
|
var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastItemFrame, function ToastItem(props, ref) {
|
|
550
|
+
var _toast_duration, _toast_type, _toast_duration1, _swipeExitYRef_current;
|
|
551
551
|
var { toast, index, children, ...rest } = props;
|
|
552
552
|
var ctx = useToastContext("Toast.Item");
|
|
553
553
|
var [mounted, setMounted] = React.useState(false);
|
|
@@ -558,14 +558,11 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
558
558
|
var closeTimerRef = React.useRef(null);
|
|
559
559
|
var closeTimerStartRef = React.useRef(0);
|
|
560
560
|
var lastPauseTimeRef = React.useRef(0);
|
|
561
|
-
var _toast_duration;
|
|
562
561
|
var remainingTimeRef = React.useRef((_toast_duration = toast.duration) !== null && _toast_duration !== void 0 ? _toast_duration : ctx.duration);
|
|
563
562
|
var isFront = index === 0;
|
|
564
563
|
var isVisible = index < ctx.visibleToasts;
|
|
565
|
-
var _toast_type;
|
|
566
564
|
var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
|
|
567
565
|
var dismissible = toast.dismissible !== false;
|
|
568
|
-
var _toast_duration1;
|
|
569
566
|
var duration = (_toast_duration1 = toast.duration) !== null && _toast_duration1 !== void 0 ? _toast_duration1 : ctx.duration;
|
|
570
567
|
var [yPosition] = ctx.position.split("-");
|
|
571
568
|
var isTop = yPosition === "top";
|
|
@@ -667,7 +664,7 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
667
664
|
expanded: ctx.expanded,
|
|
668
665
|
onDragStart: pauseTimer,
|
|
669
666
|
onDragMove: setDragOffset,
|
|
670
|
-
onDismiss: function(exitDirection, velocity) {
|
|
667
|
+
onDismiss: function onDismiss(exitDirection, velocity) {
|
|
671
668
|
var _toast_onDismiss;
|
|
672
669
|
ctx.triggerDismissCooldown();
|
|
673
670
|
setSwipeOut(true);
|
|
@@ -677,7 +674,7 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
677
674
|
ctx.removeToast(toast);
|
|
678
675
|
animateOut(exitDirection, velocity);
|
|
679
676
|
},
|
|
680
|
-
onCancel: function() {
|
|
677
|
+
onCancel: function onCancel() {
|
|
681
678
|
springBack(function() {
|
|
682
679
|
resumeTimer();
|
|
683
680
|
});
|
|
@@ -768,7 +765,6 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
768
765
|
"data-type": toastType,
|
|
769
766
|
"data-expanded": ctx.expanded ? "true" : "false"
|
|
770
767
|
};
|
|
771
|
-
var _swipeExitYRef_current;
|
|
772
768
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastPositionWrapper, {
|
|
773
769
|
ref,
|
|
774
770
|
testID: rest.testID,
|
|
@@ -799,7 +795,7 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
799
795
|
"aria-atomic": true,
|
|
800
796
|
tabIndex: 0,
|
|
801
797
|
onLayout: handleLayout,
|
|
802
|
-
...import_constants.isWeb && { onKeyDown: function(event) {
|
|
798
|
+
...import_constants.isWeb && { onKeyDown: function onKeyDown(event) {
|
|
803
799
|
if (event.key === "Escape" && dismissible) {
|
|
804
800
|
var current = event.currentTarget;
|
|
805
801
|
var container = current.closest("[aria-label]");
|
|
@@ -833,14 +829,14 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
833
829
|
var ToastTitle = (0, import_core2.styled)(import_text.SizableText, { displayName: "ToastTitle" });
|
|
834
830
|
var ToastDescription = (0, import_core2.styled)(import_text.SizableText, { displayName: "ToastDescription" });
|
|
835
831
|
var ToastClose = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastCloseFrame, function ToastClose2(props, ref) {
|
|
832
|
+
var _ref, _props_children;
|
|
836
833
|
var _ctx_icons;
|
|
837
834
|
var handleClose;
|
|
838
835
|
try {
|
|
839
836
|
var itemCtx = useToastItemContext();
|
|
840
837
|
handleClose = itemCtx.handleClose;
|
|
841
|
-
} catch (
|
|
838
|
+
} catch (unused) {}
|
|
842
839
|
var ctx = useToastContext("Toast.Close");
|
|
843
|
-
var _props_children, _ref;
|
|
844
840
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastCloseFrame, {
|
|
845
841
|
ref,
|
|
846
842
|
"aria-label": "Close toast",
|
|
@@ -856,13 +852,14 @@ var ToastAction = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastAc
|
|
|
856
852
|
});
|
|
857
853
|
});
|
|
858
854
|
function ToastIcon(props) {
|
|
855
|
+
var _toast_type, _ref;
|
|
859
856
|
var _ctx_icons;
|
|
860
857
|
var ctx = useToastContext("Toast.Icon");
|
|
861
858
|
var toast;
|
|
862
859
|
try {
|
|
863
860
|
var itemCtx = useToastItemContext();
|
|
864
861
|
toast = itemCtx.toast;
|
|
865
|
-
} catch (
|
|
862
|
+
} catch (unused) {
|
|
866
863
|
return null;
|
|
867
864
|
}
|
|
868
865
|
if (!toast) return null;
|
|
@@ -873,10 +870,8 @@ function ToastIcon(props) {
|
|
|
873
870
|
children: toast.icon
|
|
874
871
|
});
|
|
875
872
|
}
|
|
876
|
-
var _toast_type;
|
|
877
873
|
var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
|
|
878
|
-
var
|
|
879
|
-
var icon = (_ctx_icons_toastType = (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons[toastType]) !== null && _ctx_icons_toastType !== void 0 ? _ctx_icons_toastType : null;
|
|
874
|
+
var icon = (_ref = (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons[toastType]) !== null && _ref !== void 0 ? _ref : null;
|
|
880
875
|
if (!icon) return null;
|
|
881
876
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
|
|
882
877
|
flexShrink: 0,
|
|
@@ -264,6 +264,7 @@ var ToastViewportFrame = (0, import_core2.styled)(import_core2.View, {
|
|
|
264
264
|
minHeight: 1
|
|
265
265
|
});
|
|
266
266
|
var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, function ToastViewport2(props, ref) {
|
|
267
|
+
var _offsetObj_top, _offsetObj_bottom, _offsetObj_left, _offsetObj_right, _offsetObj_left1, _offsetObj_right1;
|
|
267
268
|
var { offset = VIEWPORT_OFFSET, hotkey = DEFAULT_HOTKEY, label = "Notifications", portalToRoot = true, portalZIndex = Number.MAX_SAFE_INTEGER, children, ...rest } = props;
|
|
268
269
|
var ctx = useToastContext("Toast.Viewport");
|
|
269
270
|
var listRef = React.useRef(null);
|
|
@@ -279,7 +280,6 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
279
280
|
bottom: defaultOffset,
|
|
280
281
|
left: defaultOffset
|
|
281
282
|
};
|
|
282
|
-
var _offsetObj_top, _offsetObj_bottom;
|
|
283
283
|
var edgeProps = yPosition === "top" ? {
|
|
284
284
|
top: "safe",
|
|
285
285
|
marginTop: (_offsetObj_top = offsetObj.top) !== null && _offsetObj_top !== void 0 ? _offsetObj_top : defaultOffset
|
|
@@ -287,7 +287,6 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
287
287
|
bottom: "safe",
|
|
288
288
|
marginBottom: (_offsetObj_bottom = offsetObj.bottom) !== null && _offsetObj_bottom !== void 0 ? _offsetObj_bottom : defaultOffset
|
|
289
289
|
};
|
|
290
|
-
var _offsetObj_left, _offsetObj_right, _offsetObj_left1, _offsetObj_right1;
|
|
291
290
|
var sideProps = import_constants.isWeb ? xPosition === "left" ? {
|
|
292
291
|
left: "safe",
|
|
293
292
|
marginLeft: (_offsetObj_left = offsetObj.left) !== null && _offsetObj_left !== void 0 ? _offsetObj_left : defaultOffset
|
|
@@ -306,7 +305,7 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
306
305
|
} : null;
|
|
307
306
|
React.useEffect(function() {
|
|
308
307
|
if (!import_constants.isWeb) return;
|
|
309
|
-
var handleKeyDown = function(event) {
|
|
308
|
+
var handleKeyDown = function handleKeyDown2(event) {
|
|
310
309
|
var isHotkeyPressed = hotkey.length > 0 && hotkey.every(function(key) {
|
|
311
310
|
return event[key] || event.code === key;
|
|
312
311
|
});
|
|
@@ -334,7 +333,7 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
334
333
|
"data-y-position": yPosition,
|
|
335
334
|
"data-x-position": xPosition,
|
|
336
335
|
...import_constants.isWeb ? {
|
|
337
|
-
onMouseEnter: function() {
|
|
336
|
+
onMouseEnter: function onMouseEnter() {
|
|
338
337
|
mouseInsideRef.current = true;
|
|
339
338
|
if (deferredCollapseRef.current) {
|
|
340
339
|
clearTimeout(deferredCollapseRef.current);
|
|
@@ -346,7 +345,7 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
346
345
|
}, 50);
|
|
347
346
|
}
|
|
348
347
|
},
|
|
349
|
-
onMouseLeave: function() {
|
|
348
|
+
onMouseLeave: function onMouseLeave() {
|
|
350
349
|
mouseInsideRef.current = false;
|
|
351
350
|
if (hoverTimeoutRef.current) {
|
|
352
351
|
clearTimeout(hoverTimeoutRef.current);
|
|
@@ -366,20 +365,20 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
366
365
|
}, 1200);
|
|
367
366
|
}
|
|
368
367
|
},
|
|
369
|
-
onPointerDown: function() {
|
|
368
|
+
onPointerDown: function onPointerDown() {
|
|
370
369
|
if (hoverTimeoutRef.current) {
|
|
371
370
|
clearTimeout(hoverTimeoutRef.current);
|
|
372
371
|
hoverTimeoutRef.current = null;
|
|
373
372
|
}
|
|
374
373
|
ctx.setInteracting(true);
|
|
375
374
|
},
|
|
376
|
-
onPointerUp: function() {
|
|
375
|
+
onPointerUp: function onPointerUp() {
|
|
377
376
|
return ctx.setInteracting(false);
|
|
378
377
|
},
|
|
379
|
-
onPointerCancel: function() {
|
|
378
|
+
onPointerCancel: function onPointerCancel() {
|
|
380
379
|
return ctx.setInteracting(false);
|
|
381
380
|
}
|
|
382
|
-
} : { onPress: function() {
|
|
381
|
+
} : { onPress: function onPress() {
|
|
383
382
|
if (ctx.toasts.length > 1) {
|
|
384
383
|
ctx.setExpanded(function(prev) {
|
|
385
384
|
return !prev;
|
|
@@ -387,7 +386,7 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
387
386
|
}
|
|
388
387
|
} },
|
|
389
388
|
...import_constants.isWeb && {
|
|
390
|
-
onFocus: function(event) {
|
|
389
|
+
onFocus: function onFocus(event) {
|
|
391
390
|
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
392
391
|
if (ctx.toasts.length > 1) {
|
|
393
392
|
ctx.setExpanded(true);
|
|
@@ -395,7 +394,7 @@ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, functio
|
|
|
395
394
|
ctx.setInteracting(true);
|
|
396
395
|
}
|
|
397
396
|
},
|
|
398
|
-
onBlur: function(event) {
|
|
397
|
+
onBlur: function onBlur(event) {
|
|
399
398
|
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
400
399
|
ctx.setInteracting(false);
|
|
401
400
|
if (!ctx.isInDismissCooldown()) {
|
|
@@ -423,7 +422,7 @@ function ToastList(param) {
|
|
|
423
422
|
var ctx = useToastContext("Toast.List");
|
|
424
423
|
var maxRender = ctx.toasts.length;
|
|
425
424
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { children: ctx.toasts.slice(0, maxRender).map(function(toast, index) {
|
|
426
|
-
var handleClose = function() {
|
|
425
|
+
var handleClose = function handleClose2() {
|
|
427
426
|
var _toast_onDismiss;
|
|
428
427
|
if (toast.dismissible === false) return;
|
|
429
428
|
(_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
|
|
@@ -455,9 +454,9 @@ function ToastList(param) {
|
|
|
455
454
|
}
|
|
456
455
|
function DefaultToastContent(param) {
|
|
457
456
|
var { toast } = param;
|
|
457
|
+
var _toast_type;
|
|
458
458
|
var ctx = useToastContext("Toast.Item");
|
|
459
459
|
var { handleClose } = useToastItemContext();
|
|
460
|
-
var _toast_type;
|
|
461
460
|
var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
|
|
462
461
|
var dismissible = toast.dismissible !== false;
|
|
463
462
|
var title = typeof toast.title === "function" ? toast.title() : toast.title;
|
|
@@ -477,7 +476,7 @@ function DefaultToastContent(param) {
|
|
|
477
476
|
gap: "2",
|
|
478
477
|
marginTop: "2",
|
|
479
478
|
children: [toast.cancel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
|
|
480
|
-
onPress: function(e) {
|
|
479
|
+
onPress: function onPress(e) {
|
|
481
480
|
var _toast_cancel_onClick, _toast_cancel;
|
|
482
481
|
(_toast_cancel = toast.cancel) === null || _toast_cancel === void 0 ? void 0 : (_toast_cancel_onClick = _toast_cancel.onClick) === null || _toast_cancel_onClick === void 0 ? void 0 : _toast_cancel_onClick.call(_toast_cancel, e);
|
|
483
482
|
handleClose();
|
|
@@ -487,7 +486,7 @@ function DefaultToastContent(param) {
|
|
|
487
486
|
children: toast.cancel.label
|
|
488
487
|
})
|
|
489
488
|
}), toast.action && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
|
|
490
|
-
onPress: function(e) {
|
|
489
|
+
onPress: function onPress(e) {
|
|
491
490
|
var _toast_action_onClick, _toast_action;
|
|
492
491
|
(_toast_action = toast.action) === null || _toast_action === void 0 ? void 0 : (_toast_action_onClick = _toast_action.onClick) === null || _toast_action_onClick === void 0 ? void 0 : _toast_action_onClick.call(_toast_action, e);
|
|
493
492
|
if (!e.defaultPrevented) {
|
|
@@ -548,6 +547,7 @@ function DragWrapper(param) {
|
|
|
548
547
|
});
|
|
549
548
|
}
|
|
550
549
|
var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastItemFrame, function ToastItem(props, ref) {
|
|
550
|
+
var _toast_duration, _toast_type, _toast_duration1, _swipeExitYRef_current;
|
|
551
551
|
var { toast, index, children, ...rest } = props;
|
|
552
552
|
var ctx = useToastContext("Toast.Item");
|
|
553
553
|
var [mounted, setMounted] = React.useState(false);
|
|
@@ -558,14 +558,11 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
558
558
|
var closeTimerRef = React.useRef(null);
|
|
559
559
|
var closeTimerStartRef = React.useRef(0);
|
|
560
560
|
var lastPauseTimeRef = React.useRef(0);
|
|
561
|
-
var _toast_duration;
|
|
562
561
|
var remainingTimeRef = React.useRef((_toast_duration = toast.duration) !== null && _toast_duration !== void 0 ? _toast_duration : ctx.duration);
|
|
563
562
|
var isFront = index === 0;
|
|
564
563
|
var isVisible = index < ctx.visibleToasts;
|
|
565
|
-
var _toast_type;
|
|
566
564
|
var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
|
|
567
565
|
var dismissible = toast.dismissible !== false;
|
|
568
|
-
var _toast_duration1;
|
|
569
566
|
var duration = (_toast_duration1 = toast.duration) !== null && _toast_duration1 !== void 0 ? _toast_duration1 : ctx.duration;
|
|
570
567
|
var [yPosition] = ctx.position.split("-");
|
|
571
568
|
var isTop = yPosition === "top";
|
|
@@ -667,7 +664,7 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
667
664
|
expanded: ctx.expanded,
|
|
668
665
|
onDragStart: pauseTimer,
|
|
669
666
|
onDragMove: setDragOffset,
|
|
670
|
-
onDismiss: function(exitDirection, velocity) {
|
|
667
|
+
onDismiss: function onDismiss(exitDirection, velocity) {
|
|
671
668
|
var _toast_onDismiss;
|
|
672
669
|
ctx.triggerDismissCooldown();
|
|
673
670
|
setSwipeOut(true);
|
|
@@ -677,7 +674,7 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
677
674
|
ctx.removeToast(toast);
|
|
678
675
|
animateOut(exitDirection, velocity);
|
|
679
676
|
},
|
|
680
|
-
onCancel: function() {
|
|
677
|
+
onCancel: function onCancel() {
|
|
681
678
|
springBack(function() {
|
|
682
679
|
resumeTimer();
|
|
683
680
|
});
|
|
@@ -768,7 +765,6 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
768
765
|
"data-type": toastType,
|
|
769
766
|
"data-expanded": ctx.expanded ? "true" : "false"
|
|
770
767
|
};
|
|
771
|
-
var _swipeExitYRef_current;
|
|
772
768
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastPositionWrapper, {
|
|
773
769
|
ref,
|
|
774
770
|
testID: rest.testID,
|
|
@@ -799,7 +795,7 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
799
795
|
"aria-atomic": true,
|
|
800
796
|
tabIndex: 0,
|
|
801
797
|
onLayout: handleLayout,
|
|
802
|
-
...import_constants.isWeb && { onKeyDown: function(event) {
|
|
798
|
+
...import_constants.isWeb && { onKeyDown: function onKeyDown(event) {
|
|
803
799
|
if (event.key === "Escape" && dismissible) {
|
|
804
800
|
var current = event.currentTarget;
|
|
805
801
|
var container = current.closest("[aria-label]");
|
|
@@ -833,14 +829,14 @@ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.Toas
|
|
|
833
829
|
var ToastTitle = (0, import_core2.styled)(import_text.SizableText, { displayName: "ToastTitle" });
|
|
834
830
|
var ToastDescription = (0, import_core2.styled)(import_text.SizableText, { displayName: "ToastDescription" });
|
|
835
831
|
var ToastClose = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastCloseFrame, function ToastClose2(props, ref) {
|
|
832
|
+
var _ref, _props_children;
|
|
836
833
|
var _ctx_icons;
|
|
837
834
|
var handleClose;
|
|
838
835
|
try {
|
|
839
836
|
var itemCtx = useToastItemContext();
|
|
840
837
|
handleClose = itemCtx.handleClose;
|
|
841
|
-
} catch (
|
|
838
|
+
} catch (unused) {}
|
|
842
839
|
var ctx = useToastContext("Toast.Close");
|
|
843
|
-
var _props_children, _ref;
|
|
844
840
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastCloseFrame, {
|
|
845
841
|
ref,
|
|
846
842
|
"aria-label": "Close toast",
|
|
@@ -856,13 +852,14 @@ var ToastAction = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastAc
|
|
|
856
852
|
});
|
|
857
853
|
});
|
|
858
854
|
function ToastIcon(props) {
|
|
855
|
+
var _toast_type, _ref;
|
|
859
856
|
var _ctx_icons;
|
|
860
857
|
var ctx = useToastContext("Toast.Icon");
|
|
861
858
|
var toast;
|
|
862
859
|
try {
|
|
863
860
|
var itemCtx = useToastItemContext();
|
|
864
861
|
toast = itemCtx.toast;
|
|
865
|
-
} catch (
|
|
862
|
+
} catch (unused) {
|
|
866
863
|
return null;
|
|
867
864
|
}
|
|
868
865
|
if (!toast) return null;
|
|
@@ -873,10 +870,8 @@ function ToastIcon(props) {
|
|
|
873
870
|
children: toast.icon
|
|
874
871
|
});
|
|
875
872
|
}
|
|
876
|
-
var _toast_type;
|
|
877
873
|
var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
|
|
878
|
-
var
|
|
879
|
-
var icon = (_ctx_icons_toastType = (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons[toastType]) !== null && _ctx_icons_toastType !== void 0 ? _ctx_icons_toastType : null;
|
|
874
|
+
var icon = (_ref = (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons[toastType]) !== null && _ref !== void 0 ? _ref : null;
|
|
880
875
|
if (!icon) return null;
|
|
881
876
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
|
|
882
877
|
flexShrink: 0,
|