@tamagui/toast 1.15.4 → 1.15.6

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.
Files changed (62) hide show
  1. package/dist/cjs/Toast.js.map +1 -1
  2. package/dist/cjs/ToastImperative.js +1 -2
  3. package/dist/cjs/ToastImperative.js.map +2 -2
  4. package/dist/cjs/ToastImpl.js +8 -12
  5. package/dist/cjs/ToastImpl.js.map +2 -2
  6. package/dist/cjs/ToastProvider.js +9 -3
  7. package/dist/cjs/ToastProvider.js.map +2 -2
  8. package/dist/cjs/ToastViewport.js +44 -21
  9. package/dist/cjs/ToastViewport.js.map +2 -2
  10. package/dist/esm/Toast.js.map +1 -1
  11. package/dist/esm/Toast.mjs.map +1 -1
  12. package/dist/esm/ToastImperative.js +1 -2
  13. package/dist/esm/ToastImperative.js.map +2 -2
  14. package/dist/esm/ToastImperative.mjs +1 -2
  15. package/dist/esm/ToastImperative.mjs.map +2 -2
  16. package/dist/esm/ToastImpl.js +8 -12
  17. package/dist/esm/ToastImpl.js.map +2 -2
  18. package/dist/esm/ToastImpl.mjs +8 -12
  19. package/dist/esm/ToastImpl.mjs.map +2 -2
  20. package/dist/esm/ToastProvider.js +9 -3
  21. package/dist/esm/ToastProvider.js.map +2 -2
  22. package/dist/esm/ToastProvider.mjs +9 -3
  23. package/dist/esm/ToastProvider.mjs.map +2 -2
  24. package/dist/esm/ToastViewport.js +44 -21
  25. package/dist/esm/ToastViewport.js.map +2 -2
  26. package/dist/esm/ToastViewport.mjs +44 -21
  27. package/dist/esm/ToastViewport.mjs.map +2 -2
  28. package/dist/jsx/Toast.js.map +1 -1
  29. package/dist/jsx/Toast.mjs.map +1 -1
  30. package/dist/jsx/ToastImperative.js +1 -2
  31. package/dist/jsx/ToastImperative.js.map +2 -2
  32. package/dist/jsx/ToastImperative.mjs +1 -2
  33. package/dist/jsx/ToastImperative.mjs.map +2 -2
  34. package/dist/jsx/ToastImpl.js +8 -11
  35. package/dist/jsx/ToastImpl.js.map +2 -2
  36. package/dist/jsx/ToastImpl.mjs +8 -11
  37. package/dist/jsx/ToastImpl.mjs.map +2 -2
  38. package/dist/jsx/ToastProvider.js +9 -3
  39. package/dist/jsx/ToastProvider.js.map +2 -2
  40. package/dist/jsx/ToastProvider.mjs +9 -3
  41. package/dist/jsx/ToastProvider.mjs.map +2 -2
  42. package/dist/jsx/ToastViewport.js +44 -20
  43. package/dist/jsx/ToastViewport.js.map +2 -2
  44. package/dist/jsx/ToastViewport.mjs +44 -20
  45. package/dist/jsx/ToastViewport.mjs.map +2 -2
  46. package/package.json +13 -13
  47. package/src/Toast.tsx +2 -2
  48. package/src/ToastImperative.tsx +11 -3
  49. package/src/ToastImpl.tsx +21 -21
  50. package/src/ToastProvider.tsx +14 -5
  51. package/src/ToastViewport.tsx +51 -21
  52. package/types/Toast.d.ts +38 -66
  53. package/types/Toast.d.ts.map +1 -1
  54. package/types/ToastAnnounce.d.ts +1 -1
  55. package/types/ToastImperative.d.ts +10 -1
  56. package/types/ToastImperative.d.ts.map +1 -1
  57. package/types/ToastImpl.d.ts +13 -20
  58. package/types/ToastImpl.d.ts.map +1 -1
  59. package/types/ToastProvider.d.ts +2 -2
  60. package/types/ToastProvider.d.ts.map +1 -1
  61. package/types/ToastViewport.d.ts +18 -59
  62. package/types/ToastViewport.d.ts.map +1 -1
@@ -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 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 ToastNativePlatform,\n ToastNativeValue,\n useToast,\n useToastController,\n useToastState,\n} 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 variants: {\n unstyled: {\n false: {\n color: '$color',\n size: '$4',\n },\n },\n },\n defaultVariants: {\n unstyled: false,\n },\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\n variants: {\n unstyled: {\n false: {\n color: '$color11',\n size: '$1',\n },\n },\n },\n\n defaultVariants: {\n unstyled: false,\n },\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 = React.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 useToastController,\n useToastState,\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"],
4
+ "sourcesContent": ["import {\n GetProps,\n TamaguiElement,\n composeEventHandlers,\n styled,\n themeable,\n useEvent,\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 ToastNativePlatform,\n ToastNativeValue,\n useToast,\n useToastController,\n useToastState,\n} 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 variants: {\n unstyled: {\n false: {\n color: '$color',\n size: '$4',\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\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\n variants: {\n unstyled: {\n false: {\n color: '$color11',\n size: '$1',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\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 = React.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 useToastController,\n useToastState,\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
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgEW;AAhEX,kBAQO;AACP,oBAA+B;AAC/B,kBAA4B;AAC5B,oCAAqC;AACrC,YAAuB;AAEvB,uBAA2B;AAC3B,2BAAqC;AACrC,6BAMO;AACP,uBAKO;AACP,2BAKO;AACP,2BAAkD;AAMlD,MAAM,aAAa;AAEnB,MAAM,sBAAkB,oBAAO,yBAAa;AAAA,EAC1C,MAAM;AAAA,EACN,UAAU;AAAA,IACR,UAAU;AAAA,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rD;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
@@ -78,6 +78,7 @@ const ToastImperativeProvider = ({
78
78
  setToast({
79
79
  title,
80
80
  id: counterRef.current.toString(),
81
+ viewportName: (showOptions == null ? void 0 : showOptions.viewportName) ?? "default",
81
82
  ...showOptions,
82
83
  isHandledNatively
83
84
  });
@@ -97,8 +98,6 @@ const ToastImperativeProvider = ({
97
98
  options
98
99
  };
99
100
  }, [show, hide, lastNativeToastRef, JSON.stringify(options || null)]);
100
- const currentContextValue = (0, import_react.useMemo)(() => {
101
- }, []);
102
101
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastCurrentContext.Provider, { value: toast, children }) });
103
102
  };
