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