expo-router 4.0.0-preview.12 → 4.0.0-preview.13

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 (76) hide show
  1. package/build/ExpoRoot.js +2 -2
  2. package/build/ExpoRoot.js.map +1 -1
  3. package/build/exports.d.ts +1 -1
  4. package/build/exports.d.ts.map +1 -1
  5. package/build/exports.js +24 -2
  6. package/build/exports.js.map +1 -1
  7. package/build/global-state/router-store.d.ts.map +1 -1
  8. package/build/global-state/router-store.js +1 -2
  9. package/build/global-state/router-store.js.map +1 -1
  10. package/build/layouts/Drawer.d.ts +2 -142
  11. package/build/layouts/Drawer.d.ts.map +1 -1
  12. package/build/layouts/Drawer.js +8 -5
  13. package/build/layouts/Drawer.js.map +1 -1
  14. package/build/layouts/DrawerClient.d.ts +144 -0
  15. package/build/layouts/DrawerClient.d.ts.map +1 -0
  16. package/build/layouts/DrawerClient.js +10 -0
  17. package/build/layouts/DrawerClient.js.map +1 -0
  18. package/build/layouts/Stack.d.ts +2 -126
  19. package/build/layouts/Stack.d.ts.map +1 -1
  20. package/build/layouts/Stack.js +8 -6
  21. package/build/layouts/Stack.js.map +1 -1
  22. package/build/layouts/StackClient.d.ts +128 -0
  23. package/build/layouts/StackClient.d.ts.map +1 -0
  24. package/build/layouts/StackClient.js +10 -0
  25. package/build/layouts/StackClient.js.map +1 -0
  26. package/build/layouts/Tabs.d.ts +2 -134
  27. package/build/layouts/Tabs.d.ts.map +1 -1
  28. package/build/layouts/Tabs.js +5 -37
  29. package/build/layouts/Tabs.js.map +1 -1
  30. package/build/layouts/TabsClient.d.ts +136 -0
  31. package/build/layouts/TabsClient.d.ts.map +1 -0
  32. package/build/layouts/TabsClient.js +44 -0
  33. package/build/layouts/TabsClient.js.map +1 -0
  34. package/build/renderRootComponent.d.ts.map +1 -1
  35. package/build/renderRootComponent.js +1 -2
  36. package/build/renderRootComponent.js.map +1 -1
  37. package/build/rsc/middleware.d.ts +1 -1
  38. package/build/rsc/middleware.d.ts.map +1 -1
  39. package/build/rsc/middleware.js +2 -1
  40. package/build/rsc/middleware.js.map +1 -1
  41. package/build/rsc/server.d.ts +3 -0
  42. package/build/rsc/server.d.ts.map +1 -1
  43. package/build/rsc/server.js +19 -1
  44. package/build/rsc/server.js.map +1 -1
  45. package/build/ui/TabContext.d.ts +3 -2
  46. package/build/ui/TabContext.d.ts.map +1 -1
  47. package/build/ui/TabContext.js.map +1 -1
  48. package/build/ui/TabList.d.ts +3 -3
  49. package/build/ui/TabList.js +2 -2
  50. package/build/ui/TabList.js.map +1 -1
  51. package/build/ui/TabSlot.d.ts +28 -14
  52. package/build/ui/TabSlot.d.ts.map +1 -1
  53. package/build/ui/TabSlot.js +9 -7
  54. package/build/ui/TabSlot.js.map +1 -1
  55. package/build/ui/TabTrigger.d.ts +22 -9
  56. package/build/ui/TabTrigger.d.ts.map +1 -1
  57. package/build/ui/TabTrigger.js +6 -4
  58. package/build/ui/TabTrigger.js.map +1 -1
  59. package/build/ui/Tabs.d.ts +16 -23
  60. package/build/ui/Tabs.d.ts.map +1 -1
  61. package/build/ui/Tabs.js +15 -10
  62. package/build/ui/Tabs.js.map +1 -1
  63. package/build/utils/splash.d.ts +6 -0
  64. package/build/utils/splash.d.ts.map +1 -0
  65. package/build/utils/splash.js +51 -0
  66. package/build/utils/splash.js.map +1 -0
  67. package/build/views/Splash.d.ts +1 -1
  68. package/build/views/Splash.d.ts.map +1 -1
  69. package/build/views/Splash.js +3 -13
  70. package/build/views/Splash.js.map +1 -1
  71. package/build/views/Try.d.ts.map +1 -1
  72. package/build/views/Try.js +1 -1
  73. package/build/views/Try.js.map +1 -1
  74. package/package.json +3 -4
  75. package/rsc/headers.d.ts +3 -0
  76. package/rsc/headers.js +5 -0
@@ -7,7 +7,8 @@
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.getContext = exports.rerender = exports.runWithRenderStore = exports.defineEntries = void 0;
10
+ exports.unstable_headers = exports.getContext = exports.rerender = exports.runWithRenderStore = exports.defineEntries = exports.REQUEST_HEADERS = void 0;
11
+ exports.REQUEST_HEADERS = '__expo_requestHeaders';
11
12
  function defineEntries(renderEntries, getBuildConfig, getSsrConfig) {
12
13
  return { renderEntries, getBuildConfig, getSsrConfig };
13
14
  }
@@ -84,4 +85,21 @@ function getContext() {
84
85
  return renderStore.context;
85
86
  }
86
87
  exports.getContext = getContext;