104
103
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ToastImperative.tsx"],
4
- "sourcesContent": ["import { isWeb } from '@tamagui/core'\nimport React, { createContext, useContext, useMemo, useRef } from 'react'\nimport { Platform } from 'react-native'\n\nimport { createNativeToast } from './createNativeToast'\nimport {\n CreateNativeToastOptions,\n NativeToastRef,\n ToastNativePlatform,\n ToastNativeValue,\n} from './types'\n\ninterface ToastImperativeOptions extends Omit<CreateNativeToastOptions, 'message'> {\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 */\n native?: ToastNativeValue\n}\ninterface ShowOptions extends CreateNativeToastOptions {\n /**\n * Used when need custom data\n */\n additionalInfo?: Record<string, any>\n /**\n * Overrides the native option on `ToastImperativeProvider`\n */\n native?: ToastNativeValue\n}\n\ntype ToastData = { title: string; id: string } & CreateNativeToastOptions & {\n isHandledNatively: boolean\n }\n\ninterface ToastContextI {\n nativeToast: NativeToastRef | null\n\n /**\n * Call it to show a new toast. If you're using native toasts, you can pass native options using \\`burntOptions\\` or \\`notificationOptions\\` depending on the native platform (mobile/web).\n */\n show: (title: string, options?: ShowOptions) => boolean\n\n /**\n * Call it to hide the currently displayed toast.\n *\n * _NOTE_: does not work on Android native toasts\n *\n * _NOTE_: hides the last toast on web notification toasts\n */\n hide: () => void\n\n options?: ToastImperativeOptions\n}\n\nconst ToastContext = createContext<ToastContextI>({} as any)\nconst ToastCurrentContext = createContext<ToastData | null>(null)\n\nexport const useToastController = () => {\n return useContext(ToastContext)\n}\n\nexport const useToastState = () => {\n return useContext(ToastCurrentContext)\n}\n\n/** @deprecated use `useToastController` and `useToastState` instead to avoid performance pitfalls */\nexport const useToast = () => {\n return {\n ...useToastController(),\n currentToast: useToastState(),\n }\n}\n\ninterface ToastImperativeProviderProps {\n children: React.ReactNode\n /**\n * Used to provide defaults to imperative API. Options can be overwritten when calling `show()`.\n */\n options: ToastImperativeOptions\n}\n\nexport const ToastImperativeProvider = ({\n children,\n options,\n}: ToastImperativeProviderProps) => {\n const counterRef = useRef(0)\n\n const [toast, setToast] = React.useState<ToastData | null>(null)\n\n const [lastNativeToastRef, setLastNativeToastRef] =\n React.useState<ToastContextI['nativeToast']>(null)\n\n const show = React.useCallback<ToastContextI['show']>(\n (title, showOptions) => {\n const native = showOptions?.native ?? options.native\n const isWebNative = Array.isArray(native)\n ? native.includes('web')\n : native === 'web'\n const isMobileNative = Array.isArray(native)\n ? native.includes('mobile')\n : native === 'mobile'\n const isAndroidNative =\n isMobileNative ||\n (Array.isArray(native) ? native.includes('android') : native === 'android')\n const isIosNative =\n isMobileNative ||\n (Array.isArray(native) ? native.includes('ios') : native === 'ios')\n\n const isHandledNatively =\n native === true ||\n (isWeb && isWebNative) ||\n (!isWeb && isMobileNative) ||\n (Platform.OS === 'android' && isAndroidNative) ||\n (Platform.OS === 'ios' && isIosNative)\n\n if (isHandledNatively) {\n const nativeToastResult = createNativeToast(title, showOptions ?? {})\n if (typeof nativeToastResult === 'object' && nativeToastResult.nativeToastRef) {\n setLastNativeToastRef(nativeToastResult.nativeToastRef)\n }\n }\n counterRef.current++\n setToast({\n title,\n id: counterRef.current.toString(),\n ...showOptions,\n isHandledNatively,\n })\n return true\n },\n [setToast, options.native]\n )\n const hide = React.useCallback(() => {\n lastNativeToastRef?.close()\n setToast(null)\n }, [setToast, lastNativeToastRef])\n\n const contextValue = useMemo(() => {\n return {\n show,\n hide,\n nativeToast: lastNativeToastRef,\n options,\n }\n }, [show, hide, lastNativeToastRef, JSON.stringify(options || null)])\n\n const currentContextValue = useMemo(() => {}, [])\n\n return (\n <ToastContext.Provider value={contextValue}>\n <ToastCurrentContext.Provider value={toast}>\n {children}\n </ToastCurrentContext.Provider>\n </ToastContext.Provider>\n )\n}\n\nexport type { ToastImperativeProviderProps, ToastNativePlatform, ToastNativeValue }\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqJM;AArJN,kBAAsB;AACtB,mBAAkE;AAClE,0BAAyB;AAEzB,+BAAkC;AAiDlC,MAAM,mBAAe,4BAA6B,CAAC,CAAQ;AAC3D,MAAM,0BAAsB,4BAAgC,IAAI;AAEzD,MAAM,qBAAqB,MAAM;AACtC,aAAO,yBAAW,YAAY;AAChC;AAEO,MAAM,gBAAgB,MAAM;AACjC,aAAO,yBAAW,mBAAmB;AACvC;AAGO,MAAM,WAAW,MAAM;AAC5B,SAAO;AAAA,IACL,GAAG,mBAAmB;AAAA,IACtB,cAAc,cAAc;AAAA,EAC9B;AACF;AAUO,MAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AACF,MAAoC;AAClC,QAAM,iBAAa,qBAAO,CAAC;AAE3B,QAAM,CAAC,OAAO,QAAQ,IAAI,aAAAA,QAAM,SAA2B,IAAI;AAE/D,QAAM,CAAC,oBAAoB,q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AEpE,QAAM,0BAAsB,sBAAQ,MAAM;AAAA,EAAC,GAAG,CAAC,CAAC;AAEhD,SACE,4CAAC,aAAa,UAAb,EAAsB,OAAO,cAC5B,sDAAC,oBAAoB,UAApB,EAA6B,OAAO,OAClC,UACH,GACF;AAEJ;",
4
+ "sourcesContent": ["import { isWeb } from '@tamagui/core'\nimport React, { createContext, useContext, useMemo, useRef } from 'react'\nimport { Platform } from 'react-native'\n\nimport { createNativeToast } from './createNativeToast'\nimport {\n CreateNativeToastOptions,\n NativeToastRef,\n ToastNativePlatform,\n ToastNativeValue,\n} from './types'\n\ninterface ToastImperativeOptions extends Omit<CreateNativeToastOptions, 'message'> {\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 */\n native?: ToastNativeValue\n}\ninterface ShowOptions extends CreateNativeToastOptions {\n /**\n * Used when need custom data\n * @deprecated Use `customData` instead\n */\n additionalInfo?: Record<string, any>\n /**\n * Used when need custom data\n */\n customData?: Record<string, any>\n /**\n * Overrides the native option on `ToastImperativeProvider`\n */\n native?: ToastNativeValue\n /**\n * Which viewport to send this toast to. This is only intended to be used with custom toasts and you should wire it up when creating the toast.\n */\n viewportName?: string | 'default'\n}\n\ntype ToastData = { title: string; id: string } & ShowOptions & {\n isHandledNatively: boolean\n }\n\ninterface ToastContextI {\n nativeToast: NativeToastRef | null\n\n /**\n * Call it to show a new toast. If you're using native toasts, you can pass native options using \\`burntOptions\\` or \\`notificationOptions\\` depending on the native platform (mobile/web).\n */\n show: (title: string, options?: ShowOptions) => boolean\n\n /**\n * Call it to hide the currently displayed toast.\n *\n * _NOTE_: does not work on Android native toasts\n *\n * _NOTE_: hides the last toast on web notification toasts\n */\n hide: () => void\n\n options?: ToastImperativeOptions\n}\n\nconst ToastContext = createContext<ToastContextI>({} as any)\nconst ToastCurrentContext = createContext<ToastData | null>(null)\n\nexport const useToastController = () => {\n return useContext(ToastContext)\n}\n\nexport const useToastState = () => {\n return useContext(ToastCurrentContext)\n}\n\n/** @deprecated use `useToastController` and `useToastState` instead to avoid performance pitfalls */\nexport const useToast = () => {\n return {\n ...useToastController(),\n currentToast: useToastState(),\n }\n}\n\ninterface ToastImperativeProviderProps {\n children: React.ReactNode\n /**\n * Used to provide defaults to imperative API. Options can be overwritten when calling `show()`.\n */\n options: ToastImperativeOptions\n}\n\nexport const ToastImperativeProvider = ({\n children,\n options,\n}: ToastImperativeProviderProps) => {\n const counterRef = useRef(0)\n\n const [toast, setToast] = React.useState<ToastData | null>(null)\n\n const [lastNativeToastRef, setLastNativeToastRef] =\n React.useState<ToastContextI['nativeToast']>(null)\n\n const show = React.useCallback<ToastContextI['show']>(\n (title, showOptions) => {\n const native = showOptions?.native ?? options.native\n const isWebNative = Array.isArray(native)\n ? native.includes('web')\n : native === 'web'\n const isMobileNative = Array.isArray(native)\n ? native.includes('mobile')\n : native === 'mobile'\n const isAndroidNative =\n isMobileNative ||\n (Array.isArray(native) ? native.includes('android') : native === 'android')\n const isIosNative =\n isMobileNative ||\n (Array.isArray(native) ? native.includes('ios') : native === 'ios')\n\n const isHandledNatively =\n native === true ||\n (isWeb && isWebNative) ||\n (!isWeb && isMobileNative) ||\n (Platform.OS === 'android' && isAndroidNative) ||\n (Platform.OS === 'ios' && isIosNative)\n\n if (isHandledNatively) {\n const nativeToastResult = createNativeToast(title, showOptions ?? {})\n if (typeof nativeToastResult === 'object' && nativeToastResult.nativeToastRef) {\n setLastNativeToastRef(nativeToastResult.nativeToastRef)\n }\n }\n counterRef.current++\n setToast({\n title,\n id: counterRef.current.toString(),\n viewportName: showOptions?.viewportName ?? 'default',\n ...showOptions,\n isHandledNatively,\n })\n return true\n },\n [setToast, options.native]\n )\n const hide = React.useCallback(() => {\n lastNativeToastRef?.close()\n setToast(null)\n }, [setToast, lastNativeToastRef])\n\n const contextValue = useMemo(() => {\n return {\n show,\n hide,\n nativeToast: lastNativeToastRef,\n options,\n }\n }, [show, hide, lastNativeToastRef, JSON.stringify(options || null)])\n\n return (\n <ToastContext.Provider value={contextValue}>\n <ToastCurrentContext.Provider value={toast}>\n {children}\n </ToastCurrentContext.Provider>\n </ToastContext.Provider>\n )\n}\n\nexport type { ToastImperativeProviderProps, ToastNativePlatform, ToastNativeValue }\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6JM;AA7JN,kBAAsB;AACtB,mBAAkE;AAClE,0BAAyB;AAEzB,+BAAkC;AA0DlC,MAAM,mBAAe,4BAA6B,CAAC,CAAQ;AAC3D,MAAM,0BAAsB,4BAAgC,IAAI;AAEzD,MAAM,qBAAqB,MAAM;AACtC,aAAO,yBAAW,YAAY;AAChC;AAEO,MAAM,gBAAgB,MAAM;AACjC,aAAO,yBAAW,mBAAmB;AACvC;AAGO,MAAM,WAAW,MAAM;AAC5B,SAAO;AAAA,IACL,GAAG,mBAAmB;AAAA,IACtB,cAAc,cAAc;AAAA,EAC9B;AACF;AAUO,MAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AACF,MAAoC;AAClC,QAAM,iBAAa,qBAAO,CAAC;AAE3B,QAAM,CAAC,OAAO,QAAQ,IAAI,aAAAA,QAAM,SAA2B,IAAI;AAE/D,QAAM,CAAC,oBAAoB,qBAAqB,IAC9C,aAAAA,QAAM,SAAuC,IAAI;AAEnD,QAAM,OAAO,aAAAA,QAAM;AAAA,IACjB,CAAC,OAAO,gBAAgB;AACtB,YAAM,UAAS,2CAAa,WAAU,QAAQ;AAC9C,YAAM,cAAc,MAAM,QAAQ,MAAM,IACpC,OAAO,SAAS,KAAK,IACrB,WAAW;AACf,YAAM,iBAAiB,MAAM,QAAQ,MAAM,IACvC,OAAO,SAAS,QAAQ,IACxB,WAAW;AACf,YAAM,kBACJ,mBACC,MAAM,QAAQ,MAAM,IAAI,OAAO,SAAS,SAAS,IAAI,WAAW;AACnE,YAAM,cACJ,mBACC,MAAM,QAAQ,MAAM,IAAI,OAAO,SAAS,KAAK,IAAI,WAAW;AAE/D,YAAM,oBACJ,WAAW,QACV,qBAAS,eACT,CAAC,qBAAS,kBACV,6BAAS,OAAO,aAAa,mBAC7B,6BAAS,OAAO,SAAS;AAE5B,UAAI,mBAAmB;AACrB,cAAM,wBAAoB,4CAAkB,OAAO,eAAe,CAAC,CAAC;AACpE,YAAI,OAAO,sBAAsB,YAAY,kBAAkB,gBAAgB;AAC7E,gCAAsB,kBAAkB,cAAc;AAAA,QACxD;AAAA,MACF;AACA,iBAAW;AACX,eAAS;AAAA,QACP;AAAA,QACA,IAAI,WAAW,QAAQ,SAAS;AAAA,QAChC,eAAc,2CAAa,iBAAgB;AAAA,QAC3C,GAAG;AAAA,QACH;AAAA,MACF,CAAC;AACD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,QAAQ,MAAM;AAAA,EAC3B;AACA,QAAM,OAAO,aAAAA,QAAM,YAAY,MAAM;AACnC,6DAAoB;AACpB,aAAS,IAAI;AAAA,EACf,GAAG,CAAC,UAAU,kBAAkB,CAAC;AAEjC,QAAM,mBAAe,sBAAQ,MAAM;AACjC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb;AAAA,IACF;AAAA,EACF,GAAG,CAAC,MAAM,MAAM,oBAAoB,KAAK,UAAU,WAAW,IAAI,CAAC,CAAC;AAEpE,SACE,4CAAC,aAAa,UAAb,EAAsB,OAAO,cAC5B,sDAAC,oBAAoB,UAApB,EAA6B,OAAO,OAClC,UACH,GACF;AAEJ;",
6
6
  "names": ["React"]
7
7
  }
@@ -49,13 +49,10 @@ var import_ToastViewport = require("./ToastViewport");
49
49
  const ToastImplFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
50
50
  name: "ToastImpl",
51
51
  variants: {
52
- backgrounded: {
53
- true: {
54
- backgroundColor: "$color6"
55
- }
56
- },
57
52
  unstyled: {
58
53
  false: {
54
+ focusable: true,
55
+ backgroundColor: "$color6",
59
56
  borderRadius: "$10",
60
57
  paddingHorizontal: "$5",
61
58
  paddingVertical: "$2",
@@ -65,7 +62,6 @@ const ToastImplFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
65
62
  }
66
63
  },
67
64
  defaultVariants: {
68
- backgrounded: true,
69
65
  unstyled: false
70
66
  }
71
67
  });
@@ -91,7 +87,7 @@ const ToastImpl = React.forwardRef(
91
87
  onSwipeMove,
92
88
  onSwipeCancel,
93
89
  onSwipeEnd,
94
- viewportName,
90
+ viewportName = "default",
95
91
  ...toastProps
96
92
  } = props;
97
93
  const isPresent = (0, import_animate_presence.useIsPresent)();
