@react-navigation/drawer 6.1.5 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/lib/commonjs/index.js +14 -14
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/navigators/createDrawerNavigator.js +22 -16
  4. package/lib/commonjs/navigators/createDrawerNavigator.js.map +1 -1
  5. package/lib/commonjs/utils/DrawerStatusContext.js.map +1 -1
  6. package/lib/commonjs/utils/getDrawerStatusFromState.js +2 -2
  7. package/lib/commonjs/utils/getDrawerStatusFromState.js.map +1 -1
  8. package/lib/commonjs/utils/useDrawerStatus.js.map +1 -1
  9. package/lib/commonjs/views/DrawerContent.js +6 -5
  10. package/lib/commonjs/views/DrawerContent.js.map +1 -1
  11. package/lib/commonjs/views/DrawerContentScrollView.js +7 -6
  12. package/lib/commonjs/views/DrawerContentScrollView.js.map +1 -1
  13. package/lib/commonjs/views/DrawerItem.js +14 -12
  14. package/lib/commonjs/views/DrawerItem.js.map +1 -1
  15. package/lib/commonjs/views/DrawerItemList.js +6 -5
  16. package/lib/commonjs/views/DrawerItemList.js.map +1 -1
  17. package/lib/commonjs/views/DrawerToggleButton.js +5 -4
  18. package/lib/commonjs/views/DrawerToggleButton.js.map +1 -1
  19. package/lib/commonjs/views/DrawerView.js +43 -34
  20. package/lib/commonjs/views/DrawerView.js.map +1 -1
  21. package/lib/commonjs/views/GestureHandler.js +7 -4
  22. package/lib/commonjs/views/GestureHandler.js.map +1 -1
  23. package/lib/commonjs/views/GestureHandlerNative.js +1 -1
  24. package/lib/commonjs/views/ScreenFallback.js +13 -9
  25. package/lib/commonjs/views/ScreenFallback.js.map +1 -1
  26. package/lib/commonjs/views/legacy/Drawer.js +20 -13
  27. package/lib/commonjs/views/legacy/Drawer.js.map +1 -1
  28. package/lib/commonjs/views/legacy/Overlay.js +8 -6
  29. package/lib/commonjs/views/legacy/Overlay.js.map +1 -1
  30. package/lib/commonjs/views/modern/Drawer.js +28 -30
  31. package/lib/commonjs/views/modern/Drawer.js.map +1 -1
  32. package/lib/commonjs/views/modern/Overlay.js +18 -9
  33. package/lib/commonjs/views/modern/Overlay.js.map +1 -1
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/module/navigators/createDrawerNavigator.js +22 -16
  36. package/lib/module/navigators/createDrawerNavigator.js.map +1 -1
  37. package/lib/module/utils/DrawerStatusContext.js.map +1 -1
  38. package/lib/module/utils/getDrawerStatusFromState.js +2 -2
  39. package/lib/module/utils/getDrawerStatusFromState.js.map +1 -1
  40. package/lib/module/utils/useDrawerStatus.js.map +1 -1
  41. package/lib/module/views/DrawerContent.js +6 -5
  42. package/lib/module/views/DrawerContent.js.map +1 -1
  43. package/lib/module/views/DrawerContentScrollView.js +7 -6
  44. package/lib/module/views/DrawerContentScrollView.js.map +1 -1
  45. package/lib/module/views/DrawerItem.js +14 -12
  46. package/lib/module/views/DrawerItem.js.map +1 -1
  47. package/lib/module/views/DrawerItemList.js +6 -5
  48. package/lib/module/views/DrawerItemList.js.map +1 -1
  49. package/lib/module/views/DrawerToggleButton.js +5 -4
  50. package/lib/module/views/DrawerToggleButton.js.map +1 -1
  51. package/lib/module/views/DrawerView.js +42 -33
  52. package/lib/module/views/DrawerView.js.map +1 -1
  53. package/lib/module/views/GestureHandler.js +6 -3
  54. package/lib/module/views/GestureHandler.js.map +1 -1
  55. package/lib/module/views/ScreenFallback.js +13 -9
  56. package/lib/module/views/ScreenFallback.js.map +1 -1
  57. package/lib/module/views/legacy/Drawer.js +20 -13
  58. package/lib/module/views/legacy/Drawer.js.map +1 -1
  59. package/lib/module/views/legacy/Overlay.js +8 -6
  60. package/lib/module/views/legacy/Overlay.js.map +1 -1
  61. package/lib/module/views/modern/Drawer.js +28 -30
  62. package/lib/module/views/modern/Drawer.js.map +1 -1
  63. package/lib/module/views/modern/Overlay.js +19 -10
  64. package/lib/module/views/modern/Overlay.js.map +1 -1
  65. package/lib/typescript/src/index.d.ts +1 -1
  66. package/lib/typescript/src/navigators/createDrawerNavigator.d.ts +1 -1
  67. package/lib/typescript/src/utils/DrawerStatusContext.d.ts +2 -1
  68. package/lib/typescript/src/utils/getDrawerStatusFromState.d.ts +2 -2
  69. package/lib/typescript/src/utils/useDrawerStatus.d.ts +2 -1
  70. package/lib/typescript/src/views/DrawerView.d.ts +2 -1
  71. package/lib/typescript/src/views/legacy/Overlay.d.ts +4 -0
  72. package/lib/typescript/src/views/modern/Overlay.d.ts +4 -0
  73. package/package.json +10 -10
  74. package/src/index.tsx +1 -0
  75. package/src/navigators/createDrawerNavigator.tsx +22 -14
  76. package/src/utils/DrawerStatusContext.tsx +4 -2
  77. package/src/utils/getDrawerStatusFromState.tsx +4 -3
  78. package/src/utils/useDrawerStatus.tsx +2 -1
  79. package/src/views/DrawerView.tsx +20 -6
  80. package/src/views/legacy/Drawer.tsx +21 -9
  81. package/src/views/legacy/Overlay.tsx +1 -0
  82. package/src/views/modern/Drawer.tsx +25 -23
  83. package/src/views/modern/Overlay.tsx +16 -3
@@ -4,6 +4,7 @@ import * as React from 'react';
4
4
  import { Platform, Pressable, StyleSheet } from 'react-native';
5
5
  import Animated from 'react-native-reanimated';
