UNPKG

2.31 kBSource Map (JSON)View Raw
1{"version":3,"sources":["Link.tsx"],"names":["React","Text","Platform","useLinkProps","Link","to","action","rest","props","onPress","e","createElement","select","web","onClick","default"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAiDC,QAAjD,QAAiE,cAAjE;AAEA,OAAOC,YAAP,MAAyB,gBAAzB;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,IAAT,CAAc;AAAEC,EAAAA,EAAF;AAAMC,EAAAA,MAAN;AAAc,KAAGC;AAAjB,CAAd,EAA8C;AAC3D,QAAMC,KAAK,GAAGL,YAAY,CAAC;AAAEE,IAAAA,EAAF;AAAMC,IAAAA;AAAN,GAAD,CAA1B;;AAEA,QAAMG,OAAO,GACXC,CADc,IAEX;AACH,QAAI,aAAaH,IAAjB,EAAuB;AAAA;;AACrB,uBAAAA,IAAI,CAACE,OAAL,qEAAAF,IAAI,EAAWG,CAAX,CAAJ;AACD;;AAEDF,IAAAA,KAAK,CAACC,OAAN,CAAcC,CAAd;AACD,GARD;;AAUA,sBAAOV,KAAK,CAACW,aAAN,CAAoBV,IAApB,EAA0B,EAC/B,GAAGO,KAD4B;AAE/B,OAAGD,IAF4B;AAG/B,OAAGL,QAAQ,CAACU,MAAT,CAAgB;AACjBC,MAAAA,GAAG,EAAE;AAAEC,QAAAA,OAAO,EAAEL;AAAX,OADY;AAEjBM,MAAAA,OAAO,EAAE;AAAEN,QAAAA;AAAF;AAFQ,KAAhB;AAH4B,GAA1B,CAAP;AAQD","sourcesContent":["import * as React from 'react';\nimport { Text, TextProps, GestureResponderEvent, Platform } from 'react-native';\nimport type { NavigationAction } from '@react-navigation/core';\nimport useLinkProps from './useLinkProps';\n\ntype Props = {\n to: string;\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({ to, action, ...rest }: Props) {\n const props = useLinkProps({ 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"]}
\No newline at end of file