@tamagui/toast 1.116.0 → 1.116.2
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 +126 -0
- package/dist/cjs/ToastAnnounce.js +70 -0
- package/dist/cjs/ToastImperative.js +66 -0
- package/dist/cjs/ToastImpl.js +225 -0
- package/dist/cjs/ToastPortal.js +28 -0
- package/dist/cjs/ToastProvider.js +101 -0
- package/dist/cjs/ToastViewport.js +256 -0
- package/dist/cjs/constants.js +22 -0
- package/dist/cjs/createNativeToast.js +44 -0
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/types.js +14 -0
- package/package.json +16 -16
- package/dist/cjs/createNativeToast.native.cjs +0 -39
- package/dist/cjs/createNativeToast.native.cjs.map +0 -6
- /package/dist/cjs/{Toast.cjs.map → Toast.js.map} +0 -0
- /package/dist/cjs/{ToastAnnounce.cjs.map → ToastAnnounce.js.map} +0 -0
- /package/dist/cjs/{ToastImperative.cjs.map → ToastImperative.js.map} +0 -0
- /package/dist/cjs/{ToastImpl.cjs.map → ToastImpl.js.map} +0 -0
- /package/dist/cjs/{ToastPortal.cjs.map → ToastPortal.js.map} +0 -0
- /package/dist/cjs/{ToastProvider.cjs.map → ToastProvider.js.map} +0 -0
- /package/dist/cjs/{ToastViewport.cjs.map → ToastViewport.js.map} +0 -0
- /package/dist/cjs/{constants.cjs.map → constants.js.map} +0 -0
- /package/dist/cjs/{createNativeToast.cjs.map → createNativeToast.js.map} +0 -0
- /package/dist/cjs/{index.cjs.map → index.js.map} +0 -0
- /package/dist/cjs/{types.cjs.map → types.js.map} +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
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 Toast_exports = {};
|
|
24
|
+
__export(Toast_exports, {
|
|
25
|
+
Toast: () => Toast,
|
|
26
|
+
ToastProvider: () => import_ToastProvider.ToastProvider,
|
|
27
|
+
ToastViewport: () => import_ToastViewport.ToastViewport,
|
|
28
|
+
useToast: () => import_ToastImperative.useToast,
|
|
29
|
+
useToastController: () => import_ToastImperative.useToastController,
|
|
30
|
+
useToastState: () => import_ToastImperative.useToastState
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(Toast_exports);
|
|
33
|
+
var import_core = require("@tamagui/core"), import_helpers = require("@tamagui/helpers"), import_stacks = require("@tamagui/stacks"), import_text = require("@tamagui/text"), import_use_controllable_state = require("@tamagui/use-controllable-state"), React = __toESM(require("react")), import_constants = require("./constants"), import_ToastAnnounce = require("./ToastAnnounce"), import_ToastImperative = require("./ToastImperative"), import_ToastImpl = require("./ToastImpl"), import_ToastProvider = require("./ToastProvider"), import_ToastViewport = require("./ToastViewport"), import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
const TITLE_NAME = "ToastTitle", ToastTitle = (0, import_core.styled)(import_text.SizableText, {
|
|
35
|
+
name: TITLE_NAME,
|
|
36
|
+
variants: {
|
|
37
|
+
unstyled: {
|
|
38
|
+
false: {
|
|
39
|
+
color: "$color",
|
|
40
|
+
size: "$4"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: {
|
|
45
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
ToastTitle.displayName = TITLE_NAME;
|
|
49
|
+
const DESCRIPTION_NAME = "ToastDescription", ToastDescription = (0, import_core.styled)(import_text.SizableText, {
|
|
50
|
+
name: DESCRIPTION_NAME,
|
|
51
|
+
variants: {
|
|
52
|
+
unstyled: {
|
|
53
|
+
false: {
|
|
54
|
+
color: "$color11",
|
|
55
|
+
size: "$1"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
defaultVariants: {
|
|
60
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
ToastDescription.displayName = DESCRIPTION_NAME;
|
|
64
|
+
const ACTION_NAME = "ToastAction", ToastAction = React.forwardRef(
|
|
65
|
+
(props, forwardedRef) => {
|
|
66
|
+
const { altText, ...actionProps } = props;
|
|
67
|
+
return altText ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastAnnounce.ToastAnnounceExclude, { altText, asChild: !0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastClose, { ...actionProps, ref: forwardedRef }) }) : null;
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
ToastAction.propTypes = {
|
|
71
|
+
altText(props) {
|
|
72
|
+
return props.altText ? null : new Error(`Missing prop \`altText\` expected on \`${ACTION_NAME}\``);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
ToastAction.displayName = ACTION_NAME;
|
|
76
|
+
const CLOSE_NAME = "ToastClose", ToastCloseFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
77
|
+
name: CLOSE_NAME,
|
|
78
|
+
tag: "button"
|
|
79
|
+
}), ToastClose = React.forwardRef(
|
|
80
|
+
(props, forwardedRef) => {
|
|
81
|
+
const { __scopeToast, ...closeProps } = props, interactiveContext = (0, import_ToastImpl.useToastInteractiveContext)(__scopeToast);
|
|
82
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastAnnounce.ToastAnnounceExclude, { asChild: !0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
83
|
+
ToastCloseFrame,
|
|
84
|
+
{
|
|
85
|
+
accessibilityLabel: "Dialog Close",
|
|
86
|
+
...closeProps,
|
|
87
|
+
ref: forwardedRef,
|
|
88
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, interactiveContext.onClose)
|
|
89
|
+
}
|
|
90
|
+
) });
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
ToastClose.displayName = CLOSE_NAME;
|
|
94
|
+
const ToastComponent = import_ToastImpl.ToastImplFrame.styleable(
|
|
95
|
+
(props, forwardedRef) => {
|
|
96
|
+
const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props, [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
97
|
+
prop: openProp,
|
|
98
|
+
defaultProp: defaultOpen ?? !0,
|
|
99
|
+
onChange: onOpenChange,
|
|
100
|
+
strategy: "most-recent-wins"
|
|
101
|
+
}), id = React.useId(), onPause = (0, import_core.useEvent)(props.onPause), onResume = (0, import_core.useEvent)(props.onResume);
|
|
102
|
+
return forceMount || open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
103
|
+
import_ToastImpl.ToastImpl,
|
|
104
|
+
{
|
|
105
|
+
id,
|
|
106
|
+
open,
|
|
107
|
+
...toastProps,
|
|
108
|
+
ref: forwardedRef,
|
|
109
|
+
onClose: () => setOpen(!1),
|
|
110
|
+
onPause,
|
|
111
|
+
onResume,
|
|
112
|
+
onSwipeEnd: (0, import_helpers.composeEventHandlers)(props.onSwipeEnd, (event) => {
|
|
113
|
+
setOpen(!1);
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
) : null;
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
ToastComponent.displayName = import_constants.TOAST_NAME;
|
|
120
|
+
const Toast = (0, import_helpers.withStaticProperties)(ToastComponent, {
|
|
121
|
+
Title: ToastTitle,
|
|
122
|
+
Description: ToastDescription,
|
|
123
|
+
Action: ToastAction,
|
|
124
|
+
Close: ToastClose
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=Toast.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
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 ToastAnnounce_exports = {};
|
|
24
|
+
__export(ToastAnnounce_exports, {
|
|
25
|
+
ToastAnnounce: () => ToastAnnounce,
|
|
26
|
+
ToastAnnounceExclude: () => ToastAnnounceExclude
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(ToastAnnounce_exports);
|
|
29
|
+
var import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_start_transition = require("@tamagui/start-transition"), import_portal = require("@tamagui/portal"), import_visually_hidden = require("@tamagui/visually-hidden"), React = __toESM(require("react")), import_ToastProvider = require("./ToastProvider"), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
const ToastAnnounceExcludeFrame = (0, import_core.styled)(import_core.Stack, {
|
|
31
|
+
name: "ToastAnnounceExclude"
|
|
32
|
+
}), ToastAnnounceExclude = React.forwardRef((props, forwardedRef) => {
|
|
33
|
+
const { altText, ...announceExcludeProps } = props;
|
|
34
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
35
|
+
ToastAnnounceExcludeFrame,
|
|
36
|
+
{
|
|
37
|
+
"data-toast-announce-exclude": "",
|
|
38
|
+
"data-toast-announce-alt": altText || void 0,
|
|
39
|
+
...announceExcludeProps,
|
|
40
|
+
ref: forwardedRef
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}), ToastAnnounce = (props) => {
|
|
44
|
+
const { __scopeToast, children, ...announceProps } = props, context = (0, import_ToastProvider.useToastProviderContext)(__scopeToast), [renderAnnounceText, setRenderAnnounceText] = React.useState(!1), [isAnnounced, setIsAnnounced] = React.useState(!1);
|
|
45
|
+
return useNextFrame(() => {
|
|
46
|
+
(0, import_start_transition.startTransition)(() => {
|
|
47
|
+
setRenderAnnounceText(!0);
|
|
48
|
+
});
|
|
49
|
+
}), React.useEffect(() => {
|
|
50
|
+
const timer = setTimeout(() => setIsAnnounced(!0), 1e3);
|
|
51
|
+
return () => clearTimeout(timer);
|
|
52
|
+
}, []), isAnnounced ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, { asChild: !0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_visually_hidden.VisuallyHidden, { ...announceProps, children: renderAnnounceText && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Text, { children: [
|
|
53
|
+
context.label,
|
|
54
|
+
" ",
|
|
55
|
+
children
|
|
56
|
+
] }) }) });
|
|
57
|
+
};
|
|
58
|
+
function useNextFrame(callback = () => {
|
|
59
|
+
}) {
|
|
60
|
+
const fn = (0, import_core.useEvent)(callback);
|
|
61
|
+
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
62
|
+
let raf1 = 0, raf2 = 0;
|
|
63
|
+
return raf1 = requestAnimationFrame(() => {
|
|
64
|
+
raf2 = requestAnimationFrame(fn);
|
|
65
|
+
}), () => {
|
|
66
|
+
cancelAnimationFrame(raf1), cancelAnimationFrame(raf2);
|
|
67
|
+
};
|
|
68
|
+
}, [fn]);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=ToastAnnounce.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
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 ToastImperative_exports = {};
|
|
24
|
+
__export(ToastImperative_exports, {
|
|
25
|
+
ToastImperativeProvider: () => ToastImperativeProvider,
|
|
26
|
+
useToast: () => useToast,
|
|
27
|
+
useToastController: () => useToastController,
|
|
28
|
+
useToastState: () => useToastState
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(ToastImperative_exports);
|
|
31
|
+
var import_react = __toESM(require("react")), import_core = require("@tamagui/core"), import_react_native = require("react-native-web"), import_createNativeToast = require("./createNativeToast"), import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
const ToastContext = import_react.default.createContext({}), ToastCurrentContext = import_react.default.createContext(null), useToastController = () => import_react.default.useContext(ToastContext), useToastState = () => import_react.default.useContext(ToastCurrentContext), useToast = () => ({
|
|
33
|
+
...useToastController(),
|
|
34
|
+
currentToast: useToastState()
|
|
35
|
+
}), ToastImperativeProvider = ({
|
|
36
|
+
children,
|
|
37
|
+
options
|
|
38
|
+
}) => {
|
|
39
|
+
const counterRef = import_react.default.useRef(0), [toast, setToast] = import_react.default.useState(null), [lastNativeToastRef, setLastNativeToastRef] = import_react.default.useState(null), show = import_react.default.useCallback(
|
|
40
|
+
(title, showOptions) => {
|
|
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;
|
|
42
|
+
if (isHandledNatively) {
|
|
43
|
+
const nativeToastResult = (0, import_createNativeToast.createNativeToast)(title, showOptions ?? {});
|
|
44
|
+
typeof nativeToastResult == "object" && nativeToastResult.nativeToastRef && setLastNativeToastRef(nativeToastResult.nativeToastRef);
|
|
45
|
+
}
|
|
46
|
+
return counterRef.current++, setToast({
|
|
47
|
+
...showOptions?.customData,
|
|
48
|
+
...showOptions,
|
|
49
|
+
viewportName: showOptions?.viewportName ?? "default",
|
|
50
|
+
title,
|
|
51
|
+
id: counterRef.current.toString(),
|
|
52
|
+
isHandledNatively
|
|
53
|
+
}), !0;
|
|
54
|
+
},
|
|
55
|
+
[setToast, JSON.stringify(options.native || null)]
|
|
56
|
+
), hide = import_react.default.useCallback(() => {
|
|
57
|
+
lastNativeToastRef?.close(), setToast(null);
|
|
58
|
+
}, [setToast, lastNativeToastRef]), contextValue = import_react.default.useMemo(() => ({
|
|
59
|
+
show,
|
|
60
|
+
hide,
|
|
61
|
+
nativeToast: lastNativeToastRef,
|
|
62
|
+
options
|
|
63
|
+
}), [show, hide, lastNativeToastRef, JSON.stringify(options || null)]);
|
|
64
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastCurrentContext.Provider, { value: toast, children }) });
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=ToastImperative.js.map
|
|
@@ -0,0 +1,225 @@
|
|
|
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")), 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.ThemeableStack, {
|
|
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: "$10",
|
|
44
|
+
paddingHorizontal: "$5",
|
|
45
|
+
paddingVertical: "$2",
|
|
46
|
+
marginHorizontal: "auto",
|
|
47
|
+
marginVertical: "$1"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
defaultVariants: {
|
|
52
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
53
|
+
}
|
|
54
|
+
}), {
|
|
55
|
+
Provider: ToastInteractiveProvider,
|
|
56
|
+
useStyledContext: useToastInteractiveContext
|
|
57
|
+
} = (0, import_core.createStyledContext)({
|
|
58
|
+
onClose() {
|
|
59
|
+
}
|
|
60
|
+
}), ToastImpl = React.forwardRef(
|
|
61
|
+
(props, forwardedRef) => {
|
|
62
|
+
const {
|
|
63
|
+
__scopeToast,
|
|
64
|
+
type = "foreground",
|
|
65
|
+
duration: durationProp,
|
|
66
|
+
open,
|
|
67
|
+
onClose,
|
|
68
|
+
onEscapeKeyDown,
|
|
69
|
+
onPause,
|
|
70
|
+
onResume,
|
|
71
|
+
onSwipeStart,
|
|
72
|
+
onSwipeMove,
|
|
73
|
+
onSwipeCancel,
|
|
74
|
+
onSwipeEnd,
|
|
75
|
+
viewportName = "default",
|
|
76
|
+
...toastProps
|
|
77
|
+
} = props, isPresent = (0, import_animate_presence.useIsPresent)(), context = (0, import_ToastProvider.useToastProviderContext)(__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_constants.isWeb && node?.contains(document.activeElement) && viewport?.focus(), onClose());
|
|
79
|
+
}), startTimer = React.useCallback(
|
|
80
|
+
(duration2) => {
|
|
81
|
+
!duration2 || duration2 === Number.POSITIVE_INFINITY || (clearTimeout(closeTimerRef.current), closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime(), closeTimerRef.current = setTimeout(handleClose, duration2));
|
|
82
|
+
},
|
|
83
|
+
[handleClose]
|
|
84
|
+
), handleResume = React.useCallback(() => {
|
|
85
|
+
startTimer(closeTimerRemainingTimeRef.current), onResume?.();
|
|
86
|
+
}, [onResume, startTimer]), handlePause = React.useCallback(() => {
|
|
87
|
+
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
|
|
88
|
+
closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime, window.clearTimeout(closeTimerRef.current), onPause?.();
|
|
89
|
+
}, [onPause]);
|
|
90
|
+
React.useEffect(() => {
|
|
91
|
+
if (import_constants.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);
|
|
94
|
+
};
|
|
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_constants.isWeb && node ? getAnnounceTextContent(node) : null, [node]), isHorizontalSwipe = ["left", "right", "horizontal"].includes(
|
|
99
|
+
context.swipeDirection
|
|
100
|
+
), { animationDriver } = (0, import_core.useConfiguration)();
|
|
101
|
+
if (!animationDriver)
|
|
102
|
+
throw new Error("Must set animations in tamagui.config.ts");
|
|
103
|
+
const { useAnimatedNumber, useAnimatedNumberStyle } = animationDriver, animatedNumber = useAnimatedNumber(0), AnimatedView = animationDriver.NumberView ?? animationDriver.View ?? import_core.Stack, animatedStyles = useAnimatedNumberStyle(animatedNumber, (val) => {
|
|
104
|
+
"worklet";
|
|
105
|
+
return {
|
|
106
|
+
transform: [isHorizontalSwipe ? { translateX: val } : { translateY: val }]
|
|
107
|
+
};
|
|
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_constants.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_constants.isWeb || handleResume?.(), onSwipeCancel?.(e), animatedNumber.setValue(0, { type: "spring" }));
|
|
123
|
+
}
|
|
124
|
+
}), [handlePause, handleResume]), themeName = (0, import_core.useThemeName)();
|
|
125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
126
|
+
announceTextContent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
127
|
+
import_ToastAnnounce.ToastAnnounce,
|
|
128
|
+
{
|
|
129
|
+
__scopeToast,
|
|
130
|
+
role: "status",
|
|
131
|
+
"aria-live": type === "foreground" ? "assertive" : "polite",
|
|
132
|
+
"aria-atomic": !0,
|
|
133
|
+
children: announceTextContent
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, { hostName: viewportName ?? "default", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
137
|
+
ToastInteractiveProvider,
|
|
138
|
+
{
|
|
139
|
+
scope: __scopeToast,
|
|
140
|
+
onClose: () => {
|
|
141
|
+
handleClose();
|
|
142
|
+
},
|
|
143
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
|
+
import_dismissable.Dismissable,
|
|
145
|
+
{
|
|
146
|
+
onEscapeKeyDown: (0, import_helpers.composeEventHandlers)(onEscapeKeyDown, () => {
|
|
147
|
+
context.isFocusedToastEscapeKeyDownRef.current || handleClose(), context.isFocusedToastEscapeKeyDownRef.current = !1;
|
|
148
|
+
}),
|
|
149
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { forceClassName: !0, name: themeName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
150
|
+
AnimatedView,
|
|
151
|
+
{
|
|
152
|
+
...panResponder?.panHandlers,
|
|
153
|
+
style: [{ margin: "auto" }, animatedStyles],
|
|
154
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.ItemSlot, { __scopeCollection: __scopeToast || import_constants2.TOAST_CONTEXT, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
+
ToastImplFrame,
|
|
156
|
+
{
|
|
157
|
+
role: "status",
|
|
158
|
+
"aria-live": "off",
|
|
159
|
+
"aria-atomic": !0,
|
|
160
|
+
"data-state": open ? "open" : "closed",
|
|
161
|
+
"data-swipe-direction": context.swipeDirection,
|
|
162
|
+
pointerEvents: "auto",
|
|
163
|
+
touchAction: "none",
|
|
164
|
+
userSelect: "none",
|
|
165
|
+
...toastProps,
|
|
166
|
+
ref: composedRefs,
|
|
167
|
+
...import_constants.isWeb && {
|
|
168
|
+
onKeyDown: (0, import_helpers.composeEventHandlers)(
|
|
169
|
+
props.onKeyDown,
|
|
170
|
+
(event) => {
|
|
171
|
+
event.key === "Escape" && (onEscapeKeyDown?.(event), onEscapeKeyDown?.(event), event.defaultPrevented || (context.isFocusedToastEscapeKeyDownRef.current = !0, handleClose()));
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
) })
|
|
177
|
+
}
|
|
178
|
+
) })
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
},
|
|
182
|
+
props.id
|
|
183
|
+
) })
|
|
184
|
+
] });
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
ToastImpl.propTypes = {
|
|
188
|
+
type(props) {
|
|
189
|
+
if (props.type && !["foreground", "background"].includes(props.type)) {
|
|
190
|
+
const error = `Invalid prop \`type\` supplied to \`${import_constants2.TOAST_NAME}\`. Expected \`foreground | background\`.`;
|
|
191
|
+
return new Error(error);
|
|
192
|
+
}
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const isDeltaInDirection = (delta, direction, threshold = 0) => {
|
|
197
|
+
const deltaX = Math.abs(delta.x), deltaY = Math.abs(delta.y), isDeltaX = deltaX > deltaY;
|
|
198
|
+
return direction === "left" || direction === "right" || direction === "horizontal" ? isDeltaX && deltaX > threshold : !isDeltaX && deltaY > threshold;
|
|
199
|
+
};
|
|
200
|
+
function getAnnounceTextContent(container) {
|
|
201
|
+
if (!import_constants.isWeb) return "";
|
|
202
|
+
const textContent = [];
|
|
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)
|
|
207
|
+
if (isExcluded) {
|
|
208
|
+
const altText = node.dataset.toastAnnounceAlt;
|
|
209
|
+
altText && textContent.push(altText);
|
|
210
|
+
} else
|
|
211
|
+
textContent.push(...getAnnounceTextContent(node));
|
|
212
|
+
}
|
|
213
|
+
}), textContent;
|
|
214
|
+
}
|
|
215
|
+
function isHTMLElement(node) {
|
|
216
|
+
return node.nodeType === node.ELEMENT_NODE;
|
|
217
|
+
}
|
|
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 || (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)), {
|
|
221
|
+
x,
|
|
222
|
+
y
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
//# sourceMappingURL=ToastImpl.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var ToastPortal_exports = {};
|
|
16
|
+
__export(ToastPortal_exports, {
|
|
17
|
+
ToastPortal: () => ToastPortal
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(ToastPortal_exports);
|
|
20
|
+
var import_portal = require("@tamagui/portal"), import_react_native = require("react-native-web"), import_ToastProvider = require("./ToastProvider"), import_jsx_runtime = require("react/jsx-runtime");
|
|
21
|
+
function ToastPortal({
|
|
22
|
+
children,
|
|
23
|
+
zIndex
|
|
24
|
+
}) {
|
|
25
|
+
let content = children;
|
|
26
|
+
return (import_react_native.Platform.OS === "android" || import_react_native.Platform.OS === "ios") && (content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastProvider.ReprogapateToastProvider, { context: (0, import_ToastProvider.useToastProviderContext)(), children })), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, { zIndex: zIndex || 1e9, children: content });
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ToastPortal.js.map
|
|
@@ -0,0 +1,101 @@
|
|
|
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 ToastProvider_exports = {};
|
|
24
|
+
__export(ToastProvider_exports, {
|
|
25
|
+
Collection: () => Collection,
|
|
26
|
+
ReprogapateToastProvider: () => ReprogapateToastProvider,
|
|
27
|
+
ToastProvider: () => ToastProvider,
|
|
28
|
+
useCollection: () => useCollection,
|
|
29
|
+
useToastProviderContext: () => useToastProviderContext
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(ToastProvider_exports);
|
|
32
|
+
var import_collection = require("@tamagui/collection"), import_core = require("@tamagui/core"), React = __toESM(require("react")), import_start_transition = require("@tamagui/start-transition"), import_constants = require("./constants"), import_ToastImperative = require("./ToastImperative"), import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
const PROVIDER_NAME = "ToastProvider", [Collection, useCollection] = (0, import_collection.createCollection)("Toast"), { Provider: ToastProviderProvider, useStyledContext: useToastProviderContext } = (0, import_core.createStyledContext)(), ToastProvider = (props) => {
|
|
34
|
+
const {
|
|
35
|
+
__scopeToast,
|
|
36
|
+
id: providedId,
|
|
37
|
+
burntOptions,
|
|
38
|
+
native,
|
|
39
|
+
notificationOptions,
|
|
40
|
+
label = "Notification",
|
|
41
|
+
duration = 5e3,
|
|
42
|
+
swipeDirection = "right",
|
|
43
|
+
swipeThreshold = 50,
|
|
44
|
+
children
|
|
45
|
+
} = props, backupId = React.useId(), id = providedId ?? backupId, [viewports, setViewports] = React.useState({}), [toastCount, setToastCount] = React.useState(0), isFocusedToastEscapeKeyDownRef = React.useRef(!1), isClosePausedRef = React.useRef(!1), handleViewportChange = React.useCallback(
|
|
46
|
+
(name, viewport) => {
|
|
47
|
+
(0, import_start_transition.startTransition)(() => {
|
|
48
|
+
setViewports((prev) => ({ ...prev, [name]: viewport }));
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
[]
|
|
52
|
+
), options = React.useMemo(() => ({
|
|
53
|
+
duration,
|
|
54
|
+
burntOptions,
|
|
55
|
+
native,
|
|
56
|
+
notificationOptions
|
|
57
|
+
}), [JSON.stringify([duration, burntOptions, native, notificationOptions])]);
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, { __scopeCollection: __scopeToast || import_constants.TOAST_CONTEXT, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
|
+
ToastProviderProvider,
|
|
60
|
+
{
|
|
61
|
+
scope: __scopeToast,
|
|
62
|
+
id,
|
|
63
|
+
label,
|
|
64
|
+
duration,
|
|
65
|
+
swipeDirection,
|
|
66
|
+
swipeThreshold,
|
|
67
|
+
toastCount,
|
|
68
|
+
viewports,
|
|
69
|
+
onViewportChange: handleViewportChange,
|
|
70
|
+
onToastAdd: React.useCallback(() => {
|
|
71
|
+
(0, import_start_transition.startTransition)(() => {
|
|
72
|
+
setToastCount((prevCount) => prevCount + 1);
|
|
73
|
+
});
|
|
74
|
+
}, []),
|
|
75
|
+
onToastRemove: React.useCallback(() => {
|
|
76
|
+
(0, import_start_transition.startTransition)(() => {
|
|
77
|
+
setToastCount((prevCount) => prevCount - 1);
|
|
78
|
+
});
|
|
79
|
+
}, []),
|
|
80
|
+
isFocusedToastEscapeKeyDownRef,
|
|
81
|
+
isClosePausedRef,
|
|
82
|
+
options,
|
|
83
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastImperative.ToastImperativeProvider, { options, children })
|
|
84
|
+
}
|
|
85
|
+
) });
|
|
86
|
+
};
|
|
87
|
+
function ReprogapateToastProvider(props) {
|
|
88
|
+
const { children, context } = props;
|
|
89
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, { __scopeCollection: import_constants.TOAST_CONTEXT, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastProviderProvider, { ...context, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastImperative.ToastImperativeProvider, { options: context.options, children }) }) });
|
|
90
|
+
}
|
|
91
|
+
ToastProvider.propTypes = {
|
|
92
|
+
label(props) {
|
|
93
|
+
if (props.label && typeof props.label == "string" && !props.label.trim()) {
|
|
94
|
+
const error = `Invalid prop \`label\` supplied to \`${PROVIDER_NAME}\`. Expected non-empty \`string\`.`;
|
|
95
|
+
return new Error(error);
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
ToastProvider.displayName = PROVIDER_NAME;
|
|
101
|
+
//# sourceMappingURL=ToastProvider.js.map
|
|
@@ -0,0 +1,256 @@
|
|
|
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 ToastViewport_exports = {};
|
|
24
|
+
__export(ToastViewport_exports, {
|
|
25
|
+
ToastViewport: () => ToastViewport,
|
|
26
|
+
VIEWPORT_DEFAULT_HOTKEY: () => VIEWPORT_DEFAULT_HOTKEY,
|
|
27
|
+
VIEWPORT_PAUSE: () => VIEWPORT_PAUSE,
|
|
28
|
+
VIEWPORT_RESUME: () => VIEWPORT_RESUME
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(ToastViewport_exports);
|
|
31
|
+
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_portal = require("@tamagui/portal"), import_stacks = require("@tamagui/stacks"), import_visually_hidden = require("@tamagui/visually-hidden"), React = __toESM(require("react")), import_constants2 = require("./constants"), import_ToastPortal = require("./ToastPortal"), import_ToastProvider = require("./ToastProvider"), import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
const VIEWPORT_NAME = "ToastViewport", VIEWPORT_DEFAULT_HOTKEY = ["F8"], VIEWPORT_PAUSE = "toast.viewportPause", VIEWPORT_RESUME = "toast.viewportResume", ToastViewportWrapperFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
33
|
+
name: "ViewportWrapper",
|
|
34
|
+
variants: {
|
|
35
|
+
unstyled: {
|
|
36
|
+
false: {
|
|
37
|
+
pointerEvents: "box-none",
|
|
38
|
+
top: 0,
|
|
39
|
+
bottom: 0,
|
|
40
|
+
left: 0,
|
|
41
|
+
right: 0,
|
|
42
|
+
position: import_constants.isWeb ? "fixed" : "absolute",
|
|
43
|
+
maxWidth: "100%",
|
|
44
|
+
tabIndex: 0,
|
|
45
|
+
zIndex: 1e5
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
defaultVariants: {
|
|
50
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
51
|
+
}
|
|
52
|
+
}), ToastViewportFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
53
|
+
name: VIEWPORT_NAME,
|
|
54
|
+
variants: {
|
|
55
|
+
unstyled: {
|
|
56
|
+
false: {
|
|
57
|
+
pointerEvents: "box-none",
|
|
58
|
+
position: import_constants.isWeb ? "fixed" : "absolute",
|
|
59
|
+
maxWidth: "100%"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
defaultVariants: {
|
|
64
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
65
|
+
}
|
|
66
|
+
}), ToastViewport = React.memo(
|
|
67
|
+
React.forwardRef(
|
|
68
|
+
(props, forwardedRef) => {
|
|
69
|
+
const {
|
|
70
|
+
__scopeToast,
|
|
71
|
+
hotkey = VIEWPORT_DEFAULT_HOTKEY,
|
|
72
|
+
label = "Notifications ({hotkey})",
|
|
73
|
+
name = "default",
|
|
74
|
+
multipleToasts,
|
|
75
|
+
zIndex,
|
|
76
|
+
portalToRoot,
|
|
77
|
+
...viewportProps
|
|
78
|
+
} = props, context = (0, import_ToastProvider.useToastProviderContext)(__scopeToast), getItems = (0, import_ToastProvider.useCollection)(__scopeToast || import_constants2.TOAST_CONTEXT), headFocusProxyRef = React.useRef(null), tailFocusProxyRef = React.useRef(null), wrapperRef = React.useRef(null), ref = React.useRef(null), onViewportChange = React.useCallback(
|
|
79
|
+
(el) => {
|
|
80
|
+
context.viewports[name] !== el && context.onViewportChange(name, el);
|
|
81
|
+
},
|
|
82
|
+
[name, context.viewports]
|
|
83
|
+
), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, onViewportChange), hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, ""), hasToasts = context.toastCount > 0;
|
|
84
|
+
React.useEffect(() => {
|
|
85
|
+
if (!import_constants.isWeb || context.toastCount === 0) return;
|
|
86
|
+
const handleKeyDown = (event) => {
|
|
87
|
+
hotkey.every(
|
|
88
|
+
(key) => event[key] || event.code === key
|
|
89
|
+
) && ref.current?.focus();
|
|
90
|
+
};
|
|
91
|
+
return document.addEventListener("keydown", handleKeyDown), () => {
|
|
92
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
93
|
+
};
|
|
94
|
+
}, [hotkey, context.toastCount]), React.useEffect(() => {
|
|
95
|
+
if (!import_constants.isWeb || context.toastCount === 0) return;
|
|
96
|
+
const wrapper = wrapperRef.current, viewport = ref.current;
|
|
97
|
+
if (hasToasts && wrapper && viewport) {
|
|
98
|
+
const handlePause = () => {
|
|
99
|
+
if (!context.isClosePausedRef.current) {
|
|
100
|
+
const pauseEvent = new CustomEvent(VIEWPORT_PAUSE);
|
|
101
|
+
viewport.dispatchEvent(pauseEvent), context.isClosePausedRef.current = !0;
|
|
102
|
+
}
|
|
103
|
+
}, handleResume = () => {
|
|
104
|
+
if (context.isClosePausedRef.current) {
|
|
105
|
+
const resumeEvent = new CustomEvent(VIEWPORT_RESUME);
|
|
106
|
+
viewport.dispatchEvent(resumeEvent), context.isClosePausedRef.current = !1;
|
|
107
|
+
}
|
|
108
|
+
}, handleFocusOutResume = (event) => {
|
|
109
|
+
!wrapper.contains(
|
|
110
|
+
event.relatedTarget
|
|
111
|
+
) && handleResume();
|
|
112
|
+
}, handlePointerLeaveResume = () => {
|
|
113
|
+
wrapper.contains(document.activeElement) || handleResume();
|
|
114
|
+
};
|
|
115
|
+
return wrapper.addEventListener("focusin", handlePause), wrapper.addEventListener("focusout", handleFocusOutResume), wrapper.addEventListener("pointermove", handlePause), wrapper.addEventListener("pointerleave", handlePointerLeaveResume), window.addEventListener("blur", handlePause), window.addEventListener("focus", handleResume), () => {
|
|
116
|
+
wrapper.removeEventListener("focusin", handlePause), wrapper.removeEventListener("focusout", handleFocusOutResume), wrapper.removeEventListener("pointermove", handlePause), wrapper.removeEventListener("pointerleave", handlePointerLeaveResume), window.removeEventListener("blur", handlePause), window.removeEventListener("focus", handleResume);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}, [hasToasts, context.isClosePausedRef, context.toastCount]);
|
|
120
|
+
const getSortedTabbableCandidates = React.useCallback(
|
|
121
|
+
({ tabbingDirection }) => {
|
|
122
|
+
const tabbableCandidates = getItems().map((toastItem) => {
|
|
123
|
+
const toastNode = toastItem.ref.current, toastTabbableCandidates = [
|
|
124
|
+
toastNode,
|
|
125
|
+
...getTabbableCandidates(toastNode)
|
|
126
|
+
];
|
|
127
|
+
return tabbingDirection === "forwards" ? toastTabbableCandidates : toastTabbableCandidates.reverse();
|
|
128
|
+
});
|
|
129
|
+
return (tabbingDirection === "forwards" ? tabbableCandidates.reverse() : tabbableCandidates).flat();
|
|
130
|
+
},
|
|
131
|
+
[getItems]
|
|
132
|
+
);
|
|
133
|
+
React.useEffect(() => {
|
|
134
|
+
if (!import_constants.isWeb || context.toastCount === 0) return;
|
|
135
|
+
const viewport = ref.current;
|
|
136
|
+
if (viewport) {
|
|
137
|
+
const handleKeyDown = (event) => {
|
|
138
|
+
const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
|
|
139
|
+
if (event.key === "Tab" && !isMetaKey) {
|
|
140
|
+
const focusedElement = document.activeElement, isTabbingBackwards = event.shiftKey;
|
|
141
|
+
if (event.target === viewport && isTabbingBackwards) {
|
|
142
|
+
headFocusProxyRef.current?.focus();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const sortedCandidates = getSortedTabbableCandidates({ tabbingDirection: isTabbingBackwards ? "backwards" : "forwards" }), index = sortedCandidates.findIndex(
|
|
146
|
+
(candidate) => candidate === focusedElement
|
|
147
|
+
);
|
|
148
|
+
focusFirst(sortedCandidates.slice(index + 1)) ? event.preventDefault() : isTabbingBackwards ? (
|
|
149
|
+
// @ts-ignore ali TODO type
|
|
150
|
+
headFocusProxyRef.current?.focus()
|
|
151
|
+
) : (
|
|
152
|
+
// @ts-ignore ali TODO type
|
|
153
|
+
tailFocusProxyRef.current?.focus()
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
return viewport.addEventListener("keydown", handleKeyDown), () => viewport.removeEventListener("keydown", handleKeyDown);
|
|
158
|
+
}
|
|
159
|
+
}, [getItems, getSortedTabbableCandidates, context.toastCount]);
|
|
160
|
+
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
161
|
+
ToastViewportWrapperFrame,
|
|
162
|
+
{
|
|
163
|
+
ref: wrapperRef,
|
|
164
|
+
role: "region",
|
|
165
|
+
"aria-label": label.replace("{hotkey}", hotkeyLabel),
|
|
166
|
+
tabIndex: -1,
|
|
167
|
+
children: [
|
|
168
|
+
hasToasts && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
169
|
+
FocusProxy,
|
|
170
|
+
{
|
|
171
|
+
__scopeToast,
|
|
172
|
+
viewportName: name,
|
|
173
|
+
ref: headFocusProxyRef,
|
|
174
|
+
onFocusFromOutsideViewport: () => {
|
|
175
|
+
const tabbableCandidates = getSortedTabbableCandidates({
|
|
176
|
+
tabbingDirection: "forwards"
|
|
177
|
+
});
|
|
178
|
+
focusFirst(tabbableCandidates);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastProvider.Collection.Slot, { __scopeCollection: __scopeToast || import_constants2.TOAST_CONTEXT, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
183
|
+
ToastViewportFrame,
|
|
184
|
+
{
|
|
185
|
+
focusable: context.toastCount > 0,
|
|
186
|
+
ref: composedRefs,
|
|
187
|
+
...viewportProps,
|
|
188
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
189
|
+
import_portal.PortalHost,
|
|
190
|
+
{
|
|
191
|
+
render: (children) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { exitBeforeEnter: !multipleToasts, children }),
|
|
192
|
+
name: name ?? "default"
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
) }),
|
|
197
|
+
hasToasts && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
198
|
+
FocusProxy,
|
|
199
|
+
{
|
|
200
|
+
__scopeToast,
|
|
201
|
+
viewportName: name,
|
|
202
|
+
ref: tailFocusProxyRef,
|
|
203
|
+
onFocusFromOutsideViewport: () => {
|
|
204
|
+
const tabbableCandidates = getSortedTabbableCandidates({
|
|
205
|
+
tabbingDirection: "backwards"
|
|
206
|
+
});
|
|
207
|
+
focusFirst(tabbableCandidates);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
return portalToRoot ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastPortal.ToastPortal, { ...typeof zIndex == "number" ? { zIndex } : {}, children: contents }) : contents;
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
);
|
|
218
|
+
ToastViewport.displayName = VIEWPORT_NAME;
|
|
219
|
+
const FOCUS_PROXY_NAME = "ToastFocusProxy", FocusProxy = React.forwardRef(
|
|
220
|
+
(props, forwardedRef) => {
|
|
221
|
+
const { __scopeToast, onFocusFromOutsideViewport, viewportName, ...proxyProps } = props, viewport = (0, import_ToastProvider.useToastProviderContext)(__scopeToast).viewports[viewportName];
|
|
222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
223
|
+
import_visually_hidden.VisuallyHidden,
|
|
224
|
+
{
|
|
225
|
+
"aria-hidden": !0,
|
|
226
|
+
tabIndex: 0,
|
|
227
|
+
...proxyProps,
|
|
228
|
+
ref: forwardedRef,
|
|
229
|
+
position: import_constants.isWeb ? "fixed" : "absolute",
|
|
230
|
+
onFocus: (event) => {
|
|
231
|
+
if (!import_constants.isWeb) return;
|
|
232
|
+
const prevFocusedElement = event.relatedTarget;
|
|
233
|
+
!viewport?.contains(prevFocusedElement) && onFocusFromOutsideViewport();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
FocusProxy.displayName = FOCUS_PROXY_NAME;
|
|
240
|
+
function focusFirst(candidates) {
|
|
241
|
+
if (!import_constants.isWeb) return;
|
|
242
|
+
const previouslyFocusedElement = document.activeElement;
|
|
243
|
+
return candidates.some((candidate) => candidate === previouslyFocusedElement ? !0 : (candidate.focus(), document.activeElement !== previouslyFocusedElement));
|
|
244
|
+
}
|
|
245
|
+
function getTabbableCandidates(container) {
|
|
246
|
+
if (!import_constants.isWeb) return [];
|
|
247
|
+
const containerHtml = container, nodes = [], walker = document.createTreeWalker(containerHtml, NodeFilter.SHOW_ELEMENT, {
|
|
248
|
+
acceptNode: (node) => {
|
|
249
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
250
|
+
return node.disabled || node.hidden || isHiddenInput ? NodeFilter.FILTER_SKIP : node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
for (; walker.nextNode(); ) nodes.push(walker.currentNode);
|
|
254
|
+
return nodes;
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=ToastViewport.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var constants_exports = {};
|
|
16
|
+
__export(constants_exports, {
|
|
17
|
+
TOAST_CONTEXT: () => TOAST_CONTEXT,
|
|
18
|
+
TOAST_NAME: () => TOAST_NAME
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(constants_exports);
|
|
21
|
+
const TOAST_NAME = "Toast", TOAST_CONTEXT = "Toast";
|
|
22
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var createNativeToast_exports = {};
|
|
16
|
+
__export(createNativeToast_exports, {
|
|
17
|
+
createNativeToast: () => createNativeToast,
|
|
18
|
+
hideNativeToast: () => hideNativeToast
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(createNativeToast_exports);
|
|
21
|
+
const createNativeToast = (title, { message, notificationOptions }) => {
|
|
22
|
+
if (!("Notification" in window))
|
|
23
|
+
return console.error("This browser does not support notifications"), !1;
|
|
24
|
+
Notification.permission;
|
|
25
|
+
const showNotification = () => new Notification(title, {
|
|
26
|
+
body: message,
|
|
27
|
+
...notificationOptions
|
|
28
|
+
});
|
|
29
|
+
return Notification.permission === "granted" ? {
|
|
30
|
+
nativeToastRef: showNotification()
|
|
31
|
+
} : (Notification.requestPermission().then((permission) => {
|
|
32
|
+
if (permission === "granted")
|
|
33
|
+
return {
|
|
34
|
+
nativeToastRef: showNotification()
|
|
35
|
+
};
|
|
36
|
+
}), !0);
|
|
37
|
+
}, hideNativeToast = (ref) => {
|
|
38
|
+
if (!("Notification" in window)) {
|
|
39
|
+
console.error("This browser does not support notifications");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
ref && ref.close();
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=createNativeToast.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
+
return to;
|
|
10
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
+
var src_exports = {};
|
|
13
|
+
module.exports = __toCommonJS(src_exports);
|
|
14
|
+
__reExport(src_exports, require("./Toast"), module.exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
+
return to;
|
|
10
|
+
};
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
+
var types_exports = {};
|
|
13
|
+
module.exports = __toCommonJS(types_exports);
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/toast",
|
|
3
|
-
"version": "1.116.
|
|
3
|
+
"version": "1.116.2",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -34,26 +34,26 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@tamagui/animate-presence": "1.116.
|
|
38
|
-
"@tamagui/compose-refs": "1.116.
|
|
39
|
-
"@tamagui/constants": "1.116.
|
|
40
|
-
"@tamagui/core": "1.116.
|
|
41
|
-
"@tamagui/create-context": "1.116.
|
|
42
|
-
"@tamagui/dismissable": "1.116.
|
|
43
|
-
"@tamagui/helpers": "1.116.
|
|
44
|
-
"@tamagui/polyfill-dev": "1.116.
|
|
45
|
-
"@tamagui/portal": "1.116.
|
|
46
|
-
"@tamagui/stacks": "1.116.
|
|
47
|
-
"@tamagui/start-transition": "1.116.
|
|
48
|
-
"@tamagui/text": "1.116.
|
|
49
|
-
"@tamagui/use-controllable-state": "1.116.
|
|
50
|
-
"@tamagui/visually-hidden": "1.116.
|
|
37
|
+
"@tamagui/animate-presence": "1.116.2",
|
|
38
|
+
"@tamagui/compose-refs": "1.116.2",
|
|
39
|
+
"@tamagui/constants": "1.116.2",
|
|
40
|
+
"@tamagui/core": "1.116.2",
|
|
41
|
+
"@tamagui/create-context": "1.116.2",
|
|
42
|
+
"@tamagui/dismissable": "1.116.2",
|
|
43
|
+
"@tamagui/helpers": "1.116.2",
|
|
44
|
+
"@tamagui/polyfill-dev": "1.116.2",
|
|
45
|
+
"@tamagui/portal": "1.116.2",
|
|
46
|
+
"@tamagui/stacks": "1.116.2",
|
|
47
|
+
"@tamagui/start-transition": "1.116.2",
|
|
48
|
+
"@tamagui/text": "1.116.2",
|
|
49
|
+
"@tamagui/use-controllable-state": "1.116.2",
|
|
50
|
+
"@tamagui/visually-hidden": "1.116.2"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": "*"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@tamagui/build": "1.116.
|
|
56
|
+
"@tamagui/build": "1.116.2",
|
|
57
57
|
"burnt": "^0.12.2",
|
|
58
58
|
"react": "^18.2.0 || ^19.0.0"
|
|
59
59
|
},
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all) __defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: !0
|
|
9
|
-
});
|
|
10
|
-
},
|
|
11
|
-
__copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
-
get: () => from[key],
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value: !0
|
|
20
|
-
}), mod);
|
|
21
|
-
var createNativeToast_native_exports = {};
|
|
22
|
-
__export(createNativeToast_native_exports, {
|
|
23
|
-
createNativeToast: () => createNativeToast,
|
|
24
|
-
hideNativeToast: () => hideNativeToast
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(createNativeToast_native_exports);
|
|
27
|
-
const createNativeToast = (title, {
|
|
28
|
-
message,
|
|
29
|
-
duration,
|
|
30
|
-
burntOptions
|
|
31
|
-
}) => (require("burnt").toast({
|
|
32
|
-
title,
|
|
33
|
-
message,
|
|
34
|
-
duration: duration ? duration / 1e3 : void 0,
|
|
35
|
-
...burntOptions
|
|
36
|
-
}), !0),
|
|
37
|
-
hideNativeToast = () => {
|
|
38
|
-
require("burnt").dismissAllAlerts();
|
|
39
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/createNativeToast.native.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,oBAA0C,CACrD,OACA,EAAE,SAAS,UAAU,aAAa,OAGpB,QAAQ,OAAO,EAEvB,MAAM;AAAA,EACV;AAAA,EACA;AAAA,EACA,UAAU,WAAW,WAAW,MAAO;AAAA,EACvC,GAAG;AACL,CAAC,GACM,KAGI,kBAAsC,MAAM;AAEvD,EADc,QAAQ,OAAO,EACvB,iBAAiB;AACzB;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|