react-native-tab-view 3.2.1 → 3.3.2

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 (66) hide show
  1. package/{LICENSE.md → LICENSE} +0 -0
  2. package/README.md +5 -36
  3. package/lib/commonjs/PagerViewAdapter.js +2 -1
  4. package/lib/commonjs/PagerViewAdapter.js.map +1 -1
  5. package/lib/commonjs/PanResponderAdapter.js +2 -1
  6. package/lib/commonjs/PanResponderAdapter.js.map +1 -1
  7. package/lib/commonjs/SceneMap.js +9 -12
  8. package/lib/commonjs/SceneMap.js.map +1 -1
  9. package/lib/commonjs/SceneView.js +54 -101
  10. package/lib/commonjs/SceneView.js.map +1 -1
  11. package/lib/commonjs/TabBar.js +358 -325
  12. package/lib/commonjs/TabBar.js.map +1 -1
  13. package/lib/commonjs/TabBarIndicator.js +81 -99
  14. package/lib/commonjs/TabBarIndicator.js.map +1 -1
  15. package/lib/commonjs/TabBarItem.js +184 -161
  16. package/lib/commonjs/TabBarItem.js.map +1 -1
  17. package/lib/commonjs/TabView.js +2 -2
  18. package/lib/commonjs/TabView.js.map +1 -1
  19. package/lib/commonjs/index.js +3 -3
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/module/PagerViewAdapter.js +2 -1
  22. package/lib/module/PagerViewAdapter.js.map +1 -1
  23. package/lib/module/PanResponderAdapter.js +3 -2
  24. package/lib/module/PanResponderAdapter.js.map +1 -1
  25. package/lib/module/SceneMap.js +9 -14
  26. package/lib/module/SceneMap.js.map +1 -1
  27. package/lib/module/SceneView.js +54 -99
  28. package/lib/module/SceneView.js.map +1 -1
  29. package/lib/module/TabBar.js +355 -324
  30. package/lib/module/TabBar.js.map +1 -1
  31. package/lib/module/TabBarIndicator.js +75 -93
  32. package/lib/module/TabBarIndicator.js.map +1 -1
  33. package/lib/module/TabBarItem.js +178 -154
  34. package/lib/module/TabBarItem.js.map +1 -1
  35. package/lib/module/TabView.js +2 -2
  36. package/lib/module/TabView.js.map +1 -1
  37. package/lib/module/index.js +2 -2
  38. package/lib/module/index.js.map +1 -1
  39. package/lib/typescript/{Pager.android.d.ts → src/Pager.android.d.ts} +0 -0
  40. package/lib/typescript/{Pager.d.ts → src/Pager.d.ts} +0 -0
  41. package/lib/typescript/{Pager.ios.d.ts → src/Pager.ios.d.ts} +0 -0
  42. package/lib/typescript/{PagerViewAdapter.d.ts → src/PagerViewAdapter.d.ts} +1 -1
  43. package/lib/typescript/{PanResponderAdapter.d.ts → src/PanResponderAdapter.d.ts} +1 -1
  44. package/lib/typescript/{PlatformPressable.d.ts → src/PlatformPressable.d.ts} +0 -0
  45. package/lib/typescript/{SceneMap.d.ts → src/SceneMap.d.ts} +5 -3
  46. package/lib/typescript/src/SceneView.d.ts +15 -0
  47. package/lib/typescript/src/TabBar.d.ts +42 -0
  48. package/lib/typescript/src/TabBarIndicator.d.ts +12 -0
  49. package/lib/typescript/{TabBarItem.d.ts → src/TabBarItem.d.ts} +5 -7
  50. package/lib/typescript/{TabView.d.ts → src/TabView.d.ts} +1 -1
  51. package/lib/typescript/{index.d.ts → src/index.d.ts} +7 -7
  52. package/lib/typescript/{types.d.ts → src/types.d.ts} +0 -0
  53. package/lib/typescript/{useAnimatedValue.d.ts → src/useAnimatedValue.d.ts} +0 -0
  54. package/package.json +28 -58
  55. package/src/PagerViewAdapter.tsx +11 -5
  56. package/src/PanResponderAdapter.tsx +16 -12
  57. package/src/SceneMap.tsx +12 -7
  58. package/src/SceneView.tsx +73 -108
  59. package/src/TabBar.tsx +506 -401
  60. package/src/TabBarIndicator.tsx +114 -117
  61. package/src/TabBarItem.tsx +230 -200
  62. package/src/TabView.tsx +6 -5
  63. package/src/index.tsx +7 -12
  64. package/lib/typescript/SceneView.d.ts +0 -32
  65. package/lib/typescript/TabBar.d.ts +0 -72
  66. package/lib/typescript/TabBarIndicator.d.ts +0 -20
File without changes
package/README.md CHANGED
@@ -1,14 +1,7 @@
1
1
  # React Native Tab View
2
2
 
