@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
@@ -22,10 +22,16 @@ const ToastProvider = (props) => {
22
22
  children
23
23
  } = props;
24
24
  const id = providedId ?? React.useId();
25
- const [viewport, setViewport] = React.useState(null);
25
+ const [viewports, setViewports] = React.useState({});
26
26
  const [toastCount, setToastCount] = React.useState(0);
27
27
  const isFocusedToastEscapeKeyDownRef = React.useRef(false);
28
28
  const isClosePausedRef = React.useRef(false);
29
+ const handleViewportChange = React.useCallback(
30
+ (name, viewport) => {
31
+ setViewports((prev) => ({ ...prev, [name]: viewport }));
32
+ },
33
+ []
34
+ );
29
35
  const options = React.useMemo(() => {
30
36
  return {
31
37
  duration,
@@ -42,8 +48,8 @@ const ToastProvider = (props) => {
42
48
  swipeDirection={swipeDirection}
43
49
  swipeThreshold={swipeThreshold}
44
50
  toastCount={toastCount}
45
- viewport={viewport}
46
- onViewportChange={setViewport}
51
+ viewports={viewports}
52
+ onViewportChange={handleViewportChange}
47
53
  onToastAdd={React.useCallback(() => {
48
54
  setToastCount((prevCount) => prevCount + 1);
49
55
  }, [])}
@@ -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,SAAS,wBAAwB;AAGjC,SAAS,0BAA0B;AACnC,YAAY,WAAW;AAEvB,SAAS,+BAAiD;AAO1D,MAAM,gBAAgB;AAEtB,MAAM,CAAC,YAAY,eAAe,qBAAqB,IACrD,iBAAiC,OAAO;AAmB1C,MAAM,CAAC,oBAAoB,gBAAgB,IAAI,mBAAmB,SAAS;AAAA,EACzE;AACF,CAAC;AACD,MAAM,CAAC,uBAAuB,uBAAuB,IACnD,mBAA8C,aAAa;AA4C7D,MAAM,gBAA8C,CAClD,UACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,IACjB;AAAA,EACF,IAAI;AACJ,QAAM,KAAK,cAAc,MAAM,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,CAAC,WAAW,SAAS,OAAO,cAC1B,CAAC;AAAA,IACC,OAAO;AAAA,IACP,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,kBAAkB;AAAA,IAClB,YAAY,MAAM,YAAY,MAAM;AAClC,oBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,IAC5C,GAAG,CAAC,CAAC;AAAA,IACL,eAAe,MAAM,YAAY,MAAM;AACrC,oBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,IAC5C,GAAG,CAAC,CAAC;AAAA,IACL,gCAAgC;AAAA,IAChC,kBAAkB;AAAA,GAElB,CAAC,wBAAwB,SAAS,UAAU,SAAS,EAApD,wBACH,EApBC,sBAqBH,EAtBC,WAAW;AAwBhB;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}\n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AI;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,YAAY,MAAM,YAAY,MAAM;AAClC,oBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,IAC5C,GAAG,CAAC,CAAC;AAAA,IACL,eAAe,MAAM,YAAY,MAAM;AACrC,oBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,IAC5C,GAAG,CAAC,CAAC;AAAA,IACL,gCAAgC;AAAA,IAChC,kBAAkB;AAAA,GAElB,CAAC,wBAAwB,SAAS,UAAU,SAAS,EAApD,wBACH,EApBC,sBAqBH,EAtBC,WAAW;AAwBhB;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
  }
@@ -22,10 +22,16 @@ const ToastProvider = (props) => {
22
22
  children
23
23
  } = props;
24
24
  const id = providedId ?? React.useId();
25
- const [viewport, setViewport] = React.useState(null);
25
+ const [viewports, setViewports] = React.useState({});
26
26
  const [toastCount, setToastCount] = React.useState(0);
27
27
  const isFocusedToastEscapeKeyDownRef = React.useRef(false);
28
28
  const isClosePausedRef = React.useRef(false);
29
+ const handleViewportChange = React.useCallback(
30
+ (name, viewport) => {
31
+ setViewports((prev) => ({ ...prev, [name]: viewport }));
32
+ },
33
+ []
34
+ );
29
35
  const options = React.useMemo(() => {
30
36
  return {
31
37
  duration,
@@ -42,8 +48,8 @@ const ToastProvider = (props) => {
42
48
  swipeDirection={swipeDirection}
43
49
  swipeThreshold={swipeThreshold}
44
50
  toastCount={toastCount}
45
- viewport={viewport}
46
- onViewportChange={setViewport}
51
+ viewports={viewports}
52
+ onViewportChange={handleViewportChange}
47
53
  onToastAdd={React.useCallback(() => {
48
54
  setToastCount((prevCount) => prevCount + 1);
49
55
  }, [])}
@@ -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,SAAS,wBAAwB;AAGjC,SAAS,0BAA0B;AACnC,YAAY,WAAW;AAEvB,SAAS,+BAAiD;AAO1D,MAAM,gBAAgB;AAEtB,MAAM,CAAC,YAAY,eAAe,qBAAqB,IACrD,iBAAiC,OAAO;AAmB1C,MAAM,CAAC,oBAAoB,gBAAgB,IAAI,mBAAmB,SAAS;AAAA,EACzE;AACF,CAAC;AACD,MAAM,CAAC,uBAAuB,uBAAuB,IACnD,mBAA8C,aAAa;AA4C7D,MAAM,gBAA8C,CAClD,UACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,IACjB;AAAA,EACF,IAAI;AACJ,QAAM,KAAK,cAAc,MAAM,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,CAAC,WAAW,SAAS,OAAO,cAC1B,CAAC;AAAA,IACC,OAAO;AAAA,IACP,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,kBAAkB;AAAA,IAClB,YAAY,MAAM,YAAY,MAAM;AAClC,oBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,IAC5C,GAAG,CAAC,CAAC;AAAA,IACL,eAAe,MAAM,YAAY,MAAM;AACrC,oBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,IAC5C,GAAG,CAAC,CAAC;AAAA,IACL,gCAAgC;AAAA,IAChC,kBAAkB;AAAA,GAElB,CAAC,wBAAwB,SAAS,UAAU,SAAS,EAApD,wBACH,EApBC,sBAqBH,EAtBC,WAAW;AAwBhB;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,SAAS,wBAAwB;AAGjC,SAAS,0BAA0B;AACnC,YAAY,WAA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AAW;AAAA,IACX,kBAAkB;AAAA,IAClB,YAAY,MAAM,YAAY,MAAM;AAClC,oBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,IAC5C,GAAG,CAAC,CAAC;AAAA,IACL,eAAe,MAAM,YAAY,MAAM;AACrC,oBAAc,CAAC,cAAc,YAAY,CAAC;AAAA,IAC5C,GAAG,CAAC,CAAC;AAAA,IACL,gCAAgC;AAAA,IAChC,kBAAkB;AAAA,GAElB,CAAC,wBAAwB,SAAS,UAAU,SAAS,EAApD,wBACH,EApBC,sBAqBH,EAtBC,WAAW;AAwBhB;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
  }
@@ -16,23 +16,39 @@ const VIEWPORT_PAUSE = "toast.viewportPause";
16
16
  const VIEWPORT_RESUME = "toast.viewportResume";
17
17
  const ToastViewportWrapperFrame = styled(YStack, {
18
18
  name: "ViewportWrapper",
19
- pointerEvents: "box-none",
20
- top: 0,
21
- bottom: 0,
22
- left: 0,
23
- right: 0,
24
- // @ts-ignore
25
- position: isWeb ? "fixed" : "absolute",
26
- maxWidth: "100%",
27
- tabIndex: 0,
28
- zIndex: 1e5
19
+ variants: {
20
+ unstyled: {
21
+ false: {
22
+ pointerEvents: "box-none",
23
+ top: 0,
24
+ bottom: 0,
25
+ left: 0,
26
+ right: 0,
27
+ position: isWeb ? "fixed" : "absolute",
28
+ maxWidth: "100%",
29
+ tabIndex: 0,
30
+ zIndex: 1e5
31
+ }
32
+ }
33
+ },
34
+ defaultVariants: {
35
+ unstyled: false
36
+ }
29
37
  });
30
38
  const ToastViewportFrame = styled(YStack, {
31
39
  name: VIEWPORT_NAME,
32
- pointerEvents: "box-none",
33
- // @ts-ignore
34
- position: isWeb ? "fixed" : "absolute",
35
- maxWidth: "100%"
40
+ variants: {
41
+ unstyled: {
42
+ false: {
43
+ pointerEvents: "box-none",
44
+ position: isWeb ? "fixed" : "absolute",
45
+ maxWidth: "100%"
46
+ }
47
+ }
48
+ },
49
+ defaultVariants: {
50
+ unstyled: false
51
+ }
36
52
  });
37
53
  const ToastViewport = React.forwardRef(
38
54
  (props, forwardedRef) => {
@@ -40,7 +56,7 @@ const ToastViewport = React.forwardRef(
40
56
  __scopeToast,
41
57
  hotkey = VIEWPORT_DEFAULT_HOTKEY,
42
58
  label = "Notifications ({hotkey})",
43
- name,
59
+ name = "default",
44
60
  multipleToasts,
45
61
  ...viewportProps
46
62
  } = props;
@@ -50,7 +66,14 @@ const ToastViewport = React.forwardRef(
50
66
  const tailFocusProxyRef = React.useRef(null);
51
67
  const wrapperRef = React.useRef(null);
52
68
  const ref = React.useRef(null);
53
- const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange);
69
+ const onViewportChange = React.useCallback(
70
+ (el) => {
71
+ if (context.viewports[name] !== el)
72
+ context.onViewportChange(name, el);
73
+ },
74
+ [name, context.viewports]
75
+ );
76
+ const composedRefs = useComposedRefs(forwardedRef, ref, onViewportChange);
54
77
  const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
55
78
  const hasToasts = context.toastCount > 0;
56
79
  React.useEffect(() => {
@@ -173,6 +196,7 @@ const ToastViewport = React.forwardRef(
173
196
  tabIndex={-1}
174
197
  >
175
198
  {hasToasts && <FocusProxy
199
+ viewportName={name}
176
200
  ref={headFocusProxyRef}
177
201
  onFocusFromOutsideViewport={() => {
178
202
  const tabbableCandidates = getSortedTabbableCandidates({
@@ -186,6 +210,7 @@ const ToastViewport = React.forwardRef(
186
210
  name={name ?? "default"}
187
211
  /></ToastViewportFrame></Collection.Slot>
188
212
  {hasToasts && <FocusProxy
213
+ viewportName={name}
189
214
  ref={tailFocusProxyRef}
190
215
  onFocusFromOutsideViewport={() => {
191
216
  const tabbableCandidates = getSortedTabbableCandidates({
@@ -201,8 +226,9 @@ ToastViewport.displayName = VIEWPORT_NAME;
201
226
  const FOCUS_PROXY_NAME = "ToastFocusProxy";
202
227
  const FocusProxy = React.forwardRef(
203
228
  (props, forwardedRef) => {
204
- const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props;
229
+ const { __scopeToast, onFocusFromOutsideViewport, viewportName, ...proxyProps } = props;
205
230
  const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast);
231
+ const viewport = context.viewports[viewportName];
206
232
  return <VisuallyHidden
207
233
  aria-hidden
208
234
  tabIndex={0}
@@ -213,9 +239,7 @@ const FocusProxy = React.forwardRef(
213
239
  if (!isWeb)
214
240
  return;
215
241
  const prevFocusedElement = event.relatedTarget;
216
- const isFocusFromOutsideViewport = !context.viewport?.contains(
217
- prevFocusedElement
218
- );
242
+ const isFocusFromOutsideViewport = !viewport?.contains(prevFocusedElement);
219
243
  if (isFocusFromOutsideViewport)
220
244
  onFocusFromOutsideViewport();
221
245
  }}
@@ -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,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAmC,OAAO,cAAc;AACxD,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AAEvB;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,gBAAgB;AACtB,MAAM,0BAA0B,CAAC,IAAI;AACrC,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAExB,MAAM,4BAA4B,OAAO,QAAQ;AAAA,EAC/C,MAAM;AAAA,EACN,eAAe;AAAA,EACf,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA;AAAA,EAEP,UAAU,QAAQ,UAAU;AAAA,EAC5B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,QAAQ;AACV,CAAC;AAED,MAAM,qBAAqB,OAAO,QAAQ;AAAA,EACxC,MAAM;AAAA,EACN,eAAe;AAAA;AAAA,EAEf,UAAU,QAAQ,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,UAAU,wBAAwB,eAAe,YAAY;AACnE,UAAM,WAAW,cAAc,YAAY;AAC3C,UAAM,oBAAoB,MAAM,OAA0B,IAAI;AAC9D,UAAM,oBAAoB,MAAM,OAA0B,IAAI;AAC9D,UAAM,aAAa,MAAM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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": "AAA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EpC,QAAI,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;",
6
6
  "names": []
7
7
  }
@@ -16,23 +16,39 @@ const VIEWPORT_PAUSE = "toast.viewportPause";
16
16
  const VIEWPORT_RESUME = "toast.viewportResume";
17
17
  const ToastViewportWrapperFrame = styled(YStack, {
18
18
  name: "ViewportWrapper",
19
- pointerEvents: "box-none",
20
- top: 0,
21
- bottom: 0,
22
- left: 0,
23
- right: 0,
24
- // @ts-ignore
25
- position: isWeb ? "fixed" : "absolute",
26
- maxWidth: "100%",
27
- tabIndex: 0,
28
- zIndex: 1e5
19
+ variants: {
20
+ unstyled: {
21
+ false: {
22
+ pointerEvents: "box-none",
23
+ top: 0,
24
+ bottom: 0,
25
+ left: 0,
26
+ right: 0,
27
+ position: isWeb ? "fixed" : "absolute",
28
+ maxWidth: "100%",
29
+ tabIndex: 0,
30
+ zIndex: 1e5
31
+ }
32
+ }
33
+ },
34
+ defaultVariants: {
35
+ unstyled: false
36
+ }
29
37
  });
30
38
  const ToastViewportFrame = styled(YStack, {
31
39
  name: VIEWPORT_NAME,
32
- pointerEvents: "box-none",
33
- // @ts-ignore
34
- position: isWeb ? "fixed" : "absolute",
35
- maxWidth: "100%"
40
+ variants: {
41
+ unstyled: {
42
+ false: {
43
+ pointerEvents: "box-none",
44
+ position: isWeb ? "fixed" : "absolute",
45
+ maxWidth: "100%"
46
+ }
47
+ }
48
+ },
49
+ defaultVariants: {
50
+ unstyled: false
51
+ }
36
52
  });
37
53
  const ToastViewport = React.forwardRef(
38
54
  (props, forwardedRef) => {
@@ -40,7 +56,7 @@ const ToastViewport = React.forwardRef(
40
56
  __scopeToast,
41
57
  hotkey = VIEWPORT_DEFAULT_HOTKEY,
42
58
  label = "Notifications ({hotkey})",
43
- name,
59
+ name = "default",
44
60
  multipleToasts,
45
61
  ...viewportProps
46
62
  } = props;
@@ -50,7 +66,14 @@ const ToastViewport = React.forwardRef(
50
66
  const tailFocusProxyRef = React.useRef(null);
51
67
  const wrapperRef = React.useRef(null);
52
68
  const ref = React.useRef(null);
53
- const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange);
69
+ const onViewportChange = React.useCallback(
70
+ (el) => {
71
+ if (context.viewports[name] !== el)
72
+ context.onViewportChange(name, el);
73
+ },
74
+ [name, context.viewports]
75
+ );
76
+ const composedRefs = useComposedRefs(forwardedRef, ref, onViewportChange);
54
77
  const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
55
78
  const hasToasts = context.toastCount > 0;
56
79
  React.useEffect(() => {
@@ -173,6 +196,7 @@ const ToastViewport = React.forwardRef(
173
196
  tabIndex={-1}
174
197
  >
175
198
  {hasToasts && <FocusProxy
199
+ viewportName={name}
176
200
  ref={headFocusProxyRef}
177
201
  onFocusFromOutsideViewport={() => {
178
202
  const tabbableCandidates = getSortedTabbableCandidates({
@@ -186,6 +210,7 @@ const ToastViewport = React.forwardRef(
186
210
  name={name ?? "default"}
187
211
  /></ToastViewportFrame></Collection.Slot>
188
212
  {hasToasts && <FocusProxy
213
+ viewportName={name}
189
214
  ref={tailFocusProxyRef}
190
215
  onFocusFromOutsideViewport={() => {
191
216
  const tabbableCandidates = getSortedTabbableCandidates({
@@ -201,8 +226,9 @@ ToastViewport.displayName = VIEWPORT_NAME;
201
226
  const FOCUS_PROXY_NAME = "ToastFocusProxy";
202
227
  const FocusProxy = React.forwardRef(
203
228
  (props, forwardedRef) => {
204
- const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props;
229
+ const { __scopeToast, onFocusFromOutsideViewport, viewportName, ...proxyProps } = props;
205
230
  const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast);
231
+ const viewport = context.viewports[viewportName];
206
232
  return <VisuallyHidden
207
233
  aria-hidden
208
234
  tabIndex={0}
@@ -213,9 +239,7 @@ const FocusProxy = React.forwardRef(
213
239
  if (!isWeb)
214
240
  return;
215
241
  const prevFocusedElement = event.relatedTarget;
216
- const isFocusFromOutsideViewport = !context.viewport?.contains(
217
- prevFocusedElement
218
- );
242
+ const isFocusFromOutsideViewport = !viewport?.contains(prevFocusedElement);
219
243
  if (isFocusFromOutsideViewport)
220
244
  onFocusFromOutsideViewport();
221
245
  }}
@@ -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,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAmC,OAAO,cAAc;AACxD,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AAEvB;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,gBAAgB;AACtB,MAAM,0BAA0B,CAAC,IAAI;AACrC,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAExB,MAAM,4BAA4B,OAAO,QAAQ;AAAA,EAC/C,MAAM;AAAA,EACN,eAAe;AAAA,EACf,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA;AAAA,EAEP,UAAU,QAAQ,UAAU;AAAA,EAC5B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,QAAQ;AACV,CAAC;AAED,MAAM,qBAAqB,OAAO,QAAQ;AAAA,EACxC,MAAM;AAAA,EACN,eAAe;AAAA;AAAA,EAEf,UAAU,QAAQ,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,UAAU,wBAAwB,eAAe,YAAY;AACnE,UAAM,WAAW,cAAc,YAAY;AAC3C,UAAM,oBAAoB,MAAM,OAA0B,IAAI;AAC9D,UAAM,oBAAoB,MAAM,OAA0B,IAAI;AAC9D,UAAM,aAAa,MAAM,OAAuB,IAAI;AACpD,UAAM,MAAM,MAAM,OAAuB,IAAI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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,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAmC,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