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

1 line
2.0 KiB
Plaintext

{"version":3,"sources":["useDocumentTitle.tsx"],"names":["useDocumentTitle","ref","enabled","formatter","options","route","title","name","React","useEffect","navigation","current","getCurrentOptions","getCurrentRoute","document","addListener","e","data"],"mappings":";;;;;;;AAAA;;;;;;AAIA;AACA;AACA;AACe,SAASA,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;AACAC,EAAAA,KAAK,CAACC,SAAN,CAAgB,MAAM;AACpB,QAAI,CAACP,OAAL,EAAc;AACZ;AACD;;AAED,UAAMQ,UAAU,GAAGT,GAAG,CAACU,OAAvB;;AAEA,QAAID,UAAJ,EAAgB;AACd,YAAMJ,KAAK,GAAGH,SAAS,CACrBO,UAAU,CAACE,iBAAX,EADqB,EAErBF,UAAU,CAACG,eAAX,EAFqB,CAAvB;AAKAC,MAAAA,QAAQ,CAACR,KAAT,GAAiBA,KAAjB;AACD;;AAED,WAAOI,UAAP,aAAOA,UAAP,uBAAOA,UAAU,CAAEK,WAAZ,CAAwB,SAAxB,EAAoCC,CAAD,IAAO;AAC/C,YAAMV,KAAK,GAAGH,SAAS,CAACa,CAAC,CAACC,IAAF,CAAOb,OAAR,EAAiBM,UAAjB,aAAiBA,UAAjB,uBAAiBA,UAAU,CAAEG,eAAZ,EAAjB,CAAvB;AAEAC,MAAAA,QAAQ,CAACR,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"]}