GT2/Ejectable/node_modules/@react-navigation/native/lib/module/useDocumentTitle.js.map

1 line
2.0 KiB
Plaintext
Raw Normal View History

2021-08-16 00:14:59 +00:00
{"version":3,"sources":["useDocumentTitle.tsx"],"names":["React","useDocumentTitle","ref","enabled","formatter","options","route","title","name","useEffect","navigation","current","getCurrentOptions","getCurrentRoute","document","addListener","e","data"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;;AAIA;AACA;AACA;AACA,eAAe,SAASC,gBAAT,CACbC,GADa,EAEb;AACEC,EAAAA,OAAO,GAAG,IADZ;AAEEC,EAAAA,SAAS,GAAG,CAACC,OAAD,EAAUC,KAAV;AAAA;;AAAA,6BAAoBD,OAApB,aAAoBA,OAApB,uBAAoBA,OAAO,CAAEE,KAA7B,2DAAsCD,KAAtC,aAAsCA,KAAtC,uBAAsCA,KAAK,CAAEE,IAA7C;AAAA;AAFd,IAG0B,EALb,EAMb;AACAR,EAAAA,KAAK,CAACS,SAAN,CAAgB,MAAM;AACpB,QAAI,CAACN,OAAL,EAAc;AACZ;AACD;;AAED,UAAMO,UAAU,GAAGR,GAAG,CAACS,OAAvB;;AAEA,QAAID,UAAJ,EAAgB;AACd,YAAMH,KAAK,GAAGH,SAAS,CACrBM,UAAU,CAACE,iBAAX,EADqB,EAErBF,UAAU,CAACG,eAAX,EAFqB,CAAvB;AAKAC,MAAAA,QAAQ,CAACP,KAAT,GAAiBA,KAAjB;AACD;;AAED,WAAOG,UAAP,aAAOA,UAAP,uBAAOA,UAAU,CAAEK,WAAZ,CAAwB,SAAxB,EAAoCC,CAAD,IAAO;AAC/C,YAAMT,KAAK,GAAGH,SAAS,CAACY,CAAC,CAACC,IAAF,CAAOZ,OAAR,EAAiBK,UAAjB,aAAiBA,UAAjB,uBAAiBA,UAAU,CAAEG,eAAZ,EAAjB,CAAvB;AAEAC,MAAAA,QAAQ,CAACP,KAAT,GAAiBA,KAAjB;AACD,KAJM,CAAP;AAKD,GArBD;AAsBD","sourcesContent":["import * as React from 'react';\nimport type { NavigationContainerRef } from '@react-navigation/core';\nimport type { DocumentTitleOptions } from './types';\n\n/**\n * Set the document title for the active screen\n */\nexport default function useDocumentTitle(\n ref: React.RefObject<NavigationContainerRef>,\n {\n enabled = true,\n formatter = (options, route) => options?.title ?? route?.name,\n }: DocumentTitleOptions = {}\n) {\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const navigation = ref.current;\n\n if (navigation) {\n const title = formatter(\n navigation.getCurrentOptions(),\n navigation.getCurrentRoute()\n );\n\n document.title = title;\n }\n\n return navigation?.addListener('options', (e) => {\n const title = formatter(e.data.options, navigation?.getCurrentRoute());\n\n document.title = title;\n });\n });\n}\n"]}