6
6
  const {
7
+ // @ts-expect-error: this is to support reanimated 1
7
8
  interpolate: interpolateDeprecated,
8
9
  interpolateNode,
9
10
  cond,
@@ -11,12 +12,13 @@ const {
11
12
  } = Animated;
12
13
  const interpolate = interpolateNode !== null && interpolateNode !== void 0 ? interpolateNode : interpolateDeprecated;
13
14
  const PROGRESS_EPSILON = 0.05;
14
- const Overlay = /*#__PURE__*/React.forwardRef(function Overlay({
15
- progress,
16
- onPress,
17
- style,
18
- ...props
19
- }, ref) {
15
+ const Overlay = /*#__PURE__*/React.forwardRef(function Overlay(_ref, ref) {
16
+ let {
17
+ progress,
18
+ onPress,
19
+ style,
20
+ ...props
21
+ } = _ref;
20
22
  const animatedStyle = {
21
23
  opacity: interpolate(progress, {
22
24
  // Default input range is [PROGRESS_EPSILON, 1]
@@ -1 +1 @@
1
- {"version":3,"sources":["Overlay.tsx"],"names":["React","Platform","Pressable","StyleSheet","Animated","interpolate","interpolateDeprecated","interpolateNode","cond","greaterThan","PROGRESS_EPSILON","Overlay","forwardRef","progress","onPress","style","props","ref","animatedStyle","opacity","inputRange","OS","outputRange","zIndex","styles","overlay","overlayStyle","pressable","select","web","WebkitTapHighlightColor","default","create","absoluteFillObject","backgroundColor","flex"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,UAA9B,QAAgD,cAAhD;AACA,OAAOC,QAAP,MAAqB,yBAArB;AAEA,MAAM;AACJC,EAAAA,WAAW,EAAEC,qBADT;AAEJC,EAAAA,eAFI;AAGJC,EAAAA,IAHI;AAIJC,EAAAA;AAJI,IAKFL,QALJ;AAOA,MAAMC,WAAmC,GACvCE,eADuC,aACvCA,eADuC,cACvCA,eADuC,GACpBD,qBADrB;AAGA,MAAMI,gBAAgB,GAAG,IAAzB;AAOA,MAAMC,OAAO,gBAAGX,KAAK,CAACY,UAAN,CAAiB,SAASD,OAAT,CAC/B;AAAEE,EAAAA,QAAF;AAAYC,EAAAA,OAAZ;AAAqBC,EAAAA,KAArB;AAA4B,KAAGC;AAA/B,CAD+B,EAE/BC,GAF+B,EAG/B;AACA,QAAMC,aAAa,GAAG;AACpBC,IAAAA,OAAO,EAAEd,WAAW,CAACQ,QAAD,EAAW;AAC7B;AACA;AACA;AACA;AACAO,MAAAA,UAAU,EACRnB,QAAQ,CAACoB,EAAT,KAAgB,SAAhB,IAA6BpB,QAAQ,CAACoB,EAAT,KAAgB,OAA7C,GACI,CAAC,CAAD,EAAI,CAAJ,CADJ,GAEI,CAACX,gBAAD,EAAmB,CAAnB,CARuB;AAS7BY,MAAAA,WAAW,EAAE,CAAC,CAAD,EAAI,CAAJ;AATgB,KAAX,CADA;AAYpB;AACA;AACA;AACAC,IAAAA,MAAM,EAAEf,IAAI,CAACC,WAAW,CAACI,QAAD,EAAWH,gBAAX,CAAZ,EAA0C,CAA1C,EAA6C,CAAC,CAA9C;AAfQ,GAAtB;AAkBA,sBACE,oBAAC,QAAD,CAAU,IAAV,eACMM,KADN;AAEE,IAAA,GAAG,EAAEC,GAFP;AAGE,IAAA,KAAK,EAAE,CAACO,MAAM,CAACC,OAAR,EAAiBC,YAAjB,EAA+BR,aAA/B,EAA8CH,KAA9C;AAHT,mBAKE,oBAAC,SAAD;AAAW,IAAA,OAAO,EAAED,OAApB;AAA6B,IAAA,KAAK,EAAEU,MAAM,CAACG;AAA3C,IALF,CADF;AASD,CA/Be,CAAhB;AAiCA,MAAMD,YAAY,GAAGzB,QAAQ,CAAC2B,MAAT,CAAwC;AAC3DC,EAAAA,GAAG,EAAE;AACH;AACA;AACAC,IAAAA,uBAAuB,EAAE;AAHtB,GADsD;AAM3DC,EAAAA,OAAO,EAAE;AANkD,CAAxC,CAArB;AASA,MAAMP,MAAM,GAAGrB,UAAU,CAAC6B,MAAX,CAAkB;AAC/BP,EAAAA,OAAO,EAAE,EACP,GAAGtB,UAAU,CAAC8B,kBADP;AAEPC,IAAAA,eAAe,EAAE;AAFV,GADsB;AAK/BP,EAAAA,SAAS,EAAE;AACTQ,IAAAA,IAAI,EAAE;AADG;AALoB,CAAlB,CAAf;AAUA,eAAexB,OAAf","sourcesContent":["import * as React from 'react';\nimport { Platform, Pressable, StyleSheet } from 'react-native';\nimport Animated from 'react-native-reanimated';\n\nconst {\n interpolate: interpolateDeprecated,\n interpolateNode,\n cond,\n greaterThan,\n} = Animated;\n\nconst interpolate: typeof interpolateNode =\n interpolateNode ?? interpolateDeprecated;\n\nconst PROGRESS_EPSILON = 0.05;\n\ntype Props = React.ComponentProps<typeof Animated.View> & {\n progress: Animated.Node<number>;\n onPress: () => void;\n};\n\nconst Overlay = React.forwardRef(function Overlay(\n { progress, onPress, style, ...props }: Props,\n ref: React.Ref<Animated.View>\n) {\n const animatedStyle = {\n opacity: interpolate(progress, {\n // Default input range is [PROGRESS_EPSILON, 1]\n // On Windows, the output value is 1 when input value is out of range for some reason\n // The default value 0 will be interpolated to 1 in this case, which is not what we want.\n // Therefore changing input range on Windows to [0,1] instead.\n inputRange:\n Platform.OS === 'windows' || Platform.OS === 'macos'\n ? [0, 1]\n : [PROGRESS_EPSILON, 1],\n outputRange: [0, 1],\n }),\n // We don't want the user to be able to press through the overlay when drawer is open\n // One approach is to adjust the pointerEvents based on the progress\n // But we can also send the overlay behind the screen, which works, and is much less code\n zIndex: cond(greaterThan(progress, PROGRESS_EPSILON), 0, -1),\n };\n\n return (\n <Animated.View\n {...props}\n ref={ref}\n style={[styles.overlay, overlayStyle, animatedStyle, style]}\n >\n <Pressable onPress={onPress} style={styles.pressable} />\n </Animated.View>\n );\n});\n\nconst overlayStyle = Platform.select<Record<string, string>>({\n web: {\n // Disable touch highlight on mobile Safari.\n // WebkitTapHighlightColor must be used outside of StyleSheet.create because react-native-web will omit the property.\n WebkitTapHighlightColor: 'transparent',\n },\n default: {},\n});\n\nconst styles = StyleSheet.create({\n overlay: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0, 0, 0, 0.5)',\n },\n pressable: {\n flex: 1,\n },\n});\n\nexport default Overlay;\n"]}
1
+ {"version":3,"sources":["Overlay.tsx"],"names":["React","Platform","Pressable","StyleSheet","Animated","interpolate","interpolateDeprecated","interpolateNode","cond","greaterThan","PROGRESS_EPSILON","Overlay","forwardRef","ref","progress","onPress","style","props","animatedStyle","opacity","inputRange","OS","outputRange","zIndex","styles","overlay","overlayStyle","pressable","select","web","WebkitTapHighlightColor","default","create","absoluteFillObject","backgroundColor","flex"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,UAA9B,QAAgD,cAAhD;AACA,OAAOC,QAAP,MAAqB,yBAArB;AAEA,MAAM;AACJ;AACAC,EAAAA,WAAW,EAAEC,qBAFT;AAGJ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3DC,EAAAA,GAAG,EAAE;AACH;AACA;AACAC,IAAAA,uBAAuB,EAAE;AAHtB,GADsD;AAM3DC,EAAAA,OAAO,EAAE;AANkD,CAAxC,CAArB;AASA,MAAMP,MAAM,GAAGrB,UAAU,CAAC6B,MAAX,CAAkB;AAC/BP,EAAAA,OAAO,EAAE,EACP,GAAGtB,UAAU,CAAC8B,kBADP;AAEPC,IAAAA,eAAe,EAAE;AAFV,GADsB;AAK/BP,EAAAA,SAAS,EAAE;AACTQ,IAAAA,IAAI,EAAE;AADG;AALoB,CAAlB,CAAf;AAUA,eAAexB,OAAf","sourcesContent":["import * as React from 'react';\nimport { Platform, Pressable, StyleSheet } from 'react-native';\nimport Animated from 'react-native-reanimated';\n\nconst {\n // @ts-expect-error: this is to support reanimated 1\n interpolate: interpolateDeprecated,\n interpolateNode,\n cond,\n greaterThan,\n} = Animated;\n\nconst interpolate: typeof interpolateNode =\n interpolateNode ?? interpolateDeprecated;\n\nconst PROGRESS_EPSILON = 0.05;\n\ntype Props = React.ComponentProps<typeof Animated.View> & {\n progress: Animated.Node<number>;\n onPress: () => void;\n};\n\nconst Overlay = React.forwardRef(function Overlay(\n { progress, onPress, style, ...props }: Props,\n ref: React.Ref<Animated.View>\n) {\n const animatedStyle = {\n opacity: interpolate(progress, {\n // Default input range is [PROGRESS_EPSILON, 1]\n // On Windows, the output value is 1 when input value is out of range for some reason\n // The default value 0 will be interpolated to 1 in this case, which is not what we want.\n // Therefore changing input range on Windows to [0,1] instead.\n inputRange:\n Platform.OS === 'windows' || Platform.OS === 'macos'\n ? [0, 1]\n : [PROGRESS_EPSILON, 1],\n outputRange: [0, 1],\n }),\n // We don't want the user to be able to press through the overlay when drawer is open\n // One approach is to adjust the pointerEvents based on the progress\n // But we can also send the overlay behind the screen, which works, and is much less code\n zIndex: cond(greaterThan(progress, PROGRESS_EPSILON), 0, -1),\n };\n\n return (\n <Animated.View\n {...props}\n ref={ref}\n style={[styles.overlay, overlayStyle, animatedStyle, style]}\n >\n <Pressable onPress={onPress} style={styles.pressable} />\n </Animated.View>\n );\n});\n\nconst overlayStyle = Platform.select<Record<string, string>>({\n web: {\n // Disable touch highlight on mobile Safari.\n // WebkitTapHighlightColor must be used outside of StyleSheet.create because react-native-web will omit the property.\n WebkitTapHighlightColor: 'transparent',\n },\n default: {},\n});\n\nconst styles = StyleSheet.create({\n overlay: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0, 0, 0, 0.5)',\n },\n pressable: {\n flex: 1,\n },\n});\n\nexport default Overlay;\n"]}
@@ -15,26 +15,28 @@ const minmax = (value, start, end) => {
15
15
  return Math.min(Math.max(value, start), end);
16
16
  };
17
17
 
18
- export default function Drawer({
19
- dimensions,
20
- drawerPosition,
21
- drawerStyle,
22
- drawerType,
23
- gestureHandlerProps,
24
- hideStatusBarOnOpen,
25
- keyboardDismissMode,
26
- onClose,
27
- onOpen,
28
- open,
29
- overlayStyle,
30
- renderDrawerContent,
31
- renderSceneContent,
32
- statusBarAnimation,
33
- swipeDistanceThreshold,
34
- swipeEdgeWidth,
35
- swipeEnabled,
36
- swipeVelocityThreshold
37
- }) {
18
+ export default function Drawer(_ref) {
19
+ let {
20
+ dimensions,
21
+ drawerPosition,
22
+ drawerStyle,
23
+ drawerType,
24
+ gestureHandlerProps,
25
+ hideStatusBarOnOpen,
26
+ keyboardDismissMode,
27
+ onClose,
28
+ onOpen,
29
+ open,
30
+ overlayStyle,
31
+ renderDrawerContent,
32
+ renderSceneContent,
33
+ statusBarAnimation,
34
+ swipeDistanceThreshold,
35
+ swipeEdgeWidth,
36
+ swipeEnabled,
37
+ swipeVelocityThreshold
38
+ } = _ref;
39
+
38
40
  const getDrawerWidth = () => {
39
41
  const {
40
42
  width = DEFAULT_DRAWER_WIDTH
@@ -192,23 +194,19 @@ export default function Drawer({
192
194
  return translateX;
193
195
  });
194
196
  const drawerAnimatedStyle = useAnimatedStyle(() => {
195
- if (drawerType === 'permanent') {
196
- return {};
197
- }
198
-
199
197
  return {
200
- transform: [{
198
+ transform: drawerType === 'permanent' ? // Reanimated needs the property to be present, but it results in Browser bug
199
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=20574
200
+ undefined : [{
201
201
  translateX: drawerType === 'back' ? 0 : translateX.value
202
202
  }]
203
203
  };
204
204
  });
205
205
  const contentAnimatedStyle = useAnimatedStyle(() => {
206
- if (drawerType === 'permanent') {
207
- return {};
208
- }
209
-
210
206
  return {
211
- transform: [{
207
+ transform: drawerType === 'permanent' ? // Reanimated needs the property to be present, but it results in Browser bug
208
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=20574
209
+ undefined : [{
212
210
  translateX: drawerType === 'front' ? 0 : drawerPosition === 'left' ? drawerWidth + translateX.value : translateX.value - drawerWidth
213
211
  }]
214
212
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["Drawer.tsx"],"names":["React","InteractionManager","Keyboard","Platform","StatusBar","StyleSheet","View","PanGestureHandler","State","GestureState","Animated","interpolate","runOnJS","useAnimatedGestureHandler","useAnimatedStyle","useDerivedValue","useSharedValue","withSpring","DrawerProgressContext","Overlay","SWIPE_DISTANCE_MINIMUM","DEFAULT_DRAWER_WIDTH","minmax","value","start","end","Math","min","max","Drawer","dimensions","drawerPosition","drawerStyle","drawerType","gestureHandlerProps","hideStatusBarOnOpen","keyboardDismissMode","onClose","onOpen","open","overlayStyle","renderDrawerContent","renderSceneContent","statusBarAnimation","swipeDistanceThreshold","swipeEdgeWidth","swipeEnabled","swipeVelocityThreshold","getDrawerWidth","width","flatten","endsWith","percentage","Number","replace","isFinite","drawerWidth","isOpen","isRight","getDrawerTranslationX","useCallback","hideStatusBar","hide","setHidden","useEffect","interactionHandleRef","useRef","startInteraction","current","createInteractionHandle","endInteraction","clearInteractionHandle","hideKeyboard","dismiss","onGestureStart","onGestureEnd","hitSlop","right","undefined","left","touchStartX","touchX","translationX","gestureState","UNDETERMINED","toggleDrawer","velocity","translateX","stiffness","damping","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","onGestureEvent","onStart","event","ctx","startX","state","x","onActive","onEnd","nextOpen","abs","velocityX","touchDistance","ACTIVE","drawerAnimatedStyle","transform","contentAnimatedStyle","progress","styles","main","flexDirection","content","OS","container","position","zIndex","create","top","bottom","maxWidth","flex","select","web","default","overflow"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,kBADF,EAEEC,QAFF,EAGEC,QAHF,EAIEC,SAJF,EAKEC,UALF,EAMEC,IANF,QAOO,cAPP;AAQA,SACEC,iBADF,EAGEC,KAAK,IAAIC,YAHX,QAIO,8BAJP;AAKA,OAAOC,QAAP,IACEC,WADF,EAEEC,OAFF,EAGEC,yBAHF,EAIEC,gBAJF,EAKEC,eALF,EAMEC,cANF,EAOEC,UAPF,QAQO,yBARP;AAWA,OAAOC,qBAAP,MAAkC,mCAAlC;AACA,OAAOC,OAAP,MAAoB,WAApB;AAEA,MAAMC,sBAAsB,GAAG,CAA/B;AACA,MAAMC,oBAAoB,GAAG,KAA7B;;AAEA,MAAMC,MAAM,GAAG,CAACC,KAAD,EAAgBC,KAAhB,EAA+BC,GAA/B,KAA+C;AAC5D;;AAEA,SAAOC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACE,GAAL,CAASL,KAAT,EAAgBC,KAAhB,CAAT,EAAiCC,GAAjC,CAAP;AACD,CAJD;;AAMA,eAAe,SAASI,MAAT,CAAgB;AAC7BC,EAAAA,UAD6B;AAE7BC,EAAAA,cAF6B;AAG7BC,EAAAA,WAH6B;AAI7BC,EAAAA,UAJ6B;AAK7BC,EAAAA,mBAL6B;AAM7BC,EAAAA,mBAN6B;AAO7BC,EAAAA,mBAP6B;AAQ7BC,EAAAA,OAR6B;AAS7BC,EAAAA,MAT6B;AAU7BC,EAAAA,IAV6B;AAW7BC,EAAAA,YAX6B;AAY7BC,EAAAA,mBAZ6B;AAa7BC,EAAAA,kBAb6B;AAc7BC,EAAAA,kBAd6B;AAe7BC,EAAAA,sBAf6B;A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AA,GAAG,EAAE,CADI;AAETC,IAAAA,MAAM,EAAE,CAFC;AAGTC,IAAAA,QAAQ,EAAE,MAHD;AAIT1E,IAAAA,KAAK,EAAE5B;AAJE,GADoB;AAO/B8F,EAAAA,OAAO,EAAE;AACPS,IAAAA,IAAI,EAAE;AADC,GAPsB;AAU/BX,EAAAA,IAAI,EAAE;AACJW,IAAAA,IAAI,EAAE,CADF;AAEJ,OAAGzH,QAAQ,CAAC0H,MAAT,CAAgB;AACjB;AACA;AACAC,MAAAA,GAAG,EAAE,IAHY;AAIjBC,MAAAA,OAAO,EAAE;AAAEC,QAAAA,QAAQ,EAAE;AAAZ;AAJQ,KAAhB;AAFC;AAVyB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n InteractionManager,\n Keyboard,\n Platform,\n StatusBar,\n StyleSheet,\n View,\n} from 'react-native';\nimport {\n PanGestureHandler,\n PanGestureHandlerGestureEvent,\n State as GestureState,\n} from 'react-native-gesture-handler';\nimport Animated, {\n interpolate,\n runOnJS,\n useAnimatedGestureHandler,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n} from 'react-native-reanimated';\n\nimport type { DrawerProps } from '../../types';\nimport DrawerProgressContext from '../../utils/DrawerProgressContext';\nimport Overlay from './Overlay';\n\nconst SWIPE_DISTANCE_MINIMUM = 5;\nconst DEFAULT_DRAWER_WIDTH = '80%';\n\nconst minmax = (value: number, start: number, end: number) => {\n 'worklet';\n\n return Math.min(Math.max(value, start), end);\n};\n\nexport default function Drawer({\n dimensions,\n drawerPosition,\n drawerStyle,\n drawerType,\n gestureHandlerProps,\n hideStatusBarOnOpen,\n keyboardDismissMode,\n onClose,\n onOpen,\n open,\n overlayStyle,\n renderDrawerContent,\n renderSceneContent,\n statusBarAnimation,\n swipeDistanceThreshold,\n swipeEdgeWidth,\n swipeEnabled,\n swipeVelocityThreshold,\n}: DrawerProps) {\n const getDrawerWidth = (): number => {\n const { width = DEFAULT_DRAWER_WIDTH } =\n StyleSheet.flatten(drawerStyle) || {};\n\n if (typeof width === 'string' && width.endsWith('%')) {\n // Try to calculate width if a percentage is given\n const percentage = Number(width.replace(/%$/, ''));\n\n if (Number.isFinite(percentage)) {\n return dimensions.width * (percentage / 100);\n }\n }\n\n return typeof width === 'number' ? width : 0;\n };\n\n const drawerWidth = getDrawerWidth();\n\n const isOpen = drawerType === 'permanent' ? true : open;\n const isRight = drawerPosition === 'right';\n\n const getDrawerTranslationX = React.useCallback(\n (open: boolean) => {\n 'worklet';\n\n if (drawerPosition === 'left') {\n return open ? 0 : -drawerWidth;\n }\n\n return open ? 0 : drawerWidth;\n },\n [drawerPosition, drawerWidth]\n );\n\n const hideStatusBar = React.useCallback(\n (hide: boolean) => {\n if (hideStatusBarOnOpen) {\n StatusBar.setHidden(hide, statusBarAnimation);\n }\n },\n [hideStatusBarOnOpen, statusBarAnimation]\n );\n\n React.useEffect(() => {\n hideStatusBar(isOpen);\n\n return () => hideStatusBar(false);\n }, [isOpen, hideStatusBarOnOpen, statusBarAnimation, hideStatusBar]);\n\n const interactionHandleRef = React.useRef<number | null>(null);\n\n const startInteraction = () => {\n interactionHandleRef.current = InteractionManager.createInteractionHandle();\n };\n\n const endInteraction = () => {\n if (interactionHandleRef.current != null) {\n InteractionManager.clearInteractionHandle(interactionHandleRef.current);\n interactionHandleRef.current = null;\n }\n };\n\n const hideKeyboard = () => {\n if (keyboardDismissMode === 'on-drag') {\n Keyboard.dismiss();\n }\n };\n\n const onGestureStart = () => {\n startInteraction();\n hideKeyboard();\n hideStatusBar(true);\n };\n\n const onGestureEnd = () => {\n endInteraction();\n };\n\n // FIXME: Currently hitSlop is broken when on Android when drawer is on right\n // https://github.com/software-mansion/react-native-gesture-handler/issues/569\n const hitSlop = isRight\n ? // Extend hitSlop to the side of the screen when drawer is closed\n // This lets the user drag the drawer from the side of the screen\n { right: 0, width: isOpen ? undefined : swipeEdgeWidth }\n : { left: 0, width: isOpen ? undefined : swipeEdgeWidth };\n\n const touchStartX = useSharedValue(0);\n const touchX = useSharedValue(0);\n const translationX = useSharedValue(getDrawerTranslationX(open));\n const gestureState = useSharedValue<GestureState>(GestureState.UNDETERMINED);\n\n const toggleDrawer = React.useCallback(\n (open: boolean, velocity?: number) => {\n 'worklet';\n\n const translateX = getDrawerTranslationX(open);\n\n touchStartX.value = 0;\n touchX.value = 0;\n translationX.value = withSpring(\n translateX,\n {\n velocity,\n stiffness: 1000,\n damping: 500,\n mass: 3,\n overshootClamping: true,\n restDisplacementThreshold: 0.01,\n restSpeedThreshold: 0.01,\n },\n () => {\n if (translationX.value === getDrawerTranslationX(true)) {\n runOnJS(onOpen)();\n } else if (translationX.value === getDrawerTranslationX(false)) {\n runOnJS(onClose)();\n }\n }\n );\n },\n [getDrawerTranslationX, onClose, onOpen, touchStartX, touchX, translationX]\n );\n\n React.useEffect(() => toggleDrawer(open), [open, toggleDrawer]);\n\n const onGestureEvent = useAnimatedGestureHandler<\n PanGestureHandlerGestureEvent,\n { startX: number }\n >({\n onStart: (event, ctx) => {\n ctx.startX = translationX.value;\n gestureState.value = event.state;\n touchStartX.value = event.x;\n\n runOnJS(onGestureStart)();\n },\n onActive: (event, ctx) => {\n touchX.value = event.x;\n translationX.value = ctx.startX + event.translationX;\n gestureState.value = event.state;\n },\n onEnd: (event) => {\n gestureState.value = event.state;\n\n const nextOpen =\n (Math.abs(event.translationX) > SWIPE_DISTANCE_MINIMUM &&\n Math.abs(event.translationX) > swipeVelocityThreshold) ||\n Math.abs(event.translationX) > swipeDistanceThreshold\n ? drawerPosition === 'left'\n ? // If swiped to right, open the drawer, otherwise close it\n (event.velocityX === 0 ? event.translationX : event.velocityX) > 0\n : // If swiped to left, open the drawer, otherwise close it\n (event.velocityX === 0 ? event.translationX : event.velocityX) < 0\n : open;\n\n toggleDrawer(nextOpen, event.velocityX);\n runOnJS(onGestureEnd)();\n },\n });\n\n const translateX = useDerivedValue(() => {\n // Comment stolen from react-native-gesture-handler/DrawerLayout\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 start position\n // of the gesture. Then we use that value to calculate how much we need to subtract from\n // the translationX. If the gesture started on the greyed out area we take the distance from the\n // edge of the drawer to the start position. Otherwise we don't subtract at all and the\n // drawer be pulled back as soon as you start the pan.\n //\n // This is used only when drawerType is \"front\"\n const touchDistance =\n drawerType === 'front' && gestureState.value === GestureState.ACTIVE\n ? minmax(\n drawerPosition === 'left'\n ? touchStartX.value - drawerWidth\n : dimensions.width - drawerWidth - touchStartX.value,\n 0,\n dimensions.width\n )\n : 0;\n\n const translateX =\n drawerPosition === 'left'\n ? minmax(translationX.value + touchDistance, -drawerWidth, 0)\n : minmax(translationX.value - touchDistance, 0, drawerWidth);\n\n return translateX;\n });\n\n const drawerAnimatedStyle = useAnimatedStyle(() => {\n if (drawerType === 'permanent') {\n return {};\n }\n\n return {\n transform: [\n {\n translateX: drawerType === 'back' ? 0 : translateX.value,\n },\n ],\n };\n });\n\n const contentAnimatedStyle = useAnimatedStyle(() => {\n if (drawerType === 'permanent') {\n return {};\n }\n\n return {\n transform: [\n {\n translateX:\n drawerType === 'front'\n ? 0\n : drawerPosition === 'left'\n ? drawerWidth + translateX.value\n : translateX.value - drawerWidth,\n },\n ],\n };\n });\n\n const progress = useDerivedValue(() => {\n return drawerType === 'permanent'\n ? 1\n : interpolate(\n translateX.value,\n [getDrawerTranslationX(false), getDrawerTranslationX(true)],\n [0, 1]\n );\n });\n\n return (\n <DrawerProgressContext.Provider value={progress}>\n <PanGestureHandler\n activeOffsetX={[-SWIPE_DISTANCE_MINIMUM, SWIPE_DISTANCE_MINIMUM]}\n failOffsetY={[-SWIPE_DISTANCE_MINIMUM, SWIPE_DISTANCE_MINIMUM]}\n hitSlop={hitSlop}\n enabled={drawerType !== 'permanent' && swipeEnabled}\n onGestureEvent={onGestureEvent}\n {...gestureHandlerProps}\n >\n {/* Immediate child of gesture handler needs to be an Animated.View */}\n <Animated.View\n style={[\n styles.main,\n {\n flexDirection:\n drawerType === 'permanent' && !isRight ? 'row-reverse' : 'row',\n },\n ]}\n >\n <Animated.View style={[styles.content, contentAnimatedStyle]}>\n <View\n accessibilityElementsHidden={isOpen && drawerType !== 'permanent'}\n importantForAccessibility={\n isOpen && drawerType !== 'permanent'\n ? 'no-hide-descendants'\n : 'auto'\n }\n style={styles.content}\n >\n {renderSceneContent()}\n </View>\n {drawerType !== 'permanent' ? (\n <Overlay\n progress={progress}\n onPress={() => toggleDrawer(false)}\n style={overlayStyle}\n />\n ) : null}\n </Animated.View>\n <Animated.View\n accessibilityViewIsModal={isOpen && drawerType !== 'permanent'}\n removeClippedSubviews={Platform.OS !== 'ios'}\n style={[\n styles.container,\n {\n position: drawerType === 'permanent' ? 'relative' : 'absolute',\n zIndex: drawerType === 'back' ? -1 : 0,\n },\n drawerAnimatedStyle,\n drawerStyle as any,\n ]}\n >\n {renderDrawerContent()}\n </Animated.View>\n </Animated.View>\n </PanGestureHandler>\n </DrawerProgressContext.Provider>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n top: 0,\n bottom: 0,\n maxWidth: '100%',\n width: DEFAULT_DRAWER_WIDTH,\n },\n content: {\n flex: 1,\n },\n main: {\n flex: 1,\n ...Platform.select({\n // FIXME: We need to hide `overflowX` on Web so the translated content doesn't show offscreen.\n // But adding `overflowX: 'hidden'` prevents content from collapsing the URL bar.\n web: null,\n default: { overflow: 'hidden' },\n }),\n },\n});\n"]}
1
+ {"version":3,"sources":["Drawer.tsx"],"names":["React","InteractionManager","Keyboard","Platform","StatusBar","StyleSheet","View","PanGestureHandler","State","GestureState","Animated","interpolate","runOnJS","useAnimatedGestureHandler","useAnimatedStyle","useDerivedValue","useSharedValue","withSpring","DrawerProgressContext","Overlay","SWIPE_DISTANCE_MINIMUM","DEFAULT_DRAWER_WIDTH","minmax","value","start","end","Math","min","max","Drawer","dimensions","drawerPosition","drawerStyle","drawerType","gestureHandlerProps","hideStatusBarOnOpen","keyboardDismissMode","onClose","onOpen","open","overlayStyle","renderDrawerContent","renderSceneContent","statusBarAnimation","swipeDistanceThreshold","swipeEdgeWidth","swipeEnabled","swipeVelocityThreshold","getDrawerWidth","width","flatten","endsWith","percentage","Number","replace","isFinite","drawerWidth","isOpen","isRight","getDrawerTranslationX","useCallback","hideStatusBar","hide","setHidden","useEffect","interactionHandleRef","useRef","startInteraction","current","createInteractionHandle","endInteraction","clearInteractionHandle","hideKeyboard","dismiss","onGestureStart","onGestureEnd","hitSlop","right","undefined","left","touchStartX","touchX","translationX","gestureState","UNDETERMINED","toggleDrawer","velocity","translateX","stiffness","damping","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","onGestureEvent","onStart","event","ctx","startX","state","x","onActive","onEnd","nextOpen","abs","velocityX","touchDistance","ACTIVE","drawerAnimatedStyle","transform","contentAnimatedStyle","progress","styles","main","flexDirection","content","OS","container","position","zIndex","create","top","bottom","maxWidth","flex","select","web","default","overflow"],"mappings":";;AAAA,OAAO,KAAKA,K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ACJW,IAAAA,IAAI,EAAE,CADF;AAEJ,OAAGzH,QAAQ,CAAC0H,MAAT,CAAgB;AACjB;AACA;AACAC,MAAAA,GAAG,EAAE,IAHY;AAIjBC,MAAAA,OAAO,EAAE;AAAEC,QAAAA,QAAQ,EAAE;AAAZ;AAJQ,KAAhB;AAFC;AAVyB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n InteractionManager,\n Keyboard,\n Platform,\n StatusBar,\n StyleSheet,\n View,\n} from 'react-native';\nimport {\n PanGestureHandler,\n PanGestureHandlerGestureEvent,\n State as GestureState,\n} from 'react-native-gesture-handler';\nimport Animated, {\n interpolate,\n runOnJS,\n useAnimatedGestureHandler,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n} from 'react-native-reanimated';\n\nimport type { DrawerProps } from '../../types';\nimport DrawerProgressContext from '../../utils/DrawerProgressContext';\nimport Overlay from './Overlay';\n\nconst SWIPE_DISTANCE_MINIMUM = 5;\nconst DEFAULT_DRAWER_WIDTH = '80%';\n\nconst minmax = (value: number, start: number, end: number) => {\n 'worklet';\n\n return Math.min(Math.max(value, start), end);\n};\n\nexport default function Drawer({\n dimensions,\n drawerPosition,\n drawerStyle,\n drawerType,\n gestureHandlerProps,\n hideStatusBarOnOpen,\n keyboardDismissMode,\n onClose,\n onOpen,\n open,\n overlayStyle,\n renderDrawerContent,\n renderSceneContent,\n statusBarAnimation,\n swipeDistanceThreshold,\n swipeEdgeWidth,\n swipeEnabled,\n swipeVelocityThreshold,\n}: DrawerProps) {\n const getDrawerWidth = (): number => {\n const { width = DEFAULT_DRAWER_WIDTH } =\n StyleSheet.flatten(drawerStyle) || {};\n\n if (typeof width === 'string' && width.endsWith('%')) {\n // Try to calculate width if a percentage is given\n const percentage = Number(width.replace(/%$/, ''));\n\n if (Number.isFinite(percentage)) {\n return dimensions.width * (percentage / 100);\n }\n }\n\n return typeof width === 'number' ? width : 0;\n };\n\n const drawerWidth = getDrawerWidth();\n\n const isOpen = drawerType === 'permanent' ? true : open;\n const isRight = drawerPosition === 'right';\n\n const getDrawerTranslationX = React.useCallback(\n (open: boolean) => {\n 'worklet';\n\n if (drawerPosition === 'left') {\n return open ? 0 : -drawerWidth;\n }\n\n return open ? 0 : drawerWidth;\n },\n [drawerPosition, drawerWidth]\n );\n\n const hideStatusBar = React.useCallback(\n (hide: boolean) => {\n if (hideStatusBarOnOpen) {\n StatusBar.setHidden(hide, statusBarAnimation);\n }\n },\n [hideStatusBarOnOpen, statusBarAnimation]\n );\n\n React.useEffect(() => {\n hideStatusBar(isOpen);\n\n return () => hideStatusBar(false);\n }, [isOpen, hideStatusBarOnOpen, statusBarAnimation, hideStatusBar]);\n\n const interactionHandleRef = React.useRef<number | null>(null);\n\n const startInteraction = () => {\n interactionHandleRef.current = InteractionManager.createInteractionHandle();\n };\n\n const endInteraction = () => {\n if (interactionHandleRef.current != null) {\n InteractionManager.clearInteractionHandle(interactionHandleRef.current);\n interactionHandleRef.current = null;\n }\n };\n\n const hideKeyboard = () => {\n if (keyboardDismissMode === 'on-drag') {\n Keyboard.dismiss();\n }\n };\n\n const onGestureStart = () => {\n startInteraction();\n hideKeyboard();\n hideStatusBar(true);\n };\n\n const onGestureEnd = () => {\n endInteraction();\n };\n\n // FIXME: Currently hitSlop is broken when on Android when drawer is on right\n // https://github.com/software-mansion/react-native-gesture-handler/issues/569\n const hitSlop = isRight\n ? // Extend hitSlop to the side of the screen when drawer is closed\n // This lets the user drag the drawer from the side of the screen\n { right: 0, width: isOpen ? undefined : swipeEdgeWidth }\n : { left: 0, width: isOpen ? undefined : swipeEdgeWidth };\n\n const touchStartX = useSharedValue(0);\n const touchX = useSharedValue(0);\n const translationX = useSharedValue(getDrawerTranslationX(open));\n const gestureState = useSharedValue<GestureState>(GestureState.UNDETERMINED);\n\n const toggleDrawer = React.useCallback(\n (open: boolean, velocity?: number) => {\n 'worklet';\n\n const translateX = getDrawerTranslationX(open);\n\n touchStartX.value = 0;\n touchX.value = 0;\n translationX.value = withSpring(\n translateX,\n {\n velocity,\n stiffness: 1000,\n damping: 500,\n mass: 3,\n overshootClamping: true,\n restDisplacementThreshold: 0.01,\n restSpeedThreshold: 0.01,\n },\n () => {\n if (translationX.value === getDrawerTranslationX(true)) {\n runOnJS(onOpen)();\n } else if (translationX.value === getDrawerTranslationX(false)) {\n runOnJS(onClose)();\n }\n }\n );\n },\n [getDrawerTranslationX, onClose, onOpen, touchStartX, touchX, translationX]\n );\n\n React.useEffect(() => toggleDrawer(open), [open, toggleDrawer]);\n\n const onGestureEvent = useAnimatedGestureHandler<\n PanGestureHandlerGestureEvent,\n { startX: number }\n >({\n onStart: (event, ctx) => {\n ctx.startX = translationX.value;\n gestureState.value = event.state;\n touchStartX.value = event.x;\n\n runOnJS(onGestureStart)();\n },\n onActive: (event, ctx) => {\n touchX.value = event.x;\n translationX.value = ctx.startX + event.translationX;\n gestureState.value = event.state;\n },\n onEnd: (event) => {\n gestureState.value = event.state;\n\n const nextOpen =\n (Math.abs(event.translationX) > SWIPE_DISTANCE_MINIMUM &&\n Math.abs(event.translationX) > swipeVelocityThreshold) ||\n Math.abs(event.translationX) > swipeDistanceThreshold\n ? drawerPosition === 'left'\n ? // If swiped to right, open the drawer, otherwise close it\n (event.velocityX === 0 ? event.translationX : event.velocityX) > 0\n : // If swiped to left, open the drawer, otherwise close it\n (event.velocityX === 0 ? event.translationX : event.velocityX) < 0\n : open;\n\n toggleDrawer(nextOpen, event.velocityX);\n runOnJS(onGestureEnd)();\n },\n });\n\n const translateX = useDerivedValue(() => {\n // Comment stolen from react-native-gesture-handler/DrawerLayout\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 start position\n // of the gesture. Then we use that value to calculate how much we need to subtract from\n // the translationX. If the gesture started on the greyed out area we take the distance from the\n // edge of the drawer to the start position. Otherwise we don't subtract at all and the\n // drawer be pulled back as soon as you start the pan.\n //\n // This is used only when drawerType is \"front\"\n const touchDistance =\n drawerType === 'front' && gestureState.value === GestureState.ACTIVE\n ? minmax(\n drawerPosition === 'left'\n ? touchStartX.value - drawerWidth\n : dimensions.width - drawerWidth - touchStartX.value,\n 0,\n dimensions.width\n )\n : 0;\n\n const translateX =\n drawerPosition === 'left'\n ? minmax(translationX.value + touchDistance, -drawerWidth, 0)\n : minmax(translationX.value - touchDistance, 0, drawerWidth);\n\n return translateX;\n });\n\n const drawerAnimatedStyle = useAnimatedStyle(() => {\n return {\n transform:\n drawerType === 'permanent'\n ? // Reanimated needs the property to be present, but it results in Browser bug\n // https://bugs.chromium.org/p/chromium/issues/detail?id=20574\n undefined\n : [\n {\n translateX: drawerType === 'back' ? 0 : translateX.value,\n },\n ],\n };\n });\n\n const contentAnimatedStyle = useAnimatedStyle(() => {\n return {\n transform:\n drawerType === 'permanent'\n ? // Reanimated needs the property to be present, but it results in Browser bug\n // https://bugs.chromium.org/p/chromium/issues/detail?id=20574\n undefined\n : [\n {\n translateX:\n drawerType === 'front'\n ? 0\n : drawerPosition === 'left'\n ? drawerWidth + translateX.value\n : translateX.value - drawerWidth,\n },\n ],\n };\n });\n\n const progress = useDerivedValue(() => {\n return drawerType === 'permanent'\n ? 1\n : interpolate(\n translateX.value,\n [getDrawerTranslationX(false), getDrawerTranslationX(true)],\n [0, 1]\n );\n });\n\n return (\n <DrawerProgressContext.Provider value={progress}>\n <PanGestureHandler\n activeOffsetX={[-SWIPE_DISTANCE_MINIMUM, SWIPE_DISTANCE_MINIMUM]}\n failOffsetY={[-SWIPE_DISTANCE_MINIMUM, SWIPE_DISTANCE_MINIMUM]}\n hitSlop={hitSlop}\n enabled={drawerType !== 'permanent' && swipeEnabled}\n onGestureEvent={onGestureEvent}\n {...gestureHandlerProps}\n >\n {/* Immediate child of gesture handler needs to be an Animated.View */}\n <Animated.View\n style={[\n styles.main,\n {\n flexDirection:\n drawerType === 'permanent' && !isRight ? 'row-reverse' : 'row',\n },\n ]}\n >\n <Animated.View style={[styles.content, contentAnimatedStyle]}>\n <View\n accessibilityElementsHidden={isOpen && drawerType !== 'permanent'}\n importantForAccessibility={\n isOpen && drawerType !== 'permanent'\n ? 'no-hide-descendants'\n : 'auto'\n }\n style={styles.content}\n >\n {renderSceneContent()}\n </View>\n {drawerType !== 'permanent' ? (\n <Overlay\n progress={progress}\n onPress={() => toggleDrawer(false)}\n style={overlayStyle}\n />\n ) : null}\n </Animated.View>\n <Animated.View\n accessibilityViewIsModal={isOpen && drawerType !== 'permanent'}\n removeClippedSubviews={Platform.OS !== 'ios'}\n style={[\n styles.container,\n {\n position: drawerType === 'permanent' ? 'relative' : 'absolute',\n zIndex: drawerType === 'back' ? -1 : 0,\n },\n drawerAnimatedStyle,\n drawerStyle as any,\n ]}\n >\n {renderDrawerContent()}\n </Animated.View>\n </Animated.View>\n </PanGestureHandler>\n </DrawerProgressContext.Provider>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n top: 0,\n bottom: 0,\n maxWidth: '100%',\n width: DEFAULT_DRAWER_WIDTH,\n },\n content: {\n flex: 1,\n },\n main: {\n flex: 1,\n ...Platform.select({\n // FIXME: We need to hide `overflowX` on Web so the translated content doesn't show offscreen.\n // But adding `overflowX: 'hidden'` prevents content from collapsing the URL bar.\n web: null,\n default: { overflow: 'hidden' },\n }),\n },\n});\n"]}
@@ -2,26 +2,35 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import * as React from 'react';
4
4
  import { Platform, Pressable, StyleSheet } from 'react-native';
5
- import Animated, { useAnimatedStyle } from 'react-native-reanimated';
5
+ import Animated, { useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
6
6
  const PROGRESS_EPSILON = 0.05;
7
- const Overlay = /*#__PURE__*/React.forwardRef(function Overlay({
8
- progress,
9
- onPress,
10
- style,
11
- ...props
12
- }, ref) {
7
+ const Overlay = /*#__PURE__*/React.forwardRef(function Overlay(_ref, ref) {
8
+ let {
9
+ progress,
10
+ onPress,
11
+ style,
12
+ ...props
13
+ } = _ref;
13
14
  const animatedStyle = useAnimatedStyle(() => {
14
15
  return {
15
16
  opacity: progress.value,
16
17
  // We don't want the user to be able to press through the overlay when drawer is open
17
- // One approach is to adjust the pointerEvents based on the progress
18
- // But we can also send the overlay behind the screen
18
+ // We can send the overlay behind the screen to avoid it
19
19
  zIndex: progress.value > PROGRESS_EPSILON ? 0 : -1
20
20
  };
21
21
  });
22
+ const animatedProps = useAnimatedProps(() => {
23
+ const active = progress.value > PROGRESS_EPSILON;
24
+ return {
25
+ pointerEvents: active ? 'auto' : 'none',
26
+ accessibilityElementsHidden: !active,
27
+ importantForAccessibility: active ? 'auto' : 'no-hide-descendants'
28
+ };
29
+ });
22
30
  return /*#__PURE__*/React.createElement(Animated.View, _extends({}, props, {
23
31
  ref: ref,
24
- style: [styles.overlay, overlayStyle, animatedStyle, style]
32
+ style: [styles.overlay, overlayStyle, animatedStyle, style],
33
+ animatedProps: animatedProps
25
34
  }), /*#__PURE__*/React.createElement(Pressable, {
26
35
  onPress: onPress,
27
36
  style: styles.pressable
@@ -1 +1 @@
1
- {"version":3,"sources":["Overlay.tsx"],"names":["React","Platform","Pressable","StyleSheet","Animated","useAnimatedStyle","PROGRESS_EPSILON","Overlay","forwardRef","progress","onPress","style","props","ref","animatedStyle","opacity","value","zIndex","styles","overlay","overlayStyle","pressable","select","web","WebkitTapHighlightColor","default","create","absoluteFillObject","backgroundColor","flex"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,UAA9B,QAAgD,cAAhD;AACA,OAAOC,QAAP,IAAmBC,gBAAnB,QAA2C,yBAA3C;AAEA,MAAMC,gBAAgB,GAAG,IAAzB;AAOA,MAAMC,OAAO,gBAAGP,KAAK,CAACQ,UAAN,CAAiB,SAASD,OAAT,CAC/B;AAAEE,EAAAA,QAAF;AAAYC,EAAAA,OAAZ;AAAqBC,EAAAA,KAArB;AAA4B,KAAGC;AAA/B,CAD+B,EAE/BC,GAF+B,EAG/B;AACA,QAAMC,aAAa,GAAGT,gBAAgB,CAAC,MAAM;AAC3C,WAAO;AACLU,MAAAA,OAAO,EAAEN,QAAQ,CAACO,KADb;AAEL;AACA;AACA;AACAC,MAAAA,MAAM,EAAER,QAAQ,CAACO,KAAT,GAAiBV,gBAAjB,GAAoC,CAApC,GAAwC,CAAC;AAL5C,KAAP;AAOD,GARqC,CAAtC;AAUA,sBACE,oBAAC,QAAD,CAAU,IAAV,eACMM,KADN;AAEE,IAAA,GAAG,EAAEC,GAFP;AAGE,IAAA,KAAK,EAAE,CAACK,MAAM,CAACC,OAAR,EAAiBC,YAAjB,EAA+BN,aAA/B,EAA8CH,KAA9C;AAHT,mBAKE,oBAAC,SAAD;AAAW,IAAA,OAAO,EAAED,OAApB;AAA6B,IAAA,KAAK,EAAEQ,MAAM,CAACG;AAA3C,IALF,CADF;AASD,CAvBe,CAAhB;AAyBA,MAAMD,YAAY,GAAGnB,QAAQ,CAACqB,MAAT,CAAwC;AAC3DC,EAAAA,GAAG,EAAE;AACH;AACA;AACAC,IAAAA,uBAAuB,EAAE;AAHtB,GADsD;AAM3DC,EAAAA,OAAO,EAAE;AANkD,CAAxC,CAArB;AASA,MAAMP,MAAM,GAAGf,UAAU,CAACuB,MAAX,CAAkB;AAC/BP,EAAAA,OAAO,EAAE,EACP,GAAGhB,UAAU,CAACwB,kBADP;AAEPC,IAAAA,eAAe,EAAE;AAFV,GADsB;AAK/BP,EAAAA,SAAS,EAAE;AACTQ,IAAAA,IAAI,EAAE;AADG;AALoB,CAAlB,CAAf;AAUA,eAAetB,OAAf","sourcesContent":["import * as React from 'react';\nimport { Platform, Pressable, StyleSheet } from 'react-native';\nimport Animated, { useAnimatedStyle } from 'react-native-reanimated';\n\nconst PROGRESS_EPSILON = 0.05;\n\ntype Props = React.ComponentProps<typeof Animated.View> & {\n progress: Animated.SharedValue<number>;\n onPress: () => void;\n};\n\nconst Overlay = React.forwardRef(function Overlay(\n { progress, onPress, style, ...props }: Props,\n ref: React.Ref<Animated.View>\n) {\n const animatedStyle = useAnimatedStyle(() => {\n return {\n opacity: progress.value,\n // We don't want the user to be able to press through the overlay when drawer is open\n // One approach is to adjust the pointerEvents based on the progress\n // But we can also send the overlay behind the screen\n zIndex: progress.value > PROGRESS_EPSILON ? 0 : -1,\n };\n });\n\n return (\n <Animated.View\n {...props}\n ref={ref}\n style={[styles.overlay, overlayStyle, animatedStyle, style]}\n >\n <Pressable onPress={onPress} style={styles.pressable} />\n </Animated.View>\n );\n});\n\nconst overlayStyle = Platform.select<Record<string, string>>({\n web: {\n // Disable touch highlight on mobile Safari.\n // WebkitTapHighlightColor must be used outside of StyleSheet.create because react-native-web will omit the property.\n WebkitTapHighlightColor: 'transparent',\n },\n default: {},\n});\n\nconst styles = StyleSheet.create({\n overlay: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0, 0, 0, 0.5)',\n },\n pressable: {\n flex: 1,\n },\n});\n\nexport default Overlay;\n"]}
1
+ {"version":3,"sources":["Overlay.tsx"],"names":["React","Platform","Pressable","StyleSheet","Animated","useAnimatedProps","useAnimatedStyle","PROGRESS_EPSILON","Overlay","forwardRef","ref","progress","onPress","style","props","animatedStyle","opacity","value","zIndex","animatedProps","active","pointerEvents","accessibilityElementsHidden","importantForAccessibility","styles","overlay","overlayStyle","pressable","select","web","WebkitTapHighlightColor","default","create","absoluteFillObject","backgroundColor","flex"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,UAA9B,QAAgD,cAAhD;AACA,OAAOC,QAAP,IACEC,gBADF,EAEEC,gBAFF,QAGO,yBAHP;AAKA,MAAMC,gBAAgB,GAAG,IAAzB;AAOA,MAAMC,OAAO,gBAAGR,KAAK,CAACS,UAAN,CAAiB,SAASD,OAAT,OAE/BE,GAF+B,EAG/B;AAAA,MAFA;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,OAAZ;AAAqBC,IAAAA,KAArB;AAA4B,OAAGC;AAA/B,GAEA;AACA,QAAMC,aAAa,GAAGT,gBAAgB,CAAC,MAAM;AAC3C,WAAO;AACLU,MAAAA,OAAO,EAAEL,QAAQ,CAACM,KADb;AAEL;AACA;AACAC,MAAAA,MAAM,EAAEP,QAAQ,CAACM,KAAT,GAAiBV,gBAAjB,GAAoC,CAApC,GAAwC,CAAC;AAJ5C,KAAP;AAMD,GAPqC,CAAtC;AASA,QAAMY,aAAa,GAAGd,gBAAgB,CAAC,MAAM;AAC3C,UAAMe,MAAM,GAAGT,QAAQ,CAACM,KAAT,GAAiBV,gBAAhC;AAEA,WAAO;AACLc,MAAAA,aAAa,EAAED,MAAM,GAAG,MAAH,GAAY,MAD5B;AAELE,MAAAA,2BAA2B,EAAE,CAACF,MAFzB;AAGLG,MAAAA,yBAAyB,EAAEH,MAAM,GAAG,MAAH,GAAY;AAHxC,KAAP;AAKD,GARqC,CAAtC;AAUA,sBACE,oBAAC,QAAD,CAAU,IAAV,eACMN,KADN;AAEE,IAAA,GAAG,EAAEJ,GAFP;AAGE,IAAA,KAAK,EAAE,CAACc,MAAM,CAACC,OAAR,EAAiBC,YAAjB,EAA+BX,aAA/B,EAA8CF,KAA9C,CAHT;AAIE,IAAA,aAAa,EAAEM;AAJjB,mBAME,oBAAC,SAAD;AAAW,IAAA,OAAO,EAAEP,OAApB;AAA6B,IAAA,KAAK,EAAEY,MAAM,CAACG;AAA3C,IANF,CADF;AAUD,CAjCe,CAAhB;AAmCA,MAAMD,YAAY,GAAGzB,QAAQ,CAAC2B,MAAT,CAAwC;AAC3DC,EAAAA,GAAG,EAAE;AACH;AACA;AACAC,IAAAA,uBAAuB,EAAE;AAHtB,GADsD;AAM3DC,EAAAA,OAAO,EAAE;AANkD,CAAxC,CAArB;AASA,MAAMP,MAAM,GAAGrB,UAAU,CAAC6B,MAAX,CAAkB;AAC/BP,EAAAA,OAAO,EAAE,EACP,GAAGtB,UAAU,CAAC8B,kBADP;AAEPC,IAAAA,eAAe,EAAE;AAFV,GADsB;AAK/BP,EAAAA,SAAS,EAAE;AACTQ,IAAAA,IAAI,EAAE;AADG;AALoB,CAAlB,CAAf;AAUA,eAAe3B,OAAf","sourcesContent":["import * as React from 'react';\nimport { Platform, Pressable, StyleSheet } from 'react-native';\nimport Animated, {\n useAnimatedProps,\n useAnimatedStyle,\n} from 'react-native-reanimated';\n\nconst PROGRESS_EPSILON = 0.05;\n\ntype Props = React.ComponentProps<typeof Animated.View> & {\n progress: Animated.SharedValue<number>;\n onPress: () => void;\n};\n\nconst Overlay = React.forwardRef(function Overlay(\n { progress, onPress, style, ...props }: Props,\n ref: React.Ref<Animated.View>\n) {\n const animatedStyle = useAnimatedStyle(() => {\n return {\n opacity: progress.value,\n // We don't want the user to be able to press through the overlay when drawer is open\n // We can send the overlay behind the screen to avoid it\n zIndex: progress.value > PROGRESS_EPSILON ? 0 : -1,\n };\n });\n\n const animatedProps = useAnimatedProps(() => {\n const active = progress.value > PROGRESS_EPSILON;\n\n return {\n pointerEvents: active ? 'auto' : 'none',\n accessibilityElementsHidden: !active,\n importantForAccessibility: active ? 'auto' : 'no-hide-descendants',\n } as const;\n });\n\n return (\n <Animated.View\n {...props}\n ref={ref}\n style={[styles.overlay, overlayStyle, animatedStyle, style]}\n animatedProps={animatedProps}\n >\n <Pressable onPress={onPress} style={styles.pressable} />\n </Animated.View>\n );\n});\n\nconst overlayStyle = Platform.select<Record<string, string>>({\n web: {\n // Disable touch highlight on mobile Safari.\n // WebkitTapHighlightColor must be used outside of StyleSheet.create because react-native-web will omit the property.\n WebkitTapHighlightColor: 'transparent',\n },\n default: {},\n});\n\nconst styles = StyleSheet.create({\n overlay: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0, 0, 0, 0.5)',\n },\n pressable: {\n flex: 1,\n },\n});\n\nexport default Overlay;\n"]}
@@ -22,4 +22,4 @@ export { default as useDrawerStatus } from './utils/useDrawerStatus';
22
22
  /**
23
23
  * Types
24
24
  */
25
- export type { DrawerContentComponentProps, DrawerHeaderProps, DrawerNavigationOptions, DrawerNavigationProp, DrawerScreenProps, } from './types';
25
+ export type { DrawerContentComponentProps, DrawerHeaderProps, DrawerNavigationEventMap, DrawerNavigationOptions, DrawerNavigationProp, DrawerScreenProps, } from './types';
@@ -2,6 +2,6 @@
2
2
  import { DefaultNavigatorOptions, DrawerNavigationState, DrawerRouterOptions, ParamListBase } from '@react-navigation/native';
3
3
  import type { DrawerNavigationConfig, DrawerNavigationEventMap, DrawerNavigationOptions } from '../types';
4
4
  declare type Props = DefaultNavigatorOptions<ParamListBase, DrawerNavigationState<ParamListBase>, DrawerNavigationOptions, DrawerNavigationEventMap> & DrawerRouterOptions & DrawerNavigationConfig;
5
- declare function DrawerNavigator({ initialRouteName, defaultStatus, backBehavior, children, screenListeners, screenOptions, openByDefault, lazy, drawerContentOptions, ...rest }: Props): JSX.Element;
5
+ declare function DrawerNavigator({ initialRouteName, defaultStatus: customDefaultStatus, backBehavior, children, screenListeners, screenOptions, ...restWithDeprecated }: Props): JSX.Element;
6
6
  declare const _default: <ParamList extends ParamListBase>() => import("@react-navigation/native").TypedNavigator<ParamList, DrawerNavigationState<ParamListBase>, DrawerNavigationOptions, DrawerNavigationEventMap, typeof DrawerNavigator>;
7
7
  export default _default;
@@ -1,3 +1,4 @@
1
+ import type { DrawerStatus } from '@react-navigation/native';
1
2
  import * as React from 'react';
2
- declare const DrawerStatusContext: React.Context<"open" | "closed" | undefined>;
3
+ declare const DrawerStatusContext: React.Context<DrawerStatus | undefined>;
3
4
  export default DrawerStatusContext;
@@ -1,2 +1,2 @@
1
- import type { DrawerNavigationState, ParamListBase } from '@react-navigation/native';
2
- export default function getDrawerStatusFromState(state: DrawerNavigationState<ParamListBase>): "open" | "closed";
1
+ import type { DrawerNavigationState, DrawerStatus, ParamListBase } from '@react-navigation/native';
2
+ export default function getDrawerStatusFromState(state: DrawerNavigationState<ParamListBase>): DrawerStatus;
@@ -1,5 +1,6 @@
1
+ import type { DrawerStatus } from '@react-navigation/native';
1
2
  /**
2
3
  * Hook to detect if the drawer's status in a parent navigator.
3
4
  * Returns 'open' if the drawer is open, 'closed' if the drawer is closed.
4
5
  */
5
- export default function useDrawerStatus(): "open" | "closed";
6
+ export default function useDrawerStatus(): DrawerStatus;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { DrawerNavigationState, ParamListBase } from '@react-navigation/native';
2
+ import { DrawerNavigationState, DrawerStatus, ParamListBase } from '@react-navigation/native';
3
3
  import type { DrawerDescriptorMap, DrawerNavigationConfig, DrawerNavigationHelpers } from '../types';
4
4
  declare type Props = DrawerNavigationConfig & {
5
+ defaultStatus: DrawerStatus;
5
6
  state: DrawerNavigationState<ParamListBase>;
6
7
  navigation: DrawerNavigationHelpers;
7
8
  descriptors: DrawerDescriptorMap;
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import Animated from 'react-native-reanimated';
3
3
  declare const Overlay: React.ForwardRefExoticComponent<{
4
+ children?: React.ReactNode | Animated.Node<React.ReactNode>;
4
5
  hitSlop?: import("react-native").Insets | Animated.Node<import("react-native").Insets | undefined> | undefined;
5
6
  onLayout?: ((event: import("react-native").LayoutChangeEvent) => void) | Animated.Node<((event: import("react-native").LayoutChangeEvent) => void) | undefined> | undefined;
6
7
  pointerEvents?: "none" | "auto" | "box-none" | "box-only" | Animated.Node<"none" | "auto" | "box-none" | "box-only" | undefined> | undefined;
@@ -61,6 +62,9 @@ declare const Overlay: React.ForwardRefExoticComponent<{
61
62
  accessibilityIgnoresInvertColors?: boolean | Animated.Node<boolean | undefined> | undefined;
62
63
  } & {
63
64
  animatedProps?: Partial<Animated.AnimateProps<import("react-native").ViewProps>> | undefined;
65
+ layout?: import("react-native-reanimated").BaseAnimationBuilder | import("react-native-reanimated").LayoutAnimationFunction | typeof import("react-native-reanimated").BaseAnimationBuilder | undefined;
66
+ entering?: import("react-native-reanimated").BaseAnimationBuilder | typeof import("react-native-reanimated").BaseAnimationBuilder | import("react-native-reanimated").EntryExitAnimationFunction | import("react-native-reanimated").Keyframe | undefined;
67
+ exiting?: import("react-native-reanimated").BaseAnimationBuilder | typeof import("react-native-reanimated").BaseAnimationBuilder | import("react-native-reanimated").EntryExitAnimationFunction | import("react-native-reanimated").Keyframe | undefined;
64
68
  } & {
65
69
  progress: Animated.Node<number>;
66
70
  onPress: () => void;
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import Animated from 'react-native-reanimated';
3
3
  declare const Overlay: React.ForwardRefExoticComponent<{
4
+ children?: React.ReactNode | Animated.Node<React.ReactNode>;
4
5
  hitSlop?: import("react-native").Insets | Animated.Node<import("react-native").Insets | undefined> | undefined;
5
6
  onLayout?: ((event: import("react-native").LayoutChangeEvent) => void) | Animated.Node<((event: import("react-native").LayoutChangeEvent) => void) | undefined> | undefined;
6
7
  pointerEvents?: "none" | "auto" | "box-none" | "box-only" | Animated.Node<"none" | "auto" | "box-none" | "box-only" | undefined> | undefined;
@@ -61,6 +62,9 @@ declare const Overlay: React.ForwardRefExoticComponent<{
61
62
  accessibilityIgnoresInvertColors?: boolean | Animated.Node<boolean | undefined> | undefined;
62
63
  } & {
63
64
  animatedProps?: Partial<Animated.AnimateProps<import("react-native").ViewProps>> | undefined;
65
+ layout?: import("react-native-reanimated").BaseAnimationBuilder | import("react-native-reanimated").LayoutAnimationFunction | typeof import("react-native-reanimated").BaseAnimationBuilder | undefined;
66
+ entering?: import("react-native-reanimated").BaseAnimationBuilder | typeof import("react-native-reanimated").BaseAnimationBuilder | import("react-native-reanimated").EntryExitAnimationFunction | import("react-native-reanimated").Keyframe | undefined;
67
+ exiting?: import("react-native-reanimated").BaseAnimationBuilder | typeof import("react-native-reanimated").BaseAnimationBuilder | import("react-native-reanimated").EntryExitAnimationFunction | import("react-native-reanimated").Keyframe | undefined;
64
68
  } & {
65
69
  progress: Animated.SharedValue<number>;
66
70
  onPress: () => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/drawer",
3
3
  "description": "Drawer navigator component with animated transitions and gesturess",
4
- "version": "6.1.5",
4
+ "version": "6.2.0",
5
5
  "keywords": [
6
6
  "react-native-component",
7
7
  "react-component",
@@ -41,23 +41,23 @@
41
41
  "clean": "del lib"
42
42
  },
43
43
  "dependencies": {
44
- "@react-navigation/elements": "^1.1.1",
44
+ "@react-navigation/elements": "^1.3.0",
45
45
  "color": "^3.1.3",
46
46
  "warn-once": "^0.1.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@react-navigation/native": "^6.0.3",
49
+ "@react-navigation/native": "^6.0.7",
50
50
  "@testing-library/react-native": "^7.2.0",
51
51
  "@types/react": "^17.0.9",
52
52
  "@types/react-native": "~0.64.9",
53
53
  "del-cli": "^3.0.1",
54
- "react": "~16.13.1",
55
- "react-native": "~0.63.4",
54
+ "react": "17.0.1",
55
+ "react-native": "~0.64.3",
56
56
  "react-native-builder-bob": "^0.18.1",
57
- "react-native-gesture-handler": "~1.10.2",
58
- "react-native-reanimated": "~2.2.0",
59
- "react-native-safe-area-context": "~3.2.0",
60
- "react-native-screens": "~3.3.0",
57
+ "react-native-gesture-handler": "~2.1.0",
58
+ "react-native-reanimated": "~2.3.1",
59
+ "react-native-safe-area-context": "3.3.2",
60
+ "react-native-screens": "~3.10.1",
61
61
  "typescript": "^4.3.2"
62
62
  },
63
63
  "peerDependencies": {
@@ -83,5 +83,5 @@
83
83
  ]
84
84
  ]
85
85
  },
86
- "gitHead": "38ac69f17ee314f96d3d4bcee02349fa4a02d422"
86
+ "gitHead": "4c5805867ce946d99ba17f71b4d6086bb8751262"
87
87
  }
package/src/index.tsx CHANGED
@@ -28,6 +28,7 @@ export { default as useDrawerStatus } from './utils/useDrawerStatus';
28
28
  export type {
29
29
  DrawerContentComponentProps,
30
30
  DrawerHeaderProps,
31
+ DrawerNavigationEventMap,
31
32
  DrawerNavigationOptions,
32
33
  DrawerNavigationProp,
33
34
  DrawerScreenProps,
@@ -5,6 +5,7 @@ import {
5
5
  DrawerNavigationState,
6
6
  DrawerRouter,
7
7
  DrawerRouterOptions,
8
+ DrawerStatus,
8
9
  ParamListBase,
9
10
  useNavigationBuilder,
10
11
  } from '@react-navigation/native';
@@ -29,19 +30,23 @@ type Props = DefaultNavigatorOptions<
29
30
 
30
31
  function DrawerNavigator({
31
32
  initialRouteName,
32
- defaultStatus,
33
+ defaultStatus: customDefaultStatus,
33
34
  backBehavior,
34
35
  children,
35
36
  screenListeners,
36
37
  screenOptions,
37
- // @ts-expect-error: openByDefault is deprecated
38
- openByDefault,
39
- // @ts-expect-error: lazy is deprecated
40
- lazy,
41
- // @ts-expect-error: drawerContentOptions is deprecated
42
- drawerContentOptions,
43
- ...rest
38
+ ...restWithDeprecated
44
39
  }: Props) {
40
+ const {
41
+ // @ts-expect-error: openByDefault is deprecated
42
+ openByDefault,
43
+ // @ts-expect-error: lazy is deprecated
44
+ lazy,
45
+ // @ts-expect-error: drawerContentOptions is deprecated
46
+ drawerContentOptions,
47
+ ...rest
48
+ } = restWithDeprecated;
49
+
45
50
  let defaultScreenOptions: DrawerNavigationOptions = {};
46
51
 
47
52
  if (drawerContentOptions) {
@@ -92,6 +97,13 @@ function DrawerNavigator({
92
97
  );
93
98
  }
94
99
 
100
+ const defaultStatus: DrawerStatus =
101
+ customDefaultStatus !== undefined
102
+ ? customDefaultStatus
103
+ : openByDefault
104
+ ? 'open'
105
+ : 'closed';
106
+
95
107
  const { state, descriptors, navigation, NavigationContent } =
96
108
  useNavigationBuilder<
97
109
  DrawerNavigationState<ParamListBase>,
@@ -101,12 +113,7 @@ function DrawerNavigator({
101
113
  DrawerNavigationEventMap
102
114
  >(DrawerRouter, {
103
115
  initialRouteName,
104
- defaultStatus:
105
- defaultStatus !== undefined
106
- ? defaultStatus
107
- : openByDefault
108
- ? 'open'
109
- : 'closed',
116
+ defaultStatus,
110
117
  backBehavior,
111
118
  children,
112
119
  screenListeners,
@@ -118,6 +125,7 @@ function DrawerNavigator({
118
125
  <NavigationContent>
119
126
  <DrawerView
120
127
  {...rest}
128
+ defaultStatus={defaultStatus}
121
129
  state={state}
122
130
  descriptors={descriptors}
123
131
  navigation={navigation}
@@ -1,6 +1,8 @@
1
+ import type { DrawerStatus } from '@react-navigation/native';
1
2
  import * as React from 'react';
2
3
 
3
- const DrawerStatusContext =
4
- React.createContext<'open' | 'closed' | undefined>(undefined);
4
+ const DrawerStatusContext = React.createContext<DrawerStatus | undefined>(
5
+ undefined
6
+ );
5
7
 
6
8
  export default DrawerStatusContext;
@@ -1,11 +1,12 @@
1
1
  import type {
2
2
  DrawerNavigationState,
3
+ DrawerStatus,
3
4
  ParamListBase,
4
5
  } from '@react-navigation/native';
5
6
 
6
7
  export default function getDrawerStatusFromState(
7
8
  state: DrawerNavigationState<ParamListBase>
8
- ) {
9
+ ): DrawerStatus {
9
10
  if (state.history == null) {
10
11
  throw new Error(
11
12
  "Couldn't find the drawer status in the state object. Is it a valid state object of drawer navigator?"
@@ -13,8 +14,8 @@ export default function getDrawerStatusFromState(
13
14
  }
14
15
 
15
16
  const entry = state.history.find((it) => it.type === 'drawer') as
16
- | { type: 'drawer'; status: 'open' }
17
+ | { type: 'drawer'; status: DrawerStatus }
17
18
  | undefined;
18
19
 
19
- return entry?.status ?? 'closed';
20
+ return entry?.status ?? state.default ?? 'closed';
20
21
  }
@@ -1,3 +1,4 @@
1
+ import type { DrawerStatus } from '@react-navigation/native';
1
2
  import * as React from 'react';
2
3
 
3
4
  import DrawerStatusContext from './DrawerStatusContext';
@@ -6,7 +7,7 @@ import DrawerStatusContext from './DrawerStatusContext';
6
7
  * Hook to detect if the drawer's status in a parent navigator.
7
8
  * Returns 'open' if the drawer is open, 'closed' if the drawer is closed.
8
9
  */
9
- export default function useDrawerStatus() {
10
+ export default function useDrawerStatus(): DrawerStatus {
10
11
  const drawerStatus = React.useContext(DrawerStatusContext);
11
12
 
12
13
  if (drawerStatus === undefined) {