UNPKG

5.92 kBSource Map (JSON)View Raw
1{"version":3,"sources":["NavigationContainer.tsx"],"names":["NavigationContainer","React","forwardRef","theme","DefaultTheme","linking","fallback","documentTitle","onReady","rest","ref","isLinkingEnabled","enabled","refContainer","useRef","getInitialState","prefixes","isResolved","initialState","useImperativeHandle","current","linkingContext","useMemo","options","isReady","onReadyRef","useEffect"],"mappings":";;;;;;;AAAA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,mBAAmB,gBAAGC,KAAK,CAACC,UAAN,CAAiB,SAASF,mBAAT,CAC3C;AACEG,EAAAA,KAAK,GAAGC,qBADV;AAEEC,EAAAA,OAFF;AAGEC,EAAAA,QAAQ,GAAG,IAHb;AAIEC,EAAAA,aAJF;AAKEC,EAAAA,OALF;AAME,KAAGC;AANL,CAD2C,EAS3CC,GAT2C,EAU3C;AACA,QAAMC,gBAAgB,GAAGN,OAAO,GAAGA,OAAO,CAACO,OAAR,KAAoB,KAAvB,GAA+B,KAA/D;AAEA,QAAMC,YAAY,GAAGZ,KAAK,CAACa,MAAN,CAAqC,IAArC,CAArB;AAEA,8BAAcD,YAAd;AACA,iCAAiBA,YAAjB,EAA+BN,aAA/B;AAEA,QAAM;AAAEQ,IAAAA;AAAF,MAAsB,yBAAWF,YAAX,EAAyB;AACnDD,IAAAA,OAAO,EAAED,gBAD0C;AAEnDK,IAAAA,QAAQ,EAAE,EAFyC;AAGnD,OAAGX;AAHgD,GAAzB,CAA5B;AAMA,QAAM,CAACY,UAAD,EAAaC,YAAb,IAA6B,0BAAYH,eAAZ,CAAnC;AAEAd,EAAAA,KAAK,CAACkB,mBAAN,CAA0BT,GAA1B,EAA+B,MAAMG,YAAY,CAACO,OAAlD;AAEA,QAAMC,cAAc,GAAGpB,KAAK,CAACqB,OAAN,CAAc,OAAO;AAAEC,IAAAA,OAAO,EAAElB;AAAX,GAAP,CAAd,EAA4C,CAACA,OAAD,CAA5C,CAAvB;AAEA,QAAMmB,OAAO,GAAGf,IAAI,CAACS,YAAL,IAAqB,IAArB,IAA6B,CAACP,gBAA9B,IAAkDM,UAAlE;AAEA,QAAMQ,UAAU,GAAGxB,KAAK,CAACa,MAAN,CAAaN,OAAb,CAAnB;AAEAP,EAAAA,KAAK,CAACyB,SAAN,CAAgB,MAAM;AACpBD,IAAAA,UAAU,CAACL,OAAX,GAAqBZ,OAArB;AACD,GAFD;AAIAP,EAAAA,KAAK,CAACyB,SAAN,CAAgB,MAAM;AACpB,QAAIF,OAAJ,EAAa;AAAA;;AACX,6BAAAC,UAAU,CAACL,OAAX,iFAAAK,UAAU;AACX;AACF,GAJD,EAIG,CAACD,OAAD,CAJH;;AAMA,MAAI,CAACA,OAAL,EAAc;AACZ;AACA;AACA,WAAOlB,QAAP;AACD;;AAED,sBACE,oBAAC,uBAAD,CAAgB,QAAhB;AAAyB,IAAA,KAAK,EAAEe;AAAhC,kBACE,oBAAC,sBAAD;AAAe,IAAA,KAAK,EAAElB;AAAtB,kBACE,oBAAC,6BAAD,eACMM,IADN;AAEE,IAAA,YAAY,EACVA,IAAI,CAACS,YAAL,IAAqB,IAArB,GAA4BA,YAA5B,GAA2CT,IAAI,CAACS,YAHpD;AAKE,IAAA,GAAG,EAAEL;AALP,KADF,CADF,CADF;AAaD,CA/D2B,CAA5B;eAiEeb,mB","sourcesContent":["import * as React from 'react';\nimport {\n BaseNavigationContainer,\n NavigationContainerProps,\n NavigationContainerRef,\n} from '@react-navigation/core';\nimport ThemeProvider from './theming/ThemeProvider';\nimport DefaultTheme from './theming/DefaultTheme';\nimport LinkingContext from './LinkingContext';\nimport useThenable from './useThenable';\nimport useLinking from './useLinking';\nimport useDocumentTitle from './useDocumentTitle';\nimport useBackButton from './useBackButton';\nimport type { Theme, LinkingOptions, DocumentTitleOptions } from './types';\n\ntype Props = NavigationContainerProps & {\n theme?: Theme;\n linking?: LinkingOptions;\n fallback?: React.ReactNode;\n documentTitle?: DocumentTitleOptions;\n onReady?: () => void;\n};\n\n/**\n * Container component which holds the navigation state designed for React Native apps.\n * This should be rendered at the root wrapping the whole app.\n *\n * @param props.initialState Initial state object for the navigation tree. When deep link handling is enabled, this will override deep links when specified. Make sure that you don't specify an `initialState` when there's a deep link (`Linking.getInitialURL()`).\n * @param props.onReady Callback which is called after the navigation tree mounts.\n * @param props.onStateChange Callback which is called with the latest navigation state when it changes.\n * @param props.theme Theme object for the navigators.\n * @param props.linking Options for deep linking. Deep link handling is enabled when this prop is provided, unless `linking.enabled` is `false`.\n * @param props.fallback Fallback component to render until we have finished getting initial state when linking is enabled. Defaults to `null`.\n * @param props.documentTitle Options to configure the document title on Web. Updating document title is handled by default unless `documentTitle.enabled` is `false`.\n * @param props.children Child elements to render the content.\n * @param props.ref Ref object which refers to the navigation object containing helper methods.\n */\nconst NavigationContainer = React.forwardRef(function NavigationContainer(\n {\n theme = DefaultTheme,\n linking,\n fallback = null,\n documentTitle,\n onReady,\n ...rest\n }: Props,\n ref?: React.Ref<NavigationContainerRef | null>\n) {\n const isLinkingEnabled = linking ? linking.enabled !== false : false;\n\n const refContainer = React.useRef<NavigationContainerRef>(null);\n\n useBackButton(refContainer);\n useDocumentTitle(refContainer, documentTitle);\n\n const { getInitialState } = useLinking(refContainer, {\n enabled: isLinkingEnabled,\n prefixes: [],\n ...linking,\n });\n\n const [isResolved, initialState] = useThenable(getInitialState);\n\n React.useImperativeHandle(ref, () => refContainer.current);\n\n const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);\n\n const isReady = rest.initialState != null || !isLinkingEnabled || isResolved;\n\n const onReadyRef = React.useRef(onReady);\n\n React.useEffect(() => {\n onReadyRef.current = onReady;\n });\n\n React.useEffect(() => {\n if (isReady) {\n onReadyRef.current?.();\n }\n }, [isReady]);\n\n if (!isReady) {\n // This is temporary until we have Suspense for data-fetching\n // Then the fallback will be handled by a parent `Suspense` component\n return fallback as React.ReactElement;\n }\n\n return (\n <LinkingContext.Provider value={linkingContext}>\n <ThemeProvider value={theme}>\n <BaseNavigationContainer\n {...rest}\n initialState={\n rest.initialState == null ? initialState : rest.initialState\n }\n ref={refContainer}\n />\n </ThemeProvider>\n </LinkingContext.Provider>\n );\n});\n\nexport default NavigationContainer;\n"]}
\No newline at end of file