88
+ /** Get the request headers used to make the server component or action request. */
89
+ async function unstable_headers() {
90
+ const headers = (getContext()[exports.REQUEST_HEADERS] || {});
91
+ return new ReadonlyHeaders(headers);
92
+ }
93
+ exports.unstable_headers = unstable_headers;
94
+ class ReadonlyHeaders extends Headers {
95
+ set() {
96
+ throw new Error('Server component Headers are read-only');
97
+ }
98
+ append() {
99
+ throw new Error('Server component Headers are read-only');
100
+ }
101
+ delete() {
102
+ throw new Error('Server component Headers are read-only');
103
+ }
104
+ }
87
105
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/rsc/server.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAsDH,SAAgB,aAAa,CAC3B,aAA4B,EAC5B,cAA+B,EAC/B,YAA2B;IAE3B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;AACzD,CAAC;AAND,sCAMC;AAkBD,6DAA6D;AAC7D,oIAAoI;AACpI,SAAS,yBAAyB;IAChC,IAAI,CAAC,UAAU,CAAC,kBAAkB,EAAE;QAClC,UAAU,CAAC,kBAAkB,GAAG,IAAI,GAAG,EAAE,CAAC;KAC3C;IAED,IAAI,UAAU,CAAC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAQ,CAAC,EAAE;QAC3D,OAAO,UAAU,CAAC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAQ,CAAE,CAAC;KACjE;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B,GAAG,WAAW,CAAC;IACjC,IAAI;QACF,OAAO,EAAE,EAAE,CAAC;KACb;YAAS;QACR,kBAAkB,GAAG,mBAAmB,CAAC;KAC1C;AACH,CAAC,CAAC;AAXW,QAAA,kBAAkB,sBAW7B;AAEF,SAAgB,QAAQ,CAAC,KAAa,EAAE,MAAgB;IACtD,MAAM,WAAW,GAAG,aAAa,EAAE,QAAQ,EAAE,IAAI,kBAAkB,CAAC;IACpE,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC;AAND,4BAMC;AAED,SAAgB,UAAU;IAGxB,MAAM,WAAW,GAAG,aAAa,EAAE,QAAQ,EAAE,IAAI,kBAAkB,CAAC;IACpE,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,OAAO,WAAW,CAAC,OAAqB,CAAC;AAC3C,CAAC;AARD,gCAQC","sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n * Copyright © 2024 2023 Daishi Kato\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { type AsyncLocalStorage } from 'node:async_hooks';\nimport type { ReactNode } from 'react';\n\nimport type { PathSpec } from './path';\n\ndeclare let globalThis: {\n __EXPO_RSC_CACHE__?: Map<string, any>;\n __webpack_chunk_load__: (id: string) => Promise<any>;\n __webpack_require__: (id: string) => any;\n};\n\ntype Config = any;\n\ntype Elements = Record<string, ReactNode>;\n\nexport type BuildConfig = {\n pathname: string | PathSpec; // TODO drop support for string?\n isStatic?: boolean | undefined;\n entries?: {\n input: string;\n skipPrefetch?: boolean | undefined;\n isStatic?: boolean | undefined;\n }[];\n context?: Record<string, unknown>;\n customCode?: string; // optional code to inject TODO hope to remove this\n customData?: unknown; // should be serializable with JSON.stringify\n}[];\n\nexport type RenderEntries = (\n input: string,\n options: {\n params: unknown | undefined;\n buildConfig: BuildConfig | undefined;\n }\n) => Promise<Elements | null>;\n\nexport type GetBuildConfig = (\n unstable_collectClientModules: (input: string) => Promise<string[]>\n) => Promise<BuildConfig>;\n\nexport type GetSsrConfig = (\n pathname: string,\n options: {\n searchParams: URLSearchParams;\n buildConfig?: BuildConfig | undefined;\n }\n) => Promise<{\n input: string;\n searchParams?: URLSearchParams;\n html: ReactNode;\n} | null>;\n\nexport function defineEntries(\n renderEntries: RenderEntries,\n getBuildConfig?: GetBuildConfig,\n getSsrConfig?: GetSsrConfig\n) {\n return { renderEntries, getBuildConfig, getSsrConfig };\n}\n\nexport type EntriesDev = {\n default: ReturnType<typeof defineEntries>;\n};\n\nexport type EntriesPrd = EntriesDev & {\n loadConfig: () => Promise<Config>;\n loadModule: (id: string) => Promise<unknown>;\n dynamicHtmlPaths: [pathSpec: PathSpec, htmlHead: string][];\n publicIndexHtml: string;\n};\n\ntype RenderStore<> = {\n rerender: (input: string, params?: unknown) => void;\n context: Record<string, unknown>;\n};\n\n// TODO(EvanBacon): This can leak between platforms and runs.\n// We need to share this module between the server action module and the renderer module, per platform, and invalidate on refreshes.\nfunction getGlobalCacheForPlatform(): Pick<AsyncLocalStorage<RenderStore>, 'getStore' | 'run'> {\n if (!globalThis.__EXPO_RSC_CACHE__) {\n globalThis.__EXPO_RSC_CACHE__ = new Map();\n }\n\n if (globalThis.__EXPO_RSC_CACHE__.has(process.env.EXPO_OS!)) {\n return globalThis.__EXPO_RSC_CACHE__.get(process.env.EXPO_OS!)!;\n }\n try {\n const { AsyncLocalStorage } = require('node:async_hooks');\n // @ts-expect-error: This is a Node.js feature.\n const serverCache = new AsyncLocalStorage<RenderStore>();\n globalThis.__EXPO_RSC_CACHE__.set(process.env.EXPO_OS!, serverCache);\n return serverCache;\n } catch (error) {\n console.log('[RSC]: Failed to create cache:', error);\n\n // Fallback to a simple in-memory cache.\n const cache = new Map();\n const serverCache = {\n getStore: () => cache.get('store'),\n run: <T>(store: RenderStore, fn: () => T) => {\n cache.set('store', store);\n try {\n return fn();\n } finally {\n cache.delete('store');\n }\n },\n };\n globalThis.__EXPO_RSC_CACHE__.set(process.env.EXPO_OS!, serverCache);\n return serverCache;\n }\n}\n\nlet previousRenderStore: RenderStore | undefined;\nlet currentRenderStore: RenderStore | undefined;\n\nconst renderStorage = getGlobalCacheForPlatform();\n\n/**\n * This is an internal function and not for public use.\n */\nexport const runWithRenderStore = <T>(renderStore: RenderStore, fn: () => T): T => {\n if (renderStorage) {\n return renderStorage.run(renderStore, fn);\n }\n previousRenderStore = currentRenderStore;\n currentRenderStore = renderStore;\n try {\n return fn();\n } finally {\n currentRenderStore = previousRenderStore;\n }\n};\n\nexport function rerender(input: string, params?: unknown) {\n const renderStore = renderStorage?.getStore() ?? currentRenderStore;\n if (!renderStore) {\n throw new Error('Render store is not available');\n }\n renderStore.rerender(input, params);\n}\n\nexport function getContext<\n RscContext extends Record<string, unknown> = Record<string, unknown>,\n>(): RscContext {\n const renderStore = renderStorage?.getStore() ?? currentRenderStore;\n if (!renderStore) {\n throw new Error('Render store is not available');\n }\n return renderStore.context as RscContext;\n}\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/rsc/server.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAOU,QAAA,eAAe,GAAG,uBAAuB,CAAC;AAiDvD,SAAgB,aAAa,CAC3B,aAA4B,EAC5B,cAA+B,EAC/B,YAA2B;IAE3B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;AACzD,CAAC;AAND,sCAMC;AAkBD,6DAA6D;AAC7D,oIAAoI;AACpI,SAAS,yBAAyB;IAChC,IAAI,CAAC,UAAU,CAAC,kBAAkB,EAAE;QAClC,UAAU,CAAC,kBAAkB,GAAG,IAAI,GAAG,EAAE,CAAC;KAC3C;IAED,IAAI,UAAU,CAAC,kBAAkB,CAAC,GAAG,CAAC,O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AI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;CACF","sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n * Copyright © 2024 2023 Daishi Kato\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { type AsyncLocalStorage } from 'node:async_hooks';\nimport type { ReactNode } from 'react';\n\nimport type { PathSpec } from './path';\n\nexport const REQUEST_HEADERS = '__expo_requestHeaders';\n\ndeclare let globalThis: {\n __EXPO_RSC_CACHE__?: Map<string, any>;\n __webpack_chunk_load__: (id: string) => Promise<any>;\n __webpack_require__: (id: string) => any;\n};\n\ntype Config = any;\n\ntype Elements = Record<string, ReactNode>;\n\nexport type BuildConfig = {\n pathname: string | PathSpec; // TODO drop support for string?\n isStatic?: boolean | undefined;\n entries?: {\n input: string;\n skipPrefetch?: boolean | undefined;\n isStatic?: boolean | undefined;\n }[];\n context?: Record<string, unknown>;\n customCode?: string; // optional code to inject TODO hope to remove this\n customData?: unknown; // should be serializable with JSON.stringify\n}[];\n\nexport type RenderEntries = (\n input: string,\n options: {\n params: unknown | undefined;\n buildConfig: BuildConfig | undefined;\n }\n) => Promise<Elements | null>;\n\nexport type GetBuildConfig = (\n unstable_collectClientModules: (input: string) => Promise<string[]>\n) => Promise<BuildConfig>;\n\nexport type GetSsrConfig = (\n pathname: string,\n options: {\n searchParams: URLSearchParams;\n buildConfig?: BuildConfig | undefined;\n }\n) => Promise<{\n input: string;\n searchParams?: URLSearchParams;\n html: ReactNode;\n} | null>;\n\nexport function defineEntries(\n renderEntries: RenderEntries,\n getBuildConfig?: GetBuildConfig,\n getSsrConfig?: GetSsrConfig\n) {\n return { renderEntries, getBuildConfig, getSsrConfig };\n}\n\nexport type EntriesDev = {\n default: ReturnType<typeof defineEntries>;\n};\n\nexport type EntriesPrd = EntriesDev & {\n loadConfig: () => Promise<Config>;\n loadModule: (id: string) => Promise<unknown>;\n dynamicHtmlPaths: [pathSpec: PathSpec, htmlHead: string][];\n publicIndexHtml: string;\n};\n\ntype RenderStore<> = {\n rerender: (input: string, params?: unknown) => void;\n context: Record<string, unknown>;\n};\n\n// TODO(EvanBacon): This can leak between platforms and runs.\n// We need to share this module between the server action module and the renderer module, per platform, and invalidate on refreshes.\nfunction getGlobalCacheForPlatform(): Pick<AsyncLocalStorage<RenderStore>, 'getStore' | 'run'> {\n if (!globalThis.__EXPO_RSC_CACHE__) {\n globalThis.__EXPO_RSC_CACHE__ = new Map();\n }\n\n if (globalThis.__EXPO_RSC_CACHE__.has(process.env.EXPO_OS!)) {\n return globalThis.__EXPO_RSC_CACHE__.get(process.env.EXPO_OS!)!;\n }\n try {\n const { AsyncLocalStorage } = require('node:async_hooks');\n // @ts-expect-error: This is a Node.js feature.\n const serverCache = new AsyncLocalStorage<RenderStore>();\n globalThis.__EXPO_RSC_CACHE__.set(process.env.EXPO_OS!, serverCache);\n return serverCache;\n } catch (error) {\n console.log('[RSC]: Failed to create cache:', error);\n\n // Fallback to a simple in-memory cache.\n const cache = new Map();\n const serverCache = {\n getStore: () => cache.get('store'),\n run: <T>(store: RenderStore, fn: () => T) => {\n cache.set('store', store);\n try {\n return fn();\n } finally {\n cache.delete('store');\n }\n },\n };\n globalThis.__EXPO_RSC_CACHE__.set(process.env.EXPO_OS!, serverCache);\n return serverCache;\n }\n}\n\nlet previousRenderStore: RenderStore | undefined;\nlet currentRenderStore: RenderStore | undefined;\n\nconst renderStorage = getGlobalCacheForPlatform();\n\n/**\n * This is an internal function and not for public use.\n */\nexport const runWithRenderStore = <T>(renderStore: RenderStore, fn: () => T): T => {\n if (renderStorage) {\n return renderStorage.run(renderStore, fn);\n }\n previousRenderStore = currentRenderStore;\n currentRenderStore = renderStore;\n try {\n return fn();\n } finally {\n currentRenderStore = previousRenderStore;\n }\n};\n\nexport function rerender(input: string, params?: unknown) {\n const renderStore = renderStorage?.getStore() ?? currentRenderStore;\n if (!renderStore) {\n throw new Error('Render store is not available');\n }\n renderStore.rerender(input, params);\n}\n\nexport function getContext<\n RscContext extends Record<string, unknown> = Record<string, unknown>,\n>(): RscContext {\n const renderStore = renderStorage?.getStore() ?? currentRenderStore;\n if (!renderStore) {\n throw new Error('Render store is not available');\n }\n return renderStore.context as RscContext;\n}\n\n/** Get the request headers used to make the server component or action request. */\nexport async function unstable_headers(): Promise<Headers> {\n const headers = (getContext()[REQUEST_HEADERS] || {}) as Record<string, string>;\n return new ReadonlyHeaders(headers);\n}\n\nclass ReadonlyHeaders extends Headers {\n set() {\n throw new Error('Server component Headers are read-only');\n }\n append() {\n throw new Error('Server component Headers are read-only');\n }\n delete() {\n throw new Error('Server component Headers are read-only');\n }\n}\n"]}
@@ -38,8 +38,9 @@ export type TabNavigationEventMap = {
38
38
  };
39
39
  };
