You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
61 KiB

{"ast":null,"code":"import _defineProperty2 from \"@babel/runtime/helpers/defineProperty\";\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\";\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 _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 invariant from 'invariant';\nimport Animated from \"react-native-web/dist/exports/Animated\";\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport View from \"react-native-web/dist/exports/View\";\nimport Keyboard from \"react-native-web/dist/exports/Keyboard\";\nimport StatusBar from \"react-native-web/dist/exports/StatusBar\";\nimport I18nManager from \"react-native-web/dist/exports/I18nManager\";\nimport { PanGestureHandler } from \"../handlers/PanGestureHandler\";\nimport { TapGestureHandler } from \"../handlers/TapGestureHandler\";\nimport { State } from \"../State\";\nvar DRAG_TOSS = 0.05;\nvar IDLE = 'Idle';\nvar DRAGGING = 'Dragging';\nvar SETTLING = 'Settling';\nvar DrawerLayout = function (_Component) {\n _inherits(DrawerLayout, _Component);\n var _super = _createSuper(DrawerLayout);\n function DrawerLayout(_props) {\n var _this;\n _classCallCheck(this, DrawerLayout);\n _this = _super.call(this, _props);\n _defineProperty(_assertThisInitialized(_this), \"openValue\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"onGestureEvent\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"accessibilityIsModalView\", React.createRef());\n _defineProperty(_assertThisInitialized(_this), \"pointerEventsView\", React.createRef());\n _defineProperty(_assertThisInitialized(_this), \"panGestureHandler\", React.createRef());\n _defineProperty(_assertThisInitialized(_this), \"drawerShown\", false);\n _defineProperty(_assertThisInitialized(_this), \"updateAnimatedEvent\", function (props, state) {\n var drawerPosition = props.drawerPosition,\n drawerWidth = props.drawerWidth,\n drawerType = props.drawerType;\n var dragXValue = state.dragX,\n touchXValue = state.touchX,\n drawerTranslation = state.drawerTranslation,\n containerWidth = state.containerWidth;\n var dragX = dragXValue;\n var touchX = touchXValue;\n if (drawerPosition !== 'left') {\n dragX = Animated.multiply(new Animated.Value(-1), dragXValue);\n touchX = Animated.add(new Animated.Value(containerWidth), Animated.multiply(new Animated.Value(-1), touchXValue));\n touchXValue.setValue(containerWidth);\n } else {\n touchXValue.setValue(0);\n }\n var translationX = dragX;\n if (drawerType === 'front') {\n var startPositionX = Animated.add(touchX, Animated.multiply(new Animated.Value(-1), dragX));\n var dragOffsetFromOnStartPosition = startPositionX.interpolate({\n inputRange: [drawerWidth - 1, drawerWidth, drawerWidth + 1],\n outputRange: [0, 0, 1]\n });\n translationX = Animated.add(dragX, dragOffsetFromOnStartPosition);\n }\n _this.openValue = Animated.add(translationX, drawerTranslation).interpolate({\n inputRange: [0, drawerWidth],\n outputRange: [0, 1],\n extrapolate: 'clamp'\n });\n var gestureOptions = {\n useNativeDriver: props.useNativeAnimations\n };\n if (_this.props.onDrawerSlide) {\n gestureOptions.listener = function (ev) {\n var _this$props$onDrawerS, _this$props;\n var translationX = Math.floor(Math.abs(ev.nativeEvent.translationX));\n var position = translationX / _this.state.containerWidth;\n (_this$props$onDrawerS = (_this$props = _this.props).onDrawerSlide) === null || _this$props$onDrawerS === void 0 ? void 0 : _this$props$onDrawerS.call(_this$props, position);\n };\n }\n _this.onGestureEvent = Animated.event([{\n nativeEvent: {\n translationX: dragXValue,\n x: touchXValue\n }\n }], gestureOptions);\n });\n _defineProperty(_assertThisInitialized(_this), \"handleContainerLayout\", function (_ref) {\n var nativeEvent = _ref.nativeEvent;\n _this.setState({\n containerWidth: nativeEvent.layout.width\n });\n });\n _defineProperty(_assertThisInitialized(_this), \"emitStateChanged\", function (newState, drawerWillShow) {\n var _this$props$onDrawerS2, _this$props2;\n (_this$props$onDrawerS2 = (_this$props2 = _this.props).onDrawerStateChanged) === null || _this$props$onDrawerS2 === void 0 ? void 0 : _this$props$onDrawerS2.call(_this$props2, newState, drawerWillShow);\n });\n _defineProperty(_assertThisInitialized(_this), \"openingHandlerStateChange\", function (_ref2) {\n var nativeEvent = _ref2.nativeEvent;\n if (nativeEvent.oldState === State.ACTIVE) {\n _this.handleRelease({\n nativeEvent: nativeEvent\n });\n } else if (nativeEvent.state === State.ACTIVE) {\n _this.emitStateChanged(DRAGGING, false);\n _this.setState({\n drawerState: DRAGGING\n });\n if (_this.props.keyboardDismissMode === 'on-drag') {\n Keyboard.dismiss();\n }\n if (_this.props.hideStatusBar) {\n StatusBar.setHidden(true, _this.props.statusBarAnimation || 'slide');\n }\n }\n });\n _defineProperty(_assertThisInitialized(_this), \"onTapHandlerStateChange\", function (_ref3) {\n var nativeEvent = _ref3.nativeEvent;\n if (_this.drawerShown && nativeEvent.oldState === State.ACTIVE && _this.props.drawerLockMode !== 'locked-open') {\n _this.closeDrawer();\n }\n });\n _defineProperty(_assertThisInitialized(_this), \"handleRelease\", function (_ref4) {\n var nativeEvent = _ref4.nativeEvent;\n var _this$props6 = _this.props,\n drawerWidth = _this$props6.drawerWidth,\n drawerPosition = _this$props6.drawerPosition,\n drawerType = _this$props6.drawerType;\n var containerWidth = _this.state.containerWidth;\n var dragX = nativeEvent.translationX,\n velocityX = nativeEvent.velocityX,\n touchX = nativeEvent.x;\n if (drawerPosition !== 'left') {\n dragX = -dragX;\n touchX = containerWidth - touchX;\n velocityX = -velocityX;\n }\n var gestureStartX = touchX - dragX;\n var dragOffsetBasedOnStart = 0;\n if (drawerType === 'front') {\n dragOffsetBasedOnStart = gestureStartX > drawerWidth ? gestureStartX - drawerWidth : 0;\n }\n var startOffsetX = dragX + dragOffsetBasedOnStart + (_this.drawerShown ? drawerWidth : 0);\n var projOffsetX = startOffsetX + DRAG_TOSS * velocityX;\n var shouldOpen = projOffsetX > drawerWidth / 2;\n if (shouldOpen) {\n _this.animateDrawer(startOffsetX, drawerWidth, velocityX);\n } else {\n _this.animateDrawer(startOffsetX, 0, velocityX);\n }\n });\n _defineProperty(_assertThisInitialized(_this), \"updateShowing\", function (showing) {\n var _this$accessibilityIs, _this$pointerEventsVi, _this$panGestureHandl;\n _this.drawerShown = showing;\n (_this$accessibilityIs = _this.accessibilityIsModalView.current) === null || _this$accessibilityIs === void 0 ? void 0 : _this$accessibilityIs.setNativeProps({\n accessibilityViewIsModal: showing\n });\n (_this$pointerEventsVi = _this.pointerEventsView.current) === null || _this$pointerEventsVi === void 0 ? void 0 : _this$pointerEventsVi.setNativeProps({\n pointerEvents: showing ? 'auto' : 'none'\n });\n var _this$props7 = _this.props,\n drawerPosition = _this$props7.drawerPosition,\n minSwipeDistance = _this$props7.minSwipeDistance,\n edgeWidth = _this$props7.edgeWidth;\n var fromLeft = drawerPosition === 'left';\n var gestureOrientation = (fromLeft ? 1 : -1) * (_this.drawerShown ? -1 : 1);\n var hitSlop = fromLeft ? {\n left: 0,\n width: showing ? undefined : edgeWidth\n } : {\n right: 0,\n width: showing ? undefined : edgeWidth\n };\n (_this$panGestureHandl = _this.panGestureHandler.current) === null || _this$panGestureHandl === void 0 ? void 0 : _this$panGestureHandl.setNativeProps({\n hitSlop: hitSlop,\n activeOffsetX: gestureOrientation * minSwipeDistance\n });\n });\n _defineProperty(_assertThisInitialized(_this), \"animateDrawer\", function (fromValue, toValue, velocity, speed) {\n _this.state.dragX.setValue(0);\n _this.state.touchX.setValue(_this.props.drawerPosition === 'left' ? 0 : _this.state.containerWidth);\n if (fromValue != null) {\n var nextFramePosition = fromValue;\n if (_this.props.useNativeAnimations) {\n if (fromValue < toValue && velocity > 0) {\n nextFramePosition = Math.min(fromValue + velocity / 60.0, toValue);\n } else if (fromValue > toValue && velocity < 0) {\n nextFramePosition = Math.max(fromValue + velocity / 60.0, toValue);\n }\n }\n _this.state.drawerTranslation.setValue(nextFramePosition);\n }\n var willShow = toValue !== 0;\n _this.updateShowing(willShow);\n _this.emitStateChanged(SETTLING, willShow);\n _this.setState({\n drawerState: SETTLING\n });\n if (_this.props.hideStatusBar) {\n StatusBar.setHidden(willShow, _this.props.statusBarAnimation || 'slide');\n }\n Animated.spring(_this.state.drawerTranslation, {\n velocity: velocity,\n bounciness: 0,\n toValue: toValue,\n useNativeDriver: _this.props.useNativeAnimations,\n speed: speed !== null && speed !== void 0 ? speed : undefined\n }).start(function (_ref5) {\n var finished = _ref5.finished;\n if (finished) {\n _this.emitStateChanged(IDLE, willShow);\n _this.setState({\n drawerOpened: willShow\n });\n if (_this.state.drawerState !== DRAGGING) {\n _this.setState({\n drawerState: IDLE\n });\n }\n if (willShow) {\n var _this$props$onDrawerO, _this$props3;\n (_this$props$onDrawerO = (_this$props3 = _this.props).onDrawerOpen) === null || _this$props$onDrawerO === void 0 ? void 0 : _this$props$onDrawerO.call(_this$props3);\n } else {\n var _this$props$onDrawerC, _this$props4;\n (_this$props$onDrawerC = (_this$props4 = _this.props).onDrawerClose) === null || _this$props$onDrawerC === void 0 ? void 0 : _this$props$onDrawerC.call(_this$props4);\n }\n }\n });\n });\n _defineProperty(_assertThisInitialized(_this), \"openDrawer\", function () {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _this.animateDrawer(undefined, _this.props.drawerWidth, options.velocity ? options.velocity : 0, options.speed);\n _this.forceUpdate();\n });\n _defineProperty(_assertThisInitialized(_this), \"closeDrawer\", function () {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _this.animateDrawer(undefined, 0, options.velocity ? options.velocity : 0, options.speed);\n _this.forceUpdate();\n });\n _defineProperty(_assertThisInitialized(_this), \"renderOverlay\", function () {\n invariant(_this.openValue, 'should be set');\n var overlayOpacity;\n if (_this.state.drawerState !== IDLE) {\n overlayOpacity = _this.openValue;\n } else {\n overlayOpacity = _this.state.drawerOpened ? 1 : 0;\n }\n var dynamicOverlayStyles = {\n opacity: overlayOpacity,\n backgroundColor: _this.props.overlayColor\n };\n return React.createElement(TapGestureHandler, {\n onHandlerStateChange: _this.onTapHandlerStateChange\n }, React.createElement(Animated.View, {\n pointerEvents: _this.drawerShown ? 'auto' : 'none',\n ref: _this.pointerEventsView,\n style: [styles.overlay, dynamicOverlayStyles]\n }));\n });\n _defineProperty(_assertThisInitialized(_this), \"renderDrawer\", function () {\n var _this$props8 = _this.props,\n drawerBackgroundColor = _this$props8.drawerBackgroundColor,\n drawerWidth = _this$props8.drawerWidth,\n drawerPosition = _this$props8.drawerPosition,\n drawerType = _this$props8.drawerType,\n drawerContainerStyle = _this$props8.drawerContainerStyle,\n contentContainerStyle = _this$props8.contentContainerStyle;\n var fromLeft = drawerPosition === 'left';\n var drawerSlide = drawerType !== 'back';\n var containerSlide = drawerType !== 'front';\n var reverseContentDirection = I18nManager.isRTL ? fromLeft : !fromLeft;\n var dynamicDrawerStyles = {\n backgroundColor: drawerBackgroundColor,\n width: drawerWidth\n };\n var openValue = _this.openValue;\n invariant(openValue, 'should be set');\n var containerStyles;\n if (containerSlide) {\n var containerTranslateX = openValue.interpolate({\n inputRange: [0, 1],\n outputRange: fromLeft ? [0, drawerWidth] : [0, -drawerWidth],\n extrapolate: 'clamp'\n });\n containerStyles = {\n transform: [{\n translateX: containerTranslateX\n }]\n };\n }\n var drawerTranslateX = 0;\n if (drawerSlide) {\n var closedDrawerOffset = fromLeft ? -drawerWidth : drawerWidth;\n if (_this.state.drawerState !== IDLE) {\n drawerTranslateX = openValue.interpolate({\n inputRange: [0, 1],\n outputRange: [closedDrawerOffset, 0],\n extrapolate: 'clamp'\n });\n } else {\n drawerTranslateX = _this.state.drawerOpened ? 0 : closedDrawerOffset;\n }\n }\n var drawerStyles = {\n transform: [{\n translateX: drawerTranslateX\n }],\n flexDirection: reverseContentDirection ? 'row-reverse' : 'row'\n };\n return React.createElement(Animated.View, {\n style: styles.main,\n onLayout: _this.handleContainerLayout\n }, React.createElement(Animated.View, {\n style: [drawerType === 'front' ? styles.containerOnBack : styles.containerInFront, containerStyles, contentContainerStyle],\n importantForAccessibility: _this.drawerShown ? 'no-hide-descendants' : 'yes'\n }, typeof _this.props.children === 'function' ? _this.props.children(_this.openValue) : _this.props.children, _this.renderOverlay()), React.createElement(Animated.View, {\n pointerEvents: \"box-none\",\n ref: _this.accessibilityIsModalView,\n accessibilityViewIsModal: _this.drawerShown,\n style: [styles.drawerContainer, drawerStyles, drawerContainerStyle]\n }, React.createElement(View, {\n style: dynamicDrawerStyles\n }, _this.props.renderNavigationView(_this.openValue))));\n });\n _defineProperty(_assertThisInitialized(_this), \"setPanGestureRef\", function (ref) {\n var _this$props$onGesture, _this$props5;\n _this.panGestureHandler.current = ref;\n (_this$props$onGesture = (_this$props5 = _this.props).onGestureRef) === null || _this$props$onGesture === void 0 ? void 0 : _this$props$onGesture.call(_this$props5, ref);\n });\n var _dragX = new Animated.Value(0);\n var _touchX = new Animated.Value(0);\n var _drawerTranslation = new Animated.Value(0);\n _this.state = {\n dragX: _dragX,\n touchX: _touchX,\n drawerTranslation: _drawerTranslation,\n containerWidth: 0,\n drawerState: IDLE,\n drawerOpened: false\n };\n _this.updateAnimatedEvent(_props, _this.state);\n return _this;\n }\n _createClass(DrawerLayout, [{\n key: \"shouldComponentUpdate\",\n value: function shouldComponentUpdate(props, state) {\n if (this.props.drawerPosition !== props.drawerPosition || this.props.drawerWidth !== props.drawerWidth || this.props.drawerType !== props.drawerType || this.state.containerWidth !== state.containerWidth) {\n this.updateAnimatedEvent(props, state);\n }\n return true;\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this$props9 = this.props,\n drawerPosition = _this$props9.drawerPosition,\n drawerLockMode = _this$props9.drawerLockMode,\n edgeWidth = _this$props9.edgeWidth,\n minSwipeDistance = _this$props9.minSwipeDistance;\n var fromLeft = drawerPosition === 'left';\n var gestureOrientation = (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);\n var hitSlop = fromLeft ? {\n left: 0,\n width: this.drawerShown ? undefined : edgeWidth\n } : {\n right: 0,\n width: this.drawerShown ? undefined : edgeWidth\n };\n return React.createElement(PanGestureHandler, {\n userSelect: this.props.userSelect,\n ref: this.setPanGestureRef,\n hitSlop: hitSlop,\n activeOffsetX: gestureOrientation * minSwipeDistance,\n failOffsetY: [-15, 15],\n onGestureEvent: this.onGestureEvent,\n onHandlerStateChange: this.openingHandlerStateChange,\n enableTrackpadTwoFingerGesture: this.props.enableTrackpadTwoFingerGesture,\n enabled: drawerLockMode !== 'locked-closed' && drawerLockMode !== 'locked-open'\n }, this.renderDrawer());\n }\n }]);\n return DrawerLayout;\n}(Component);\nexport { DrawerLayout as default };\n_defineProperty(DrawerLayout, \"defaultProps\", {\n drawerWidth: 200,\n drawerPosition: 'left',\n useNativeAnimations: true,\n drawerType: 'front',\n edgeWidth: 20,\n minSwipeDistance: 3,\n overlayColor: 'rgba(0, 0, 0, 0.7)',\n drawerLockMode: 'unlocked',\n enableTrackpadTwoFingerGesture: false\n});\n_defineProperty(DrawerLayout, \"positions\", {\n Left: 'left',\n Right: 'right'\n});\nvar styles = StyleSheet.create({\n drawerContainer: _objectSpread(_objectSpread({}, StyleSheet.absoluteFillObject), {}, {\n zIndex: 1001,\n flexDirection: 'row'\n }),\n containerInFront: _objectSpread(_objectSpread({}, StyleSheet.absoluteFillObject), {}, {\n zIndex: 1002\n }),\n containerOnBack: _objectSpread({}, StyleSheet.absoluteFillObject),\n main: {\n flex: 1,\n zIndex: 0,\n overflow: 'hidden'\n },\n overlay: _objectSpread(_objectSpread({}, StyleSheet.absoluteFillObject), {}, {\n zIndex: 1000\n })\n});","map":{"version":3,"sources":["DrawerLayout.tsx"],"names":["React","Component","invariant","PanGestureHandler","TapGestureHandler","State","DRAG_TOSS","IDLE","DRAGGING","SETTLING","DrawerLayout","drawerWidth","drawerPosition","useNativeAnimations","drawerType","edgeWidth","minSwipeDistance","overlayColor","drawerLockMode","enableTrackpadTwoFingerGesture","constructor","props","dragX","Animated","Value","touchX","drawerTranslation","state","containerWidth","drawerState","drawerOpened","updateAnimatedEvent","shouldComponentUpdate","createRef","Left","Right","dragXValue","touchXValue","multiply","add","setValue","translationX","startPositionX","dragOffsetFromOnStartPosition","interpolate","inputRange","outputRange","openValue","extrapolate","gestureOptions","useNativeDriver","onDrawerSlide","listener","ev","Math","floor","abs","nativeEvent","position","onGestureEvent","event","x","setState","layout","width","newState","drawerWillShow","onDrawerStateChanged","oldState","ACTIVE","handleRelease","emitStateChanged","keyboardDismissMode","Keyboard","dismiss","hideStatusBar","StatusBar","setHidden","statusBarAnimation","drawerShown","closeDrawer","velocityX","gestureStartX","dragOffsetBasedOnStart","startOffsetX","projOffsetX","shouldOpen","animateDrawer","showing","accessibilityIsModalView","current","setNativeProps","accessibilityViewIsModal","pointerEventsView","pointerEvents","fromLeft","gestureOrientation","hitSlop","left","undefined","right","panGestureHandler","activeOffsetX","fromValue","toValue","velocity","speed","nextFramePosition","min","max","willShow","updateShowing","spring","bounciness","start","finished","onDrawerOpen","onDrawerClose","options","forceUpdate","overlayOpacity","dynamicOverlayStyles","opacity","backgroundColor","onTapHandlerStateChange","styles","overlay","drawerBackgroundColor","drawerContainerStyle","contentContainerStyle","drawerSlide","containerSlide","reverseContentDirection","I18nManager","isRTL","dynamicDrawerStyles","containerStyles","containerTranslateX","transform","translateX","drawerTranslateX","closedDrawerOffset","drawerStyles","flexDirection","main","handleContainerLayout","containerOnBack","containerInFront","children","renderOverlay","drawerContainer","renderNavigationView","ref","onGestureRef","render","userSelect","setPanGestureRef","openingHandlerStateChange","renderDrawer","create","StyleSheet","absoluteFillObject","zIndex","flex","overflow"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAQA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,SAAT,QAA0B,OAA1B;AACA,OAAOC,SAAP,MAAsB,WAAtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBA,SACEC,iBADF;AAIA,SACEC,iBADF;AAIA,SAASC,KAAT;AAEA,IAAMC,SAAS,GAAG,IAAlB;AAEA,IAAMC,IAAiB,GAAG,MAA1B;AACA,IAAMC,QAAqB,GAAG,UAA9B;AACA,IAAMC,QAAqB,GAAG,UAA9B;AAAA,IA0IqBC,YAAN;EAAA;EAAA;EAgBbU,sBAAYC,MAAD,EAA2B;IAAA;IAAA;IACpC,0BAAMA,MAAN;IADoC,eAAA,gCAAA,WAAA,EAAA,KAAA,CAAA,CAAA;IAAA,eAAA,gCA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BC,UAAU,EAAE,OAJQ;EAKpBC,SAAS,EAAE,EALS;EAMpBC,gBAAgB,EAAE,CANE;EAOpBC,YAAY,EAAE,oBAPM;EAQpBC,cAAc,EAAE,UARI;EASpBC,8BAA8B,EAAE;AATZ,C;gBAJHT,Y,eAyDA;EACjBwB,IAAI,EAAE,MADW;EAEjBC,KAAK,EAAE;AAFU,C;AAwdrB,IAAM0F,MAAM,GAAG,UAAU,CAACkC,MAAX,CAAkB;EAC/BT,eAAe,kCACVU,UAAU,CAACC,kBADC;IAEfC,MAAM,EAAE,IAFO;IAGfnB,aAAa,EAAE;EAAA,EAJc;EAM/BI,gBAAgB,kCACXa,UAAU,CAACC,kBADE;IAEhBC,MAAM,EAAE;EAAA,EARqB;EAU/BhB,eAAe,oBACVc,UAAU,CAACC,kBAAAA,CAXe;EAa/BjB,IAAI,EAAE;IACJmB,IAAI,EAAE,CADF;IAEJD,MAAM,EAAE,CAFJ;IAGJE,QAAQ,EAAE;EAHN,CAbyB;EAkB/BtC,OAAO,kCACFkC,UAAU,CAACC,kBADP;IAEPC,MAAM,EAAE;EAAA;AApBqB,CAAlB,CAAf","sourcesContent":["// This component is based on RN's DrawerLayoutAndroid API\n//\n// It perhaps deserves to be put in a separate repo, but since it relies on\n// react-native-gesture-handler library which isn't very popular at the moment I\n// decided to keep it here for the time being. It will allow us to move faster\n// and fix issues that may arise in gesture handler library that could be found\n// when using the drawer component\n\nimport * as React from 'react';\nimport { Component } from 'react';\nimport invariant from 'invariant';\nimport {\n Animated,\n StyleSheet,\n View,\n Keyboard,\n StatusBar,\n I18nManager,\n StatusBarAnimation,\n StyleProp,\n ViewStyle,\n LayoutChangeEvent,\n NativeSyntheticEvent,\n} from 'react-native';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n UserSelect,\n} from '../handlers/gestureHandlerCommon';\nimport {\n PanGestureHandler,\n PanGestureHandlerEventPayload,\n} from '../handlers/PanGestureHandler';\nimport {\n TapGestureHandler,\n TapGestureHandlerEventPayload,\n} from '../handlers/TapGestureHandler';\nimport { State } from '../State';\n\nconst DRAG_TOSS = 0.05;\n\nconst IDLE: DrawerState = 'Idle';\nconst DRAGGING: DrawerState = 'Dragging';\nconst SETTLING: DrawerState = 'Settling';\n\nexport type DrawerPosition = 'left' | 'right';\n\nexport type DrawerState = 'Idle' | 'Dragging' | 'Settling';\n\nexport type DrawerType = 'front' | 'back' | 'slide';\n\nexport type DrawerLockMode = 'unlocked' | 'locked-closed' | 'locked-open';\n\nexport type DrawerKeyboardDismissMode = 'none' | 'on-drag';\n\n// Animated.AnimatedInterpolation has been converted to a generic type\n// in @types/react-native 0.70. This way we can maintain compatibility\n// with all versions of @types/react-native`\ntype AnimatedInterpolation = ReturnType<Animated.Value['interpolate']>;\nexport interface DrawerLayoutProps {\n /**\n * This attribute is present in the standard implementation already and is one\n * of the required params. Gesture handler version of DrawerLayout make it\n * possible for the function passed as `renderNavigationView` to take an\n * Animated value as a parameter that indicates the progress of drawer\n * opening/closing animation (progress value is 0 when closed and 1 when\n * opened). This can be used by the drawer component to animated its children\n * while the drawer is opening or closing.\n */\n renderNavigationView: (\n progressAnimatedValue: Animated.Value\n ) => React.ReactNode;\n\n drawerPosition?: DrawerPosition;\n\n drawerWidth?: number;\n\n drawerBackgroundColor?: string;\n\n drawerLockMode?: DrawerLockMode;\n\n keyboardDismissMode?: DrawerKeyboardDismissMode;\n\n /**\n * Called when the drawer is closed.\n */\n onDrawerClose?: () => void;\n\n /**\n * Called when the drawer is opened.\n */\n onDrawerOpen?: () => void;\n\n /**\n * Called when the status of the drawer changes.\n */\n onDrawerStateChanged?: (\n newState: DrawerState,\n drawerWillShow: boolean\n ) => void;\n useNativeAnimations?: boolean;\n\n drawerType?: DrawerType;\n\n /**\n * Defines how far from the edge of the content view the gesture should\n * activate.\n */\n edgeWidth?: number;\n\n minSwipeDistance?: number;\n\n /**\n * When set to true Drawer component will use\n * {@link https://reactnative.dev/docs/statusbar StatusBar} API to hide the OS\n * status bar whenever the drawer is pulled or when its in an \"open\" state.\n */\n hideStatusBar?: boolean;\n\n /**\n * @default 'slide'\n *\n * Can be used when hideStatusBar is set to true and will select the animation\n * used for hiding/showing the status bar. See\n * {@link https://reactnative.dev/docs/statusbar StatusBar} documentation for\n * more details\n */\n statusBarAnimation?: StatusBarAnimation;\n\n /**\n * @default black\n *\n * Color of a semi-transparent overlay to be displayed on top of the content\n * view when drawer gets open. A solid color should be used as the opacity is\n * added by the Drawer itself and the opacity of the overlay is animated (from\n * 0% to 70%).\n */\n overlayColor?: string;\n\n contentContainerStyle?: StyleProp<ViewStyle>;\n\n drawerContainerStyle?: StyleProp<ViewStyle>;\n\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n onDrawerSlide?: (position: number) => void;\n\n onGestureRef?: (ref: PanGestureHandler) => void;\n\n // implicit `children` prop has been removed in @types/react^18.0.0\n children?:\n | React.ReactNode\n | ((openValue?: AnimatedInterpolation) => React.ReactNode);\n\n /**\n * @default 'none'\n * Defines which userSelect property should be used.\n * Values: 'none'|'text'|'auto'\n */\n userSelect?: UserSelect;\n}\n\nexport type DrawerLayoutState = {\n dragX: Animated.Value;\n touchX: Animated.Value;\n drawerTranslation: Animated.Value;\n containerWidth: number;\n drawerState: DrawerState;\n drawerOpened: boolean;\n};\n\nexport type DrawerMovementOption = {\n velocity?: number;\n speed?: number;\n};\nexport default class DrawerLayout extends Component<\n DrawerLayoutProps,\n DrawerLayoutState\n> {\n static defaultProps = {\n drawerWidth: 200,\n drawerPosition: 'left',\n useNativeAnimations: true,\n drawerType: 'front',\n edgeWidth: 20,\n minSwipeDistance: 3,\n overlayColor: 'rgba(0, 0, 0, 0.7)',\n drawerLockMode: 'unlocked',\n enableTrackpadTwoFingerGesture: false,\n };\n\n constructor(props: DrawerLayoutProps) {\n super(props);\n\n const dragX = new Animated.Value(0);\n const touchX = new Animated.Value(0);\n const drawerTranslation = new Animated.Value(0);\n\n this.state = {\n dragX,\n touchX,\n drawerTranslation,\n containerWidth: 0,\n drawerState: IDLE,\n drawerOpened: false,\n };\n\n this.updateAnimatedEvent(props, this.state);\n }\n\n shouldComponentUpdate(props: DrawerLayoutProps, state: DrawerLayoutState) {\n if (\n this.props.drawerPosition !== props.drawerPosition ||\n this.props.drawerWidth !== props.drawerWidth ||\n this.props.drawerType !== props.drawerType ||\n this.state.containerWidth !== state.containerWidth\n ) {\n this.updateAnimatedEvent(props, state);\n }\n\n return true;\n }\n\n private openValue?: AnimatedInterpolation;\n private onGestureEvent?: (\n event: GestureEvent<PanGestureHandlerEventPayload>\n ) => void;\n private accessibilityIsModalView = React.createRef<View>();\n private pointerEventsView = React.createRef<View>();\n private panGestureHandler = React.createRef<PanGestureHandler | null>();\n private drawerShown = false;\n\n static positions = {\n Left: 'left',\n Right: 'right',\n };\n\n private updateAnimatedEvent = (\n props: DrawerLayoutProps,\n state: DrawerLayoutState\n ) => {\n // Event definition is based on\n const { drawerPosition, drawerWidth, drawerType } = props;\n const {\n dragX: dragXValue,\n touchX: touchXValue,\n drawerTranslation,\n containerWidth,\n } = state;\n\n let dragX = dragXValue;\n let touchX = touchXValue;\n\n if (drawerPosition !== 'left') {\n // Most of the code is written in a way to handle left-side drawer. In\n // order to handle right-side drawer the only thing we need to do is to\n // reverse events coming from gesture handler in a way they emulate\n // left-side drawer gestures. E.g. dragX is simply -dragX, and touchX is\n // calulcated by subtracing real touchX from the width of the container\n // (such that when touch happens at the right edge the value is simply 0)\n dragX = Animated.multiply(\n new Animated.Value(-1),\n dragXValue\n ) as Animated.Value; // TODO(TS): (for all \"as\" in this file) make sure we can map this\n touchX = Animated.add(\n new Animated.Value(containerWidth),\n Animated.multiply(new Animated.Value(-1), touchXValue)\n ) as Animated.Value; // TODO(TS): make sure we can map this;\n touchXValue.setValue(containerWidth);\n } else {\n touchXValue.setValue(0);\n }\n\n // While closing the drawer when user starts gesture outside of its area (in greyed\n // out part of the window), we want the drawer to follow only once finger reaches the\n // edge of the drawer.\n // E.g. on the diagram below drawer is illustrate by X signs and the greyed out area by\n // dots. The touch gesture starts at '*' and moves left, touch path is indicated by\n // an arrow pointing left\n // 1) +---------------+ 2) +---------------+ 3) +---------------+ 4) +---------------+\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|.<-*..| |XXXXXXXX|<--*..| |XXXXX|<-----*..|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // +---------------+ +---------------+ +---------------+ +---------------+\n //\n // For the above to work properly we define animated value that will keep\n // start position of the gesture. Then we use that value to calculate how\n // much we need to subtract from the dragX. If the gesture started on the\n // greyed out area we take the distance from the edge of the drawer to the\n // start position. Otherwise we don't subtract at all and the drawer be\n // pulled back as soon as you start the pan.\n //\n // This is used only when drawerType is \"front\"\n //\n let translationX = dragX;\n if (drawerType === 'front') {\n const startPositionX = Animated.add(\n touchX,\n Animated.multiply(new Animated.Value(-1), dragX)\n );\n\n const dragOffsetFromOnStartPosition = startPositionX.interpolate({\n inputRange: [drawerWidth! - 1, drawerWidth!, drawerWidth! + 1],\n outputRange: [0, 0, 1],\n });\n translationX = Animated.add(\n dragX,\n dragOffsetFromOnStartPosition\n ) as Animated.Value; // TODO: as above\n }\n\n this.openValue = Animated.add(translationX, drawerTranslation).interpolate({\n inputRange: [0, drawerWidth!],\n outputRange: [0, 1],\n extrapolate: 'clamp',\n });\n\n const gestureOptions: {\n useNativeDriver: boolean;\n // TODO: make sure it is correct\n listener?: (\n ev: NativeSyntheticEvent<PanGestureHandlerEventPayload>\n ) => void;\n } = {\n useNativeDriver: props.useNativeAnimations!,\n };\n\n if (this.props.onDrawerSlide) {\n gestureOptions.listener = (ev) => {\n const translationX = Math.floor(Math.abs(ev.nativeEvent.translationX));\n const position = translationX / this.state.containerWidth;\n\n this.props.onDrawerSlide?.(position);\n };\n }\n\n this.onGestureEvent = Animated.event(\n [{ nativeEvent: { translationX: dragXValue, x: touchXValue } }],\n gestureOptions\n );\n };\n\n private handleContainerLayout = ({ nativeEvent }: LayoutChangeEvent) => {\n this.setState({ containerWidth: nativeEvent.layout.width });\n };\n\n private emitStateChanged = (\n newState: DrawerState,\n drawerWillShow: boolean\n ) => {\n this.props.onDrawerStateChanged?.(newState, drawerWillShow);\n };\n\n private openingHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<PanGestureHandlerEventPayload>) => {\n if (nativeEvent.oldState === State.ACTIVE) {\n this.handleRelease({ nativeEvent });\n } else if (nativeEvent.state === State.ACTIVE) {\n this.emitStateChanged(DRAGGING, false);\n this.setState({ drawerState: DRAGGING });\n if (this.props.keyboardDismissMode === 'on-drag') {\n Keyboard.dismiss();\n }\n if (this.props.hideStatusBar) {\n StatusBar.setHidden(true, this.props.statusBarAnimation || 'slide');\n }\n }\n };\n\n private onTapHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<TapGestureHandlerEventPayload>) => {\n if (\n this.drawerShown &&\n nativeEvent.oldState === State.ACTIVE &&\n this.props.drawerLockMode !== 'locked-open'\n ) {\n this.closeDrawer();\n }\n };\n\n private handleRelease = ({\n nativeEvent,\n }: HandlerStateChangeEvent<PanGestureHandlerEventPayload>) => {\n const { drawerWidth, drawerPosition, drawerType } = this.props;\n const { containerWidth } = this.state;\n let { translationX: dragX, velocityX, x: touchX } = nativeEvent;\n\n if (drawerPosition !== 'left') {\n // See description in _updateAnimatedEvent about why events are flipped\n // for right-side drawer\n dragX = -dragX;\n touchX = containerWidth - touchX;\n velocityX = -velocityX;\n }\n\n const gestureStartX = touchX - dragX;\n let dragOffsetBasedOnStart = 0;\n\n if (drawerType === 'front') {\n dragOffsetBasedOnStart =\n gestureStartX > drawerWidth! ? gestureStartX - drawerWidth! : 0;\n }\n\n const startOffsetX =\n dragX + dragOffsetBasedOnStart + (this.drawerShown ? drawerWidth! : 0);\n const projOffsetX = startOffsetX + DRAG_TOSS * velocityX;\n\n const shouldOpen = projOffsetX > drawerWidth! / 2;\n\n if (shouldOpen) {\n this.animateDrawer(startOffsetX, drawerWidth!, velocityX);\n } else {\n this.animateDrawer(startOffsetX, 0, velocityX);\n }\n };\n\n private updateShowing = (showing: boolean) => {\n this.drawerShown = showing;\n this.accessibilityIsModalView.current?.setNativeProps({\n accessibilityViewIsModal: showing,\n });\n this.pointerEventsView.current?.setNativeProps({\n pointerEvents: showing ? 'auto' : 'none',\n });\n const { drawerPosition, minSwipeDistance, edgeWidth } = this.props;\n const fromLeft = drawerPosition === 'left';\n // gestureOrientation is 1 if the expected gesture is from left to right and\n // -1 otherwise e.g. when drawer is on the left and is closed we expect left\n // to right gesture, thus orientation will be 1.\n const gestureOrientation =\n (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);\n // When drawer is closed we want the hitSlop to be horizontally shorter than\n // the container size by the value of SLOP. This will make it only activate\n // when gesture happens not further than SLOP away from the edge\n const hitSlop = fromLeft\n ? { left: 0, width: showing ? undefined : edgeWidth }\n : { right: 0, width: showing ? undefined : edgeWidth };\n // @ts-ignore internal API, maybe could be fixed in handler types\n this.panGestureHandler.current?.setNativeProps({\n hitSlop,\n activeOffsetX: gestureOrientation * minSwipeDistance!,\n });\n };\n\n private animateDrawer = (\n fromValue: number | null | undefined,\n toValue: number,\n velocity: number,\n speed?: number\n ) => {\n this.state.dragX.setValue(0);\n this.state.touchX.setValue(\n this.props.drawerPosition === 'left' ? 0 : this.state.containerWidth\n );\n\n if (fromValue != null) {\n let nextFramePosition = fromValue;\n if (this.props.useNativeAnimations) {\n // When using native driver, we predict the next position of the\n // animation because it takes one frame of a roundtrip to pass RELEASE\n // event from native driver to JS before we can start animating. Without\n // it, it is more noticable that the frame is dropped.\n if (fromValue < toValue && velocity > 0) {\n nextFramePosition = Math.min(fromValue + velocity / 60.0, toValue);\n } else if (fromValue > toValue && velocity < 0) {\n nextFramePosition = Math.max(fromValue + velocity / 60.0, toValue);\n }\n }\n this.state.drawerTranslation.setValue(nextFramePosition);\n }\n\n const willShow = toValue !== 0;\n this.updateShowing(willShow);\n this.emitStateChanged(SETTLING, willShow);\n this.setState({ drawerState: SETTLING });\n if (this.props.hideStatusBar) {\n StatusBar.setHidden(willShow, this.props.statusBarAnimation || 'slide');\n }\n Animated.spring(this.state.drawerTranslation, {\n velocity,\n bounciness: 0,\n toValue,\n useNativeDriver: this.props.useNativeAnimations!,\n speed: speed ?? undefined,\n }).start(({ finished }) => {\n if (finished) {\n this.emitStateChanged(IDLE, willShow);\n this.setState({ drawerOpened: willShow });\n if (this.state.drawerState !== DRAGGING) {\n // it's possilbe that user started drag while the drawer\n // was settling, don't override state in this case\n this.setState({ drawerState: IDLE });\n }\n if (willShow) {\n this.props.onDrawerOpen?.();\n } else {\n this.props.onDrawerClose?.();\n }\n }\n });\n };\n\n openDrawer = (options: DrawerMovementOption = {}) => {\n this.animateDrawer(\n // TODO: decide if it should be null or undefined is the proper value\n undefined,\n this.props.drawerWidth!,\n options.velocity ? options.velocity : 0,\n options.speed\n );\n\n // We need to force the update, otherwise the overlay is not rerendered and\n // it would not be clickable\n this.forceUpdate();\n };\n\n closeDrawer = (options: DrawerMovementOption = {}) => {\n // TODO: decide if it should be null or undefined is the proper value\n this.animateDrawer(\n undefined,\n 0,\n options.velocity ? options.velocity : 0,\n options.speed\n );\n\n // We need to force the update, otherwise the overlay is not rerendered and\n // it would be still clickable\n this.forceUpdate();\n };\n\n private renderOverlay = () => {\n /* Overlay styles */\n invariant(this.openValue, 'should be set');\n let overlayOpacity;\n\n if (this.state.drawerState !== IDLE) {\n overlayOpacity = this.openValue;\n } else {\n overlayOpacity = this.state.drawerOpened ? 1 : 0;\n }\n\n const dynamicOverlayStyles = {\n opacity: overlayOpacity,\n backgroundColor: this.props.overlayColor,\n };\n\n return (\n <TapGestureHandler onHandlerStateChange={this.onTapHandlerStateChange}>\n <Animated.View\n pointerEvents={this.drawerShown ? 'auto' : 'none'}\n ref={this.pointerEventsView}\n style={[styles.overlay, dynamicOverlayStyles]}\n />\n </TapGestureHandler>\n );\n };\n\n private renderDrawer = () => {\n const {\n drawerBackgroundColor,\n drawerWidth,\n drawerPosition,\n drawerType,\n drawerContainerStyle,\n contentContainerStyle,\n } = this.props;\n\n const fromLeft = drawerPosition === 'left';\n const drawerSlide = drawerType !== 'back';\n const containerSlide = drawerType !== 'front';\n\n // we rely on row and row-reverse flex directions to position the drawer\n // properly. Apparently for RTL these are flipped which requires us to use\n // the opposite setting for the drawer to appear from left or right\n // according to the drawerPosition prop\n const reverseContentDirection = I18nManager.isRTL ? fromLeft : !fromLeft;\n\n const dynamicDrawerStyles = {\n backgroundColor: drawerBackgroundColor,\n width: drawerWidth,\n };\n const openValue = this.openValue;\n invariant(openValue, 'should be set');\n\n let containerStyles;\n if (containerSlide) {\n const containerTranslateX = openValue.interpolate({\n inputRange: [0, 1],\n outputRange: fromLeft ? [0, drawerWidth!] : [0, -drawerWidth!],\n extrapolate: 'clamp',\n });\n containerStyles = {\n transform: [{ translateX: containerTranslateX }],\n };\n }\n\n let drawerTranslateX: number | AnimatedInterpolation = 0;\n if (drawerSlide) {\n const closedDrawerOffset = fromLeft ? -drawerWidth! : drawerWidth!;\n if (this.state.drawerState !== IDLE) {\n drawerTranslateX = openValue.interpolate({\n inputRange: [0, 1],\n outputRange: [closedDrawerOffset, 0],\n extrapolate: 'clamp',\n });\n } else {\n drawerTranslateX = this.state.drawerOpened ? 0 : closedDrawerOffset;\n }\n }\n const drawerStyles: {\n transform: { translateX: number | AnimatedInterpolation }[];\n flexDirection: 'row-reverse' | 'row';\n } = {\n transform: [{ translateX: drawerTranslateX }],\n flexDirection: reverseContentDirection ? 'row-reverse' : 'row',\n };\n\n return (\n <Animated.View style={styles.main} onLayout={this.handleContainerLayout}>\n <Animated.View\n style={[\n drawerType === 'front'\n ? styles.containerOnBack\n : styles.containerInFront,\n containerStyles,\n contentContainerStyle,\n ]}\n importantForAccessibility={\n this.drawerShown ? 'no-hide-descendants' : 'yes'\n }>\n {typeof this.props.children === 'function'\n ? this.props.children(this.openValue)\n : this.props.children}\n {this.renderOverlay()}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n ref={this.accessibilityIsModalView}\n accessibilityViewIsModal={this.drawerShown}\n style={[styles.drawerContainer, drawerStyles, drawerContainerStyle]}>\n <View style={dynamicDrawerStyles}>\n {this.props.renderNavigationView(this.openValue as Animated.Value)}\n </View>\n </Animated.View>\n </Animated.View>\n );\n };\n\n private setPanGestureRef = (ref: PanGestureHandler) => {\n // TODO(TS): make sure it is OK taken from\n // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31065#issuecomment-596081842\n (\n this.panGestureHandler as React.MutableRefObject<PanGestureHandler>\n ).current = ref;\n this.props.onGestureRef?.(ref);\n };\n\n render() {\n const { drawerPosition, drawerLockMode, edgeWidth, minSwipeDistance } =\n this.props;\n\n const fromLeft = drawerPosition === 'left';\n\n // gestureOrientation is 1 if the expected gesture is from left to right and\n // -1 otherwise e.g. when drawer is on the left and is closed we expect left\n // to right gesture, thus orientation will be 1.\n const gestureOrientation =\n (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);\n\n // When drawer is closed we want the hitSlop to be horizontally shorter than\n // the container size by the value of SLOP. This will make it only activate\n // when gesture happens not further than SLOP away from the edge\n const hitSlop = fromLeft\n ? { left: 0, width: this.drawerShown ? undefined : edgeWidth }\n : { right: 0, width: this.drawerShown ? undefined : edgeWidth };\n\n return (\n <PanGestureHandler\n // @ts-ignore could be fixed in handler types\n userSelect={this.props.userSelect}\n ref={this.setPanGestureRef}\n hitSlop={hitSlop}\n activeOffsetX={gestureOrientation * minSwipeDistance!}\n failOffsetY={[-15, 15]}\n onGestureEvent={this.onGestureEvent}\n onHandlerStateChange={this.openingHandlerStateChange}\n enableTrackpadTwoFingerGesture={\n this.props.enableTrackpadTwoFingerGesture\n }\n enabled={\n drawerLockMode !== 'locked-closed' && drawerLockMode !== 'locked-open'\n }>\n {this.renderDrawer()}\n </PanGestureHandler>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n drawerContainer: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1001,\n flexDirection: 'row',\n },\n containerInFront: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1002,\n },\n containerOnBack: {\n ...StyleSheet.absoluteFillObject,\n },\n main: {\n flex: 1,\n zIndex: 0,\n overflow: 'hidden',\n },\n overlay: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1000,\n },\n});\n"]},"metadata":{},"sourceType":"module"}