3
- [![Build Status][build-badge]][build]
4
- [![Version][version-badge]][package]
5
- [![MIT License][license-badge]][license]
6
-
7
3
  A cross-platform Tab View component for React Native. Implemented using [`react-native-pager-view`](https://github.com/callstack/react-native-viewpager) on Android & iOS, and [PanResponder](https://reactnative.dev/docs/panresponder) on Web, macOS, and Windows.
8
4
 
9
- - [Run the example app to see it in action](https://expo.io/@satya164/react-native-tab-view-demos).
10
- - Checkout the [example/](https://github.com/satya164/react-native-tab-view/tree/main/example) folder for source code.
11
-
12
5
  ## Features
13
6
 
14
7
  - Smooth animations and gestures
@@ -20,7 +13,7 @@ A cross-platform Tab View component for React Native. Implemented using [`react-
20
13
 
21
14
  ## Demo
22
15
 
23
- <a href="https://raw.githubusercontent.com/satya164/react-native-tab-view/main/demo/demo.mp4"><img src="https://raw.githubusercontent.com/satya164/react-native-tab-view/main/demo/demo.gif" width="360"></a>
16
+ <a href="https://github.com/react-navigation/react-navigation/blob/main/packages/react-native-tab-view/demo/demo.gif"><img src="https://github.com/react-navigation/react-navigation/blob/main/packages/react-native-tab-view/demo/demo.gif" width="360"></a>
24
17
 
25
18
  ## React Native Compatibility
26
19
 
@@ -530,6 +523,10 @@ Style to apply to the tab bar container.
530
523
 
531
524
  Define a spacing between tabs.
532
525
 
526
+ ##### `testID`
527
+
528
+ Test id for the tabBar. Can be used for scrolling the tab bar in tests
529
+
533
530
  ## Using with other libraries
534
531
 
535
532
  ### [React Navigation](https://github.com/react-navigation/react-navigation)
@@ -646,31 +643,3 @@ Nesting the `TabView` inside a vertical `ScrollView` will disable the optimizati
646
643
  ### Use `lazy` and `renderLazyPlaceholder` props to render routes as needed
647
644
 
648
645
  The `lazy` option is disabled by default to provide a smoother tab switching experience, but you can enable it and provide a placeholder component for a better lazy loading experience. Enabling `lazy` can improve initial load performance by rendering routes only when they come into view. Refer the [prop reference](#lazy) for more details.
649
-
650
- ## Contributing
651
-
652
- While developing, you can run the [example app](/example/README.md) to test your changes.
653
-
654
- Make sure your code passes TypeScript and ESLint. Run the following to verify:
655
-
656
- ```sh
657
- yarn typescript
658
- yarn lint
659
- ```
660
-
661
- To fix formatting errors, run the following:
662
-
663
- ```sh
664
- yarn lint -- --fix
665
- ```
666
-
667
- Remember to add tests for your change if possible.
668
-
669
- <!-- badges -->
670
-
671
- [build-badge]: https://img.shields.io/circleci/project/github/satya164/react-native-tab-view/main.svg?style=flat-square
672
- [build]: https://circleci.com/gh/satya164/react-native-tab-view
673
- [version-badge]: https://img.shields.io/npm/v/react-native-tab-view.svg?style=flat-square
674
- [package]: https://www.npmjs.com/package/react-native-tab-view
675
- [license-badge]: https://img.shields.io/npm/l/react-native-tab-view.svg?style=flat-square
676
- [license]: https://opensource.org/licenses/MIT
@@ -121,8 +121,9 @@ function PagerViewAdapter(_ref) {
121
121
  }
122
122
  };
123
123
  }, []);
124
+ const memoizedPosition = React.useMemo(() => _reactNative.Animated.add(position, offset), [offset, position]);
124
125
  return children({
125
- position: _reactNative.Animated.add(position, offset),
126
+ position: memoizedPosition,
126
127
  addEnterListener,
127
128
  jumpTo,
128
129
  render: children => /*#__PURE__*/React.createElement(AnimatedViewPager, _extends({}, rest, {
@@ -1 +1 @@
1
- {"version":3,"names":["AnimatedViewPager","Animated","createAnimatedComponent","ViewPager","PagerViewAdapter","keyboardDismissMode","swipeEnabled","navigationState","onIndexChange","onSwipeStart","onSwipeEnd","children","style","animationEnabled","rest","index","listenersRef","React","useRef","pagerRef","indexRef","navigationStateRef","position","useAnimatedValue","offset","useEffect","current","jumpTo","useCallback","key","routes","findIndex","route","setPage","setPageWithoutAnimation","setValue","Keyboard","dismiss","onPageScrollStateChanged","state","pageScrollState","nativeEvent","subscription","addListener","value","next","Math","ceil","floor","forEach","listener","removeListener","addEnterListener","push","indexOf","splice","add","render","styles","container","event","useNativeDriver","e","StyleSheet","create","flex"],"sources":["PagerViewAdapter.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Animated, Keyboard, StyleSheet } from 'react-native';\nimport ViewPager, {\n PageScrollStateChangedNativeEvent,\n} from 'react-native-pager-view';\nimport useAnimatedValue from './useAnimatedValue';\nimport type {\n NavigationState,\n Route,\n Listener,\n EventEmitterProps,\n PagerProps,\n} from './types';\n\nconst AnimatedViewPager = Animated.createAnimatedComponent(ViewPager);\n\ntype Props<T extends Route> = PagerProps & {\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n children: (\n props: EventEmitterProps & {\n // Animated value which represents the state of current index\n // It can include fractional digits as it represents the intermediate value\n position: Animated.AnimatedInterpolation;\n // Function to actually render the content of the pager\n // The parent component takes care of rendering\n render: (children: React.ReactNode) => React.ReactNode;\n // Callback to call when switching the tab\n // The tab switch animation is performed even if the index in state is unchanged\n jumpTo: (key: string) => void;\n }\n ) => React.ReactElement;\n};\n\nexport default function PagerViewAdapter<T extends Route>({\n keyboardDismissMode = 'auto',\n swipeEnabled = true,\n navigationState,\n onIndexChange,\n onSwipeStart,\n onSwipeEnd,\n children,\n style,\n animationEnabled,\n ...rest\n}: Props<T>) {\n const { index } = navigationState;\n\n const listenersRef = React.useRef<Listener[]>([]);\n\n const pagerRef = React.useRef<ViewPager>();\n const indexRef = React.useRef<number>(index);\n const navigationStateRef = React.useRef(navigationState);\n\n const position = useAnimatedValue(index);\n const offset = useAnimatedValue(0);\n\n React.useEffect(() => {\n navigationStateRef.current = navigationState;\n });\n\n const jumpTo = React.useCallback(\n (key: string) => {\n const index = navigationStateRef.current.routes.findIndex(\n (route: { key: string }) => route.key === key\n );\n\n if (animationEnabled) {\n pagerRef.current?.setPage(index);\n } else {\n pagerRef.current?.setPageWithoutAnimation(index);\n position.setValue(index);\n }\n },\n [animationEnabled, position]\n );\n\n React.useEffect(() => {\n if (keyboardDismissMode === 'auto') {\n Keyboard.dismiss();\n }\n\n if (indexRef.current !== index) {\n if (animationEnabled) {\n pagerRef.current?.setPage(index);\n } else {\n pagerRef.current?.setPageWithoutAnimation(index);\n position.setValue(index);\n }\n }\n }, [keyboardDismissMode, index, animationEnabled, position]);\n\n const onPageScrollStateChanged = (\n state: PageScrollStateChangedNativeEvent\n ) => {\n const { pageScrollState } = state.nativeEvent;\n\n switch (pageScrollState) {\n case 'idle':\n onSwipeEnd?.();\n return;\n case 'dragging': {\n const subscription = offset.addListener(({ value }) => {\n const next =\n index + (value > 0 ? Math.ceil(value) : Math.floor(value));\n\n if (next !== index) {\n listenersRef.current.forEach((listener) => listener(next));\n }\n\n offset.removeListener(subscription);\n });\n\n onSwipeStart?.();\n return;\n }\n }\n };\n\n const addEnterListener = React.useCallback((listener: Listener) => {\n listenersRef.current.push(listener);\n\n return () => {\n const index = listenersRef.current.indexOf(listener);\n\n if (index > -1) {\n listenersRef.current.splice(index, 1);\n }\n };\n }, []);\n\n return children({\n position: Animated.add(position, offset),\n addEnterListener,\n jumpTo,\n render: (children) => (\n <AnimatedViewPager\n {...rest}\n ref={pagerRef}\n style={[styles.container, style]}\n initialPage={index}\n keyboardDismissMode={\n keyboardDismissMode === 'auto' ? 'on-drag' : keyboardDismissMode\n }\n onPageScroll={Animated.event(\n [\n {\n nativeEvent: {\n position: position,\n offset: offset,\n },\n },\n ],\n { useNativeDriver: true }\n )}\n onPageSelected={(e) => {\n const index = e.nativeEvent.position;\n indexRef.current = index;\n onIndexChange(index);\n }}\n onPageScrollStateChanged={onPageScrollStateChanged}\n scrollEnabled={swipeEnabled}\n >\n {children}\n </AnimatedViewPager>\n ),\n });\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAGA;;;;;;;;;;AASA,MAAMA,iBAAiB,GAAGC,qBAAA,CAASC,uBAAT,CAAiCC,6BAAjC,CAA1B;;AAoBe,SAASC,gBAAT,OAWF;EAAA,IAX6C;IACxDC,mBAAmB,GAAG,MADkC;IAExDC,YAAY,GAAG,IAFyC;IAGxDC,eAHwD;IAIxDC,aAJwD;IAKxDC,YALwD;IAMxDC,UANwD;IAOxDC,QAPwD;IAQxDC,KARwD;IASxDC,gBATwD;IAUx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createAnimatedComponent","ViewPager","PagerViewAdapter","keyboardDismissMode","swipeEnabled","navigationState","onIndexChange","onSwipeStart","onSwipeEnd","children","style","animationEnabled","rest","index","listenersRef","React","useRef","pagerRef","indexRef","navigationStateRef","position","useAnimatedValue","offset","useEffect","current","jumpTo","useCallback","key","routes","findIndex","route","setPage","setPageWithoutAnimation","setValue","Keyboard","dismiss","onPageScrollStateChanged","state","pageScrollState","nativeEvent","subscription","addListener","value","next","Math","ceil","floor","forEach","listener","removeListener","addEnterListener","push","indexOf","splice","memoizedPosition","useMemo","add","render","styles","container","event","useNativeDriver","e","StyleSheet","create","flex"],"sources":["PagerViewAdapter.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Animated, Keyboard, StyleSheet } from 'react-native';\nimport ViewPager, {\n PageScrollStateChangedNativeEvent,\n} from 'react-native-pager-view';\n\nimport type {\n EventEmitterProps,\n Listener,\n NavigationState,\n PagerProps,\n Route,\n} from './types';\nimport useAnimatedValue from './useAnimatedValue';\n\nconst AnimatedViewPager = Animated.createAnimatedComponent(ViewPager);\n\ntype Props<T extends Route> = PagerProps & {\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n children: (\n props: EventEmitterProps & {\n // Animated value which represents the state of current index\n // It can include fractional digits as it represents the intermediate value\n position: Animated.AnimatedInterpolation;\n // Function to actually render the content of the pager\n // The parent component takes care of rendering\n render: (children: React.ReactNode) => React.ReactNode;\n // Callback to call when switching the tab\n // The tab switch animation is performed even if the index in state is unchanged\n jumpTo: (key: string) => void;\n }\n ) => React.ReactElement;\n};\n\nexport default function PagerViewAdapter<T extends Route>({\n keyboardDismissMode = 'auto',\n swipeEnabled = true,\n navigationState,\n onIndexChange,\n onSwipeStart,\n onSwipeEnd,\n children,\n style,\n animationEnabled,\n ...rest\n}: Props<T>) {\n const { index } = navigationState;\n\n const listenersRef = React.useRef<Listener[]>([]);\n\n const pagerRef = React.useRef<ViewPager>();\n const indexRef = React.useRef<number>(index);\n const navigationStateRef = React.useRef(navigationState);\n\n const position = useAnimatedValue(index);\n const offset = useAnimatedValue(0);\n\n React.useEffect(() => {\n navigationStateRef.current = navigationState;\n });\n\n const jumpTo = React.useCallback(\n (key: string) => {\n const index = navigationStateRef.current.routes.findIndex(\n (route: { key: string }) => route.key === key\n );\n\n if (animationEnabled) {\n pagerRef.current?.setPage(index);\n } else {\n pagerRef.current?.setPageWithoutAnimation(index);\n position.setValue(index);\n }\n },\n [animationEnabled, position]\n );\n\n React.useEffect(() => {\n if (keyboardDismissMode === 'auto') {\n Keyboard.dismiss();\n }\n\n if (indexRef.current !== index) {\n if (animationEnabled) {\n pagerRef.current?.setPage(index);\n } else {\n pagerRef.current?.setPageWithoutAnimation(index);\n position.setValue(index);\n }\n }\n }, [keyboardDismissMode, index, animationEnabled, position]);\n\n const onPageScrollStateChanged = (\n state: PageScrollStateChangedNativeEvent\n ) => {\n const { pageScrollState } = state.nativeEvent;\n\n switch (pageScrollState) {\n case 'idle':\n onSwipeEnd?.();\n return;\n case 'dragging': {\n const subscription = offset.addListener(({ value }) => {\n const next =\n index + (value > 0 ? Math.ceil(value) : Math.floor(value));\n\n if (next !== index) {\n listenersRef.current.forEach((listener) => listener(next));\n }\n\n offset.removeListener(subscription);\n });\n\n onSwipeStart?.();\n return;\n }\n }\n };\n\n const addEnterListener = React.useCallback((listener: Listener) => {\n listenersRef.current.push(listener);\n\n return () => {\n const index = listenersRef.current.indexOf(listener);\n\n if (index > -1) {\n listenersRef.current.splice(index, 1);\n }\n };\n }, []);\n\n const memoizedPosition = React.useMemo(\n () => Animated.add(position, offset),\n [offset, position]\n );\n\n return children({\n position: memoizedPosition,\n addEnterListener,\n jumpTo,\n render: (children) => (\n <AnimatedViewPager\n {...rest}\n ref={pagerRef}\n style={[styles.container, style]}\n initialPage={index}\n keyboardDismissMode={\n keyboardDismissMode === 'auto' ? 'on-drag' : keyboardDismissMode\n }\n onPageScroll={Animated.event(\n [\n {\n nativeEvent: {\n position: position,\n offset: offset,\n },\n },\n ],\n { useNativeDriver: true }\n )}\n onPageSelected={(e) => {\n const index = e.nativeEvent.position;\n indexRef.current = index;\n onIndexChange(index);\n }}\n onPageScrollStateChanged={onPageScrollStateChanged}\n scrollEnabled={swipeEnabled}\n >\n {children}\n </AnimatedViewPager>\n ),\n });\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAWA;;;;;;;;;;AAEA,MAAMA,iBAAiB,GAAGC,qBAAA,CAASC,uBAAT,CAAiCC,6BAAjC,CAA1B;;AAoBe,SAASC,gBAAT,OAWF;EAAA,IAX6C;IACxDC,mBAAmB,GAAG,MADkC;IAExDC,YAAY,GAAG,IAFyC;IAGxDC,eAHwD;IAIxDC,aAJwD;IAKxDC,YALwD;IAMxDC,UANwD;IAOxDC,QAPwD;IAQxDC,KARwD;IASxDC,gBATwD;IAUxD,GAAGC;EAVqD,CAW7C;EACX,MAAM;IAAEC;EAAF,IAAYR,eAAlB;EAEA,MAAMS,YAAY,GAAGC,KAAK,CAACC,MAAN,CAAyB,EAAzB,CAArB;EAEA,MAAMC,QAAQ,GAAGF,KAAK,CAACC,MAAN,EAAjB;EACA,MAAME,QAAQ,GAAGH,KAAK,CAACC,MAAN,CAAqBH,KAArB,CAAjB;EACA,MAAMM,kBAAkB,GAAGJ,KAAK,CAACC,MAAN,CAAaX,eAAb,CAA3B;EAEA,MAAMe,QAAQ,GAAG,IAAAC,yBAAA,EAAiBR,KAAjB,CAAjB;EACA,MAAMS,MAAM,GAAG,IAAAD,yBAAA,EAAiB,CAAjB,CAAf;EAEAN,KAAK,CAACQ,SAAN,CAAgB,MAAM;IACpBJ,kBAAkB,CAACK,OAAnB,GAA6BnB,eAA7B;EACD,CAFD;EAIA,MAAMoB,MAAM,GAAGV,KAAK,CAACW,WAAN,CACZC,GAAD,IAAiB;IACf,MAAMd,KAAK,GAAGM,kBAAkB,CAACK,OAAnB,CAA2BI,MAA3B,CAAkCC,SAAlC,C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,mBAAmB,KAAK,MAAxB,GAAiC,SAAjC,GAA6CA,mBANjD;MAQE,YAAY,EAAEJ,qBAAA,CAAS6D,KAAT,CACZ,CACE;QACErB,WAAW,EAAE;UACXnB,QAAQ,EAAEA,QADC;UAEXE,MAAM,EAAEA;QAFG;MADf,CADF,CADY,EASZ;QAAEuC,eAAe,EAAE;MAAnB,CATY,CARhB;MAmBE,cAAc,EAAGC,CAAD,IAAO;QACrB,MAAMjD,KAAK,GAAGiD,CAAC,CAACvB,WAAF,CAAcnB,QAA5B;QACAF,QAAQ,CAACM,OAAT,GAAmBX,KAAnB;QACAP,aAAa,CAACO,KAAD,CAAb;MACD,CAvBH;MAwBE,wBAAwB,EAAEuB,wBAxB5B;MAyBE,aAAa,EAAEhC;IAzBjB,IA2BGK,QA3BH;EALY,CAAD,CAAf;AAoCD;;AAED,MAAMiD,MAAM,GAAGK,uBAAA,CAAWC,MAAX,CAAkB;EAC/BL,SAAS,EAAE;IACTM,IAAI,EAAE;EADG;AADoB,CAAlB,CAAf"}
@@ -203,8 +203,9 @@ function PanResponderAdapter(_ref) {
203
203
  extrapolate: 'clamp'
204
204
  }), _reactNative.I18nManager.isRTL ? -1 : 1);
205
205
 
206
+ const position = React.useMemo(() => layout.width ? _reactNative.Animated.divide(panX, -layout.width) : null, [layout.width, panX]);
206
207
  return children({
207
- position: layout.width ? _reactNative.Animated.divide(panX, -layout.width) : new _reactNative.Animated.Value(index),
208
+ position: position !== null && position !== void 0 ? position : new _reactNative.Animated.Value(index),
208
209
  addEnterListener,
209
210
  jumpTo,
210
211
  render: children => /*#__PURE__*/React.createElement(_reactNative.Animated.View, _extends({
@@ -1 +1 @@
1
- {"version":3,"names":["DEAD_ZONE","DefaultTransitionSpec","timing","Animated","spring","stiffness","damping","mass","overshootClamping","PanResponderAdapter","layout","keyboardDismissMode","swipeEnabled","navigationState","onIndexChange","onSwipeStart","onSwipeEnd","children","style","animationEnabled","routes","index","panX","useAnimatedValue","listenersRef","React","useRef","navigationStateRef","layoutRef","onIndexChangeRef","currentIndexRef","pendingIndexRef","swipeVelocityThreshold","swipeDistanceThreshold","width","jumpToIndex","useCallback","animate","offset","current","transitionConfig","parallel","toValue","useNativeDriver","start","finished","undefined","setValue","useEffect","Keyboard","dismiss","isMovingHorizontally","_","gestureState","Math","abs","dx","dy","vx","vy","canMoveScreen","event","diffX","I18nManager","isRTL","length","startGesture","stopAnimation","setOffset","_value","respondToGesture","position","_offset","next","ceil","floor","forEach","listener","finishGesture","flattenOffset","currentIndex","nextIndex","round","min","max","isFinite","addEnterListener","push","indexOf","splice","jumpTo","key","findIndex","route","panResponder","PanResponder","create","onMoveShouldSetPanResponder","onMoveShouldSetPanResponderCapture","onPanResponderGrant","onPanResponderMove","onPanResponderTerminate","onPanResponderRelease","onPanResponderTerminationRequest","maxTranslate","translateX","multiply","interpolate","inputRange","outputRange","extrapolate","divide","Value","render","styles","sheet","transform","panHandlers","Children","map","child","i","focused","StyleSheet","absoluteFill","flex","flexDirection","alignItems"],"sources":["PanResponderAdapter.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n PanResponder,\n Keyboard,\n StyleSheet,\n GestureResponderEvent,\n PanResponderGestureState,\n I18nManager,\n View,\n} from 'react-native';\nimport useAnimatedValue from './useAnimatedValue';\nimport type {\n NavigationState,\n Route,\n Layout,\n EventEmitterProps,\n PagerProps,\n Listener,\n} from './types';\n\ntype Props<T extends Route> = PagerProps & {\n layout: Layout;\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n children: (\n props: EventEmitterProps & {\n // Animated value which represents the state of current index\n // It can include fractional digits as it represents the intermediate value\n position: Animated.AnimatedInterpolation;\n // Function to actually render the content of the pager\n // The parent component takes care of rendering\n render: (children: React.ReactNode) => React.ReactNode;\n // Callback to call when switching the tab\n // The tab switch animation is performed even if the index in state is unchanged\n jumpTo: (key: string) => void;\n }\n ) => React.ReactElement;\n};\n\nconst DEAD_ZONE = 12;\n\nconst DefaultTransitionSpec = {\n timing: Animated.spring,\n stiffness: 1000,\n damping: 500,\n mass: 3,\n overshootClamping: true,\n};\n\nexport default function PanResponderAdapter<T extends Route>({\n layout,\n keyboardDismissMode = 'auto',\n swipeEnabled = true,\n navigationState,\n onIndexChange,\n onSwipeStart,\n onSwipeEnd,\n children,\n style,\n animationEnabled = false,\n}: Props<T>) {\n const { routes, index } = navigationState;\n\n const panX = useAnimatedValue(0);\n\n const listenersRef = React.useRef<Listener[]>([]);\n\n const navigationStateRef = React.useRef(navigationState);\n const layoutRef = React.useRef(layout);\n const onIndexChangeRef = React.useRef(onIndexChange);\n\n const currentIndexRef = React.useRef(index);\n const pendingIndexRef = React.useRef<number>();\n\n const swipeVelocityThreshold = 0.15;\n const swipeDistanceThreshold = layout.width / 1.75;\n\n const jumpToIndex = React.useCallback(\n (index: number, animate = animationEnabled) => {\n const offset = -index * layoutRef.current.width;\n\n const { timing, ...transitionConfig } = DefaultTransitionSpec;\n\n if (animate) {\n Animated.parallel([\n timing(panX, {\n ...transitionConfig,\n toValue: offset,\n useNativeDriver: false,\n }),\n ]).start(({ finished }) => {\n if (finished) {\n onIndexChangeRef.current(index);\n pendingIndexRef.current = undefined;\n }\n });\n pendingIndexRef.current = index;\n } else {\n panX.setValue(offset);\n onIndexChangeRef.current(index);\n pendingIndexRef.current = undefined;\n }\n },\n [animationEnabled, panX]\n );\n\n React.useEffect(() => {\n navigationStateRef.current = navigationState;\n layoutRef.current = layout;\n onIndexChangeRef.current = onIndexChange;\n });\n\n React.useEffect(() => {\n const offset = -navigationStateRef.current.index * layout.width;\n\n panX.setValue(offset);\n }, [layout.width, panX]);\n\n React.useEffect(() => {\n if (keyboardDismissMode === 'auto') {\n Keyboard.dismiss();\n }\n\n if (layout.width && currentIndexRef.current !== index) {\n currentIndexRef.current = index;\n jumpToIndex(index);\n }\n }, [jumpToIndex, keyboardDismissMode, layout.width, index]);\n\n const isMovingHorizontally = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n return (\n Math.abs(gestureState.dx) > Math.abs(gestureState.dy * 2) &&\n Math.abs(gestureState.vx) > Math.abs(gestureState.vy * 2)\n );\n };\n\n const canMoveScreen = (\n event: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n if (swipeEnabled === false) {\n return false;\n }\n\n const diffX = I18nManager.isRTL ? -gestureState.dx : gestureState.dx;\n\n return (\n isMovingHorizontally(event, gestureState) &&\n ((diffX >= DEAD_ZONE && currentIndexRef.current > 0) ||\n (diffX <= -DEAD_ZONE && currentIndexRef.current < routes.length - 1))\n );\n };\n\n const startGesture = () => {\n onSwipeStart?.();\n\n if (keyboardDismissMode === 'on-drag') {\n Keyboard.dismiss();\n }\n\n panX.stopAnimation();\n // @ts-expect-error: _value is private, but docs use it as well\n panX.setOffset(panX._value);\n };\n\n const respondToGesture = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n const diffX = I18nManager.isRTL ? -gestureState.dx : gestureState.dx;\n\n if (\n // swiping left\n (diffX > 0 && index <= 0) ||\n // swiping right\n (diffX < 0 && index >= routes.length - 1)\n ) {\n return;\n }\n\n if (layout.width) {\n // @ts-expect-error: _offset is private, but docs use it as well\n const position = (panX._offset + diffX) / -layout.width;\n const next =\n position > index ? Math.ceil(position) : Math.floor(position);\n\n if (next !== index) {\n listenersRef.current.forEach((listener) => listener(next));\n }\n }\n\n panX.setValue(diffX);\n };\n\n const finishGesture = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n panX.flattenOffset();\n\n onSwipeEnd?.();\n\n const currentIndex =\n typeof pendingIndexRef.current === 'number'\n ? pendingIndexRef.current\n : currentIndexRef.current;\n\n let nextIndex = currentIndex;\n\n if (\n Math.abs(gestureState.dx) > Math.abs(gestureState.dy) &&\n Math.abs(gestureState.vx) > Math.abs(gestureState.vy) &&\n (Math.abs(gestureState.dx) > swipeDistanceThreshold ||\n Math.abs(gestureState.vx) > swipeVelocityThreshold)\n ) {\n nextIndex = Math.round(\n Math.min(\n Math.max(\n 0,\n I18nManager.isRTL\n ? currentIndex + gestureState.dx / Math.abs(gestureState.dx)\n : currentIndex - gestureState.dx / Math.abs(gestureState.dx)\n ),\n routes.length - 1\n )\n );\n\n currentIndexRef.current = nextIndex;\n }\n\n if (!isFinite(nextIndex)) {\n nextIndex = currentIndex;\n }\n\n jumpToIndex(nextIndex, true);\n };\n\n // TODO: use the listeners\n const addEnterListener = React.useCallback((listener: Listener) => {\n listenersRef.current.push(listener);\n\n return () => {\n const index = listenersRef.current.indexOf(listener);\n\n if (index > -1) {\n listenersRef.current.splice(index, 1);\n }\n };\n }, []);\n\n const jumpTo = React.useCallback(\n (key: string) => {\n const index = navigationStateRef.current.routes.findIndex(\n (route: { key: string }) => route.key === key\n );\n\n jumpToIndex(index);\n },\n [jumpToIndex]\n );\n\n const panResponder = PanResponder.create({\n onMoveShouldSetPanResponder: canMoveScreen,\n onMoveShouldSetPanResponderCapture: canMoveScreen,\n onPanResponderGrant: startGesture,\n onPanResponderMove: respondToGesture,\n onPanResponderTerminate: finishGesture,\n onPanResponderRelease: finishGesture,\n onPanResponderTerminationRequest: () => true,\n });\n\n const maxTranslate = layout.width * (routes.length - 1);\n const translateX = Animated.multiply(\n panX.interpolate({\n inputRange: [-maxTranslate, 0],\n outputRange: [-maxTranslate, 0],\n extrapolate: 'clamp',\n }),\n I18nManager.isRTL ? -1 : 1\n );\n\n return children({\n position: layout.width\n ? Animated.divide(panX, -layout.width)\n : new Animated.Value(index),\n addEnterListener,\n jumpTo,\n render: (children) => (\n <Animated.View\n style={[\n styles.sheet,\n layout.width\n ? {\n width: routes.length * layout.width,\n transform: [{ translateX }],\n }\n : null,\n style,\n ]}\n {...panResponder.panHandlers}\n >\n {React.Children.map(children, (child, i) => {\n const route = routes[i];\n const focused = i === index;\n\n return (\n <View\n key={route.key}\n style={\n layout.width\n ? { width: layout.width }\n : focused\n ? StyleSheet.absoluteFill\n : null\n }\n >\n {focused || layout.width ? child : null}\n </View>\n );\n })}\n </Animated.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LU,IAAI,EAAE,CADD;IAELC,aAAa,EAAE,KAFV;IAGLC,UAAU,EAAE;EAHP;AADwB,CAAlB,CAAf"}
1
+ {"version":3,"names":["DEAD_ZONE","DefaultTransitionSpec","timing","Animated","spring","stiffness","damping","mass","overshootClamping","PanResponderAdapter","layout","keyboardDismissMode","swipeEnabled","navigationState","onIndexChange","onSwipeStart","onSwipeEnd","children","style","animationEnabled","routes","index","panX","useAnimatedValue","listenersRef","React","useRef","navigationStateRef","layoutRef","onIndexChangeRef","currentIndexRef","pendingIndexRef","swipeVelocityThreshold","swipeDistanceThreshold","width","jumpToIndex","useCallback","animate","offset","current","transitionConfig","parallel","toValue","useNativeDriver","start","finished","undefined","setValue","useEffect","Keyboard","dismiss","isMovingHorizontally","_","gestureState","Math","abs","dx","dy","vx","vy","canMoveScreen","event","diffX","I18nManager","isRTL","length","startGesture","stopAnimation","setOffset","_value","respondToGesture","position","_offset","next","ceil","floor","forEach","listener","finishGesture","flattenOffset","currentIndex","nextIndex","round","min","max","isFinite","addEnterListener","push","indexOf","splice","jumpTo","key","findIndex","route","panResponder","PanResponder","create","onMoveShouldSetPanResponder","onMoveShouldSetPanResponderCapture","onPanResponderGrant","onPanResponderMove","onPanResponderTerminate","onPanResponderRelease","onPanResponderTerminationRequest","maxTranslate","translateX","multiply","interpolate","inputRange","outputRange","extrapolate","useMemo","divide","Value","render","styles","sheet","transform","panHandlers","Children","map","child","i","focused","StyleSheet","absoluteFill","flex","flexDirection","alignItems"],"sources":["PanResponderAdapter.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n GestureResponderEvent,\n I18nManager,\n Keyboard,\n PanResponder,\n PanResponderGestureState,\n StyleSheet,\n View,\n} from 'react-native';\n\nimport type {\n EventEmitterProps,\n Layout,\n Listener,\n NavigationState,\n PagerProps,\n Route,\n} from './types';\nimport useAnimatedValue from './useAnimatedValue';\n\ntype Props<T extends Route> = PagerProps & {\n layout: Layout;\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n children: (\n props: EventEmitterProps & {\n // Animated value which represents the state of current index\n // It can include fractional digits as it represents the intermediate value\n position: Animated.AnimatedInterpolation;\n // Function to actually render the content of the pager\n // The parent component takes care of rendering\n render: (children: React.ReactNode) => React.ReactNode;\n // Callback to call when switching the tab\n // The tab switch animation is performed even if the index in state is unchanged\n jumpTo: (key: string) => void;\n }\n ) => React.ReactElement;\n};\n\nconst DEAD_ZONE = 12;\n\nconst DefaultTransitionSpec = {\n timing: Animated.spring,\n stiffness: 1000,\n damping: 500,\n mass: 3,\n overshootClamping: true,\n};\n\nexport default function PanResponderAdapter<T extends Route>({\n layout,\n keyboardDismissMode = 'auto',\n swipeEnabled = true,\n navigationState,\n onIndexChange,\n onSwipeStart,\n onSwipeEnd,\n children,\n style,\n animationEnabled = false,\n}: Props<T>) {\n const { routes, index } = navigationState;\n\n const panX = useAnimatedValue(0);\n\n const listenersRef = React.useRef<Listener[]>([]);\n\n const navigationStateRef = React.useRef(navigationState);\n const layoutRef = React.useRef(layout);\n const onIndexChangeRef = React.useRef(onIndexChange);\n\n const currentIndexRef = React.useRef(index);\n const pendingIndexRef = React.useRef<number>();\n\n const swipeVelocityThreshold = 0.15;\n const swipeDistanceThreshold = layout.width / 1.75;\n\n const jumpToIndex = React.useCallback(\n (index: number, animate = animationEnabled) => {\n const offset = -index * layoutRef.current.width;\n\n const { timing, ...transitionConfig } = DefaultTransitionSpec;\n\n if (animate) {\n Animated.parallel([\n timing(panX, {\n ...transitionConfig,\n toValue: offset,\n useNativeDriver: false,\n }),\n ]).start(({ finished }) => {\n if (finished) {\n onIndexChangeRef.current(index);\n pendingIndexRef.current = undefined;\n }\n });\n pendingIndexRef.current = index;\n } else {\n panX.setValue(offset);\n onIndexChangeRef.current(index);\n pendingIndexRef.current = undefined;\n }\n },\n [animationEnabled, panX]\n );\n\n React.useEffect(() => {\n navigationStateRef.current = navigationState;\n layoutRef.current = layout;\n onIndexChangeRef.current = onIndexChange;\n });\n\n React.useEffect(() => {\n const offset = -navigationStateRef.current.index * layout.width;\n\n panX.setValue(offset);\n }, [layout.width, panX]);\n\n React.useEffect(() => {\n if (keyboardDismissMode === 'auto') {\n Keyboard.dismiss();\n }\n\n if (layout.width && currentIndexRef.current !== index) {\n currentIndexRef.current = index;\n jumpToIndex(index);\n }\n }, [jumpToIndex, keyboardDismissMode, layout.width, index]);\n\n const isMovingHorizontally = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n return (\n Math.abs(gestureState.dx) > Math.abs(gestureState.dy * 2) &&\n Math.abs(gestureState.vx) > Math.abs(gestureState.vy * 2)\n );\n };\n\n const canMoveScreen = (\n event: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n if (swipeEnabled === false) {\n return false;\n }\n\n const diffX = I18nManager.isRTL ? -gestureState.dx : gestureState.dx;\n\n return (\n isMovingHorizontally(event, gestureState) &&\n ((diffX >= DEAD_ZONE && currentIndexRef.current > 0) ||\n (diffX <= -DEAD_ZONE && currentIndexRef.current < routes.length - 1))\n );\n };\n\n const startGesture = () => {\n onSwipeStart?.();\n\n if (keyboardDismissMode === 'on-drag') {\n Keyboard.dismiss();\n }\n\n panX.stopAnimation();\n // @ts-expect-error: _value is private, but docs use it as well\n panX.setOffset(panX._value);\n };\n\n const respondToGesture = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n const diffX = I18nManager.isRTL ? -gestureState.dx : gestureState.dx;\n\n if (\n // swiping left\n (diffX > 0 && index <= 0) ||\n // swiping right\n (diffX < 0 && index >= routes.length - 1)\n ) {\n return;\n }\n\n if (layout.width) {\n // @ts-expect-error: _offset is private, but docs use it as well\n const position = (panX._offset + diffX) / -layout.width;\n const next =\n position > index ? Math.ceil(position) : Math.floor(position);\n\n if (next !== index) {\n listenersRef.current.forEach((listener) => listener(next));\n }\n }\n\n panX.setValue(diffX);\n };\n\n const finishGesture = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n panX.flattenOffset();\n\n onSwipeEnd?.();\n\n const currentIndex =\n typeof pendingIndexRef.current === 'number'\n ? pendingIndexRef.current\n : currentIndexRef.current;\n\n let nextIndex = currentIndex;\n\n if (\n Math.abs(gestureState.dx) > Math.abs(gestureState.dy) &&\n Math.abs(gestureState.vx) > Math.abs(gestureState.vy) &&\n (Math.abs(gestureState.dx) > swipeDistanceThreshold ||\n Math.abs(gestureState.vx) > swipeVelocityThreshold)\n ) {\n nextIndex = Math.round(\n Math.min(\n Math.max(\n 0,\n I18nManager.isRTL\n ? currentIndex + gestureState.dx / Math.abs(gestureState.dx)\n : currentIndex - gestureState.dx / Math.abs(gestureState.dx)\n ),\n routes.length - 1\n )\n );\n\n currentIndexRef.current = nextIndex;\n }\n\n if (!isFinite(nextIndex)) {\n nextIndex = currentIndex;\n }\n\n jumpToIndex(nextIndex, true);\n };\n\n // TODO: use the listeners\n const addEnterListener = React.useCallback((listener: Listener) => {\n listenersRef.current.push(listener);\n\n return () => {\n const index = listenersRef.current.indexOf(listener);\n\n if (index > -1) {\n listenersRef.current.splice(index, 1);\n }\n };\n }, []);\n\n const jumpTo = React.useCallback(\n (key: string) => {\n const index = navigationStateRef.current.routes.findIndex(\n (route: { key: string }) => route.key === key\n );\n\n jumpToIndex(index);\n },\n [jumpToIndex]\n );\n\n const panResponder = PanResponder.create({\n onMoveShouldSetPanResponder: canMoveScreen,\n onMoveShouldSetPanResponderCapture: canMoveScreen,\n onPanResponderGrant: startGesture,\n onPanResponderMove: respondToGesture,\n onPanResponderTerminate: finishGesture,\n onPanResponderRelease: finishGesture,\n onPanResponderTerminationRequest: () => true,\n });\n\n const maxTranslate = layout.width * (routes.length - 1);\n const translateX = Animated.multiply(\n panX.interpolate({\n inputRange: [-maxTranslate, 0],\n outputRange: [-maxTranslate, 0],\n extrapolate: 'clamp',\n }),\n I18nManager.isRTL ? -1 : 1\n );\n\n const position = React.useMemo(\n () => (layout.width ? Animated.divide(panX, -layout.width) : null),\n [layout.width, panX]\n );\n\n return children({\n position: position ?? new Animated.Value(index),\n addEnterListener,\n jumpTo,\n render: (children) => (\n <Animated.View\n style={[\n styles.sheet,\n layout.width\n ? {\n width: routes.length * layout.width,\n transform: [{ translateX }],\n }\n : null,\n style,\n ]}\n {...panResponder.panHandlers}\n >\n {React.Children.map(children, (child, i) => {\n const route = routes[i];\n const focused = i === index;\n\n return (\n <View\n key={route.key}\n style={\n layout.width\n ? { width: layout.width }\n : focused\n ? StyleSheet.absoluteFill\n : null\n }\n >\n {focused || layout.width ? child : null}\n </View>\n );\n })}\n </Animated.View>\n ),\n });\n}\n\nconst styles = StyleSheet.create({\n sheet: {\n flex: 1,\n flexDirection: 'row',\n alignItems: 'stretch',\n },\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AAmBA;;;;;;;;;;AAqBA,MAAMA,SAAS,GAAG,EAAlB;AAEA,MAAMC,qBAAqB,GAAG;EAC5BC,MAAM,EAAEC,qBAAA,CAASC,MADW;EAE5BC,SAAS,EAAE,IAFiB;EAG5BC,OAAO,EAAE,GAHmB;EAI5BC,IAAI,EAAE,CAJsB;EAK5BC,iBAAiB,EAAE;AALS,CAA9B;;AAQe,SAASC,mBAAT,OAWF;EAAA,IAXgD;IAC3DC,MAD2D;IAE3DC,mBAAmB,GAAG,MAFqC;IAG3DC,YAAY,GAAG,IAH4C;IAI3DC,eAJ2D;IAK3DC,aAL2D;IAM3DC,YAN2D;IAO3DC,UAP2D;IAQ3DC,QAR2D;IAS3DC,KAT2D;IAU3DC,gBAAgB,GAAG;EAVwC,CAWhD;EACX,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAoBR,eAA1B;EAEA,MAAMS,IAAI,GAAG,IAAAC,yBAAA,EAAiB,CAAjB,CAAb;EAEA,MAAMC,YAAY,GAAGC,KAAK,CAACC,MAAN,CAAyB,EAAzB,CAArB;EAEA,MAAMC,kBAAkB,GAAGF,KAAK,CAACC,MAAN,CAAab,eAAb,CAA3B;EACA,MAAMe,SAAS,GAAGH,KAAK,CAACC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,KAAc;MAC1C,MAAM7B,KAAK,GAAGzE,MAAM,CAACsG,CAAD,CAApB;MACA,MAAMC,OAAO,GAAGD,CAAC,KAAKrG,KAAtB;MAEA,oBACE,oBAAC,iBAAD;QACE,GAAG,EAAEwE,KAAK,CAACF,GADb;QAEE,KAAK,EACHjF,MAAM,CAACwB,KAAP,GACI;UAAEA,KAAK,EAAExB,MAAM,CAACwB;QAAhB,CADJ,GAEIyF,OAAO,GACPC,uBAAA,CAAWC,YADJ,GAEP;MAPR,GAUGF,OAAO,IAAIjH,MAAM,CAACwB,KAAlB,GAA0BuF,KAA1B,GAAkC,IAVrC,CADF;IAcD,CAlBA,CAbH;EALY,CAAD,CAAf;AAwCD;;AAED,MAAMN,MAAM,GAAGS,uBAAA,CAAW5B,MAAX,CAAkB;EAC/BoB,KAAK,EAAE;IACLU,IAAI,EAAE,CADD;IAELC,aAAa,EAAE,KAFV;IAGLC,UAAU,EAAE;EAHP;AADwB,CAAlB,CAAf"}
@@ -11,24 +11,21 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
11
11
 
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
13
 
14
- class SceneComponent extends React.PureComponent {
15
- render() {
16
- const {
17
- component,
18
- ...rest
19
- } = this.props;
20
- return /*#__PURE__*/React.createElement(component, rest);
21
- }
22
-
23
- }
14
+ const SceneComponent = /*#__PURE__*/React.memo(_ref => {
15
+ let {
16
+ component,
17
+ ...rest
18
+ } = _ref;
19
+ return /*#__PURE__*/React.createElement(component, rest);
20
+ });
24
21
 
25
22
  function SceneMap(scenes) {
26
- return _ref => {
23
+ return _ref2 => {
27
24
  let {
28
25
  route,
29
26
  jumpTo,
30
27
  position
31
- } = _ref;
28
+ } = _ref2;
32
29
  return /*#__PURE__*/React.createElement(SceneComponent, {
33
30
  key: route.key,
34
31
  component: scenes[route.key],
@@ -1 +1 @@
1
- {"version":3,"names":["SceneComponent","React","PureComponent","render","component","rest","props","createElement","SceneMap","scenes","route","jumpTo","position","key"],"sources":["SceneMap.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { SceneRendererProps } from './types';\n\nclass SceneComponent<\n T extends { component: React.ComponentType<any> }\n> extends React.PureComponent<T> {\n render() {\n const { component, ...rest } = this.props;\n return React.createElement(component, rest);\n }\n}\n\nexport default function SceneMap<T extends any>(scenes: {\n [key: string]: React.ComponentType<T>;\n}) {\n return ({ route, jumpTo, position }: SceneRendererProps & { route: any }) => (\n <SceneComponent\n key={route.key}\n component={scenes[route.key]}\n route={route}\n jumpTo={jumpTo}\n position={position}\n />\n );\n}\n"],"mappings":";;;;;;;AAAA;;;;;;AAGA,MAAMA,cAAN,SAEUC,KAAK,CAACC,aAFhB,CAEiC;EAC/BC,MAAM,GAAG;IACP,MAAM;MAAEC,SAAF;MAAa,GAAGC;IAAhB,IAAyB,KAAKC,KAApC;IACA,oBAAOL,KAAK,CAACM,aAAN,CAAoBH,SAApB,EAA+BC,IAA/B,CAAP;EACD;;AAJ8B;;AAOlB,SAASG,QAAT,CAAiCC,MAAjC,EAEZ;EACD,OAAO;IAAA,IAAC;MAAEC,KAAF;MAASC,MAAT;MAAiBC;IAAjB,CAAD;IAAA,oBACL,oBAAC,cAAD;MACE,GAAG,EAAEF,KAAK,CAACG,GADb;MAEE,SAAS,EAAEJ,MAAM,CAACC,KAAK,CAACG,GAAP,CAFnB;MAGE,KAAK,EAAEH,KAHT;MAIE,MAAM,EAAEC,MAJV;MAKE,QAAQ,EAAEC;IALZ,EADK;EAAA,CAAP;AASD"}
1
+ {"version":3,"names":["SceneComponent","React","memo","component","rest","createElement","SceneMap","scenes","route","jumpTo","position","key"],"sources":["SceneMap.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport type { SceneRendererProps } from './types';\n\ntype SceneProps = {\n route: any;\n} & Omit<SceneRendererProps, 'layout'>;\n\nconst SceneComponent = React.memo(\n <T extends { component: React.ComponentType<any> } & SceneProps>({\n component,\n ...rest\n }: T) => {\n return React.createElement(component, rest);\n }\n);\n\nexport default function SceneMap<T extends any>(scenes: {\n [key: string]: React.ComponentType<T>;\n}) {\n return ({ route, jumpTo, position }: SceneProps) => (\n <SceneComponent\n key={route.key}\n component={scenes[route.key]}\n route={route}\n jumpTo={jumpTo}\n position={position}\n />\n );\n}\n"],"mappings":";;;;;;;AAAA;;;;;;AAQA,MAAMA,cAAc,gBAAGC,KAAK,CAACC,IAAN,CACrB,QAGS;EAAA,IAHwD;IAC/DC,SAD+D;IAE/D,GAAGC;EAF4D,CAGxD;EACP,oBAAOH,KAAK,CAACI,aAAN,CAAoBF,SAApB,EAA+BC,IAA/B,CAAP;AACD,CANoB,CAAvB;;AASe,SAASE,QAAT,CAAiCC,MAAjC,EAEZ;EACD,OAAO;IAAA,IAAC;MAAEC,KAAF;MAASC,MAAT;MAAiBC;IAAjB,CAAD;IAAA,oBACL,oBAAC,cAAD;MACE,GAAG,EAAEF,KAAK,CAACG,GADb;MAEE,SAAS,EAAEJ,MAAM,CAACC,KAAK,CAACG,GAAP,CAFnB;MAGE,KAAK,EAAEH,KAHT;MAIE,MAAM,EAAEC,MAJV;MAKE,QAAQ,EAAEC;IALZ,EADK;EAAA,CAAP;AASD"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = SceneView;
7
7
 
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
 
@@ -13,121 +13,74 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
13
13
 
14
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
15
 
16
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
-
18
- class SceneView extends React.Component {
19
- constructor() {
20
- super(...arguments);
21
-
22
- _defineProperty(this, "state", {
23
- loading: Math.abs(this.props.navigationState.index - this.props.index) > this.props.lazyPreloadDistance
24
- });
25
-
26
- _defineProperty(this, "timerHandler", void 0);
27
-
28
- _defineProperty(this, "unsubscribe", null);
29
-
30
- _defineProperty(this, "handleEnter", value => {
31
- const {
32
- index
33
- } = this.props; // If we're entering the current route, we need to load it
16
+ function SceneView(_ref) {
17
+ let {
18
+ children,
19
+ navigationState,
20
+ lazy,
21
+ layout,
22
+ index,
23
+ lazyPreloadDistance,
24
+ addEnterListener,
25
+ style
26
+ } = _ref;
27
+ const [isLoading, setIsLoading] = React.useState(Math.abs(navigationState.index - index) > lazyPreloadDistance);
28
+
29
+ if (isLoading && Math.abs(navigationState.index - index) <= lazyPreloadDistance) {
30
+ // Always render the route when it becomes focused
31
+ setIsLoading(false);
32
+ }
34
33
 
34
+ React.useEffect(() => {
35
+ const handleEnter = value => {
36
+ // If we're entering the current route, we need to load it
35
37
  if (value === index) {
36
- this.setState(prevState => {
37
- if (prevState.loading) {
38
- return {
39
- loading: false
40
- };
38
+ setIsLoading(prevState => {
39
+ if (prevState) {
40
+ return false;
41
41
  }
42
42
 
43
- return null;
43
+ return prevState;
44
44
  });
45
45
  }
46
- });
47
- }
48
-
49
- static getDerivedStateFromProps(props, state) {
50
- if (state.loading && Math.abs(props.navigationState.index - props.index) <= props.lazyPreloadDistance) {
51
- // Always render the route when it becomes focused
52
- return {
53
- loading: false
54
- };
55
- }
46
+ };
56
47
 
57
- return null;
58
- }
48
+ let unsubscribe;
49
+ let timer;
59
50
 
60
- componentDidMount() {
61
- if (this.props.lazy) {
51
+ if (lazy && isLoading) {
62
52
  // If lazy mode is enabled, listen to when we enter screens
63
- this.unsubscribe = this.props.addEnterListener(this.handleEnter);
64
- } else if (this.state.loading) {
53
+ unsubscribe = addEnterListener(handleEnter);
54
+ } else if (isLoading) {
65
55
  // If lazy mode is not enabled, render the scene with a delay if not loaded already
66
56
  // This improves the initial startup time as the scene is no longer blocking
67
- this.timerHandler = setTimeout(() => this.setState({
68
- loading: false
69
- }), 0);
57
+ timer = setTimeout(() => setIsLoading(false), 0);
70
58
  }
71
- }
72
-
73
- componentDidUpdate(prevProps, prevState) {
74
- if (this.props.lazy !== prevProps.lazy || this.state.loading !== prevState.loading) {
75
- // We only need the listener if the tab hasn't loaded yet and lazy is enabled
76
- if (this.props.lazy && this.state.loading) {
77
- var _this$unsubscribe;
78
-
79
- (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
80
- this.unsubscribe = this.props.addEnterListener(this.handleEnter);
81
- } else {
82
- var _this$unsubscribe2;
83
-
84
- (_this$unsubscribe2 = this.unsubscribe) === null || _this$unsubscribe2 === void 0 ? void 0 : _this$unsubscribe2.call(this);
85
- }
86
- }
87
- }
88
-
89
- componentWillUnmount() {
90
- var _this$unsubscribe3;
91
-
92
- (_this$unsubscribe3 = this.unsubscribe) === null || _this$unsubscribe3 === void 0 ? void 0 : _this$unsubscribe3.call(this);
93
-
94
- if (this.timerHandler) {
95
- clearTimeout(this.timerHandler);
96
- this.timerHandler = undefined;
97
- }
98
- }
99
-
100
- render() {
101
- const {
102
- navigationState,
103
- index,
104
- layout,
105
- style
106
- } = this.props;
107
- const {
108
- loading
109
- } = this.state;
110
- const focused = navigationState.index === index;
111
- return /*#__PURE__*/React.createElement(_reactNative.View, {
112
- accessibilityElementsHidden: !focused,
113
- importantForAccessibility: focused ? 'auto' : 'no-hide-descendants',
114
- style: [styles.route, // If we don't have the layout yet, make the focused screen fill the container
115
- // This avoids delay before we are able to render pages side by side
116
- layout.width ? {
117
- width: layout.width
118
- } : focused ? _reactNative.StyleSheet.absoluteFill : null, style]
119
- }, // Only render the route only if it's either focused or layout is available
120
- // When layout is not available, we must not render unfocused routes
121
- // so that the focused route can fill the screen
122
- focused || layout.width ? this.props.children({
123
- loading
124
- }) : null);
125
- }
126
59
 
60
+ return () => {
61
+ var _unsubscribe;
62
+
63
+ (_unsubscribe = unsubscribe) === null || _unsubscribe === void 0 ? void 0 : _unsubscribe();
64
+ clearTimeout(timer);
65
+ };
66
+ }, [addEnterListener, index, isLoading, lazy]);
67
+ const focused = navigationState.index === index;
68
+ return /*#__PURE__*/React.createElement(_reactNative.View, {
69
+ accessibilityElementsHidden: !focused,
70
+ importantForAccessibility: focused ? 'auto' : 'no-hide-descendants',
71
+ style: [styles.route, // If we don't have the layout yet, make the focused screen fill the container
72
+ // This avoids delay before we are able to render pages side by side
73
+ layout.width ? {
74
+ width: layout.width
75
+ } : focused ? _reactNative.StyleSheet.absoluteFill : null, style]
76
+ }, // Only render the route only if it's either focused or layout is available
77
+ // When layout is not available, we must not render unfocused routes
78
+ // so that the focused route can fill the screen
79
+ focused || layout.width ? children({
80
+ loading: isLoading
81
+ }) : null);
127
82
  }
128
83
 
129
- exports.default = SceneView;
130
-
131
84
  const styles = _reactNative.StyleSheet.create({
132
85
  route: {
133
86
  flex: 1,
@@ -1 +1 @@
1
- {"version":3,"names":["SceneView","React","Component","loading","Math","abs","props","navigationState","index","lazyPreloadDistance","value","setState","prevState","getDerivedStateFromProps","state","componentDidMount","lazy","unsubscribe","addEnterListener","handleEnter","timerHandler","setTimeout","componentDidUpdate","prevProps","componentWillUnmount","clearTimeout","undefined","render","layout","style","focused","styles","route","width","StyleSheet","absoluteFill","children","create","flex","overflow"],"sources":["SceneView.tsx"],"sourcesContent":["import * as React from 'react';\nimport { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';\nimport type {\n SceneRendererProps,\n EventEmitterProps,\n NavigationState,\n Route,\n} from './types';\n\ntype Props<T extends Route> = SceneRendererProps &\n EventEmitterProps & {\n navigationState: NavigationState<T>;\n lazy: boolean;\n lazyPreloadDistance: number;\n index: number;\n children: (props: { loading: boolean }) => React.ReactNode;\n style?: StyleProp<ViewStyle>;\n };\n\ntype State = {\n loading: boolean;\n};\n\nexport default class SceneView<T extends Route> extends React.Component<\n Props<T>,\n State\n> {\n static getDerivedStateFromProps(props: Props<Route>, state: State) {\n if (\n state.loading &&\n Math.abs(props.navigationState.index - props.index) <=\n props.lazyPreloadDistance\n ) {\n // Always render the route when it becomes focused\n return { loading: false };\n }\n\n return null;\n }\n\n state = {\n loading:\n Math.abs(this.props.navigationState.index - this.props.index) >\n this.props.lazyPreloadDistance,\n };\n\n componentDidMount() {\n if (this.props.lazy) {\n // If lazy mode is enabled, listen to when we enter screens\n this.unsubscribe = this.props.addEnterListener(this.handleEnter);\n } else if (this.state.loading) {\n // If lazy mode is not enabled, render the scene with a delay if not loaded already\n // This improves the initial startup time as the scene is no longer blocking\n this.timerHandler = setTimeout(\n () => this.setState({ loading: false }),\n 0\n );\n }\n }\n\n componentDidUpdate(prevProps: Props<T>, prevState: State) {\n if (\n this.props.lazy !== prevProps.lazy ||\n this.state.loading !== prevState.loading\n ) {\n // We only need the listener if the tab hasn't loaded yet and lazy is enabled\n if (this.props.lazy && this.state.loading) {\n this.unsubscribe?.();\n this.unsubscribe = this.props.addEnterListener(this.handleEnter);\n } else {\n this.unsubscribe?.();\n }\n }\n }\n\n componentWillUnmount() {\n this.unsubscribe?.();\n\n if (this.timerHandler) {\n clearTimeout(this.timerHandler);\n this.timerHandler = undefined;\n }\n }\n\n private timerHandler: NodeJS.Timeout | undefined;\n\n private unsubscribe: (() => void) | null = null;\n\n private handleEnter = (value: number) => {\n const { index } = this.props;\n\n // If we're entering the current route, we need to load it\n if (value === index) {\n this.setState((prevState) => {\n if (prevState.loading) {\n return { loading: false };\n }\n\n return null;\n });\n }\n };\n\n render() {\n const { navigationState, index, layout, style } = this.props;\n const { loading } = this.state;\n\n const focused = navigationState.index === index;\n\n return (\n <View\n accessibilityElementsHidden={!focused}\n importantForAccessibility={focused ? 'auto' : 'no-hide-descendants'}\n style={[\n styles.route,\n // If we don't have the layout yet, make the focused screen fill the container\n // This avoids delay before we are able to render pages side by side\n layout.width\n ? { width: layout.width }\n : focused\n ? StyleSheet.absoluteFill\n : null,\n style,\n ]}\n >\n {\n // Only render the route only if it's either focused or layout is available\n // When layout is not available, we must not render unfocused routes\n // so that the focused route can fill the screen\n focused || layout.width ? this.props.children({ loading }) : null\n }\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n route: {\n flex: 1,\n overflow: 'hidden',\n },\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;AAsBe,MAAMA,SAAN,SAAyCC,KAAK,CAACC,SAA/C,CAGb;EAAA;IAAA;;IAAA,+BAcQ;MACNC,OAAO,EACLC,IAAI,CAACC,GAAL,CAAS,KAAKC,KAAL,CAAWC,eAAX,CAA2BC,KAA3B,GAAmC,KAAKF,KAAL,CAAWE,KAAvD,IACA,KAAKF,KAAL,CAAWG;IAHP,CAdR;;IAAA;;IAAA,qCA4D2C,IA5D3C;;IAAA,qCA8DuBC,KAAD,IAAmB;MACvC,MA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B,KAAKX,KAAL,CAAWY,gBAAX,CAA4B,KAAKC,WAAjC,CAAnB;MACD,CAHD,MAGO;QAAA;;QACL,2BAAKF,WAAL;MACD;IACF;EACF;;EAEDO,oBAAoB,GAAG;IAAA;;IACrB,2BAAKP,WAAL;;IAEA,IAAI,KAAKG,YAAT,EAAuB;MACrBK,YAAY,CAAC,KAAKL,YAAN,CAAZ;MACA,KAAKA,YAAL,GAAoBM,SAApB;IACD;EACF;;EAqBDC,MAAM,GAAG;IACP,MAAM;MAAEpB,eAAF;MAAmBC,KAAnB;MAA0BoB,MAA1B;MAAkCC;IAAlC,IAA4C,KAAKvB,KAAvD;IACA,MAAM;MAAEH;IAAF,IAAc,KAAKW,KAAzB;IAEA,MAAMgB,OAAO,GAAGvB,eAAe,CAACC,KAAhB,KAA0BA,KAA1C;IAEA,oBACE,oBAAC,iBAAD;MACE,2BAA2B,EAAE,CAACsB,OADhC;MAEE,yBAAyB,EAAEA,OAAO,GAAG,MAAH,GAAY,qBAFhD;MAGE,KAAK,EAAE,CACLC,MAAM,CAACC,KADF,EAEL;MACA;MACAJ,MAAM,CAACK,KAAP,GACI;QAAEA,KAAK,EAAEL,MAAM,CAACK;MAAhB,CADJ,GAEIH,OAAO,GACPI,uBAAA,CAAWC,YADJ,GAEP,IARC,EASLN,KATK;IAHT,GAgBI;IACA;IACA;IACAC,OAAO,IAAIF,MAAM,CAACK,KAAlB,GAA0B,KAAK3B,KAAL,CAAW8B,QAAX,CAAoB;MAAEjC;IAAF,CAApB,CAA1B,GAA6D,IAnBjE,CADF;EAwBD;;AA3GD;;;;AA8GF,MAAM4B,MAAM,GAAGG,uBAAA,CAAWG,MAAX,CAAkB;EAC/BL,KAAK,EAAE;IACLM,IAAI,EAAE,CADD;IAELC,QAAQ,EAAE;EAFL;AADwB,CAAlB,CAAf"}
1
+ {"version":3,"names":["SceneView","children","navigationState","lazy","layout","index","lazyPreloadDistance","addEnterListener","style","isLoading","setIsLoading","React","useState","Math","abs","useEffect","handleEnter","value","prevState","unsubscribe","timer","setTimeout","clearTimeout","focused","styles","route","width","StyleSheet","absoluteFill","loading","create","flex","overflow"],"sources":["SceneView.tsx"],"sourcesContent":["import * as React from 'react';\nimport { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';\n\nimport type {\n EventEmitterProps,\n NavigationState,\n Route,\n SceneRendererProps,\n} from './types';\n\ntype Props<T extends Route> = SceneRendererProps &\n EventEmitterProps & {\n navigationState: NavigationState<T>;\n lazy: boolean;\n lazyPreloadDistance: number;\n index: number;\n children: (props: { loading: boolean }) => React.ReactNode;\n style?: StyleProp<ViewStyle>;\n };\n\nexport default function SceneView<T extends Route>({\n children,\n navigationState,\n lazy,\n layout,\n index,\n lazyPreloadDistance,\n addEnterListener,\n style,\n}: Props<T>) {\n const [isLoading, setIsLoading] = React.useState(\n Math.abs(navigationState.index - index) > lazyPreloadDistance\n );\n\n if (\n isLoading &&\n Math.abs(navigationState.index - index) <= lazyPreloadDistance\n ) {\n // Always render the route when it becomes focused\n setIsLoading(false);\n }\n\n React.useEffect(() => {\n const handleEnter = (value: number) => {\n // If we're entering the current route, we need to load it\n if (value === index) {\n setIsLoading((prevState) => {\n if (prevState) {\n return false;\n }\n return prevState;\n });\n }\n };\n\n let unsubscribe: (() => void) | undefined;\n let timer: NodeJS.Timeout;\n\n if (lazy && isLoading) {\n // If lazy mode is enabled, listen to when we enter screens\n unsubscribe = addEnterListener(handleEnter);\n } else if (isLoading) {\n // If lazy mode is not enabled, render the scene with a delay if not loaded already\n // This improves the initial startup time as the scene is no longer blocking\n timer = setTimeout(() => setIsLoading(false), 0);\n }\n\n return () => {\n unsubscribe?.();\n clearTimeout(timer);\n };\n }, [addEnterListener, index, isLoading, lazy]);\n\n const focused = navigationState.index === index;\n\n return (\n <View\n accessibilityElementsHidden={!focused}\n importantForAccessibility={focused ? 'auto' : 'no-hide-descendants'}\n style={[\n styles.route,\n // If we don't have the layout yet, make the focused screen fill the container\n // This avoids delay before we are able to render pages side by side\n layout.width\n ? { width: layout.width }\n : focused\n ? StyleSheet.absoluteFill\n : null,\n style,\n ]}\n >\n {\n // Only render the route only if it's either focused or layout is available\n // When layout is not available, we must not render unfocused routes\n // so that the focused route can fill the screen\n focused || layout.width ? children({ loading: isLoading }) : null\n }\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n route: {\n flex: 1,\n overflow: 'hidden',\n },\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAmBe,SAASA,SAAT,OASF;EAAA,IATsC;IACjDC,QADiD;IAEjDC,eAFiD;IAGjDC,IAHiD;IAIjDC,MAJiD;IAKjDC,KALiD;IAMjDC,mBANiD;IAOjDC,gBAPiD;IAQjDC;EARiD,CAStC;EACX,MAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4BC,KAAK,CAACC,QAAN,CAChCC,IAAI,CAACC,GAAL,CAASZ,eAAe,CAACG,KAAhB,GAAwBA,KAAjC,IAA0CC,mBADV,CAAlC;;EAIA,IACEG,SAAS,IACTI,IAAI,CAACC,GAAL,CAASZ,eAAe,CAACG,KAAhB,GAAwBA,KAAjC,KAA2CC,mBAF7C,EAGE;IACA;IACAI,YAAY,CAAC,KAAD,CAAZ;EACD;;EAEDC,KAAK,CAACI,SAAN,CAAgB,MAAM;IACpB,MAAMC,WAAW,GAAIC,KAAD,IAAmB;MACrC;MACA,IAAIA,KAAK,KAAKZ,KAAd,EAAqB;QACnBK,YAAY,CAAEQ,SAAD,IAAe;UAC1B,IAAIA,SAAJ,EAAe;YACb,OAAO,KAAP;UACD;;UACD,OAAOA,SAAP;QACD,CALW,CAAZ;MAMD;IACF,CAVD;;IAYA,IAAIC,WAAJ;IACA,IAAIC,KAAJ;;IAEA,IAAIjB,IAAI,IAAIM,SAAZ,EAAuB;MACrB;MACAU,WAAW,GAAGZ,gBAAgB,CAACS,WAAD,CAA9B;IACD,CAHD,MAGO,IAAIP,SAAJ,EAAe;MACpB;MACA;MACAW,KAAK,GAAGC,UAAU,CAAC,MAAMX,YAAY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