40
40
  /**
41
- * The React Navigation custom navigator
42
- * @see https://reactnavigation.org/docs/custom-navigators/#usenavigationbuilder
41
+ * The React Navigation custom navigator.
42
+ *
43
+ * @see [`useNavigationBuilder`](https://reactnavigation.org/docs/custom-navigators/#usenavigationbuilder) hook from React Navigation for more information.
43
44
  */
44
45
  export type TabsContextValue = ReturnType<typeof useNavigationBuilder<TabNavigationState<any>, TabRouterOptions, TabActionHelpers<ParamListBase>, ExpoTabsNavigatorScreenOptions, TabNavigationEventMap>>;
45
46
  export type TabContextValue = TabsDescriptor['options'];
@@ -1 +1 @@
1
- {"version":3,"file":"TabContext.d.ts","sourceRoot":"","sources":["../../src/ui/TabContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAErD,MAAM,MAAM,8BAA8B,GAAG;IAC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ACT,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,KAAK;IACZ,UAAU,EAAE,EAAE;IACd,MAAM,EAAE,EAAE;CACX,CAAC,CAAC","sourcesContent":["import { BottomTabNavigationOptions } from '@react-navigation/bottom-tabs';\nimport {\n DefaultNavigatorOptions,\n NavigationAction,\n NavigationProp,\n ParamListBase,\n TabActionHelpers,\n TabNavigationState,\n TabRouterOptions,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport { createContext } from 'react';\n\nimport { TriggerMap } from './common';\n\nexport type ExpoTabsProps = ExpoTabsNavigatorOptions;\n\nexport type ExpoTabsNavigatorScreenOptions = {\n detachInactiveScreens?: boolean;\n unmountOnBlur?: boolean;\n freezeOnBlur?: boolean;\n lazy?: boolean;\n};\n\nexport type ExpoTabsNavigatorOptions = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n TabNavigationState<ParamListBase>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap,\n ExpoTabsNavigationProp<ParamListBase>\n> &\n // Should be set through `unstable_settings`\n Omit<TabRouterOptions, 'initialRouteName'> &\n ExpoTabsNavigatorScreenOptions;\n\nexport type ExpoTabsNavigationProp<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = keyof ParamList,\n NavigatorID extends string | undefined = undefined,\n> = NavigationProp<\n ParamList,\n RouteName,\n NavigatorID,\n TabNavigationState<ParamListBase>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap\n>;\n\n/**\n * @hidden\n */\nexport type ExpoTabsScreenOptions = Pick<\n BottomTabNavigationOptions,\n 'title' | 'lazy' | 'freezeOnBlur'\n> & {\n params?: object;\n title: string;\n action: NavigationAction;\n};\n\n/**\n * @hidden\n */\nexport type TabNavigationEventMap = {\n /**\n * Event which fires on tapping on the tab in the tab bar.\n */\n tabPress: { data: undefined; canPreventDefault: true };\n /**\n * Event which fires on long press on the tab in the tab bar.\n */\n tabLongPress: { data: undefined };\n};\n\n/**\n * The React Navigation custom navigator\n * @see https://reactnavigation.org/docs/custom-navigators/#usenavigationbuilder\n */\nexport type TabsContextValue = ReturnType<\n typeof useNavigationBuilder<\n TabNavigationState<any>,\n TabRouterOptions,\n TabActionHelpers<ParamListBase>,\n ExpoTabsNavigatorScreenOptions,\n TabNavigationEventMap\n >\n>;\n\nexport type TabContextValue = TabsDescriptor['options'];\n\nexport const TabContext = createContext<TabContextValue>({});\n/**\n * @hidden\n */\nexport const TabTriggerMapContext = createContext<TriggerMap>({});\n/**\n * @hidden\n */\nexport const TabsDescriptorsContext = createContext<TabsContextValue['descriptors']>({});\n/**\n * @hidden\n */\nexport const TabsNavigatorContext = createContext<TabsContextValue['navigation'] | null>(null);\n/**\n * @hidden\n */\nexport const TabsStateContext = createContext<TabsContextValue['state']>({\n type: 'tab',\n preloadedRouteKeys: [],\n history: [],\n index: -1,\n key: '',\n stale: false,\n routeNames: [],\n routes: [],\n});\n\nexport type Route = TabNavigationState<ParamListBase>['routes'][number];\nexport type TabsDescriptor = TabsContextValue['descriptors'][number];\n"]}
1
+ {"version":3,"file":"TabContext.js","sourceRoot":"","sources":["../../src/ui/TabContext.tsx"],"names":[],"mappings":";;;AAWA,iCAAsC;AAiFzB,QAAA,UAAU,GAAG,IAAA,qBAAa,EAAkB,EAAE,CAAC,CAAC;AAC7D;;GAEG;AACU,QAAA,oBAAoB,GAAG,IAAA,qBAAa,EAAa,EAAE,CAAC,CAAC;AAClE;;GAEG;AACU,QAAA,sBAAsB,GAAG,IAAA,qBAAa,EAAkC,EAAE,CAAC,CAAC;AACzF;;GAEG;AACU,QAAA,oBAAoB,GAAG,IAAA,qBAAa,EAAwC,IAAI,CAAC,CAAC;AAC/F;;GAEG;AACU,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAA4B;IACvE,IAAI,EAAE,KAAK;IACX,kBAAkB,EAAE,EAAE;IACtB,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,CAAC,CAAC;IACT,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,KAAK;IACZ,UAAU,EAAE,EAAE;IACd,MAAM,EAAE,EAAE;CACX,CAAC,CAAC","sourcesContent":["import { BottomTabNavigationOptions } from '@react-navigation/bottom-tabs';\nimport {\n DefaultNavigatorOptions,\n NavigationAction,\n NavigationProp,\n ParamListBase,\n TabActionHelpers,\n TabNavigationState,\n TabRouterOptions,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport { createContext } from 'react';\n\nimport { TriggerMap } from './common';\n\nexport type ExpoTabsProps = ExpoTabsNavigatorOptions;\n\nexport type ExpoTabsNavigatorScreenOptions = {\n detachInactiveScreens?: boolean;\n unmountOnBlur?: boolean;\n freezeOnBlur?: boolean;\n lazy?: boolean;\n};\n\nexport type ExpoTabsNavigatorOptions = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n TabNavigationState<ParamListBase>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap,\n ExpoTabsNavigationProp<ParamListBase>\n> &\n // Should be set through `unstable_settings`\n Omit<TabRouterOptions, 'initialRouteName'> &\n ExpoTabsNavigatorScreenOptions;\n\nexport type ExpoTabsNavigationProp<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = keyof ParamList,\n NavigatorID extends string | undefined = undefined,\n> = NavigationProp<\n ParamList,\n RouteName,\n NavigatorID,\n TabNavigationState<ParamListBase>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap\n>;\n\n/**\n * @hidden\n */\nexport type ExpoTabsScreenOptions = Pick<\n BottomTabNavigationOptions,\n 'title' | 'lazy' | 'freezeOnBlur'\n> & {\n params?: object;\n title: string;\n action: NavigationAction;\n};\n\n/**\n * @hidden\n */\nexport type TabNavigationEventMap = {\n /**\n * Event which fires on tapping on the tab in the tab bar.\n */\n tabPress: { data: undefined; canPreventDefault: true };\n /**\n * Event which fires on long press on the tab in the tab bar.\n */\n tabLongPress: { data: undefined };\n};\n\n/**\n * The React Navigation custom navigator.\n *\n * @see [`useNavigationBuilder`](https://reactnavigation.org/docs/custom-navigators/#usenavigationbuilder) hook from React Navigation for more information.\n */\nexport type TabsContextValue = ReturnType<\n typeof useNavigationBuilder<\n TabNavigationState<any>,\n TabRouterOptions,\n TabActionHelpers<ParamListBase>,\n ExpoTabsNavigatorScreenOptions,\n TabNavigationEventMap\n >\n>;\n\nexport type TabContextValue = TabsDescriptor['options'];\n\nexport const TabContext = createContext<TabContextValue>({});\n/**\n * @hidden\n */\nexport const TabTriggerMapContext = createContext<TriggerMap>({});\n/**\n * @hidden\n */\nexport const TabsDescriptorsContext = createContext<TabsContextValue['descriptors']>({});\n/**\n * @hidden\n */\nexport const TabsNavigatorContext = createContext<TabsContextValue['navigation'] | null>(null);\n/**\n * @hidden\n */\nexport const TabsStateContext = createContext<TabsContextValue['state']>({\n type: 'tab',\n preloadedRouteKeys: [],\n history: [],\n index: -1,\n key: '',\n stale: false,\n routeNames: [],\n routes: [],\n});\n\nexport type Route = TabNavigationState<ParamListBase>['routes'][number];\nexport type TabsDescriptor = TabsContextValue['descriptors'][number];\n"]}
@@ -1,14 +1,14 @@
1
1
  import { ReactElement, ComponentProps } from 'react';
2
2
  import { ViewProps } from 'react-native';
3
3
  export type TabListProps = ViewProps & {
4
- /** Forward props to child component and removes the extra <View />. Useful for custom wrappers. */
4
+ /** Forward props to child component and removes the extra `<View>`. Useful for custom wrappers. */
5
5
  asChild?: boolean;
6
6
  };
7
7
  /**
8
- * Wrapper component for `<TabTriggers />`. `<TabTriggers />` within the `<TabList />` define the tabs.o
8
+ * Wrapper component for `TabTriggers`. `TabTriggers` within the `TabList` define the tabs.
9
9
  *
10
10
  * @example
11
- * ```ts
11
+ * ```tsx
12
12
  * <Tabs>
13
13
  * <TabSlot />
14
14
  * <TabList>
@@ -4,10 +4,10 @@ exports.isTabList = exports.TabList = void 0;
4
4
  const react_native_1 = require("react-native");
5
5
  const common_1 = require("./common");
6
6
  /**
7
- * Wrapper component for `<TabTriggers />`. `<TabTriggers />` within the `<TabList />` define the tabs.o
7
+ * Wrapper component for `TabTriggers`. `TabTriggers` within the `TabList` define the tabs.
8
8
  *
9
9
  * @example
10
- * ```ts
10
+ * ```tsx
11
11
  * <Tabs>
12
12
  * <TabSlot />
13
13
  * <TabList>
@@ -1 +1 @@
1
- {"version":3,"file":"TabList.js","sourceRoot":"","sources":["../../src/ui/TabList.tsx"],"names":[],"mappings":";;;AACA,+CAA2D;AAE3D,qCAAoC;AAOpC;;;;;;;;;;;;GAYG;AACH,SAAgB,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAgB;IAChE,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,iBAAQ,CAAC,CAAC,CAAC,mBAAI,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AAC7D,CAAC;AAHD,0BAGC;AAED;;GAEG;AACH,SAAgB,SAAS,CACvB,KAAwB;IAExB,OAAO,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC;AAChC,CAAC;AAJD,8BAIC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE;QACP,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,eAAe;KAChC;IACD,UAAU,EAAE;QACV,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,eAAe;KAChC;CACF,CAAC,CAAC","sourcesContent":["import { ReactElement, ComponentProps } from 'react';\nimport { View, StyleSheet, ViewProps } from 'react-native';\n\nimport { ViewSlot } from './common';\n\nexport type TabListProps = ViewProps & {\n /** Forward props to child component and removes the extra <View />. Useful for custom wrappers. */\n asChild?: boolean;\n};\n\n/**\n * Wrapper component for `<TabTriggers />`. `<TabTriggers />` within the `<TabList />` define the tabs.o\n *\n * @example\n * ```ts\n * <Tabs>\n * <TabSlot />\n * <TabList>\n * <TabTrigger name=\"home\" href=\"/\" />\n * </TabList>\n * </Tabs>\n * ```\n */\nexport function TabList({ asChild, style, ...props }: TabListProps) {\n const Comp = asChild ? ViewSlot : View;\n return <Comp style={[styles.tabList, style]} {...props} />;\n}\n\n/**\n * @hidden\n */\nexport function isTabList(\n child: ReactElement<any>\n): child is ReactElement<ComponentProps<typeof TabList>> {\n return child.type === TabList;\n}\n\nconst styles = StyleSheet.create({\n tabList: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n tabTrigger: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n});\n"]}
1
+ {"version":3,"file":"TabList.js","sourceRoot":"","sources":["../../src/ui/TabList.tsx"],"names":[],"mappings":";;;AACA,+CAA2D;AAE3D,qCAAoC;AAOpC;;;;;;;;;;;;GAYG;AACH,SAAgB,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAgB;IAChE,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,iBAAQ,CAAC,CAAC,CAAC,mBAAI,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AAC7D,CAAC;AAHD,0BAGC;AAED;;GAEG;AACH,SAAgB,SAAS,CACvB,KAAwB;IAExB,OAAO,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC;AAChC,CAAC;AAJD,8BAIC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE;QACP,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,eAAe;KAChC;IACD,UAAU,EAAE;QACV,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,eAAe;KAChC;CACF,CAAC,CAAC","sourcesContent":["import { ReactElement, ComponentProps } from 'react';\nimport { View, StyleSheet, ViewProps } from 'react-native';\n\nimport { ViewSlot } from './common';\n\nexport type TabListProps = ViewProps & {\n /** Forward props to child component and removes the extra `<View>`. Useful for custom wrappers. */\n asChild?: boolean;\n};\n\n/**\n * Wrapper component for `TabTriggers`. `TabTriggers` within the `TabList` define the tabs.\n *\n * @example\n * ```tsx\n * <Tabs>\n * <TabSlot />\n * <TabList>\n * <TabTrigger name=\"home\" href=\"/\" />\n * </TabList>\n * </Tabs>\n * ```\n */\nexport function TabList({ asChild, style, ...props }: TabListProps) {\n const Comp = asChild ? ViewSlot : View;\n return <Comp style={[styles.tabList, style]} {...props} />;\n}\n\n/**\n * @hidden\n */\nexport function isTabList(\n child: ReactElement<any>\n): child is ReactElement<ComponentProps<typeof TabList>> {\n return child.type === TabList;\n}\n\nconst styles = StyleSheet.create({\n tabList: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n tabTrigger: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n});\n"]}
@@ -3,34 +3,48 @@ import { ScreenContainer } from 'react-native-screens';
3
3
  import { TabsDescriptor } from './TabContext';
