@tamagui/toast 1.61.2 → 1.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Toast.js +26 -61
- package/dist/cjs/Toast.js.map +1 -1
- package/dist/cjs/Toast.native.js +141 -0
- package/dist/cjs/Toast.native.js.map +6 -0
- package/dist/cjs/ToastAnnounce.js +18 -40
- package/dist/cjs/ToastAnnounce.js.map +1 -1
- package/dist/cjs/ToastAnnounce.native.js +74 -0
- package/dist/cjs/ToastAnnounce.native.js.map +6 -0
- package/dist/cjs/ToastImperative.js +27 -65
- package/dist/cjs/ToastImperative.js.map +1 -1
- package/dist/cjs/ToastImperative.native.js +74 -0
- package/dist/cjs/ToastImperative.native.js.map +6 -0
- package/dist/cjs/ToastImpl.js +65 -213
- package/dist/cjs/ToastImpl.js.map +1 -1
- package/dist/cjs/ToastImpl.native.js +232 -0
- package/dist/cjs/ToastImpl.native.js.map +6 -0
- package/dist/cjs/ToastProvider.js +18 -41
- package/dist/cjs/ToastProvider.js.map +1 -1
- package/dist/cjs/ToastProvider.native.js +103 -0
- package/dist/cjs/ToastProvider.native.js.map +6 -0
- package/dist/cjs/ToastViewport.js +59 -150
- package/dist/cjs/ToastViewport.js.map +1 -1
- package/dist/cjs/ToastViewport.native.js +260 -0
- package/dist/cjs/ToastViewport.native.js.map +6 -0
- package/dist/cjs/constants.js +5 -9
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/constants.native.js +26 -0
- package/dist/cjs/constants.native.js.map +6 -0
- package/dist/cjs/createNativeToast.js +22 -43
- package/dist/cjs/createNativeToast.js.map +1 -1
- package/dist/cjs/createNativeToast.native.js +12 -21
- package/dist/cjs/createNativeToast.native.js.map +1 -1
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +20 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/cjs/types.js +3 -6
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/types.native.js +15 -0
- package/dist/cjs/types.native.js.map +6 -0
- package/dist/esm/Toast.js +19 -37
- package/dist/esm/Toast.js.map +1 -1
- package/dist/esm/ToastAnnounce.js +11 -21
- package/dist/esm/ToastAnnounce.js.map +1 -1
- package/dist/esm/ToastImperative.js +20 -48
- package/dist/esm/ToastImperative.js.map +1 -1
- package/dist/esm/ToastImpl.js +58 -188
- package/dist/esm/ToastImpl.js.map +1 -1
- package/dist/esm/ToastProvider.js +11 -24
- package/dist/esm/ToastProvider.js.map +1 -1
- package/dist/esm/ToastViewport.js +52 -129
- package/dist/esm/ToastViewport.js.map +1 -1
- package/dist/esm/createNativeToast.js +17 -34
- package/dist/esm/createNativeToast.js.map +1 -1
- package/dist/jsx/Toast.js +17 -35
- package/dist/jsx/Toast.js.map +1 -1
- package/dist/jsx/Toast.native.js +127 -0
- package/dist/jsx/Toast.native.js.map +6 -0
- package/dist/jsx/ToastAnnounce.js +10 -20
- package/dist/jsx/ToastAnnounce.js.map +1 -1
- package/dist/jsx/ToastAnnounce.native.js +52 -0
- package/dist/jsx/ToastAnnounce.native.js.map +6 -0
- package/dist/jsx/ToastImperative.js +17 -45
- package/dist/jsx/ToastImperative.js.map +1 -1
- package/dist/jsx/ToastImperative.native.js +45 -0
- package/dist/jsx/ToastImperative.native.js.map +6 -0
- package/dist/jsx/ToastImpl.js +53 -183
- package/dist/jsx/ToastImpl.js.map +1 -1
- package/dist/jsx/ToastImpl.native.js +207 -0
- package/dist/jsx/ToastImpl.native.js.map +6 -0
- package/dist/jsx/ToastProvider.js +10 -23
- package/dist/jsx/ToastProvider.js.map +1 -1
- package/dist/jsx/ToastProvider.native.js +68 -0
- package/dist/jsx/ToastProvider.native.js.map +6 -0
- package/dist/jsx/ToastViewport.js +49 -124
- package/dist/jsx/ToastViewport.js.map +1 -1
- package/dist/jsx/ToastViewport.native.js +225 -0
- package/dist/jsx/ToastViewport.native.js.map +6 -0
- package/dist/jsx/constants.native.js +5 -0
- package/dist/jsx/constants.native.js.map +6 -0
- package/dist/jsx/createNativeToast.js +17 -34
- package/dist/jsx/createNativeToast.js.map +1 -1
- package/dist/jsx/createNativeToast.native.js +7 -13
- package/dist/jsx/createNativeToast.native.js.map +1 -1
- package/dist/jsx/index.native.js +2 -0
- package/dist/jsx/index.native.js.map +6 -0
- package/dist/jsx/types.native.js +1 -0
- package/dist/jsx/types.native.js.map +6 -0
- package/package.json +13 -13
- package/dist/esm/createNativeToast.native.js +0 -19
- package/dist/esm/createNativeToast.native.js.map +0 -6
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
14
11
|
for (let key of __getOwnPropNames(from))
|
|
15
|
-
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
13
|
return to;
|
|
19
14
|
};
|
|
20
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
@@ -22,10 +17,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
17
|
// file that has been converted to a CommonJS file using a Babel-
|
|
23
18
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
19
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
26
21
|
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
29
23
|
var ToastImperative_exports = {};
|
|
30
24
|
__export(ToastImperative_exports, {
|
|
31
25
|
ToastImperativeProvider: () => ToastImperativeProvider,
|
|
@@ -34,71 +28,39 @@ __export(ToastImperative_exports, {
|
|
|
34
28
|
useToastState: () => useToastState
|
|
35
29
|
});
|
|
36
30
|
module.exports = __toCommonJS(ToastImperative_exports);
|
|
37
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const ToastContext = (0, import_react.createContext)({});
|
|
43
|
-
const ToastCurrentContext = (0, import_react.createContext)(null);
|
|
44
|
-
const useToastController = () => {
|
|
45
|
-
return (0, import_react.useContext)(ToastContext);
|
|
46
|
-
};
|
|
47
|
-
const useToastState = () => {
|
|
48
|
-
return (0, import_react.useContext)(ToastCurrentContext);
|
|
49
|
-
};
|
|
50
|
-
const useToast = () => {
|
|
51
|
-
return {
|
|
52
|
-
...useToastController(),
|
|
53
|
-
currentToast: useToastState()
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
const ToastImperativeProvider = ({
|
|
31
|
+
var import_core = require("@tamagui/core"), import_react = __toESM(require("react")), import_react_native = require("react-native"), import_createNativeToast = require("./createNativeToast"), import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
const ToastContext = (0, import_react.createContext)({}), ToastCurrentContext = (0, import_react.createContext)(null), useToastController = () => (0, import_react.useContext)(ToastContext), useToastState = () => (0, import_react.useContext)(ToastCurrentContext), useToast = () => ({
|
|
33
|
+
...useToastController(),
|
|
34
|
+
currentToast: useToastState()
|
|
35
|
+
}), ToastImperativeProvider = ({
|
|
57
36
|
children,
|
|
58
37
|
options
|
|
59
38
|
}) => {
|
|
60
|
-
const counterRef = (0, import_react.useRef)(0)
|
|
61
|
-
const [toast, setToast] = import_react.default.useState(null);
|
|
62
|
-
const [lastNativeToastRef, setLastNativeToastRef] = import_react.default.useState(null);
|
|
63
|
-
const show = import_react.default.useCallback(
|
|
39
|
+
const counterRef = (0, import_react.useRef)(0), [toast, setToast] = import_react.default.useState(null), [lastNativeToastRef, setLastNativeToastRef] = import_react.default.useState(null), show = import_react.default.useCallback(
|
|
64
40
|
(title, showOptions) => {
|
|
65
|
-
const native =
|
|
66
|
-
const isWebNative = Array.isArray(native) ? native.includes("web") : native === "web";
|
|
67
|
-
const isMobileNative = Array.isArray(native) ? native.includes("mobile") : native === "mobile";
|
|
68
|
-
const isAndroidNative = isMobileNative || (Array.isArray(native) ? native.includes("android") : native === "android");
|
|
69
|
-
const isIosNative = isMobileNative || (Array.isArray(native) ? native.includes("ios") : native === "ios");
|
|
70
|
-
const isHandledNatively = native === true || import_core.isWeb && isWebNative || !import_core.isWeb && isMobileNative || import_react_native.Platform.OS === "android" && isAndroidNative || import_react_native.Platform.OS === "ios" && isIosNative;
|
|
41
|
+
const native = showOptions?.native ?? options.native, isWebNative = Array.isArray(native) ? native.includes("web") : native === "web", isMobileNative = Array.isArray(native) ? native.includes("mobile") : native === "mobile", isAndroidNative = isMobileNative || (Array.isArray(native) ? native.includes("android") : native === "android"), isIosNative = isMobileNative || (Array.isArray(native) ? native.includes("ios") : native === "ios"), isHandledNatively = native === !0 || import_core.isWeb && isWebNative || !import_core.isWeb && isMobileNative || import_react_native.Platform.OS === "android" && isAndroidNative || import_react_native.Platform.OS === "ios" && isIosNative;
|
|
71
42
|
if (isHandledNatively) {
|
|
72
43
|
const nativeToastResult = (0, import_createNativeToast.createNativeToast)(title, showOptions ?? {});
|
|
73
|
-
|
|
74
|
-
setLastNativeToastRef(nativeToastResult.nativeToastRef);
|
|
75
|
-
}
|
|
44
|
+
typeof nativeToastResult == "object" && nativeToastResult.nativeToastRef && setLastNativeToastRef(nativeToastResult.nativeToastRef);
|
|
76
45
|
}
|
|
77
|
-
counterRef.current
|
|
78
|
-
|
|
79
|
-
...showOptions == null ? void 0 : showOptions.customData,
|
|
46
|
+
return counterRef.current++, setToast({
|
|
47
|
+
...showOptions?.customData,
|
|
80
48
|
...showOptions,
|
|
81
|
-
viewportName:
|
|
49
|
+
viewportName: showOptions?.viewportName ?? "default",
|
|
82
50
|
title,
|
|
83
51
|
id: counterRef.current.toString(),
|
|
84
52
|
isHandledNatively
|
|
85
|
-
});
|
|
86
|
-
return true;
|
|
53
|
+
}), !0;
|
|
87
54
|
},
|
|
88
55
|
[setToast, options.native]
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
hide,
|
|
98
|
-
nativeToast: lastNativeToastRef,
|
|
99
|
-
options
|
|
100
|
-
};
|
|
101
|
-
}, [show, hide, lastNativeToastRef, JSON.stringify(options || null)]);
|
|
56
|
+
), hide = import_react.default.useCallback(() => {
|
|
57
|
+
lastNativeToastRef?.close(), setToast(null);
|
|
58
|
+
}, [setToast, lastNativeToastRef]), contextValue = (0, import_react.useMemo)(() => ({
|
|
59
|
+
show,
|
|
60
|
+
hide,
|
|
61
|
+
nativeToast: lastNativeToastRef,
|
|
62
|
+
options
|
|
63
|
+
}), [show, hide, lastNativeToastRef, JSON.stringify(options || null)]);
|
|
102
64
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastCurrentContext.Provider, { value: toast, children }) });
|
|
103
65
|
};
|
|
104
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ToastImperative.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmD,0BACnD,eAAkE,2BAClE,sBAAyB,yBAEzB,2BAAkC,gCA4K5B;AAhGN,MAAM,mBAAe,4BAA6B,CAAC,CAAQ,GACrD,0BAAsB,4BAAgC,IAAI,GAEnD,qBAAqB,UACzB,yBAAW,YAAY,GAGnB,gBAAgB,UACpB,yBAAW,mBAAmB,GAI1B,WAAW,OACf;AAAA,EACL,GAAG,mBAAmB;AAAA,EACtB,cAAc,cAAc;AAC9B,IAWW,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AACF,MAAoC;AAClC,QAAM,iBAAa,qBAAO,CAAC,GAErB,CAAC,OAAO,QAAQ,IAAI,aAAAA,QAAM,SAA2B,IAAI,GAEzD,CAAC,oBAAoB,qBAAqB,IAC9C,aAAAA,QAAM,SAAuC,IAAI,GAE7C,OAAO,aAAAA,QAAM;AAAA,IACjB,CAAC,OAAO,gBAAgB;AACtB,YAAM,SAAS,aAAa,UAAU,QAAQ,QACxC,cAAc,MAAM,QAAQ,MAAM,IACpC,OAAO,SAAS,KAAK,IACrB,WAAW,OACT,iBAAiB,MAAM,QAAQ,MAAM,IACvC,OAAO,SAAS,QAAQ,IACxB,WAAW,UACT,kBACJ,mBACC,MAAM,QAAQ,MAAM,IAAI,OAAO,SAAS,SAAS,IAAI,WAAW,YAC7D,cACJ,mBACC,MAAM,QAAQ,MAAM,IAAI,OAAO,SAAS,KAAK,IAAI,WAAW,QAEzD,oBACJ,WAAW,MACV,qBAAS,eACT,CAAC,qBAAS,kBACV,6BAAS,OAAO,aAAa,mBAC7B,6BAAS,OAAO,SAAS;AAE5B,UAAI,mBAAmB;AACrB,cAAM,wBAAoB,4CAAkB,OAAO,eAAe,CAAC,CAAC;AACpE,QAAI,OAAO,qBAAsB,YAAY,kBAAkB,kBAC7D,sBAAsB,kBAAkB,cAAc;AAAA,MAE1D;AACA,wBAAW,WACX,SAAS;AAAA,QACP,GAAG,aAAa;AAAA,QAChB,GAAG;AAAA,QACH,cAAc,aAAa,gBAAgB;AAAA,QAC3C;AAAA,QACA,IAAI,WAAW,QAAQ,SAAS;AAAA,QAChC;AAAA,MACF,CAAC,GACM;AAAA,IACT;AAAA,IACA,CAAC,UAAU,QAAQ,MAAM;AAAA,EAC3B,GACM,OAAO,aAAAA,QAAM,YAAY,MAAM;AACnC,wBAAoB,MAAM,GAC1B,SAAS,IAAI;AAAA,EACf,GAAG,CAAC,UAAU,kBAAkB,CAAC,GAE3B,mBAAe,sBAAQ,OACpB;AAAA,IACL;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,EACF,IACC,CAAC,MAAM,MAAM,oBAAoB,KAAK,UAAU,WAAW,IAAI,CAAC,CAAC;AAEpE,SACE,4CAAC,aAAa,UAAb,EAAsB,OAAO,cAC5B,sDAAC,oBAAoB,UAApB,EAA6B,OAAO,OAClC,UACH,GACF;AAEJ;",
|
|
5
5
|
"names": ["React"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
+
mod
|
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
+
var ToastImperative_exports = {};
|
|
25
|
+
__export(ToastImperative_exports, {
|
|
26
|
+
ToastImperativeProvider: () => ToastImperativeProvider,
|
|
27
|
+
useToast: () => useToast,
|
|
28
|
+
useToastController: () => useToastController,
|
|
29
|
+
useToastState: () => useToastState
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(ToastImperative_exports);
|
|
32
|
+
var import_core = require("@tamagui/core"), import_react = __toESM(require("react")), import_react_native = require("react-native"), import_createNativeToast = require("./createNativeToast"), import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
const ToastContext = (0, import_react.createContext)({}), ToastCurrentContext = (0, import_react.createContext)(null), useToastController = () => (0, import_react.useContext)(ToastContext), useToastState = () => (0, import_react.useContext)(ToastCurrentContext), useToast = () => ({
|
|
34
|
+
...useToastController(),
|
|
35
|
+
currentToast: useToastState()
|
|
36
|
+
}), ToastImperativeProvider = ({
|
|
37
|
+
children,
|
|
38
|
+
options
|
|
39
|
+
}) => {
|
|
40
|
+
const counterRef = (0, import_react.useRef)(0), [toast, setToast] = import_react.default.useState(null), [lastNativeToastRef, setLastNativeToastRef] = import_react.default.useState(null), show = import_react.default.useCallback(
|
|
41
|
+
(title, showOptions) => {
|
|
42
|
+
const native = showOptions?.native ?? options.native, isWebNative = Array.isArray(native) ? native.includes("web") : native === "web", isMobileNative = Array.isArray(native) ? native.includes("mobile") : native === "mobile", isAndroidNative = isMobileNative || (Array.isArray(native) ? native.includes("android") : native === "android"), isIosNative = isMobileNative || (Array.isArray(native) ? native.includes("ios") : native === "ios"), isHandledNatively = native === !0 || import_core.isWeb && isWebNative || !import_core.isWeb && isMobileNative || import_react_native.Platform.OS === "android" && isAndroidNative || import_react_native.Platform.OS === "ios" && isIosNative;
|
|
43
|
+
if (isHandledNatively) {
|
|
44
|
+
const nativeToastResult = (0, import_createNativeToast.createNativeToast)(title, showOptions ?? {});
|
|
45
|
+
typeof nativeToastResult == "object" && nativeToastResult.nativeToastRef && setLastNativeToastRef(nativeToastResult.nativeToastRef);
|
|
46
|
+
}
|
|
47
|
+
return counterRef.current++, setToast({
|
|
48
|
+
...showOptions?.customData,
|
|
49
|
+
...showOptions,
|
|
50
|
+
viewportName: showOptions?.viewportName ?? "default",
|
|
51
|
+
title,
|
|
52
|
+
id: counterRef.current.toString(),
|
|
53
|
+
isHandledNatively
|
|
54
|
+
}), !0;
|
|
55
|
+
},
|
|
56
|
+
[setToast, options.native]
|
|
57
|
+
), hide = import_react.default.useCallback(() => {
|
|
58
|
+
lastNativeToastRef?.close(), setToast(null);
|
|
59
|
+
}, [setToast, lastNativeToastRef]), contextValue = (0, import_react.useMemo)(() => ({
|
|
60
|
+
show,
|
|
61
|
+
hide,
|
|
62
|
+
nativeToast: lastNativeToastRef,
|
|
63
|
+
options
|
|
64
|
+
}), [show, hide, lastNativeToastRef, JSON.stringify(options || null)]);
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastCurrentContext.Provider, { value: toast, children }) });
|
|
66
|
+
};
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
ToastImperativeProvider,
|
|
70
|
+
useToast,
|
|
71
|
+
useToastController,
|
|
72
|
+
useToastState
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=ToastImperative.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ToastImperative.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmD,0BACnD,eAAkE,2BAClE,sBAAyB,yBAEzB,2BAAkC,gCA4K5B;AAhGN,MAAM,mBAAe,4BAA6B,CAAC,CAAQ,GACrD,0BAAsB,4BAAgC,IAAI,GAEnD,qBAAqB,UACzB,yBAAW,YAAY,GAGnB,gBAAgB,UACpB,yBAAW,mBAAmB,GAI1B,WAAW,OACf;AAAA,EACL,GAAG,mBAAmB;AAAA,EACtB,cAAc,cAAc;AAC9B,IAWW,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AACF,MAAoC;AAClC,QAAM,iBAAa,qBAAO,CAAC,GAErB,CAAC,OAAO,QAAQ,IAAI,aAAAA,QAAM,SAA2B,IAAI,GAEzD,CAAC,oBAAoB,qBAAqB,IAC9C,aAAAA,QAAM,SAAuC,IAAI,GAE7C,OAAO,aAAAA,QAAM;AAAA,IACjB,CAAC,OAAO,gBAAgB;AACtB,YAAM,SAAS,aAAa,UAAU,QAAQ,QACxC,cAAc,MAAM,QAAQ,MAAM,IACpC,OAAO,SAAS,KAAK,IACrB,WAAW,OACT,iBAAiB,MAAM,QAAQ,MAAM,IACvC,OAAO,SAAS,QAAQ,IACxB,WAAW,UACT,kBACJ,mBACC,MAAM,QAAQ,MAAM,IAAI,OAAO,SAAS,SAAS,IAAI,WAAW,YAC7D,cACJ,mBACC,MAAM,QAAQ,MAAM,IAAI,OAAO,SAAS,KAAK,IAAI,WAAW,QAEzD,oBACJ,WAAW,MACV,qBAAS,eACT,CAAC,qBAAS,kBACV,6BAAS,OAAO,aAAa,mBAC7B,6BAAS,OAAO,SAAS;AAE5B,UAAI,mBAAmB;AACrB,cAAM,wBAAoB,4CAAkB,OAAO,eAAe,CAAC,CAAC;AACpE,QAAI,OAAO,qBAAsB,YAAY,kBAAkB,kBAC7D,sBAAsB,kBAAkB,cAAc;AAAA,MAE1D;AACA,wBAAW,WACX,SAAS;AAAA,QACP,GAAG,aAAa;AAAA,QAChB,GAAG;AAAA,QACH,cAAc,aAAa,gBAAgB;AAAA,QAC3C;AAAA,QACA,IAAI,WAAW,QAAQ,SAAS;AAAA,QAChC;AAAA,MACF,CAAC,GACM;AAAA,IACT;AAAA,IACA,CAAC,UAAU,QAAQ,MAAM;AAAA,EAC3B,GACM,OAAO,aAAAA,QAAM,YAAY,MAAM;AACnC,wBAAoB,MAAM,GAC1B,SAAS,IAAI;AAAA,EACf,GAAG,CAAC,UAAU,kBAAkB,CAAC,GAE3B,mBAAe,sBAAQ,OACpB;AAAA,IACL;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,EACF,IACC,CAAC,MAAM,MAAM,oBAAoB,KAAK,UAAU,WAAW,IAAI,CAAC,CAAC;AAEpE,SACE,4CAAC,aAAa,UAAb,EAAsB,OAAO,cAC5B,sDAAC,oBAAoB,UAApB,EAA6B,OAAO,OAClC,UACH,GACF;AAEJ;",
|
|
5
|
+
"names": ["React"]
|
|
6
|
+
}
|
package/dist/cjs/ToastImpl.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
14
11
|
for (let key of __getOwnPropNames(from))
|
|
15
|
-
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
13
|
return to;
|
|
19
14
|
};
|
|
20
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
@@ -22,10 +17,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
17
|
// file that has been converted to a CommonJS file using a Babel-
|
|
23
18
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
19
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
26
21
|
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
29
23
|
var ToastImpl_exports = {};
|
|
30
24
|
__export(ToastImpl_exports, {
|
|
31
25
|
ToastImpl: () => ToastImpl,
|
|
@@ -33,22 +27,10 @@ __export(ToastImpl_exports, {
|
|
|
33
27
|
useToastInteractiveContext: () => useToastInteractiveContext
|
|
34
28
|
});
|
|
35
29
|
module.exports = __toCommonJS(ToastImpl_exports);
|
|
36
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
-
var import_animate_presence = require("@tamagui/animate-presence");
|
|
38
|
-
var import_compose_refs = require("@tamagui/compose-refs");
|
|
39
|
-
var import_core = require("@tamagui/core");
|
|
40
|
-
var import_dismissable = require("@tamagui/dismissable");
|
|
41
|
-
var import_portal = require("@tamagui/portal");
|
|
42
|
-
var import_stacks = require("@tamagui/stacks");
|
|
43
|
-
var React = __toESM(require("react"));
|
|
44
|
-
var import_react_native = require("react-native");
|
|
45
|
-
var import_constants = require("./constants");
|
|
46
|
-
var import_ToastAnnounce = require("./ToastAnnounce");
|
|
47
|
-
var import_ToastProvider = require("./ToastProvider");
|
|
48
|
-
var import_ToastViewport = require("./ToastViewport");
|
|
30
|
+
var import_animate_presence = require("@tamagui/animate-presence"), import_compose_refs = require("@tamagui/compose-refs"), import_core = require("@tamagui/core"), import_dismissable = require("@tamagui/dismissable"), import_portal = require("@tamagui/portal"), import_stacks = require("@tamagui/stacks"), React = __toESM(require("react")), import_react_native = require("react-native"), import_constants = require("./constants"), import_ToastAnnounce = require("./ToastAnnounce"), import_ToastProvider = require("./ToastProvider"), import_ToastViewport = require("./ToastViewport"), import_jsx_runtime = require("react/jsx-runtime");
|
|
49
31
|
const ToastImplFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
50
32
|
name: "ToastImpl",
|
|
51
|
-
focusable:
|
|
33
|
+
focusable: !0,
|
|
52
34
|
variants: {
|
|
53
35
|
unstyled: {
|
|
54
36
|
false: {
|
|
@@ -67,17 +49,15 @@ const ToastImplFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
|
67
49
|
}
|
|
68
50
|
},
|
|
69
51
|
defaultVariants: {
|
|
70
|
-
unstyled:
|
|
52
|
+
unstyled: !1
|
|
71
53
|
}
|
|
72
|
-
})
|
|
73
|
-
const [ToastInteractiveProvider, useToastInteractiveContext] = (0, import_ToastProvider.createToastContext)(
|
|
54
|
+
}), [ToastInteractiveProvider, useToastInteractiveContext] = (0, import_ToastProvider.createToastContext)(
|
|
74
55
|
import_constants.TOAST_NAME,
|
|
75
56
|
{
|
|
76
57
|
onClose() {
|
|
77
58
|
}
|
|
78
59
|
}
|
|
79
|
-
)
|
|
80
|
-
const ToastImpl = React.forwardRef(
|
|
60
|
+
), ToastImpl = React.forwardRef(
|
|
81
61
|
(props, forwardedRef) => {
|
|
82
62
|
const {
|
|
83
63
|
__scopeToast,
|
|
@@ -94,132 +74,54 @@ const ToastImpl = React.forwardRef(
|
|
|
94
74
|
onSwipeEnd,
|
|
95
75
|
viewportName = "default",
|
|
96
76
|
...toastProps
|
|
97
|
-
} = props
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const [node, setNode] = React.useState(null);
|
|
101
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node2) => setNode(node2));
|
|
102
|
-
const duration = durationProp || context.duration;
|
|
103
|
-
const closeTimerStartTimeRef = React.useRef(0);
|
|
104
|
-
const closeTimerRemainingTimeRef = React.useRef(duration);
|
|
105
|
-
const closeTimerRef = React.useRef(0);
|
|
106
|
-
const { onToastAdd, onToastRemove } = context;
|
|
107
|
-
const viewport = React.useMemo(() => {
|
|
108
|
-
return context.viewports[viewportName];
|
|
109
|
-
}, [context.viewports, viewportName]);
|
|
110
|
-
const handleClose = (0, import_core.useEvent)(() => {
|
|
111
|
-
if (!isPresent) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (import_core.isWeb) {
|
|
115
|
-
const isFocusInToast = node == null ? void 0 : node.contains(document.activeElement);
|
|
116
|
-
if (isFocusInToast)
|
|
117
|
-
viewport == null ? void 0 : viewport.focus();
|
|
118
|
-
}
|
|
119
|
-
onClose();
|
|
120
|
-
});
|
|
121
|
-
const startTimer = React.useCallback(
|
|
77
|
+
} = props, isPresent = (0, import_animate_presence.useIsPresent)(), context = (0, import_ToastProvider.useToastProviderContext)(import_constants.TOAST_NAME, __scopeToast), [node, setNode] = React.useState(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node2) => setNode(node2)), 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)(() => {
|
|
78
|
+
isPresent && (import_core.isWeb && node?.contains(document.activeElement) && viewport?.focus(), onClose());
|
|
79
|
+
}), startTimer = React.useCallback(
|
|
122
80
|
(duration2) => {
|
|
123
|
-
|
|
124
|
-
return;
|
|
125
|
-
clearTimeout(closeTimerRef.current);
|
|
126
|
-
closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
127
|
-
closeTimerRef.current = setTimeout(handleClose, duration2);
|
|
81
|
+
!duration2 || duration2 === 1 / 0 || (clearTimeout(closeTimerRef.current), closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime(), closeTimerRef.current = setTimeout(handleClose, duration2));
|
|
128
82
|
},
|
|
129
83
|
[handleClose]
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
onResume == null ? void 0 : onResume();
|
|
134
|
-
}, [onResume, startTimer]);
|
|
135
|
-
const handlePause = React.useCallback(() => {
|
|
84
|
+
), handleResume = React.useCallback(() => {
|
|
85
|
+
startTimer(closeTimerRemainingTimeRef.current), onResume?.();
|
|
86
|
+
}, [onResume, startTimer]), handlePause = React.useCallback(() => {
|
|
136
87
|
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
|
|
137
|
-
closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime;
|
|
138
|
-
window.clearTimeout(closeTimerRef.current);
|
|
139
|
-
onPause == null ? void 0 : onPause();
|
|
88
|
+
closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime, window.clearTimeout(closeTimerRef.current), onPause?.();
|
|
140
89
|
}, [onPause]);
|
|
141
90
|
React.useEffect(() => {
|
|
142
|
-
if (
|
|
143
|
-
return
|
|
144
|
-
|
|
145
|
-
viewport.addEventListener(import_ToastViewport.VIEWPORT_PAUSE, handlePause);
|
|
146
|
-
viewport.addEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume);
|
|
147
|
-
return () => {
|
|
148
|
-
viewport.removeEventListener(import_ToastViewport.VIEWPORT_PAUSE, handlePause);
|
|
149
|
-
viewport.removeEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume);
|
|
91
|
+
if (import_core.isWeb && viewport)
|
|
92
|
+
return viewport.addEventListener(import_ToastViewport.VIEWPORT_PAUSE, handlePause), viewport.addEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume), () => {
|
|
93
|
+
viewport.removeEventListener(import_ToastViewport.VIEWPORT_PAUSE, handlePause), viewport.removeEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume);
|
|
150
94
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
React.useEffect(() =>
|
|
154
|
-
|
|
155
|
-
startTimer(duration);
|
|
156
|
-
}
|
|
157
|
-
}, [open, duration, context.isClosePausedRef, startTimer]);
|
|
158
|
-
React.useEffect(() => {
|
|
159
|
-
onToastAdd();
|
|
160
|
-
return () => onToastRemove();
|
|
161
|
-
}, [onToastAdd, onToastRemove]);
|
|
162
|
-
const announceTextContent = React.useMemo(() => {
|
|
163
|
-
if (!import_core.isWeb)
|
|
164
|
-
return null;
|
|
165
|
-
return node ? getAnnounceTextContent(node) : null;
|
|
166
|
-
}, [node]);
|
|
167
|
-
const isHorizontalSwipe = ["left", "right", "horizontal"].includes(
|
|
95
|
+
}, [viewport, duration, onPause, onResume, startTimer]), React.useEffect(() => {
|
|
96
|
+
open && !context.isClosePausedRef.current && startTimer(duration);
|
|
97
|
+
}, [open, duration, context.isClosePausedRef, startTimer]), React.useEffect(() => (onToastAdd(), () => onToastRemove()), [onToastAdd, onToastRemove]);
|
|
98
|
+
const announceTextContent = React.useMemo(() => import_core.isWeb && node ? getAnnounceTextContent(node) : null, [node]), isHorizontalSwipe = ["left", "right", "horizontal"].includes(
|
|
168
99
|
context.swipeDirection
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
if (!driver) {
|
|
100
|
+
), driver = (0, import_core.useAnimationDriver)();
|
|
101
|
+
if (!driver)
|
|
172
102
|
throw new Error("Must set animations in tamagui.config.ts");
|
|
173
|
-
}
|
|
174
|
-
const { useAnimatedNumber, useAnimatedNumberStyle } = driver;
|
|
175
|
-
const animatedNumber = useAnimatedNumber(0);
|
|
176
|
-
const AnimatedView = driver["NumberView"] ?? driver.View;
|
|
177
|
-
const animatedStyles = useAnimatedNumberStyle(animatedNumber, (val) => {
|
|
103
|
+
const { useAnimatedNumber, useAnimatedNumberStyle } = driver, animatedNumber = useAnimatedNumber(0), AnimatedView = driver.NumberView ?? driver.View, animatedStyles = useAnimatedNumberStyle(animatedNumber, (val) => {
|
|
178
104
|
"worklet";
|
|
179
105
|
return {
|
|
180
106
|
transform: [isHorizontalSwipe ? { translateX: val } : { translateY: val }]
|
|
181
107
|
};
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const { x, y } = getGestureDistance(context.swipeDirection, gesture);
|
|
200
|
-
const delta = { x, y };
|
|
201
|
-
animatedNumber.setValue(isHorizontalSwipe ? x : y, { type: "direct" });
|
|
202
|
-
if (isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)) {
|
|
203
|
-
onSwipeEnd == null ? void 0 : onSwipeEnd(e);
|
|
204
|
-
}
|
|
205
|
-
onSwipeMove == null ? void 0 : onSwipeMove(e);
|
|
206
|
-
},
|
|
207
|
-
onPanResponderEnd: (e, { dx, dy }) => {
|
|
208
|
-
if (!isDeltaInDirection(
|
|
209
|
-
{ x: dx, y: dy },
|
|
210
|
-
context.swipeDirection,
|
|
211
|
-
context.swipeThreshold
|
|
212
|
-
)) {
|
|
213
|
-
if (!import_core.isWeb) {
|
|
214
|
-
handleResume == null ? void 0 : handleResume();
|
|
215
|
-
}
|
|
216
|
-
onSwipeCancel == null ? void 0 : onSwipeCancel(e);
|
|
217
|
-
animatedNumber.setValue(0, { type: "spring" });
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
}, [handlePause, handleResume]);
|
|
222
|
-
const themeName = (0, import_core.useThemeName)();
|
|
108
|
+
}), panResponder = React.useMemo(() => import_react_native.PanResponder.create({
|
|
109
|
+
onMoveShouldSetPanResponder: (e, gesture) => shouldGrantGestureMove(context.swipeDirection, gesture) ? (onSwipeStart?.(e), !0) : !1,
|
|
110
|
+
onPanResponderGrant: (e) => {
|
|
111
|
+
import_core.isWeb || handlePause?.();
|
|
112
|
+
},
|
|
113
|
+
onPanResponderMove: (e, gesture) => {
|
|
114
|
+
const { x, y } = getGestureDistance(context.swipeDirection, gesture), delta = { x, y };
|
|
115
|
+
animatedNumber.setValue(isHorizontalSwipe ? x : y, { type: "direct" }), isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold) && onSwipeEnd?.(e), onSwipeMove?.(e);
|
|
116
|
+
},
|
|
117
|
+
onPanResponderEnd: (e, { dx, dy }) => {
|
|
118
|
+
isDeltaInDirection(
|
|
119
|
+
{ x: dx, y: dy },
|
|
120
|
+
context.swipeDirection,
|
|
121
|
+
context.swipeThreshold
|
|
122
|
+
) || (import_core.isWeb || handleResume?.(), onSwipeCancel?.(e), animatedNumber.setValue(0, { type: "spring" }));
|
|
123
|
+
}
|
|
124
|
+
}), [handlePause, handleResume]), themeName = (0, import_core.useThemeName)();
|
|
223
125
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
224
126
|
announceTextContent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
225
127
|
import_ToastAnnounce.ToastAnnounce,
|
|
@@ -227,7 +129,7 @@ const ToastImpl = React.forwardRef(
|
|
|
227
129
|
__scopeToast,
|
|
228
130
|
role: "status",
|
|
229
131
|
"aria-live": type === "foreground" ? "assertive" : "polite",
|
|
230
|
-
"aria-atomic":
|
|
132
|
+
"aria-atomic": !0,
|
|
231
133
|
children: announceTextContent
|
|
232
134
|
}
|
|
233
135
|
),
|
|
@@ -242,22 +144,19 @@ const ToastImpl = React.forwardRef(
|
|
|
242
144
|
import_dismissable.Dismissable,
|
|
243
145
|
{
|
|
244
146
|
onEscapeKeyDown: (0, import_core.composeEventHandlers)(onEscapeKeyDown, () => {
|
|
245
|
-
|
|
246
|
-
handleClose();
|
|
247
|
-
}
|
|
248
|
-
context.isFocusedToastEscapeKeyDownRef.current = false;
|
|
147
|
+
context.isFocusedToastEscapeKeyDownRef.current || handleClose(), context.isFocusedToastEscapeKeyDownRef.current = !1;
|
|
249
148
|
}),
|
|
250
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { forceClassName:
|
|
149
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { forceClassName: !0, name: themeName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
251
150
|
AnimatedView,
|
|
252
151
|
{
|
|
253
|
-
...panResponder
|
|
152
|
+
...panResponder?.panHandlers,
|
|
254
153
|
style: [{ margin: "auto" }, animatedStyles],
|
|
255
154
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.ItemSlot, { scope: __scopeToast, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
256
155
|
ToastImplFrame,
|
|
257
156
|
{
|
|
258
157
|
role: "status",
|
|
259
158
|
"aria-live": "off",
|
|
260
|
-
"aria-atomic":
|
|
159
|
+
"aria-atomic": !0,
|
|
261
160
|
"data-state": open ? "open" : "closed",
|
|
262
161
|
"data-swipe-direction": context.swipeDirection,
|
|
263
162
|
pointerEvents: "auto",
|
|
@@ -268,14 +167,7 @@ const ToastImpl = React.forwardRef(
|
|
|
268
167
|
onKeyDown: (0, import_core.composeEventHandlers)(
|
|
269
168
|
props.onKeyDown,
|
|
270
169
|
(event) => {
|
|
271
|
-
|
|
272
|
-
return;
|
|
273
|
-
onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
|
|
274
|
-
onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
|
|
275
|
-
if (!event.defaultPrevented) {
|
|
276
|
-
context.isFocusedToastEscapeKeyDownRef.current = true;
|
|
277
|
-
handleClose();
|
|
278
|
-
}
|
|
170
|
+
event.key === "Escape" && (onEscapeKeyDown?.(event), onEscapeKeyDown?.(event), event.defaultPrevented || (context.isFocusedToastEscapeKeyDownRef.current = !0, handleClose()));
|
|
279
171
|
}
|
|
280
172
|
)
|
|
281
173
|
}
|
|
@@ -301,71 +193,31 @@ ToastImpl.propTypes = {
|
|
|
301
193
|
}
|
|
302
194
|
};
|
|
303
195
|
const isDeltaInDirection = (delta, direction, threshold = 0) => {
|
|
304
|
-
const deltaX = Math.abs(delta.x);
|
|
305
|
-
|
|
306
|
-
const isDeltaX = deltaX > deltaY;
|
|
307
|
-
if (direction === "left" || direction === "right" || direction === "horizontal") {
|
|
308
|
-
return isDeltaX && deltaX > threshold;
|
|
309
|
-
} else {
|
|
310
|
-
return !isDeltaX && deltaY > threshold;
|
|
311
|
-
}
|
|
196
|
+
const deltaX = Math.abs(delta.x), deltaY = Math.abs(delta.y), isDeltaX = deltaX > deltaY;
|
|
197
|
+
return direction === "left" || direction === "right" || direction === "horizontal" ? isDeltaX && deltaX > threshold : !isDeltaX && deltaY > threshold;
|
|
312
198
|
};
|
|
313
199
|
function getAnnounceTextContent(container) {
|
|
314
200
|
if (!import_core.isWeb)
|
|
315
201
|
return "";
|
|
316
202
|
const textContent = [];
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (isHTMLElement(node)) {
|
|
322
|
-
const isHidden = node.ariaHidden || node.hidden || node.style.display === "none";
|
|
323
|
-
const isExcluded = node.dataset.toastAnnounceExclude === "";
|
|
324
|
-
if (!isHidden) {
|
|
203
|
+
return Array.from(container.childNodes).forEach((node) => {
|
|
204
|
+
if (node.nodeType === node.TEXT_NODE && node.textContent && textContent.push(node.textContent), isHTMLElement(node)) {
|
|
205
|
+
const isHidden = node.ariaHidden || node.hidden || node.style.display === "none", isExcluded = node.dataset.toastAnnounceExclude === "";
|
|
206
|
+
if (!isHidden)
|
|
325
207
|
if (isExcluded) {
|
|
326
208
|
const altText = node.dataset.toastAnnounceAlt;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
} else {
|
|
209
|
+
altText && textContent.push(altText);
|
|
210
|
+
} else
|
|
330
211
|
textContent.push(...getAnnounceTextContent(node));
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
212
|
}
|
|
334
|
-
});
|
|
335
|
-
return textContent;
|
|
213
|
+
}), textContent;
|
|
336
214
|
}
|
|
337
215
|
function isHTMLElement(node) {
|
|
338
216
|
return node.nodeType === node.ELEMENT_NODE;
|
|
339
217
|
}
|
|
340
|
-
const GESTURE_GRANT_THRESHOLD = 10
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
return true;
|
|
344
|
-
} else if ((dir === "horizontal" || dir === "right") && dx > GESTURE_GRANT_THRESHOLD) {
|
|
345
|
-
return true;
|
|
346
|
-
} else if ((dir === "vertical" || dir === "up") && dy > -GESTURE_GRANT_THRESHOLD) {
|
|
347
|
-
return true;
|
|
348
|
-
} else if ((dir === "vertical" || dir === "down") && dy < GESTURE_GRANT_THRESHOLD) {
|
|
349
|
-
return true;
|
|
350
|
-
}
|
|
351
|
-
return false;
|
|
352
|
-
};
|
|
353
|
-
const getGestureDistance = (dir, { dx, dy }) => {
|
|
354
|
-
let y = 0;
|
|
355
|
-
let x = 0;
|
|
356
|
-
if (dir === "horizontal")
|
|
357
|
-
x = dx;
|
|
358
|
-
else if (dir === "left")
|
|
359
|
-
x = Math.min(0, dx);
|
|
360
|
-
else if (dir === "right")
|
|
361
|
-
x = Math.max(0, dx);
|
|
362
|
-
else if (dir === "vertical")
|
|
363
|
-
y = dy;
|
|
364
|
-
else if (dir === "up")
|
|
365
|
-
y = Math.min(0, dy);
|
|
366
|
-
else if (dir === "down")
|
|
367
|
-
y = Math.max(0, dy);
|
|
368
|
-
return {
|
|
218
|
+
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 ? !0 : (dir === "vertical" || dir === "down") && dy < GESTURE_GRANT_THRESHOLD, getGestureDistance = (dir, { dx, dy }) => {
|
|
219
|
+
let y = 0, x = 0;
|
|
220
|
+
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)), {
|
|
369
221
|
x,
|
|
370
222
|
y
|
|
371
223
|
};
|