@fountain-ui/lab 2.0.0-beta.9 → 3.0.0-alpha.10

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 (480) hide show
  1. package/build/commonjs/BottomSheet/BottomSheetNative.js +97 -30
  2. package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
  3. package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
  4. package/build/commonjs/BottomSheet/BottomSheetWeb.js +64 -17
  5. package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
  6. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js +79 -0
  7. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js.map +1 -0
  8. package/build/commonjs/BottomSheet/useDynamicSnapPoints.native.js +22 -0
  9. package/build/commonjs/BottomSheet/useDynamicSnapPoints.native.js.map +1 -0
  10. package/build/commonjs/Carousel/Carousel.js +130 -0
  11. package/build/commonjs/Carousel/Carousel.js.map +1 -0
  12. package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
  13. package/build/commonjs/Carousel/animation/animationUtils.js +9 -0
  14. package/build/commonjs/Carousel/animation/animationUtils.js.map +1 -0
  15. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js +15 -0
  16. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  17. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js +26 -0
  18. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  19. package/build/commonjs/Carousel/animation/index.js +40 -0
  20. package/build/commonjs/Carousel/animation/index.js.map +1 -0
  21. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js +27 -0
  22. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  23. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js +65 -0
  24. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  25. package/build/commonjs/Carousel/components/InternalContext.js +29 -0
  26. package/build/commonjs/Carousel/components/InternalContext.js.map +1 -0
  27. package/build/commonjs/Carousel/components/ItemView.js +66 -0
  28. package/build/commonjs/Carousel/components/ItemView.js.map +1 -0
  29. package/build/commonjs/Carousel/components/RootView.js +86 -0
  30. package/build/commonjs/Carousel/components/RootView.js.map +1 -0
  31. package/build/commonjs/Carousel/components/ScrollViewGesture.js +84 -0
  32. package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -0
  33. package/build/commonjs/Carousel/components/index.js +40 -0
  34. package/build/commonjs/Carousel/components/index.js.map +1 -0
  35. package/build/commonjs/Carousel/components/useItemInterpolation.js +65 -0
  36. package/build/commonjs/Carousel/components/useItemInterpolation.js.map +1 -0
  37. package/build/commonjs/Carousel/hooks/index.js +48 -0
  38. package/build/commonjs/Carousel/hooks/index.js.map +1 -0
  39. package/build/commonjs/Carousel/hooks/useAutoplayController.js +58 -0
  40. package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -0
  41. package/build/commonjs/Carousel/hooks/useIndexController.js +55 -0
  42. package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -0
  43. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js +95 -0
  44. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  45. package/build/commonjs/Carousel/hooks/useLoopedData.js +33 -0
  46. package/build/commonjs/Carousel/hooks/useLoopedData.js.map +1 -0
  47. package/build/commonjs/Carousel/hooks/usePagingAnimator.js +202 -0
  48. package/build/commonjs/Carousel/hooks/usePagingAnimator.js.map +1 -0
  49. package/build/commonjs/Carousel/index.js +16 -2
  50. package/build/commonjs/Carousel/index.js.map +1 -1
  51. package/build/commonjs/Carousel/tick.js +16 -0
  52. package/build/commonjs/Carousel/tick.js.map +1 -0
  53. package/build/commonjs/Carousel/types.js +8 -0
  54. package/build/commonjs/Carousel/types.js.map +1 -0
  55. package/build/commonjs/ComicViewer/ComicViewer.js +230 -92
  56. package/build/commonjs/ComicViewer/ComicViewer.js.map +1 -1
  57. package/build/commonjs/ComicViewer/ComicViewerProps.js.map +1 -1
  58. package/build/commonjs/ComicViewer/EncodedTile.js +10 -0
  59. package/build/commonjs/ComicViewer/EncodedTile.js.map +1 -0
  60. package/build/commonjs/ComicViewer/FastScroll.js +175 -0
  61. package/build/commonjs/ComicViewer/FastScroll.js.map +1 -0
  62. package/build/commonjs/ComicViewer/{ComicViewerItemProps.js → FastScrollProps.js} +1 -1
  63. package/build/commonjs/ComicViewer/FastScrollProps.js.map +1 -0
  64. package/build/commonjs/ComicViewer/ReloadButton.js +48 -0
  65. package/build/commonjs/ComicViewer/ReloadButton.js.map +1 -0
  66. package/build/commonjs/ComicViewer/ViewerItem.js +53 -59
  67. package/build/commonjs/ComicViewer/ViewerItem.js.map +1 -1
  68. package/build/commonjs/ComicViewer/index.js.map +1 -1
  69. package/build/commonjs/ComicViewer/util.js +27 -0
  70. package/build/commonjs/ComicViewer/util.js.map +1 -0
  71. package/build/commonjs/DateTimePicker/DateTimePicker.js +12 -3
  72. package/build/commonjs/DateTimePicker/DateTimePicker.js.map +1 -1
  73. package/build/commonjs/DateTimePicker/YearPicker.js +2 -2
  74. package/build/commonjs/DateTimePicker/YearPicker.js.map +1 -1
  75. package/build/commonjs/StatusBarProvider/Provider.js.map +1 -1
  76. package/build/commonjs/StatusBarProvider/StatusBarProvider.js +111 -2
  77. package/build/commonjs/StatusBarProvider/StatusBarProvider.js.map +1 -1
  78. package/build/commonjs/ViewPager/FluxContext.js +13 -0
  79. package/build/commonjs/ViewPager/FluxContext.js.map +1 -0
  80. package/build/commonjs/ViewPager/InternalContext.js +17 -0
  81. package/build/commonjs/ViewPager/InternalContext.js.map +1 -0
  82. package/build/commonjs/ViewPager/PageStateContext.js +14 -0
  83. package/build/commonjs/ViewPager/PageStateContext.js.map +1 -0
  84. package/build/commonjs/ViewPager/ViewPager.js +81 -0
  85. package/build/commonjs/ViewPager/ViewPager.js.map +1 -0
  86. package/build/commonjs/ViewPager/ViewPager.native.js +152 -0
  87. package/build/commonjs/ViewPager/ViewPager.native.js.map +1 -0
  88. package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
  89. package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js +122 -0
  90. package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
  91. package/build/commonjs/ViewPager/components/FluxStoreProvider.js +37 -0
  92. package/build/commonjs/ViewPager/components/FluxStoreProvider.js.map +1 -0
  93. package/build/commonjs/ViewPager/components/index.js +24 -0
  94. package/build/commonjs/ViewPager/components/index.js.map +1 -0
  95. package/build/commonjs/ViewPager/hooks/index.js +64 -0
  96. package/build/commonjs/ViewPager/hooks/index.js.map +1 -0
  97. package/build/commonjs/ViewPager/hooks/useDispatch.js +22 -0
  98. package/build/commonjs/ViewPager/hooks/useDispatch.js.map +1 -0
  99. package/build/commonjs/ViewPager/hooks/useEagerState.js +24 -0
  100. package/build/commonjs/ViewPager/hooks/useEagerState.js.map +1 -0
  101. package/build/commonjs/ViewPager/hooks/useForceRender.js +16 -0
  102. package/build/commonjs/ViewPager/hooks/useForceRender.js.map +1 -0
  103. package/build/commonjs/ViewPager/hooks/useLazyState.js +43 -0
  104. package/build/commonjs/ViewPager/hooks/useLazyState.js.map +1 -0
  105. package/build/commonjs/ViewPager/hooks/usePageStore.js +35 -0
  106. package/build/commonjs/ViewPager/hooks/usePageStore.js.map +1 -0
  107. package/build/commonjs/ViewPager/hooks/useStore.js +26 -0
  108. package/build/commonjs/ViewPager/hooks/useStore.js.map +1 -0
  109. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js +19 -0
  110. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
  111. package/build/commonjs/ViewPager/index.js +42 -2
  112. package/build/commonjs/ViewPager/index.js.map +1 -1
  113. package/build/commonjs/ViewPager/types.js +2 -0
  114. package/build/commonjs/ViewPager/types.js.map +1 -0
  115. package/build/commonjs/ViewPager/utils.js +12 -45
  116. package/build/commonjs/ViewPager/utils.js.map +1 -1
  117. package/build/commonjs/ViewabilityTrackerView/Viewability.js +2 -0
  118. package/build/commonjs/ViewabilityTrackerView/Viewability.js.map +1 -0
  119. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js +45 -0
  120. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  121. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  122. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  123. package/build/commonjs/{Carousel/index.native.js → ViewabilityTrackerView/index.js} +3 -3
  124. package/build/commonjs/ViewabilityTrackerView/index.js.map +1 -0
  125. package/build/commonjs/ViewabilityTrackerView/measureViewability.js +42 -0
  126. package/build/commonjs/ViewabilityTrackerView/measureViewability.js.map +1 -0
  127. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js +88 -0
  128. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  129. package/build/commonjs/hooks/index.js +16 -0
  130. package/build/commonjs/hooks/index.js.map +1 -1
  131. package/build/commonjs/hooks/useDeferredExecutor.js +45 -0
  132. package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
  133. package/build/commonjs/hooks/useHeight.js +4 -4
  134. package/build/commonjs/hooks/useHeight.js.map +1 -1
  135. package/build/commonjs/hooks/useIsMounted.js +22 -0
  136. package/build/commonjs/hooks/useIsMounted.js.map +1 -0
  137. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +3 -5
  138. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  139. package/build/commonjs/index.js +22 -1
  140. package/build/commonjs/index.js.map +1 -1
  141. package/build/module/BottomSheet/BottomSheetNative.js +91 -25
  142. package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
  143. package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
  144. package/build/module/BottomSheet/BottomSheetWeb.js +59 -18
  145. package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
  146. package/build/module/BottomSheet/useDynamicSnapPoints.js +65 -0
  147. package/build/module/BottomSheet/useDynamicSnapPoints.js.map +1 -0
  148. package/build/module/BottomSheet/useDynamicSnapPoints.native.js +14 -0
  149. package/build/module/BottomSheet/useDynamicSnapPoints.native.js.map +1 -0
  150. package/build/module/Carousel/Carousel.js +109 -0
  151. package/build/module/Carousel/Carousel.js.map +1 -0
  152. package/build/module/Carousel/CarouselProps.js.map +1 -1
  153. package/build/module/Carousel/animation/animationUtils.js +2 -0
  154. package/build/module/Carousel/animation/animationUtils.js.map +1 -0
  155. package/build/module/Carousel/animation/createDefaultItemStyle.js +3 -0
  156. package/build/module/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  157. package/build/module/Carousel/animation/createDefaultScrollAnimation.js +12 -0
  158. package/build/module/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  159. package/build/module/Carousel/animation/index.js +5 -0
  160. package/build/module/Carousel/animation/index.js.map +1 -0
  161. package/build/module/Carousel/animation/normalItemStyleFactory.js +18 -0
  162. package/build/module/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  163. package/build/module/Carousel/animation/parallaxItemStyleFactory.js +55 -0
  164. package/build/module/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  165. package/build/module/Carousel/components/InternalContext.js +19 -0
  166. package/build/module/Carousel/components/InternalContext.js.map +1 -0
  167. package/build/module/Carousel/components/ItemView.js +46 -0
  168. package/build/module/Carousel/components/ItemView.js.map +1 -0
  169. package/build/module/Carousel/components/RootView.js +65 -0
  170. package/build/module/Carousel/components/RootView.js.map +1 -0
  171. package/build/module/Carousel/components/ScrollViewGesture.js +69 -0
  172. package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -0
  173. package/build/module/Carousel/components/index.js +5 -0
  174. package/build/module/Carousel/components/index.js.map +1 -0
  175. package/build/module/Carousel/components/useItemInterpolation.js +51 -0
  176. package/build/module/Carousel/components/useItemInterpolation.js.map +1 -0
  177. package/build/module/Carousel/hooks/index.js +6 -0
  178. package/build/module/Carousel/hooks/index.js.map +1 -0
  179. package/build/module/Carousel/hooks/useAutoplayController.js +48 -0
  180. package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -0
  181. package/build/module/Carousel/hooks/useIndexController.js +44 -0
  182. package/build/module/Carousel/hooks/useIndexController.js.map +1 -0
  183. package/build/module/Carousel/hooks/useItemVisibilityStore.js +86 -0
  184. package/build/module/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  185. package/build/module/Carousel/hooks/useLoopedData.js +24 -0
  186. package/build/module/Carousel/hooks/useLoopedData.js.map +1 -0
  187. package/build/module/Carousel/hooks/usePagingAnimator.js +192 -0
  188. package/build/module/Carousel/hooks/usePagingAnimator.js.map +1 -0
  189. package/build/module/Carousel/index.js +2 -1
  190. package/build/module/Carousel/index.js.map +1 -1
  191. package/build/module/Carousel/tick.js +6 -0
  192. package/build/module/Carousel/tick.js.map +1 -0
  193. package/build/module/Carousel/types.js +4 -0
  194. package/build/module/Carousel/types.js.map +1 -0
  195. package/build/module/ComicViewer/ComicViewer.js +229 -93
  196. package/build/module/ComicViewer/ComicViewer.js.map +1 -1
  197. package/build/module/ComicViewer/ComicViewerProps.js.map +1 -1
  198. package/build/module/ComicViewer/EncodedTile.js +3 -0
  199. package/build/module/ComicViewer/EncodedTile.js.map +1 -0
  200. package/build/module/ComicViewer/FastScroll.js +152 -0
  201. package/build/module/ComicViewer/FastScroll.js.map +1 -0
  202. package/build/module/ComicViewer/FastScrollProps.js +2 -0
  203. package/build/module/ComicViewer/FastScrollProps.js.map +1 -0
  204. package/build/module/ComicViewer/ReloadButton.js +33 -0
  205. package/build/module/ComicViewer/ReloadButton.js.map +1 -0
  206. package/build/module/ComicViewer/ViewerItem.js +53 -60
  207. package/build/module/ComicViewer/ViewerItem.js.map +1 -1
  208. package/build/module/ComicViewer/index.js.map +1 -1
  209. package/build/module/ComicViewer/util.js +15 -0
  210. package/build/module/ComicViewer/util.js.map +1 -0
  211. package/build/module/DateTimePicker/DateTimePicker.js +13 -4
  212. package/build/module/DateTimePicker/DateTimePicker.js.map +1 -1
  213. package/build/module/DateTimePicker/YearPicker.js +2 -2
  214. package/build/module/DateTimePicker/YearPicker.js.map +1 -1
  215. package/build/module/StatusBarProvider/Provider.js.map +1 -1
  216. package/build/module/StatusBarProvider/StatusBarProvider.js +105 -2
  217. package/build/module/StatusBarProvider/StatusBarProvider.js.map +1 -1
  218. package/build/module/ViewPager/FluxContext.js +4 -0
  219. package/build/module/ViewPager/FluxContext.js.map +1 -0
  220. package/build/module/ViewPager/InternalContext.js +7 -0
  221. package/build/module/ViewPager/InternalContext.js.map +1 -0
  222. package/build/module/ViewPager/PageStateContext.js +5 -0
  223. package/build/module/ViewPager/PageStateContext.js.map +1 -0
  224. package/build/module/ViewPager/ViewPager.js +57 -0
  225. package/build/module/ViewPager/ViewPager.js.map +1 -0
  226. package/build/module/ViewPager/ViewPager.native.js +129 -0
  227. package/build/module/ViewPager/ViewPager.native.js.map +1 -0
  228. package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
  229. package/build/module/ViewPager/components/ChildrenMemoizedPage.js +101 -0
  230. package/build/module/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
  231. package/build/module/ViewPager/components/FluxStoreProvider.js +20 -0
  232. package/build/module/ViewPager/components/FluxStoreProvider.js.map +1 -0
  233. package/build/module/ViewPager/components/index.js +3 -0
  234. package/build/module/ViewPager/components/index.js.map +1 -0
  235. package/build/module/ViewPager/hooks/index.js +8 -0
  236. package/build/module/ViewPager/hooks/index.js.map +1 -0
  237. package/build/module/ViewPager/hooks/useDispatch.js +10 -0
  238. package/build/module/ViewPager/hooks/useDispatch.js.map +1 -0
  239. package/build/module/ViewPager/hooks/useEagerState.js +12 -0
  240. package/build/module/ViewPager/hooks/useEagerState.js.map +1 -0
  241. package/build/module/ViewPager/hooks/useForceRender.js +7 -0
  242. package/build/module/ViewPager/hooks/useForceRender.js.map +1 -0
  243. package/build/module/ViewPager/hooks/useLazyState.js +28 -0
  244. package/build/module/ViewPager/hooks/useLazyState.js.map +1 -0
  245. package/build/module/ViewPager/hooks/usePageStore.js +25 -0
  246. package/build/module/ViewPager/hooks/usePageStore.js.map +1 -0
  247. package/build/module/ViewPager/hooks/useStore.js +14 -0
  248. package/build/module/ViewPager/hooks/useStore.js.map +1 -0
  249. package/build/module/ViewPager/hooks/useViewPagerPageState.js +7 -0
  250. package/build/module/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
  251. package/build/module/ViewPager/index.js +3 -1
  252. package/build/module/ViewPager/index.js.map +1 -1
  253. package/build/module/ViewPager/types.js +2 -0
  254. package/build/module/ViewPager/types.js.map +1 -0
  255. package/build/module/ViewPager/utils.js +6 -34
  256. package/build/module/ViewPager/utils.js.map +1 -1
  257. package/build/module/ViewabilityTrackerView/Viewability.js +2 -0
  258. package/build/module/ViewabilityTrackerView/Viewability.js.map +1 -0
  259. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js +28 -0
  260. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  261. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  262. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  263. package/build/module/ViewabilityTrackerView/index.js +2 -0
  264. package/build/module/ViewabilityTrackerView/index.js.map +1 -0
  265. package/build/module/ViewabilityTrackerView/measureViewability.js +34 -0
  266. package/build/module/ViewabilityTrackerView/measureViewability.js.map +1 -0
  267. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js +73 -0
  268. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  269. package/build/module/hooks/index.js +2 -0
  270. package/build/module/hooks/index.js.map +1 -1
  271. package/build/module/hooks/useDeferredExecutor.js +33 -0
  272. package/build/module/hooks/useDeferredExecutor.js.map +1 -0
  273. package/build/module/hooks/useHeight.js +2 -3
  274. package/build/module/hooks/useHeight.js.map +1 -1
  275. package/build/module/hooks/useIsMounted.js +13 -0
  276. package/build/module/hooks/useIsMounted.js.map +1 -0
  277. package/build/module/hooks/useUnstableCollapsibleAppBar.js +4 -6
  278. package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  279. package/build/module/index.js +2 -0
  280. package/build/module/index.js.map +1 -1
  281. package/build/typescript/AnimatedY/AnimatedY.d.ts +1 -0
  282. package/build/typescript/BottomSheet/BottomSheetNative.d.ts +1 -0
  283. package/build/typescript/BottomSheet/BottomSheetProps.d.ts +31 -2
  284. package/build/typescript/BottomSheet/BottomSheetWeb.d.ts +1 -0
  285. package/build/typescript/BottomSheet/TransparentBackdrop.d.ts +1 -0
  286. package/build/typescript/BottomSheet/useDynamicSnapPoints.d.ts +13 -0
  287. package/build/typescript/BottomSheet/useDynamicSnapPoints.native.d.ts +21 -0
  288. package/build/typescript/Carousel/Carousel.d.ts +5 -0
  289. package/build/typescript/Carousel/CarouselProps.d.ts +33 -48
  290. package/build/typescript/Carousel/animation/animationUtils.d.ts +1 -0
  291. package/build/typescript/Carousel/animation/createDefaultItemStyle.d.ts +2 -0
  292. package/build/typescript/Carousel/animation/createDefaultScrollAnimation.d.ts +2 -0
  293. package/build/typescript/Carousel/animation/index.d.ts +4 -0
  294. package/build/typescript/Carousel/animation/normalItemStyleFactory.d.ts +2 -0
  295. package/build/typescript/Carousel/animation/parallaxItemStyleFactory.d.ts +9 -0
  296. package/build/typescript/Carousel/components/InternalContext.d.ts +14 -0
  297. package/build/typescript/Carousel/components/ItemView.d.ts +9 -0
  298. package/build/typescript/Carousel/components/RootView.d.ts +16 -0
  299. package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +12 -0
  300. package/build/typescript/Carousel/components/index.d.ts +4 -0
  301. package/build/typescript/Carousel/components/useItemInterpolation.d.ts +2 -0
  302. package/build/typescript/Carousel/hooks/index.d.ts +5 -0
  303. package/build/typescript/Carousel/hooks/useAutoplayController.d.ts +7 -0
  304. package/build/typescript/Carousel/hooks/useIndexController.d.ts +10 -0
  305. package/build/typescript/Carousel/hooks/useItemVisibilityStore.d.ts +7 -0
  306. package/build/typescript/Carousel/hooks/useLoopedData.d.ts +1 -0
  307. package/build/typescript/Carousel/hooks/usePagingAnimator.d.ts +17 -0
  308. package/build/typescript/Carousel/index.d.ts +3 -1
  309. package/build/typescript/Carousel/tick.d.ts +2 -0
  310. package/build/typescript/Carousel/types.d.ts +91 -0
  311. package/build/typescript/ComicViewer/ComicViewer.d.ts +2 -1
  312. package/build/typescript/ComicViewer/ComicViewerProps.d.ts +61 -43
  313. package/build/typescript/ComicViewer/EncodedTile.d.ts +2 -0
  314. package/build/typescript/ComicViewer/FastScroll.d.ts +4 -0
  315. package/build/typescript/ComicViewer/FastScrollProps.d.ts +74 -0
  316. package/build/typescript/ComicViewer/ReloadButton.d.ts +7 -0
  317. package/build/typescript/ComicViewer/ViewerItem.d.ts +46 -7
  318. package/build/typescript/ComicViewer/index.d.ts +3 -2
  319. package/build/typescript/ComicViewer/util.d.ts +2 -0
  320. package/build/typescript/DateTimePicker/DateTimePicker.d.ts +1 -0
  321. package/build/typescript/DateTimePicker/YearPicker.d.ts +1 -0
  322. package/build/typescript/FlipCard/FlipCard.d.ts +1 -0
  323. package/build/typescript/StatusBarProvider/Provider.d.ts +13 -0
  324. package/build/typescript/StatusBarProvider/StatusBarProvider.d.ts +1 -0
  325. package/build/typescript/ViewPager/FluxContext.d.ts +5 -0
  326. package/build/typescript/ViewPager/InternalContext.d.ts +7 -0
  327. package/build/typescript/ViewPager/PageStateContext.d.ts +6 -0
  328. package/build/typescript/ViewPager/ViewPager.d.ts +5 -0
  329. package/build/typescript/ViewPager/ViewPager.native.d.ts +5 -0
  330. package/build/typescript/ViewPager/ViewPagerProps.d.ts +21 -27
  331. package/build/typescript/ViewPager/components/ChildrenMemoizedPage.d.ts +14 -0
  332. package/build/typescript/ViewPager/components/FluxStoreProvider.d.ts +6 -0
  333. package/build/typescript/ViewPager/components/index.d.ts +2 -0
  334. package/build/typescript/ViewPager/hooks/index.d.ts +7 -0
  335. package/build/typescript/ViewPager/hooks/useDispatch.d.ts +2 -0
  336. package/build/typescript/ViewPager/hooks/useEagerState.d.ts +1 -0
  337. package/build/typescript/ViewPager/hooks/useForceRender.d.ts +2 -0
  338. package/build/typescript/ViewPager/hooks/useLazyState.d.ts +2 -0
  339. package/build/typescript/ViewPager/hooks/usePageStore.d.ts +2 -0
  340. package/build/typescript/ViewPager/hooks/useStore.d.ts +2 -0
  341. package/build/typescript/ViewPager/hooks/useViewPagerPageState.d.ts +1 -0
  342. package/build/typescript/ViewPager/index.d.ts +4 -1
  343. package/build/typescript/ViewPager/types.d.ts +12 -0
  344. package/build/typescript/ViewPager/utils.d.ts +5 -20
  345. package/build/typescript/ViewabilityTrackerView/Viewability.d.ts +3 -0
  346. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerView.d.ts +3 -0
  347. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerViewProps.d.ts +22 -0
  348. package/build/typescript/ViewabilityTrackerView/index.d.ts +2 -0
  349. package/build/typescript/ViewabilityTrackerView/measureViewability.d.ts +11 -0
  350. package/build/typescript/ViewabilityTrackerView/useViewabilityTracker.d.ts +11 -0
  351. package/build/typescript/hooks/index.d.ts +2 -0
  352. package/build/typescript/hooks/useDeferredExecutor.d.ts +11 -0
  353. package/build/typescript/hooks/useIsMounted.d.ts +4 -0
  354. package/build/typescript/index.d.ts +2 -0
  355. package/package.json +10 -25
  356. package/src/BottomSheet/BottomSheetNative.tsx +103 -24
  357. package/src/BottomSheet/BottomSheetProps.ts +37 -2
  358. package/src/BottomSheet/BottomSheetWeb.tsx +69 -24
  359. package/src/BottomSheet/useDynamicSnapPoints.native.ts +15 -0
  360. package/src/BottomSheet/useDynamicSnapPoints.ts +87 -0
  361. package/src/Carousel/Carousel.tsx +135 -0
  362. package/src/Carousel/CarouselProps.ts +42 -53
  363. package/src/Carousel/animation/animationUtils.ts +1 -0
  364. package/src/Carousel/animation/createDefaultItemStyle.ts +3 -0
  365. package/src/Carousel/animation/createDefaultScrollAnimation.ts +14 -0
  366. package/src/Carousel/animation/index.ts +4 -0
  367. package/src/Carousel/animation/normalItemStyleFactory.ts +19 -0
  368. package/src/Carousel/animation/parallaxItemStyleFactory.ts +79 -0
  369. package/src/Carousel/components/InternalContext.ts +33 -0
  370. package/src/Carousel/components/ItemView.tsx +66 -0
  371. package/src/Carousel/components/RootView.tsx +79 -0
  372. package/src/Carousel/components/ScrollViewGesture.tsx +93 -0
  373. package/src/Carousel/components/index.ts +4 -0
  374. package/src/Carousel/components/useItemInterpolation.ts +107 -0
  375. package/src/Carousel/hooks/index.ts +5 -0
  376. package/src/Carousel/hooks/useAutoplayController.ts +57 -0
  377. package/src/Carousel/hooks/useIndexController.tsx +57 -0
  378. package/src/Carousel/hooks/useItemVisibilityStore.ts +107 -0
  379. package/src/Carousel/hooks/useLoopedData.ts +26 -0
  380. package/src/Carousel/hooks/usePagingAnimator.ts +255 -0
  381. package/src/Carousel/index.ts +4 -2
  382. package/src/Carousel/tick.ts +6 -0
  383. package/src/Carousel/types.ts +114 -0
  384. package/src/ComicViewer/ComicViewer.tsx +268 -106
  385. package/src/ComicViewer/ComicViewerProps.ts +66 -44
  386. package/src/ComicViewer/EncodedTile.ts +3 -0
  387. package/src/ComicViewer/FastScroll.tsx +176 -0
  388. package/src/ComicViewer/FastScrollProps.ts +88 -0
  389. package/src/ComicViewer/ReloadButton.tsx +36 -0
  390. package/src/ComicViewer/ViewerItem.tsx +104 -62
  391. package/src/ComicViewer/index.ts +8 -2
  392. package/src/ComicViewer/util.ts +15 -0
  393. package/src/DateTimePicker/DateTimePicker.tsx +11 -3
  394. package/src/DateTimePicker/YearPicker.tsx +2 -2
  395. package/src/StatusBarProvider/Provider.ts +14 -0
  396. package/src/StatusBarProvider/StatusBarProvider.tsx +103 -1
  397. package/src/ViewPager/FluxContext.ts +8 -0
  398. package/src/ViewPager/InternalContext.ts +13 -0
  399. package/src/ViewPager/PageStateContext.ts +11 -0
  400. package/src/ViewPager/ViewPager.native.tsx +152 -0
  401. package/src/ViewPager/ViewPager.tsx +69 -0
  402. package/src/ViewPager/ViewPagerProps.ts +25 -34
  403. package/src/ViewPager/components/ChildrenMemoizedPage.tsx +124 -0
  404. package/src/ViewPager/components/FluxStoreProvider.tsx +27 -0
  405. package/src/ViewPager/components/index.ts +2 -0
  406. package/src/ViewPager/hooks/index.ts +7 -0
  407. package/src/ViewPager/hooks/useDispatch.ts +11 -0
  408. package/src/ViewPager/hooks/useEagerState.ts +14 -0
  409. package/src/ViewPager/hooks/useForceRender.ts +7 -0
  410. package/src/ViewPager/hooks/useLazyState.ts +32 -0
  411. package/src/ViewPager/hooks/usePageStore.ts +30 -0
  412. package/src/ViewPager/hooks/useStore.ts +15 -0
  413. package/src/ViewPager/hooks/useViewPagerPageState.ts +6 -0
  414. package/src/ViewPager/index.ts +11 -2
  415. package/src/ViewPager/types.ts +15 -0
  416. package/src/ViewPager/utils.tsx +9 -56
  417. package/src/ViewabilityTrackerView/Viewability.ts +3 -0
  418. package/src/ViewabilityTrackerView/ViewabilityTrackerView.tsx +33 -0
  419. package/src/ViewabilityTrackerView/ViewabilityTrackerViewProps.ts +25 -0
  420. package/src/ViewabilityTrackerView/index.ts +2 -0
  421. package/src/ViewabilityTrackerView/measureViewability.ts +54 -0
  422. package/src/ViewabilityTrackerView/useViewabilityTracker.ts +85 -0
  423. package/src/hooks/index.ts +2 -0
  424. package/src/hooks/useDeferredExecutor.ts +46 -0
  425. package/src/hooks/useHeight.ts +3 -4
  426. package/src/hooks/useIsMounted.ts +19 -0
  427. package/src/hooks/useUnstableCollapsibleAppBar.ts +4 -4
  428. package/src/index.ts +3 -0
  429. package/build/commonjs/Carousel/CarouselNative.js +0 -72
  430. package/build/commonjs/Carousel/CarouselNative.js.map +0 -1
  431. package/build/commonjs/Carousel/CarouselWeb.js +0 -237
  432. package/build/commonjs/Carousel/CarouselWeb.js.map +0 -1
  433. package/build/commonjs/Carousel/index.native.js.map +0 -1
  434. package/build/commonjs/Carousel/utils.js +0 -19
  435. package/build/commonjs/Carousel/utils.js.map +0 -1
  436. package/build/commonjs/ComicViewer/ComicViewerItemProps.js.map +0 -1
  437. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js +0 -49
  438. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  439. package/build/commonjs/ViewPager/ViewPagerNative.js +0 -75
  440. package/build/commonjs/ViewPager/ViewPagerNative.js.map +0 -1
  441. package/build/commonjs/ViewPager/ViewPagerWeb.js +0 -55
  442. package/build/commonjs/ViewPager/ViewPagerWeb.js.map +0 -1
  443. package/build/commonjs/ViewPager/index.native.js +0 -16
  444. package/build/commonjs/ViewPager/index.native.js.map +0 -1
  445. package/build/module/Carousel/CarouselNative.js +0 -54
  446. package/build/module/Carousel/CarouselNative.js.map +0 -1
  447. package/build/module/Carousel/CarouselWeb.js +0 -215
  448. package/build/module/Carousel/CarouselWeb.js.map +0 -1
  449. package/build/module/Carousel/index.native.js +0 -2
  450. package/build/module/Carousel/index.native.js.map +0 -1
  451. package/build/module/Carousel/utils.js +0 -7
  452. package/build/module/Carousel/utils.js.map +0 -1
  453. package/build/module/ComicViewer/ComicViewerItemProps.js +0 -2
  454. package/build/module/ComicViewer/ComicViewerItemProps.js.map +0 -1
  455. package/build/module/ViewPager/ChildrenMemoizedPage.js +0 -37
  456. package/build/module/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  457. package/build/module/ViewPager/ViewPagerNative.js +0 -58
  458. package/build/module/ViewPager/ViewPagerNative.js.map +0 -1
  459. package/build/module/ViewPager/ViewPagerWeb.js +0 -41
  460. package/build/module/ViewPager/ViewPagerWeb.js.map +0 -1
  461. package/build/module/ViewPager/index.native.js +0 -2
  462. package/build/module/ViewPager/index.native.js.map +0 -1
  463. package/build/typescript/Carousel/CarouselNative.d.ts +0 -2
  464. package/build/typescript/Carousel/CarouselWeb.d.ts +0 -4
  465. package/build/typescript/Carousel/index.native.d.ts +0 -1
  466. package/build/typescript/Carousel/utils.d.ts +0 -6
  467. package/build/typescript/ComicViewer/ComicViewerItemProps.d.ts +0 -12
  468. package/build/typescript/ViewPager/ChildrenMemoizedPage.d.ts +0 -4
  469. package/build/typescript/ViewPager/ViewPagerNative.d.ts +0 -2
  470. package/build/typescript/ViewPager/ViewPagerWeb.d.ts +0 -2
  471. package/build/typescript/ViewPager/index.native.d.ts +0 -1
  472. package/src/Carousel/CarouselNative.tsx +0 -67
  473. package/src/Carousel/CarouselWeb.tsx +0 -222
  474. package/src/Carousel/index.native.ts +0 -1
  475. package/src/Carousel/utils.ts +0 -11
  476. package/src/ComicViewer/ComicViewerItemProps.ts +0 -15
  477. package/src/ViewPager/ChildrenMemoizedPage.tsx +0 -36
  478. package/src/ViewPager/ViewPagerNative.tsx +0 -73
  479. package/src/ViewPager/ViewPagerWeb.tsx +0 -52
  480. package/src/ViewPager/index.native.ts +0 -1