4
4
  import { TabListProps } from './TabList';
5
5
  export type UseTabSlotOptions = ComponentProps<typeof ScreenContainer> & {
6
- /** Remove inactive screens */
6
+ /**
7
+ * Remove inactive screens.
8
+ */
7
9
  detachInactiveScreens?: boolean;
8
- /** Override how the <Screen /> is rendered */
10
+ /**
11
+ * Override how the `Screen` component is rendered.
12
+ */
9
13
  renderFn?: typeof defaultTabsSlotRender;
10
14
  };
11
15
  /**
12
- * Options provided to the UseTabSlotOptions.renderFn
16
+ * Options provided to the `UseTabSlotOptions`.
13
17
  */
14
18
  export type TabsSlotRenderOptions = {
15
- /** Index of screen */
19
+ /**
20
+ * Index of screen.
21
+ */
16
22
  index: number;
17
- /** Whether the screen is focused */
23
+ /**
24
+ * Whether the screen is focused.
25
+ */
18
26
  isFocused: boolean;
19
- /** Whether the screen has been loaded */
27
+ /**
28
+ * Whether the screen has been loaded.
29
+ */
20
30
  loaded: boolean;
21
- /** Should the screen be unloaded when inactive */
31
+ /**
32
+ * Should the screen be unloaded when inactive.
33
+ */
22
34
  detachInactiveScreens: boolean;
23
35
  };
24
36
  /**
25
- * Returns a ReactElement of the current tab.
26
37
  *
27
- * @see `useTabSlot`
38
+ * Returns a `ReactElement` of the current tab.
39
+ *
40
+ * @see [`useTabSlot`](#usetabslotoptions).
28
41
  *
29
42
  * @example
30
- * ```ts
43
+ * ```tsx
31
44
  * function MyTabSlot() {
32
- * const slot = useTabSlot()
33
- * return slot
45
+ * const slot = useTabSlot();
46
+ *
47
+ * return slot;
34
48
  * }
35
49
  * ```
36
50
  */
@@ -39,10 +53,10 @@ export type TabSlotProps = UseTabSlotOptions;
39
53
  /**
40
54
  * Renders the current tab.
41
55
  *
42
- * @see `useTabSlot`
56
+ * @see [`useTabSlot`](#usetabslot) for a hook version of this component.
43
57
  *
44
58
  * @example
45
- * ```ts
59
+ * ```tsx
46
60
  * <Tabs>
47
61
  * <TabSlot />
48
62
  * <TabList>
@@ -1 +1 @@
1
- {"version":3,"file":"TabSlot.d.ts","sourceRoot":"","sources":["../../src/ui/TabSlot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAU,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAc,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,OAAO,eAAe,CAAC,GAAG;IACvE,8BAA8B;IAC9B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,qBAAqB,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,yCAAyC;IACzC,MAAM,EAAE,OAAO,CAAC;IAChB,kDAAkD;IAClD,qBAAqB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AAU,CAAC,OAAO,GAAE,iBAAsB,+BAsCzD;AAED,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAE7C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,+BAE1C;AAED,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,cAAc,EAC1B,EAAE,SAAS,EAAE,MAAM,EAAE,qBAAqB,EAAE,EAAE,qBAAqB,sCAuBpE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,KAAK,IAAI,YAAY,CAAC,YAAY,CAAC,CAEvF"}
@@ -7,15 +7,17 @@ const react_native_screens_1 = require("react-native-screens");
7
7
  const TabContext_1 = require("./TabContext");
8
8
  const Navigator_1 = require("../views/Navigator");
9
9
  /**
10
- * Returns a ReactElement of the current tab.
11
10
  *
12
- * @see `useTabSlot`
11
+ * Returns a `ReactElement` of the current tab.
12
+ *
13
+ * @see [`useTabSlot`](#usetabslotoptions).
13
14
  *
14
15
  * @example
15
- * ```ts
16
+ * ```tsx
16
17
  * function MyTabSlot() {
17
- * const slot = useTabSlot()
18
- * return slot
18
+ * const slot = useTabSlot();
19
+ *
20
+ * return slot;
19
21
  * }
20
22
  * ```
21
23
  */
