{"ast":null,"code":"import _objectWithoutProperties from \"@babel/runtime/helpers/objectWithoutProperties\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/inherits\";\nimport _possibleConstructorReturn from \"@babel/runtime/helpers/possibleConstructorReturn\";\nimport _getPrototypeOf from \"@babel/runtime/helpers/getPrototypeOf\";\nvar _excluded = [\"rippleColor\"],\n _excluded2 = [\"children\", \"style\"],\n _excluded3 = [\"children\", \"style\"];\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}\nfunction _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}\nimport * as React from 'react';\nimport Animated from \"react-native-web/dist/exports/Animated\";\nimport Platform from \"react-native-web/dist/exports/Platform\";\nimport processColor from \"react-native-web/dist/exports/processColor\";\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport createNativeWrapper from \"../handlers/createNativeWrapper\";\nimport GestureHandlerButton from \"./GestureHandlerButton\";\nimport { State } from \"../State\";\nexport var RawButton = createNativeWrapper(GestureHandlerButton, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: false\n});\nexport var BaseButton = function (_React$Component) {\n _inherits(BaseButton, _React$Component);\n var _super = _createSuper(BaseButton);\n function BaseButton(props) {\n var _this;\n _classCallCheck(this, BaseButton);\n _this = _super.call(this, props);\n _defineProperty(_assertThisInitialized(_this), \"lastActive\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"longPressTimeout\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"longPressDetected\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"handleEvent\", function (_ref) {\n var nativeEvent = _ref.nativeEvent;\n var state = nativeEvent.state,\n oldState = nativeEvent.oldState,\n pointerInside = nativeEvent.pointerInside;\n var active = pointerInside && state === State.ACTIVE;\n if (active !== _this.lastActive && _this.props.onActiveStateChange) {\n _this.props.onActiveStateChange(active);\n }\n if (!_this.longPressDetected && oldState === State.ACTIVE && state !== State.CANCELLED && _this.lastActive && _this.props.onPress) {\n _this.props.onPress(active);\n }\n if (!_this.lastActive && state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) && pointerInside) {\n _this.longPressDetected = false;\n if (_this.props.onLongPress) {\n _this.longPressTimeout = setTimeout(_this.onLongPress, _this.props.delayLongPress);\n }\n } else if (state === State.ACTIVE && !pointerInside && _this.longPressTimeout !== undefined) {\n clearTimeout(_this.longPressTimeout);\n _this.longPressTimeout = undefined;\n } else if (_this.longPressTimeout !== undefined && (state === State.END || state === State.CANCELLED || state === State.FAILED)) {\n clearTimeout(_this.longPressTimeout);\n _this.longPressTimeout = undefined;\n }\n _this.lastActive = active;\n });\n _defineProperty(_assertThisInitialized(_this), \"onLongPress\", function () {\n var _this$props$onLongPre, _this$props;\n _this.longPressDetected = true;\n (_this$props$onLongPre = (_this$props = _this.props).onLongPress) === null || _this$props$onLongPre === void 0 ? void 0 : _this$props$onLongPre.call(_this$props);\n });\n _defineProperty(_assertThisInitialized(_this), \"onHandlerStateChange\", function (e) {\n var _this$props$onHandler, _this$props2;\n (_this$props$onHandler = (_this$props2 = _this.props).onHandlerStateChange) === null || _this$props$onHandler === void 0 ? void 0 : _this$props$onHandler.call(_this$props2, e);\n _this.handleEvent(e);\n });\n _defineProperty(_assertThisInitialized(_this), \"onGestureEvent\", function (e) {\n var _this$props$onGesture, _this$props3;\n (_this$props$onGesture = (_this$props3 = _this.props).onGestureEvent) === null || _this$props$onGesture === void 0 ? void 0 : _this$props$onGesture.call(_this$props3, e);\n _this.handleEvent(e);\n });\n _this.lastActive = false;\n _this.longPressDetected = false;\n return _this;\n }\n _createClass(BaseButton, [{\n key: \"render\",\n value: function render() {\n var _this$props6 = this.props,\n rippleColor = _this$props6.rippleColor,\n rest = _objectWithoutProperties(_this$props6, _excluded);\n return React.createElement(RawButton, _extends({\n rippleColor: processColor(rippleColor)\n }, rest, {\n onGestureEvent: this.onGestureEvent,\n onHandlerStateChange: this.onHandlerStateChange\n }));\n }\n }]);\n return BaseButton;\n}(React.Component);\n_defineProperty(BaseButton, \"defaultProps\", {\n delayLongPress: 600\n});\nvar AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);\nvar btnStyles = StyleSheet.create({\n underlay: {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: 0,\n top: 0\n }\n});\nexport var RectButton = function (_React$Component2) {\n _inherits(RectButton, _React$Component2);\n var _super2 = _createSuper(RectButton);\n function RectButton(props) {\n var _this2;\n _classCallCheck(this, RectButton);\n _this2 = _super2.call(this, props);\n _defineProperty(_assertThisInitialized(_this2), \"opacity\", void 0);\n _defineProperty(_assertThisInitialized(_this2), \"onActiveStateChange\", function (active) {\n var _this$props$onActiveS, _this$props4;\n if (Platform.OS !== 'android') {\n _this2.opacity.setValue(active ? _this2.props.activeOpacity : 0);\n }\n (_this$props$onActiveS = (_this$props4 = _this2.props).onActiveStateChange) === null || _this$props$onActiveS === void 0 ? void 0 : _this$props$onActiveS.call(_this$props4, active);\n });\n _this2.opacity = new Animated.Value(0);\n return _this2;\n }\n _createClass(RectButton, [{\n key: \"render\",\n value: function render() {\n var _this$props7 = this.props,\n children = _this$props7.children,\n style = _this$props7.style,\n rest = _objectWithoutProperties(_this$props7, _excluded2);\n var resolvedStyle = StyleSheet.flatten(style !== null && style !== void 0 ? style : {});\n return React.createElement(BaseButton, _extends({}, rest, {\n style: resolvedStyle,\n onActiveStateChange: this.onActiveStateChange\n }), React.createElement(Animated.View, {\n style: [btnStyles.underlay, {\n opacity: this.opacity,\n backgroundColor: this.props.underlayColor,\n borderRadius: resolvedStyle.borderRadius,\n borderTopLeftRadius: resolvedStyle.borderTopLeftRadius,\n borderTopRightRadius: resolvedStyle.borderTopRightRadius,\n borderBottomLeftRadius: resolvedStyle.borderBottomLeftRadius,\n borderBottomRightRadius: resolvedStyle.borderBottomRightRadius\n }]\n }), children);\n }\n }]);\n return RectButton;\n}(React.Component);\n_defineProperty(RectButton, \"defaultProps\", {\n activeOpacity: 0.105,\n underlayColor: 'black'\n});\nexport var BorderlessButton = function (_React$Component3) {\n _inherits(BorderlessButton, _React$Component3);\n var _super3 = _createSuper(BorderlessButton);\n function BorderlessButton(props) {\n var _this3;\n _classCallCheck(this, BorderlessButton);\n _this3 = _super3.call(this, props);\n _defineProperty(_assertThisInitialized(_this3), \"opacity\", void 0);\n _defineProperty(_assertThisInitialized(_this3), \"onActiveStateChange\", function (active) {\n var _this$props$onActiveS2, _this$props5;\n if (Platform.OS !== 'android') {\n _this3.opacity.setValue(active ? _this3.props.activeOpacity : 1);\n }\n (_this$props$onActiveS2 = (_this$props5 = _this3.props).onActiveStateChange) === null || _this$props$onActiveS2 === void 0 ? void 0 : _this$props$onActiveS2.call(_this$props5, active);\n });\n _this3.opacity = new Animated.Value(1);\n return _this3;\n }\n _createClass(BorderlessButton, [{\n key: \"render\",\n value: function render() {\n var _this$props8 = this.props,\n children = _this$props8.children,\n style = _this$props8.style,\n rest = _objectWithoutProperties(_this$props8, _excluded3);\n return React.createElement(AnimatedBaseButton, _extends({}, rest, {\n onActiveStateChange: this.onActiveStateChange,\n style: [style, Platform.OS === 'ios' && {\n opacity: this.opacity\n }]\n }), children);\n }\n }]);\n return BorderlessButton;\n}(React.Component);\n_defineProperty(BorderlessButton, \"defaultProps\", {\n activeOpacity: 0.3,\n borderless: true\n});\nexport { default as PureNativeButton } from \"./GestureHandlerButton\";","map":{"version":3,"sources":["GestureButtons.tsx"],"names":["React","createNativeWrapper","GestureHandlerButton","State","RawButton","shouldCancelWhenOutside","shouldActivateOnStart","BaseButton","Component","delayLongPress","constructor","props","lastActive","longPressDetected","nativeEvent","state","oldState","pointerInside","active","ACTIVE","onActiveStateChange","CANCELLED","onPress","Platform","OS","BEGAN","onLongPress","longPressTimeout","setTimeout","undefined","clearTimeout","END","FAILED","e","onHandlerStateChange","handleEvent","onGestureEvent","render","rippleColor","rest","processColor","AnimatedBaseButton","Animated","createAnimatedComponent","btnStyles","create","underlay","position","left","right","bottom","top","RectButton","activeOpacity","underlayColor","opacity","Value","setValue","children","style","resolvedStyle","StyleSheet","flatten","backgroundColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","BorderlessButton","borderless","default","PureNativeButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAAA;AAAA;AAAA;AAAA;AAUA,OAAOC,mBAAP;AACA,OAAOC,oBAAP;AACA,SAASC,KAAT;AA2GA,OAAO,IAAMC,SAAS,GAAGH,mBAAmB,CAACC,oBAAD,EAAuB;EACjEG,uBAAuB,EAAE,KADwC;EAEjEC,qBAAqB,EAAE;AAF0C,CAAvB,CAArC;AAKP,WAAaC,UAAN;EAAA;EAAA;EASLG,oBAAYC,KAAD,EAAyB;IAAA;IAAA;IAClC,0BAAMA,KAAN;IADkC,eAAA,gCAAA,YA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AAE,CAACuC,KAAD,EAAQpC,QAAQ,CAACC,EAATD,KAAgB,KAAhBA,IAAyB;UAAEgC,OAAO,EAAE,IAAA,CAAKA;QAAhB,CAAjC;MAHT,CAAA,CAAA,EAIGG,QAJH,CADF;IAQD;EAAA;EAAA;AAAA,EAhCmC1D,KAAK,CAACQ,SAArC;gBAAM6D,gB,kBACW;EACpBhB,aAAa,EAAE,GADK;EAEpBiB,UAAU,EAAE;AAFQ,C;AAkCxB,SAASC,OAAO,IAAIC,gBAApB","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/gestureHandlerCommon';\nimport {\n NativeViewGestureHandlerPayload,\n NativeViewGestureHandlerProps,\n} from '../handlers/NativeViewGestureHandler';\n\nexport interface RawButtonProps extends NativeViewGestureHandlerProps {\n /**\n * Defines if more than one button could be pressed simultaneously. By default\n * set true.\n */\n exclusive?: boolean;\n // TODO: we should transform props in `createNativeWrapper`\n\n /**\n * Android only.\n *\n * Defines color of native ripple animation used since API level 21.\n */\n rippleColor?: any; // it was present in BaseButtonProps before but is used here in code\n\n /**\n * Android only.\n *\n * Defines radius of native ripple animation used since API level 21.\n */\n rippleRadius?: number | null;\n\n /**\n * Android only.\n *\n * Set this to true if you want the ripple animation to render outside the view bounds.\n */\n borderless?: boolean;\n\n /**\n * Android only.\n *\n * Defines whether the ripple animation should be drawn on the foreground of the view.\n */\n foreground?: boolean;\n\n /**\n * Android only.\n *\n * Set this to true if you don't want the system to play sound when the button is pressed.\n */\n touchSoundDisabled?: boolean;\n}\n\nexport interface BaseButtonProps extends RawButtonProps {\n /**\n * Called when the button gets pressed (analogous to `onPress` in\n * `TouchableHighlight` from RN core).\n */\n onPress?: (pointerInside: boolean) => void;\n\n /**\n * Called when the button gets pressed and is held for `delayLongPress`\n * milliseconds.\n */\n onLongPress?: () => void;\n\n /**\n * Called when button changes from inactive to active and vice versa. It\n * passes active state as a boolean variable as a first parameter for that\n * method.\n */\n onActiveStateChange?: (active: boolean) => void;\n style?: StyleProp;\n testID?: string;\n\n /**\n * Delay, in milliseconds, after which the `onLongPress` callback gets called.\n * Defaults to 600.\n */\n delayLongPress?: number;\n}\n\nexport interface RectButtonProps extends BaseButtonProps {\n /**\n * Background color that will be dimmed when button is in active state.\n */\n underlayColor?: string;\n\n /**\n * iOS only.\n *\n * Opacity applied to the underlay when button is in active state.\n */\n activeOpacity?: number;\n}\n\nexport interface BorderlessButtonProps extends BaseButtonProps {\n /**\n * iOS only.\n *\n * Opacity applied to the button when it is in an active state.\n */\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 static defaultProps = {\n delayLongPress: 600,\n };\n\n private lastActive: boolean;\n private longPressTimeout: ReturnType | undefined;\n private longPressDetected: boolean;\n\n constructor(props: BaseButtonProps) {\n super(props);\n this.lastActive = false;\n this.longPressDetected = 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 !this.longPressDetected &&\n oldState === State.ACTIVE &&\n state !== State.CANCELLED &&\n this.lastActive &&\n this.props.onPress\n ) {\n this.props.onPress(active);\n }\n\n if (\n !this.lastActive &&\n // NativeViewGestureHandler sends different events based on platform\n state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&\n pointerInside\n ) {\n this.longPressDetected = false;\n if (this.props.onLongPress) {\n this.longPressTimeout = setTimeout(\n this.onLongPress,\n this.props.delayLongPress\n );\n }\n } else if (\n // cancel longpress timeout if it's set and the finger moved out of the view\n state === State.ACTIVE &&\n !pointerInside &&\n this.longPressTimeout !== undefined\n ) {\n clearTimeout(this.longPressTimeout);\n this.longPressTimeout = undefined;\n } else if (\n // cancel longpress timeout if it's set and the gesture has finished\n this.longPressTimeout !== undefined &&\n (state === State.END ||\n state === State.CANCELLED ||\n state === State.FAILED)\n ) {\n clearTimeout(this.longPressTimeout);\n this.longPressTimeout = undefined;\n }\n\n this.lastActive = active;\n };\n\n private onLongPress = () => {\n this.longPressDetected = true;\n this.props.onLongPress?.();\n };\n\n // Normally, the parent would execute it's handler first, then forward the\n // event to listeners. However, here our handler is virtually only forwarding\n // events to listeners, so we reverse the order to keep the proper order of\n // 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"]},"metadata":{},"sourceType":"module"}