1 line
2.2 KiB
Plaintext
1 line
2.2 KiB
Plaintext
|
{"version":3,"sources":["Link.tsx"],"names":["Link","to","action","rest","props","onPress","e","React","createElement","Text","Platform","select","web","onClick","default"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,IAAT,CAAc;AAAEC,EAAAA,EAAF;AAAMC,EAAAA,MAAN;AAAc,KAAGC;AAAjB,CAAd,EAA8C;AAC3D,QAAMC,KAAK,GAAG,2BAAa;AAAEH,IAAAA,EAAF;AAAMC,IAAAA;AAAN,GAAb,CAAd;;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,sBAAOC,KAAK,CAACC,aAAN,CAAoBC,iBAApB,EAA0B,EAC/B,GAAGL,KAD4B;AAE/B,OAAGD,IAF4B;AAG/B,OAAGO,sBAASC,MAAT,CAAgB;AACjBC,MAAAA,GAAG,EAAE;AAAEC,QAAAA,OAAO,EAAER;AAAX,OADY;AAEjBS,MAAAA,OAAO,EAAE;AAAET,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"]}
|