@@ -47,10 +49,10 @@ exports.useTabSlot = useTabSlot;
47
49
  /**
48
50
  * Renders the current tab.
49
51
  *
50
- * @see `useTabSlot`
52
+ * @see [`useTabSlot`](#usetabslot) for a hook version of this component.
51
53
  *
52
54
  * @example
53
- * ```ts
55
+ * ```tsx
54
56
  * <Tabs>
55
57
  * <TabSlot />
56
58
  * <TabList>
@@ -1 +1 @@
1
- {"version":3,"file":"TabSlot.js","sourceRoot":"","sources":["../../src/ui/TabSlot.tsx"],"names":[],"mappings":";;;AAAA,iCAA+D;AAC/D,+CAAoD;AACpD,+DAA+D;AAE/D,6CAA0D;AAE1D,kDAAyD;AAuBzD;;;;;;;;;;;;GAYG;AACH,S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;;GAEG;AACH,SAAgB,SAAS,CAAC,KAAwB;IAChD,OAAO,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC;AAChC,CAAC;AAFD,8BAEC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,MAAM,EAAE;QACN,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,MAAM;KACf;IACD,eAAe,EAAE;QACf,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;KACZ;IACD,OAAO,EAAE;QACP,MAAM,EAAE,CAAC;QACT,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;KACZ;IACD,SAAS,EAAE;QACT,MAAM,EAAE,CAAC,CAAC;QACV,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;KACZ;CACF,CAAC,CAAC","sourcesContent":["import { ComponentProps, ReactElement, useState } from 'react';\nimport { Platform, StyleSheet } from 'react-native';\nimport { ScreenContainer, Screen } from 'react-native-screens';\n\nimport { TabContext, TabsDescriptor } from './TabContext';\nimport { TabListProps } from './TabList';\nimport { useNavigatorContext } from '../views/Navigator';\n\nexport type UseTabSlotOptions = ComponentProps<typeof ScreenContainer> & {\n /** Remove inactive screens */\n detachInactiveScreens?: boolean;\n /** Override how the <Screen /> is rendered */\n renderFn?: typeof defaultTabsSlotRender;\n};\n\n/**\n * Options provided to the UseTabSlotOptions.renderFn\n */\nexport type TabsSlotRenderOptions = {\n /** Index of screen */\n index: number;\n /** Whether the screen is focused */\n isFocused: boolean;\n /** Whether the screen has been loaded */\n loaded: boolean;\n /** Should the screen be unloaded when inactive */\n detachInactiveScreens: boolean;\n};\n\n/**\n * Returns a ReactElement of the current tab.\n *\n * @see `useTabSlot`\n *\n * @example\n * ```ts\n * function MyTabSlot() {\n * const slot = useTabSlot()\n * return slot\n * }\n * ```\n */\nexport function useTabSlot(options: UseTabSlotOptions = {}) {\n const {\n detachInactiveScreens = Platform.OS === 'web' ||\n Platform.OS === 'android' ||\n Platform.OS === 'ios',\n style,\n renderFn = defaultTabsSlotRender,\n } = options;\n\n const { state, descriptors } = useNavigatorContext();\n const focusedRouteKey = state.routes[state.index].key;\n const [loaded, setLoaded] = useState({ [focusedRouteKey]: true });\n\n if (!loaded[focusedRouteKey]) {\n setLoaded({ ...loaded, [focusedRouteKey]: true });\n }\n\n return (\n <ScreenContainer\n enabled={detachInactiveScreens}\n hasTwoStates\n style={[styles.screenContainer, style]}>\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key] as unknown as TabsDescriptor;\n\n return (\n <TabContext.Provider key={descriptor.route.key} value={descriptor.options}>\n {renderFn(descriptor, {\n index,\n isFocused: state.index === index,\n loaded: loaded[route.key],\n detachInactiveScreens,\n })}\n </TabContext.Provider>\n );\n })}\n </ScreenContainer>\n );\n}\n\nexport type TabSlotProps = UseTabSlotOptions;\n\n/**\n * Renders the current tab.\n *\n * @see `useTabSlot`\n *\n * @example\n * ```ts\n * <Tabs>\n * <TabSlot />\n * <TabList>\n * <TabTrigger name=\"home\" href=\"/\" />\n * </TabList>\n * </Tabs>\n * ```\n */\nexport function TabSlot(props: TabSlotProps) {\n return useTabSlot(props);\n}\n\nexport function defaultTabsSlotRender(\n descriptor: TabsDescriptor,\n { isFocused, loaded, detachInactiveScreens }: TabsSlotRenderOptions\n) {\n const { lazy = true, unmountOnBlur, freezeOnBlur } = descriptor.options;\n\n if (unmountOnBlur && !isFocused) {\n return null;\n }\n\n if (lazy && !loaded && !isFocused) {\n // Don't render a lazy screen if we've never navigated to it\n return null;\n }\n\n return (\n <Screen\n key={descriptor.route.key}\n enabled={detachInactiveScreens}\n activityState={isFocused ? 2 : 0}\n freezeOnBlur={freezeOnBlur}\n style={[styles.screen, isFocused ? styles.focused : styles.unfocused]}>\n {descriptor.render()}\n </Screen>\n );\n}\n\n/**\n * @hidden\n */\nexport function isTabSlot(child: ReactElement<any>): child is ReactElement<TabListProps> {\n return child.type === TabSlot;\n}\n\nconst styles = StyleSheet.create({\n screen: {\n flex: 1,\n position: 'relative',\n height: '100%',\n },\n screenContainer: {\n flexShrink: 0,\n flexGrow: 1,\n },\n focused: {\n zIndex: 1,\n display: 'flex',\n flexShrink: 0,\n flexGrow: 1,\n },\n unfocused: {\n zIndex: -1,\n display: 'none',\n flexShrink: 1,\n flexGrow: 0,\n },\n});\n"]}
1
+ {"version":3,"file":"TabSlot.js","sourceRoot":"","sources":["../../src/ui/TabSlot.tsx"],"names":[],"mappings":";;;AAAA,iCAA+D;AAC/D,+CAAoD;AACpD,+DAA+D;AAE/D,6CAA0D;AAE1D,kDAAyD;AAmCzD;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CAAC,UAA6B,EAAE;IACxD,MAAM,EACJ,qBAAqB,GAAG,uBAAQ,CAAC,EAAE,KAAK,KAAK;QAC3C,uBAAQ,CAAC,EAAE,KAAK,SAAS;QACzB,uBAAQ,CAAC,EAAE,KAAK,KAAK,EACvB,KAAK,EACL,QAAQ,GAAG,qBAAqB,GACjC,GAAG,OAAO,CAAC;IAEZ,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,IAAA,+BAAmB,GAAE,CAAC;IACrD,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;IACtD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAElE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE;QAC5B,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KACnD;IAED,OAAO,CACL,CAAC,sCAAe,CACd,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAC/B,YAAY,CACZ,KAAK,CAAC,C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AC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAC1B,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAC/B,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACjC,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CACtE;MAAA,CAAC,UAAU,CAAC,MAAM,EAAE,CACtB;IAAA,EAAE,6BAAM,CAAC,CACV,CAAC;AACJ,CAAC;AAzBD,sDAyBC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,KAAwB;IAChD,OAAO,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC;AAChC,CAAC;AAFD,8BAEC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,MAAM,EAAE;QACN,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,MAAM;KACf;IACD,eAAe,EAAE;QACf,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;KACZ;IACD,OAAO,EAAE;QACP,MAAM,EAAE,CAAC;QACT,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;KACZ;IACD,SAAS,EAAE;QACT,MAAM,EAAE,CAAC,CAAC;QACV,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;KACZ;CACF,CAAC,CAAC","sourcesContent":["import { ComponentProps, ReactElement, useState } from 'react';\nimport { Platform, StyleSheet } from 'react-native';\nimport { ScreenContainer, Screen } from 'react-native-screens';\n\nimport { TabContext, TabsDescriptor } from './TabContext';\nimport { TabListProps } from './TabList';\nimport { useNavigatorContext } from '../views/Navigator';\n\nexport type UseTabSlotOptions = ComponentProps<typeof ScreenContainer> & {\n /**\n * Remove inactive screens.\n */\n detachInactiveScreens?: boolean;\n /**\n * Override how the `Screen` component is rendered.\n */\n renderFn?: typeof defaultTabsSlotRender;\n};\n\n/**\n * Options provided to the `UseTabSlotOptions`.\n */\nexport type TabsSlotRenderOptions = {\n /**\n * Index of screen.\n */\n index: number;\n /**\n * Whether the screen is focused.\n */\n isFocused: boolean;\n /**\n * Whether the screen has been loaded.\n */\n loaded: boolean;\n /**\n * Should the screen be unloaded when inactive.\n */\n detachInactiveScreens: boolean;\n};\n\n/**\n *\n * Returns a `ReactElement` of the current tab.\n *\n * @see [`useTabSlot`](#usetabslotoptions).\n *\n * @example\n * ```tsx\n * function MyTabSlot() {\n * const slot = useTabSlot();\n *\n * return slot;\n * }\n * ```\n */\nexport function useTabSlot(options: UseTabSlotOptions = {}) {\n const {\n detachInactiveScreens = Platform.OS === 'web' ||\n Platform.OS === 'android' ||\n Platform.OS === 'ios',\n style,\n renderFn = defaultTabsSlotRender,\n } = options;\n\n const { state, descriptors } = useNavigatorContext();\n const focusedRouteKey = state.routes[state.index].key;\n const [loaded, setLoaded] = useState({ [focusedRouteKey]: true });\n\n if (!loaded[focusedRouteKey]) {\n setLoaded({ ...loaded, [focusedRouteKey]: true });\n }\n\n return (\n <ScreenContainer\n enabled={detachInactiveScreens}\n hasTwoStates\n style={[styles.screenContainer, style]}>\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key] as unknown as TabsDescriptor;\n\n return (\n <TabContext.Provider key={descriptor.route.key} value={descriptor.options}>\n {renderFn(descriptor, {\n index,\n isFocused: state.index === index,\n loaded: loaded[route.key],\n detachInactiveScreens,\n })}\n </TabContext.Provider>\n );\n })}\n </ScreenContainer>\n );\n}\n\nexport type TabSlotProps = UseTabSlotOptions;\n\n/**\n * Renders the current tab.\n *\n * @see [`useTabSlot`](#usetabslot) for a hook version of this component.\n *\n * @example\n * ```tsx\n * <Tabs>\n * <TabSlot />\n * <TabList>\n * <TabTrigger name=\"home\" href=\"/\" />\n * </TabList>\n * </Tabs>\n * ```\n */\nexport function TabSlot(props: TabSlotProps) {\n return useTabSlot(props);\n}\n\nexport function defaultTabsSlotRender(\n descriptor: TabsDescriptor,\n { isFocused, loaded, detachInactiveScreens }: TabsSlotRenderOptions\n) {\n const { lazy = true, unmountOnBlur, freezeOnBlur } = descriptor.options;\n\n if (unmountOnBlur && !isFocused) {\n return null;\n }\n\n if (lazy && !loaded && !isFocused) {\n // Don't render a lazy screen if we've never navigated to it\n return null;\n }\n\n return (\n <Screen\n key={descriptor.route.key}\n enabled={detachInactiveScreens}\n activityState={isFocused ? 2 : 0}\n freezeOnBlur={freezeOnBlur}\n style={[styles.screen, isFocused ? styles.focused : styles.unfocused]}>\n {descriptor.render()}\n </Screen>\n );\n}\n\n/**\n * @hidden\n */\nexport function isTabSlot(child: ReactElement<any>): child is ReactElement<TabListProps> {\n return child.type === TabSlot;\n}\n\nconst styles = StyleSheet.create({\n screen: {\n flex: 1,\n position: 'relative',\n height: '100%',\n },\n screenContainer: {\n flexShrink: 0,\n flexGrow: 1,\n },\n focused: {\n zIndex: 1,\n display: 'flex',\n flexShrink: 0,\n flexGrow: 1,\n },\n unfocused: {\n zIndex: -1,\n display: 'none',\n flexShrink: 1,\n flexGrow: 0,\n },\n});\n"]}
@@ -8,13 +8,22 @@ type PressablePropsWithoutFunctionChildren = Omit<PressableProps, 'children'> &
8
8
  children?: ReactNode | undefined;
9
9
  };
10
10
  export type TabTriggerProps = PressablePropsWithoutFunctionChildren & {
11
- /** Name of tab. When used within a `<TabList />` this sets the name of the tab. Otherwise, this references the name. */
11
+ /**
12
+ * Name of tab. When used within a `TabList` this sets the name of the tab.
13
+ * Otherwise, this references the name.
14
+ */
12
15
  name: string;
13
- /** Name of tab. Required when used within a `<TabList />` */
16
+ /**
17
+ * Name of tab. Required when used within a `TabList`.
18
+ */
14
19
  href?: Href;
15
- /** Forward props to child component. Useful for custom wrappers. */
20
+ /**
21
+ * Forward props to child component. Useful for custom wrappers.
22
+ */
16
23
  asChild?: boolean;
17
- /** Reset the route when switching to the tab */
24
+ /**
25
+ * Resets the route when switching to a tab.
26
+ */
18
27
  reset?: SwitchToOptions['reset'] | 'onLongPress';
19
28
  };
20
29
  export type TabTriggerOptions = {
@@ -26,12 +35,14 @@ export type TabTriggerSlotProps = PressablePropsWithoutFunctionChildren & React.
26
35
  href?: string;
27
36
  };
28
37
  /**
29
- * Creates a trigger to navigate to a tab. `<TabTrigger />` functionality slightly changes when used as a child of `<TabList />`. In this instance, the `href` prop is required, and the trigger also defines what routes are present in the `<Tabs />`.
38
+ * Creates a trigger to navigate to a tab. When used as child of `TabList`, its
39
+ * functionality slightly changes since the `href` prop is required,
40
+ * and the trigger also defines what routes are present in the `Tabs`.
30
41
  *
31
- * When used outside of `<TabList />`, `<TabTrigger />` no longer requires a `href`.
42
+ * When used outside of `TabList`, this component no longer requires an `href`.
32
43
  *
33
44
  * @example
34
- * ```ts
45
+ * ```tsx
35
46
  * <Tabs>
36
47
  * <TabSlot />
37
48
  * <TabList>
@@ -49,7 +60,9 @@ export declare function isTabTrigger(child: ReactElement<any>): child is ReactEl
49
60
  * Options for `switchTab` function.
50
61
  */
51
62
  export type SwitchToOptions = {
52
- /** Navigate and reset the history */
63
+ /**
64
+ * Navigate and reset the history.
65
+ */
53
66
  reset?: ExpoTabsResetValue;
54
67
  };
55
68
  export type Trigger = TriggerMap[string] & {
@@ -69,7 +82,7 @@ export type TriggerProps = {
69
82
  onLongPress: PressableProps['onLongPress'];
70
83
  };
71
84
  /**
72
- * Utility hook creating custom `<TabTrigger />`
85
+ * Utility hook creating custom `TabTrigger`.
73
86
  */
74
87
  export declare function useTabTrigger(options: TabTriggerProps): UseTabTriggerResult;
75
88
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"TabTrigger.d.ts","sourceRoot":"","sources":["../../src/ui/TabTrigger.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAA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,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5D,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,SAAS,CAAC;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACnC,WAAW,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;CAC5C,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,mBAAmB,CAwG3E"}
@@ -12,12 +12,14 @@ const matchers_1 = require("../matchers");
12
12
  const Navigator_1 = require("../views/Navigator");
13
13
  const TabTriggerSlot = react_slot_1.Slot;
14
14
  /**
15
- * Creates a trigger to navigate to a tab. `<TabTrigger />` functionality slightly changes when used as a child of `<TabList />`. In this instance, the `href` prop is required, and the trigger also defines what routes are present in the `<Tabs />`.
15
+ * Creates a trigger to navigate to a tab. When used as child of `TabList`, its
16
+ * functionality slightly changes since the `href` prop is required,
17
+ * and the trigger also defines what routes are present in the `Tabs`.
16
18
  *
17
- * When used outside of `<TabList />`, `<TabTrigger />` no longer requires a `href`.
19
+ * When used outside of `TabList`, this component no longer requires an `href`.
18
20
  *
19
21
  * @example
20
- * ```ts
22
+ * ```tsx
21
23
  * <Tabs>
22
24
  * <TabSlot />
23
25
  * <TabList>
@@ -55,7 +57,7 @@ function isTabTrigger(child) {
55
57
  }
56
58
  exports.isTabTrigger = isTabTrigger;
57
59
  /**
58
- * Utility hook creating custom `<TabTrigger />`
60
+ * Utility hook creating custom `TabTrigger`.
59
61
  */
60
62
  function useTabTrigger(options) {
61
63
  const { state, navigation } = (0, Navigator_1.useNavigatorContext)();
@@ -1 +1 @@
1
- {"version":3,"file":"TabTrigger.js","sourceRoot":"","sources":["../../src/ui/TabTrigger.tsx"],"names":[],"mappings":";;;AAAA,qDAA4C;AAE5C,iCAAyF;AACzF,+CAA2E;AAE3E,6CAAoD;AAGpD,+DAAyD;AACzD,sDAA2C;AAC3C,mEAAoE;AACpE,0CAAyD;AAEzD,kDAAyD;AA4BzD,MAAM,cAAc,GAAG,iBAA4D,CAAC;AAEpF;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,GAAG,SAAS,EAAE,GAAG,KAAK,EAAmB;IAC9F,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,aAAa,CAAC;QAC9C,IAAI;QACJ,KAAK;QACL,GAAG,KAAK;KACT,CAAC,CAAC;IAEH,sFAAsF;IACtF,IAAI,OAAO,EAAE;QACX,OAAO,CACL,CAAC,cAAc,CACb,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CACzB,IAAI,KAAK,CAAC,CACV,IAAI,YAAY,CAAC,CACjB,IAAI,CAAC,CAAC,OAAO,EAAE,YAAY,CAAC,CAC5B;QAAA,CAAC,KAAK,CAAC,QAAQ,CACjB;MAAA,EAAE,cAAc,CAAC,CAClB,CAAC;KACH;SAAM;QACL,iEAAiE;QACjE,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QAE5D,OAAO,CACL,CAAC,wBAAS,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC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AM,iBAAiB,GAAG,IAAA,mBAAW,EACnC,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACjB,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,IAAI,KAAK,EAAE,kBAAkB,EAAE;YAAE,OAAO;QAExC,UAAU,EAAE,IAAI,CAAC;YACf,IAAI,EAAE,cAAc;YACpB,MAAM,EAAE,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI;SACxE,CAAC,CAAC;QAEH,IAAI,CAAC,IAAA,2CAAsB,EAAC,KAAK,CAAC;YAAE,OAAO;QAE3C,SAAS,CAAC,IAAI,EAAE;YACd,KAAK,EAAE,KAAK,KAAK,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK;SAClD,CAAC,CAAC;IACL,CAAC,EACD,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CACpC,CAAC;IAEF,MAAM,YAAY,GAAG;QACnB,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC;QACtC,OAAO,EAAE,aAAa;QACtB,WAAW,EAAE,iBAAiB;KAC/B,CAAC;IAEF,OAAO;QACL,SAAS;QACT,UAAU;QACV,OAAO;QACP,YAAY;KACb,CAAC;AACJ,CAAC;AAxGD,sCAwGC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,UAAU,EAAE;QACV,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,eAAe;KAChC;CACF,CAAC,CAAC","sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport { TabNavigationState } from '@react-navigation/native';\nimport { ReactNode, useContext, ReactElement, ComponentProps, useCallback } from 'react';\nimport { View, StyleSheet, Pressable, PressableProps } from 'react-native';\n\nimport { TabTriggerMapContext } from './TabContext';\nimport { ExpoTabsResetValue } from './TabRouter';\nimport type { TriggerMap } from './common';\nimport { appendBaseUrl } from '../fork/getPathFromState';\nimport { router } from '../imperative-api';\nimport { shouldHandleMouseEvent } from '../link/useLinkToPathProps';\nimport { stripGroupSegmentsFromPath } from '../matchers';\nimport type { Href } from '../types';\nimport { useNavigatorContext } from '../views/Navigator';\n\ntype PressablePropsWithoutFunctionChildren = Omit<PressableProps, 'children'> & {\n children?: ReactNode | undefined;\n};\n\nexport type TabTriggerProps = PressablePropsWithoutFunctionChildren & {\n /** Name of tab. When used within a `<TabList />` this sets the name of the tab. Otherwise, this references the name. */\n name: string;\n /** Name of tab. Required when used within a `<TabList />` */\n href?: Href;\n /** Forward props to child component. Useful for custom wrappers. */\n asChild?: boolean;\n /** Reset the route when switching to the tab */\n reset?: SwitchToOptions['reset'] | 'onLongPress';\n};\n\nexport type TabTriggerOptions = {\n name: string;\n href: Href;\n};\n\nexport type TabTriggerSlotProps = PressablePropsWithoutFunctionChildren &\n React.RefAttributes<View> & {\n isFocused?: boolean;\n href?: string;\n };\n\nconst TabTriggerSlot = Slot as React.ForwardRefExoticComponent<TabTriggerSlotProps>;\n\n/**\n * Creates a trigger to navigate to a tab. `<TabTrigger />` functionality slightly changes when used as a child of `<TabList />`. In this instance, the `href` prop is required, and the trigger also defines what routes are present in the `<Tabs />`.\n *\n * When used outside of `<TabList />`, `<TabTrigger />` no longer requires a `href`.\n *\n * @example\n * ```ts\n * <Tabs>\n * <TabSlot />\n * <TabList>\n * <TabTrigger name=\"home\" href=\"/\" />\n * </TabList>\n * </Tabs>\n * ```\n */\nexport function TabTrigger({ asChild, name, href, reset = 'onFocus', ...props }: TabTriggerProps) {\n const { trigger, triggerProps } = useTabTrigger({\n name,\n reset,\n ...props,\n });\n\n // Pressable doesn't accept the extra props, so only pass them if we are using asChild\n if (asChild) {\n return (\n <TabTriggerSlot\n style={styles.tabTrigger}\n {...props}\n {...triggerProps}\n href={trigger?.resolvedHref}>\n {props.children}\n </TabTriggerSlot>\n );\n } else {\n // These props are not typed, but are allowed by React Native Web\n const reactNativeWebProps = { href: trigger?.resolvedHref };\n\n return (\n <Pressable style={styles.tabTrigger} {...reactNativeWebProps} {...props} {...triggerProps}>\n {props.children}\n </Pressable>\n );\n }\n}\n\n/**\n * @hidden\n */\nexport function isTabTrigger(\n child: ReactElement<any>\n): child is ReactElement<ComponentProps<typeof TabTrigger>> {\n return child.type === TabTrigger;\n}\n\n/**\n * Options for `switchTab` function.\n */\nexport type SwitchToOptions = {\n /** Navigate and reset the history */\n reset?: ExpoTabsResetValue;\n};\n\nexport type Trigger = TriggerMap[string] & {\n isFocused: boolean;\n resolvedHref: string;\n route: TabNavigationState<any>['routes'][number];\n};\n\nexport type UseTabTriggerResult = {\n switchTab: (name: string, options: SwitchToOptions) => void;\n getTrigger: (name: string) => Trigger | undefined;\n trigger?: Trigger;\n triggerProps: TriggerProps;\n};\n\nexport type TriggerProps = {\n isFocused: boolean;\n onPress: PressableProps['onPress'];\n onLongPress: PressableProps['onLongPress'];\n};\n\n/**\n * Utility hook creating custom `<TabTrigger />`\n */\nexport function useTabTrigger(options: TabTriggerProps): UseTabTriggerResult {\n const { state, navigation } = useNavigatorContext();\n const { name, reset, onPress, onLongPress } = options;\n const triggerMap = useContext(TabTriggerMapContext);\n\n const getTrigger = useCallback(\n (name: string) => {\n const config = triggerMap[name];\n\n if (!config) {\n return;\n }\n\n return {\n isFocused: state.index === config.index,\n route: state.routes[config.index],\n resolvedHref: stripGroupSegmentsFromPath(appendBaseUrl(config.href)),\n ...config,\n };\n },\n [triggerMap]\n );\n\n const trigger = name !== undefined ? getTrigger(name) : undefined;\n\n const switchTab = useCallback(\n (name: string, options?: SwitchToOptions) => {\n const config = triggerMap[name];\n\n if (config) {\n if (config.type === 'external') {\n return router.navigate(config.href);\n } else {\n return navigation?.dispatch({\n type: 'JUMP_TO',\n payload: {\n name,\n ...options,\n },\n });\n }\n } else {\n return navigation?.dispatch({\n type: 'JUMP_TO',\n payload: {\n name,\n },\n });\n }\n },\n [navigation, triggerMap]\n );\n\n const handleOnPress = useCallback<NonNullable<PressableProps['onPress']>>(\n (event) => {\n onPress?.(event);\n if (!trigger) return;\n if (event?.isDefaultPrevented()) return;\n\n navigation?.emit({\n type: 'tabPress',\n target: trigger.type === 'internal' ? trigger.route.key : trigger?.href,\n canPreventDefault: true,\n });\n\n if (!shouldHandleMouseEvent(event)) return;\n\n switchTab(name, { reset: reset !== 'onLongPress' ? reset : undefined });\n },\n [onPress, name, reset, trigger]\n );\n\n const handleOnLongPress = useCallback<NonNullable<PressableProps['onPress']>>(\n (event) => {\n onPress?.(event);\n if (!trigger) return;\n if (event?.isDefaultPrevented()) return;\n\n navigation?.emit({\n type: 'tabLongPress',\n target: trigger.type === 'internal' ? trigger.route.key : trigger?.href,\n });\n\n if (!shouldHandleMouseEvent(event)) return;\n\n switchTab(name, {\n reset: reset === 'onLongPress' ? 'always' : reset,\n });\n },\n [onLongPress, name, reset, trigger]\n );\n\n const triggerProps = {\n isFocused: Boolean(trigger?.isFocused),\n onPress: handleOnPress,\n onLongPress: handleOnLongPress,\n };\n\n return {\n switchTab,\n getTrigger,\n trigger,\n triggerProps,\n };\n}\n\nconst styles = StyleSheet.create({\n tabTrigger: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n});\n"]}
1
+ {"version":3,"file":"TabTrigger.js","sourceRoot":"","sources":["../../src/ui/TabTrigger.tsx"],"names":[],"mappings":";;;AAAA,qDAA4C;AAE5C,iCAAyF;AACzF,+CAA2E;AAE3E,6CAAoD;AAGpD,+DAAyD;AACzD,sDAA2C;AAC3C,mEAAoE;AACpE,0CAAyD;AAEzD,kDAAyD;AAqCzD,MAAM,cAAc,GAAG,iBAA4D,CAAC;AAEpF;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,GAAG,SAAS,EAAE,GAAG,KAAK,EAAmB;IAC9F,MAAM,EAAE,OA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AAK,EAAE,OAAO,CAAC,CACpC,CAAC;IAEF,MAAM,YAAY,GAAG;QACnB,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC;QACtC,OAAO,EAAE,aAAa;QACtB,WAAW,EAAE,iBAAiB;KAC/B,CAAC;IAEF,OAAO;QACL,SAAS;QACT,UAAU;QACV,OAAO;QACP,YAAY;KACb,CAAC;AACJ,CAAC;AAxGD,sCAwGC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,UAAU,EAAE;QACV,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,eAAe;KAChC;CACF,CAAC,CAAC","sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport { TabNavigationState } from '@react-navigation/native';\nimport { ReactNode, useContext, ReactElement, ComponentProps, useCallback } from 'react';\nimport { View, StyleSheet, Pressable, PressableProps } from 'react-native';\n\nimport { TabTriggerMapContext } from './TabContext';\nimport { ExpoTabsResetValue } from './TabRouter';\nimport type { TriggerMap } from './common';\nimport { appendBaseUrl } from '../fork/getPathFromState';\nimport { router } from '../imperative-api';\nimport { shouldHandleMouseEvent } from '../link/useLinkToPathProps';\nimport { stripGroupSegmentsFromPath } from '../matchers';\nimport type { Href } from '../types';\nimport { useNavigatorContext } from '../views/Navigator';\n\ntype PressablePropsWithoutFunctionChildren = Omit<PressableProps, 'children'> & {\n children?: ReactNode | undefined;\n};\n\nexport type TabTriggerProps = PressablePropsWithoutFunctionChildren & {\n /**\n * Name of tab. When used within a `TabList` this sets the name of the tab.\n * Otherwise, this references the name.\n */\n name: string;\n /**\n * Name of tab. Required when used within a `TabList`.\n */\n href?: Href;\n /**\n * Forward props to child component. Useful for custom wrappers.\n */\n asChild?: boolean;\n /**\n * Resets the route when switching to a tab.\n */\n reset?: SwitchToOptions['reset'] | 'onLongPress';\n};\n\nexport type TabTriggerOptions = {\n name: string;\n href: Href;\n};\n\nexport type TabTriggerSlotProps = PressablePropsWithoutFunctionChildren &\n React.RefAttributes<View> & {\n isFocused?: boolean;\n href?: string;\n };\n\nconst TabTriggerSlot = Slot as React.ForwardRefExoticComponent<TabTriggerSlotProps>;\n\n/**\n * Creates a trigger to navigate to a tab. When used as child of `TabList`, its\n * functionality slightly changes since the `href` prop is required,\n * and the trigger also defines what routes are present in the `Tabs`.\n *\n * When used outside of `TabList`, this component no longer requires an `href`.\n *\n * @example\n * ```tsx\n * <Tabs>\n * <TabSlot />\n * <TabList>\n * <TabTrigger name=\"home\" href=\"/\" />\n * </TabList>\n * </Tabs>\n * ```\n */\nexport function TabTrigger({ asChild, name, href, reset = 'onFocus', ...props }: TabTriggerProps) {\n const { trigger, triggerProps } = useTabTrigger({\n name,\n reset,\n ...props,\n });\n\n // Pressable doesn't accept the extra props, so only pass them if we are using asChild\n if (asChild) {\n return (\n <TabTriggerSlot\n style={styles.tabTrigger}\n {...props}\n {...triggerProps}\n href={trigger?.resolvedHref}>\n {props.children}\n </TabTriggerSlot>\n );\n } else {\n // These props are not typed, but are allowed by React Native Web\n const reactNativeWebProps = { href: trigger?.resolvedHref };\n\n return (\n <Pressable style={styles.tabTrigger} {...reactNativeWebProps} {...props} {...triggerProps}>\n {props.children}\n </Pressable>\n );\n }\n}\n\n/**\n * @hidden\n */\nexport function isTabTrigger(\n child: ReactElement<any>\n): child is ReactElement<ComponentProps<typeof TabTrigger>> {\n return child.type === TabTrigger;\n}\n\n/**\n * Options for `switchTab` function.\n */\nexport type SwitchToOptions = {\n /**\n * Navigate and reset the history.\n */\n reset?: ExpoTabsResetValue;\n};\n\nexport type Trigger = TriggerMap[string] & {\n isFocused: boolean;\n resolvedHref: string;\n route: TabNavigationState<any>['routes'][number];\n};\n\nexport type UseTabTriggerResult = {\n switchTab: (name: string, options: SwitchToOptions) => void;\n getTrigger: (name: string) => Trigger | undefined;\n trigger?: Trigger;\n triggerProps: TriggerProps;\n};\n\nexport type TriggerProps = {\n isFocused: boolean;\n onPress: PressableProps['onPress'];\n onLongPress: PressableProps['onLongPress'];\n};\n\n/**\n * Utility hook creating custom `TabTrigger`.\n */\nexport function useTabTrigger(options: TabTriggerProps): UseTabTriggerResult {\n const { state, navigation } = useNavigatorContext();\n const { name, reset, onPress, onLongPress } = options;\n const triggerMap = useContext(TabTriggerMapContext);\n\n const getTrigger = useCallback(\n (name: string) => {\n const config = triggerMap[name];\n\n if (!config) {\n return;\n }\n\n return {\n isFocused: state.index === config.index,\n route: state.routes[config.index],\n resolvedHref: stripGroupSegmentsFromPath(appendBaseUrl(config.href)),\n ...config,\n };\n },\n [triggerMap]\n );\n\n const trigger = name !== undefined ? getTrigger(name) : undefined;\n\n const switchTab = useCallback(\n (name: string, options?: SwitchToOptions) => {\n const config = triggerMap[name];\n\n if (config) {\n if (config.type === 'external') {\n return router.navigate(config.href);\n } else {\n return navigation?.dispatch({\n type: 'JUMP_TO',\n payload: {\n name,\n ...options,\n },\n });\n }\n } else {\n return navigation?.dispatch({\n type: 'JUMP_TO',\n payload: {\n name,\n },\n });\n }\n },\n [navigation, triggerMap]\n );\n\n const handleOnPress = useCallback<NonNullable<PressableProps['onPress']>>(\n (event) => {\n onPress?.(event);\n if (!trigger) return;\n if (event?.isDefaultPrevented()) return;\n\n navigation?.emit({\n type: 'tabPress',\n target: trigger.type === 'internal' ? trigger.route.key : trigger?.href,\n canPreventDefault: true,\n });\n\n if (!shouldHandleMouseEvent(event)) return;\n\n switchTab(name, { reset: reset !== 'onLongPress' ? reset : undefined });\n },\n [onPress, name, reset, trigger]\n );\n\n const handleOnLongPress = useCallback<NonNullable<PressableProps['onPress']>>(\n (event) => {\n onPress?.(event);\n if (!trigger) return;\n if (event?.isDefaultPrevented()) return;\n\n navigation?.emit({\n type: 'tabLongPress',\n target: trigger.type === 'internal' ? trigger.route.key : trigger?.href,\n });\n\n if (!shouldHandleMouseEvent(event)) return;\n\n switchTab(name, {\n reset: reset === 'onLongPress' ? 'always' : reset,\n });\n },\n [onLongPress, name, reset, trigger]\n );\n\n const triggerProps = {\n isFocused: Boolean(trigger?.isFocused),\n onPress: handleOnPress,\n onLongPress: handleOnLongPress,\n };\n\n return {\n switchTab,\n getTrigger,\n trigger,\n triggerProps,\n };\n}\n\nconst styles = StyleSheet.create({\n tabTrigger: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n});\n"]}
@@ -14,16 +14,16 @@ export type UseTabsOptions = Omit<DefaultNavigatorOptions<ParamListBase, any, Ta
14
14
  backBehavior?: TabRouterOptions['backBehavior'];
15
15
  };