@@ -5,18 +5,26 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = BottomSheet;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNative = require("react-native");
11
11
 
12
- var _styles = require("@fountain-ui/styles");
13
-
14
12
  var _bottomSheet = require("@gorhom/bottom-sheet");
15
13
 
14
+ var _core = require("@fountain-ui/core");
15
+
16
+ var _styles = require("@fountain-ui/styles");
17
+
16
18
  var _TransparentBackdrop = _interopRequireDefault(require("./TransparentBackdrop"));
17
19
 
20
+ var _useDynamicSnapPoints = _interopRequireDefault(require("./useDynamicSnapPoints.native"));
21
+
18
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
23
 
24
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
+
26
+ 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; }
27
+
20
28
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
21
29
 
22
30
  const NoHandle = () => null;
@@ -24,29 +32,43 @@ const NoHandle = () => null;
24
32
  function BottomSheet(props) {
25
33
  const {
26
34
  backdropOpacity = 0.5,
35
+ backgroundStyle: backgroundStyleProp,
36
+ borderRadius: borderRadiusProp,
27
37
  children,
38
+ enableDynamicSizing = true,
39
+ topElement,
28
40
  index,
41
+ maxHeightNormalizedRatio = 0.8,
29
42
  onChange,
30
- snapPoints
43
+ snapPoints = [],
44
+ style: styleProp
31
45
  } = props;
46
+ const indexRef = (0, _react.useRef)(-1);
47
+ const bottomSheetRef = (0, _react.useRef)(null);
48
+ const {
49
+ height: windowHeight
50
+ } = (0, _reactNative.useWindowDimensions)();
51
+ const [topElementHeight, setTopElementHeight] = (0, _react.useState)(0);
52
+ const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio) - topElementHeight;
53
+
54
+ const handleTopElementLayout = event => {
55
+ const {
56
+ height
57
+ } = event.nativeEvent.layout;
58
+ setTopElementHeight(height);
59
+ };
32
60
 
