{"version":3,"sources":["GestureButtons.tsx"],"names":["React","Animated","Platform","processColor","StyleSheet","createNativeWrapper","GestureHandlerButton","State","RawButton","shouldCancelWhenOutside","shouldActivateOnStart","BaseButton","Component","constructor","props","nativeEvent","state","oldState","pointerInside","active","ACTIVE","lastActive","onActiveStateChange","CANCELLED","onPress","e","onHandlerStateChange","handleEvent","onGestureEvent","render","rippleColor","rest","AnimatedBaseButton","createAnimatedComponent","btnStyles","create","underlay","position","left","right","bottom","top","RectButton","OS","opacity","setValue","activeOpacity","Value","children","style","resolvedStyle","flatten","backgroundColor","underlayColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","BorderlessButton","borderless","default","PureNativeButton"],"mappings":";;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,QAFF,EAGEC,YAHF,EAIEC,UAJF,QAOO,cAPP;AASA,OAAOC,mBAAP,MAAgC,iCAAhC;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AACA,SAASC,KAAT,QAAsB,UAAtB;AAkCA,OAAO,MAAMC,SAAS,GAAGH,mBAAmB,CAACC,oBAAD,EAAuB;AACjEG,EAAAA,uBAAuB,EAAE,KADwC;AAEjEC,EAAAA,qBAAqB,EAAE;AAF0C,CAAvB,CAArC;AAKP,OAAO,MAAMC,UAAN,SAAyBX,KAAK,CAACY,SAA/B,CAA0D;AAG/DC,EAAAA,WAAW,CAACC,KAAD,EAAyB;AAClC,UAAMA,KAAN;;AADkC;;AAAA,yCAKd,CAAC;AACrBC,MAAAA;AADqB,KAAD,KAE0C;AAC9D,YAAM;AAAEC,QAAAA,KAAF;AAASC,QAAAA,QAAT;AAAmBC,QAAAA;AAAnB,UAAqCH,WAA3C;AACA,YAAMI,MAAM,GAAGD,aAAa,IAAIF,KAAK,KAAKT,KAAK,CAACa,MAAhD;;AAEA,UAAID,MAAM,KAAK,KAAKE,UAAhB,IAA8B,KAAKP,KAAL,CAAWQ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nimport {\n Animated,\n Platform,\n processColor,\n StyleSheet,\n StyleProp,\n ViewStyle,\n} from 'react-native';\n\nimport createNativeWrapper from '../handlers/createNativeWrapper';\nimport GestureHandlerButton from './GestureHandlerButton';\nimport { State } from '../State';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlers';\nimport {\n NativeViewGestureHandlerPayload,\n NativeViewGestureHandlerProps,\n} from '../handlers/NativeViewGestureHandler';\n\nexport interface RawButtonProps extends NativeViewGestureHandlerProps {\n exclusive?: boolean;\n // TODO: we should transform props in `createNativeWrapper`\n rippleColor?: any; // it was present in BaseButtonProps before but is used here in code\n}\n\nexport interface BaseButtonProps extends RawButtonProps {\n onPress?: (pointerInside: boolean) => void;\n onActiveStateChange?: (active: boolean) => void;\n style?: StyleProp;\n testID?: string;\n}\n\nexport interface RectButtonProps extends BaseButtonProps {\n underlayColor?: string;\n activeOpacity?: number;\n}\n\nexport interface BorderlessButtonProps extends BaseButtonProps {\n borderless?: boolean;\n activeOpacity?: number;\n}\n\nexport const RawButton = createNativeWrapper(GestureHandlerButton, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: false,\n});\n\nexport class BaseButton extends React.Component {\n private lastActive: boolean;\n\n constructor(props: BaseButtonProps) {\n super(props);\n this.lastActive = false;\n }\n\n private handleEvent = ({\n nativeEvent,\n }: HandlerStateChangeEvent) => {\n const { state, oldState, pointerInside } = nativeEvent;\n const active = pointerInside && state === State.ACTIVE;\n\n if (active !== this.lastActive && this.props.onActiveStateChange) {\n this.props.onActiveStateChange(active);\n }\n\n if (\n oldState === State.ACTIVE &&\n state !== State.CANCELLED &&\n this.lastActive &&\n this.props.onPress\n ) {\n this.props.onPress(active);\n }\n\n this.lastActive = active;\n };\n\n // Normally, the parent would execute it's handler first,\n // then forward the event to listeners. However, here our handler\n // is virtually only forwarding events to listeners, so we reverse the order\n // to keep the proper order of the callbacks (from \"raw\" ones to \"processed\").\n private onHandlerStateChange = (\n e: HandlerStateChangeEvent\n ) => {\n this.props.onHandlerStateChange?.(e);\n this.handleEvent(e);\n };\n\n private onGestureEvent = (\n e: GestureEvent\n ) => {\n this.props.onGestureEvent?.(e);\n this.handleEvent(\n e as HandlerStateChangeEvent\n ); // TODO: maybe it is not correct\n };\n\n render() {\n const { rippleColor, ...rest } = this.props;\n\n return (\n \n );\n }\n}\n\nconst AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);\n\nconst btnStyles = StyleSheet.create({\n underlay: {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: 0,\n top: 0,\n },\n});\n\nexport class RectButton extends React.Component {\n static defaultProps = {\n activeOpacity: 0.105,\n underlayColor: 'black',\n };\n\n private opacity: Animated.Value;\n\n constructor(props: RectButtonProps) {\n super(props);\n this.opacity = new Animated.Value(0);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 0);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, ...rest } = this.props;\n\n const resolvedStyle = StyleSheet.flatten(style ?? {});\n\n return (\n \n \n {children}\n \n );\n }\n}\n\nexport class BorderlessButton extends React.Component {\n static defaultProps = {\n activeOpacity: 0.3,\n borderless: true,\n };\n\n private opacity: Animated.Value;\n\n constructor(props: BorderlessButtonProps) {\n super(props);\n this.opacity = new Animated.Value(1);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 1);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, ...rest } = this.props;\n\n return (\n \n {children}\n \n );\n }\n}\n\nexport { default as PureNativeButton } from './GestureHandlerButton';\n"]}