16
16
  export type TabsProps = ViewProps & {
17
- /** Forward props to child component and removes the extra <View />. Useful for custom wrappers. */
17
+ /** Forward props to child component and removes the extra `<View>`. Useful for custom wrappers. */
18
18
  asChild?: boolean;
19
19
  options?: UseTabsOptions;
20
20
  };
21
21
  /**
22
22
  * Root component for the headless tabs.
23
23
  *
24
- * @see useTabsWithChildren - The hook version of this component.
24
+ * @see [`useTabsWithChildren`](#usetabswithchildrenoptions) for a hook version of this component.
25
25
  * @example
26
- * ```ts
26
+ * ```tsx
27
27
  * <Tabs>
28
28
  * <TabSlot />
29
29
  * <TabList>
@@ -40,14 +40,17 @@ export type UseTabsWithTriggersOptions = UseTabsOptions & {
40
40
  triggers: ScreenTrigger[];
41
41
  };
42
42
  /**
43
- * Hook version of `<Tabs />`. The returned NavigationContent component should be rendered
43
+ * Hook version of `Tabs`. The returned NavigationContent component
44
+ * should be rendered.
44
45
  *
45
- * @see Tabs - The component version of this hook
46
+ * @see [`Tabs`](#tabs) for the component version of this hook.
46
47
  * @example
47
- * ```ts
48
+ * ```tsx
48
49
  * export function MyTabs({ children }) {
49
- * const { NavigationContent } = useTabsWithChildren({ children })
50
- * return <NavigationContent />
50
+ * const { NavigationContent } = useTabsWithChildren({ children })
51
+ *
52
+ * return <NavigationContent />
53
+ * }
51
54
  * ```
52
55
  */