33
- const indexRef = _react.default.useRef(-1);
34
-
35
- const bottomSheetRef = _react.default.useRef(null);
36
-
37
- const handleChange = _react.default.useCallback(newIndex => {
61
+ const handleChange = (0, _react.useCallback)(newIndex => {
38
62
  indexRef.current = newIndex;
39
63
 
40
64
  if (onChange) {
41
65
  onChange(newIndex);
42
66
  }
43
67
  }, [onChange]);
44
-
45
- const handleDismiss = _react.default.useCallback(() => {
68
+ const handleDismiss = (0, _react.useCallback)(() => {
46
69
  handleChange(-1);
47
70
  }, [handleChange]);
48
-
49
- _react.default.useEffect(() => {
71
+ (0, _react.useEffect)(() => {
50
72
  if (index === indexRef.current) {
51
73
  return;
52
74
  }
@@ -66,28 +88,59 @@ function BottomSheet(props) {
66
88
  (_bottomSheetRef$curre3 = bottomSheetRef.current) === null || _bottomSheetRef$curre3 === void 0 ? void 0 : _bottomSheetRef$curre3.snapToIndex(index);
67
89
  }
68
90
  }, [index]);
69
-
70
91
  const theme = (0, _styles.useTheme)();
71
- const shadow = theme.shadow[12];
72
- const modalStyle = {
73
- backgroundColor: '#ffffff00',
74
- ..._reactNative.Platform.select({
75
- android: shadow === null || shadow === void 0 ? void 0 : shadow.elevation,
76
- ios: shadow === null || shadow === void 0 ? void 0 : shadow.shadow,
77
- web: shadow === null || shadow === void 0 ? void 0 : shadow.boxShadow
78
- })
79
- };
80
- const backgroundStyle = {
81
- backgroundColor: theme.palette.paper.default
82
- };
92
+ const borderRadius = borderRadiusProp ?? theme.shape.radius.xxl;
93
+ const backgroundStyle = (0, _core.css)([{
94
+ backgroundColor: theme.palette.surface.base,
95
+ borderTopLeftRadius: borderRadius,
96
+ borderTopRightRadius: borderRadius
97
+ }, backgroundStyleProp]);
98
+ const contentWrapperStyle = (0, _core.css)([{
99
+ backgroundColor: theme.palette.surface.base,
100
+ borderTopLeftRadius: borderRadius,
101
+ borderTopRightRadius: borderRadius,
102
+ flexShrink: 1,
103
+ maxHeight: maxDynamicContentSize,
104
+ minHeight: 325,
105
+ overflow: 'hidden',
106
+ paddingBottom: theme.spacing(6),
107
+ paddingTop: theme.spacing(5.5)
108
+ }, styleProp]);
83
109
  const isBackdropTransparent = backdropOpacity <= 0;
84
110
 
85
111
  const OpacityAwareBackdrop = props => /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetBackdrop, _extends({}, props, {
86
112
  appearsOnIndex: 0,
87
113
  disappearsOnIndex: -1,
88
- opacity: backdropOpacity
114
+ opacity: backdropOpacity,
115
+ pressBehavior: onChange ? 'close' : 'none'
89
116
  }));
90
117
 
118
+ const topElementOpacity = (0, _core.useAnimatedValue)(0);
119
+ const topElementAnimationStyle = {
120
+ opacity: topElementOpacity
121
+ };
122
+ const topElementLocationStyle = {
123
+ position: 'absolute',
124
+ width: '100%',
125
+ bottom: 0
126
+ };
127
+
128
+ const onAnimate = (fromIndex, toIndex) => {
129
+ const isVisible = toIndex > -1;
130
+
131
+ _reactNative.Animated.timing(topElementOpacity, {
132
+ toValue: isVisible ? 1 : 0,
133
+ duration: 0,
134
+ useNativeDriver: _core.isNotAndroid12
135
+ }).start();
136
+ };
137
+
138
+ const {
139
+ animatedHandleHeight,
140
+ animatedSnapPoints,
141
+ animatedContentHeight,
142
+ handleContentLayout
143
+ } = (0, _useDynamicSnapPoints.default)(snapPoints);
91
144
  return /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetModalProvider, null, /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetModal, {
92
145
  backdropComponent: isBackdropTransparent ? _TransparentBackdrop.default : OpacityAwareBackdrop // @ts-ignore
93
146
  ,
@@ -97,9 +150,23 @@ function BottomSheet(props) {
97
150
  onChange: handleChange,
98
151
  onDismiss: handleDismiss,
99
152
  ref: bottomSheetRef,
100
- snapPoints: snapPoints,
101
- style: modalStyle
102
- }, children));
153
+ enablePanDownToClose: Boolean(onChange),
154
+ enableDynamicSizing: enableDynamicSizing,
155
+ maxDynamicContentSize: maxDynamicContentSize,
156
+ detached: Boolean(topElement),
157
+ onAnimate: topElement ? onAnimate : undefined,
158
+ snapPoints: animatedSnapPoints,
159
+ handleHeight: animatedHandleHeight,
160
+ contentHeight: animatedContentHeight
161
+ }, topElement ? /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
162
+ style: topElementAnimationStyle
163
+ }, /*#__PURE__*/_react.default.createElement(_core.Column, {
164
+ onLayout: handleTopElementLayout,
165
+ style: topElementLocationStyle
166
+ }, topElement)) : null, /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetView, {
167
+ onLayout: handleContentLayout,
168
+ style: contentWrapperStyle
169
+ }, children)));
103
170
  }
