UNPKG

repoweaver

Version:

A GitHub App that skillfully weaves multiple templates together to create and update repositories with intelligent merge strategies

1 lines 11.1 kB
{"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\";\nvar _getStateFromParams = function getStateFromParams(params) {\n if (params != null && params.state) {\n return params.state;\n }\n if (params != null && 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(_ref) {\n var _options$getPathFromS;\n var screen = _ref.screen,\n params = _ref.params,\n href = _ref.href,\n action = _ref.action;\n var root = React.useContext(NavigationContainerRefContext);\n var navigation = React.useContext(NavigationHelpersContext);\n var _React$useContext = React.useContext(LinkingContext),\n options = _React$useContext.options;\n var onPress = function onPress(e) {\n var shouldHandle = false;\n if (Platform.OS !== 'web' || !e) {\n e == null ? void 0 : e.preventDefault == null ? void 0 : e.preventDefault();\n shouldHandle = true;\n } else {\n var hasModifierKey = 'metaKey' in e && e.metaKey || 'altKey' in e && e.altKey || 'ctrlKey' in e && e.ctrlKey || 'shiftKey' in e && e.shiftKey;\n var isLeftClick = 'button' in e ? e.button == null || e.button === 0 : true;\n var isSelfTarget = e.currentTarget && 'target' in e.currentTarget ? [undefined, null, '', 'self'].includes(e.currentTarget.target) : true;\n if (!hasModifierKey && isLeftClick && isSelfTarget) {\n e.preventDefault == null ? void 0 : 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 == null ? void 0 : navigation.navigate(screen, params);\n }\n }\n };\n var getPathFromStateHelper = (_options$getPathFromS = options == null ? void 0 : options.getPathFromState) != null ? _options$getPathFromS : getPathFromState;\n return {\n href: href != null ? href : Platform.OS === 'web' && screen != null ? getPathFromStateHelper({\n routes: [{\n name: screen,\n params: params,\n state: _getStateFromParams(params)\n }]\n }, options == null ? void 0 : options.config) : undefined,\n role: 'link',\n onPress: onPress\n };\n}","map":{"version":3,"names":["getPathFromState","NavigationContainerRefContext","NavigationHelpersContext","React","Platform","LinkingContext","getStateFromParams","params","state","screen","routes","name","undefined","useLinkProps","_ref","_options$getPathFromS","href","action","root","useContext","navigation","_React$useContext","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 const,\n onPress,\n };\n}\n"],"mappings":";;AAAA,SACEA,gBAAgB,EAEhBC,6BAA6B,EAC7BC,wBAAwB,QAGnB,wBAAwB;AAE/B,OAAO,KAAKC,KAAK,MAAM,OAAO;AAAA,OAAAC,QAAA;AAG9B,SAASC,cAAc;AAqBvB,IAAMC,mBAAkB,GACtB,SADIA,kBAAkBA,CACtBC,MAAwD,EACQ;EAChE,IAAIA,MAAM,YAANA,MAAM,CAAEC,KAAK,EAAE;IACjB,OAAOD,MAAM,CAACC,KAAK;EACrB;EAEA,IAAID,MAAM,YAANA,MAAM,CAAEE,MAAM,EAAE;IAClB,OAAO;MACLC,MAAM,EAAE,CACN;QACEC,IAAI,EAAEJ,MAAM,CAACE,MAAM;QACnBF,MAAM,EAAEA,MAAM,CAACA,MAAM;QAErBC,KAAK,EAAED,MAAM,CAACE,MAAM,GAChBH,mBAAkB,CAChBC,MAAM,CAACA,MAGT,CAAC,GACDK;MACN,CAAC;IAEL,CAAC;EACH;EAEA,OAAOA,SAAS;AAClB,CAAC;AAUD,OAAO,SAASC,YAAYA,CAAAC,IAAA,EAKH;EAAA,IAAAC,qBAAA;EAAA,IAJvBN,MAAM,GAAAK,IAAA,CAANL,MAAM;IACNF,MAAM,GAAAO,IAAA,CAANP,MAAM;IACNS,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,MAAA,GAAAH,IAAA,CAAAG,MAAA;EAEA,IAAMC,IAAI,GAAGf,KAAK,CAACgB,UAAU,CAAClB,6BAA6B,CAAC;EAC5D,IAAMmB,UAAU,GAAGjB,KAAK,CAACgB,UAAU,CAACjB,wBAAwB,CA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