repoweaver
Version:
A GitHub App that skillfully weaves multiple templates together to create and update repositories with intelligent merge strategies
1 lines • 10.2 kB
JSON
{"ast":null,"code":"\"use strict\";\n\nimport { getPathFromState, NavigationContainerRefContext, NavigationHelpersContext } from '@react-navigation/core';\nimport * as React from 'react';\nimport Platform from \"react-native-web/dist/exports/Platform\";\nimport { LinkingContext } from \"./LinkingContext.js\";\nconst getStateFromParams = params => {\n if (params?.state) {\n return params.state;\n }\n if (params?.screen) {\n return {\n routes: [{\n name: params.screen,\n params: params.params,\n state: params.screen ? getStateFromParams(params.params) : undefined\n }]\n };\n }\n return undefined;\n};\nexport function useLinkProps({\n screen,\n params,\n href,\n action\n}) {\n const root = React.useContext(NavigationContainerRefContext);\n const navigation = React.useContext(NavigationHelpersContext);\n const {\n options\n } = React.useContext(LinkingContext);\n const onPress = e => {\n let shouldHandle = false;\n if (Platform.OS !== 'web' || !e) {\n e?.preventDefault?.();\n shouldHandle = true;\n } else {\n const hasModifierKey = 'metaKey' in e && e.metaKey || 'altKey' in e && e.altKey || 'ctrlKey' in e && e.ctrlKey || 'shiftKey' in e && e.shiftKey;\n const isLeftClick = 'button' in e ? e.button == null || e.button === 0 : true;\n const isSelfTarget = e.currentTarget && 'target' in e.currentTarget ? [undefined, null, '', 'self'].includes(e.currentTarget.target) : true;\n if (!hasModifierKey && isLeftClick && isSelfTarget) {\n e.preventDefault?.();\n shouldHandle = true;\n }\n }\n if (shouldHandle) {\n if (action) {\n if (navigation) {\n navigation.dispatch(action);\n } else if (root) {\n root.dispatch(action);\n } else {\n throw new Error(\"Couldn't find a navigation object. Is your component inside NavigationContainer?\");\n }\n } else {\n navigation?.navigate(screen, params);\n }\n }\n };\n const getPathFromStateHelper = options?.getPathFromState ?? getPathFromState;\n return {\n href: href ?? (Platform.OS === 'web' && screen != null ? getPathFromStateHelper({\n routes: [{\n name: screen,\n params: params,\n state: getStateFromParams(params)\n }]\n }, options?.config) : undefined),\n role: 'link',\n onPress\n };\n}","map":{"version":3,"names":["getPathFromState","NavigationContainerRefContext","NavigationHelpersContext","React","Platform","LinkingContext","getStateFromParams","params","state","screen","routes","name","undefined","useLinkProps","href","action","root","useContext","navigation","options","onPress","e","shouldHandle","OS","preventDefault","hasModifierKey","metaKey","altKey","ctrlKey","shiftKey","isLeftClick","button","isSelfTarget","currentTarget","includes","target","dispatch","Error","navigate","getPathFromStateHelper","config","role"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/@react-navigation/native/src/useLinkProps.tsx"],"sourcesContent":["import {\n getPathFromState,\n type NavigationAction,\n NavigationContainerRefContext,\n NavigationHelpersContext,\n type NavigatorScreenParams,\n type ParamListBase,\n} from '@react-navigation/core';\nimport type { NavigationState, PartialState } from '@react-navigation/routers';\nimport * as React from 'react';\nimport { type GestureResponderEvent, Platform } from 'react-native';\n\nimport { LinkingContext } from './LinkingContext';\n\nexport type LinkProps<\n ParamList extends ReactNavigation.RootParamList,\n RouteName extends keyof ParamList = keyof ParamList,\n> =\n | ({\n href?: string;\n action?: NavigationAction;\n } & (RouteName extends unknown\n ? undefined extends ParamList[RouteName]\n ? { screen: RouteName; params?: ParamList[RouteName] }\n : { screen: RouteName; params: ParamList[RouteName] }\n : never))\n | {\n href?: string;\n action: NavigationAction;\n screen?: undefined;\n params?: undefined;\n };\n\nconst getStateFromParams = (\n params: NavigatorScreenParams<ParamListBase> | undefined\n): PartialState<NavigationState> | NavigationState | undefined => {\n if (params?.state) {\n return params.state;\n }\n\n if (params?.screen) {\n return {\n routes: [\n {\n name: params.screen,\n params: params.params,\n // @ts-expect-error this is fine 🔥\n state: params.screen\n ? getStateFromParams(\n params.params as\n | NavigatorScreenParams<ParamListBase>\n | undefined\n )\n : undefined,\n },\n ],\n };\n }\n\n return undefined;\n};\n\n/**\n * Hook to get props for an anchor tag so it can work with in page navigation.\n *\n * @param props.screen Name of the screen to navigate to (e.g. `'Feeds'`).\n * @param props.params Params to pass to the screen to navigate to (e.g. `{ sort: 'hot' }`).\n * @param props.href Optional absolute path to use for the href (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 */\nexport function useLinkProps<ParamList extends ReactNavigation.RootParamList>({\n screen,\n params,\n href,\n action,\n}: LinkProps<ParamList>) {\n const root = React.useContext(NavigationContainerRefContext);\n const navigation = React.useContext(NavigationHelpersContext);\n const { options } = React.useContext(LinkingContext);\n\n const onPress = (\n e?: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n let shouldHandle = false;\n\n if (Platform.OS !== 'web' || !e) {\n e?.preventDefault?.();\n shouldHandle = true;\n } else {\n // ignore clicks with modifier keys\n const hasModifierKey =\n ('metaKey' in e && e.metaKey) ||\n ('altKey' in e && e.altKey) ||\n ('ctrlKey' in e && e.ctrlKey) ||\n ('shiftKey' in e && e.shiftKey);\n\n // only handle left clicks\n const isLeftClick =\n 'button' in e ? e.button == null || e.button === 0 : true;\n\n // let browser handle \"target=_blank\" etc.\n const isSelfTarget =\n e.currentTarget && 'target' in e.currentTarget\n ? [undefined, null, '', 'self'].includes(e.currentTarget.target)\n : true;\n\n if (!hasModifierKey && isLeftClick && isSelfTarget) {\n e.preventDefault?.();\n shouldHandle = true;\n }\n }\n\n if (shouldHandle) {\n if (action) {\n if (navigation) {\n navigation.dispatch(action);\n } else if (root) {\n root.dispatch(action);\n } else {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n } else {\n // @ts-expect-error This is already type-checked by the prop types\n navigation?.navigate(screen, params);\n }\n }\n };\n\n const getPathFromStateHelper = options?.getPathFromState ?? getPathFromState;\n\n return {\n href:\n href ??\n (Platform.OS === 'web' && screen != null\n ? getPathFromStateHelper(\n {\n routes: [\n {\n // @ts-expect-error this is fine 🔥\n name: screen,\n // @ts-expect-error this is fine 🔥\n params: params,\n // @ts-expect-error this is fine 🔥\n state: getStateFromParams(params),\n },\n ],\n },\n options?.config\n )\n : undefined),\n role: 'link' as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