104
171
 
105
172
  ;
@@ -1 +1 @@
1
- {"version":3,"names":["NoHandle","BottomSheet","props","backdropOpacity","children","index","onChange","snapPoints","indexRef","React","useRef","bottomSheetRef","handleChange","useCallback","newIndex","current","handleDismiss","useEffect","present","dismiss","snapToIndex","theme","useTheme","shadow","modalStyle","backgroundColor","Platform","select","android","elevation","ios","web","boxShadow","backgroundStyle","palette","paper","default","isBackdropTransparent","OpacityAwareBackdrop","TransparentBackdrop"],"sources":["BottomSheetNative.tsx"],"sourcesContent":["import React from 'react';\nimport { Platform } from 'react-native';\nimport { useTheme } from '@fountain-ui/styles';\nimport {\n BottomSheetBackdrop,\n BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetModalProvider,\n} from '@gorhom/bottom-sheet';\nimport type BottomSheetProps from './BottomSheetProps';\nimport TransparentBackdrop from './TransparentBackdrop';\n\nconst NoHandle = () => null;\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity = 0.5,\n children,\n index,\n onChange,\n snapPoints,\n } = props;\n\n const indexRef = React.useRef<number>(-1);\n const bottomSheetRef = React.useRef<BottomSheetModal | null>(null);\n\n const handleChange = React.useCallback((newIndex: number) => {\n indexRef.current = newIndex;\n\n if (onChange) {\n onChange(newIndex);\n }\n }, [onChange]);\n\n const handleDismiss = React.useCallback(() => {\n handleChange(-1);\n }, [handleChange]);\n\n React.useEffect(() => {\n if (index === indexRef.current) {\n return;\n }\n\n if (indexRef.current < 0 && index >= 0) {\n bottomSheetRef.current?.present();\n } else if (indexRef.current >= 0 && index < 0) {\n bottomSheetRef.current?.dismiss();\n } else {\n // @ts-ignore\n bottomSheetRef.current?.snapToIndex(index);\n }\n }, [index]);\n\n const theme = useTheme();\n const shadow = theme.shadow[12];\n const modalStyle = {\n backgroundColor: '#ffffff00',\n ...Platform.select<object>({\n android: shadow?.elevation,\n ios: shadow?.shadow,\n web: shadow?.boxShadow,\n }),\n };\n const backgroundStyle = {\n backgroundColor: theme.palette.paper.default,\n };\n\n const isBackdropTransparent = backdropOpacity <= 0;\n\n const OpacityAwareBackdrop = (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={backdropOpacity}\n />\n );\n\n return (\n <BottomSheetModalProvider>\n <BottomSheetModal\n backdropComponent={isBackdropTransparent ? TransparentBackdrop : OpacityAwareBackdrop}\n // @ts-ignore\n backgroundStyle={backgroundStyle}\n index={index}\n handleComponent={NoHandle}\n onChange={handleChange}\n onDismiss={handleDismiss}\n ref={bottomSheetRef}\n snapPoints={snapPoints}\n style={modalStyle}\n >\n {children}\n </BottomSheetModal>\n </BottomSheetModalProvider>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;;;;;AAEA,MAAMA,QAAQ,GAAG,MAAM,IAAvB;;AAEe,SAASC,WAAT,CAAqBC,KAArB,EAA8C;EACzD,MAAM;IACFC,eAAe,GAAG,GADhB;IAEFC,QAFE;IAGFC,KAHE;IAIFC,QAJE;IAKFC;EALE,IAMFL,KANJ;;EAQA,MAAMM,QAAQ,GAAGC,cAAA,CAAMC,MAAN,CAAqB,CAAC,CAAtB,CAAjB;;EACA,MAAMC,cAAc,GAAGF,cAAA,CAAMC,MAAN,CAAsC,IAAtC,CAAvB;;EAEA,MAAME,YAAY,GAAGH,cAAA,CAAM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,MAAM,CAAES;IAHU,CAAxB;EAFY,CAAnB;EAQA,MAAMC,eAAe,GAAG;IACpBR,eAAe,EAAEJ,KAAK,CAACa,OAAN,CAAcC,KAAd,CAAoBC;EADjB,CAAxB;EAIA,MAAMC,qBAAqB,GAAGlC,eAAe,IAAI,CAAjD;;EAEA,MAAMmC,oBAAoB,GAAIpC,KAAD,iBACzB,6BAAC,gCAAD,eACQA,KADR;IAEI,cAAc,EAAE,CAFpB;IAGI,iBAAiB,EAAE,CAAC,CAHxB;IAII,OAAO,EAAEC;EAJb,GADJ;;EASA,oBACI,6BAAC,qCAAD,qBACI,6BAAC,6BAAD;IACI,iBAAiB,EAAEkC,qBAAqB,GAAGE,4BAAH,GAAyBD,oBADrE,CAEI;IAFJ;IAGI,eAAe,EAAEL,eAHrB;IAII,KAAK,EAAE5B,KAJX;IAKI,eAAe,EAAEL,QALrB;IAMI,QAAQ,EAAEY,YANd;IAOI,SAAS,EAAEI,aAPf;IAQI,GAAG,EAAEL,cART;IASI,UAAU,EAAEJ,UAThB;IAUI,KAAK,EAAEiB;EAVX,GAYKpB,QAZL,CADJ,CADJ;AAkBH;;AAAA"}
1
+ {"version":3,"names":["NoHandle","BottomSheet","props","backdropOpacity","backgroundStyle","backgroundStyleProp","borderRadius","borderRadiusProp","children","enableDynamicSizing","topElement","index","maxHeightNormalizedRatio","onChange","snapPoints","style","styleProp","indexRef","useRef","bottomSheetRef","height","windowHeight","useWindowDimensions","topElementHeight","setTopElementHeight","useState","maxDynamicContentSize","Math","round","handleTopElementLayout","event","nativeEvent","layout","handleChange","useCallback","newIndex","current","handleDismiss","useEffect","present","dismiss","snapToIndex","theme","useTheme","shape","radius","xxl","css","backgroundColor","palette","surface","base","borderTopLeftRadius","borderTopRightRadius","contentWrapperStyle","flexShrink","maxHeight","minHeight","overflow","paddingBottom","spacing","paddingTop","isBackdropTransparent","OpacityAwareBackdrop","topElementOpacity","useAnimatedValue","topElementAnimationStyle","opacity","topElementLocationStyle","position","width","bottom","onAnimate","fromIndex","toIndex","isVisible","Animated","timing","toValue","duration","useNativeDriver","isNotAndroid12","start","animatedHandleHeight","animatedSnapPoints","animatedContentHeight","handleContentLayout","useDynamicSnapPoints","TransparentBackdrop","Boolean","undefined"],"sources":["BottomSheetNative.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { Animated, LayoutChangeEvent, useWindowDimensions, ViewStyle } from 'react-native';\nimport {\n BottomSheetBackdrop,\n BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetModalProvider,\n BottomSheetView,\n} from '@gorhom/bottom-sheet';\nimport { Column, css, ExtendedStyle, isNotAndroid12, useAnimatedValue } from '@fountain-ui/core';\nimport { useTheme } from '@fountain-ui/styles';\nimport type BottomSheetProps from './BottomSheetProps';\nimport TransparentBackdrop from './TransparentBackdrop';\nimport useDynamicSnapPoints from './useDynamicSnapPoints.native';\n\nconst NoHandle = () => null;\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity = 0.5,\n backgroundStyle: backgroundStyleProp,\n borderRadius: borderRadiusProp,\n children,\n enableDynamicSizing = true,\n topElement,\n index,\n maxHeightNormalizedRatio = 0.8,\n onChange,\n snapPoints = [],\n style: styleProp,\n } = props;\n\n const indexRef = useRef<number>(-1);\n const bottomSheetRef = useRef<BottomSheetModal | null>(null);\n\n const { height: windowHeight } = useWindowDimensions();\n const [topElementHeight, setTopElementHeight] = useState(0);\n\n const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio) - topElementHeight;\n\n const handleTopElementLayout = (event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n setTopElementHeight(height);\n };\n\n const handleChange = useCallback((newIndex: number) => {\n indexRef.current = newIndex;\n\n if (onChange) {\n onChange(newIndex);\n }\n }, [onChange]);\n\n const handleDismiss = useCallback(() => {\n handleChange(-1);\n }, [handleChange]);\n\n useEffect(() => {\n if (index === indexRef.current) {\n return;\n }\n\n if (indexRef.current < 0 && index >= 0) {\n bottomSheetRef.current?.present();\n } else if (indexRef.current >= 0 && index < 0) {\n bottomSheetRef.current?.dismiss();\n } else {\n // @ts-ignore\n bottomSheetRef.current?.snapToIndex(index);\n }\n }, [index]);\n\n const theme = useTheme();\n\n const borderRadius = borderRadiusProp ?? theme.shape.radius.xxl;\n const backgroundStyle = css([\n {\n backgroundColor: theme.palette.surface.base,\n borderTopLeftRadius: borderRadius,\n borderTopRightRadius: borderRadius,\n },\n backgroundStyleProp,\n ]);\n\n const contentWrapperStyle: ViewStyle = css([\n {\n backgroundColor: theme.palette.surface.base,\n borderTopLeftRadius: borderRadius,\n borderTopRightRadius: borderRadius,\n flexShrink: 1,\n maxHeight: maxDynamicContentSize,\n minHeight: 325,\n overflow: 'hidden',\n paddingBottom: theme.spacing(6),\n paddingTop: theme.spacing(5.5),\n },\n styleProp,\n ]);\n\n const isBackdropTransparent = backdropOpacity <= 0;\n\n const OpacityAwareBackdrop = (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={backdropOpacity}\n pressBehavior={onChange ? 'close' : 'none'}\n />\n );\n\n const topElementOpacity = useAnimatedValue(0);\n const topElementAnimationStyle: Animated.WithAnimatedValue<ExtendedStyle> = { opacity: topElementOpacity };\n const topElementLocationStyle: ExtendedStyle = {\n position: 'absolute',\n width: '100%',\n bottom: 0,\n };\n const onAnimate = (fromIndex: number, toIndex: number) => {\n const isVisible = toIndex > -1;\n\n Animated.timing(topElementOpacity, {\n toValue: isVisible ? 1 : 0,\n duration: 0,\n useNativeDriver: isNotAndroid12,\n }).start();\n };\n\n const {\n animatedHandleHeight,\n animatedSnapPoints,\n animatedContentHeight,\n handleContentLayout,\n } = useDynamicSnapPoints(snapPoints);\n\n return (\n <BottomSheetModalProvider>\n <BottomSheetModal\n backdropComponent={isBackdropTransparent ? TransparentBackdrop : OpacityAwareBackdrop}\n // @ts-ignore\n backgroundStyle={backgroundStyle}\n index={index}\n handleComponent={NoHandle}\n onChange={handleChange}\n onDismiss={handleDismiss}\n ref={bottomSheetRef}\n enablePanDownToClose={Boolean(onChange)}\n enableDynamicSizing={enableDynamicSizing}\n maxDynamicContentSize={maxDynamicContentSize}\n detached={Boolean(topElement)}\n onAnimate={topElement ? onAnimate : undefined}\n snapPoints={animatedSnapPoints}\n handleHeight={animatedHandleHeight}\n contentHeight={animatedContentHeight}\n >\n {topElement ? (\n <Animated.View style={topElementAnimationStyle}>\n <Column\n onLayout={handleTopElementLayout}\n style={topElementLocationStyle}\n >\n {topElement}\n </Column>\n </Animated.View>\n ) : null}\n\n <BottomSheetView\n onLayout={handleContentLayout}\n style={contentWrapperStyle}\n >\n {children}\n </BottomSheetView>\n </BottomSheetModal>\n </BottomSheetModalProvider>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAOA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,MAAMA,QAAQ,GAAG,MAAM,IAAvB;;AAEe,SAASC,WAAT,CAAqBC,KAArB,EAA8C;EACzD,MAAM;IACFC,eAAe,GAAG,GADhB;IAEFC,eAAe,EAAEC,mBAFf;IAGFC,YAAY,EAAEC,gBAHZ;IAIFC,QAJE;IAKFC,mBAAmB,GAAG,IALpB;IAMFC,UANE;IAOFC,KAPE;IAQFC,wBAAwB,GAAG,GARzB;IASFC,QATE;IAUFC,UAAU,GAAG,EAVX;IAWFC,KAAK,EAAEC;EAXL,IAYFd,KAZJ;EAcA,MAAMe,QAAQ,GAAG,IAAAC,aAAA,EAAe,CAAC,CAAhB,CAAjB;EACA,MAAMC,cAAc,GAAG,IAAAD,aAAA,EAAgC,IAAhC,CAAvB;EAEA,MAAM;IAAEE,MAAM,EAAEC;EAAV,IAA2B,IAAAC,gCAAA,GAAjC;EACA,MAAM,CAACC,gBAAD,EAAmBC,mBAAnB,IAA0C,IAAAC,eAAA,EAAS,CAAT,CAAhD;EAEA,MAAMC,qBAAqB,GAAGC,IAAI,CAACC,KAAL,CAA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version":3,"names":[],"sources":["BottomSheetProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport default interface BottomSheetProps extends ComponentProps<{\n /**\n * Opacity for BackdropComponent\n * @default 0.5\n */\n backdropOpacity?: number;\n\n /**\n * BottomSheet children, usually the included sub-components.\n */\n children?: React.ReactNode;\n\n /**\n * Snap index. You could also provide -1 to bottom sheet in closed state.\n */\n index: number;\n\n /**\n * Callback fired when the index is changed.\n * Important! Use memoized value.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * Points for the bottom sheet to snap to, points should be sorted from bottom to top.\n * Important! Use memoized value.\n */\n snapPoints: Array<number>;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["BottomSheetProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ComponentProps, ExtendedStyle } from '@fountain-ui/core';\n\nexport default interface BottomSheetProps extends ComponentProps<{\n /**\n * Opacity for BackdropComponent\n * @default 0.5\n */\n backdropOpacity?: number;\n\n /**\n * View style to be applied to the background component. (only native)\n */\n backgroundStyle?: ExtendedStyle | ExtendedStyle[];\n\n /**\n * Border radius for bottom sheet\n */\n borderRadius?: number;\n\n /**\n * BottomSheet children, usually the included sub-components.\n */\n children?: React.ReactNode;\n\n /**\n * Enable dynamic sizing for content size.\n * @default true\n */\n enableDynamicSizing?: boolean;\n\n /**\n * Top element for displaying additional information on the bottom sheet.\n */\n topElement?: React.ReactNode;\n\n /**\n * Snap index. You could also provide -1 to bottom sheet in closed state.\n */\n index: number;\n\n /**\n * Maximum height(normalized value) of dialog\n * ex. 30% => 0.3 / 90% => 0.9\n * @default 0.8\n */\n maxHeightNormalizedRatio?: number;\n\n /**\n * Callback fired when the index is changed.\n * Important! Use memoized value.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * Points for the bottom sheet to snap to, points should be sorted from bottom to top.\n * Important! Use memoized value.\n * Only number type or string type(~% format) can be used.\n * @default []\n */\n snapPoints?: Array<number | string>;\n\n /**\n * View style to be applied to the content area.\n */\n style?: ExtendedStyle | ExtendedStyle[];\n}> {}\n"],"mappings":""}
@@ -5,14 +5,22 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = BottomSheet;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
9
11
 
10
12
  var _core = require("@fountain-ui/core");
11
13
 
12
14
  var _AnimatedY = _interopRequireDefault(require("../AnimatedY"));
13
15
 
16
+ var _useDynamicSnapPoints = _interopRequireDefault(require("./useDynamicSnapPoints"));
17
+
14
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
19
 
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ 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; }
23
+
16
24
  const useStyles = function () {
17
25
  const theme = (0, _core.useTheme)();
18
26
  return {
@@ -26,27 +34,49 @@ const useStyles = function () {
26
34
  width: '100%'
27
35
  },
28
36
  paper: {
29
- borderBottomLeftRadius: 0,
30
- borderBottomRightRadius: 0,
37
+ backgroundColor: theme.palette.surface.base,
38
+ borderTopLeftRadius: theme.shape.radius.xxl,
39
+ borderTopRightRadius: theme.shape.radius.xxl,
31
40
  flexGrow: 1,
32
- overflow: 'hidden'
41
+ minHeight: 325,
42
+ overflow: 'hidden',
43
+ paddingBottom: theme.spacing(6),
44
+ paddingTop: theme.spacing(5.5)
45
+ },
46
+ topElementLocation: {
47
+ position: 'absolute',
48
+ bottom: 0,
49
+ width: '100%'
33
50
  }
34
51
  };
35
52
  };
36
53
 
37
- const calculateHeight = points => {
38
- return points[points.length - 1] ?? 0;
39
- };
40
-
41
54
  function BottomSheet(props) {
42
55
  const {
43
56
  backdropOpacity,
57
+ borderRadius,
44
58
  children,
59
+ enableDynamicSizing = true,
60
+ topElement,
45
61
  index,
62
+ maxHeightNormalizedRatio = 0.8,
46
63
  onChange,
47
- snapPoints
64
+ snapPoints = [],
65
+ style: styleProp
48
66
  } = props;
49
67
  const styles = useStyles();
68
+ const {
69
+ height: windowHeight
70
+ } = (0, _reactNative.useWindowDimensions)();
71
+ const [topElementHeight, setTopElementHeight] = (0, _react.useState)(0);
72
+ const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio) - topElementHeight;
73
+
74
+ const handleTopElementLayout = event => {
75
+ const {
76
+ height
77
+ } = event.nativeEvent.layout;
78
+ setTopElementHeight(height);
79
+ };
50
80
 
51
81
  const handleClose = () => {
52
82
  if (onChange) {
@@ -54,21 +84,38 @@ function BottomSheet(props) {
54
84
  }
55
85
  };
56
86
 
57
- const height = calculateHeight(snapPoints);
58
- const translateY = height - (snapPoints[index] ?? 0);
87
+ const {
88
+ convertedSnapPoints,
89
+ handleLayout,
90
+ highestSnapPoint
91
+ } = (0, _useDynamicSnapPoints.default)({
92
+ enableDynamicSizing,
93
+ maxDynamicContentSize,
94
+ snapPoints
95
+ });
96
+ const translateY = highestSnapPoint - (convertedSnapPoints[index] ?? 0);
97
+ const contentStyles = (0, _core.css)([styles.paper, { ...(borderRadius ? {
98
+ borderTopLeftRadius: borderRadius,
99
+ borderTopRightRadius: borderRadius
100
+ } : {}),
101
+ ...(highestSnapPoint !== maxDynamicContentSize ? {
102
+ height: highestSnapPoint
103
+ } : {}),
104
+ maxHeight: maxDynamicContentSize
105
+ }, styleProp]);
59
106
  return /*#__PURE__*/_react.default.createElement(_core.Modal, {
60
107
  backdropOpacity: backdropOpacity,
61
108
  onClose: handleClose,
62
109
  visible: index >= 0,
63
110
  style: (0, _core.css)([_core.StyleSheet.absoluteFill, styles.root])
64
111
  }, /*#__PURE__*/_react.default.createElement(_AnimatedY.default, {
65
- style: styles.animated,
66
112
  translateY: translateY
67
- }, /*#__PURE__*/_react.default.createElement(_core.Paper, {
68
- elevation: 12,
69
- style: [styles.paper, {
70
- height
71
- }]
113
+ }, topElement ? /*#__PURE__*/_react.default.createElement(_core.Column, {
114
+ onLayout: handleTopElementLayout,
115
+ style: styles.topElementLocation
116
+ }, topElement) : null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
117
+ onLayout: handleLayout,
118
+ style: contentStyles
72
119
  }, children)));
73
120
  }
74
121
 
@@ -1 +1 @@
1
- {"version":3,"names":["useStyles","theme","useTheme","root","justifyContent","zIndex","dialog","animated","alignSelf","maxWidth","width","paper","borderBottomLeftRadius","borderBottomRightRadius","flexGrow","overflow","calculateHeight","points","length","BottomSheet","props","backdropOpacity","children","index","onChange","snapPoints","styles","handleClose","height","translateY","css","StyleSheet","absoluteFill"],"sources":["BottomSheetWeb.tsx"],"sourcesContent":["import React from 'react';\nimport { Modal, Paper, StyleSheet, css, useTheme } from '@fountain-ui/core';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport AnimatedY from '../AnimatedY';\nimport type BottomSheetProps from './BottomSheetProps';\n\ntype BottomSheetStyles = NamedStylesStringUnion<'root' | 'animated' | 'paper'>;\n\nconst useStyles: UseStyles<BottomSheetStyles> = function (): BottomSheetStyles {\n const theme = useTheme();\n\n return {\n root: {\n justifyContent: 'flex-end',\n zIndex: theme.zIndex.dialog\n },\n animated: {\n alignSelf: 'center',\n maxWidth: 720,\n width: '100%',\n },\n paper: {\n borderBottomLeftRadius: 0,\n borderBottomRightRadius: 0,\n flexGrow: 1,\n overflow: 'hidden',\n },\n };\n};\n\nconst calculateHeight = (points: BottomSheetProps['snapPoints']): number => {\n return points[points.length - 1] ?? 0;\n};\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity,\n children,\n index,\n onChange,\n snapPoints,\n } = props;\n\n const styles = useStyles();\n\n const handleClose = () => {\n if (onChange) {\n onChange(-1);\n }\n };\n\n const height = calculateHeight(snapPoints);\n const translateY = height - (snapPoints[index] ?? 0);\n\n return (\n <Modal\n backdropOpacity={backdropOpacity}\n onClose={handleClose}\n visible={index >= 0}\n style={css([StyleSheet.absoluteFill, styles.root])}\n >\n <AnimatedY\n style={styles.animated}\n translateY={translateY}\n >\n <Paper\n elevation={12}\n style={[\n styles.paper,\n { height },\n ]}\n >\n {children}\n </Paper>\n </AnimatedY>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;AAKA,MAAMA,SAAuC,GAAG,YAA+B;EAC3E,MAAMC,KAAK,GAAG,IAAAC,cAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,cAAc,EAAE,UADd;MAEFC,MAAM,EAAEJ,KAAK,CAACI,MAAN,CAAaC;IAFnB,CADH;IAKHC,QAAQ,EAAE;MACNC,SAAS,EAAE,QADL;MAENC,QAAQ,EAAE,GAFJ;MAGNC,KAAK,EAAE;IAHD,CALP;IAUHC,KAAK,EAAE;MACHC,sBAAsB,EAAE,CADrB;MAEHC,uBAAuB,EAAE,CAFtB;MAGHC,QAAQ,EAAE,CAHP;MAIHC,QAAQ,EAAE;IAJP;EAVJ,CAAP;AAiBH,CApBD;;AAsBA,MAAMC,eAAe,GAAIC,MAAD,IAAoD;EACxE,OAAOA,MAAM,CAACA,MAAM,CAACC,MAAP,GAAgB,CAAjB,CAAN,IAA6B,CAApC;AACH,CAFD;;AAIe,SAASC,WAAT,CAAqBC,KAArB,EAA8C;EACzD,MAAM;IACFC,eADE;IAEFC,QAFE;IAGFC,KAHE;IAIFC,QAJE;IAKFC;EALE,IAMFL,KANJ;EAQA,MAAMM,MAAM,GAAG1B,SAAS,EAAxB;;EAEA,MAAM2B,WAAW,GAAG,MAAM;IACtB,IAAIH,QAAJ,EAAc;MACVA,QAAQ,CAAC,CAAC,CAAF,CAAR;IACH;EACJ,CAJD;;EAMA,MAAMI,MAAM,GAAGZ,eAAe,CAACS,UAAD,CAA9B;EACA,MAAMI,UAAU,GAAGD,MAAM,IAAIH,UAAU,CAACF,KAAD,CAAV,IAAqB,CAAzB,CAAzB;EAEA,oBACI,6BAAC,WAAD;IACI,eAAe,EAAEF,eADrB;IAEI,OAAO,EAAEM,WAFb;IAGI,OAAO,EAAEJ,KAAK,IAAI,CAHtB;IAII,KAAK,EAAE,IAAAO,SAAA,EAAI,CAACC,gBAAA,CAAWC,YAAZ,EAA0BN,MAAM,CAACvB,IAAjC,CAAJ;EAJX,gBAMI,6BAAC,kBAAD;IACI,KAAK,EAAEuB,MAAM,CAACnB,QADlB;IAEI,UAAU,EAAEsB;EAFhB,gBAII,6BAAC,WAAD;IACI,SAAS,EAAE,EADf;IAEI,KAAK,EAAE,CACHH,MAAM,CAACf,KADJ,EAEH;MAAEiB;IAAF,CAFG;EAFX,GAOKN,QAPL,CAJJ,CANJ,CADJ;AAuBH;;AAAA"}
1
+ {"version":3,"names":["useStyles","theme","useTheme","root","justifyContent","zIndex","dialog","animated","alignSelf","maxWidth","width","paper","backgroundColor","palette","surface","base","borderTopLeftRadius","shape","radius","xxl","borderTopRightRadius","flexGrow","minHeight","overflow","paddingBottom","spacing","paddingTop","topElementLocation","position","bottom","BottomSheet","props","backdropOpacity","borderRadius","children","enableDynamicSizing","topElement","index","maxHeightNormalizedRatio","onChange","snapPoints","style","styleProp","styles","height","windowHeight","useWindowDimensions","topElementHeight","setTopElementHeight","useState","maxDynamicContentSize","Math","round","handleTopElementLayout","event","nativeEvent","layout","handleClose","convertedSnapPoints","handleLayout","highestSnapPoint","useDynamicSnapPoints","translateY","contentStyles","css","maxHeight","StyleSheet","absoluteFill"],"sources":["BottomSheetWeb.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { LayoutChangeEvent, useWindowDimensions, View } from 'react-native';\nimport { Column, css, Modal, StyleSheet, useTheme } from '@fountain-ui/core';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport AnimatedY from '../AnimatedY';\nimport type BottomSheetProps from './BottomSheetProps';\nimport useDynamicSnapPoints from './useDynamicSnapPoints';\n\ntype BottomSheetStyles = NamedStylesStringUnion<'root' | 'animated' | 'paper' | 'topElementLocation'>;\n\nconst useStyles: UseStyles<BottomSheetStyles> = function (): BottomSheetStyles {\n const theme = useTheme();\n\n return {\n root: {\n justifyContent: 'flex-end',\n zIndex: theme.zIndex.dialog,\n },\n animated: {\n alignSelf: 'center',\n maxWidth: 720,\n width: '100%',\n },\n paper: {\n backgroundColor: theme.palette.surface.base,\n borderTopLeftRadius: theme.shape.radius.xxl,\n borderTopRightRadius: theme.shape.radius.xxl,\n flexGrow: 1,\n minHeight: 325,\n overflow: 'hidden',\n paddingBottom: theme.spacing(6),\n paddingTop: theme.spacing(5.5),\n },\n topElementLocation: {\n position: 'absolute',\n bottom: 0,\n width: '100%',\n },\n };\n};\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity,\n borderRadius,\n children,\n enableDynamicSizing = true,\n topElement,\n index,\n maxHeightNormalizedRatio = 0.8,\n onChange,\n snapPoints = [],\n style: styleProp,\n } = props;\n\n const styles = useStyles();\n\n const { height: windowHeight } = useWindowDimensions();\n\n const [topElementHeight, setTopElementHeight] = useState(0);\n\n const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio) - topElementHeight;\n\n const handleTopElementLayout = (event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n setTopElementHeight(height);\n };\n\n const handleClose = () => {\n if (onChange) {\n onChange(-1);\n }\n };\n\n const {\n convertedSnapPoints,\n handleLayout,\n highestSnapPoint,\n } = useDynamicSnapPoints({\n enableDynamicSizing,\n maxDynamicContentSize,\n snapPoints,\n });\n\n const translateY = highestSnapPoint - (convertedSnapPoints[index] ?? 0);\n\n const contentStyles = css([\n styles.paper,\n {\n ...(borderRadius ? { borderTopLeftRadius: borderRadius, borderTopRightRadius: borderRadius } : {}),\n ...(highestSnapPoint !== maxDynamicContentSize ? { height: highestSnapPoint } : {}),\n maxHeight: maxDynamicContentSize,\n },\n styleProp,\n ]);\n\n return (\n <Modal\n backdropOpacity={backdropOpacity}\n onClose={handleClose}\n visible={index >= 0}\n style={css([StyleSheet.absoluteFill, styles.root])}\n >\n <AnimatedY translateY={translateY}>\n {topElement ? (\n <Column\n onLayout={handleTopElementLayout}\n style={styles.topElementLocation}\n >\n {topElement}\n </Column>\n ) : null}\n\n <View\n onLayout={handleLayout}\n style={contentStyles}\n >\n {children}\n </View>\n </AnimatedY>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;;;;;;;AAIA,MAAMA,SAAuC,GAAG,YAA+B;EAC3E,MAAMC,KAAK,GAAG,IAAAC,cAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,cAAc,EAAE,UADd;MAEFC,MAAM,EAAEJ,KAAK,CAACI,MAAN,CAAaC;IAFnB,CADH;IAKHC,QAAQ,EAAE;MACNC,SAAS,EAAE,QADL;MAENC,QAAQ,EAAE,GAFJ;MAGNC,KAAK,EAAE;IAHD,CALP;IAUHC,KAAK,EAAE;MACHC,eAAe,EAAEX,KAAK,CAACY,OAAN,CAAcC,OAAd,CAAsBC,IADpC;MAEHC,mBAAmB,EAAEf,KAAK,CAACgB,KAAN,CAAYC,MAAZ,CAAmBC,GAFrC;MAGHC,oBAAoB,EAAEnB,KAAK,CAACgB,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C,6BAAA,EAAqB;IACrB1B,mBADqB;IAErBe,qBAFqB;IAGrBV;EAHqB,CAArB,CAJJ;EAUA,MAAMsB,UAAU,GAAGF,gBAAgB,IAAIF,mBAAmB,CAACrB,KAAD,CAAnB,IAA8B,CAAlC,CAAnC;EAEA,MAAM0B,aAAa,GAAG,IAAAC,SAAA,EAAI,CACtBrB,MAAM,CAAChC,KADe,EAEtB,EACI,IAAIsB,YAAY,GAAG;MAAEjB,mBAAmB,EAAEiB,YAAvB;MAAqCb,oBAAoB,EAAEa;IAA3D,CAAH,GAA+E,EAA/F,CADJ;IAEI,IAAI2B,gBAAgB,KAAKV,qBAArB,GAA6C;MAAEN,MAAM,EAAEgB;IAAV,CAA7C,GAA4E,EAAhF,CAFJ;IAGIK,SAAS,EAAEf;EAHf,CAFsB,EAOtBR,SAPsB,CAAJ,CAAtB;EAUA,oBACI,6BAAC,WAAD;IACI,eAAe,EAAEV,eADrB;IAEI,OAAO,EAAEyB,WAFb;IAGI,OAAO,EAAEpB,KAAK,IAAI,CAHtB;IAII,KAAK,EAAE,IAAA2B,SAAA,EAAI,CAACE,gBAAA,CAAWC,YAAZ,EAA0BxB,MAAM,CAACxC,IAAjC,CAAJ;EAJX,gBAMI,6BAAC,kBAAD;IAAW,UAAU,EAAE2D;EAAvB,GACK1B,UAAU,gBACP,6BAAC,YAAD;IACI,QAAQ,EAAEiB,sBADd;IAEI,KAAK,EAAEV,MAAM,CAAChB;EAFlB,GAIKS,UAJL,CADO,GAOP,IARR,eAUI,6BAAC,iBAAD;IACI,QAAQ,EAAEuB,YADd;IAEI,KAAK,EAAEI;EAFX,GAIK7B,QAJL,CAVJ,CANJ,CADJ;AA0BH;;AAAA"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useDynamicSnapPoints;
7
+
8
+ var _react = require("react");
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var R = _interopRequireWildcard(require("ramda"));
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ 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; }
17
+
18
+ const INITIAL_CONTAINER_HEIGHT = -999;
19
+
20
+ const convertSnapPoint = (snapPoint, windowHeight, maxDynamicContentSize) => {
21
+ if (typeof snapPoint === 'number') {
22
+ return Math.min(maxDynamicContentSize, snapPoint);
23
+ }
24
+
25
+ const percentageRegex = new RegExp(/^[0-9]+%$/);
26
+
27
+ if (percentageRegex.test(snapPoint)) {
28
+ const percentage = parseFloat(snapPoint) / 100;
29
+ return isNaN(percentage) ? 0 : Math.min(maxDynamicContentSize, Math.round(windowHeight * percentage));
30
+ }
31
+
32
+ return 0;
33
+ };
34
+
35
+ function useDynamicSnapPoints(params) {
36
+ const {
37
+ enableDynamicSizing,
38
+ maxDynamicContentSize,
39
+ snapPoints
40
+ } = params;
41
+ const {
42
+ height: windowHeight
43
+ } = (0, _reactNative.useWindowDimensions)();
44
+ const [contentHeight, setContentHeight] = (0, _react.useState)(INITIAL_CONTAINER_HEIGHT);
45
+ const hasMeasureRef = (0, _react.useRef)(false);
46
+ const convertedSnapPoints = (0, _react.useMemo)(() => {
47
+ if (contentHeight === INITIAL_CONTAINER_HEIGHT) {
48
+ return [];
49
+ }
50
+
51
+ const convertedSnapPoints = snapPoints.map(snapPoint => {
52
+ return convertSnapPoint(snapPoint, windowHeight, maxDynamicContentSize);
53
+ });
54
+
55
+ if (enableDynamicSizing && contentHeight !== 0) {
56
+ convertedSnapPoints.push(convertSnapPoint(contentHeight, windowHeight, maxDynamicContentSize));
57
+ }
58
+
59
+ return Array.from(new Set(convertedSnapPoints)).sort((a, b) => a - b);
60
+ }, [contentHeight, enableDynamicSizing, maxDynamicContentSize, snapPoints, windowHeight]);
61
+ const highestSnapPoint = R.last(convertedSnapPoints) ?? maxDynamicContentSize;
62
+ const handleLayout = (0, _react.useCallback)(event => {
63
+ if (hasMeasureRef.current) {
64
+ return;
65
+ }
66
+
67
+ hasMeasureRef.current = true;
68
+ const {
69
+ height
70
+ } = event.nativeEvent.layout;
71
+ setContentHeight(height);
72
+ }, []);
73
+ return {
74
+ convertedSnapPoints,
75
+ handleLayout,
76
+ highestSnapPoint
77
+ };
78
+ }
79
+ //# sourceMappingURL=useDynamicSnapPoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["INITIAL_CONTAINER_HEIGHT","convertSnapPoint","snapPoint","windowHeight","maxDynamicContentSize","Math","min","percentageRegex","RegExp","test","percentage","parseFloat","isNaN","round","useDynamicSnapPoints","params","enableDynamicSizing","snapPoints","height","useWindowDimensions","contentHeight","setContentHeight","useState","hasMeasureRef","useRef","convertedSnapPoints","useMemo","map","push","Array","from","Set","sort","a","b","highestSnapPoint","R","last","handleLayout","useCallback","event","current","nativeEvent","layout"],"sources":["useDynamicSnapPoints.ts"],"sourcesContent":["import { useCallback, useMemo, useRef, useState } from 'react';\nimport { LayoutChangeEvent, useWindowDimensions } from 'react-native';\nimport * as R from 'ramda';\n\nconst INITIAL_CONTAINER_HEIGHT = -999;\n\ninterface UseDynamicSnapPointsParams {\n enableDynamicSizing: boolean;\n maxDynamicContentSize: number;\n snapPoints: (number | string)[];\n}\n\ninterface UseDynamicSnapPointsReturns {\n convertedSnapPoints: number[];\n handleLayout: (e: LayoutChangeEvent) => void;\n highestSnapPoint: number;\n}\n\nconst convertSnapPoint = (snapPoint: number | string, windowHeight: number, maxDynamicContentSize: number): number => {\n if (typeof snapPoint === 'number') {\n return Math.min(maxDynamicContentSize, snapPoint);\n }\n\n const percentageRegex = new RegExp(/^[0-9]+%$/);\n if (percentageRegex.test(snapPoint)) {\n const percentage = parseFloat(snapPoint) / 100;\n return isNaN(percentage) ? 0 : Math.min(maxDynamicContentSize, Math.round(windowHeight * percentage));\n }\n\n return 0;\n};\n\nexport default function useDynamicSnapPoints(params: UseDynamicSnapPointsParams): UseDynamicSnapPointsReturns {\n const {\n enableDynamicSizing,\n maxDynamicContentSize,\n snapPoints,\n } = params;\n\n const { height: windowHeight } = useWindowDimensions();\n\n const [contentHeight, setContentHeight] = useState<number>(INITIAL_CONTAINER_HEIGHT);\n\n const hasMeasureRef = useRef<boolean>(false);\n\n const convertedSnapPoints = useMemo(() => {\n if (contentHeight === INITIAL_CONTAINER_HEIGHT) {\n return [];\n }\n\n const convertedSnapPoints = snapPoints.map((snapPoint) => {\n return convertSnapPoint(snapPoint, windowHeight, maxDynamicContentSize);\n });\n\n if (enableDynamicSizing && contentHeight !== 0) {\n convertedSnapPoints.push(\n convertSnapPoint(contentHeight, windowHeight, maxDynamicContentSize),\n );\n }\n\n return Array.from(new Set(convertedSnapPoints)).sort((a, b) => a - b);\n }, [\n contentHeight,\n enableDynamicSizing,\n maxDynamicContentSize,\n snapPoints,\n windowHeight,\n ]);\n\n const highestSnapPoint = R.last(convertedSnapPoints) ?? maxDynamicContentSize;\n\n const handleLayout = useCallback((event: LayoutChangeEvent) => {\n if (hasMeasureRef.current) {\n return;\n }\n\n hasMeasureRef.current = true;\n const { height } = event.nativeEvent.layout;\n setContentHeight(height);\n }, []);\n\n return {\n convertedSnapPoints,\n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ACC,SAAD,EAAYC,YAAZ,EAA0BC,qBAA1B,CAAvB;IACH,CAF2B,CAA5B;;IAIA,IAAIY,mBAAmB,IAAII,aAAa,KAAK,CAA7C,EAAgD;MAC5CK,mBAAmB,CAACG,IAApB,CACI3B,gBAAgB,CAACmB,aAAD,EAAgBjB,YAAhB,EAA8BC,qBAA9B,CADpB;IAGH;;IAED,OAAOyB,KAAK,CAACC,IAAN,CAAW,IAAIC,GAAJ,CAAQN,mBAAR,CAAX,EAAyCO,IAAzC,CAA8C,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,GAAGC,CAA5D,CAAP;EACH,CAhB2B,EAgBzB,CACCd,aADD,EAECJ,mBAFD,EAGCZ,qBAHD,EAICa,UAJD,EAKCd,YALD,CAhByB,CAA5B;EAwBA,MAAMgC,gBAAgB,GAAGC,CAAC,CAACC,IAAF,CAAOZ,mBAAP,KAA+BrB,qBAAxD;EAEA,MAAMkC,YAAY,GAAG,IAAAC,kBAAA,EAAaC,KAAD,IAA8B;IAC3D,IAAIjB,aAAa,CAACkB,OAAlB,EAA2B;MACvB;IACH;;IAEDlB,aAAa,CAACkB,OAAd,GAAwB,IAAxB;IACA,MAAM;MAAEvB;IAAF,IAAasB,KAAK,CAACE,WAAN,CAAkBC,MAArC;IACAtB,gBAAgB,CAACH,MAAD,CAAhB;EACH,CARoB,EAQlB,EARkB,CAArB;EAUA,OAAO;IACHO,mBADG;IAEHa,YAFG;IAGHH;EAHG,CAAP;AAKH"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useDynamicSnapPoints;
7
+
8
+ var _bottomSheet = require("@gorhom/bottom-sheet");
9
+
10
+ function useDynamicSnapPoints(snapPoints) {
11
+ if (snapPoints !== null && snapPoints !== void 0 && snapPoints.includes('CONTENT_HEIGHT')) {
12
+ return (0, _bottomSheet.useBottomSheetDynamicSnapPoints)(snapPoints);
13
+ }
14
+
15
+ return {
16
+ animatedHandleHeight: undefined,
17
+ animatedSnapPoints: snapPoints,
18
+ animatedContentHeight: undefined,
19
+ handleContentLayout: undefined
20
+ };
21
+ }
22
+ //# sourceMappingURL=useDynamicSnapPoints.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useDynamicSnapPoints","snapPoints","includes","useBottomSheetDynamicSnapPoints","animatedHandleHeight","undefined","animatedSnapPoints","animatedContentHeight","handleContentLayout"],"sources":["useDynamicSnapPoints.native.ts"],"sourcesContent":["import { useBottomSheetDynamicSnapPoints } from '@gorhom/bottom-sheet';\nimport type BottomSheetProps from './BottomSheetProps';\n\nexport default function useDynamicSnapPoints(snapPoints: BottomSheetProps['snapPoints']) {\n if (snapPoints?.includes('CONTENT_HEIGHT')) {\n return useBottomSheetDynamicSnapPoints(snapPoints);\n }\n\n return {\n animatedHandleHeight: undefined,\n animatedSnapPoints: snapPoints,\n animatedContentHeight: undefined,\n handleContentLayout: undefined,\n };\n}\n"],"mappings":";;;;;;;AAAA;;AAGe,SAASA,oBAAT,CAA8BC,UAA9B,EAA0E;EACrF,IAAIA,UAAJ,aAAIA,UAAJ,eAAIA,UAAU,CAAEC,QAAZ,CAAqB,gBAArB,CAAJ,EAA4C;IACxC,OAAO,IAAAC,4CAAA,EAAgCF,UAAhC,CAAP;EACH;;EAED,OAAO;IACHG,oBAAoB,EAAEC,SADnB;IAEHC,kBAAkB,EAAEL,UAFjB;IAGHM,qBAAqB,EAAEF,SAHpB;IAIHG,mBAAmB,EAAEH;EAJlB,CAAP;AAMH"}
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _ViewabilityTrackerView = _interopRequireDefault(require("../ViewabilityTrackerView"));
11
+
12
+ var _hooks = require("./hooks");
13
+
14
+ var _animation = require("./animation");
15
+
16
+ var _components = require("./components");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ 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; }
23
+
24
+ const Carousel = /*#__PURE__*/(0, _react.forwardRef)(function Carousel(props, ref) {
25
+ const {
26
+ autoplay = false,
27
+ autoplayInterval = 3000,
28
+ createItemStyle = _animation.createDefaultItemStyle,
29
+ createScrollAnimation = _animation.createDefaultScrollAnimation,
30
+ data: originalData,
31
+ disableSmartAutoplay = false,
32
+ initialIndex = 0,
33
+ itemHeight,
34
+ itemWidth,
35
+ loop = false,
36
+ onIndexChange,
37
+ renderItem,
38
+ scrollEnabled = true,
39
+ style,
40
+ windowSize = 5
41
+ } = props;
42
+ const data = (0, _hooks.useLoopedData)(originalData, loop);
43
+ const [itemVisibilityStore, onPositionChange] = (0, _hooks.useItemVisibilityStore)({
44
+ initialIndex,
45
+ numberOfData: data.length,
46
+ windowSize
47
+ });
48
+ const indexController = (0, _hooks.useIndexController)({
49
+ initialIndex,
50
+ itemWidth,
51
+ numberOfData: data.length,
52
+ numberOfOriginalData: originalData.length,
53
+ onIndexChange,
54
+ onPositionChange
55
+ });
56
+ const {
57
+ getCurrentIndex
58
+ } = indexController;
59
+ const {
60
+ gestureTranslationX,
61
+ globalInterpolation,
62
+ interruptAnimation,
63
+ startPagingAnimation
64
+ } = (0, _hooks.usePagingAnimator)({
65
+ createScrollAnimation,
66
+ itemWidth,
67
+ indexController,
68
+ initialIndex,
69
+ loop,
70
+ numberOfData: data.length
71
+ });
72
+ const autoplayController = (0, _hooks.useAutoplayController)({
73
+ enabled: autoplay,
74
+ intervalMillis: autoplayInterval,
75
+ startPagingAnimation
76
+ });
77
+ (0, _react.useImperativeHandle)(ref, () => ({
78
+ getCurrentIndex,
79
+ next: () => startPagingAnimation('directional', {
80
+ direction: 'next'
81
+ }),
82
+ prev: () => startPagingAnimation('directional', {
83
+ direction: 'prev'
84
+ }),
85
+ scrollTo: option => startPagingAnimation('index', option)
86
+ }), [startPagingAnimation, getCurrentIndex]);
87
+ const contextValue = (0, _react.useMemo)(() => ({
88
+ createItemStyle,
89
+ data,
90
+ globalInterpolation,
91
+ itemHeight,
92
+ itemWidth,
93
+ itemVisibilityStore,
94
+ loop
95
+ }), [createItemStyle, data, globalInterpolation, itemHeight, itemWidth, itemVisibilityStore, loop]);
96
+ return /*#__PURE__*/_react.default.createElement(_components.InternalContext.Provider, {
97
+ value: contextValue
98
+ }, /*#__PURE__*/_react.default.createElement(_ViewabilityTrackerView.default, {
99
+ enabled: autoplay && !disableSmartAutoplay,
100
+ measurementIntervalMillis: Math.max(3000, autoplayInterval),
101
+ onViewabilityChange: _ref => {
102
+ let {
103
+ visible
104
+ } = _ref;
105
+
106
+ if (visible) {
107
+ autoplayController.resume();
108
+ } else {
109
+ autoplayController.pause();
110
+ }
111
+ }
112
+ }, /*#__PURE__*/_react.default.createElement(_components.ScrollViewGesture, {
113
+ autoplayController: autoplayController,
114
+ gestureTranslationX: gestureTranslationX,
115
+ interruptAnimation: interruptAnimation,
116
+ scrollEnabled: scrollEnabled,
117
+ startPagingAnimation: startPagingAnimation
118
+ }, /*#__PURE__*/_react.default.createElement(_components.RootView, {
119
+ data: data,
120
+ itemHeight: itemHeight,
121
+ originalData: originalData,
122
+ renderItem: renderItem,
123
+ style: style
124
+ }))));
125
+ });
126
+
127
+ var _default = /*#__PURE__*/(0, _react.memo)(Carousel);
128
+
129
+ exports.default = _default;
130
+ //# sourceMappingURL=Carousel.js.map