{"version":3,"sources":["GestureButtons.tsx"],"names":["RawButton","GestureHandlerButton","shouldCancelWhenOutside","shouldActivateOnStart","BaseButton","React","Component","constructor","props","nativeEvent","state","oldState","pointerInside","active","State","ACTIVE","lastActive","onActiveStateChange","CANCELLED","onPress","e","onHandlerStateChange","handleEvent","onGestureEvent","render","rippleColor","rest","AnimatedBaseButton","Animated","createAnimatedComponent","btnStyles","StyleSheet","create","underlay","position","left","right","bottom","top","RectButton","Platform","OS","opacity","setValue","activeOpacity","Value","children","style","resolvedStyle","flatten","backgroundColor","underlayColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","BorderlessButton","borderless"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AASA;;AACA;;AACA;;;;;;;;;;;;AAkCO,MAAMA,SAAS,GAAG,kCAAoBC,6BAApB,EAA0C;AACjEC,EAAAA,uBAAuB,EAAE,KADwC;AAEjEC,EAAAA,qBAAqB,EAAE;AAF0C,CAA1C,CAAlB;;;AAKA,MAAMC,UAAN,SAAyBC,KAAK,CAACC,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,KAAKI,aAAMC,MAAhD;;AAEA,UAAIF,MAAM,KAAK,KAAKG,UAAhB,IAA8B,KAAKR,KAAL,CAAWS,mBAA7C,EAAkE;AAChE,aAAKT,KAAL,CAAWS,mBAAX,CAA+BJ,MAA/B;AACD;;AAED,UACEF,QAAQ,KAAKG,aAAMC,MAAnB,IACAL,KAAK,KAAKI,aAAMI,SADhB,IAEA,KAAKF,UAFL,IAGA,KAAKR,KAAL,CAAWW,OAJb,EAKE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ArC,CAAsE;AAQ3EC,EAAAA,WAAW,CAACC,KAAD,EAA+B;AACxC,UAAMA,KAAN;;AADwC;;AAAA,iDAKXK,MAAD,IAAqB;AAAA;;AACjD,UAAI2B,sBAASC,EAAT,KAAgB,SAApB,EAA+B;AAC7B,aAAKC,OAAL,CAAaC,QAAb,CAAsB9B,MAAM,GAAG,KAAKL,KAAL,CAAWoC,aAAd,GAA+B,CAA3D;AACD;;AAED,qDAAKpC,KAAL,EAAWS,mBAAX,qGAAiCJ,MAAjC;AACD,KAXyC;;AAExC,SAAK6B,OAAL,GAAe,IAAId,sBAASiB,KAAb,CAAmB,CAAnB,CAAf;AACD;;AAUDrB,EAAAA,MAAM,GAAG;AACP,UAAM;AAAEsB,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmB,SAAGrB;AAAtB,QAA+B,KAAKlB,KAA1C;AAEA,wBACE,oBAAC,kBAAD,eACMkB,IADN;AAEE,MAAA,mBAAmB,EAAE,KAAKT,mBAF5B;AAGE,MAAA,KAAK,EAAE,CAAC8B,KAAD,EAAQP,sBAASC,EAAT,KAAgB,KAAhB,IAAyB;AAAEC,QAAAA,OAAO,EAAE,KAAKA;AAAhB,OAAjC;AAHT,QAIGI,QAJH,CADF;AAQD;;AAhC0E;;;;gBAAhEW,gB,kBACW;AACpBb,EAAAA,aAAa,EAAE,GADK;AAEpBc,EAAAA,UAAU,EAAE;AAFQ,C","sourcesContent":["import * as React from 'react';\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"]}