{"ast":null,"code":"import _defineProperty2 from \"@babel/runtime/helpers/defineProperty\";\nimport _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 = [\"style\"];\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\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 { Component } from 'react';\nimport GenericTouchable, { TOUCHABLE_STATE } from \"./GenericTouchable\";\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport View from \"react-native-web/dist/exports/View\";\nvar TouchableHighlight = function (_Component) {\n  _inherits(TouchableHighlight, _Component);\n  var _super = _createSuper(TouchableHighlight);\n  function TouchableHighlight(props) {\n    var _this;\n    _classCallCheck(this, TouchableHighlight);\n    _this = _super.call(this, props);\n    _defineProperty(_assertThisInitialized(_this), \"showUnderlay\", function () {\n      var _this$props$onShowUnd, _this$props;\n      if (!_this.hasPressHandler()) {\n        return;\n      }\n      _this.setState({\n        extraChildStyle: {\n          opacity: _this.props.activeOpacity\n        },\n        extraUnderlayStyle: {\n          backgroundColor: _this.props.underlayColor\n        }\n      });\n      (_this$props$onShowUnd = (_this$props = _this.props).onShowUnderlay) === null || _this$props$onShowUnd === void 0 ? void 0 : _this$props$onShowUnd.call(_this$props);\n    });\n    _defineProperty(_assertThisInitialized(_this), \"hasPressHandler\", function () {\n      return _this.props.onPress || _this.props.onPressIn || _this.props.onPressOut || _this.props.onLongPress;\n    });\n    _defineProperty(_assertThisInitialized(_this), \"hideUnderlay\", function () {\n      var _this$props$onHideUnd, _this$props2;\n      _this.setState({\n        extraChildStyle: null,\n        extraUnderlayStyle: null\n      });\n      (_this$props$onHideUnd = (_this$props2 = _this.props).onHideUnderlay) === null || _this$props$onHideUnd === void 0 ? void 0 : _this$props$onHideUnd.call(_this$props2);\n    });\n    _defineProperty(_assertThisInitialized(_this), \"onStateChange\", function (_from, to) {\n      if (to === TOUCHABLE_STATE.BEGAN) {\n        _this.showUnderlay();\n      } else if (to === TOUCHABLE_STATE.UNDETERMINED || to === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n        _this.hideUnderlay();\n      }\n    });\n    _this.state = {\n      extraChildStyle: null,\n      extraUnderlayStyle: null\n    };\n    return _this;\n  }\n  _createClass(TouchableHighlight, [{\n    key: \"renderChildren\",\n    value: function renderChildren() {\n      if (!this.props.children) {\n        return React.createElement(View, null);\n      }\n      var child = React.Children.only(this.props.children);\n      return React.cloneElement(child, {\n        style: StyleSheet.compose(child.props.style, this.state.extraChildStyle)\n      });\n    }\n  }, {\n    key: \"render\",\n    value: function render() {\n      var _this$props3 = this.props,\n        _this$props3$style = _this$props3.style,\n        style = _this$props3$style === void 0 ? {} : _this$props3$style,\n        rest = _objectWithoutProperties(_this$props3, _excluded);\n      var extraUnderlayStyle = this.state.extraUnderlayStyle;\n      return React.createElement(GenericTouchable, _extends({}, rest, {\n        style: [style, extraUnderlayStyle],\n        onStateChange: this.onStateChange\n      }), this.renderChildren());\n    }\n  }]);\n  return TouchableHighlight;\n}(Component);\nexport { TouchableHighlight as default };\n_defineProperty(TouchableHighlight, \"defaultProps\", _objectSpread(_objectSpread({}, GenericTouchable.defaultProps), {}, {\n  activeOpacity: 0.85,\n  delayPressOut: 100,\n  underlayColor: 'black'\n}));","map":{"version":3,"sources":["TouchableHighlight.tsx"],"names":["React","Component","GenericTouchable","TOUCHABLE_STATE","TouchableHighlight","defaultProps","activeOpacity","delayPressOut","underlayColor","constructor","props","state","extraChildStyle","extraUnderlayStyle","hasPressHandler","setState","opacity","backgroundColor","onShowUnderlay","onPress","onPressIn","onPressOut","onLongPress","onHideUnderlay","renderChildren","children","child","Children","only","cloneElement","style","StyleSheet","compose","_from","to","BEGAN","showUnderlay","UNDETERMINED","MOVED_OUTSIDE","hideUnderlay","render","rest","onStateChange"],"mappings":";;;;;;;;;;;;;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,CAAmBL,KAAK,CAAChB,KAANgB,CAAYI,KAA/BC,EAAsC,IAAA,CAAKpB,KAAL,CAAWC,eAAjDmB;MADwB,CAA1B,CAAP;IAGD;EAAA;IAAA,GAAA;IAAA,KAAA,EAaDS,SAAAA,OAAAA,EAAS;MACP,IAAA,YAAA,GAAgC,IAAA,CAAK9B,KAArC;QAAA,kBAAA,GAAA,YAAA,CAAQoB,KAAK;QAALA,KAAK,GAAA,kBAAA,cAAG,CAAA,CAAV,GAAA,kBAAA;QAAiBW,IAAAA,GAAAA,wBAAAA,CAAAA,YAAAA,EAAAA,SAAAA;MACvB,IAAQ5B,kBAAAA,GAAuB,IAAA,CAAKF,KAApC,CAAQE,kBAAAA;MACR,OACE,KAAA,CAAA,aAAA,CAAC,gBAAD,EAAA,QAAA,CAAA,CAAA,CAAA,EACM4B,IADN,EAAA;QAEE,KAAK,EAAE,CAACX,KAAD,EAAQjB,kBAAR,CAFT;QAGE,aAAa,EAAE,IAAA,CAAK6B;MAHtB,CAAA,CAAA,EAIG,IAAA,CAAKlB,cAAL,CAAA,CAJH,CADF;IAQD;EAAA;EAAA,OAAA,kBAAA;AAAA,EApF6CvB,SAAjC;AAAA,SAAMG,kBAAN,IAAA,OAAA;gBAAMA,kB,gBAIG,EAAA,aAAA,CAAA,aAAA,KACjBF,gBAAgB,CAACG,YADA;EAEpBC,aAAa,EAAE,IAFK;EAGpBC,aAAa,EAAE,GAHK;EAIpBC,aAAa,EAAE;AAAA,E","sourcesContent":["import * as React from 'react';\nimport { Component } from 'react';\nimport GenericTouchable, {\n  GenericTouchableProps,\n  TOUCHABLE_STATE,\n} from './GenericTouchable';\nimport {\n  StyleSheet,\n  View,\n  TouchableHighlightProps,\n  ColorValue,\n  ViewProps,\n} from 'react-native';\n\ninterface State {\n  extraChildStyle: null | {\n    opacity?: number;\n  };\n  extraUnderlayStyle: null | {\n    backgroundColor?: ColorValue;\n  };\n}\n\n/**\n * TouchableHighlight follows RN's implementation\n */\nexport default class TouchableHighlight extends Component<\n  TouchableHighlightProps & GenericTouchableProps,\n  State\n> {\n  static defaultProps = {\n    ...GenericTouchable.defaultProps,\n    activeOpacity: 0.85,\n    delayPressOut: 100,\n    underlayColor: 'black',\n  };\n\n  constructor(props: TouchableHighlightProps & GenericTouchableProps) {\n    super(props);\n    this.state = {\n      extraChildStyle: null,\n      extraUnderlayStyle: null,\n    };\n  }\n\n  // Copied from RN\n  showUnderlay = () => {\n    if (!this.hasPressHandler()) {\n      return;\n    }\n    this.setState({\n      extraChildStyle: {\n        opacity: this.props.activeOpacity,\n      },\n      extraUnderlayStyle: {\n        backgroundColor: this.props.underlayColor,\n      },\n    });\n    this.props.onShowUnderlay?.();\n  };\n\n  hasPressHandler = () =>\n    this.props.onPress ||\n    this.props.onPressIn ||\n    this.props.onPressOut ||\n    this.props.onLongPress;\n\n  hideUnderlay = () => {\n    this.setState({\n      extraChildStyle: null,\n      extraUnderlayStyle: null,\n    });\n    this.props.onHideUnderlay?.();\n  };\n\n  renderChildren() {\n    if (!this.props.children) {\n      return <View />;\n    }\n\n    const child = React.Children.only(\n      this.props.children\n    ) as React.ReactElement<ViewProps>; // TODO: not sure if OK but fixes error\n    return React.cloneElement(child, {\n      style: StyleSheet.compose(child.props.style, this.state.extraChildStyle),\n    });\n  }\n\n  onStateChange = (_from: number, to: number) => {\n    if (to === TOUCHABLE_STATE.BEGAN) {\n      this.showUnderlay();\n    } else if (\n      to === TOUCHABLE_STATE.UNDETERMINED ||\n      to === TOUCHABLE_STATE.MOVED_OUTSIDE\n    ) {\n      this.hideUnderlay();\n    }\n  };\n\n  render() {\n    const { style = {}, ...rest } = this.props;\n    const { extraUnderlayStyle } = this.state;\n    return (\n      <GenericTouchable\n        {...rest}\n        style={[style, extraUnderlayStyle]}\n        onStateChange={this.onStateChange}>\n        {this.renderChildren()}\n      </GenericTouchable>\n    );\n  }\n}\n"]},"metadata":{},"sourceType":"module"}