@tamagui/toast 1.11.2 → 1.12.1
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 +5 -2
- package/dist/cjs/Toast.js.map +2 -2
- package/dist/cjs/ToastProvider.js +13 -1
- package/dist/cjs/ToastProvider.js.map +2 -2
- package/dist/cjs/index.js +1 -2
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/Toast.js +3 -1
- package/dist/esm/Toast.js.map +2 -2
- package/dist/esm/Toast.mjs +3 -1
- package/dist/esm/Toast.mjs.map +2 -2
- package/dist/esm/ToastProvider.js +13 -1
- package/dist/esm/ToastProvider.js.map +2 -2
- package/dist/esm/ToastProvider.mjs +13 -1
- package/dist/esm/ToastProvider.mjs.map +2 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.mjs.map +2 -2
- package/dist/jsx/Toast.js +3 -1
- package/dist/jsx/Toast.js.map +2 -2
- package/dist/jsx/Toast.mjs +3 -1
- package/dist/jsx/Toast.mjs.map +2 -2
- package/dist/jsx/ToastProvider.js +13 -1
- package/dist/jsx/ToastProvider.js.map +2 -2
- package/dist/jsx/ToastProvider.mjs +13 -1
- package/dist/jsx/ToastProvider.mjs.map +2 -2
- package/dist/jsx/index.js +1 -2
- package/dist/jsx/index.js.map +2 -2
- package/dist/jsx/index.mjs +1 -2
- package/dist/jsx/index.mjs.map +2 -2
- package/package.json +13 -13
- package/src/Toast.tsx +7 -1
- package/src/ToastProvider.tsx +31 -2
- package/src/index.ts +1 -2
- package/types/Toast.d.ts +3 -2
- package/types/Toast.d.ts.map +1 -1
- package/types/ToastProvider.d.ts +15 -0
- package/types/ToastProvider.d.ts.map +1 -1
- package/types/index.d.ts +1 -2
- package/types/index.d.ts.map +1 -1
package/dist/cjs/Toast.js
CHANGED
|
@@ -31,7 +31,8 @@ __export(Toast_exports, {
|
|
|
31
31
|
Toast: () => Toast,
|
|
32
32
|
ToastProvider: () => import_ToastProvider.ToastProvider,
|
|
33
33
|
ToastViewport: () => import_ToastViewport.ToastViewport,
|
|
34
|
-
createToastScope: () => import_ToastProvider.createToastScope
|
|
34
|
+
createToastScope: () => import_ToastProvider.createToastScope,
|
|
35
|
+
useToast: () => import_ToastImperative.useToast
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(Toast_exports);
|
|
37
38
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -42,6 +43,7 @@ var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
|
42
43
|
var React = __toESM(require("react"));
|
|
43
44
|
var import_constants = require("./constants");
|
|
44
45
|
var import_ToastAnnounce = require("./ToastAnnounce");
|
|
46
|
+
var import_ToastImperative = require("./ToastImperative.js");
|
|
45
47
|
var import_ToastImpl = require("./ToastImpl");
|
|
46
48
|
var import_ToastProvider = require("./ToastProvider");
|
|
47
49
|
var import_ToastViewport = require("./ToastViewport");
|
|
@@ -174,6 +176,7 @@ const Toast = (0, import_core.withStaticProperties)(
|
|
|
174
176
|
Toast,
|
|
175
177
|
ToastProvider,
|
|
176
178
|
ToastViewport,
|
|
177
|
-
createToastScope
|
|
179
|
+
createToastScope,
|
|
180
|
+
useToast
|
|
178
181
|
});
|
|
179
182
|
//# sourceMappingURL=Toast.js.map
|
package/dist/cjs/Toast.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Toast.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n GetProps,\n TamaguiElement,\n composeEventHandlers,\n styled,\n themeable,\n useEvent,\n useId,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounceExclude } from './ToastAnnounce'\nimport {\n ToastImpl,\n ToastImplFrame,\n ToastProps,\n useToastInteractiveContext,\n} from './ToastImpl'\nimport {\n ScopedProps,\n ToastProvider,\n ToastProviderProps,\n createToastScope,\n} from './ToastProvider'\nimport { ToastViewport, ToastViewportProps } from './ToastViewport'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'ToastTitle'\n\nconst ToastTitleFrame = styled(SizableText, {\n name: TITLE_NAME,\n color: '$color',\n variants: {\n unstyled: {\n false: {\n size: '$4',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype PrimitiveDivProps = GetProps<typeof ToastTitleFrame>\ntype ToastTitleProps = PrimitiveDivProps & {}\n\nconst ToastTitle = React.forwardRef<TamaguiElement, ToastTitleProps>(\n (props: ScopedProps<ToastTitleProps>, forwardedRef) => {\n const { __scopeToast, ...titleProps } = props\n return <ToastTitleFrame {...titleProps} ref={forwardedRef} />\n }\n)\n\nToastTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'ToastDescription'\n\nconst ToastDescriptionFrame = styled(SizableText, {\n name: DESCRIPTION_NAME,\n color: '$color11',\n variants: {\n unstyled: {\n false: {\n size: '$1',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype ToastDescriptionFrameProps = GetProps<typeof ToastDescriptionFrame>\ntype ToastDescriptionProps = ToastDescriptionFrameProps & {}\n\nconst ToastDescription = React.forwardRef<TamaguiElement, ToastDescriptionProps>(\n (props: ScopedProps<ToastDescriptionProps>, forwardedRef) => {\n const { __scopeToast, ...descriptionProps } = props\n return <ToastDescriptionFrame {...descriptionProps} ref={forwardedRef} />\n }\n)\n\nToastDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction'\n\ntype ToastActionProps = ToastCloseProps & {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to updgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string\n}\n\nconst ToastAction = React.forwardRef<TamaguiElement, ToastActionProps>(\n (props: ScopedProps<ToastActionProps>, forwardedRef) => {\n const { altText, ...actionProps } = props\n if (!altText) return null\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastAction.propTypes = {\n altText(props) {\n if (!props.altText) {\n return new Error(`Missing prop \\`altText\\` expected on \\`${ACTION_NAME}\\``)\n }\n return null\n },\n}\n\nToastAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose'\n\nconst ToastCloseFrame = styled(ThemeableStack, {\n name: CLOSE_NAME,\n tag: 'button',\n})\ntype ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>\ntype ToastCloseProps = ToastCloseFrameProps & {}\n\nconst ToastClose = React.forwardRef<TamaguiElement, ToastCloseProps>(\n (props: ScopedProps<ToastCloseProps>, forwardedRef) => {\n const { __scopeToast, ...closeProps } = props\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast)\n\n return (\n <ToastAnnounceExclude asChild>\n <ToastCloseFrame\n accessibilityLabel=\"Dialog Close\"\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress as any, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(\n ToastImplFrame.extractable((props: ScopedProps<ToastProps>, forwardedRef) => {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n })\n\n const id = useId()\n const onPause = useEvent(props.onPause)\n const onResume = useEvent(props.onResume)\n const shouldShow = forceMount || open\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import {\n GetProps,\n TamaguiElement,\n composeEventHandlers,\n styled,\n themeable,\n useEvent,\n useId,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounceExclude } from './ToastAnnounce'\nimport { ToastNativePlatform, ToastNativeValue, useToast } from './ToastImperative.js'\nimport {\n ToastImpl,\n ToastImplFrame,\n ToastProps,\n useToastInteractiveContext,\n} from './ToastImpl'\nimport {\n ScopedProps,\n ToastProvider,\n ToastProviderProps,\n createToastScope,\n} from './ToastProvider'\nimport { ToastViewport, ToastViewportProps } from './ToastViewport'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'ToastTitle'\n\nconst ToastTitleFrame = styled(SizableText, {\n name: TITLE_NAME,\n color: '$color',\n variants: {\n unstyled: {\n false: {\n size: '$4',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype PrimitiveDivProps = GetProps<typeof ToastTitleFrame>\ntype ToastTitleProps = PrimitiveDivProps & {}\n\nconst ToastTitle = React.forwardRef<TamaguiElement, ToastTitleProps>(\n (props: ScopedProps<ToastTitleProps>, forwardedRef) => {\n const { __scopeToast, ...titleProps } = props\n return <ToastTitleFrame {...titleProps} ref={forwardedRef} />\n }\n)\n\nToastTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'ToastDescription'\n\nconst ToastDescriptionFrame = styled(SizableText, {\n name: DESCRIPTION_NAME,\n color: '$color11',\n variants: {\n unstyled: {\n false: {\n size: '$1',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype ToastDescriptionFrameProps = GetProps<typeof ToastDescriptionFrame>\ntype ToastDescriptionProps = ToastDescriptionFrameProps & {}\n\nconst ToastDescription = React.forwardRef<TamaguiElement, ToastDescriptionProps>(\n (props: ScopedProps<ToastDescriptionProps>, forwardedRef) => {\n const { __scopeToast, ...descriptionProps } = props\n return <ToastDescriptionFrame {...descriptionProps} ref={forwardedRef} />\n }\n)\n\nToastDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction'\n\ntype ToastActionProps = ToastCloseProps & {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to updgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string\n}\n\nconst ToastAction = React.forwardRef<TamaguiElement, ToastActionProps>(\n (props: ScopedProps<ToastActionProps>, forwardedRef) => {\n const { altText, ...actionProps } = props\n if (!altText) return null\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastAction.propTypes = {\n altText(props) {\n if (!props.altText) {\n return new Error(`Missing prop \\`altText\\` expected on \\`${ACTION_NAME}\\``)\n }\n return null\n },\n}\n\nToastAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose'\n\nconst ToastCloseFrame = styled(ThemeableStack, {\n name: CLOSE_NAME,\n tag: 'button',\n})\ntype ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>\ntype ToastCloseProps = ToastCloseFrameProps & {}\n\nconst ToastClose = React.forwardRef<TamaguiElement, ToastCloseProps>(\n (props: ScopedProps<ToastCloseProps>, forwardedRef) => {\n const { __scopeToast, ...closeProps } = props\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast)\n\n return (\n <ToastAnnounceExclude asChild>\n <ToastCloseFrame\n accessibilityLabel=\"Dialog Close\"\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress as any, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(\n ToastImplFrame.extractable((props: ScopedProps<ToastProps>, forwardedRef) => {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n })\n\n const id = useId()\n const onPause = useEvent(props.onPause)\n const onResume = useEvent(props.onResume)\n const shouldShow = forceMount || open\n\n if (!shouldShow) return null\n\n return (\n <ToastImpl\n id={id}\n open={open}\n {...toastProps}\n ref={forwardedRef}\n onClose={() => setOpen(false)}\n onPause={onPause}\n onResume={onResume}\n onSwipeEnd={composeEventHandlers(props.onSwipeEnd, (event) => {\n setOpen(false)\n })}\n />\n )\n })\n)\n\nToastComponent.displayName = TOAST_NAME\n\nconst Toast = withStaticProperties(\n themeable(ToastComponent, ToastImplFrame.staticConfig),\n {\n Title: ToastTitle,\n Description: ToastDescription,\n Action: ToastAction,\n Close: ToastClose,\n }\n)\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n Toast,\n ToastProvider,\n ToastViewport,\n //\n createToastScope,\n // imperative\n useToast,\n}\nexport type {\n ToastActionProps,\n ToastCloseProps,\n ToastDescriptionProps,\n ToastProps,\n ToastProviderProps,\n ToastTitleProps,\n ToastViewportProps,\n // imperative\n ToastNativeValue,\n ToastNativePlatform,\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0DW;AA1DX,kBASO;AACP,oBAA+B;AAC/B,kBAA4B;AAC5B,oCAAqC;AACrC,YAAuB;AAEvB,uBAA2B;AAC3B,2BAAqC;AACrC,6BAAgE;AAChE,uBAKO;AACP,2BAKO;AACP,2BAAkD;AAMlD,MAAM,aAAa;AAEnB,MAAM,sBAAkB,oBAAO,yBAAa;AAAA,EAC1C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAID,MAAM,aAAa,MAAM;AAAA,EACvB,CAAC,OAAqC,iBAAiB;AACrD,UAAM,EAAE,cAAc,GAAG,WAAW,IAAI;AACxC,WAAO,4CAAC,mBAAiB,GAAG,YAAY,KAAK,cAAc;AAAA,EAC7D;AACF;AAEA,WAAW,cAAc;AAMzB,MAAM,mBAAmB;AAEzB,MAAM,4BAAwB,oBAAO,yBAAa;AAAA,EAChD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF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,WAAW,IAAI;AACjF,UAAM,CAAC,MAAM,OAAO,QAAI,oDAAqB;AAAA,MAC3C,MAAM;AAAA,MACN,aAAa,eAAe;AAAA,MAC5B,UAAU;AAAA,IACZ,CAAC;AAED,UAAM,SAAK,mBAAM;AACjB,UAAM,cAAU,sBAAS,MAAM,OAAO;AACtC,UAAM,eAAW,sBAAS,MAAM,QAAQ;AACxC,UAAM,aAAa,cAAc;AAEjC,QAAI,CAAC;AAAY,aAAO;AAExB,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,SAAS,MAAM,QAAQ,KAAK;AAAA,QAC5B;AAAA,QACA;AAAA,QACA,gBAAY,kCAAqB,MAAM,YAAY,CAAC,UAAU;AAC5D,kBAAQ,KAAK;AAAA,QACf,CAAC;AAAA;AAAA,IACH;AAAA,EAEJ,CAAC;AACH;AAEA,eAAe,cAAc;AAE7B,MAAM,YAAQ;AAAA,MACZ,uBAAU,gBAAgB,gCAAe,YAAY;AAAA,EACrD;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -41,6 +41,7 @@ var import_collection = require("@tamagui/collection");
|
|
|
41
41
|
var import_core = require("@tamagui/core");
|
|
42
42
|
var import_create_context = require("@tamagui/create-context");
|
|
43
43
|
var React = __toESM(require("react"));
|
|
44
|
+
var import_ToastImperative = require("./ToastImperative");
|
|
44
45
|
const PROVIDER_NAME = "ToastProvider";
|
|
45
46
|
const [Collection, useCollection, createCollectionScope] = (0, import_collection.createCollection)("Toast");
|
|
46
47
|
const [createToastContext, createToastScope] = (0, import_create_context.createContextScope)("Toast", [
|
|
@@ -51,6 +52,9 @@ const ToastProvider = (props) => {
|
|
|
51
52
|
const {
|
|
52
53
|
__scopeToast,
|
|
53
54
|
id: providedId,
|
|
55
|
+
burntOptions,
|
|
56
|
+
native,
|
|
57
|
+
notificationOptions,
|
|
54
58
|
label = "Notification",
|
|
55
59
|
duration = 5e3,
|
|
56
60
|
swipeDirection = "right",
|
|
@@ -62,6 +66,14 @@ const ToastProvider = (props) => {
|
|
|
62
66
|
const [toastCount, setToastCount] = React.useState(0);
|
|
63
67
|
const isFocusedToastEscapeKeyDownRef = React.useRef(false);
|
|
64
68
|
const isClosePausedRef = React.useRef(false);
|
|
69
|
+
const options = React.useMemo(() => {
|
|
70
|
+
return {
|
|
71
|
+
duration,
|
|
72
|
+
burntOptions,
|
|
73
|
+
native,
|
|
74
|
+
notificationOptions
|
|
75
|
+
};
|
|
76
|
+
}, [JSON.stringify([duration, burntOptions, native, notificationOptions])]);
|
|
65
77
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, { scope: __scopeToast, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
66
78
|
ToastProviderProvider,
|
|
67
79
|
{
|
|
@@ -82,7 +94,7 @@ const ToastProvider = (props) => {
|
|
|
82
94
|
}, []),
|
|
83
95
|
isFocusedToastEscapeKeyDownRef,
|
|
84
96
|
isClosePausedRef,
|
|
85
|
-
children
|
|
97
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastImperative.ToastImperativeProvider, { options, children })
|
|
86
98
|
}
|
|
87
99
|
) });
|
|
88
100
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ToastProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement, useId } from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement, useId } from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport * as React from 'react'\n\nimport { ToastImperativeProvider, ToastNativeValue } from './ToastImperative'\nimport { BurntToastOptions } from './types'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'ToastProvider'\n\nconst [Collection, useCollection, createCollectionScope] =\n createCollection<TamaguiElement>('Toast')\n\ntype SwipeDirection = 'vertical' | 'up' | 'down' | 'horizontal' | 'left' | 'right'\ntype ToastProviderContextValue = {\n id: string\n label: string\n duration: number\n swipeDirection: SwipeDirection\n swipeThreshold: number\n toastCount: number\n viewport: TamaguiElement | null\n onViewportChange(viewport: TamaguiElement): void\n onToastAdd(): void\n onToastRemove(): void\n isFocusedToastEscapeKeyDownRef: React.MutableRefObject<boolean>\n isClosePausedRef: React.MutableRefObject<boolean>\n}\n\ntype ScopedProps<P> = P & { __scopeToast?: Scope }\nconst [createToastContext, createToastScope] = createContextScope('Toast', [\n createCollectionScope,\n])\nconst [ToastProviderProvider, useToastProviderContext] =\n createToastContext<ToastProviderContextValue>(PROVIDER_NAME)\n\ninterface ToastProviderProps {\n children?: React.ReactNode\n /**\n * An author-localized label for each toast. Used to help screen reader users\n * associate the interruption with a toast.\n * @defaultValue 'Notification'\n */\n label?: string\n /**\n * Time in milliseconds that each toast should remain visible for.\n * @defaultValue 5000\n */\n duration?: number\n /**\n * Direction of pointer swipe that should close the toast.\n * @defaultValue 'right'\n */\n swipeDirection?: SwipeDirection\n /**\n * Distance in pixels that the swipe must pass before a close is triggered.\n * @defaultValue 50\n */\n swipeThreshold?: number\n /**\n * @defaultValue unique generated identifier\n */\n id?: string\n /**\n * Will show a native toast if is true or is set to the current platform. On iOS, it wraps `SPIndicator` and `SPAlert`. On Android, it wraps `ToastAndroid`. On web, it wraps Notification API. Mobile's native features are handled by `burnt`.\n * Only works with the imperative `useToast` hook.\n */\n native?: ToastNativeValue\n /**\n * Options for the burnt package if you're using native toasts on mobile\n */\n burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>\n /**\n * Options for the notification API if you're using native toasts on web\n */\n notificationOptions?: NotificationOptions\n}\n\nconst ToastProvider: React.FC<ToastProviderProps> = (\n props: ScopedProps<ToastProviderProps>\n) => {\n const {\n __scopeToast,\n id: providedId,\n burntOptions,\n native,\n notificationOptions,\n label = 'Notification',\n duration = 5000,\n swipeDirection = 'right',\n swipeThreshold = 50,\n children,\n } = props\n const id = providedId ?? useId()\n const [viewport, setViewport] = React.useState<TamaguiElement | null>(null)\n const [toastCount, setToastCount] = React.useState(0)\n const isFocusedToastEscapeKeyDownRef = React.useRef(false)\n const isClosePausedRef = React.useRef(false)\n\n // memo context to avoid expensive re-renders\n const options = React.useMemo(() => {\n return {\n duration,\n burntOptions,\n native,\n notificationOptions,\n }\n // nested simple object so JSON.stringify\n }, [JSON.stringify([duration, burntOptions, native, notificationOptions])])\n\n return (\n <Collection.Provider scope={__scopeToast}>\n <ToastProviderProvider\n scope={__scopeToast}\n id={id}\n label={label}\n duration={duration}\n swipeDirection={swipeDirection}\n swipeThreshold={swipeThreshold}\n toastCount={toastCount}\n viewport={viewport}\n onViewportChange={setViewport}\n onToastAdd={React.useCallback(() => {\n setToastCount((prevCount) => prevCount + 1)\n }, [])}\n onToastRemove={React.useCallback(() => {\n setToastCount((prevCount) => prevCount - 1)\n }, [])}\n isFocusedToastEscapeKeyDownRef={isFocusedToastEscapeKeyDownRef}\n isClosePausedRef={isClosePausedRef}\n >\n <ToastImperativeProvider options={options}>{children}</ToastImperativeProvider>\n </ToastProviderProvider>\n </Collection.Provider>\n )\n}\n\nToastProvider.propTypes = {\n label(props) {\n if (props.label && typeof props.label === 'string' && !props.label.trim()) {\n const error = `Invalid prop \\`label\\` supplied to \\`${PROVIDER_NAME}\\`. Expected non-empty \\`string\\`.`\n return new Error(error)\n }\n return null\n },\n}\n\nToastProvider.displayName = PROVIDER_NAME\n\nexport {\n Collection,\n ToastProvider,\n createToastContext,\n createToastScope,\n useCollection,\n useToastProviderContext,\n}\nexport type { ScopedProps, SwipeDirection, ToastProviderProps }\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwIQ;AAxIR,wBAAiC;AACjC,kBAAsC;AAEtC,4BAAmC;AACnC,YAAuB;AAEvB,6BAA0D;AAO1D,MAAM,gBAAgB;AAEtB,MAAM,CAAC,YAAY,eAAe,qBAAqB,QACrD,oCAAiC,OAAO;AAmB1C,MAAM,CAAC,oBAAoB,gBAAgB,QAAI,0CAAmB,SAAS;AAAA,EACzE;AACF,CAAC;AACD,MAAM,CAAC,uBAAuB,uBAAuB,IACnD,mBAA8C,aAAa;AA4C7D,MAAM,gBAA8C,CAClD,UACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,IACjB;AAAA,EACF,IAAI;AACJ,QAAM,KAAK,kBAAc,mBAAM;AAC/B,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAgC,IAAI;AAC1E,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,CAAC;AACpD,QAAM,iCAAiC,MAAM,OAAO,KAAK;AACzD,QAAM,mBAAmB,MAAM,OAAO,KAAK;AAG3C,QAAM,UAAU,MAAM,QAAQ,MAAM;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAEF,GAAG,CAAC,KAAK,UAAU,CAAC,UAAU,cAAc,QAAQ,mBAAmB,CAAC,CAAC,CAAC;AAE1E,SACE,4CAAC,WAAW,UAAX,EAAoB,OAAO,cAC1B;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,kBAAkB;AAAA,MAClB,YAAY,MAAM,YAAY,MAAM;AAClC,sBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,MAC5C,GAAG,CAAC,CAAC;AAAA,MACL,eAAe,MAAM,YAAY,MAAM;AACrC,sBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,MAC5C,GAAG,CAAC,CAAC;AAAA,MACL;AAAA,MACA;AAAA,MAEA,sDAAC,kDAAwB,SAAmB,UAAS;AAAA;AAAA,EACvD,GACF;AAEJ;AAEA,cAAc,YAAY;AAAA,EACxB,MAAM,OAAO;AACX,QAAI,MAAM,SAAS,OAAO,MAAM,UAAU,YAAY,CAAC,MAAM,MAAM,KAAK,GAAG;AACzE,YAAM,QAAQ,wCAAwC;AACtD,aAAO,IAAI,MAAM,KAAK;AAAA,IACxB;AACA,WAAO;AAAA,EACT;AACF;AAEA,cAAc,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,6 +15,5 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var src_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(src_exports);
|
|
18
|
-
__reExport(src_exports, require("./Toast"), module.exports);
|
|
19
|
-
__reExport(src_exports, require("./ToastImperative"), module.exports);
|
|
18
|
+
__reExport(src_exports, require("./Toast.js"), module.exports);
|
|
20
19
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Toast'\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,
|
|
4
|
+
"sourcesContent": ["export * from './Toast.js'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,uBAAd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/Toast.js
CHANGED
|
@@ -13,6 +13,7 @@ import { useControllableState } from "@tamagui/use-controllable-state";
|
|
|
13
13
|
import * as React from "react";
|
|
14
14
|
import { TOAST_NAME } from "./constants";
|
|
15
15
|
import { ToastAnnounceExclude } from "./ToastAnnounce";
|
|
16
|
+
import { useToast } from "./ToastImperative.js";
|
|
16
17
|
import {
|
|
17
18
|
ToastImpl,
|
|
18
19
|
ToastImplFrame,
|
|
@@ -151,6 +152,7 @@ export {
|
|
|
151
152
|
Toast,
|
|
152
153
|
ToastProvider,
|
|
153
154
|
ToastViewport,
|
|
154
|
-
createToastScope
|
|
155
|
+
createToastScope,
|
|
156
|
+
useToast
|
|
155
157
|
};
|
|
156
158
|
//# sourceMappingURL=Toast.js.map
|
package/dist/esm/Toast.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Toast.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n GetProps,\n TamaguiElement,\n composeEventHandlers,\n styled,\n themeable,\n useEvent,\n useId,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounceExclude } from './ToastAnnounce'\nimport {\n ToastImpl,\n ToastImplFrame,\n ToastProps,\n useToastInteractiveContext,\n} from './ToastImpl'\nimport {\n ScopedProps,\n ToastProvider,\n ToastProviderProps,\n createToastScope,\n} from './ToastProvider'\nimport { ToastViewport, ToastViewportProps } from './ToastViewport'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'ToastTitle'\n\nconst ToastTitleFrame = styled(SizableText, {\n name: TITLE_NAME,\n color: '$color',\n variants: {\n unstyled: {\n false: {\n size: '$4',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype PrimitiveDivProps = GetProps<typeof ToastTitleFrame>\ntype ToastTitleProps = PrimitiveDivProps & {}\n\nconst ToastTitle = React.forwardRef<TamaguiElement, ToastTitleProps>(\n (props: ScopedProps<ToastTitleProps>, forwardedRef) => {\n const { __scopeToast, ...titleProps } = props\n return <ToastTitleFrame {...titleProps} ref={forwardedRef} />\n }\n)\n\nToastTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'ToastDescription'\n\nconst ToastDescriptionFrame = styled(SizableText, {\n name: DESCRIPTION_NAME,\n color: '$color11',\n variants: {\n unstyled: {\n false: {\n size: '$1',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype ToastDescriptionFrameProps = GetProps<typeof ToastDescriptionFrame>\ntype ToastDescriptionProps = ToastDescriptionFrameProps & {}\n\nconst ToastDescription = React.forwardRef<TamaguiElement, ToastDescriptionProps>(\n (props: ScopedProps<ToastDescriptionProps>, forwardedRef) => {\n const { __scopeToast, ...descriptionProps } = props\n return <ToastDescriptionFrame {...descriptionProps} ref={forwardedRef} />\n }\n)\n\nToastDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction'\n\ntype ToastActionProps = ToastCloseProps & {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to updgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string\n}\n\nconst ToastAction = React.forwardRef<TamaguiElement, ToastActionProps>(\n (props: ScopedProps<ToastActionProps>, forwardedRef) => {\n const { altText, ...actionProps } = props\n if (!altText) return null\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastAction.propTypes = {\n altText(props) {\n if (!props.altText) {\n return new Error(`Missing prop \\`altText\\` expected on \\`${ACTION_NAME}\\``)\n }\n return null\n },\n}\n\nToastAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose'\n\nconst ToastCloseFrame = styled(ThemeableStack, {\n name: CLOSE_NAME,\n tag: 'button',\n})\ntype ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>\ntype ToastCloseProps = ToastCloseFrameProps & {}\n\nconst ToastClose = React.forwardRef<TamaguiElement, ToastCloseProps>(\n (props: ScopedProps<ToastCloseProps>, forwardedRef) => {\n const { __scopeToast, ...closeProps } = props\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast)\n\n return (\n <ToastAnnounceExclude asChild>\n <ToastCloseFrame\n accessibilityLabel=\"Dialog Close\"\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress as any, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(\n ToastImplFrame.extractable((props: ScopedProps<ToastProps>, forwardedRef) => {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n })\n\n const id = useId()\n const onPause = useEvent(props.onPause)\n const onResume = useEvent(props.onResume)\n const shouldShow = forceMount || open\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n GetProps,\n TamaguiElement,\n composeEventHandlers,\n styled,\n themeable,\n useEvent,\n useId,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounceExclude } from './ToastAnnounce'\nimport { ToastNativePlatform, ToastNativeValue, useToast } from './ToastImperative.js'\nimport {\n ToastImpl,\n ToastImplFrame,\n ToastProps,\n useToastInteractiveContext,\n} from './ToastImpl'\nimport {\n ScopedProps,\n ToastProvider,\n ToastProviderProps,\n createToastScope,\n} from './ToastProvider'\nimport { ToastViewport, ToastViewportProps } from './ToastViewport'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'ToastTitle'\n\nconst ToastTitleFrame = styled(SizableText, {\n name: TITLE_NAME,\n color: '$color',\n variants: {\n unstyled: {\n false: {\n size: '$4',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype PrimitiveDivProps = GetProps<typeof ToastTitleFrame>\ntype ToastTitleProps = PrimitiveDivProps & {}\n\nconst ToastTitle = React.forwardRef<TamaguiElement, ToastTitleProps>(\n (props: ScopedProps<ToastTitleProps>, forwardedRef) => {\n const { __scopeToast, ...titleProps } = props\n return <ToastTitleFrame {...titleProps} ref={forwardedRef} />\n }\n)\n\nToastTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'ToastDescription'\n\nconst ToastDescriptionFrame = styled(SizableText, {\n name: DESCRIPTION_NAME,\n color: '$color11',\n variants: {\n unstyled: {\n false: {\n size: '$1',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype ToastDescriptionFrameProps = GetProps<typeof ToastDescriptionFrame>\ntype ToastDescriptionProps = ToastDescriptionFrameProps & {}\n\nconst ToastDescription = React.forwardRef<TamaguiElement, ToastDescriptionProps>(\n (props: ScopedProps<ToastDescriptionProps>, forwardedRef) => {\n const { __scopeToast, ...descriptionProps } = props\n return <ToastDescriptionFrame {...descriptionProps} ref={forwardedRef} />\n }\n)\n\nToastDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction'\n\ntype ToastActionProps = ToastCloseProps & {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to updgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string\n}\n\nconst ToastAction = React.forwardRef<TamaguiElement, ToastActionProps>(\n (props: ScopedProps<ToastActionProps>, forwardedRef) => {\n const { altText, ...actionProps } = props\n if (!altText) return null\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastAction.propTypes = {\n altText(props) {\n if (!props.altText) {\n return new Error(`Missing prop \\`altText\\` expected on \\`${ACTION_NAME}\\``)\n }\n return null\n },\n}\n\nToastAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose'\n\nconst ToastCloseFrame = styled(ThemeableStack, {\n name: CLOSE_NAME,\n tag: 'button',\n})\ntype ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>\ntype ToastCloseProps = ToastCloseFrameProps & {}\n\nconst ToastClose = React.forwardRef<TamaguiElement, ToastCloseProps>(\n (props: ScopedProps<ToastCloseProps>, forwardedRef) => {\n const { __scopeToast, ...closeProps } = props\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast)\n\n return (\n <ToastAnnounceExclude asChild>\n <ToastCloseFrame\n accessibilityLabel=\"Dialog Close\"\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress as any, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(\n ToastImplFrame.extractable((props: ScopedProps<ToastProps>, forwardedRef) => {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n })\n\n const id = useId()\n const onPause = useEvent(props.onPause)\n const onResume = useEvent(props.onResume)\n const shouldShow = forceMount || open\n\n if (!shouldShow) return null\n\n return (\n <ToastImpl\n id={id}\n open={open}\n {...toastProps}\n ref={forwardedRef}\n onClose={() => setOpen(false)}\n onPause={onPause}\n onResume={onResume}\n onSwipeEnd={composeEventHandlers(props.onSwipeEnd, (event) => {\n setOpen(false)\n })}\n />\n )\n })\n)\n\nToastComponent.displayName = TOAST_NAME\n\nconst Toast = withStaticProperties(\n themeable(ToastComponent, ToastImplFrame.staticConfig),\n {\n Title: ToastTitle,\n Description: ToastDescription,\n Action: ToastAction,\n Close: ToastClose,\n }\n)\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n Toast,\n ToastProvider,\n ToastViewport,\n //\n createToastScope,\n // imperative\n useToast,\n}\nexport type {\n ToastActionProps,\n ToastCloseProps,\n ToastDescriptionProps,\n ToastProps,\n ToastProviderProps,\n ToastT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,CAAC;AAED,UAAM,KAAK,MAAM;AACjB,UAAM,UAAU,SAAS,MAAM,OAAO;AACtC,UAAM,WAAW,SAAS,MAAM,QAAQ;AACxC,UAAM,aAAa,cAAc;AAEjC,QAAI,CAAC;AAAY,aAAO;AAExB,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,SAAS,MAAM,QAAQ,KAAK;AAAA,QAC5B;AAAA,QACA;AAAA,QACA,YAAY,qBAAqB,MAAM,YAAY,CAAC,UAAU;AAC5D,kBAAQ,KAAK;AAAA,QACf,CAAC;AAAA;AAAA,IACH;AAAA,EAEJ,CAAC;AACH;AAEA,eAAe,cAAc;AAE7B,MAAM,QAAQ;AAAA,EACZ,UAAU,gBAAgB,eAAe,YAAY;AAAA,EACrD;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/Toast.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { useControllableState } from "@tamagui/use-controllable-state";
|
|
|
13
13
|
import * as React from "react";
|
|
14
14
|
import { TOAST_NAME } from "./constants";
|
|
15
15
|
import { ToastAnnounceExclude } from "./ToastAnnounce";
|
|
16
|
+
import { useToast } from "./ToastImperative.js";
|
|
16
17
|
import {
|
|
17
18
|
ToastImpl,
|
|
18
19
|
ToastImplFrame,
|
|
@@ -151,6 +152,7 @@ export {
|
|
|
151
152
|
Toast,
|
|
152
153
|
ToastProvider,
|
|
153
154
|
ToastViewport,
|
|
154
|
-
createToastScope
|
|
155
|
+
createToastScope,
|
|
156
|
+
useToast
|
|
155
157
|
};
|
|
156
158
|
//# sourceMappingURL=Toast.mjs.map
|
package/dist/esm/Toast.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Toast.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n GetProps,\n TamaguiElement,\n composeEventHandlers,\n styled,\n themeable,\n useEvent,\n useId,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounceExclude } from './ToastAnnounce'\nimport {\n ToastImpl,\n ToastImplFrame,\n ToastProps,\n useToastInteractiveContext,\n} from './ToastImpl'\nimport {\n ScopedProps,\n ToastProvider,\n ToastProviderProps,\n createToastScope,\n} from './ToastProvider'\nimport { ToastViewport, ToastViewportProps } from './ToastViewport'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'ToastTitle'\n\nconst ToastTitleFrame = styled(SizableText, {\n name: TITLE_NAME,\n color: '$color',\n variants: {\n unstyled: {\n false: {\n size: '$4',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype PrimitiveDivProps = GetProps<typeof ToastTitleFrame>\ntype ToastTitleProps = PrimitiveDivProps & {}\n\nconst ToastTitle = React.forwardRef<TamaguiElement, ToastTitleProps>(\n (props: ScopedProps<ToastTitleProps>, forwardedRef) => {\n const { __scopeToast, ...titleProps } = props\n return <ToastTitleFrame {...titleProps} ref={forwardedRef} />\n }\n)\n\nToastTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'ToastDescription'\n\nconst ToastDescriptionFrame = styled(SizableText, {\n name: DESCRIPTION_NAME,\n color: '$color11',\n variants: {\n unstyled: {\n false: {\n size: '$1',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype ToastDescriptionFrameProps = GetProps<typeof ToastDescriptionFrame>\ntype ToastDescriptionProps = ToastDescriptionFrameProps & {}\n\nconst ToastDescription = React.forwardRef<TamaguiElement, ToastDescriptionProps>(\n (props: ScopedProps<ToastDescriptionProps>, forwardedRef) => {\n const { __scopeToast, ...descriptionProps } = props\n return <ToastDescriptionFrame {...descriptionProps} ref={forwardedRef} />\n }\n)\n\nToastDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction'\n\ntype ToastActionProps = ToastCloseProps & {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to updgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string\n}\n\nconst ToastAction = React.forwardRef<TamaguiElement, ToastActionProps>(\n (props: ScopedProps<ToastActionProps>, forwardedRef) => {\n const { altText, ...actionProps } = props\n if (!altText) return null\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastAction.propTypes = {\n altText(props) {\n if (!props.altText) {\n return new Error(`Missing prop \\`altText\\` expected on \\`${ACTION_NAME}\\``)\n }\n return null\n },\n}\n\nToastAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose'\n\nconst ToastCloseFrame = styled(ThemeableStack, {\n name: CLOSE_NAME,\n tag: 'button',\n})\ntype ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>\ntype ToastCloseProps = ToastCloseFrameProps & {}\n\nconst ToastClose = React.forwardRef<TamaguiElement, ToastCloseProps>(\n (props: ScopedProps<ToastCloseProps>, forwardedRef) => {\n const { __scopeToast, ...closeProps } = props\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast)\n\n return (\n <ToastAnnounceExclude asChild>\n <ToastCloseFrame\n accessibilityLabel=\"Dialog Close\"\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress as any, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(\n ToastImplFrame.extractable((props: ScopedProps<ToastProps>, forwardedRef) => {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n })\n\n const id = useId()\n const onPause = useEvent(props.onPause)\n const onResume = useEvent(props.onResume)\n const shouldShow = forceMount || open\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n GetProps,\n TamaguiElement,\n composeEventHandlers,\n styled,\n themeable,\n useEvent,\n useId,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounceExclude } from './ToastAnnounce'\nimport { ToastNativePlatform, ToastNativeValue, useToast } from './ToastImperative.js'\nimport {\n ToastImpl,\n ToastImplFrame,\n ToastProps,\n useToastInteractiveContext,\n} from './ToastImpl'\nimport {\n ScopedProps,\n ToastProvider,\n ToastProviderProps,\n createToastScope,\n} from './ToastProvider'\nimport { ToastViewport, ToastViewportProps } from './ToastViewport'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'ToastTitle'\n\nconst ToastTitleFrame = styled(SizableText, {\n name: TITLE_NAME,\n color: '$color',\n variants: {\n unstyled: {\n false: {\n size: '$4',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype PrimitiveDivProps = GetProps<typeof ToastTitleFrame>\ntype ToastTitleProps = PrimitiveDivProps & {}\n\nconst ToastTitle = React.forwardRef<TamaguiElement, ToastTitleProps>(\n (props: ScopedProps<ToastTitleProps>, forwardedRef) => {\n const { __scopeToast, ...titleProps } = props\n return <ToastTitleFrame {...titleProps} ref={forwardedRef} />\n }\n)\n\nToastTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'ToastDescription'\n\nconst ToastDescriptionFrame = styled(SizableText, {\n name: DESCRIPTION_NAME,\n color: '$color11',\n variants: {\n unstyled: {\n false: {\n size: '$1',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype ToastDescriptionFrameProps = GetProps<typeof ToastDescriptionFrame>\ntype ToastDescriptionProps = ToastDescriptionFrameProps & {}\n\nconst ToastDescription = React.forwardRef<TamaguiElement, ToastDescriptionProps>(\n (props: ScopedProps<ToastDescriptionProps>, forwardedRef) => {\n const { __scopeToast, ...descriptionProps } = props\n return <ToastDescriptionFrame {...descriptionProps} ref={forwardedRef} />\n }\n)\n\nToastDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction'\n\ntype ToastActionProps = ToastCloseProps & {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to updgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string\n}\n\nconst ToastAction = React.forwardRef<TamaguiElement, ToastActionProps>(\n (props: ScopedProps<ToastActionProps>, forwardedRef) => {\n const { altText, ...actionProps } = props\n if (!altText) return null\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastAction.propTypes = {\n altText(props) {\n if (!props.altText) {\n return new Error(`Missing prop \\`altText\\` expected on \\`${ACTION_NAME}\\``)\n }\n return null\n },\n}\n\nToastAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose'\n\nconst ToastCloseFrame = styled(ThemeableStack, {\n name: CLOSE_NAME,\n tag: 'button',\n})\ntype ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>\ntype ToastCloseProps = ToastCloseFrameProps & {}\n\nconst ToastClose = React.forwardRef<TamaguiElement, ToastCloseProps>(\n (props: ScopedProps<ToastCloseProps>, forwardedRef) => {\n const { __scopeToast, ...closeProps } = props\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast)\n\n return (\n <ToastAnnounceExclude asChild>\n <ToastCloseFrame\n accessibilityLabel=\"Dialog Close\"\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress as any, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(\n ToastImplFrame.extractable((props: ScopedProps<ToastProps>, forwardedRef) => {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n })\n\n const id = useId()\n const onPause = useEvent(props.onPause)\n const onResume = useEvent(props.onResume)\n const shouldShow = forceMount || open\n\n if (!shouldShow) return null\n\n return (\n <ToastImpl\n id={id}\n open={open}\n {...toastProps}\n ref={forwardedRef}\n onClose={() => setOpen(false)}\n onPause={onPause}\n onResume={onResume}\n onSwipeEnd={composeEventHandlers(props.onSwipeEnd, (event) => {\n setOpen(false)\n })}\n />\n )\n })\n)\n\nToastComponent.displayName = TOAST_NAME\n\nconst Toast = withStaticProperties(\n themeable(ToastComponent, ToastImplFrame.staticConfig),\n {\n Title: ToastTitle,\n Description: ToastDescription,\n Action: ToastAction,\n Close: ToastClose,\n }\n)\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n Toast,\n ToastProvider,\n ToastViewport,\n //\n createToastScope,\n // imperative\n useToast,\n}\nexport type {\n ToastActionProps,\n ToastCloseProps,\n ToastDescriptionProps,\n ToastProps,\n ToastProviderProps,\n ToastTitleProps,\n ToastViewportProps,\n // imperative\n ToastNativeValue,\n ToastNativePlatform,\n}\n"],
|
|
5
|
+
"mappings": "AA0DW;AA1DX;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,YAAY,WAAW;AAEvB,SAAS,kBAAkB;AAC3B,SAAS,4BAA4B;AACrC,SAAgD,gBAAgB;AAChE;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,qBAAyC;AAMlD,MAAM,aAAa;AAEnB,MAAM,kBAAkB,OAAO,aAAa;AAAA,EAC1C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAID,MAAM,aAAa,MAAM;AAAA,EACvB,CAAC,OAAqC,iBAAiB;AACrD,UAAM,EAAE,cAAc,GAAG,WAAW,IAAI;AACxC,WAAO,oBAAC,mBAAiB,GAAG,YA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,QACC,oBAAmB;AAAA,QAClB,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,SAAS,qBAAqB,MAAM,SAAgB,mBAAmB,OAAO;AAAA;AAAA,IAChF,GACF;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;AAMzB,MAAM,iBAAiB,MAAM;AAAA,EAC3B,eAAe,YAAY,CAAC,OAAgC,iBAAiB;AAC3E,UAAM,EAAE,YAAY,MAAM,UAAU,aAAa,cAAc,GAAG,WAAW,IAAI;AACjF,UAAM,CAAC,MAAM,OAAO,IAAI,qBAAqB;AAAA,MAC3C,MAAM;AAAA,MACN,aAAa,eAAe;AAAA,MAC5B,UAAU;AAAA,IACZ,CAAC;AAED,UAAM,KAAK,MAAM;AACjB,UAAM,UAAU,SAAS,MAAM,OAAO;AACtC,UAAM,WAAW,SAAS,MAAM,QAAQ;AACxC,UAAM,aAAa,cAAc;AAEjC,QAAI,CAAC;AAAY,aAAO;AAExB,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,SAAS,MAAM,QAAQ,KAAK;AAAA,QAC5B;AAAA,QACA;AAAA,QACA,YAAY,qBAAqB,MAAM,YAAY,CAAC,UAAU;AAC5D,kBAAQ,KAAK;AAAA,QACf,CAAC;AAAA;AAAA,IACH;AAAA,EAEJ,CAAC;AACH;AAEA,eAAe,cAAc;AAE7B,MAAM,QAAQ;AAAA,EACZ,UAAU,gBAAgB,eAAe,YAAY;AAAA,EACrD;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,6 +3,7 @@ import { createCollection } from "@tamagui/collection";
|
|
|
3
3
|
import { useId } from "@tamagui/core";
|
|
4
4
|
import { createContextScope } from "@tamagui/create-context";
|
|
5
5
|
import * as React from "react";
|
|
6
|
+
import { ToastImperativeProvider } from "./ToastImperative";
|
|
6
7
|
const PROVIDER_NAME = "ToastProvider";
|
|
7
8
|
const [Collection, useCollection, createCollectionScope] = createCollection("Toast");
|
|
8
9
|
const [createToastContext, createToastScope] = createContextScope("Toast", [
|
|
@@ -13,6 +14,9 @@ const ToastProvider = (props) => {
|
|
|
13
14
|
const {
|
|
14
15
|
__scopeToast,
|
|
15
16
|
id: providedId,
|
|
17
|
+
burntOptions,
|
|
18
|
+
native,
|
|
19
|
+
notificationOptions,
|
|
16
20
|
label = "Notification",
|
|
17
21
|
duration = 5e3,
|
|
18
22
|
swipeDirection = "right",
|
|
@@ -24,6 +28,14 @@ const ToastProvider = (props) => {
|
|
|
24
28
|
const [toastCount, setToastCount] = React.useState(0);
|
|
25
29
|
const isFocusedToastEscapeKeyDownRef = React.useRef(false);
|
|
26
30
|
const isClosePausedRef = React.useRef(false);
|
|
31
|
+
const options = React.useMemo(() => {
|
|
32
|
+
return {
|
|
33
|
+
duration,
|
|
34
|
+
burntOptions,
|
|
35
|
+
native,
|
|
36
|
+
notificationOptions
|
|
37
|
+
};
|
|
38
|
+
}, [JSON.stringify([duration, burntOptions, native, notificationOptions])]);
|
|
27
39
|
return /* @__PURE__ */ jsx(Collection.Provider, { scope: __scopeToast, children: /* @__PURE__ */ jsx(
|
|
28
40
|
ToastProviderProvider,
|
|
29
41
|
{
|
|
@@ -44,7 +56,7 @@ const ToastProvider = (props) => {
|
|
|
44
56
|
}, []),
|
|
45
57
|
isFocusedToastEscapeKeyDownRef,
|
|
46
58
|
isClosePausedRef,
|
|
47
|
-
children
|
|
59
|
+
children: /* @__PURE__ */ jsx(ToastImperativeProvider, { options, children })
|
|
48
60
|
}
|
|
49
61
|
) });
|
|
50
62
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ToastProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement, useId } from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement, useId } from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport * as React from 'react'\n\nimport { ToastImperativeProvider, ToastNativeValue } from './ToastImperative'\nimport { BurntToastOptions } from './types'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'ToastProvider'\n\nconst [Collection, useCollection, createCollectionScope] =\n createCollection<TamaguiElement>('Toast')\n\ntype SwipeDirection = 'vertical' | 'up' | 'down' | 'horizontal' | 'left' | 'right'\ntype ToastProviderContextValue = {\n id: string\n label: string\n duration: number\n swipeDirection: SwipeDirection\n swipeThreshold: number\n toastCount: number\n viewport: TamaguiElement | null\n onViewportChange(viewport: TamaguiElement): void\n onToastAdd(): void\n onToastRemove(): void\n isFocusedToastEscapeKeyDownRef: React.MutableRefObject<boolean>\n isClosePausedRef: React.MutableRefObject<boolean>\n}\n\ntype ScopedProps<P> = P & { __scopeToast?: Scope }\nconst [createToastContext, createToastScope] = createContextScope('Toast', [\n createCollectionScope,\n])\nconst [ToastProviderProvider, useToastProviderContext] =\n createToastContext<ToastProviderContextValue>(PROVIDER_NAME)\n\ninterface ToastProviderProps {\n children?: React.ReactNode\n /**\n * An author-localized label for each toast. Used to help screen reader users\n * associate the interruption with a toast.\n * @defaultValue 'Notification'\n */\n label?: string\n /**\n * Time in milliseconds that each toast should remain visible for.\n * @defaultValue 5000\n */\n duration?: number\n /**\n * Direction of pointer swipe that should close the toast.\n * @defaultValue 'right'\n */\n swipeDirection?: SwipeDirection\n /**\n * Distance in pixels that the swipe must pass before a close is triggered.\n * @defaultValue 50\n */\n swipeThreshold?: number\n /**\n * @defaultValue unique generated identifier\n */\n id?: string\n /**\n * Will show a native toast if is true or is set to the current platform. On iOS, it wraps `SPIndicator` and `SPAlert`. On Android, it wraps `ToastAndroid`. On web, it wraps Notification API. Mobile's native features are handled by `burnt`.\n * Only works with the imperative `useToast` hook.\n */\n native?: ToastNativeValue\n /**\n * Options for the burnt package if you're using native toasts on mobile\n */\n burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>\n /**\n * Options for the notification API if you're using native toasts on web\n */\n notificationOptions?: NotificationOptions\n}\n\nconst ToastProvider: React.FC<ToastProviderProps> = (\n props: ScopedProps<ToastProviderProps>\n) => {\n const {\n __scopeToast,\n id: providedId,\n burntOptions,\n native,\n notificationOptions,\n label = 'Notification',\n duration = 5000,\n swipeDirection = 'right',\n swipeThreshold = 50,\n children,\n } = props\n const id = providedId ?? useId()\n const [viewport, setViewport] = React.useState<TamaguiElement | null>(null)\n const [toastCount, setToastCount] = React.useState(0)\n const isFocusedToastEscapeKeyDownRef = React.useRef(false)\n const isClosePausedRef = React.useRef(false)\n\n // memo context to avoid expensive re-renders\n const options = React.useMemo(() => {\n return {\n duration,\n burntOptions,\n native,\n notificationOptions,\n }\n // nested simple object so JSON.stringify\n }, [JSON.stringify([duration, burntOptions, native, notificationOptions])])\n\n return (\n <Collection.Provider scope={__scopeToast}>\n <ToastProviderProvider\n scope={__scopeToast}\n id={id}\n label={label}\n duration={duration}\n swipeDirection={swipeDirection}\n swipeThreshold={swipeThreshold}\n toastCount={toastCount}\n viewport={viewport}\n onViewportChange={setViewport}\n onToastAdd={React.useCallback(() => {\n setToastCount((prevCount) => prevCount + 1)\n }, [])}\n onToastRemove={React.useCallback(() => {\n setToastCount((prevCount) => prevCount - 1)\n }, [])}\n isFocusedToastEscapeKeyDownRef={isFocusedToastEscapeKeyDownRef}\n isClosePausedRef={isClosePausedRef}\n >\n <ToastImperativeProvider options={options}>{children}</ToastImperativeProvider>\n </ToastProviderProvider>\n </Collection.Provider>\n )\n}\n\nToastProvider.propTypes = {\n label(props) {\n if (props.label && typeof props.label === 'string' && !props.label.trim()) {\n const error = `Invalid prop \\`label\\` supplied to \\`${PROVIDER_NAME}\\`. Expected non-empty \\`string\\`.`\n return new Error(error)\n }\n return null\n },\n}\n\nToastProvider.displayName = PROVIDER_NAME\n\nexport {\n Collection,\n ToastProvider,\n createToastContext,\n createToastScope,\n useCollection,\n useToastProviderContext,\n}\nexport type { ScopedProps, SwipeDirection, ToastProviderProps }\n"],
|
|
5
|
+
"mappings": "AAwIQ;AAxIR,SAAS,wBAAwB;AACjC,SAAyB,aAAa;AAEtC,SAAS,0BAA0B;AACnC,YAAY,WAAW;AAEvB,SAAS,+BAAiD;AAO1D,MAAM,gBAAgB;AAEtB,MAAM,CAAC,YAAY,eAAe,qBAAqB,IACrD,iBAAiC,OAAO;AAmB1C,MAAM,CAAC,oBAAoB,gBAAgB,IAAI,mBAAmB,SAAS;AAAA,EACzE;AACF,CAAC;AACD,MAAM,CAAC,uBAAuB,uBAAuB,IACnD,mBAA8C,aAAa;AA4C7D,MAAM,gBAA8C,CAClD,UACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,IACjB;AAAA,EACF,IAAI;AACJ,QAAM,KAAK,cAAc,MAAM;AAC/B,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAgC,IAAI;AAC1E,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,CAAC;AACpD,QAAM,iCAAiC,MAAM,OAAO,KAAK;AACzD,QAAM,mBAAmB,MAAM,OAAO,KAAK;AAG3C,QAAM,UAAU,MAAM,QAAQ,MAAM;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAEF,GAAG,CAAC,KAAK,UAAU,CAAC,UAAU,cAAc,QAAQ,mBAAmB,CAAC,CAAC,CAAC;AAE1E,SACE,oBAAC,WAAW,UAAX,EAAoB,OAAO,cAC1B;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,kBAAkB;AAAA,MAClB,YAAY,MAAM,YAAY,MAAM;AAClC,sBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,MAC5C,GAAG,CAAC,CAAC;AAAA,MACL,eAAe,MAAM,YAAY,MAAM;AACrC,sBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,MAC5C,GAAG,CAAC,CAAC;AAAA,MACL;AAAA,MACA;AAAA,MAEA,8BAAC,2BAAwB,SAAmB,UAAS;AAAA;AAAA,EACvD,GACF;AAEJ;AAEA,cAAc,YAAY;AAAA,EACxB,MAAM,OAAO;AACX,QAAI,MAAM,SAAS,OAAO,MAAM,UAAU,YAAY,CAAC,MAAM,MAAM,KAAK,GAAG;AACzE,YAAM,QAAQ,wCAAwC;AACtD,aAAO,IAAI,MAAM,KAAK;AAAA,IACxB;AACA,WAAO;AAAA,EACT;AACF;AAEA,cAAc,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,6 +3,7 @@ import { createCollection } from "@tamagui/collection";
|
|
|
3
3
|
import { useId } from "@tamagui/core";
|
|
4
4
|
import { createContextScope } from "@tamagui/create-context";
|
|
5
5
|
import * as React from "react";
|
|
6
|
+
import { ToastImperativeProvider } from "./ToastImperative";
|
|
6
7
|
const PROVIDER_NAME = "ToastProvider";
|
|
7
8
|
const [Collection, useCollection, createCollectionScope] = createCollection("Toast");
|
|
8
9
|
const [createToastContext, createToastScope] = createContextScope("Toast", [
|
|
@@ -13,6 +14,9 @@ const ToastProvider = (props) => {
|
|
|
13
14
|
const {
|
|
14
15
|
__scopeToast,
|
|
15
16
|
id: providedId,
|
|
17
|
+
burntOptions,
|
|
18
|
+
native,
|
|
19
|
+
notificationOptions,
|
|
16
20
|
label = "Notification",
|
|
17
21
|
duration = 5e3,
|
|
18
22
|
swipeDirection = "right",
|
|
@@ -24,6 +28,14 @@ const ToastProvider = (props) => {
|
|
|
24
28
|
const [toastCount, setToastCount] = React.useState(0);
|
|
25
29
|
const isFocusedToastEscapeKeyDownRef = React.useRef(false);
|
|
26
30
|
const isClosePausedRef = React.useRef(false);
|
|
31
|
+
const options = React.useMemo(() => {
|
|
32
|
+
return {
|
|
33
|
+
duration,
|
|
34
|
+
burntOptions,
|
|
35
|
+
native,
|
|
36
|
+
notificationOptions
|
|
37
|
+
};
|
|
38
|
+
}, [JSON.stringify([duration, burntOptions, native, notificationOptions])]);
|
|
27
39
|
return /* @__PURE__ */ jsx(Collection.Provider, { scope: __scopeToast, children: /* @__PURE__ */ jsx(
|
|
28
40
|
ToastProviderProvider,
|
|
29
41
|
{
|
|
@@ -44,7 +56,7 @@ const ToastProvider = (props) => {
|
|
|
44
56
|
}, []),
|
|
45
57
|
isFocusedToastEscapeKeyDownRef,
|
|
46
58
|
isClosePausedRef,
|
|
47
|
-
children
|
|
59
|
+
children: /* @__PURE__ */ jsx(ToastImperativeProvider, { options, children })
|
|
48
60
|
}
|
|
49
61
|
) });
|
|
50
62
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ToastProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement, useId } from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement, useId } from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport * as React from 'react'\n\nimport { ToastImperativeProvider, ToastNativeValue } from './ToastImperative'\nimport { BurntToastOptions } from './types'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'ToastProvider'\n\nconst [Collection, useCollection, createCollectionScope] =\n createCollection<TamaguiElement>('Toast')\n\ntype SwipeDirection = 'vertical' | 'up' | 'down' | 'horizontal' | 'left' | 'right'\ntype ToastProviderContextValue = {\n id: string\n label: string\n duration: number\n swipeDirection: SwipeDirection\n swipeThreshold: number\n toastCount: number\n viewport: TamaguiElement | null\n onViewportChange(viewport: TamaguiElement): void\n onToastAdd(): void\n onToastRemove(): void\n isFocusedToastEscapeKeyDownRef: React.MutableRefObject<boolean>\n isClosePausedRef: React.MutableRefObject<boolean>\n}\n\ntype ScopedProps<P> = P & { __scopeToast?: Scope }\nconst [createToastContext, createToastScope] = createContextScope('Toast', [\n createCollectionScope,\n])\nconst [ToastProviderProvider, useToastProviderContext] =\n createToastContext<ToastProviderContextValue>(PROVIDER_NAME)\n\ninterface ToastProviderProps {\n children?: React.ReactNode\n /**\n * An author-localized label for each toast. Used to help screen reader users\n * associate the interruption with a toast.\n * @defaultValue 'Notification'\n */\n label?: string\n /**\n * Time in milliseconds that each toast should remain visible for.\n * @defaultValue 5000\n */\n duration?: number\n /**\n * Direction of pointer swipe that should close the toast.\n * @defaultValue 'right'\n */\n swipeDirection?: SwipeDirection\n /**\n * Distance in pixels that the swipe must pass before a close is triggered.\n * @defaultValue 50\n */\n swipeThreshold?: number\n /**\n * @defaultValue unique generated identifier\n */\n id?: string\n /**\n * Will show a native toast if is true or is set to the current platform. On iOS, it wraps `SPIndicator` and `SPAlert`. On Android, it wraps `ToastAndroid`. On web, it wraps Notification API. Mobile's native features are handled by `burnt`.\n * Only works with the imperative `useToast` hook.\n */\n native?: ToastNativeValue\n /**\n * Options for the burnt package if you're using native toasts on mobile\n */\n burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>\n /**\n * Options for the notification API if you're using native toasts on web\n */\n notificationOptions?: NotificationOptions\n}\n\nconst ToastProvider: React.FC<ToastProviderProps> = (\n props: ScopedProps<ToastProviderProps>\n) => {\n const {\n __scopeToast,\n id: providedId,\n burntOptions,\n native,\n notificationOptions,\n label = 'Notification',\n duration = 5000,\n swipeDirection = 'right',\n swipeThreshold = 50,\n children,\n } = props\n const id = providedId ?? useId()\n const [viewport, setViewport] = React.useState<TamaguiElement | null>(null)\n const [toastCount, setToastCount] = React.useState(0)\n const isFocusedToastEscapeKeyDownRef = React.useRef(false)\n const isClosePausedRef = React.useRef(false)\n\n // memo context to avoid expensive re-renders\n const options = React.useMemo(() => {\n return {\n duration,\n burntOptions,\n native,\n notificationOptions,\n }\n // nested simple object so JSON.stringify\n }, [JSON.stringify([duration, burntOptions, native, notificationOptions])])\n\n return (\n <Collection.Provider scope={__scopeToast}>\n <ToastProviderProvider\n scope={__scopeToast}\n id={id}\n label={label}\n duration={duration}\n swipeDirection={swipeDirection}\n swipeThreshold={swipeThreshold}\n toastCount={toastCount}\n viewport={viewport}\n onViewportChange={setViewport}\n onToastAdd={React.useCallback(() => {\n setToastCount((prevCount) => prevCount + 1)\n }, [])}\n onToastRemove={React.useCallback(() => {\n setToastCount((prevCount) => prevCount - 1)\n }, [])}\n isFocusedToastEscapeKeyDownRef={isFocusedToastEscapeKeyDownRef}\n isClosePausedRef={isClosePausedRef}\n >\n <ToastImperativeProvider options={options}>{children}</ToastImperativeProvider>\n </ToastProviderProvider>\n </Collection.Provider>\n )\n}\n\nToastProvider.propTypes = {\n label(props) {\n if (props.label && typeof props.label === 'string' && !props.label.trim()) {\n const error = `Invalid prop \\`label\\` supplied to \\`${PROVIDER_NAME}\\`. Expected non-empty \\`string\\`.`\n return new Error(error)\n }\n return null\n },\n}\n\nToastProvider.displayName = PROVIDER_NAME\n\nexport {\n Collection,\n ToastProvider,\n createToastContext,\n createToastScope,\n useCollection,\n useToastProviderContext,\n}\nexport type { ScopedProps, SwipeDirection, ToastProviderProps }\n"],
|
|
5
|
+
"mappings": "AAwIQ;AAx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L,eAAe,MAAM,YAAY,MAAM;AACrC,sBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,MAC5C,GAAG,CAAC,CAAC;AAAA,MACL;AAAA,MACA;AAAA,MAEA,8BAAC,2BAAwB,SAAmB,UAAS;AAAA;AAAA,EACvD,GACF;AAEJ;AAEA,cAAc,YAAY;AAAA,EACxB,MAAM,OAAO;AACX,QAAI,MAAM,SAAS,OAAO,MAAM,UAAU,YAAY,CAAC,MAAM,MAAM,KAAK,GAAG;AACzE,YAAM,QAAQ,wCAAwC;AACtD,aAAO,IAAI,MAAM,KAAK;AAAA,IACxB;AACA,WAAO;AAAA,EACT;AACF;AAEA,cAAc,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Toast'\
|
|
5
|
-
"mappings": "AAAA,cAAc;
|
|
4
|
+
"sourcesContent": ["export * from './Toast.js'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.mjs
CHANGED
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Toast'\
|
|
5
|
-
"mappings": "AAAA,cAAc;
|
|
4
|
+
"sourcesContent": ["export * from './Toast.js'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/Toast.js
CHANGED
|
@@ -12,6 +12,7 @@ import { useControllableState } from "@tamagui/use-controllable-state";
|
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
import { TOAST_NAME } from "./constants";
|
|
14
14
|
import { ToastAnnounceExclude } from "./ToastAnnounce";
|
|
15
|
+
import { useToast } from "./ToastImperative.js";
|
|
15
16
|
import {
|
|
16
17
|
ToastImpl,
|
|
17
18
|
ToastImplFrame,
|
|
@@ -144,6 +145,7 @@ export {
|
|
|
144
145
|
Toast,
|
|
145
146
|
ToastProvider,
|
|
146
147
|
ToastViewport,
|
|
147
|
-
createToastScope
|
|
148
|
+
createToastScope,
|
|
149
|
+
useToast
|
|
148
150
|
};
|
|
149
151
|
//# sourceMappingURL=Toast.js.map
|
package/dist/jsx/Toast.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Toast.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n GetProps,\n TamaguiElement,\n composeEventHandlers,\n styled,\n themeable,\n useEvent,\n useId,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounceExclude } from './ToastAnnounce'\nimport {\n ToastImpl,\n ToastImplFrame,\n ToastProps,\n useToastInteractiveContext,\n} from './ToastImpl'\nimport {\n ScopedProps,\n ToastProvider,\n ToastProviderProps,\n createToastScope,\n} from './ToastProvider'\nimport { ToastViewport, ToastViewportProps } from './ToastViewport'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'ToastTitle'\n\nconst ToastTitleFrame = styled(SizableText, {\n name: TITLE_NAME,\n color: '$color',\n variants: {\n unstyled: {\n false: {\n size: '$4',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype PrimitiveDivProps = GetProps<typeof ToastTitleFrame>\ntype ToastTitleProps = PrimitiveDivProps & {}\n\nconst ToastTitle = React.forwardRef<TamaguiElement, ToastTitleProps>(\n (props: ScopedProps<ToastTitleProps>, forwardedRef) => {\n const { __scopeToast, ...titleProps } = props\n return <ToastTitleFrame {...titleProps} ref={forwardedRef} />\n }\n)\n\nToastTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'ToastDescription'\n\nconst ToastDescriptionFrame = styled(SizableText, {\n name: DESCRIPTION_NAME,\n color: '$color11',\n variants: {\n unstyled: {\n false: {\n size: '$1',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype ToastDescriptionFrameProps = GetProps<typeof ToastDescriptionFrame>\ntype ToastDescriptionProps = ToastDescriptionFrameProps & {}\n\nconst ToastDescription = React.forwardRef<TamaguiElement, ToastDescriptionProps>(\n (props: ScopedProps<ToastDescriptionProps>, forwardedRef) => {\n const { __scopeToast, ...descriptionProps } = props\n return <ToastDescriptionFrame {...descriptionProps} ref={forwardedRef} />\n }\n)\n\nToastDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction'\n\ntype ToastActionProps = ToastCloseProps & {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to updgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string\n}\n\nconst ToastAction = React.forwardRef<TamaguiElement, ToastActionProps>(\n (props: ScopedProps<ToastActionProps>, forwardedRef) => {\n const { altText, ...actionProps } = props\n if (!altText) return null\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastAction.propTypes = {\n altText(props) {\n if (!props.altText) {\n return new Error(`Missing prop \\`altText\\` expected on \\`${ACTION_NAME}\\``)\n }\n return null\n },\n}\n\nToastAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose'\n\nconst ToastCloseFrame = styled(ThemeableStack, {\n name: CLOSE_NAME,\n tag: 'button',\n})\ntype ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>\ntype ToastCloseProps = ToastCloseFrameProps & {}\n\nconst ToastClose = React.forwardRef<TamaguiElement, ToastCloseProps>(\n (props: ScopedProps<ToastCloseProps>, forwardedRef) => {\n const { __scopeToast, ...closeProps } = props\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast)\n\n return (\n <ToastAnnounceExclude asChild>\n <ToastCloseFrame\n accessibilityLabel=\"Dialog Close\"\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress as any, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(\n ToastImplFrame.extractable((props: ScopedProps<ToastProps>, forwardedRef) => {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n })\n\n const id = useId()\n const onPause = useEvent(props.onPause)\n const onResume = useEvent(props.onResume)\n const shouldShow = forceMount || open\n
|
|
5
|
-
"mappings": "AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,YAAY,WAAW;AAEvB,SAAS,kBAAkB;AAC3B,SAAS,4BAA4B;AACrC;AAAA,EACE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AA,MACf,CAAC;AAAA,IACH;AAAA,EAEJ,CAAC;AACH;AAEA,eAAe,cAAc;AAE7B,MAAM,QAAQ;AAAA,EACZ,UAAU,gBAAgB,eAAe,YAAY;AAAA,EACrD;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;",
|
|
4
|
+
"sourcesContent": ["import {\n GetProps,\n TamaguiElement,\n composeEventHandlers,\n styled,\n themeable,\n useEvent,\n useId,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounceExclude } from './ToastAnnounce'\nimport { ToastNativePlatform, ToastNativeValue, useToast } from './ToastImperative.js'\nimport {\n ToastImpl,\n ToastImplFrame,\n ToastProps,\n useToastInteractiveContext,\n} from './ToastImpl'\nimport {\n ScopedProps,\n ToastProvider,\n ToastProviderProps,\n createToastScope,\n} from './ToastProvider'\nimport { ToastViewport, ToastViewportProps } from './ToastViewport'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'ToastTitle'\n\nconst ToastTitleFrame = styled(SizableText, {\n name: TITLE_NAME,\n color: '$color',\n variants: {\n unstyled: {\n false: {\n size: '$4',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype PrimitiveDivProps = GetProps<typeof ToastTitleFrame>\ntype ToastTitleProps = PrimitiveDivProps & {}\n\nconst ToastTitle = React.forwardRef<TamaguiElement, ToastTitleProps>(\n (props: ScopedProps<ToastTitleProps>, forwardedRef) => {\n const { __scopeToast, ...titleProps } = props\n return <ToastTitleFrame {...titleProps} ref={forwardedRef} />\n }\n)\n\nToastTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'ToastDescription'\n\nconst ToastDescriptionFrame = styled(SizableText, {\n name: DESCRIPTION_NAME,\n color: '$color11',\n variants: {\n unstyled: {\n false: {\n size: '$1',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype ToastDescriptionFrameProps = GetProps<typeof ToastDescriptionFrame>\ntype ToastDescriptionProps = ToastDescriptionFrameProps & {}\n\nconst ToastDescription = React.forwardRef<TamaguiElement, ToastDescriptionProps>(\n (props: ScopedProps<ToastDescriptionProps>, forwardedRef) => {\n const { __scopeToast, ...descriptionProps } = props\n return <ToastDescriptionFrame {...descriptionProps} ref={forwardedRef} />\n }\n)\n\nToastDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction'\n\ntype ToastActionProps = ToastCloseProps & {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to updgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string\n}\n\nconst ToastAction = React.forwardRef<TamaguiElement, ToastActionProps>(\n (props: ScopedProps<ToastActionProps>, forwardedRef) => {\n const { altText, ...actionProps } = props\n if (!altText) return null\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastAction.propTypes = {\n altText(props) {\n if (!props.altText) {\n return new Error(`Missing prop \\`altText\\` expected on \\`${ACTION_NAME}\\``)\n }\n return null\n },\n}\n\nToastAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose'\n\nconst ToastCloseFrame = styled(ThemeableStack, {\n name: CLOSE_NAME,\n tag: 'button',\n})\ntype ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>\ntype ToastCloseProps = ToastCloseFrameProps & {}\n\nconst ToastClose = React.forwardRef<TamaguiElement, ToastCloseProps>(\n (props: ScopedProps<ToastCloseProps>, forwardedRef) => {\n const { __scopeToast, ...closeProps } = props\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast)\n\n return (\n <ToastAnnounceExclude asChild>\n <ToastCloseFrame\n accessibilityLabel=\"Dialog Close\"\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress as any, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(\n ToastImplFrame.extractable((props: ScopedProps<ToastProps>, forwardedRef) => {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n })\n\n const id = useId()\n const onPause = useEvent(props.onPause)\n const onResume = useEvent(props.onResume)\n const shouldShow = forceMount || open\n\n if (!shouldShow) return null\n\n return (\n <ToastImpl\n id={id}\n open={open}\n {...toastProps}\n ref={forwardedRef}\n onClose={() => setOpen(false)}\n onPause={onPause}\n onResume={onResume}\n onSwipeEnd={composeEventHandlers(props.onSwipeEnd, (event) => {\n setOpen(false)\n })}\n />\n )\n })\n)\n\nToastComponent.displayName = TOAST_NAME\n\nconst Toast = withStaticProperties(\n themeable(ToastComponent, ToastImplFrame.staticConfig),\n {\n Title: ToastTitle,\n Description: ToastDescription,\n Action: ToastAction,\n Close: ToastClose,\n }\n)\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n Toast,\n ToastProvider,\n ToastViewport,\n //\n createToastScope,\n // imperative\n useToast,\n}\nexport type {\n ToastActionProps,\n ToastCloseProps,\n ToastDescriptionProps,\n ToastProps,\n ToastProviderProps,\n ToastTitleProps,\n ToastViewportProps,\n // imperative\n ToastNativeValue,\n ToastNativePlatform,\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,YAAY,WAAW;AAEvB,SAAS,kBAAkB;AAC3B,SAAS,4BAA4B;AACrC,SAAgD,gBAAgB;AAChE;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,qBAAyC;AAMlD,MAAM,aAAa;AAEnB,MAAM,kBAAkB,OAAO,aAAa;AAAA,EAC1C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAID,MAAM,aAAa,MAAM;AAAA,EACvB,CAAC,OAAqC,iBAAiB;AACrD,UAAM,EAAE,cAAc,GAAG,WAAW,IAAI;AACxC,WAAO,CAAC,oBAAoB,YAAY,KAAK,cAAc;AAAA,EAC7D;AACF;AAEA,WAAW,cAAc;AAMzB,MAAM,mBAAmB;AAEzB,MAAM,wBAAwB,OAAO,aAAa;AAAA,EAChD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAID,MAAM,mBAAmB,MAAM;AAAA,EAC7B,CAAC,OAA2C,iB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AC5B,UAAU;AAAA,IACZ,CAAC;AAED,UAAM,KAAK,MAAM;AACjB,UAAM,UAAU,SAAS,MAAM,OAAO;AACtC,UAAM,WAAW,SAAS,MAAM,QAAQ;AACxC,UAAM,aAAa,cAAc;AAEjC,QAAI,CAAC;AAAY,aAAO;AAExB,WACE,CAAC;AAAA,MACC,IAAI;AAAA,MACJ,MAAM;AAAA,UACF;AAAA,MACJ,KAAK;AAAA,MACL,SAAS,MAAM,QAAQ,KAAK;AAAA,MAC5B,SAAS;AAAA,MACT,UAAU;AAAA,MACV,YAAY,qBAAqB,MAAM,YAAY,CAAC,UAAU;AAC5D,gBAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AAAA,EAEJ,CAAC;AACH;AAEA,eAAe,cAAc;AAE7B,MAAM,QAAQ;AAAA,EACZ,UAAU,gBAAgB,eAAe,YAAY;AAAA,EACrD;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/Toast.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { useControllableState } from "@tamagui/use-controllable-state";
|
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
import { TOAST_NAME } from "./constants";
|
|
14
14
|
import { ToastAnnounceExclude } from "./ToastAnnounce";
|
|
15
|
+
import { useToast } from "./ToastImperative.js";
|
|
15
16
|
import {
|
|
16
17
|
ToastImpl,
|
|
17
18
|
ToastImplFrame,
|
|
@@ -144,6 +145,7 @@ export {
|
|
|
144
145
|
Toast,
|
|
145
146
|
ToastProvider,
|
|
146
147
|
ToastViewport,
|
|
147
|
-
createToastScope
|
|
148
|
+
createToastScope,
|
|
149
|
+
useToast
|
|
148
150
|
};
|
|
149
151
|
//# sourceMappingURL=Toast.mjs.map
|
package/dist/jsx/Toast.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Toast.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n GetProps,\n TamaguiElement,\n composeEventHandlers,\n styled,\n themeable,\n useEvent,\n useId,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounceExclude } from './ToastAnnounce'\nimport {\n ToastImpl,\n ToastImplFrame,\n ToastProps,\n useToastInteractiveContext,\n} from './ToastImpl'\nimport {\n ScopedProps,\n ToastProvider,\n ToastProviderProps,\n createToastScope,\n} from './ToastProvider'\nimport { ToastViewport, ToastViewportProps } from './ToastViewport'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'ToastTitle'\n\nconst ToastTitleFrame = styled(SizableText, {\n name: TITLE_NAME,\n color: '$color',\n variants: {\n unstyled: {\n false: {\n size: '$4',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype PrimitiveDivProps = GetProps<typeof ToastTitleFrame>\ntype ToastTitleProps = PrimitiveDivProps & {}\n\nconst ToastTitle = React.forwardRef<TamaguiElement, ToastTitleProps>(\n (props: ScopedProps<ToastTitleProps>, forwardedRef) => {\n const { __scopeToast, ...titleProps } = props\n return <ToastTitleFrame {...titleProps} ref={forwardedRef} />\n }\n)\n\nToastTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'ToastDescription'\n\nconst ToastDescriptionFrame = styled(SizableText, {\n name: DESCRIPTION_NAME,\n color: '$color11',\n variants: {\n unstyled: {\n false: {\n size: '$1',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype ToastDescriptionFrameProps = GetProps<typeof ToastDescriptionFrame>\ntype ToastDescriptionProps = ToastDescriptionFrameProps & {}\n\nconst ToastDescription = React.forwardRef<TamaguiElement, ToastDescriptionProps>(\n (props: ScopedProps<ToastDescriptionProps>, forwardedRef) => {\n const { __scopeToast, ...descriptionProps } = props\n return <ToastDescriptionFrame {...descriptionProps} ref={forwardedRef} />\n }\n)\n\nToastDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction'\n\ntype ToastActionProps = ToastCloseProps & {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to updgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string\n}\n\nconst ToastAction = React.forwardRef<TamaguiElement, ToastActionProps>(\n (props: ScopedProps<ToastActionProps>, forwardedRef) => {\n const { altText, ...actionProps } = props\n if (!altText) return null\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastAction.propTypes = {\n altText(props) {\n if (!props.altText) {\n return new Error(`Missing prop \\`altText\\` expected on \\`${ACTION_NAME}\\``)\n }\n return null\n },\n}\n\nToastAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose'\n\nconst ToastCloseFrame = styled(ThemeableStack, {\n name: CLOSE_NAME,\n tag: 'button',\n})\ntype ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>\ntype ToastCloseProps = ToastCloseFrameProps & {}\n\nconst ToastClose = React.forwardRef<TamaguiElement, ToastCloseProps>(\n (props: ScopedProps<ToastCloseProps>, forwardedRef) => {\n const { __scopeToast, ...closeProps } = props\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast)\n\n return (\n <ToastAnnounceExclude asChild>\n <ToastCloseFrame\n accessibilityLabel=\"Dialog Close\"\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress as any, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(\n ToastImplFrame.extractable((props: ScopedProps<ToastProps>, forwardedRef) => {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n })\n\n const id = useId()\n const onPause = useEvent(props.onPause)\n const onResume = useEvent(props.onResume)\n const shouldShow = forceMount || open\n
|
|
5
|
-
"mappings": "AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,YAAY,WAAW;AAEvB,SAAS,kBAAkB;AAC3B,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,qBAAyC;AAMlD,MAAM,aAAa;AAEnB,MAAM,kBAAkB,OAAO,aAAa;AAAA,EAC1C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAID,MAAM,aAAa,MAAM;AAAA,EACvB,CAAC,OAAqC,iBAAiB;AACrD,UAAM,EAAE,cAAc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pB,CAAC;AAAA,MACC,mBAAmB;AAAA,UACf;AAAA,MACJ,KAAK;AAAA,MACL,SAAS,qBAAqB,MAAM,SAAgB,mBAAmB,OAAO;AAAA,IAChF,EACF,EAPC;AAAA,EASL;AACF;AAEA,WAAW,cAAc;AAMzB,MAAM,iBAAiB,MAAM;AAAA,EAC3B,eAAe,YAAY,CAAC,OAAgC,iBAAiB;AAC3E,UAAM,EAAE,YAAY,MAAM,UAAU,aAAa,cAAc,GAAG,WAAW,IAAI;AACjF,UAAM,CAAC,MAAM,OAAO,IAAI,qBAAqB;AAAA,MAC3C,MAAM;AAAA,MACN,aAAa,eAAe;AAAA,MAC5B,UAAU;AAAA,IACZ,CAAC;AAED,UAAM,KAAK,MAAM;AACjB,UAAM,UAAU,SAAS,MAAM,OAAO;AACtC,UAAM,WAAW,SAAS,MAAM,QAAQ;AACxC,UAAM,aAAa,cAAc;AAEjC,QAAI,CAAC;AAAY,aAAO;AAExB,WACE,CAAC;AAAA,MACC,IAAI;AAAA,MACJ,MAAM;AAAA,UACF;AAAA,MACJ,KAAK;AAAA,MACL,SAAS,MAAM,QAAQ,KAAK;AAAA,MAC5B,SAAS;AAAA,MACT,UAAU;AAAA,MACV,YAAY,qBAAqB,MAAM,YAAY,CAAC,UAAU;AAC5D,gBAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AAAA,EAEJ,CAAC;AACH;AAEA,eAAe,cAAc;AAE7B,MAAM,QAAQ;AAAA,EACZ,UAAU,gBAAgB,eAAe,YAAY;AAAA,EACrD;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;",
|
|
4
|
+
"sourcesContent": ["import {\n GetProps,\n TamaguiElement,\n composeEventHandlers,\n styled,\n themeable,\n useEvent,\n useId,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText } from '@tamagui/text'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounceExclude } from './ToastAnnounce'\nimport { ToastNativePlatform, ToastNativeValue, useToast } from './ToastImperative.js'\nimport {\n ToastImpl,\n ToastImplFrame,\n ToastProps,\n useToastInteractiveContext,\n} from './ToastImpl'\nimport {\n ScopedProps,\n ToastProvider,\n ToastProviderProps,\n createToastScope,\n} from './ToastProvider'\nimport { ToastViewport, ToastViewportProps } from './ToastViewport'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastTitle\n * -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_NAME = 'ToastTitle'\n\nconst ToastTitleFrame = styled(SizableText, {\n name: TITLE_NAME,\n color: '$color',\n variants: {\n unstyled: {\n false: {\n size: '$4',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype PrimitiveDivProps = GetProps<typeof ToastTitleFrame>\ntype ToastTitleProps = PrimitiveDivProps & {}\n\nconst ToastTitle = React.forwardRef<TamaguiElement, ToastTitleProps>(\n (props: ScopedProps<ToastTitleProps>, forwardedRef) => {\n const { __scopeToast, ...titleProps } = props\n return <ToastTitleFrame {...titleProps} ref={forwardedRef} />\n }\n)\n\nToastTitle.displayName = TITLE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastDescription\n * -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_NAME = 'ToastDescription'\n\nconst ToastDescriptionFrame = styled(SizableText, {\n name: DESCRIPTION_NAME,\n color: '$color11',\n variants: {\n unstyled: {\n false: {\n size: '$1',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\n})\ntype ToastDescriptionFrameProps = GetProps<typeof ToastDescriptionFrame>\ntype ToastDescriptionProps = ToastDescriptionFrameProps & {}\n\nconst ToastDescription = React.forwardRef<TamaguiElement, ToastDescriptionProps>(\n (props: ScopedProps<ToastDescriptionProps>, forwardedRef) => {\n const { __scopeToast, ...descriptionProps } = props\n return <ToastDescriptionFrame {...descriptionProps} ref={forwardedRef} />\n }\n)\n\nToastDescription.displayName = DESCRIPTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastAction\n * -----------------------------------------------------------------------------------------------*/\n\nconst ACTION_NAME = 'ToastAction'\n\ntype ToastActionProps = ToastCloseProps & {\n /**\n * A short description for an alternate way to carry out the action. For screen reader users\n * who will not be able to navigate to the button easily/quickly.\n * @example <ToastAction altText=\"Goto account settings to updgrade\">Upgrade</ToastAction>\n * @example <ToastAction altText=\"Undo (Alt+U)\">Undo</ToastAction>\n */\n altText: string\n}\n\nconst ToastAction = React.forwardRef<TamaguiElement, ToastActionProps>(\n (props: ScopedProps<ToastActionProps>, forwardedRef) => {\n const { altText, ...actionProps } = props\n if (!altText) return null\n return (\n <ToastAnnounceExclude altText={altText} asChild>\n <ToastClose {...actionProps} ref={forwardedRef} />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastAction.propTypes = {\n altText(props) {\n if (!props.altText) {\n return new Error(`Missing prop \\`altText\\` expected on \\`${ACTION_NAME}\\``)\n }\n return null\n },\n}\n\nToastAction.displayName = ACTION_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * ToastClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'ToastClose'\n\nconst ToastCloseFrame = styled(ThemeableStack, {\n name: CLOSE_NAME,\n tag: 'button',\n})\ntype ToastCloseFrameProps = GetProps<typeof ToastCloseFrame>\ntype ToastCloseProps = ToastCloseFrameProps & {}\n\nconst ToastClose = React.forwardRef<TamaguiElement, ToastCloseProps>(\n (props: ScopedProps<ToastCloseProps>, forwardedRef) => {\n const { __scopeToast, ...closeProps } = props\n const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast)\n\n return (\n <ToastAnnounceExclude asChild>\n <ToastCloseFrame\n accessibilityLabel=\"Dialog Close\"\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress as any, interactiveContext.onClose)}\n />\n </ToastAnnounceExclude>\n )\n }\n)\n\nToastClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Toast\n * -----------------------------------------------------------------------------------------------*/\n\nconst ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(\n ToastImplFrame.extractable((props: ScopedProps<ToastProps>, forwardedRef) => {\n const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n })\n\n const id = useId()\n const onPause = useEvent(props.onPause)\n const onResume = useEvent(props.onResume)\n const shouldShow = forceMount || open\n\n if (!shouldShow) return null\n\n return (\n <ToastImpl\n id={id}\n open={open}\n {...toastProps}\n ref={forwardedRef}\n onClose={() => setOpen(false)}\n onPause={onPause}\n onResume={onResume}\n onSwipeEnd={composeEventHandlers(props.onSwipeEnd, (event) => {\n setOpen(false)\n })}\n />\n )\n })\n)\n\nToastComponent.displayName = TOAST_NAME\n\nconst Toast = withStaticProperties(\n themeable(ToastComponent, ToastImplFrame.staticConfig),\n {\n Title: ToastTitle,\n Description: ToastDescription,\n Action: ToastAction,\n Close: ToastClose,\n }\n)\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n Toast,\n ToastProvider,\n ToastViewport,\n //\n createToastScope,\n // imperative\n useToast,\n}\nexport type {\n ToastActionProps,\n ToastCloseProps,\n ToastDescriptionProps,\n ToastProps,\n ToastProviderProps,\n ToastTitleProps,\n ToastViewportProps,\n // imperative\n ToastNativeValue,\n ToastNativePlatform,\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,YAAY,WAAW;AAEvB,SAAS,kBAAkB;AAC3B,SAAS,4BAA4B;AACrC,SAAgD,gBAAgB;AAChE;AAAA,EACE;AAAA,EACA;A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;AAAA,IACH;AAAA,EAEJ,CAAC;AACH;AAEA,eAAe,cAAc;AAE7B,MAAM,QAAQ;AAAA,EACZ,UAAU,gBAAgB,eAAe,YAAY;AAAA,EACrD;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,7 @@ import { createCollection } from "@tamagui/collection";
|
|
|
2
2
|
import { useId } from "@tamagui/core";
|
|
3
3
|
import { createContextScope } from "@tamagui/create-context";
|
|
4
4
|
import * as React from "react";
|
|
5
|
+
import { ToastImperativeProvider } from "./ToastImperative";
|
|
5
6
|
const PROVIDER_NAME = "ToastProvider";
|
|
6
7
|
const [Collection, useCollection, createCollectionScope] = createCollection("Toast");
|
|
7
8
|
const [createToastContext, createToastScope] = createContextScope("Toast", [
|
|
@@ -12,6 +13,9 @@ const ToastProvider = (props) => {
|
|
|
12
13
|
const {
|
|
13
14
|
__scopeToast,
|
|
14
15
|
id: providedId,
|
|
16
|
+
burntOptions,
|
|
17
|
+
native,
|
|
18
|
+
notificationOptions,
|
|
15
19
|
label = "Notification",
|
|
16
20
|
duration = 5e3,
|
|
17
21
|
swipeDirection = "right",
|
|
@@ -23,6 +27,14 @@ const ToastProvider = (props) => {
|
|
|
23
27
|
const [toastCount, setToastCount] = React.useState(0);
|
|
24
28
|
const isFocusedToastEscapeKeyDownRef = React.useRef(false);
|
|
25
29
|
const isClosePausedRef = React.useRef(false);
|
|
30
|
+
const options = React.useMemo(() => {
|
|
31
|
+
return {
|
|
32
|
+
duration,
|
|
33
|
+
burntOptions,
|
|
34
|
+
native,
|
|
35
|
+
notificationOptions
|
|
36
|
+
};
|
|
37
|
+
}, [JSON.stringify([duration, burntOptions, native, notificationOptions])]);
|
|
26
38
|
return <Collection.Provider scope={__scopeToast}><ToastProviderProvider
|
|
27
39
|
scope={__scopeToast}
|
|
28
40
|
id={id}
|
|
@@ -41,7 +53,7 @@ const ToastProvider = (props) => {
|
|
|
41
53
|
}, [])}
|
|
42
54
|
isFocusedToastEscapeKeyDownRef={isFocusedToastEscapeKeyDownRef}
|
|
43
55
|
isClosePausedRef={isClosePausedRef}
|
|
44
|
-
>{children}</ToastProviderProvider></Collection.Provider>;
|
|
56
|
+
><ToastImperativeProvider options={options}>{children}</ToastImperativeProvider></ToastProviderProvider></Collection.Provider>;
|
|
45
57
|
};
|
|
46
58
|
ToastProvider.propTypes = {
|
|
47
59
|
label(props) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ToastProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement, useId } from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport {
|
|
5
|
-
"mappings": "AAAA,SAAS,wBAAwB;AACjC,SAAyB,aAAa;AAEtC,SAAS,0BAA0B;
|
|
4
|
+
"sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement, useId } from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport * as React from 'react'\n\nimport { ToastImperativeProvider, ToastNativeValue } from './ToastImperative'\nimport { BurntToastOptions } from './types'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'ToastProvider'\n\nconst [Collection, useCollection, createCollectionScope] =\n createCollection<TamaguiElement>('Toast')\n\ntype SwipeDirection = 'vertical' | 'up' | 'down' | 'horizontal' | 'left' | 'right'\ntype ToastProviderContextValue = {\n id: string\n label: string\n duration: number\n swipeDirection: SwipeDirection\n swipeThreshold: number\n toastCount: number\n viewport: TamaguiElement | null\n onViewportChange(viewport: TamaguiElement): void\n onToastAdd(): void\n onToastRemove(): void\n isFocusedToastEscapeKeyDownRef: React.MutableRefObject<boolean>\n isClosePausedRef: React.MutableRefObject<boolean>\n}\n\ntype ScopedProps<P> = P & { __scopeToast?: Scope }\nconst [createToastContext, createToastScope] = createContextScope('Toast', [\n createCollectionScope,\n])\nconst [ToastProviderProvider, useToastProviderContext] =\n createToastContext<ToastProviderContextValue>(PROVIDER_NAME)\n\ninterface ToastProviderProps {\n children?: React.ReactNode\n /**\n * An author-localized label for each toast. Used to help screen reader users\n * associate the interruption with a toast.\n * @defaultValue 'Notification'\n */\n label?: string\n /**\n * Time in milliseconds that each toast should remain visible for.\n * @defaultValue 5000\n */\n duration?: number\n /**\n * Direction of pointer swipe that should close the toast.\n * @defaultValue 'right'\n */\n swipeDirection?: SwipeDirection\n /**\n * Distance in pixels that the swipe must pass before a close is triggered.\n * @defaultValue 50\n */\n swipeThreshold?: number\n /**\n * @defaultValue unique generated identifier\n */\n id?: string\n /**\n * Will show a native toast if is true or is set to the current platform. On iOS, it wraps `SPIndicator` and `SPAlert`. On Android, it wraps `ToastAndroid`. On web, it wraps Notification API. Mobile's native features are handled by `burnt`.\n * Only works with the imperative `useToast` hook.\n */\n native?: ToastNativeValue\n /**\n * Options for the burnt package if you're using native toasts on mobile\n */\n burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>\n /**\n * Options for the notification API if you're using native toasts on web\n */\n notificationOptions?: NotificationOptions\n}\n\nconst ToastProvider: React.FC<ToastProviderProps> = (\n props: ScopedProps<ToastProviderProps>\n) => {\n const {\n __scopeToast,\n id: providedId,\n burntOptions,\n native,\n notificationOptions,\n label = 'Notification',\n duration = 5000,\n swipeDirection = 'right',\n swipeThreshold = 50,\n children,\n } = props\n const id = providedId ?? useId()\n const [viewport, setViewport] = React.useState<TamaguiElement | null>(null)\n const [toastCount, setToastCount] = React.useState(0)\n const isFocusedToastEscapeKeyDownRef = React.useRef(false)\n const isClosePausedRef = React.useRef(false)\n\n // memo context to avoid expensive re-renders\n const options = React.useMemo(() => {\n return {\n duration,\n burntOptions,\n native,\n notificationOptions,\n }\n // nested simple object so JSON.stringify\n }, [JSON.stringify([duration, burntOptions, native, notificationOptions])])\n\n return (\n <Collection.Provider scope={__scopeToast}>\n <ToastProviderProvider\n scope={__scopeToast}\n id={id}\n label={label}\n duration={duration}\n swipeDirection={swipeDirection}\n swipeThreshold={swipeThreshold}\n toastCount={toastCount}\n viewport={viewport}\n onViewportChange={setViewport}\n onToastAdd={React.useCallback(() => {\n setToastCount((prevCount) => prevCount + 1)\n }, [])}\n onToastRemove={React.useCallback(() => {\n setToastCount((prevCount) => prevCount - 1)\n }, [])}\n isFocusedToastEscapeKeyDownRef={isFocusedToastEscapeKeyDownRef}\n isClosePausedRef={isClosePausedRef}\n >\n <ToastImperativeProvider options={options}>{children}</ToastImperativeProvider>\n </ToastProviderProvider>\n </Collection.Provider>\n )\n}\n\nToastProvider.propTypes = {\n label(props) {\n if (props.label && typeof props.label === 'string' && !props.label.trim()) {\n const error = `Invalid prop \\`label\\` supplied to \\`${PROVIDER_NAME}\\`. Expected non-empty \\`string\\`.`\n return new Error(error)\n }\n return null\n },\n}\n\nToastProvider.displayName = PROVIDER_NAME\n\nexport {\n Collection,\n ToastProvider,\n createToastContext,\n createToastScope,\n useCollection,\n useToastProviderContext,\n}\nexport type { ScopedProps, SwipeDirection, ToastProviderProps }\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,wBAAwB;AACjC,SAAyB,aAAa;AAEtC,SAAS,0BAA0B;AACnC,YAAY,WAAW;AAEvB,SAAS,+BAAiD;AAO1D,MAAM,gBAAgB;AAEtB,MAAM,CAAC,YAAY,eAAe,qBAAqB,IACrD,iBAAiC,OAAO;AAmB1C,MAAM,CAAC,oBAAoB,gBAAgB,IAAI,mBAAmB,SAAS;AAAA,EACzE;AACF,CAAC;AACD,MAAM,CAAC,uBAAuB,uBAAuB,IACnD,mBAA8C,aAAa;AA4C7D,MAAM,gBAA8C,CAClD,UACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA,IAA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AM,QAAQ,wCAAwC;AACtD,aAAO,IAAI,MAAM,KAAK;AAAA,IACxB;AACA,WAAO;AAAA,EACT;AACF;AAEA,cAAc,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,7 @@ import { createCollection } from "@tamagui/collection";
|
|
|
2
2
|
import { useId } from "@tamagui/core";
|
|
3
3
|
import { createContextScope } from "@tamagui/create-context";
|
|
4
4
|
import * as React from "react";
|
|
5
|
+
import { ToastImperativeProvider } from "./ToastImperative";
|
|
5
6
|
const PROVIDER_NAME = "ToastProvider";
|
|
6
7
|
const [Collection, useCollection, createCollectionScope] = createCollection("Toast");
|
|
7
8
|
const [createToastContext, createToastScope] = createContextScope("Toast", [
|
|
@@ -12,6 +13,9 @@ const ToastProvider = (props) => {
|
|
|
12
13
|
const {
|
|
13
14
|
__scopeToast,
|
|
14
15
|
id: providedId,
|
|
16
|
+
burntOptions,
|
|
17
|
+
native,
|
|
18
|
+
notificationOptions,
|
|
15
19
|
label = "Notification",
|
|
16
20
|
duration = 5e3,
|
|
17
21
|
swipeDirection = "right",
|
|
@@ -23,6 +27,14 @@ const ToastProvider = (props) => {
|
|
|
23
27
|
const [toastCount, setToastCount] = React.useState(0);
|
|
24
28
|
const isFocusedToastEscapeKeyDownRef = React.useRef(false);
|
|
25
29
|
const isClosePausedRef = React.useRef(false);
|
|
30
|
+
const options = React.useMemo(() => {
|
|
31
|
+
return {
|
|
32
|
+
duration,
|
|
33
|
+
burntOptions,
|
|
34
|
+
native,
|
|
35
|
+
notificationOptions
|
|
36
|
+
};
|
|
37
|
+
}, [JSON.stringify([duration, burntOptions, native, notificationOptions])]);
|
|
26
38
|
return <Collection.Provider scope={__scopeToast}><ToastProviderProvider
|
|
27
39
|
scope={__scopeToast}
|
|
28
40
|
id={id}
|
|
@@ -41,7 +53,7 @@ const ToastProvider = (props) => {
|
|
|
41
53
|
}, [])}
|
|
42
54
|
isFocusedToastEscapeKeyDownRef={isFocusedToastEscapeKeyDownRef}
|
|
43
55
|
isClosePausedRef={isClosePausedRef}
|
|
44
|
-
>{children}</ToastProviderProvider></Collection.Provider>;
|
|
56
|
+
><ToastImperativeProvider options={options}>{children}</ToastImperativeProvider></ToastProviderProvider></Collection.Provider>;
|
|
45
57
|
};
|
|
46
58
|
ToastProvider.propTypes = {
|
|
47
59
|
label(props) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ToastProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement, useId } from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport {
|
|
5
|
-
"mappings": "AAAA,SAAS,wBAAwB;AACjC,SAAyB,aAAa;AAEtC,SAAS,0BAA0B;
|
|
4
|
+
"sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement, useId } from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport * as React from 'react'\n\nimport { ToastImperativeProvider, ToastNativeValue } from './ToastImperative'\nimport { BurntToastOptions } from './types'\n\n/* -------------------------------------------------------------------------------------------------\n * ToastProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'ToastProvider'\n\nconst [Collection, useCollection, createCollectionScope] =\n createCollection<TamaguiElement>('Toast')\n\ntype SwipeDirection = 'vertical' | 'up' | 'down' | 'horizontal' | 'left' | 'right'\ntype ToastProviderContextValue = {\n id: string\n label: string\n duration: number\n swipeDirection: SwipeDirection\n swipeThreshold: number\n toastCount: number\n viewport: TamaguiElement | null\n onViewportChange(viewport: TamaguiElement): void\n onToastAdd(): void\n onToastRemove(): void\n isFocusedToastEscapeKeyDownRef: React.MutableRefObject<boolean>\n isClosePausedRef: React.MutableRefObject<boolean>\n}\n\ntype ScopedProps<P> = P & { __scopeToast?: Scope }\nconst [createToastContext, createToastScope] = createContextScope('Toast', [\n createCollectionScope,\n])\nconst [ToastProviderProvider, useToastProviderContext] =\n createToastContext<ToastProviderContextValue>(PROVIDER_NAME)\n\ninterface ToastProviderProps {\n children?: React.ReactNode\n /**\n * An author-localized label for each toast. Used to help screen reader users\n * associate the interruption with a toast.\n * @defaultValue 'Notification'\n */\n label?: string\n /**\n * Time in milliseconds that each toast should remain visible for.\n * @defaultValue 5000\n */\n duration?: number\n /**\n * Direction of pointer swipe that should close the toast.\n * @defaultValue 'right'\n */\n swipeDirection?: SwipeDirection\n /**\n * Distance in pixels that the swipe must pass before a close is triggered.\n * @defaultValue 50\n */\n swipeThreshold?: number\n /**\n * @defaultValue unique generated identifier\n */\n id?: string\n /**\n * Will show a native toast if is true or is set to the current platform. On iOS, it wraps `SPIndicator` and `SPAlert`. On Android, it wraps `ToastAndroid`. On web, it wraps Notification API. Mobile's native features are handled by `burnt`.\n * Only works with the imperative `useToast` hook.\n */\n native?: ToastNativeValue\n /**\n * Options for the burnt package if you're using native toasts on mobile\n */\n burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>\n /**\n * Options for the notification API if you're using native toasts on web\n */\n notificationOptions?: NotificationOptions\n}\n\nconst ToastProvider: React.FC<ToastProviderProps> = (\n props: ScopedProps<ToastProviderProps>\n) => {\n const {\n __scopeToast,\n id: providedId,\n burntOptions,\n native,\n notificationOptions,\n label = 'Notification',\n duration = 5000,\n swipeDirection = 'right',\n swipeThreshold = 50,\n children,\n } = props\n const id = providedId ?? useId()\n const [viewport, setViewport] = React.useState<TamaguiElement | null>(null)\n const [toastCount, setToastCount] = React.useState(0)\n const isFocusedToastEscapeKeyDownRef = React.useRef(false)\n const isClosePausedRef = React.useRef(false)\n\n // memo context to avoid expensive re-renders\n const options = React.useMemo(() => {\n return {\n duration,\n burntOptions,\n native,\n notificationOptions,\n }\n // nested simple object so JSON.stringify\n }, [JSON.stringify([duration, burntOptions, native, notificationOptions])])\n\n return (\n <Collection.Provider scope={__scopeToast}>\n <ToastProviderProvider\n scope={__scopeToast}\n id={id}\n label={label}\n duration={duration}\n swipeDirection={swipeDirection}\n swipeThreshold={swipeThreshold}\n toastCount={toastCount}\n viewport={viewport}\n onViewportChange={setViewport}\n onToastAdd={React.useCallback(() => {\n setToastCount((prevCount) => prevCount + 1)\n }, [])}\n onToastRemove={React.useCallback(() => {\n setToastCount((prevCount) => prevCount - 1)\n }, [])}\n isFocusedToastEscapeKeyDownRef={isFocusedToastEscapeKeyDownRef}\n isClosePausedRef={isClosePausedRef}\n >\n <ToastImperativeProvider options={options}>{children}</ToastImperativeProvider>\n </ToastProviderProvider>\n </Collection.Provider>\n )\n}\n\nToastProvider.propTypes = {\n label(props) {\n if (props.label && typeof props.label === 'string' && !props.label.trim()) {\n const error = `Invalid prop \\`label\\` supplied to \\`${PROVIDER_NAME}\\`. Expected non-empty \\`string\\`.`\n return new Error(error)\n }\n return null\n },\n}\n\nToastProvider.displayName = PROVIDER_NAME\n\nexport {\n Collection,\n ToastProvider,\n createToastContext,\n createToastScope,\n useCollection,\n useToastProviderContext,\n}\nexport type { ScopedProps, SwipeDirection, ToastProviderProps }\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,wBAAwB;AACjC,SAAyB,aAAa;AAEtC,SAAS,0BAA0B;AACnC,YAAY,WAAW;AAEvB,SAAS,+BAAiD;AAO1D,MAAM,gBAAgB;AAEtB,MAAM,CAAC,YAAY,eAAe,qBAAqB,IACrD,iBAAiC,OAAO;AAmB1C,MAAM,CAAC,oBAAoB,gBAAgB,IAAI,mBAAmB,SAAS;AAAA,EACzE;AACF,CAAC;AACD,MAAM,CAAC,uBAAuB,uBAAuB,IACnD,mBAA8C,aAAa;AA4C7D,MAAM,gBAA8C,CAClD,UACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,i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c;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/index.js
CHANGED
package/dist/jsx/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Toast'\
|
|
5
|
-
"mappings": "AAAA,cAAc;
|
|
4
|
+
"sourcesContent": ["export * from './Toast.js'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/index.mjs
CHANGED
package/dist/jsx/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Toast'\
|
|
5
|
-
"mappings": "AAAA,cAAc;
|
|
4
|
+
"sourcesContent": ["export * from './Toast.js'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/toast",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -31,24 +31,24 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tamagui/animate-presence": "1.
|
|
35
|
-
"@tamagui/compose-refs": "1.
|
|
36
|
-
"@tamagui/core": "1.
|
|
37
|
-
"@tamagui/create-context": "1.
|
|
38
|
-
"@tamagui/dismissable": "1.
|
|
39
|
-
"@tamagui/polyfill-dev": "1.
|
|
40
|
-
"@tamagui/portal": "1.
|
|
41
|
-
"@tamagui/stacks": "1.
|
|
42
|
-
"@tamagui/text": "1.
|
|
43
|
-
"@tamagui/use-controllable-state": "1.
|
|
44
|
-
"@tamagui/visually-hidden": "1.
|
|
34
|
+
"@tamagui/animate-presence": "1.12.1",
|
|
35
|
+
"@tamagui/compose-refs": "1.12.1",
|
|
36
|
+
"@tamagui/core": "1.12.1",
|
|
37
|
+
"@tamagui/create-context": "1.12.1",
|
|
38
|
+
"@tamagui/dismissable": "1.12.1",
|
|
39
|
+
"@tamagui/polyfill-dev": "1.12.1",
|
|
40
|
+
"@tamagui/portal": "1.12.1",
|
|
41
|
+
"@tamagui/stacks": "1.12.1",
|
|
42
|
+
"@tamagui/text": "1.12.1",
|
|
43
|
+
"@tamagui/use-controllable-state": "1.12.1",
|
|
44
|
+
"@tamagui/visually-hidden": "1.12.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "*",
|
|
48
48
|
"react-native": "*"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@tamagui/build": "1.
|
|
51
|
+
"@tamagui/build": "1.12.1",
|
|
52
52
|
"react": "^18.2.0",
|
|
53
53
|
"react-native": "^0.71.4"
|
|
54
54
|
},
|
package/src/Toast.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import * as React from 'react'
|
|
|
15
15
|
|
|
16
16
|
import { TOAST_NAME } from './constants'
|
|
17
17
|
import { ToastAnnounceExclude } from './ToastAnnounce'
|
|
18
|
+
import { ToastNativePlatform, ToastNativeValue, useToast } from './ToastImperative.js'
|
|
18
19
|
import {
|
|
19
20
|
ToastImpl,
|
|
20
21
|
ToastImplFrame,
|
|
@@ -182,7 +183,7 @@ const ToastComponent = React.forwardRef<TamaguiElement, ToastProps>(
|
|
|
182
183
|
const onPause = useEvent(props.onPause)
|
|
183
184
|
const onResume = useEvent(props.onResume)
|
|
184
185
|
const shouldShow = forceMount || open
|
|
185
|
-
|
|
186
|
+
|
|
186
187
|
if (!shouldShow) return null
|
|
187
188
|
|
|
188
189
|
return (
|
|
@@ -222,6 +223,8 @@ export {
|
|
|
222
223
|
ToastViewport,
|
|
223
224
|
//
|
|
224
225
|
createToastScope,
|
|
226
|
+
// imperative
|
|
227
|
+
useToast,
|
|
225
228
|
}
|
|
226
229
|
export type {
|
|
227
230
|
ToastActionProps,
|
|
@@ -231,4 +234,7 @@ export type {
|
|
|
231
234
|
ToastProviderProps,
|
|
232
235
|
ToastTitleProps,
|
|
233
236
|
ToastViewportProps,
|
|
237
|
+
// imperative
|
|
238
|
+
ToastNativeValue,
|
|
239
|
+
ToastNativePlatform,
|
|
234
240
|
}
|
package/src/ToastProvider.tsx
CHANGED
|
@@ -2,9 +2,11 @@ import { createCollection } from '@tamagui/collection'
|
|
|
2
2
|
import { TamaguiElement, useId } from '@tamagui/core'
|
|
3
3
|
import type { Scope } from '@tamagui/create-context'
|
|
4
4
|
import { createContextScope } from '@tamagui/create-context'
|
|
5
|
-
import { PortalProvider } from '@tamagui/portal'
|
|
6
5
|
import * as React from 'react'
|
|
7
6
|
|
|
7
|
+
import { ToastImperativeProvider, ToastNativeValue } from './ToastImperative'
|
|
8
|
+
import { BurntToastOptions } from './types'
|
|
9
|
+
|
|
8
10
|
/* -------------------------------------------------------------------------------------------------
|
|
9
11
|
* ToastProvider
|
|
10
12
|
* -----------------------------------------------------------------------------------------------*/
|
|
@@ -64,6 +66,19 @@ interface ToastProviderProps {
|
|
|
64
66
|
* @defaultValue unique generated identifier
|
|
65
67
|
*/
|
|
66
68
|
id?: string
|
|
69
|
+
/**
|
|
70
|
+
* Will show a native toast if is true or is set to the current platform. On iOS, it wraps `SPIndicator` and `SPAlert`. On Android, it wraps `ToastAndroid`. On web, it wraps Notification API. Mobile's native features are handled by `burnt`.
|
|
71
|
+
* Only works with the imperative `useToast` hook.
|
|
72
|
+
*/
|
|
73
|
+
native?: ToastNativeValue
|
|
74
|
+
/**
|
|
75
|
+
* Options for the burnt package if you're using native toasts on mobile
|
|
76
|
+
*/
|
|
77
|
+
burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>
|
|
78
|
+
/**
|
|
79
|
+
* Options for the notification API if you're using native toasts on web
|
|
80
|
+
*/
|
|
81
|
+
notificationOptions?: NotificationOptions
|
|
67
82
|
}
|
|
68
83
|
|
|
69
84
|
const ToastProvider: React.FC<ToastProviderProps> = (
|
|
@@ -72,6 +87,9 @@ const ToastProvider: React.FC<ToastProviderProps> = (
|
|
|
72
87
|
const {
|
|
73
88
|
__scopeToast,
|
|
74
89
|
id: providedId,
|
|
90
|
+
burntOptions,
|
|
91
|
+
native,
|
|
92
|
+
notificationOptions,
|
|
75
93
|
label = 'Notification',
|
|
76
94
|
duration = 5000,
|
|
77
95
|
swipeDirection = 'right',
|
|
@@ -84,6 +102,17 @@ const ToastProvider: React.FC<ToastProviderProps> = (
|
|
|
84
102
|
const isFocusedToastEscapeKeyDownRef = React.useRef(false)
|
|
85
103
|
const isClosePausedRef = React.useRef(false)
|
|
86
104
|
|
|
105
|
+
// memo context to avoid expensive re-renders
|
|
106
|
+
const options = React.useMemo(() => {
|
|
107
|
+
return {
|
|
108
|
+
duration,
|
|
109
|
+
burntOptions,
|
|
110
|
+
native,
|
|
111
|
+
notificationOptions,
|
|
112
|
+
}
|
|
113
|
+
// nested simple object so JSON.stringify
|
|
114
|
+
}, [JSON.stringify([duration, burntOptions, native, notificationOptions])])
|
|
115
|
+
|
|
87
116
|
return (
|
|
88
117
|
<Collection.Provider scope={__scopeToast}>
|
|
89
118
|
<ToastProviderProvider
|
|
@@ -105,7 +134,7 @@ const ToastProvider: React.FC<ToastProviderProps> = (
|
|
|
105
134
|
isFocusedToastEscapeKeyDownRef={isFocusedToastEscapeKeyDownRef}
|
|
106
135
|
isClosePausedRef={isClosePausedRef}
|
|
107
136
|
>
|
|
108
|
-
{children}
|
|
137
|
+
<ToastImperativeProvider options={options}>{children}</ToastImperativeProvider>
|
|
109
138
|
</ToastProviderProvider>
|
|
110
139
|
</Collection.Provider>
|
|
111
140
|
)
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './Toast'
|
|
2
|
-
export * from './ToastImperative'
|
|
1
|
+
export * from './Toast.js'
|
package/types/Toast.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GetProps, TamaguiElement } from '@tamagui/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { ToastNativePlatform, ToastNativeValue, useToast } from './ToastImperative.js';
|
|
3
4
|
import { ToastProps } from './ToastImpl';
|
|
4
5
|
import { ToastProvider, ToastProviderProps, createToastScope } from './ToastProvider';
|
|
5
6
|
import { ToastViewport, ToastViewportProps } from './ToastViewport';
|
|
@@ -432,6 +433,6 @@ declare const Toast: ((props: Omit<ToastProps & React.RefAttributes<TamaguiEleme
|
|
|
432
433
|
[x: string]: undefined;
|
|
433
434
|
}>>, "ref">) & React.RefAttributes<TamaguiElement>>;
|
|
434
435
|
};
|
|
435
|
-
export { Toast, ToastProvider, ToastViewport, createToastScope, };
|
|
436
|
-
export type { ToastActionProps, ToastCloseProps, ToastDescriptionProps, ToastProps, ToastProviderProps, ToastTitleProps, ToastViewportProps, };
|
|
436
|
+
export { Toast, ToastProvider, ToastViewport, createToastScope, useToast, };
|
|
437
|
+
export type { ToastActionProps, ToastCloseProps, ToastDescriptionProps, ToastProps, ToastProviderProps, ToastTitleProps, ToastViewportProps, ToastNativeValue, ToastNativePlatform, };
|
|
437
438
|
//# sourceMappingURL=Toast.d.ts.map
|
package/types/Toast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,cAAc,EAOf,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAGL,UAAU,EAEX,MAAM,aAAa,CAAA;AACpB,OAAO,EAEL,aAAa,EACb,kBAAkB,EAClB,gBA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BAAoB,GAAG,EAAE,CAAA;AA6DhD,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAxGT;;;;;WAKG;iBACM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QANf;;;;;WAKG;iBACM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0GhB,CAAA;AAID,OAAO,EACL,KAAK,EACL,aAAa,EACb,aAAa,EAEb,gBAAgB,EAEhB,QAAQ,GACT,CAAA;AACD,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAElB,gBAAgB,EAChB,mBAAmB,GACpB,CAAA"}
|
package/types/ToastProvider.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { TamaguiElement } from '@tamagui/core';
|
|
2
2
|
import type { Scope } from '@tamagui/create-context';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
import { ToastNativeValue } from './ToastImperative';
|
|
5
|
+
import { BurntToastOptions } from './types';
|
|
4
6
|
declare const Collection: {
|
|
5
7
|
readonly Provider: React.FC<{
|
|
6
8
|
children?: React.ReactNode;
|
|
@@ -73,6 +75,19 @@ interface ToastProviderProps {
|
|
|
73
75
|
* @defaultValue unique generated identifier
|
|
74
76
|
*/
|
|
75
77
|
id?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Will show a native toast if is true or is set to the current platform. On iOS, it wraps `SPIndicator` and `SPAlert`. On Android, it wraps `ToastAndroid`. On web, it wraps Notification API. Mobile's native features are handled by `burnt`.
|
|
80
|
+
* Only works with the imperative `useToast` hook.
|
|
81
|
+
*/
|
|
82
|
+
native?: ToastNativeValue;
|
|
83
|
+
/**
|
|
84
|
+
* Options for the burnt package if you're using native toasts on mobile
|
|
85
|
+
*/
|
|
86
|
+
burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>;
|
|
87
|
+
/**
|
|
88
|
+
* Options for the notification API if you're using native toasts on web
|
|
89
|
+
*/
|
|
90
|
+
notificationOptions?: NotificationOptions;
|
|
76
91
|
}
|
|
77
92
|
declare const ToastProvider: React.FC<ToastProviderProps>;
|
|
78
93
|
export { Collection, ToastProvider, createToastContext, createToastScope, useCollection, useToastProviderContext, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../src/ToastProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAS,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../src/ToastProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAS,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAEpD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAA2B,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAQ3C,QAAA,MAAO,UAAU;;;;;;;;;;GAAE,aAAa;;GACW,CAAA;AAE3C,KAAK,cAAc,GAAG,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,YAAY,GAAG,MAAM,GAAG,OAAO,CAAA;AAClF,KAAK,yBAAyB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,cAAc,CAAA;IAC9B,cA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,EAChB,aAAa,EACb,uBAAuB,GACxB,CAAA;AACD,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAA"}
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|