UNPKG

5.34 kBSource Map (JSON)View Raw
1{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","target","i","arguments","length","source","apply","ContextPressable","createContext","pressed","hovered","exports","MotionPressable","props","onPressIn","onPressOut","onMouseEnter","onMouseLeave","children","rest","state","setState","useState","update","useCallback","cur","createElement","Pressable","e","undefined","Platform","OS","Provider","value"],"sources":["MotionPressable.tsx"],"sourcesContent":["import React, { createContext, useCallback, useState } from 'react';\nimport { Platform, Pressable, PressableProps } from 'react-native';\n\nexport const ContextPressable = createContext({ pressed: false, hovered: false });\n\nexport function MotionPressable(props: PressableProps) {\n // @ts-ignore Web props cause errors\n const { onPressIn, onPressOut, onMouseEnter, onMouseLeave, children, ...rest } = props;\n\n const [state, setState] = useState({ pressed: false, hovered: false });\n\n const update = useCallback((pressed: boolean, hovered: boolean) => {\n setState((cur) => ({\n pressed: pressed ?? cur.pressed,\n hovered: hovered ?? cur.hovered,\n }));\n }, []);\n\n return (\n <Pressable\n onPressIn={(e) => {\n update(true, undefined);\n onPressIn?.(e);\n }}\n onPressOut={(e) => {\n update(false, undefined);\n onPressOut?.(e);\n }}\n // @ts-ignore\n onMouseEnter={\n Platform.OS === 'web'\n ? (e) => {\n update(undefined, true);\n onMouseEnter?.(e);\n }\n : undefined\n }\n // @ts-ignore\n onMouseLeave={\n Platform.OS === 'web'\n ? (e) => {\n update(undefined, false);\n onMouseLeave?.(e);\n }\n : undefined\n }\n {...rest}\n >\n <ContextPressable.Provider value={state}>{children}</ContextPressable.Provider>\n </Pressable>\n );\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAmE,SAAAE,yBAAAC,W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