UNPKG

2.45 kBSource Map (JSON)View Raw
1{"version":3,"names":["React","Platform","Text","useLinkProps","Link","to","action","rest","props","onPress","e","createElement","select","web","onClick","default"],"sources":["Link.tsx"],"sourcesContent":["import type { NavigationAction } from '@react-navigation/core';\nimport * as React from 'react';\nimport { GestureResponderEvent, Platform, Text, TextProps } from 'react-native';\n\nimport useLinkProps from './useLinkProps';\nimport type { To } from './useLinkTo';\n\ntype Props<ParamList extends ReactNavigation.RootParamList> = {\n to: To<ParamList>;\n action?: NavigationAction;\n target?: string;\n onPress?: (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => void;\n} & (TextProps & { children: React.ReactNode });\n\n/**\n * Component to render link to another screen using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.to Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.\n * @param props.children Child elements to render the content.\n */\nexport default function Link<ParamList extends ReactNavigation.RootParamList>({\n to,\n action,\n ...rest\n}: Props<ParamList>) {\n const props = useLinkProps<ParamList>({ to, action });\n\n const onPress = (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n if ('onPress' in rest) {\n rest.onPress?.(e);\n }\n\n props.onPress(e);\n };\n\n return React.createElement(Text, {\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n });\n}\n"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAAgCC,QAAhC,EAA0CC,IAA1C,QAAiE,cAAjE;AAEA,OAAOC,YAAP,MAAyB,gBAAzB;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,IAAT,OAIM;EAAA,IAJyD;IAC5EC,EAD4E;IAE5EC,MAF4E;IAG5E,GAAGC;EAHyE,CAIzD;EACnB,MAAMC,KAAK,GAAGL,YAAY,CAAY;IAAEE,EAAF;IAAMC;EAAN,CAAZ,CAA1B;;EAEA,MAAMG,OAAO,GACXC,CADc,IAEX;IACH,IAAI,aAAaH,IAAjB,EAAuB;MAAA;;MACrB,iBAAAA,IAAI,CAACE,OAAL,qEAAAF,IAAI,EAAWG,CAAX,CAAJ;IACD;;IAEDF,KAAK,CAACC,OAAN,CAAcC,CAAd;EACD,CARD;;EAUA,oBAAOV,KAAK,CAACW,aAAN,CAAoBT,IAApB,EAA0B,EAC/B,GAAGM,KAD4B;IAE/B,GAAGD,IAF4B;IAG/B,GAAGN,QAAQ,CAACW,MAAT,CAAgB;MACjBC,GAAG,EAAE;QAAEC,OAAO,EAAEL;MAAX,CADY;MAEjBM,OAAO,EAAE;QAAEN;MAAF;IAFQ,CAAhB;EAH4B,CAA1B,CAAP;AAQD"}
\No newline at end of file