53
56
  export declare function useTabsWithChildren(options: UseTabsWithChildrenOptions): {
@@ -110,18 +113,6 @@ export declare function useTabsWithChildren(options: UseTabsWithChildrenOptions)
110
113
  getParent<T = import("@react-navigation/native").NavigationHelpers<ParamListBase, {}> | undefined>(id?: string | undefined): T;
111
114
  getState(): Readonly<{
112
115
  key: string;
113
- /**
114
- * Alternative hook version of `<Tabs />` that uses explicit triggers instead of `children`
115
- *
116
- * @see Tabs - The component version of this hook
117
- * @example
118
- * ```ts
119
- * export function MyTabs({ children }) {
120
- * const { NavigationContent } = useTabsWithChildren({ triggers: [] })
121
- * return <NavigationContent />
122
- * }
123
- * ```
124
- */
125
116
  index: number;
126
117
  routeNames: string[];
127
118
  history?: unknown[] | undefined;
@@ -248,13 +239,15 @@ export declare function useTabsWithChildren(options: UseTabsWithChildrenOptions)
248
239
  }) => import("react/jsx-runtime").JSX.Element;
249
240
  };
250
241
  /**
251
- * Alternative hook version of `<Tabs />` that uses explicit triggers instead of `children`
242
+ * Alternative hook version of `Tabs` that uses explicit triggers
243
+ * instead of `children`.
252
244
  *
253
- * @see Tabs - The component version of this hook
245
+ * @see [`Tabs`](#tabs) for the component version of this hook.
254
246
  * @example
255
- * ```ts
247
+ * ```tsx
256
248
  * export function MyTabs({ children }) {
257
249
  * const { NavigationContent } = useTabsWithChildren({ triggers: [] })
250
+ *
258
251
  * return <NavigationContent />
259
252
  * }
260
253
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../src/ui/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAKL,SAAS,EAIV,MAAM,OAAO,CAAC;AACf,OAAO,EAAc,SAAS,EAAQ,MAAM,cAAc,CAAC;AAE3D,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EAErB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAoB,aAAa,EAAqB,MAAM,UAAU,CAAC;AAQ9E,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC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