@@ -103,15 +99,17 @@ const ToastImpl = React.forwardRef(
103
99
  const closeTimerRemainingTimeRef = React.useRef(duration);
104
100
  const closeTimerRef = React.useRef(0);
105
101
  const { onToastAdd, onToastRemove } = context;
102
+ const viewport = React.useMemo(() => {
103
+ return context.viewports[viewportName];
104
+ }, [context.viewports, viewportName]);
106
105
  const handleClose = (0, import_core.useEvent)(() => {
107
- var _a;
108
106
  if (!isPresent) {
109
107
  return;
110
108
  }
111
109
  if (import_core.isWeb) {
112
110
  const isFocusInToast = node == null ? void 0 : node.contains(document.activeElement);
113
111
  if (isFocusInToast)
114
- (_a = context.viewport) == null ? void 0 : _a.focus();
112
+ viewport == null ? void 0 : viewport.focus();
115
113
  }
116
114
  onClose();
117
115
  });
@@ -138,7 +136,6 @@ const ToastImpl = React.forwardRef(
138
136
  React.useEffect(() => {
139
137
  if (!import_core.isWeb)
140
138
  return;
141
- const viewport = context.viewport;
142
139
  if (viewport) {
143
140
  viewport.addEventListener(import_ToastViewport.VIEWPORT_PAUSE, handlePause);
144
141
  viewport.addEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume);
@@ -147,7 +144,7 @@ const ToastImpl = React.forwardRef(
147
144
  viewport.removeEventListener(import_ToastViewport.VIEWPORT_RESUME, handleResume);
148
145
  };
149
146
  }
150
- }, [context.viewport, duration, onPause, onResume, startTimer]);
147
+ }, [viewport, duration, onPause, onResume, startTimer]);
151
148
  React.useEffect(() => {
152
149
  if (open && !context.isClosePausedRef.current) {
153
150
  startTimer(duration);
@@ -264,7 +261,6 @@ const ToastImpl = React.forwardRef(
264
261
  role: "status",
265
262
  "aria-live": "off",
266
263
  "aria-atomic": true,
267
- tabIndex: 0,
268
264
  "data-state": open ? "open" : "closed",
269
265
  "data-swipe-direction": context.swipeDirection,
270
266
  pointerEvents: "auto",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ToastImpl.tsx"],
4
- "sourcesContent": ["import { useIsPresent } from '@tamagui/animate-presence'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n GetProps,\n TamaguiElement,\n Theme,\n composeEventHandlers,\n isWeb,\n styled,\n useAnimationDriver,\n useEvent,\n useThemeName,\n} from '@tamagui/core'\nimport { Dismissable, DismissableProps } from '@tamagui/dismissable'\nimport { PortalItem } from '@tamagui/portal'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { Animated, GestureResponderEvent, PanResponder } from 'react-native'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounce } from './ToastAnnounce'\nimport {\n Collection,\n ScopedProps,\n SwipeDirection,\n createToastContext,\n useToastProviderContext,\n} from './ToastProvider'\nimport { VIEWPORT_PAUSE, VIEWPORT_RESUME } from './ToastViewport'\n\nconst ToastImplFrame = styled(ThemeableStack, {\n name: 'ToastImpl',\n variants: {\n backgrounded: {\n true: {\n backgroundColor: '$color6',\n },\n },\n unstyled: {\n false: {\n borderRadius: '$10',\n paddingHorizontal: '$5',\n paddingVertical: '$2',\n marginHorizontal: 'auto',\n marginVertical: '$1',\n },\n },\n },\n defaultVariants: {\n backgrounded: true,\n unstyled: false,\n },\n})\ninterface ToastProps extends Omit<ToastImplProps, keyof ToastImplPrivateProps> {\n /**\n * The controlled open state of the dialog. Must be used in conjunction with `onOpenChange`.\n */\n open?: boolean\n /**\n * The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.\n */\n defaultOpen?: boolean\n /**\n * Event handler called when the open state of the dialog changes.\n */\n onOpenChange?(open: boolean): void\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true\n}\n\ntype SwipeEvent = GestureResponderEvent\n\nconst [ToastInteractiveProvider, useToastInteractiveContext] = createToastContext(\n TOAST_NAME,\n {\n onClose() {},\n }\n)\n\ntype ToastImplPrivateProps = { open: boolean; onClose(): void }\ntype ToastImplFrameProps = GetProps<typeof ToastImplFrame>\ntype ToastImplProps = ToastImplPrivateProps &\n ToastImplFrameProps & {\n /**\n * Control the sensitivity of the toast for accessibility purposes.\n * For toasts that are the result of a user action, choose foreground. Toasts generated from background tasks should use background.\n */\n type?: 'foreground' | 'background'\n /**\n * Time in milliseconds that toast should remain visible for. Overrides value given to `ToastProvider`.\n */\n duration?: number\n /**\n * Event handler called when the escape key is down. It can be prevented by calling `event.preventDefault`.\n */\n onEscapeKeyDown?: DismissableProps['onEscapeKeyDown']\n /**\n * Event handler called when the dismiss timer is paused.\n * On web, this occurs when the pointer is moved over the viewport, the viewport is focused or when the window is blurred.\n * On mobile, this occurs when the toast is touched.\n */\n onPause?(): void\n /**\n * Event handler called when the dismiss timer is resumed.\n * On web, this occurs when the pointer is moved away from the viewport, the viewport is blurred or when the window is focused.\n * On mobile, this occurs when the toast is released.\n */\n onResume?(): void\n /**\n * Event handler called when starting a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeStart?(event: SwipeEvent): void\n /**\n * Event handler called during a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeMove?(event: SwipeEvent): void\n /**\n * Event handler called at the cancellation of a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeCancel?(event: SwipeEvent): void\n /**\n * Event handler called at the end of a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeEnd?(event: SwipeEvent): void\n /**\n * The viewport's name to send the toast to. Used when using multiple viewports and want to forward toasts to different ones.\n *\n * @default \"default\"\n */\n viewportName?: string\n /**\n * \n */\n id?: string\n }\n\nconst ToastImpl = React.forwardRef<TamaguiElement, ToastImplProps>(\n (props: ScopedProps<ToastImplProps>, forwardedRef) => {\n const {\n __scopeToast,\n type = 'foreground',\n duration: durationProp,\n open,\n onClose,\n onEscapeKeyDown,\n onPause,\n onResume,\n onSwipeStart,\n onSwipeMove,\n onSwipeCancel,\n onSwipeEnd,\n viewportName,\n ...toastProps\n } = props\n const isPresent = useIsPresent()\n const context = useToastProviderContext(TOAST_NAME, __scopeToast)\n const [node, setNode] = React.useState<TamaguiElement | null>(null)\n const composedRefs = useComposedRefs(forwardedRef, (node) => setNode(node))\n const duration = durationProp || context.duration\n const closeTimerStartTimeRef = React.useRef(0)\n const closeTimerRemainingTimeRef = React.useRef(duration)\n const closeTimerRef = React.useRef(0)\n const { onToastAdd, onToastRemove } = context\n const handleClose = useEvent(() => {\n if (!isPresent) {\n // already removed from the react tree\n return\n }\n // focus viewport if focus is within toast to read the remaining toast\n // count to SR users and ensure focus isn't lost\n if (isWeb) {\n const isFocusInToast = (node as HTMLDivElement)?.contains(document.activeElement)\n if (isFocusInToast) context.viewport?.focus()\n }\n onClose()\n })\n\n const startTimer = React.useCallback(\n (duration: number) => {\n if (!duration || duration === Infinity) return\n clearTimeout(closeTimerRef.current)\n closeTimerStartTimeRef.current = new Date().getTime()\n closeTimerRef.current = setTimeout(handleClose, duration) as unknown as number\n },\n [handleClose]\n )\n const handleResume = React.useCallback(() => {\n startTimer(closeTimerRemainingTimeRef.current)\n onResume?.()\n }, [onResume, startTimer])\n const handlePause = React.useCallback(() => {\n const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current\n closeTimerRemainingTimeRef.current =\n closeTimerRemainingTimeRef.current - elapsedTime\n window.clearTimeout(closeTimerRef.current)\n onPause?.()\n }, [onPause])\n\n React.useEffect(() => {\n if (!isWeb) return\n const viewport = context.viewport as HTMLElement\n if (viewport) {\n viewport.addEventListener(VIEWPORT_PAUSE, handlePause)\n viewport.addEventListener(VIEWPORT_RESUME, handleResume)\n return () => {\n viewport.removeEventListener(VIEWPORT_PAUSE, handlePause)\n viewport.removeEventListener(VIEWPORT_RESUME, handleResume)\n }\n }\n }, [context.viewport, duration, onPause, onResume, startTimer])\n\n // start timer when toast opens or duration changes.\n // we include `open` in deps because closed !== unmounted when animating\n // so it could reopen before being completely unmounted\n React.useEffect(() => {\n if (open && !context.isClosePausedRef.current) {\n startTimer(duration)\n }\n }, [open, duration, context.isClosePausedRef, startTimer])\n\n React.useEffect(() => {\n onToastAdd()\n return () => onToastRemove()\n }, [onToastAdd, onToastRemove])\n\n const announceTextContent = React.useMemo(() => {\n if (!isWeb) return null\n return node ? getAnnounceTextContent(node as HTMLDivElement) : null\n }, [node])\n\n const isHorizontalSwipe = ['left', 'right', 'horizontal'].includes(\n context.swipeDirection\n )\n\n const driver = useAnimationDriver()\n if (!driver) {\n throw new Error('Must set animations in tamagui.config.ts')\n }\n\n const { useAnimatedNumber, useAnimatedNumberStyle } = driver\n\n const animatedNumber = useAnimatedNumber(0)\n\n // temp until reanimated useAnimatedNumber fix\n const AnimatedView = (driver['NumberView'] ?? driver.View) as typeof Animated.View\n\n const animatedStyles = useAnimatedNumberStyle(animatedNumber, (val) => {\n return {\n transform: [isHorizontalSwipe ? { translateX: val } : { translateY: val }],\n }\n })\n\n const panResponder = React.useMemo(() => {\n return PanResponder.create({\n onMoveShouldSetPanResponder: (e) => {\n onSwipeStart?.(e)\n return true\n },\n onPanResponderGrant: (e) => {\n if (!isWeb) {\n handlePause?.()\n }\n },\n onPanResponderMove: (e, { dy, dx }) => {\n let y = 0\n let x = 0\n if (context.swipeDirection === 'horizontal') x = dx\n else if (context.swipeDirection === 'left') x = Math.min(0, dx)\n else if (context.swipeDirection === 'right') x = Math.max(0, dx)\n else if (context.swipeDirection === 'vertical') y = dy\n else if (context.swipeDirection === 'up') y = Math.min(0, dy)\n else if (context.swipeDirection === 'down') y = Math.max(0, dy)\n\n onSwipeMove?.(e)\n\n const delta = { x, y }\n animatedNumber.setValue(isHorizontalSwipe ? x : y, { type: 'direct' })\n if (isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)) {\n onSwipeEnd?.(e)\n }\n },\n onPanResponderEnd: (e, { dx, dy }) => {\n if (\n !isDeltaInDirection(\n { x: dx, y: dy },\n context.swipeDirection,\n context.swipeThreshold\n )\n ) {\n if (!isWeb) {\n handleResume?.()\n }\n onSwipeCancel?.(e)\n animatedNumber.setValue(0, { type: 'spring' })\n }\n },\n })\n }, [handlePause, handleResume])\n\n // need to get the theme name from context and apply it again since portals don't retain the theme\n const themeName = useThemeName()\n\n return (\n <>\n {announceTextContent && (\n <ToastAnnounce\n __scopeToast={__scopeToast}\n // Toasts are always role=status to avoid stuttering issues with role=alert in SRs.\n role=\"status\"\n aria-live={type === 'foreground' ? 'assertive' : 'polite'}\n aria-atomic\n >\n {announceTextContent}\n </ToastAnnounce>\n )}\n\n <PortalItem hostName={viewportName ?? 'default'}>\n <ToastInteractiveProvider\n key={props.id}\n scope={__scopeToast}\n onClose={() => {\n handleClose()\n }}\n >\n <Dismissable\n // asChild\n onEscapeKeyDown={composeEventHandlers(onEscapeKeyDown, () => {\n if (!context.isFocusedToastEscapeKeyDownRef.current) {\n handleClose()\n }\n context.isFocusedToastEscapeKeyDownRef.current = false\n })}\n >\n <Theme forceClassName name={themeName}>\n <AnimatedView\n {...panResponder?.panHandlers}\n style={[{ margin: 'auto' }, animatedStyles]}\n >\n <Collection.ItemSlot scope={__scopeToast}>\n <ToastImplFrame\n // Ensure toasts are announced as status list or status when focused\n role=\"status\"\n aria-live=\"off\"\n aria-atomic\n tabIndex={0}\n data-state={open ? 'open' : 'closed'}\n data-swipe-direction={context.swipeDirection}\n pointerEvents=\"auto\"\n // touchAction=\"none\"\n userSelect=\"none\"\n {...toastProps}\n ref={composedRefs}\n {...(isWeb && {\n onKeyDown: composeEventHandlers(\n (props as any).onKeyDown,\n (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n onEscapeKeyDown?.(event)\n onEscapeKeyDown?.(event)\n if (!event.defaultPrevented) {\n context.isFocusedToastEscapeKeyDownRef.current = true\n handleClose()\n }\n }\n ),\n })}\n />\n </Collection.ItemSlot>\n </AnimatedView>\n </Theme>\n </Dismissable>\n </ToastInteractiveProvider>\n </PortalItem>\n </>\n )\n }\n)\n\nToastImpl.propTypes = {\n type(props) {\n if (props.type && !['foreground', 'background'].includes(props.type)) {\n const error = `Invalid prop \\`type\\` supplied to \\`${TOAST_NAME}\\`. Expected \\`foreground | background\\`.`\n return new Error(error)\n }\n return null\n },\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\nconst isDeltaInDirection = (\n delta: { x: number; y: number },\n direction: SwipeDirection,\n threshold = 0\n) => {\n const deltaX = Math.abs(delta.x)\n const deltaY = Math.abs(delta.y)\n const isDeltaX = deltaX > deltaY\n if (direction === 'left' || direction === 'right' || direction === 'horizontal') {\n return isDeltaX && deltaX > threshold\n } else {\n return !isDeltaX && deltaY > threshold\n }\n}\n\nfunction getAnnounceTextContent(container: HTMLElement) {\n if (!isWeb) return ''\n const textContent: string[] = []\n const childNodes = Array.from(container.childNodes)\n\n childNodes.forEach((node) => {\n if (node.nodeType === node.TEXT_NODE && node.textContent)\n textContent.push(node.textContent)\n if (isHTMLElement(node)) {\n const isHidden = node.ariaHidden || node.hidden || node.style.display === 'none'\n const isExcluded = node.dataset.toastAnnounceExclude === ''\n\n if (!isHidden) {\n if (isExcluded) {\n const altText = node.dataset.toastAnnounceAlt\n if (altText) textContent.push(altText)\n } else {\n textContent.push(...getAnnounceTextContent(node))\n }\n }\n }\n })\n\n // We return a collection of text rather than a single concatenated string.\n // This allows SR VO to naturally pause break between nodes while announcing.\n return textContent\n}\n\nfunction isHTMLElement(node: any): node is HTMLElement {\n return node.nodeType === node.ELEMENT_NODE\n}\n\nexport { ToastImpl, ToastImplFrame, ToastImplProps, useToastInteractiveContext }\nexport type { ToastProps }\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkTM;AAlTN,8BAA6B;AAC7B,0BAAgC;AAChC,kBAUO;AACP,yBAA8C;AAC9C,oBAA2B;AAC3B,oBAA+B;AAC/B,YAAuB;AACvB,0BAA8D;AAE9D,uBAA2B;AAC3B,2BAA8B;AAC9B,2BAMO;AACP,2BAAgD;AAEhD,MAAM,qBAAiB,oBAAO,8BAAgB;AAAA,EAC5C,MAAM;AAAA,EACN,UAAU;AAAA,IACR,cAAc;AAAA,MACZ,MAAM;AAAA,QACJ,iBAAiB;AAAA,MACnB;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,OAAO;AAAA,QACL,cAAc;AAAA,QACd,mBAAmB;AAAA,QACnB,iBAAiB;AAAA,QACjB,kBAAkB;AAAA,QAClB,gBAAgB;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,cAAc;AAAA,IACd,UAAU;AAAA,EACZ;AACF,CAAC;AAuBD,MAAM,CAAC,0BAA0B,0BAA0B,QAAI;AAAA,EAC7D;AAAA,EACA;AAAA,IACE,UAAU;AAAA,IAAC;AAAA,EACb;AACF;AA2DA,MAAM,YAAY,MAAM;AAAA,EACtB,CAAC,OAAoC,iBAAiB;AACpD,UAAM;AAAA,MACJ;AAAA,MACA,OAAO;AAAA,MACP,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AACJ,UAAM,gBAAY,sCAAa;AAC/B,UAAM,cAAU,8CAAwB,6BAAY,YAAY;AAChE,UAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAgC,IAAI;AAClE,UAAM,mB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,MAAM,IAAI,GAAG;AACpE,YAAM,QAAQ,uCAAuC;AACrD,aAAO,IAAI,MAAM,KAAK;AAAA,IACxB;AACA,WAAO;AAAA,EACT;AACF;AAIA,MAAM,qBAAqB,CACzB,OACA,WACA,YAAY,MACT;AACH,QAAM,SAAS,KAAK,IAAI,MAAM,CAAC;AAC/B,QAAM,SAAS,KAAK,IAAI,MAAM,CAAC;AAC/B,QAAM,WAAW,SAAS;AAC1B,MAAI,cAAc,UAAU,cAAc,WAAW,cAAc,cAAc;AAC/E,WAAO,YAAY,SAAS;AAAA,EAC9B,OAAO;AACL,WAAO,CAAC,YAAY,SAAS;AAAA,EAC/B;AACF;AAEA,SAAS,uBAAuB,WAAwB;AACtD,MAAI,CAAC;AAAO,WAAO;AACnB,QAAM,cAAwB,CAAC;AAC/B,QAAM,aAAa,MAAM,KAAK,UAAU,UAAU;AAElD,aAAW,QAAQ,CAAC,SAAS;AAC3B,QAAI,KAAK,aAAa,KAAK,aAAa,KAAK;AAC3C,kBAAY,KAAK,KAAK,WAAW;AACnC,QAAI,cAAc,IAAI,GAAG;AACvB,YAAM,WAAW,KAAK,cAAc,KAAK,UAAU,KAAK,MAAM,YAAY;AAC1E,YAAM,aAAa,KAAK,QAAQ,yBAAyB;AAEzD,UAAI,CAAC,UAAU;AACb,YAAI,YAAY;AACd,gBAAM,UAAU,KAAK,QAAQ;AAC7B,cAAI;AAAS,wBAAY,KAAK,OAAO;AAAA,QACvC,OAAO;AACL,sBAAY,KAAK,GAAG,uBAAuB,IAAI,CAAC;AAAA,QAClD;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAID,SAAO;AACT;AAEA,SAAS,cAAc,MAAgC;AACrD,SAAO,KAAK,aAAa,KAAK;AAChC;",
4
+ "sourcesContent": ["import { useIsPresent } from '@tamagui/animate-presence'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n GetProps,\n TamaguiElement,\n Theme,\n composeEventHandlers,\n isWeb,\n styled,\n useAnimationDriver,\n useEvent,\n useThemeName,\n} from '@tamagui/core'\nimport { Dismissable, DismissableProps } from '@tamagui/dismissable'\nimport { PortalItem } from '@tamagui/portal'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { Animated, GestureResponderEvent, PanResponder } from 'react-native'\n\nimport { TOAST_NAME } from './constants'\nimport { ToastAnnounce } from './ToastAnnounce'\nimport {\n Collection,\n ScopedProps,\n SwipeDirection,\n createToastContext,\n useToastProviderContext,\n} from './ToastProvider'\nimport { VIEWPORT_PAUSE, VIEWPORT_RESUME } from './ToastViewport'\n\nconst ToastImplFrame = styled(ThemeableStack, {\n name: 'ToastImpl',\n variants: {\n unstyled: {\n false: {\n focusable: true,\n backgroundColor: '$color6',\n borderRadius: '$10',\n paddingHorizontal: '$5',\n paddingVertical: '$2',\n marginHorizontal: 'auto',\n marginVertical: '$1',\n },\n },\n } as const,\n defaultVariants: {\n unstyled: false,\n },\n})\ninterface ToastProps extends Omit<ToastImplProps, keyof ToastImplPrivateProps> {\n /**\n * The controlled open state of the dialog. Must be used in conjunction with `onOpenChange`.\n */\n open?: boolean\n /**\n * The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.\n */\n defaultOpen?: boolean\n /**\n * Event handler called when the open state of the dialog changes.\n */\n onOpenChange?(open: boolean): void\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true\n}\n\ntype SwipeEvent = GestureResponderEvent\n\nconst [ToastInteractiveProvider, useToastInteractiveContext] = createToastContext(\n TOAST_NAME,\n {\n onClose() {},\n }\n)\n\ntype ToastImplPrivateProps = { open: boolean; onClose(): void }\ntype ToastImplFrameProps = GetProps<typeof ToastImplFrame>\ntype ToastImplProps = ToastImplPrivateProps &\n ToastImplFrameProps & {\n /**\n * Control the sensitivity of the toast for accessibility purposes.\n * For toasts that are the result of a user action, choose foreground. Toasts generated from background tasks should use background.\n */\n type?: 'foreground' | 'background'\n /**\n * Time in milliseconds that toast should remain visible for. Overrides value given to `ToastProvider`.\n */\n duration?: number\n /**\n * Event handler called when the escape key is down. It can be prevented by calling `event.preventDefault`.\n */\n onEscapeKeyDown?: DismissableProps['onEscapeKeyDown']\n /**\n * Event handler called when the dismiss timer is paused.\n * On web, this occurs when the pointer is moved over the viewport, the viewport is focused or when the window is blurred.\n * On mobile, this occurs when the toast is touched.\n */\n onPause?(): void\n /**\n * Event handler called when the dismiss timer is resumed.\n * On web, this occurs when the pointer is moved away from the viewport, the viewport is blurred or when the window is focused.\n * On mobile, this occurs when the toast is released.\n */\n onResume?(): void\n /**\n * Event handler called when starting a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeStart?(event: SwipeEvent): void\n /**\n * Event handler called during a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeMove?(event: SwipeEvent): void\n /**\n * Event handler called at the cancellation of a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeCancel?(event: SwipeEvent): void\n /**\n * Event handler called at the end of a swipe interaction. It can be prevented by calling `event.preventDefault`.\n */\n onSwipeEnd?(event: SwipeEvent): void\n /**\n * The viewport's name to send the toast to. Used when using multiple viewports and want to forward toasts to different ones.\n *\n * @default \"default\"\n */\n viewportName?: string\n /**\n *\n */\n id?: string\n }\n\nconst ToastImpl = React.forwardRef<TamaguiElement, ToastImplProps>(\n (props: ScopedProps<ToastImplProps>, forwardedRef) => {\n const {\n __scopeToast,\n type = 'foreground',\n duration: durationProp,\n open,\n onClose,\n onEscapeKeyDown,\n onPause,\n onResume,\n onSwipeStart,\n onSwipeMove,\n onSwipeCancel,\n onSwipeEnd,\n viewportName = 'default',\n ...toastProps\n } = props\n const isPresent = useIsPresent()\n const context = useToastProviderContext(TOAST_NAME, __scopeToast)\n const [node, setNode] = React.useState<TamaguiElement | null>(null)\n const composedRefs = useComposedRefs(forwardedRef, (node) => setNode(node))\n const duration = durationProp || context.duration\n const closeTimerStartTimeRef = React.useRef(0)\n const closeTimerRemainingTimeRef = React.useRef(duration)\n const closeTimerRef = React.useRef(0)\n const { onToastAdd, onToastRemove } = context\n\n const viewport = React.useMemo(() => {\n return context.viewports[viewportName] as HTMLElement | null | undefined\n }, [context.viewports, viewportName])\n\n const handleClose = useEvent(() => {\n if (!isPresent) {\n // already removed from the react tree\n return\n }\n // focus viewport if focus is within toast to read the remaining toast\n // count to SR users and ensure focus isn't lost\n if (isWeb) {\n const isFocusInToast = (node as HTMLDivElement)?.contains(document.activeElement)\n if (isFocusInToast) viewport?.focus()\n }\n onClose()\n })\n\n const startTimer = React.useCallback(\n (duration: number) => {\n if (!duration || duration === Infinity) return\n clearTimeout(closeTimerRef.current)\n closeTimerStartTimeRef.current = new Date().getTime()\n closeTimerRef.current = setTimeout(handleClose, duration) as unknown as number\n },\n [handleClose]\n )\n const handleResume = React.useCallback(() => {\n startTimer(closeTimerRemainingTimeRef.current)\n onResume?.()\n }, [onResume, startTimer])\n const handlePause = React.useCallback(() => {\n const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current\n closeTimerRemainingTimeRef.current =\n closeTimerRemainingTimeRef.current - elapsedTime\n window.clearTimeout(closeTimerRef.current)\n onPause?.()\n }, [onPause])\n\n React.useEffect(() => {\n if (!isWeb) return\n\n if (viewport) {\n viewport.addEventListener(VIEWPORT_PAUSE, handlePause)\n viewport.addEventListener(VIEWPORT_RESUME, handleResume)\n return () => {\n viewport.removeEventListener(VIEWPORT_PAUSE, handlePause)\n viewport.removeEventListener(VIEWPORT_RESUME, handleResume)\n }\n }\n }, [viewport, duration, onPause, onResume, startTimer])\n\n // start timer when toast opens or duration changes.\n // we include `open` in deps because closed !== unmounted when animating\n // so it could reopen before being completely unmounted\n React.useEffect(() => {\n if (open && !context.isClosePausedRef.current) {\n startTimer(duration)\n }\n }, [open, duration, context.isClosePausedRef, startTimer])\n\n React.useEffect(() => {\n onToastAdd()\n return () => onToastRemove()\n }, [onToastAdd, onToastRemove])\n\n const announceTextContent = React.useMemo(() => {\n if (!isWeb) return null\n return node ? getAnnounceTextContent(node as HTMLDivElement) : null\n }, [node])\n\n const isHorizontalSwipe = ['left', 'right', 'horizontal'].includes(\n context.swipeDirection\n )\n\n const driver = useAnimationDriver()\n if (!driver) {\n throw new Error('Must set animations in tamagui.config.ts')\n }\n\n const { useAnimatedNumber, useAnimatedNumberStyle } = driver\n\n const animatedNumber = useAnimatedNumber(0)\n\n // temp until reanimated useAnimatedNumber fix\n const AnimatedView = (driver['NumberView'] ?? driver.View) as typeof Animated.View\n\n const animatedStyles = useAnimatedNumberStyle(animatedNumber, (val) => {\n return {\n transform: [isHorizontalSwipe ? { translateX: val } : { translateY: val }],\n }\n })\n\n const panResponder = React.useMemo(() => {\n return PanResponder.create({\n onMoveShouldSetPanResponder: (e) => {\n onSwipeStart?.(e)\n return true\n },\n onPanResponderGrant: (e) => {\n if (!isWeb) {\n handlePause?.()\n }\n },\n onPanResponderMove: (e, { dy, dx }) => {\n let y = 0\n let x = 0\n if (context.swipeDirection === 'horizontal') x = dx\n else if (context.swipeDirection === 'left') x = Math.min(0, dx)\n else if (context.swipeDirection === 'right') x = Math.max(0, dx)\n else if (context.swipeDirection === 'vertical') y = dy\n else if (context.swipeDirection === 'up') y = Math.min(0, dy)\n else if (context.swipeDirection === 'down') y = Math.max(0, dy)\n\n onSwipeMove?.(e)\n\n const delta = { x, y }\n animatedNumber.setValue(isHorizontalSwipe ? x : y, { type: 'direct' })\n if (isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)) {\n onSwipeEnd?.(e)\n }\n },\n onPanResponderEnd: (e, { dx, dy }) => {\n if (\n !isDeltaInDirection(\n { x: dx, y: dy },\n context.swipeDirection,\n context.swipeThreshold\n )\n ) {\n if (!isWeb) {\n handleResume?.()\n }\n onSwipeCancel?.(e)\n animatedNumber.setValue(0, { type: 'spring' })\n }\n },\n })\n }, [handlePause, handleResume])\n\n // need to get the theme name from context and apply it again since portals don't retain the theme\n const themeName = useThemeName()\n\n return (\n <>\n {announceTextContent && (\n <ToastAnnounce\n __scopeToast={__scopeToast}\n // Toasts are always role=status to avoid stuttering issues with role=alert in SRs.\n role=\"status\"\n aria-live={type === 'foreground' ? 'assertive' : 'polite'}\n aria-atomic\n >\n {announceTextContent}\n </ToastAnnounce>\n )}\n\n <PortalItem hostName={viewportName ?? 'default'}>\n <ToastInteractiveProvider\n key={props.id}\n scope={__scopeToast}\n onClose={() => {\n handleClose()\n }}\n >\n <Dismissable\n // asChild\n onEscapeKeyDown={composeEventHandlers(onEscapeKeyDown, () => {\n if (!context.isFocusedToastEscapeKeyDownRef.current) {\n handleClose()\n }\n context.isFocusedToastEscapeKeyDownRef.current = false\n })}\n >\n <Theme forceClassName name={themeName}>\n <AnimatedView\n {...panResponder?.panHandlers}\n style={[{ margin: 'auto' }, animatedStyles]}\n >\n <Collection.ItemSlot scope={__scopeToast}>\n <ToastImplFrame\n // Ensure toasts are announced as status list or status when focused\n role=\"status\"\n aria-live=\"off\"\n aria-atomic\n data-state={open ? 'open' : 'closed'}\n data-swipe-direction={context.swipeDirection}\n pointerEvents=\"auto\"\n // touchAction=\"none\"\n userSelect=\"none\"\n {...toastProps}\n ref={composedRefs}\n {...(isWeb && {\n onKeyDown: composeEventHandlers(\n (props as any).onKeyDown,\n (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n onEscapeKeyDown?.(event)\n onEscapeKeyDown?.(event)\n if (!event.defaultPrevented) {\n context.isFocusedToastEscapeKeyDownRef.current = true\n handleClose()\n }\n }\n ),\n })}\n />\n </Collection.ItemSlot>\n </AnimatedView>\n </Theme>\n </Dismissable>\n </ToastInteractiveProvider>\n </PortalItem>\n </>\n )\n }\n)\n\nToastImpl.propTypes = {\n type(props) {\n if (props.type && !['foreground', 'background'].includes(props.type)) {\n const error = `Invalid prop \\`type\\` supplied to \\`${TOAST_NAME}\\`. Expected \\`foreground | background\\`.`\n return new Error(error)\n }\n return null\n },\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\nconst isDeltaInDirection = (\n delta: { x: number; y: number },\n direction: SwipeDirection,\n threshold = 0\n) => {\n const deltaX = Math.abs(delta.x)\n const deltaY = Math.abs(delta.y)\n const isDeltaX = deltaX > deltaY\n if (direction === 'left' || direction === 'right' || direction === 'horizontal') {\n return isDeltaX && deltaX > threshold\n } else {\n return !isDeltaX && deltaY > threshold\n }\n}\n\nfunction getAnnounceTextContent(container: HTMLElement) {\n if (!isWeb) return ''\n const textContent: string[] = []\n const childNodes = Array.from(container.childNodes)\n\n childNodes.forEach((node) => {\n if (node.nodeType === node.TEXT_NODE && node.textContent)\n textContent.push(node.textContent)\n if (isHTMLElement(node)) {\n const isHidden = node.ariaHidden || node.hidden || node.style.display === 'none'\n const isExcluded = node.dataset.toastAnnounceExclude === ''\n\n if (!isHidden) {\n if (isExcluded) {\n const altText = node.dataset.toastAnnounceAlt\n if (altText) textContent.push(altText)\n } else {\n textContent.push(...getAnnounceTextContent(node))\n }\n }\n }\n })\n\n // We return a collection of text rather than a single concatenated string.\n // This allows SR VO to naturally pause break between nodes while announcing.\n return textContent\n}\n\nfunction isHTMLElement(node: any): node is HTMLElement {\n return node.nodeType === node.ELEMENT_NODE\n}\n\nexport { ToastImpl, ToastImplFrame, ToastImplProps, useToastInteractiveContext }\nexport type { ToastProps }\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmTM;AAnTN,8BAA6B;AAC7B,0BAAgC;AAChC,kBAUO;AACP,yBAA8C;AAC9C,oBAA2B;AAC3B,oBAA+B;AAC/B,YAAuB;AACvB,0BAA8D;AAE9D,uBAA2B;AAC3B,2BAA8B;AAC9B,2BAMO;AACP,2BAAgD;AAEhD,MAAM,qBAAiB,oBAAO,8BAAgB;AAAA,EAC5C,MAAM;AAAA,EACN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,WAAW;AAAA,QACX,iBAAiB;AAAA,QACjB,cAAc;AAAA,QACd,mBAAmB;AAAA,QAC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AAU,UAAU;AAElD,aAAW,QAAQ,CAAC,SAAS;AAC3B,QAAI,KAAK,aAAa,KAAK,aAAa,KAAK;AAC3C,kBAAY,KAAK,KAAK,WAAW;AACnC,QAAI,cAAc,IAAI,GAAG;AACvB,YAAM,WAAW,KAAK,cAAc,KAAK,UAAU,KAAK,MAAM,YAAY;AAC1E,YAAM,aAAa,KAAK,QAAQ,yBAAyB;AAEzD,UAAI,CAAC,UAAU;AACb,YAAI,YAAY;AACd,gBAAM,UAAU,KAAK,QAAQ;AAC7B,cAAI;AAAS,wBAAY,KAAK,OAAO;AAAA,QACvC,OAAO;AACL,sBAAY,KAAK,GAAG,uBAAuB,IAAI,CAAC;AAAA,QAClD;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAID,SAAO;AACT;AAEA,SAAS,cAAc,MAAgC;AACrD,SAAO,KAAK,aAAa,KAAK;AAChC;",
6
6
  "names": ["node", "duration"]
7
7
  }
@@ -61,10 +61,16 @@ const ToastProvider = (props) => {
61
61
  children
62
62
  } = props;
63
63
  const id = providedId ?? React.useId();
64
- const [viewport, setViewport] = React.useState(null);
64
+ const [viewports, setViewports] = React.useState({});
65
65
  const [toastCount, setToastCount] = React.useState(0);
66
66
  const isFocusedToastEscapeKeyDownRef = React.useRef(false);
67
67
  const isClosePausedRef = React.useRef(false);
68
+ const handleViewportChange = React.useCallback(
69
+ (name, viewport) => {
70
+ setViewports((prev) => ({ ...prev, [name]: viewport }));
71
+ },
72
+ []
73
+ );
68
74
  const options = React.useMemo(() => {
69
75
  return {
70
76
  duration,
@@ -83,8 +89,8 @@ const ToastProvider = (props) => {
83
89
  swipeDirection,
84
90
  swipeThreshold,
85
91
  toastCount,
86
- viewport,
87
- onViewportChange: setViewport,
92
+ viewports,
93
+ onViewportChange: handleViewportChange,
88
94
  onToastAdd: React.useCallback(() => {
89
95
  setToastCount((prevCount) => prevCount + 1);
90
96
  }, []),
@@ -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 } 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 ?? React.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;AAGjC,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,cAAc,MAAM,MAAM;AACrC,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;",
4
+ "sourcesContent": ["import { createCollection } from '@tamagui/collection'\nimport { TamaguiElement } 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 viewports: Record<string, TamaguiElement | null>\n onViewportChange(name: string, 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 ?? React.useId()\n const [viewports, setViewports] = React.useState<\n ToastProviderContextValue['viewports']\n >({})\n const [toastCount, setToastCount] = React.useState(0)\n const isFocusedToastEscapeKeyDownRef = React.useRef(false)\n const isClosePausedRef = React.useRef(false)\n\n const handleViewportChange = React.useCallback(\n (name: string, viewport: TamaguiElement | null) => {\n setViewports((prev) => ({ ...prev, [name]: viewport }))\n },\n []\n )\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 viewports={viewports}\n onViewportChange={handleViewportChange}\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;AAiJQ;AAjJR,wBAAiC;AAGjC,4BAAmC;AACnC,YAAuB;AAEvB,6BAA0D;AAO1D,MAAM,gBAAgB;AAEtB,MAAM,CAAC,YAAY,eAAe,qBAAqB,QACrD,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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
  }
@@ -49,23 +49,39 @@ const VIEWPORT_PAUSE = "toast.viewportPause";
49
49
  const VIEWPORT_RESUME = "toast.viewportResume";
50
50
  const ToastViewportWrapperFrame = (0, import_core.styled)(import_stacks.YStack, {
51
51
  name: "ViewportWrapper",
52
- pointerEvents: "box-none",
53
- top: 0,
54
- bottom: 0,
55
- left: 0,
56
- right: 0,
57
- // @ts-ignore
58
- position: import_core.isWeb ? "fixed" : "absolute",
59
- maxWidth: "100%",
60
- tabIndex: 0,
61
- zIndex: 1e5
52
+ variants: {
53
+ unstyled: {
54
+ false: {
55
+ pointerEvents: "box-none",
56
+ top: 0,
57
+ bottom: 0,
58
+ left: 0,
59
+ right: 0,
60
+ position: import_core.isWeb ? "fixed" : "absolute",
61
+ maxWidth: "100%",
62
+ tabIndex: 0,
63
+ zIndex: 1e5
64
+ }
65
+ }
66
+ },
67
+ defaultVariants: {
68
+ unstyled: false
69
+ }
62
70
  });
63
71
  const ToastViewportFrame = (0, import_core.styled)(import_stacks.YStack, {
64
72
  name: VIEWPORT_NAME,
65
- pointerEvents: "box-none",
66
- // @ts-ignore
67
- position: import_core.isWeb ? "fixed" : "absolute",
68
- maxWidth: "100%"
73
+ variants: {
74
+ unstyled: {
75
+ false: {
76
+ pointerEvents: "box-none",
77
+ position: import_core.isWeb ? "fixed" : "absolute",
78
+ maxWidth: "100%"
79
+ }
80
+ }
81
+ },
82
+ defaultVariants: {
83
+ unstyled: false
84
+ }
69
85
  });
70
86
  const ToastViewport = React.forwardRef(
71
87
  (props, forwardedRef) => {
@@ -73,7 +89,7 @@ const ToastViewport = React.forwardRef(
73
89
  __scopeToast,
74
90
  hotkey = VIEWPORT_DEFAULT_HOTKEY,
75
91
  label = "Notifications ({hotkey})",
76
- name,
92
+ name = "default",
77
93
  multipleToasts,
78
94
  ...viewportProps
79
95
  } = props;
@@ -83,7 +99,14 @@ const ToastViewport = React.forwardRef(
83
99
  const tailFocusProxyRef = React.useRef(null);
84
100
  const wrapperRef = React.useRef(null);
85
101
  const ref = React.useRef(null);
86
- const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, context.onViewportChange);
102
+ const onViewportChange = React.useCallback(
103
+ (el) => {
104
+ if (context.viewports[name] !== el)
105
+ context.onViewportChange(name, el);
106
+ },
107
+ [name, context.viewports]
108
+ );
109
+ const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, onViewportChange);
87
110
  const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
88
111
  const hasToasts = context.toastCount > 0;
89
112
  React.useEffect(() => {
@@ -212,6 +235,7 @@ const ToastViewport = React.forwardRef(
212
235
  hasToasts && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
213
236
  FocusProxy,
214
237
  {
238
+ viewportName: name,
215
239
  ref: headFocusProxyRef,
216
240
  onFocusFromOutsideViewport: () => {
217
241
  const tabbableCandidates = getSortedTabbableCandidates({
@@ -231,6 +255,7 @@ const ToastViewport = React.forwardRef(
231
255
  hasToasts && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
232
256
  FocusProxy,
233
257
  {
258
+ viewportName: name,
234
259
  ref: tailFocusProxyRef,
235
260
  onFocusFromOutsideViewport: () => {
236
261
  const tabbableCandidates = getSortedTabbableCandidates({
@@ -249,8 +274,9 @@ ToastViewport.displayName = VIEWPORT_NAME;
249
274
  const FOCUS_PROXY_NAME = "ToastFocusProxy";
250
275
  const FocusProxy = React.forwardRef(
251
276
  (props, forwardedRef) => {
252
- const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props;
277
+ const { __scopeToast, onFocusFromOutsideViewport, viewportName, ...proxyProps } = props;
253
278
  const context = (0, import_ToastProvider.useToastProviderContext)(FOCUS_PROXY_NAME, __scopeToast);
279
+ const viewport = context.viewports[viewportName];
254
280
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
255
281
  import_visually_hidden.VisuallyHidden,
256
282
  {
@@ -260,13 +286,10 @@ const FocusProxy = React.forwardRef(
260
286
  ref: forwardedRef,
261
287
  position: import_core.isWeb ? "fixed" : "absolute",
262
288
  onFocus: (event) => {
263
- var _a;
264
289
  if (!import_core.isWeb)
265
290
  return;
266
291
  const prevFocusedElement = event.relatedTarget;
267
- const isFocusFromOutsideViewport = !((_a = context.viewport) == null ? void 0 : _a.contains(
268
- prevFocusedElement
269
- ));
292
+ const isFocusFromOutsideViewport = !(viewport == null ? void 0 : viewport.contains(prevFocusedElement));
270
293
  if (isFocusFromOutsideViewport)
271
294
  onFocusFromOutsideViewport();
272
295
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ToastViewport.tsx"],
4
- "sourcesContent": ["import { AnimatePresence } from '@tamagui/animate-presence'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport { GetProps, TamaguiElement, isWeb, styled } from '@tamagui/core'\nimport { PortalHost } from '@tamagui/portal'\nimport { YStack } from '@tamagui/stacks'\nimport { VisuallyHidden } from '@tamagui/visually-hidden'\nimport * as React from 'react'\n\nimport {\n Collection,\n ScopedProps,\n useCollection,\n useToastProviderContext,\n} from './ToastProvider'\n\nconst VIEWPORT_NAME = 'ToastViewport'\nconst VIEWPORT_DEFAULT_HOTKEY = ['F8']\nconst VIEWPORT_PAUSE = 'toast.viewportPause'\nconst VIEWPORT_RESUME = 'toast.viewportResume'\n\nconst ToastViewportWrapperFrame = styled(YStack, {\n name: 'ViewportWrapper',\n pointerEvents: 'box-none',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n // @ts-ignore\n position: isWeb ? 'fixed' : 'absolute',\n maxWidth: '100%',\n tabIndex: 0,\n zIndex: 100000,\n})\n\nconst ToastViewportFrame = styled(YStack, {\n name: VIEWPORT_NAME,\n pointerEvents: 'box-none',\n // @ts-ignore\n position: isWeb ? 'fixed' : 'absolute',\n maxWidth: '100%',\n})\ntype ToastViewportFrameProps = GetProps<typeof ToastViewportFrame>\ntype ToastViewportProps = ToastViewportFrameProps & {\n /**\n * The keys to use as the keyboard shortcut that will move focus to the toast viewport.\n * @defaultValue ['F8']\n */\n hotkey?: string[]\n /**\n * An author-localized label for the toast viewport to provide context for screen reader users\n * when navigating page landmarks. The available `{hotkey}` placeholder will be replaced for you.\n * @defaultValue 'Notifications ({hotkey})'\n */\n label?: string\n /**\n * Used to reference the viewport if you want to have multiple viewports in the same provider.\n */\n name?: string\n /**\n * Pass this when you want to have multiple/duplicated toasts.\n */\n multipleToasts?: boolean\n}\n\nconst ToastViewport = React.forwardRef<HTMLDivElement, ToastViewportProps>(\n (props: ScopedProps<ToastViewportProps>, forwardedRef) => {\n const {\n __scopeToast,\n hotkey = VIEWPORT_DEFAULT_HOTKEY,\n label = 'Notifications ({hotkey})',\n name,\n multipleToasts,\n ...viewportProps\n } = props\n const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast)\n const getItems = useCollection(__scopeToast)\n const headFocusProxyRef = React.useRef<FocusProxyElement>(null)\n const tailFocusProxyRef = React.useRef<FocusProxyElement>(null)\n const wrapperRef = React.useRef<HTMLDivElement>(null)\n const ref = React.useRef<HTMLDivElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange)\n const hotkeyLabel = hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '')\n const hasToasts = context.toastCount > 0\n\n React.useEffect(() => {\n if (!isWeb) return\n if (context.toastCount === 0) return\n const handleKeyDown = (event: KeyboardEvent) => {\n // we use `event.code` as it is consistent regardless of meta keys that were pressed.\n // for example, `event.key` for `Control+Alt+t` is `\u2020` and `t !== \u2020`\n const isHotkeyPressed = hotkey.every(\n (key) => (event as any)[key] || event.code === key\n )\n if (isHotkeyPressed) ref.current?.focus()\n }\n document.addEventListener('keydown', handleKeyDown)\n return () => {\n document.removeEventListener('keydown', handleKeyDown)\n }\n }, [hotkey, context.toastCount])\n\n React.useEffect(() => {\n if (!isWeb) return\n if (context.toastCount === 0) return\n const wrapper = wrapperRef.current\n const viewport = ref.current\n if (hasToasts && wrapper && viewport) {\n const handlePause = () => {\n if (!context.isClosePausedRef.current) {\n const pauseEvent = new CustomEvent(VIEWPORT_PAUSE)\n viewport.dispatchEvent(pauseEvent)\n context.isClosePausedRef.current = true\n }\n }\n\n const handleResume = () => {\n if (context.isClosePausedRef.current) {\n const resumeEvent = new CustomEvent(VIEWPORT_RESUME)\n viewport.dispatchEvent(resumeEvent)\n context.isClosePausedRef.current = false\n }\n }\n\n const handleFocusOutResume = (event: FocusEvent) => {\n const isFocusMovingOutside = !wrapper.contains(\n event.relatedTarget as HTMLElement\n )\n if (isFocusMovingOutside) handleResume()\n }\n\n const handlePointerLeaveResume = () => {\n const isFocusInside = wrapper.contains(document.activeElement)\n if (!isFocusInside) handleResume()\n }\n // Toasts are not in the viewport React tree so we need to bind DOM events\n\n wrapper.addEventListener('focusin', handlePause)\n wrapper.addEventListener('focusout', handleFocusOutResume)\n wrapper.addEventListener('pointermove', handlePause)\n wrapper.addEventListener('pointerleave', handlePointerLeaveResume)\n window.addEventListener('blur', handlePause)\n window.addEventListener('focus', handleResume)\n return () => {\n wrapper.removeEventListener('focusin', handlePause)\n wrapper.removeEventListener('focusout', handleFocusOutResume)\n wrapper.removeEventListener('pointermove', handlePause)\n wrapper.removeEventListener('pointerleave', handlePointerLeaveResume)\n window.removeEventListener('blur', handlePause)\n window.removeEventListener('focus', handleResume)\n }\n }\n }, [hasToasts, context.isClosePausedRef, context.toastCount])\n\n const getSortedTabbableCandidates = React.useCallback(\n ({ tabbingDirection }: { tabbingDirection: 'forwards' | 'backwards' }) => {\n const toastItems = getItems()\n const tabbableCandidates = toastItems.map((toastItem) => {\n const toastNode = toastItem.ref.current!\n const toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)]\n return tabbingDirection === 'forwards'\n ? toastTabbableCandidates\n : toastTabbableCandidates.reverse()\n })\n return (\n tabbingDirection === 'forwards'\n ? tabbableCandidates.reverse()\n : tabbableCandidates\n ).flat()\n },\n [getItems]\n )\n\n React.useEffect(() => {\n if (!isWeb) return\n if (context.toastCount === 0) return\n\n const viewport = ref.current\n // We programmatically manage tabbing as we are unable to influence\n // the source order with portals, this allows us to reverse the\n // tab order so that it runs from most recent toast to least\n if (viewport) {\n const handleKeyDown = (event: KeyboardEvent) => {\n const isMetaKey = event.altKey || event.ctrlKey || event.metaKey\n const isTabKey = event.key === 'Tab' && !isMetaKey\n\n if (isTabKey) {\n const focusedElement = document.activeElement\n const isTabbingBackwards = event.shiftKey\n const targetIsViewport = event.target === viewport\n\n // If we're back tabbing after jumping to the viewport then we simply\n // proxy focus out to the preceding document\n if (targetIsViewport && isTabbingBackwards) {\n headFocusProxyRef.current?.focus()\n return\n }\n\n const tabbingDirection = isTabbingBackwards ? 'backwards' : 'forwards'\n const sortedCandidates = getSortedTabbableCandidates({ tabbingDirection })\n const index = sortedCandidates.findIndex(\n (candidate) => candidate === focusedElement\n )\n if (focusFirst(sortedCandidates.slice(index + 1))) {\n event.preventDefault()\n } else {\n // If we can't focus that means we're at the edges so we\n // proxy to the corresponding exit point and let the browser handle\n // tab/shift+tab keypress and implicitly pass focus to the next valid element in the document\n isTabbingBackwards\n ? headFocusProxyRef.current?.focus()\n : tailFocusProxyRef.current?.focus()\n }\n }\n }\n\n // Toasts are not in the viewport React tree so we need to bind DOM events\n viewport.addEventListener('keydown', handleKeyDown)\n return () => viewport.removeEventListener('keydown', handleKeyDown)\n }\n }, [getItems, getSortedTabbableCandidates, context.toastCount])\n\n return (\n <ToastViewportWrapperFrame\n ref={wrapperRef}\n role=\"region\"\n aria-label={label.replace('{hotkey}', hotkeyLabel)}\n // // Ensure virtual cursor from landmarks menus triggers focus/blur for pause/resume\n tabIndex={-1}\n // // incase list has size when empty (e.g. padding), we remove pointer events so\n // // it doesn't prevent interactions with page elements that it overlays\n // pointerEvents={hasToasts ? undefined : 'none'}\n >\n {hasToasts && (\n <FocusProxy\n ref={headFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'forwards',\n })\n focusFirst(tabbableCandidates)\n }}\n />\n )}\n {/**\n * tabindex on the the list so that it can be focused when items are removed. we focus\n * the list instead of the viewport so it announces number of items remaining.\n */}\n <Collection.Slot scope={__scopeToast}>\n <ToastViewportFrame ref={composedRefs} {...viewportProps}>\n <PortalHost\n render={(children) => (\n <AnimatePresence exitBeforeEnter={!multipleToasts}>\n {children}\n </AnimatePresence>\n )}\n name={name ?? 'default'}\n />\n </ToastViewportFrame>\n </Collection.Slot>\n {hasToasts && (\n <FocusProxy\n ref={tailFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'backwards',\n })\n focusFirst(tabbableCandidates)\n }}\n />\n )}\n </ToastViewportWrapperFrame>\n )\n }\n)\n\nToastViewport.displayName = VIEWPORT_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst FOCUS_PROXY_NAME = 'ToastFocusProxy'\n\ntype FocusProxyElement = React.ElementRef<typeof VisuallyHidden>\ntype VisuallyHiddenProps = GetProps<typeof VisuallyHidden>\ninterface FocusProxyProps extends VisuallyHiddenProps {\n onFocusFromOutsideViewport(): void\n}\n\nconst FocusProxy = React.forwardRef<FocusProxyElement, ScopedProps<FocusProxyProps>>(\n (props, forwardedRef) => {\n const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props\n const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast)\n\n return (\n <VisuallyHidden\n aria-hidden\n tabIndex={0}\n {...proxyProps}\n ref={forwardedRef}\n // Avoid page scrolling when focus is on the focus proxy\n position={isWeb ? ('fixed' as any) : 'absolute'}\n onFocus={(event) => {\n if (!isWeb) return\n const prevFocusedElement = event.relatedTarget as HTMLElement | null\n const isFocusFromOutsideViewport = !(context.viewport as HTMLElement)?.contains(\n prevFocusedElement\n )\n if (isFocusFromOutsideViewport) onFocusFromOutsideViewport()\n }}\n />\n )\n }\n)\n\nFocusProxy.displayName = FOCUS_PROXY_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction focusFirst(candidates: TamaguiElement[]) {\n if (!isWeb) return\n const previouslyFocusedElement = document.activeElement\n return candidates.some((candidate) => {\n // if focus is already where we want to go, we don't want to keep going through the candidates\n if (candidate === previouslyFocusedElement) return true\n candidate.focus()\n return document.activeElement !== previouslyFocusedElement\n })\n}\n\n/**\n * Returns a list of potential tabbable candidates.\n *\n * NOTE: This is only a close approximation. For example it doesn't take into account cases like when\n * elements are not visible. This cannot be worked out easily by just reading a property, but rather\n * necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker\n * Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1\n */\nfunction getTabbableCandidates(container: TamaguiElement) {\n if (!isWeb) return []\n const containerHtml = container as HTMLElement\n const nodes: HTMLElement[] = []\n const walker = document.createTreeWalker(containerHtml, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: any) => {\n const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden'\n if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP\n // `.tabIndex` is not the same as the `tabindex` attribute. It works on the\n // runtime's understanding of tabbability, so this automatically accounts\n // for any kind of element that could be tabbed to.\n return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP\n },\n })\n while (walker.nextNode()) nodes.push(walker.currentNode as HTMLElement)\n // we do not take into account the order of nodes with positive `tabIndex` as it\n // hinders accessibility to have tab order different from visual order.\n return nodes\n}\n\nexport {\n ToastViewport,\n ToastViewportProps,\n VIEWPORT_DEFAULT_HOTKEY,\n VIEWPORT_PAUSE,\n VIEWPORT_RESUME,\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8NM;AA9NN,8BAAgC;AAChC,0BAAgC;AAChC,kBAAwD;AACxD,oBAA2B;AAC3B,oBAAuB;AACvB,6BAA+B;AAC/B,YAAuB;AAEvB,2BAKO;AAEP,MAAM,gBAAgB;AACtB,MAAM,0BAA0B,CAAC,IAAI;AACrC,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAExB,MAAM,gCAA4B,oBAAO,sBAAQ;AAAA,EAC/C,MAAM;AAAA,EACN,eAAe;AAAA,EACf,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA;AAAA,EAEP,UAAU,oBAAQ,UAAU;AAAA,EAC5B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,QAAQ;AACV,CAAC;AAED,MAAM,yBAAqB,oBAAO,sBAAQ;AAAA,EACxC,MAAM;AAAA,EACN,eAAe;AAAA;AAAA,EAEf,UAAU,oBAAQ,UAAU;AAAA,EAC5B,UAAU;AACZ,CAAC;AAwBD,MAAM,gBAAgB,MAAM;AAAA,EAC1B,CAAC,OAAwC,iBAAiB;AACxD,UAAM;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AACJ,UAAM,cAAU,8CAAwB,eAAe,YAAY;AACnE,UAAM,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AAI,cAAc;AAA0B,aAAO;AACnD,cAAU,MAAM;AAChB,WAAO,SAAS,kBAAkB;AAAA,EACpC,CAAC;AACH;AAYA,SAAS,sBAAsB,WAA2B;AACxD,MAAI,CAAC;AAAO,WAAO,CAAC;AACpB,QAAM,gBAAgB;AACtB,QAAM,QAAuB,CAAC;AAC9B,QAAM,SAAS,SAAS,iBAAiB,eAAe,WAAW,cAAc;AAAA,IAC/E,YAAY,CAAC,SAAc;AACzB,YAAM,gBAAgB,KAAK,YAAY,WAAW,KAAK,SAAS;AAChE,UAAI,KAAK,YAAY,KAAK,UAAU;AAAe,eAAO,WAAW;AAIrE,aAAO,KAAK,YAAY,IAAI,WAAW,gBAAgB,WAAW;AAAA,IACpE;AAAA,EACF,CAAC;AACD,SAAO,OAAO,SAAS;AAAG,UAAM,KAAK,OAAO,WAA0B;AAGtE,SAAO;AACT;",
4
+ "sourcesContent": ["import { AnimatePresence } from '@tamagui/animate-presence'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport { GetProps, TamaguiElement, isWeb, styled } from '@tamagui/core'\nimport { PortalHost } from '@tamagui/portal'\nimport { YStack } from '@tamagui/stacks'\nimport { VisuallyHidden } from '@tamagui/visually-hidden'\nimport * as React from 'react'\n\nimport {\n Collection,\n ScopedProps,\n useCollection,\n useToastProviderContext,\n} from './ToastProvider'\n\nconst VIEWPORT_NAME = 'ToastViewport'\nconst VIEWPORT_DEFAULT_HOTKEY = ['F8']\nconst VIEWPORT_PAUSE = 'toast.viewportPause'\nconst VIEWPORT_RESUME = 'toast.viewportResume'\n\nconst ToastViewportWrapperFrame = styled(YStack, {\n name: 'ViewportWrapper',\n\n variants: {\n unstyled: {\n false: {\n pointerEvents: 'box-none',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n position: isWeb ? ('fixed' as any) : 'absolute',\n maxWidth: '100%',\n tabIndex: 0,\n zIndex: 100000,\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nconst ToastViewportFrame = styled(YStack, {\n name: VIEWPORT_NAME,\n\n variants: {\n unstyled: {\n false: {\n pointerEvents: 'box-none',\n position: isWeb ? ('fixed' as any) : 'absolute',\n maxWidth: '100%',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\ntype ToastViewportFrameProps = GetProps<typeof ToastViewportFrame>\ntype ToastViewportProps = ToastViewportFrameProps & {\n /**\n * The keys to use as the keyboard shortcut that will move focus to the toast viewport.\n * @defaultValue ['F8']\n */\n hotkey?: string[]\n /**\n * An author-localized label for the toast viewport to provide context for screen reader users\n * when navigating page landmarks. The available `{hotkey}` placeholder will be replaced for you.\n * @defaultValue 'Notifications ({hotkey})'\n */\n label?: string\n /**\n * Used to reference the viewport if you want to have multiple viewports in the same provider.\n */\n name?: string\n /**\n * Pass this when you want to have multiple/duplicated toasts.\n */\n multipleToasts?: boolean\n}\n\nconst ToastViewport = React.forwardRef<HTMLDivElement, ToastViewportProps>(\n (props: ScopedProps<ToastViewportProps>, forwardedRef) => {\n const {\n __scopeToast,\n hotkey = VIEWPORT_DEFAULT_HOTKEY,\n label = 'Notifications ({hotkey})',\n name = 'default',\n multipleToasts,\n ...viewportProps\n } = props\n const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast)\n const getItems = useCollection(__scopeToast)\n const headFocusProxyRef = React.useRef<FocusProxyElement>(null)\n const tailFocusProxyRef = React.useRef<FocusProxyElement>(null)\n const wrapperRef = React.useRef<HTMLDivElement>(null)\n const ref = React.useRef<HTMLDivElement>(null)\n const onViewportChange = React.useCallback(\n (el: TamaguiElement) => {\n if (context.viewports[name] !== el) context.onViewportChange(name, el)\n },\n [name, context.viewports]\n )\n const composedRefs = useComposedRefs(forwardedRef, ref, onViewportChange)\n const hotkeyLabel = hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '')\n const hasToasts = context.toastCount > 0\n\n React.useEffect(() => {\n if (!isWeb) return\n if (context.toastCount === 0) return\n const handleKeyDown = (event: KeyboardEvent) => {\n // we use `event.code` as it is consistent regardless of meta keys that were pressed.\n // for example, `event.key` for `Control+Alt+t` is `\u2020` and `t !== \u2020`\n const isHotkeyPressed = hotkey.every(\n (key) => (event as any)[key] || event.code === key\n )\n if (isHotkeyPressed) ref.current?.focus()\n }\n document.addEventListener('keydown', handleKeyDown)\n return () => {\n document.removeEventListener('keydown', handleKeyDown)\n }\n }, [hotkey, context.toastCount])\n\n React.useEffect(() => {\n if (!isWeb) return\n if (context.toastCount === 0) return\n const wrapper = wrapperRef.current\n const viewport = ref.current\n if (hasToasts && wrapper && viewport) {\n const handlePause = () => {\n if (!context.isClosePausedRef.current) {\n const pauseEvent = new CustomEvent(VIEWPORT_PAUSE)\n viewport.dispatchEvent(pauseEvent)\n context.isClosePausedRef.current = true\n }\n }\n\n const handleResume = () => {\n if (context.isClosePausedRef.current) {\n const resumeEvent = new CustomEvent(VIEWPORT_RESUME)\n viewport.dispatchEvent(resumeEvent)\n context.isClosePausedRef.current = false\n }\n }\n\n const handleFocusOutResume = (event: FocusEvent) => {\n const isFocusMovingOutside = !wrapper.contains(\n event.relatedTarget as HTMLElement\n )\n if (isFocusMovingOutside) handleResume()\n }\n\n const handlePointerLeaveResume = () => {\n const isFocusInside = wrapper.contains(document.activeElement)\n if (!isFocusInside) handleResume()\n }\n\n // Toasts are not in the viewport React tree so we need to bind DOM events\n wrapper.addEventListener('focusin', handlePause)\n wrapper.addEventListener('focusout', handleFocusOutResume)\n wrapper.addEventListener('pointermove', handlePause)\n wrapper.addEventListener('pointerleave', handlePointerLeaveResume)\n window.addEventListener('blur', handlePause)\n window.addEventListener('focus', handleResume)\n return () => {\n wrapper.removeEventListener('focusin', handlePause)\n wrapper.removeEventListener('focusout', handleFocusOutResume)\n wrapper.removeEventListener('pointermove', handlePause)\n wrapper.removeEventListener('pointerleave', handlePointerLeaveResume)\n window.removeEventListener('blur', handlePause)\n window.removeEventListener('focus', handleResume)\n }\n }\n }, [hasToasts, context.isClosePausedRef, context.toastCount])\n\n const getSortedTabbableCandidates = React.useCallback(\n ({ tabbingDirection }: { tabbingDirection: 'forwards' | 'backwards' }) => {\n const toastItems = getItems()\n const tabbableCandidates = toastItems.map((toastItem) => {\n const toastNode = toastItem.ref.current!\n const toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)]\n return tabbingDirection === 'forwards'\n ? toastTabbableCandidates\n : toastTabbableCandidates.reverse()\n })\n return (\n tabbingDirection === 'forwards'\n ? tabbableCandidates.reverse()\n : tabbableCandidates\n ).flat()\n },\n [getItems]\n )\n\n React.useEffect(() => {\n if (!isWeb) return\n if (context.toastCount === 0) return\n\n const viewport = ref.current\n // We programmatically manage tabbing as we are unable to influence\n // the source order with portals, this allows us to reverse the\n // tab order so that it runs from most recent toast to least\n if (viewport) {\n const handleKeyDown = (event: KeyboardEvent) => {\n const isMetaKey = event.altKey || event.ctrlKey || event.metaKey\n const isTabKey = event.key === 'Tab' && !isMetaKey\n\n if (isTabKey) {\n const focusedElement = document.activeElement\n const isTabbingBackwards = event.shiftKey\n const targetIsViewport = event.target === viewport\n\n // If we're back tabbing after jumping to the viewport then we simply\n // proxy focus out to the preceding document\n if (targetIsViewport && isTabbingBackwards) {\n headFocusProxyRef.current?.focus()\n return\n }\n\n const tabbingDirection = isTabbingBackwards ? 'backwards' : 'forwards'\n const sortedCandidates = getSortedTabbableCandidates({ tabbingDirection })\n const index = sortedCandidates.findIndex(\n (candidate) => candidate === focusedElement\n )\n if (focusFirst(sortedCandidates.slice(index + 1))) {\n event.preventDefault()\n } else {\n // If we can't focus that means we're at the edges so we\n // proxy to the corresponding exit point and let the browser handle\n // tab/shift+tab keypress and implicitly pass focus to the next valid element in the document\n isTabbingBackwards\n ? headFocusProxyRef.current?.focus()\n : tailFocusProxyRef.current?.focus()\n }\n }\n }\n\n // Toasts are not in the viewport React tree so we need to bind DOM events\n viewport.addEventListener('keydown', handleKeyDown)\n return () => viewport.removeEventListener('keydown', handleKeyDown)\n }\n }, [getItems, getSortedTabbableCandidates, context.toastCount])\n\n return (\n <ToastViewportWrapperFrame\n ref={wrapperRef}\n role=\"region\"\n aria-label={label.replace('{hotkey}', hotkeyLabel)}\n // // Ensure virtual cursor from landmarks menus triggers focus/blur for pause/resume\n tabIndex={-1}\n // // incase list has size when empty (e.g. padding), we remove pointer events so\n // // it doesn't prevent interactions with page elements that it overlays\n // pointerEvents={hasToasts ? undefined : 'none'}\n >\n {hasToasts && (\n <FocusProxy\n viewportName={name}\n ref={headFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'forwards',\n })\n focusFirst(tabbableCandidates)\n }}\n />\n )}\n {/**\n * tabindex on the the list so that it can be focused when items are removed. we focus\n * the list instead of the viewport so it announces number of items remaining.\n */}\n <Collection.Slot scope={__scopeToast}>\n <ToastViewportFrame ref={composedRefs} {...viewportProps}>\n <PortalHost\n render={(children) => (\n <AnimatePresence exitBeforeEnter={!multipleToasts}>\n {children}\n </AnimatePresence>\n )}\n name={name ?? 'default'}\n />\n </ToastViewportFrame>\n </Collection.Slot>\n {hasToasts && (\n <FocusProxy\n viewportName={name}\n ref={tailFocusProxyRef}\n onFocusFromOutsideViewport={() => {\n const tabbableCandidates = getSortedTabbableCandidates({\n tabbingDirection: 'backwards',\n })\n focusFirst(tabbableCandidates)\n }}\n />\n )}\n </ToastViewportWrapperFrame>\n )\n }\n)\n\nToastViewport.displayName = VIEWPORT_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst FOCUS_PROXY_NAME = 'ToastFocusProxy'\n\ntype FocusProxyElement = React.ElementRef<typeof VisuallyHidden>\ntype VisuallyHiddenProps = GetProps<typeof VisuallyHidden>\ninterface FocusProxyProps extends VisuallyHiddenProps {\n onFocusFromOutsideViewport(): void\n viewportName: string\n}\n\nconst FocusProxy = React.forwardRef<FocusProxyElement, ScopedProps<FocusProxyProps>>(\n (props, forwardedRef) => {\n const { __scopeToast, onFocusFromOutsideViewport, viewportName, ...proxyProps } =\n props\n const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast)\n const viewport = context.viewports[viewportName] as HTMLElement\n\n return (\n <VisuallyHidden\n aria-hidden\n tabIndex={0}\n {...proxyProps}\n ref={forwardedRef}\n // Avoid page scrolling when focus is on the focus proxy\n position={isWeb ? ('fixed' as any) : 'absolute'}\n onFocus={(event) => {\n if (!isWeb) return\n const prevFocusedElement = event.relatedTarget as HTMLElement | null\n const isFocusFromOutsideViewport = !viewport?.contains(prevFocusedElement)\n if (isFocusFromOutsideViewport) onFocusFromOutsideViewport()\n }}\n />\n )\n }\n)\n\nFocusProxy.displayName = FOCUS_PROXY_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction focusFirst(candidates: TamaguiElement[]) {\n if (!isWeb) return\n const previouslyFocusedElement = document.activeElement\n return candidates.some((candidate) => {\n // if focus is already where we want to go, we don't want to keep going through the candidates\n if (candidate === previouslyFocusedElement) return true\n candidate.focus()\n return document.activeElement !== previouslyFocusedElement\n })\n}\n\n/**\n * Returns a list of potential tabbable candidates.\n *\n * NOTE: This is only a close approximation. For example it doesn't take into account cases like when\n * elements are not visible. This cannot be worked out easily by just reading a property, but rather\n * necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker\n * Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1\n */\nfunction getTabbableCandidates(container: TamaguiElement) {\n if (!isWeb) return []\n const containerHtml = container as HTMLElement\n const nodes: HTMLElement[] = []\n const walker = document.createTreeWalker(containerHtml, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: any) => {\n const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden'\n if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP\n // `.tabIndex` is not the same as the `tabindex` attribute. It works on the\n // runtime's understanding of tabbability, so this automatically accounts\n // for any kind of element that could be tabbed to.\n return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP\n },\n })\n while (walker.nextNode()) nodes.push(walker.currentNode as HTMLElement)\n // we do not take into account the order of nodes with positive `tabIndex` as it\n // hinders accessibility to have tab order different from visual order.\n return nodes\n}\n\nexport {\n ToastViewport,\n ToastViewportProps,\n VIEWPORT_DEFAULT_HOTKEY,\n VIEWPORT_PAUSE,\n VIEWPORT_RESUME,\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyPM;AAzPN,8BAAgC;AAChC,0BAAgC;AAChC,kBAAwD;AACxD,oBAA2B;AAC3B,oBAAuB;AACvB,6BAA+B;AAC/B,YAAuB;AAEvB,2BAKO;AAEP,MAAM,gBAAgB;AACtB,MAAM,0BAA0B,CAAC,IAAI;AACrC,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAExB,MAAM,gCAA4B,oBAAO,sBAAQ;AAAA,EAC/C,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,eAAe;AAAA,QACf,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,UAAU,oBAAS,UAAkB;AAAA,QACrC,UAAU;AAAA,QACV,UAAU;AAAA,QACV,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAED,MAAM,yBAAqB,oBAAO,sBAAQ;AAAA,EACxC,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,eAAe;AAAA,QACf,UAAU,oBAAS,UAAkB;AAAA,QACrC,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAyBD,MAAM,gBAAgB,MAAM;A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