@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,292 @@
|
|
|
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 ToastImpl_exports = {};
|
|
33
|
+
__export(ToastImpl_exports, {
|
|
34
|
+
ToastImpl: () => ToastImpl,
|
|
35
|
+
ToastImplFrame: () => ToastImplFrame,
|
|
36
|
+
useToastInteractiveContext: () => useToastInteractiveContext
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(ToastImpl_exports);
|
|
39
|
+
var import_animate_presence = require("@tamagui/animate-presence"),
|
|
40
|
+
import_compose_refs = require("@tamagui/compose-refs"),
|
|
41
|
+
import_constants = require("@tamagui/constants"),
|
|
42
|
+
import_core = require("@tamagui/core"),
|
|
43
|
+
import_dismissable = require("@tamagui/dismissable"),
|
|
44
|
+
import_helpers = require("@tamagui/helpers"),
|
|
45
|
+
import_portal = require("@tamagui/portal"),
|
|
46
|
+
import_stacks = require("@tamagui/stacks"),
|
|
47
|
+
React = __toESM(require("react"), 1),
|
|
48
|
+
import_react_native = require("react-native-web"),
|
|
49
|
+
import_constants2 = require("./constants.cjs"),
|
|
50
|
+
import_ToastAnnounce = require("./ToastAnnounce.cjs"),
|
|
51
|
+
import_ToastProvider = require("./ToastProvider.cjs"),
|
|
52
|
+
import_ToastViewport = require("./ToastViewport.cjs"),
|
|
53
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
54
|
+
const ToastImplFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
55
|
+
name: "ToastImpl",
|
|
56
|
+
focusable: !0,
|
|
57
|
+
variants: {
|
|
58
|
+
unstyled: {
|
|
59
|
+
false: {
|
|
60
|
+
focusStyle: {
|
|
61
|
+
outlineStyle: "solid",
|
|
62
|
+
outlineWidth: 2,
|
|
63
|
+
outlineColor: "$outlineColor"
|
|
64
|
+
},
|
|
65
|
+
backgroundColor: "$color6",
|
|
66
|
+
borderRadius: "$4",
|
|
67
|
+
paddingHorizontal: "$4",
|
|
68
|
+
paddingVertical: "$3",
|
|
69
|
+
marginHorizontal: "auto",
|
|
70
|
+
marginVertical: "$1",
|
|
71
|
+
elevation: "$3"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
defaultVariants: {
|
|
76
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
{
|
|
80
|
+
Provider: ToastInteractiveProvider,
|
|
81
|
+
useStyledContext: useToastInteractiveContext
|
|
82
|
+
} = (0, import_core.createStyledContext)({
|
|
83
|
+
onClose() {}
|
|
84
|
+
}),
|
|
85
|
+
ToastImpl = React.forwardRef((props, forwardedRef) => {
|
|
86
|
+
const {
|
|
87
|
+
scope,
|
|
88
|
+
type = "foreground",
|
|
89
|
+
duration: durationProp,
|
|
90
|
+
open,
|
|
91
|
+
onClose,
|
|
92
|
+
onEscapeKeyDown,
|
|
93
|
+
onPause,
|
|
94
|
+
onResume,
|
|
95
|
+
onSwipeStart,
|
|
96
|
+
onSwipeMove,
|
|
97
|
+
onSwipeCancel,
|
|
98
|
+
onSwipeEnd,
|
|
99
|
+
viewportName = "default",
|
|
100
|
+
...toastProps
|
|
101
|
+
} = props,
|
|
102
|
+
isPresent = (0, import_animate_presence.useIsPresent)(),
|
|
103
|
+
context = (0, import_ToastProvider.useToastProviderContext)(scope),
|
|
104
|
+
[node, setNode] = React.useState(null),
|
|
105
|
+
composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, setNode),
|
|
106
|
+
duration = durationProp || context.duration,
|
|
107
|
+
closeTimerStartTimeRef = React.useRef(0),
|
|
108
|
+
closeTimerRemainingTimeRef = React.useRef(duration),
|
|
109
|
+
closeTimerRef = React.useRef(0),
|
|
110
|
+
{
|
|
111
|
+
onToastAdd,
|
|
112
|
+
onToastRemove
|
|
113
|
+
} = context,
|
|
114
|
+
viewport = React.useMemo(() => context.viewports[viewportName], [context.viewports, viewportName]),
|
|
115
|
+
handleClose = (0, import_core.useEvent)(() => {
|
|
116
|
+
isPresent && (import_constants.isWeb && node?.contains(document.activeElement) && viewport?.focus(), onClose());
|
|
117
|
+
}),
|
|
118
|
+
startTimer = React.useCallback(duration2 => {
|
|
119
|
+
!duration2 || duration2 === Number.POSITIVE_INFINITY || (clearTimeout(closeTimerRef.current), closeTimerStartTimeRef.current = (/* @__PURE__ */new Date()).getTime(), closeTimerRef.current = setTimeout(handleClose, duration2));
|
|
120
|
+
}, [handleClose]),
|
|
121
|
+
handleResume = React.useCallback(() => {
|
|
122
|
+
startTimer(closeTimerRemainingTimeRef.current), onResume?.();
|
|
123
|
+
}, [onResume, startTimer]),
|
|
124
|
+
handlePause = React.useCallback(() => {
|
|
125
|
+
const elapsedTime = (/* @__PURE__ */new Date()).getTime() - closeTimerStartTimeRef.current;
|
|
126
|
+
closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime, window.clearTimeout(closeTimerRef.current), onPause?.();
|
|
127
|
+
}, [onPause]);
|
|
128
|
+
React.useEffect(() => {
|
|
129
|
+
if (import_constants.isWeb && viewport) return viewport.addEventListener(import_ToastViewport.VIEWPORT_PAUSE, handlePause), viewport.addEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume), () => {
|
|
130
|
+
viewport.removeEventListener(import_ToastViewport.VIEWPORT_PAUSE, handlePause), viewport.removeEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume);
|
|
131
|
+
};
|
|
132
|
+
}, [viewport, duration, onPause, onResume, startTimer]), React.useEffect(() => {
|
|
133
|
+
open && !context.isClosePausedRef.current && startTimer(duration);
|
|
134
|
+
}, [open, duration, context.isClosePausedRef, startTimer]), React.useEffect(() => (onToastAdd(), () => onToastRemove()), [onToastAdd, onToastRemove]);
|
|
135
|
+
const announceTextContent = React.useMemo(() => import_constants.isWeb && node ? getAnnounceTextContent(node) : null, [node]),
|
|
136
|
+
isHorizontalSwipe = ["left", "right", "horizontal"].includes(context.swipeDirection),
|
|
137
|
+
{
|
|
138
|
+
animationDriver
|
|
139
|
+
} = (0, import_core.useConfiguration)();
|
|
140
|
+
if (!animationDriver) throw new Error("Must set animations in tamagui.config.ts");
|
|
141
|
+
const {
|
|
142
|
+
useAnimatedNumber,
|
|
143
|
+
useAnimatedNumberStyle
|
|
144
|
+
} = animationDriver,
|
|
145
|
+
animatedNumber = useAnimatedNumber(0),
|
|
146
|
+
AnimatedView = animationDriver.NumberView ?? animationDriver.View ?? import_core.View,
|
|
147
|
+
animatedStyles = useAnimatedNumberStyle(animatedNumber, val => {
|
|
148
|
+
"worklet";
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
transform: [isHorizontalSwipe ? {
|
|
152
|
+
translateX: val
|
|
153
|
+
} : {
|
|
154
|
+
translateY: val
|
|
155
|
+
}]
|
|
156
|
+
};
|
|
157
|
+
}),
|
|
158
|
+
panResponder = React.useMemo(() => import_react_native.PanResponder.create({
|
|
159
|
+
onMoveShouldSetPanResponder: (e, gesture) => shouldGrantGestureMove(context.swipeDirection, gesture) ? (onSwipeStart?.(e), !0) : !1,
|
|
160
|
+
onPanResponderGrant: e => {
|
|
161
|
+
import_constants.isWeb || handlePause?.();
|
|
162
|
+
},
|
|
163
|
+
onPanResponderMove: (e, gesture) => {
|
|
164
|
+
const {
|
|
165
|
+
x,
|
|
166
|
+
y
|
|
167
|
+
} = getGestureDistance(context.swipeDirection, gesture),
|
|
168
|
+
delta = {
|
|
169
|
+
x,
|
|
170
|
+
y
|
|
171
|
+
};
|
|
172
|
+
animatedNumber.setValue(isHorizontalSwipe ? x : y, {
|
|
173
|
+
type: "direct"
|
|
174
|
+
}), isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold) && onSwipeEnd?.(e), onSwipeMove?.(e);
|
|
175
|
+
},
|
|
176
|
+
onPanResponderEnd: (e, {
|
|
177
|
+
dx,
|
|
178
|
+
dy
|
|
179
|
+
}) => {
|
|
180
|
+
isDeltaInDirection({
|
|
181
|
+
x: dx,
|
|
182
|
+
y: dy
|
|
183
|
+
}, context.swipeDirection, context.swipeThreshold) || (import_constants.isWeb || handleResume?.(), onSwipeCancel?.(e), animatedNumber.setValue(0, {
|
|
184
|
+
type: "spring"
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
}), [handlePause, handleResume]),
|
|
188
|
+
themeName = (0, import_core.useThemeName)();
|
|
189
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
190
|
+
children: [announceTextContent && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastAnnounce.ToastAnnounce, {
|
|
191
|
+
scope,
|
|
192
|
+
role: "status",
|
|
193
|
+
"aria-live": type === "foreground" ? "assertive" : "polite",
|
|
194
|
+
"aria-atomic": !0,
|
|
195
|
+
children: announceTextContent
|
|
196
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.PortalItem, {
|
|
197
|
+
hostName: viewportName ?? "default",
|
|
198
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastInteractiveProvider, {
|
|
199
|
+
scope,
|
|
200
|
+
onClose: () => {
|
|
201
|
+
handleClose();
|
|
202
|
+
},
|
|
203
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dismissable.Dismissable, {
|
|
204
|
+
onEscapeKeyDown: (0, import_helpers.composeEventHandlers)(onEscapeKeyDown, () => {
|
|
205
|
+
context.isFocusedToastEscapeKeyDownRef.current || handleClose(), context.isFocusedToastEscapeKeyDownRef.current = !1;
|
|
206
|
+
}),
|
|
207
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Theme, {
|
|
208
|
+
contain: !0,
|
|
209
|
+
forceClassName: !0,
|
|
210
|
+
name: themeName,
|
|
211
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AnimatedView, {
|
|
212
|
+
...panResponder?.panHandlers,
|
|
213
|
+
style: [{
|
|
214
|
+
margin: "auto"
|
|
215
|
+
}, animatedStyles],
|
|
216
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.ItemSlot, {
|
|
217
|
+
scope: context.toastScope,
|
|
218
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastImplFrame, {
|
|
219
|
+
role: "status",
|
|
220
|
+
"aria-live": "off",
|
|
221
|
+
"aria-atomic": !0,
|
|
222
|
+
"data-state": open ? "open" : "closed",
|
|
223
|
+
"data-swipe-direction": context.swipeDirection,
|
|
224
|
+
pointerEvents: "auto",
|
|
225
|
+
"$platform-web": {
|
|
226
|
+
touchAction: "none",
|
|
227
|
+
userSelect: "none"
|
|
228
|
+
},
|
|
229
|
+
...toastProps,
|
|
230
|
+
ref: composedRefs,
|
|
231
|
+
...(import_constants.isWeb && {
|
|
232
|
+
onKeyDown: (0, import_helpers.composeEventHandlers)(props.onKeyDown, event => {
|
|
233
|
+
event.key === "Escape" && (onEscapeKeyDown?.(event), event.defaultPrevented || (context.isFocusedToastEscapeKeyDownRef.current = !0, handleClose()));
|
|
234
|
+
})
|
|
235
|
+
})
|
|
236
|
+
})
|
|
237
|
+
})
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
})
|
|
241
|
+
}, props.id)
|
|
242
|
+
})]
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
ToastImpl.propTypes = {
|
|
246
|
+
type(props) {
|
|
247
|
+
if (props.type && !["foreground", "background"].includes(props.type)) {
|
|
248
|
+
const error = `Invalid prop \`type\` supplied to \`${import_constants2.TOAST_NAME}\`. Expected \`foreground | background\`.`;
|
|
249
|
+
return new Error(error);
|
|
250
|
+
}
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
const isDeltaInDirection = (delta, direction, threshold = 0) => {
|
|
255
|
+
const deltaX = Math.abs(delta.x),
|
|
256
|
+
deltaY = Math.abs(delta.y),
|
|
257
|
+
isDeltaX = deltaX > deltaY;
|
|
258
|
+
return direction === "left" || direction === "right" || direction === "horizontal" ? isDeltaX && deltaX > threshold : !isDeltaX && deltaY > threshold;
|
|
259
|
+
};
|
|
260
|
+
function getAnnounceTextContent(container) {
|
|
261
|
+
if (!import_constants.isWeb) return "";
|
|
262
|
+
const textContent = [];
|
|
263
|
+
return Array.from(container.childNodes).forEach(node => {
|
|
264
|
+
if (node.nodeType === node.TEXT_NODE && node.textContent && textContent.push(node.textContent), isHTMLElement(node)) {
|
|
265
|
+
const isHidden = node.ariaHidden || node.hidden || node.style.display === "none",
|
|
266
|
+
isExcluded = node.dataset.toastAnnounceExclude === "";
|
|
267
|
+
if (!isHidden) if (isExcluded) {
|
|
268
|
+
const altText = node.dataset.toastAnnounceAlt;
|
|
269
|
+
altText && textContent.push(altText);
|
|
270
|
+
} else textContent.push(...getAnnounceTextContent(node));
|
|
271
|
+
}
|
|
272
|
+
}), textContent;
|
|
273
|
+
}
|
|
274
|
+
function isHTMLElement(node) {
|
|
275
|
+
return node.nodeType === node.ELEMENT_NODE;
|
|
276
|
+
}
|
|
277
|
+
const GESTURE_GRANT_THRESHOLD = 10,
|
|
278
|
+
shouldGrantGestureMove = (dir, {
|
|
279
|
+
dx,
|
|
280
|
+
dy
|
|
281
|
+
}) => (dir === "horizontal" || dir === "left") && dx < -GESTURE_GRANT_THRESHOLD || (dir === "horizontal" || dir === "right") && dx > GESTURE_GRANT_THRESHOLD || (dir === "vertical" || dir === "up") && dy > -GESTURE_GRANT_THRESHOLD || (dir === "vertical" || dir === "down") && dy < GESTURE_GRANT_THRESHOLD,
|
|
282
|
+
getGestureDistance = (dir, {
|
|
283
|
+
dx,
|
|
284
|
+
dy
|
|
285
|
+
}) => {
|
|
286
|
+
let y = 0,
|
|
287
|
+
x = 0;
|
|
288
|
+
return dir === "horizontal" ? x = dx : dir === "left" ? x = Math.min(0, dx) : dir === "right" ? x = Math.max(0, dx) : dir === "vertical" ? y = dy : dir === "up" ? y = Math.min(0, dy) : dir === "down" && (y = Math.max(0, dy)), {
|
|
289
|
+
x,
|
|
290
|
+
y
|
|
291
|
+
};
|
|
292
|
+
};
|
|
@@ -0,0 +1,227 @@
|
|
|
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, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
+
mod
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
+
var ToastImpl_exports = {};
|
|
24
|
+
__export(ToastImpl_exports, {
|
|
25
|
+
ToastImpl: () => ToastImpl,
|
|
26
|
+
ToastImplFrame: () => ToastImplFrame,
|
|
27
|
+
useToastInteractiveContext: () => useToastInteractiveContext
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(ToastImpl_exports);
|
|
30
|
+
var import_animate_presence = require("@tamagui/animate-presence"), import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_dismissable = require("@tamagui/dismissable"), import_helpers = require("@tamagui/helpers"), import_portal = require("@tamagui/portal"), import_stacks = require("@tamagui/stacks"), React = __toESM(require("react"), 1), import_react_native = require("react-native-web"), import_constants2 = require("./constants"), import_ToastAnnounce = require("./ToastAnnounce"), import_ToastProvider = require("./ToastProvider"), import_ToastViewport = require("./ToastViewport"), import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
const ToastImplFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
32
|
+
name: "ToastImpl",
|
|
33
|
+
focusable: !0,
|
|
34
|
+
variants: {
|
|
35
|
+
unstyled: {
|
|
36
|
+
false: {
|
|
37
|
+
focusStyle: {
|
|
38
|
+
outlineStyle: "solid",
|
|
39
|
+
outlineWidth: 2,
|
|
40
|
+
outlineColor: "$outlineColor"
|
|
41
|
+
},
|
|
42
|
+
backgroundColor: "$color6",
|
|
43
|
+
borderRadius: "$4",
|
|
44
|
+
paddingHorizontal: "$4",
|
|
45
|
+
paddingVertical: "$3",
|
|
46
|
+
marginHorizontal: "auto",
|
|
47
|
+
marginVertical: "$1",
|
|
48
|
+
elevation: "$3"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
defaultVariants: {
|
|
53
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
54
|
+
}
|
|
55
|
+
}), {
|
|
56
|
+
Provider: ToastInteractiveProvider,
|
|
57
|
+
useStyledContext: useToastInteractiveContext
|
|
58
|
+
} = (0, import_core.createStyledContext)({
|
|
59
|
+
onClose() {
|
|
60
|
+
}
|
|
61
|
+
}), ToastImpl = React.forwardRef(
|
|
62
|
+
(props, forwardedRef) => {
|
|
63
|
+
const {
|
|
64
|
+
scope,
|
|
65
|
+
type = "foreground",
|
|
66
|
+
duration: durationProp,
|
|
67
|
+
open,
|
|
68
|
+
onClose,
|
|
69
|
+
onEscapeKeyDown,
|
|
70
|
+
onPause,
|
|
71
|
+
onResume,
|
|
72
|
+
onSwipeStart,
|
|
73
|
+
onSwipeMove,
|
|
74
|
+
onSwipeCancel,
|
|
75
|
+
onSwipeEnd,
|
|
76
|
+
viewportName = "default",
|
|
77
|
+
...toastProps
|
|
78
|
+
} = props, isPresent = (0, import_animate_presence.useIsPresent)(), context = (0, import_ToastProvider.useToastProviderContext)(scope), [node, setNode] = React.useState(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, setNode), duration = durationProp || context.duration, closeTimerStartTimeRef = React.useRef(0), closeTimerRemainingTimeRef = React.useRef(duration), closeTimerRef = React.useRef(0), { onToastAdd, onToastRemove } = context, viewport = React.useMemo(() => context.viewports[viewportName], [context.viewports, viewportName]), handleClose = (0, import_core.useEvent)(() => {
|
|
79
|
+
isPresent && (import_constants.isWeb && node?.contains(
|
|
80
|
+
document.activeElement
|
|
81
|
+
) && viewport?.focus(), onClose());
|
|
82
|
+
}), startTimer = React.useCallback(
|
|
83
|
+
(duration2) => {
|
|
84
|
+
!duration2 || duration2 === Number.POSITIVE_INFINITY || (clearTimeout(closeTimerRef.current), closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime(), closeTimerRef.current = setTimeout(handleClose, duration2));
|
|
85
|
+
},
|
|
86
|
+
[handleClose]
|
|
87
|
+
), handleResume = React.useCallback(() => {
|
|
88
|
+
startTimer(closeTimerRemainingTimeRef.current), onResume?.();
|
|
89
|
+
}, [onResume, startTimer]), handlePause = React.useCallback(() => {
|
|
90
|
+
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
|
|
91
|
+
closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime, window.clearTimeout(closeTimerRef.current), onPause?.();
|
|
92
|
+
}, [onPause]);
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
if (import_constants.isWeb && viewport)
|
|
95
|
+
return viewport.addEventListener(import_ToastViewport.VIEWPORT_PAUSE, handlePause), viewport.addEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume), () => {
|
|
96
|
+
viewport.removeEventListener(import_ToastViewport.VIEWPORT_PAUSE, handlePause), viewport.removeEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume);
|
|
97
|
+
};
|
|
98
|
+
}, [viewport, duration, onPause, onResume, startTimer]), React.useEffect(() => {
|
|
99
|
+
open && !context.isClosePausedRef.current && startTimer(duration);
|
|
100
|
+
}, [open, duration, context.isClosePausedRef, startTimer]), React.useEffect(() => (onToastAdd(), () => onToastRemove()), [onToastAdd, onToastRemove]);
|
|
101
|
+
const announceTextContent = React.useMemo(() => import_constants.isWeb && node ? getAnnounceTextContent(node) : null, [node]), isHorizontalSwipe = ["left", "right", "horizontal"].includes(
|
|
102
|
+
context.swipeDirection
|
|
103
|
+
), { animationDriver } = (0, import_core.useConfiguration)();
|
|
104
|
+
if (!animationDriver)
|
|
105
|
+
throw new Error("Must set animations in tamagui.config.ts");
|
|
106
|
+
const { useAnimatedNumber, useAnimatedNumberStyle } = animationDriver, animatedNumber = useAnimatedNumber(0), AnimatedView = animationDriver.NumberView ?? animationDriver.View ?? import_core.View, animatedStyles = useAnimatedNumberStyle(animatedNumber, (val) => {
|
|
107
|
+
"worklet";
|
|
108
|
+
return {
|
|
109
|
+
transform: [isHorizontalSwipe ? { translateX: val } : { translateY: val }]
|
|
110
|
+
};
|
|
111
|
+
}), panResponder = React.useMemo(() => import_react_native.PanResponder.create({
|
|
112
|
+
onMoveShouldSetPanResponder: (e, gesture) => shouldGrantGestureMove(context.swipeDirection, gesture) ? (onSwipeStart?.(e), !0) : !1,
|
|
113
|
+
onPanResponderGrant: (e) => {
|
|
114
|
+
import_constants.isWeb || handlePause?.();
|
|
115
|
+
},
|
|
116
|
+
onPanResponderMove: (e, gesture) => {
|
|
117
|
+
const { x, y } = getGestureDistance(context.swipeDirection, gesture), delta = { x, y };
|
|
118
|
+
animatedNumber.setValue(isHorizontalSwipe ? x : y, { type: "direct" }), isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold) && onSwipeEnd?.(e), onSwipeMove?.(e);
|
|
119
|
+
},
|
|
120
|
+
onPanResponderEnd: (e, { dx, dy }) => {
|
|
121
|
+
isDeltaInDirection(
|
|
122
|
+
{ x: dx, y: dy },
|
|
123
|
+
context.swipeDirection,
|
|
124
|
+
context.swipeThreshold
|
|
125
|
+
) || (import_constants.isWeb || handleResume?.(), onSwipeCancel?.(e), animatedNumber.setValue(0, { type: "spring" }));
|
|
126
|
+
}
|
|
127
|
+
}), [handlePause, handleResume]), themeName = (0, import_core.useThemeName)();
|
|
128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
129
|
+
announceTextContent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
130
|
+
import_ToastAnnounce.ToastAnnounce,
|
|
131
|
+
{
|
|
132
|
+
scope,
|
|
133
|
+
role: "status",
|
|
134
|
+
"aria-live": type === "foreground" ? "assertive" : "polite",
|
|
135
|
+
"aria-atomic": !0,
|
|
136
|
+
children: announceTextContent
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, { hostName: viewportName ?? "default", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
140
|
+
ToastInteractiveProvider,
|
|
141
|
+
{
|
|
142
|
+
scope,
|
|
143
|
+
onClose: () => {
|
|
144
|
+
handleClose();
|
|
145
|
+
},
|
|
146
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
147
|
+
import_dismissable.Dismissable,
|
|
148
|
+
{
|
|
149
|
+
onEscapeKeyDown: (0, import_helpers.composeEventHandlers)(onEscapeKeyDown, () => {
|
|
150
|
+
context.isFocusedToastEscapeKeyDownRef.current || handleClose(), context.isFocusedToastEscapeKeyDownRef.current = !1;
|
|
151
|
+
}),
|
|
152
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { contain: !0, forceClassName: !0, name: themeName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
153
|
+
AnimatedView,
|
|
154
|
+
{
|
|
155
|
+
...panResponder?.panHandlers,
|
|
156
|
+
style: [{ margin: "auto" }, animatedStyles],
|
|
157
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.ItemSlot, { scope: context.toastScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
158
|
+
ToastImplFrame,
|
|
159
|
+
{
|
|
160
|
+
role: "status",
|
|
161
|
+
"aria-live": "off",
|
|
162
|
+
"aria-atomic": !0,
|
|
163
|
+
"data-state": open ? "open" : "closed",
|
|
164
|
+
"data-swipe-direction": context.swipeDirection,
|
|
165
|
+
pointerEvents: "auto",
|
|
166
|
+
"$platform-web": {
|
|
167
|
+
touchAction: "none",
|
|
168
|
+
userSelect: "none"
|
|
169
|
+
},
|
|
170
|
+
...toastProps,
|
|
171
|
+
ref: composedRefs,
|
|
172
|
+
...import_constants.isWeb && {
|
|
173
|
+
onKeyDown: (0, import_helpers.composeEventHandlers)(props.onKeyDown, (event) => {
|
|
174
|
+
event.key === "Escape" && (onEscapeKeyDown?.(event), event.defaultPrevented || (context.isFocusedToastEscapeKeyDownRef.current = !0, handleClose()));
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
) })
|
|
179
|
+
}
|
|
180
|
+
) })
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
},
|
|
184
|
+
props.id
|
|
185
|
+
) })
|
|
186
|
+
] });
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
ToastImpl.propTypes = {
|
|
190
|
+
type(props) {
|
|
191
|
+
if (props.type && !["foreground", "background"].includes(props.type)) {
|
|
192
|
+
const error = `Invalid prop \`type\` supplied to \`${import_constants2.TOAST_NAME}\`. Expected \`foreground | background\`.`;
|
|
193
|
+
return new Error(error);
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const isDeltaInDirection = (delta, direction, threshold = 0) => {
|
|
199
|
+
const deltaX = Math.abs(delta.x), deltaY = Math.abs(delta.y), isDeltaX = deltaX > deltaY;
|
|
200
|
+
return direction === "left" || direction === "right" || direction === "horizontal" ? isDeltaX && deltaX > threshold : !isDeltaX && deltaY > threshold;
|
|
201
|
+
};
|
|
202
|
+
function getAnnounceTextContent(container) {
|
|
203
|
+
if (!import_constants.isWeb) return "";
|
|
204
|
+
const textContent = [];
|
|
205
|
+
return Array.from(container.childNodes).forEach((node) => {
|
|
206
|
+
if (node.nodeType === node.TEXT_NODE && node.textContent && textContent.push(node.textContent), isHTMLElement(node)) {
|
|
207
|
+
const isHidden = node.ariaHidden || node.hidden || node.style.display === "none", isExcluded = node.dataset.toastAnnounceExclude === "";
|
|
208
|
+
if (!isHidden)
|
|
209
|
+
if (isExcluded) {
|
|
210
|
+
const altText = node.dataset.toastAnnounceAlt;
|
|
211
|
+
altText && textContent.push(altText);
|
|
212
|
+
} else
|
|
213
|
+
textContent.push(...getAnnounceTextContent(node));
|
|
214
|
+
}
|
|
215
|
+
}), textContent;
|
|
216
|
+
}
|
|
217
|
+
function isHTMLElement(node) {
|
|
218
|
+
return node.nodeType === node.ELEMENT_NODE;
|
|
219
|
+
}
|
|
220
|
+
const GESTURE_GRANT_THRESHOLD = 10, shouldGrantGestureMove = (dir, { dx, dy }) => (dir === "horizontal" || dir === "left") && dx < -GESTURE_GRANT_THRESHOLD || (dir === "horizontal" || dir === "right") && dx > GESTURE_GRANT_THRESHOLD || (dir === "vertical" || dir === "up") && dy > -GESTURE_GRANT_THRESHOLD || (dir === "vertical" || dir === "down") && dy < GESTURE_GRANT_THRESHOLD, getGestureDistance = (dir, { dx, dy }) => {
|
|
221
|
+
let y = 0, x = 0;
|
|
222
|
+
return dir === "horizontal" ? x = dx : dir === "left" ? x = Math.min(0, dx) : dir === "right" ? x = Math.max(0, dx) : dir === "vertical" ? y = dy : dir === "up" ? y = Math.min(0, dy) : dir === "down" && (y = Math.max(0, dy)), {
|
|
223
|
+
x,
|
|
224
|
+
y
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
//# sourceMappingURL=ToastImpl.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ToastImpl.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA6B,sCAC7B,sBAAgC,kCAChC,mBAAsB,+BAEtB,cAQO,0BAEP,qBAA4B,iCAC5B,iBAAqC,6BACrC,gBAA2B,4BAC3B,gBAAuB,4BACvB,QAAuB,8BAMvB,sBAA6B,yBAC7BA,oBAA0C,wBAC1C,uBAA8B,4BAE9B,uBAAoD,4BACpD,uBAAgD,4BA2S1C;AAzSN,MAAM,qBAAiB,oBAAO,sBAAQ;AAAA,EACpC,MAAM;AAAA,EACN,WAAW;AAAA,EAEX,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,YAAY;AAAA,UACV,cAAc;AAAA,UACd,cAAc;AAAA,UACd,cAAc;AAAA,QAChB;AAAA,QACA,iBAAiB;AAAA,QACjB,cAAc;AAAA,QACd,mBAAmB;AAAA,QACnB,iBAAiB;AAAA,QACjB,kBAAkB;AAAA,QAClB,gBAAgB;AAAA,QAChB,WAAW;AAAA,MACb;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU,QAAQ,IAAI,qBAAqB;AAAA,EAC7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