@fountain-ui/lab 2.0.0-beta.3 → 2.0.0-beta.30

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 (501) hide show
  1. package/build/commonjs/AnimatedY/AnimatedY.js +10 -14
  2. package/build/commonjs/AnimatedY/AnimatedY.js.map +1 -1
  3. package/build/commonjs/AnimatedY/AnimatedYProps.js.map +1 -1
  4. package/build/commonjs/AnimatedY/index.js.map +1 -1
  5. package/build/commonjs/BottomSheet/BottomSheet.js +177 -0
  6. package/build/commonjs/BottomSheet/BottomSheet.js.map +1 -0
  7. package/build/commonjs/BottomSheet/BottomSheetNative.js +5 -3
  8. package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
  9. package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
  10. package/build/commonjs/BottomSheet/BottomSheetWeb.js +19 -7
  11. package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
  12. package/build/commonjs/BottomSheet/TransparentBackdrop.js +1 -1
  13. package/build/commonjs/BottomSheet/TransparentBackdrop.js.map +1 -1
  14. package/build/commonjs/BottomSheet/index.js.map +1 -1
  15. package/build/commonjs/BottomSheet/index.native.js.map +1 -1
  16. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js +49 -0
  17. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js.map +1 -0
  18. package/build/commonjs/Carousel/Carousel.js +130 -0
  19. package/build/commonjs/Carousel/Carousel.js.map +1 -0
  20. package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
  21. package/build/commonjs/Carousel/animation/animationUtils.js +9 -0
  22. package/build/commonjs/Carousel/animation/animationUtils.js.map +1 -0
  23. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js +15 -0
  24. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  25. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js +20 -0
  26. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  27. package/build/commonjs/Carousel/animation/index.js +40 -0
  28. package/build/commonjs/Carousel/animation/index.js.map +1 -0
  29. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js +27 -0
  30. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  31. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js +65 -0
  32. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  33. package/build/commonjs/Carousel/components/InternalContext.js +29 -0
  34. package/build/commonjs/Carousel/components/InternalContext.js.map +1 -0
  35. package/build/commonjs/Carousel/components/ItemView.js +66 -0
  36. package/build/commonjs/Carousel/components/ItemView.js.map +1 -0
  37. package/build/commonjs/Carousel/components/RootView.js +86 -0
  38. package/build/commonjs/Carousel/components/RootView.js.map +1 -0
  39. package/build/commonjs/Carousel/components/ScrollViewGesture.js +82 -0
  40. package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -0
  41. package/build/commonjs/Carousel/components/index.js +40 -0
  42. package/build/commonjs/Carousel/components/index.js.map +1 -0
  43. package/build/commonjs/Carousel/components/useItemInterpolation.js +65 -0
  44. package/build/commonjs/Carousel/components/useItemInterpolation.js.map +1 -0
  45. package/build/commonjs/Carousel/hooks/index.js +48 -0
  46. package/build/commonjs/Carousel/hooks/index.js.map +1 -0
  47. package/build/commonjs/Carousel/hooks/useAutoplayController.js +58 -0
  48. package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -0
  49. package/build/commonjs/Carousel/hooks/useIndexController.js +55 -0
  50. package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -0
  51. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js +95 -0
  52. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  53. package/build/commonjs/Carousel/hooks/useLoopedData.js +33 -0
  54. package/build/commonjs/Carousel/hooks/useLoopedData.js.map +1 -0
  55. package/build/commonjs/Carousel/hooks/usePagingAnimator.js +202 -0
  56. package/build/commonjs/Carousel/hooks/usePagingAnimator.js.map +1 -0
  57. package/build/commonjs/Carousel/index.js +16 -2
  58. package/build/commonjs/Carousel/index.js.map +1 -1
  59. package/build/commonjs/Carousel/tick.js +16 -0
  60. package/build/commonjs/Carousel/tick.js.map +1 -0
  61. package/build/commonjs/Carousel/types.js +8 -0
  62. package/build/commonjs/Carousel/types.js.map +1 -0
  63. package/build/commonjs/ComicViewer/ComicViewer.js +71 -37
  64. package/build/commonjs/ComicViewer/ComicViewer.js.map +1 -1
  65. package/build/commonjs/ComicViewer/ComicViewerItemProps.js.map +1 -1
  66. package/build/commonjs/ComicViewer/ComicViewerProps.js +12 -0
  67. package/build/commonjs/ComicViewer/ComicViewerProps.js.map +1 -1
  68. package/build/commonjs/ComicViewer/ViewerItem.js +98 -26
  69. package/build/commonjs/ComicViewer/ViewerItem.js.map +1 -1
  70. package/build/commonjs/ComicViewer/index.js.map +1 -1
  71. package/build/commonjs/DateTimePicker/DateTimePicker.js +2 -2
  72. package/build/commonjs/DateTimePicker/DateTimePicker.js.map +1 -1
  73. package/build/commonjs/DateTimePicker/DateTimePickerProps.js.map +1 -1
  74. package/build/commonjs/DateTimePicker/DateTimePickerProvider.js.map +1 -1
  75. package/build/commonjs/DateTimePicker/YearPicker.js +21 -17
  76. package/build/commonjs/DateTimePicker/YearPicker.js.map +1 -1
  77. package/build/commonjs/DateTimePicker/index.js +4 -4
  78. package/build/commonjs/DateTimePicker/index.js.map +1 -1
  79. package/build/commonjs/DateTimePicker/utils.js +2 -1
  80. package/build/commonjs/DateTimePicker/utils.js.map +1 -1
  81. package/build/commonjs/FlipCard/FlipCard.js +7 -13
  82. package/build/commonjs/FlipCard/FlipCard.js.map +1 -1
  83. package/build/commonjs/FlipCard/FlipCardProps.js.map +1 -1
  84. package/build/commonjs/FlipCard/index.js.map +1 -1
  85. package/build/commonjs/StatusBarProvider/Provider.js +1 -1
  86. package/build/commonjs/StatusBarProvider/Provider.js.map +1 -1
  87. package/build/commonjs/StatusBarProvider/StatusBarProvider.js.map +1 -1
  88. package/build/commonjs/StatusBarProvider/StatusBarProviderProps.js.map +1 -1
  89. package/build/commonjs/StatusBarProvider/index.js.map +1 -1
  90. package/build/commonjs/ViewPager/FluxContext.js +13 -0
  91. package/build/commonjs/ViewPager/FluxContext.js.map +1 -0
  92. package/build/commonjs/ViewPager/InternalContext.js +17 -0
  93. package/build/commonjs/ViewPager/InternalContext.js.map +1 -0
  94. package/build/commonjs/ViewPager/PageStateContext.js +16 -0
  95. package/build/commonjs/ViewPager/PageStateContext.js.map +1 -0
  96. package/build/commonjs/ViewPager/ViewPager.js +81 -0
  97. package/build/commonjs/ViewPager/ViewPager.js.map +1 -0
  98. package/build/commonjs/ViewPager/ViewPager.native.js +150 -0
  99. package/build/commonjs/ViewPager/ViewPager.native.js.map +1 -0
  100. package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
  101. package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js +122 -0
  102. package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
  103. package/build/commonjs/ViewPager/components/FluxStoreProvider.js +37 -0
  104. package/build/commonjs/ViewPager/components/FluxStoreProvider.js.map +1 -0
  105. package/build/commonjs/ViewPager/components/index.js +24 -0
  106. package/build/commonjs/ViewPager/components/index.js.map +1 -0
  107. package/build/commonjs/ViewPager/hooks/index.js +64 -0
  108. package/build/commonjs/ViewPager/hooks/index.js.map +1 -0
  109. package/build/commonjs/ViewPager/hooks/useDispatch.js +22 -0
  110. package/build/commonjs/ViewPager/hooks/useDispatch.js.map +1 -0
  111. package/build/commonjs/ViewPager/hooks/useEagerState.js +24 -0
  112. package/build/commonjs/ViewPager/hooks/useEagerState.js.map +1 -0
  113. package/build/commonjs/ViewPager/hooks/useForceRender.js +16 -0
  114. package/build/commonjs/ViewPager/hooks/useForceRender.js.map +1 -0
  115. package/build/commonjs/ViewPager/hooks/useLazyState.js +45 -0
  116. package/build/commonjs/ViewPager/hooks/useLazyState.js.map +1 -0
  117. package/build/commonjs/ViewPager/hooks/usePageStore.js +35 -0
  118. package/build/commonjs/ViewPager/hooks/usePageStore.js.map +1 -0
  119. package/build/commonjs/ViewPager/hooks/useStore.js +26 -0
  120. package/build/commonjs/ViewPager/hooks/useStore.js.map +1 -0
  121. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js +19 -0
  122. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
  123. package/build/commonjs/ViewPager/index.js +42 -2
  124. package/build/commonjs/ViewPager/index.js.map +1 -1
  125. package/build/commonjs/ViewPager/types.js +2 -0
  126. package/build/commonjs/ViewPager/types.js.map +1 -0
  127. package/build/commonjs/ViewPager/utils.js +12 -43
  128. package/build/commonjs/ViewPager/utils.js.map +1 -1
  129. package/build/commonjs/ViewabilityTrackerView/Viewability.js +2 -0
  130. package/build/commonjs/ViewabilityTrackerView/Viewability.js.map +1 -0
  131. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js +45 -0
  132. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  133. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  134. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  135. package/build/commonjs/{Carousel/index.native.js → ViewabilityTrackerView/index.js} +3 -3
  136. package/build/commonjs/ViewabilityTrackerView/index.js.map +1 -0
  137. package/build/commonjs/ViewabilityTrackerView/measureViewability.js +42 -0
  138. package/build/commonjs/ViewabilityTrackerView/measureViewability.js.map +1 -0
  139. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js +88 -0
  140. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  141. package/build/commonjs/hooks/index.js +16 -0
  142. package/build/commonjs/hooks/index.js.map +1 -1
  143. package/build/commonjs/hooks/useAppbarStyles.js.map +1 -1
  144. package/build/commonjs/hooks/useDeferredExecutor.js +45 -0
  145. package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
  146. package/build/commonjs/hooks/useElevationStyle.js.map +1 -1
  147. package/build/commonjs/hooks/useHeight.js +5 -4
  148. package/build/commonjs/hooks/useHeight.js.map +1 -1
  149. package/build/commonjs/hooks/useIsMounted.js +22 -0
  150. package/build/commonjs/hooks/useIsMounted.js.map +1 -0
  151. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +58 -61
  152. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  153. package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js +9 -11
  154. package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
  155. package/build/commonjs/index.js +28 -7
  156. package/build/commonjs/index.js.map +1 -1
  157. package/build/module/AnimatedY/AnimatedY.js +11 -10
  158. package/build/module/AnimatedY/AnimatedY.js.map +1 -1
  159. package/build/module/AnimatedY/AnimatedYProps.js.map +1 -1
  160. package/build/module/AnimatedY/index.js.map +1 -1
  161. package/build/module/BottomSheet/BottomSheet.js +161 -0
  162. package/build/module/BottomSheet/BottomSheet.js.map +1 -0
  163. package/build/module/BottomSheet/BottomSheetNative.js +5 -3
  164. package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
  165. package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
  166. package/build/module/BottomSheet/BottomSheetWeb.js +18 -7
  167. package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
  168. package/build/module/BottomSheet/TransparentBackdrop.js +1 -1
  169. package/build/module/BottomSheet/TransparentBackdrop.js.map +1 -1
  170. package/build/module/BottomSheet/index.js.map +1 -1
  171. package/build/module/BottomSheet/index.native.js.map +1 -1
  172. package/build/module/BottomSheet/useDynamicSnapPoints.js +41 -0
  173. package/build/module/BottomSheet/useDynamicSnapPoints.js.map +1 -0
  174. package/build/module/Carousel/Carousel.js +109 -0
  175. package/build/module/Carousel/Carousel.js.map +1 -0
  176. package/build/module/Carousel/CarouselProps.js.map +1 -1
  177. package/build/module/Carousel/animation/animationUtils.js +2 -0
  178. package/build/module/Carousel/animation/animationUtils.js.map +1 -0
  179. package/build/module/Carousel/animation/createDefaultItemStyle.js +3 -0
  180. package/build/module/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  181. package/build/module/Carousel/animation/createDefaultScrollAnimation.js +11 -0
  182. package/build/module/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  183. package/build/module/Carousel/animation/index.js +5 -0
  184. package/build/module/Carousel/animation/index.js.map +1 -0
  185. package/build/module/Carousel/animation/normalItemStyleFactory.js +18 -0
  186. package/build/module/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  187. package/build/module/Carousel/animation/parallaxItemStyleFactory.js +55 -0
  188. package/build/module/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  189. package/build/module/Carousel/components/InternalContext.js +19 -0
  190. package/build/module/Carousel/components/InternalContext.js.map +1 -0
  191. package/build/module/Carousel/components/ItemView.js +46 -0
  192. package/build/module/Carousel/components/ItemView.js.map +1 -0
  193. package/build/module/Carousel/components/RootView.js +65 -0
  194. package/build/module/Carousel/components/RootView.js.map +1 -0
  195. package/build/module/Carousel/components/ScrollViewGesture.js +68 -0
  196. package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -0
  197. package/build/module/Carousel/components/index.js +5 -0
  198. package/build/module/Carousel/components/index.js.map +1 -0
  199. package/build/module/Carousel/components/useItemInterpolation.js +51 -0
  200. package/build/module/Carousel/components/useItemInterpolation.js.map +1 -0
  201. package/build/module/Carousel/hooks/index.js +6 -0
  202. package/build/module/Carousel/hooks/index.js.map +1 -0
  203. package/build/module/Carousel/hooks/useAutoplayController.js +48 -0
  204. package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -0
  205. package/build/module/Carousel/hooks/useIndexController.js +44 -0
  206. package/build/module/Carousel/hooks/useIndexController.js.map +1 -0
  207. package/build/module/Carousel/hooks/useItemVisibilityStore.js +86 -0
  208. package/build/module/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  209. package/build/module/Carousel/hooks/useLoopedData.js +24 -0
  210. package/build/module/Carousel/hooks/useLoopedData.js.map +1 -0
  211. package/build/module/Carousel/hooks/usePagingAnimator.js +192 -0
  212. package/build/module/Carousel/hooks/usePagingAnimator.js.map +1 -0
  213. package/build/module/Carousel/index.js +2 -1
  214. package/build/module/Carousel/index.js.map +1 -1
  215. package/build/module/Carousel/tick.js +6 -0
  216. package/build/module/Carousel/tick.js.map +1 -0
  217. package/build/module/Carousel/types.js +4 -0
  218. package/build/module/Carousel/types.js.map +1 -0
  219. package/build/module/ComicViewer/ComicViewer.js +70 -37
  220. package/build/module/ComicViewer/ComicViewer.js.map +1 -1
  221. package/build/module/ComicViewer/ComicViewerItemProps.js.map +1 -1
  222. package/build/module/ComicViewer/ComicViewerProps.js +6 -1
  223. package/build/module/ComicViewer/ComicViewerProps.js.map +1 -1
  224. package/build/module/ComicViewer/ViewerItem.js +99 -28
  225. package/build/module/ComicViewer/ViewerItem.js.map +1 -1
  226. package/build/module/ComicViewer/index.js.map +1 -1
  227. package/build/module/DateTimePicker/DateTimePicker.js +2 -2
  228. package/build/module/DateTimePicker/DateTimePicker.js.map +1 -1
  229. package/build/module/DateTimePicker/DateTimePickerProps.js.map +1 -1
  230. package/build/module/DateTimePicker/DateTimePickerProvider.js.map +1 -1
  231. package/build/module/DateTimePicker/YearPicker.js +21 -17
  232. package/build/module/DateTimePicker/YearPicker.js.map +1 -1
  233. package/build/module/DateTimePicker/index.js.map +1 -1
  234. package/build/module/DateTimePicker/utils.js +2 -1
  235. package/build/module/DateTimePicker/utils.js.map +1 -1
  236. package/build/module/FlipCard/FlipCard.js +7 -7
  237. package/build/module/FlipCard/FlipCard.js.map +1 -1
  238. package/build/module/FlipCard/FlipCardProps.js.map +1 -1
  239. package/build/module/FlipCard/index.js.map +1 -1
  240. package/build/module/StatusBarProvider/Provider.js.map +1 -1
  241. package/build/module/StatusBarProvider/StatusBarProvider.js.map +1 -1
  242. package/build/module/StatusBarProvider/StatusBarProviderProps.js.map +1 -1
  243. package/build/module/StatusBarProvider/index.js.map +1 -1
  244. package/build/module/ViewPager/FluxContext.js +4 -0
  245. package/build/module/ViewPager/FluxContext.js.map +1 -0
  246. package/build/module/ViewPager/InternalContext.js +7 -0
  247. package/build/module/ViewPager/InternalContext.js.map +1 -0
  248. package/build/module/ViewPager/PageStateContext.js +7 -0
  249. package/build/module/ViewPager/PageStateContext.js.map +1 -0
  250. package/build/module/ViewPager/ViewPager.js +57 -0
  251. package/build/module/ViewPager/ViewPager.js.map +1 -0
  252. package/build/module/ViewPager/ViewPager.native.js +127 -0
  253. package/build/module/ViewPager/ViewPager.native.js.map +1 -0
  254. package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
  255. package/build/module/ViewPager/components/ChildrenMemoizedPage.js +101 -0
  256. package/build/module/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
  257. package/build/module/ViewPager/components/FluxStoreProvider.js +20 -0
  258. package/build/module/ViewPager/components/FluxStoreProvider.js.map +1 -0
  259. package/build/module/ViewPager/components/index.js +3 -0
  260. package/build/module/ViewPager/components/index.js.map +1 -0
  261. package/build/module/ViewPager/hooks/index.js +8 -0
  262. package/build/module/ViewPager/hooks/index.js.map +1 -0
  263. package/build/module/ViewPager/hooks/useDispatch.js +10 -0
  264. package/build/module/ViewPager/hooks/useDispatch.js.map +1 -0
  265. package/build/module/ViewPager/hooks/useEagerState.js +12 -0
  266. package/build/module/ViewPager/hooks/useEagerState.js.map +1 -0
  267. package/build/module/ViewPager/hooks/useForceRender.js +7 -0
  268. package/build/module/ViewPager/hooks/useForceRender.js.map +1 -0
  269. package/build/module/ViewPager/hooks/useLazyState.js +30 -0
  270. package/build/module/ViewPager/hooks/useLazyState.js.map +1 -0
  271. package/build/module/ViewPager/hooks/usePageStore.js +25 -0
  272. package/build/module/ViewPager/hooks/usePageStore.js.map +1 -0
  273. package/build/module/ViewPager/hooks/useStore.js +14 -0
  274. package/build/module/ViewPager/hooks/useStore.js.map +1 -0
  275. package/build/module/ViewPager/hooks/useViewPagerPageState.js +7 -0
  276. package/build/module/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
  277. package/build/module/ViewPager/index.js +3 -1
  278. package/build/module/ViewPager/index.js.map +1 -1
  279. package/build/module/ViewPager/types.js +2 -0
  280. package/build/module/ViewPager/types.js.map +1 -0
  281. package/build/module/ViewPager/utils.js +6 -33
  282. package/build/module/ViewPager/utils.js.map +1 -1
  283. package/build/module/ViewabilityTrackerView/Viewability.js +2 -0
  284. package/build/module/ViewabilityTrackerView/Viewability.js.map +1 -0
  285. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js +28 -0
  286. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  287. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  288. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  289. package/build/module/ViewabilityTrackerView/index.js +2 -0
  290. package/build/module/ViewabilityTrackerView/index.js.map +1 -0
  291. package/build/module/ViewabilityTrackerView/measureViewability.js +34 -0
  292. package/build/module/ViewabilityTrackerView/measureViewability.js.map +1 -0
  293. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js +73 -0
  294. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  295. package/build/module/hooks/index.js +2 -0
  296. package/build/module/hooks/index.js.map +1 -1
  297. package/build/module/hooks/useAppbarStyles.js.map +1 -1
  298. package/build/module/hooks/useDeferredExecutor.js +33 -0
  299. package/build/module/hooks/useDeferredExecutor.js.map +1 -0
  300. package/build/module/hooks/useElevationStyle.js.map +1 -1
  301. package/build/module/hooks/useHeight.js +4 -3
  302. package/build/module/hooks/useHeight.js.map +1 -1
  303. package/build/module/hooks/useIsMounted.js +13 -0
  304. package/build/module/hooks/useIsMounted.js.map +1 -0
  305. package/build/module/hooks/useUnstableCollapsibleAppBar.js +58 -45
  306. package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  307. package/build/module/hooks/useUnstableToggleDisplayStyle.js +9 -7
  308. package/build/module/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
  309. package/build/module/index.js +2 -0
  310. package/build/module/index.js.map +1 -1
  311. package/build/typescript/AnimatedY/AnimatedY.d.ts +0 -1
  312. package/build/typescript/BottomSheet/BottomSheet.d.ts +2 -0
  313. package/build/typescript/BottomSheet/BottomSheetNative.d.ts +0 -1
  314. package/build/typescript/BottomSheet/BottomSheetProps.d.ts +6 -1
  315. package/build/typescript/BottomSheet/BottomSheetWeb.d.ts +0 -1
  316. package/build/typescript/BottomSheet/TransparentBackdrop.d.ts +0 -1
  317. package/build/typescript/BottomSheet/useDynamicSnapPoints.d.ts +11 -0
  318. package/build/typescript/Carousel/Carousel.d.ts +5 -0
  319. package/build/typescript/Carousel/CarouselProps.d.ts +33 -48
  320. package/build/typescript/Carousel/animation/animationUtils.d.ts +1 -0
  321. package/build/typescript/Carousel/animation/createDefaultItemStyle.d.ts +2 -0
  322. package/build/typescript/Carousel/animation/createDefaultScrollAnimation.d.ts +2 -0
  323. package/build/typescript/Carousel/animation/index.d.ts +4 -0
  324. package/build/typescript/Carousel/animation/normalItemStyleFactory.d.ts +2 -0
  325. package/build/typescript/Carousel/animation/parallaxItemStyleFactory.d.ts +9 -0
  326. package/build/typescript/Carousel/components/InternalContext.d.ts +14 -0
  327. package/build/typescript/Carousel/components/ItemView.d.ts +9 -0
  328. package/build/typescript/Carousel/components/RootView.d.ts +16 -0
  329. package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +12 -0
  330. package/build/typescript/Carousel/components/index.d.ts +4 -0
  331. package/build/typescript/Carousel/components/useItemInterpolation.d.ts +2 -0
  332. package/build/typescript/Carousel/hooks/index.d.ts +5 -0
  333. package/build/typescript/Carousel/hooks/useAutoplayController.d.ts +7 -0
  334. package/build/typescript/Carousel/hooks/useIndexController.d.ts +10 -0
  335. package/build/typescript/Carousel/hooks/useItemVisibilityStore.d.ts +7 -0
  336. package/build/typescript/Carousel/hooks/useLoopedData.d.ts +1 -0
  337. package/build/typescript/Carousel/hooks/usePagingAnimator.d.ts +17 -0
  338. package/build/typescript/Carousel/index.d.ts +3 -1
  339. package/build/typescript/Carousel/tick.d.ts +2 -0
  340. package/build/typescript/Carousel/types.d.ts +91 -0
  341. package/build/typescript/ComicViewer/ComicViewer.d.ts +0 -1
  342. package/build/typescript/ComicViewer/ComicViewerItemProps.d.ts +12 -1
  343. package/build/typescript/ComicViewer/ComicViewerProps.d.ts +61 -12
  344. package/build/typescript/DateTimePicker/DateTimePicker.d.ts +0 -1
  345. package/build/typescript/DateTimePicker/YearPicker.d.ts +0 -1
  346. package/build/typescript/FlipCard/FlipCard.d.ts +0 -1
  347. package/build/typescript/StatusBarProvider/StatusBarProvider.d.ts +0 -1
  348. package/build/typescript/ViewPager/FluxContext.d.ts +5 -0
  349. package/build/typescript/ViewPager/InternalContext.d.ts +7 -0
  350. package/build/typescript/ViewPager/PageStateContext.d.ts +6 -0
  351. package/build/typescript/ViewPager/ViewPager.d.ts +5 -0
  352. package/build/typescript/ViewPager/ViewPager.native.d.ts +5 -0
  353. package/build/typescript/ViewPager/ViewPagerProps.d.ts +18 -29
  354. package/build/typescript/ViewPager/components/ChildrenMemoizedPage.d.ts +14 -0
  355. package/build/typescript/ViewPager/components/FluxStoreProvider.d.ts +6 -0
  356. package/build/typescript/ViewPager/components/index.d.ts +2 -0
  357. package/build/typescript/ViewPager/hooks/index.d.ts +7 -0
  358. package/build/typescript/ViewPager/hooks/useDispatch.d.ts +2 -0
  359. package/build/typescript/ViewPager/hooks/useEagerState.d.ts +1 -0
  360. package/build/typescript/ViewPager/hooks/useForceRender.d.ts +2 -0
  361. package/build/typescript/ViewPager/hooks/useLazyState.d.ts +2 -0
  362. package/build/typescript/ViewPager/hooks/usePageStore.d.ts +2 -0
  363. package/build/typescript/ViewPager/hooks/useStore.d.ts +2 -0
  364. package/build/typescript/ViewPager/hooks/useViewPagerPageState.d.ts +1 -0
  365. package/build/typescript/ViewPager/index.d.ts +4 -1
  366. package/build/typescript/ViewPager/types.d.ts +12 -0
  367. package/build/typescript/ViewPager/utils.d.ts +5 -20
  368. package/build/typescript/ViewabilityTrackerView/Viewability.d.ts +3 -0
  369. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerView.d.ts +2 -0
  370. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerViewProps.d.ts +22 -0
  371. package/build/typescript/ViewabilityTrackerView/index.d.ts +2 -0
  372. package/build/typescript/ViewabilityTrackerView/measureViewability.d.ts +11 -0
  373. package/build/typescript/ViewabilityTrackerView/useViewabilityTracker.d.ts +11 -0
  374. package/build/typescript/hooks/index.d.ts +2 -0
  375. package/build/typescript/hooks/useDeferredExecutor.d.ts +11 -0
  376. package/build/typescript/hooks/useIsMounted.d.ts +4 -0
  377. package/build/typescript/hooks/useUnstableCollapsibleAppBar.d.ts +2 -3
  378. package/build/typescript/hooks/useUnstableToggleDisplayStyle.d.ts +2 -2
  379. package/build/typescript/index.d.ts +2 -0
  380. package/package.json +11 -25
  381. package/src/AnimatedY/AnimatedY.tsx +13 -10
  382. package/src/BottomSheet/BottomSheet.tsx +184 -0
  383. package/src/BottomSheet/BottomSheetNative.tsx +2 -0
  384. package/src/BottomSheet/BottomSheetProps.ts +7 -1
  385. package/src/BottomSheet/BottomSheetWeb.tsx +18 -5
  386. package/src/BottomSheet/useDynamicSnapPoints.ts +52 -0
  387. package/src/Carousel/Carousel.tsx +135 -0
  388. package/src/Carousel/CarouselProps.ts +42 -53
  389. package/src/Carousel/animation/animationUtils.ts +1 -0
  390. package/src/Carousel/animation/createDefaultItemStyle.ts +3 -0
  391. package/src/Carousel/animation/createDefaultScrollAnimation.ts +13 -0
  392. package/src/Carousel/animation/index.ts +4 -0
  393. package/src/Carousel/animation/normalItemStyleFactory.ts +19 -0
  394. package/src/Carousel/animation/parallaxItemStyleFactory.ts +79 -0
  395. package/src/Carousel/components/InternalContext.ts +33 -0
  396. package/src/Carousel/components/ItemView.tsx +66 -0
  397. package/src/Carousel/components/RootView.tsx +79 -0
  398. package/src/Carousel/components/ScrollViewGesture.tsx +92 -0
  399. package/src/Carousel/components/index.ts +4 -0
  400. package/src/Carousel/components/useItemInterpolation.ts +107 -0
  401. package/src/Carousel/hooks/index.ts +5 -0
  402. package/src/Carousel/hooks/useAutoplayController.ts +57 -0
  403. package/src/Carousel/hooks/useIndexController.tsx +57 -0
  404. package/src/Carousel/hooks/useItemVisibilityStore.ts +107 -0
  405. package/src/Carousel/hooks/useLoopedData.ts +26 -0
  406. package/src/Carousel/hooks/usePagingAnimator.ts +255 -0
  407. package/src/Carousel/index.ts +4 -2
  408. package/src/Carousel/tick.ts +6 -0
  409. package/src/Carousel/types.ts +114 -0
  410. package/src/ComicViewer/ComicViewer.tsx +70 -30
  411. package/src/ComicViewer/ComicViewerItemProps.ts +16 -1
  412. package/src/ComicViewer/ComicViewerProps.ts +70 -10
  413. package/src/ComicViewer/ViewerItem.tsx +107 -27
  414. package/src/DateTimePicker/DateTimePicker.tsx +2 -2
  415. package/src/FlipCard/FlipCard.tsx +8 -8
  416. package/src/ViewPager/FluxContext.ts +8 -0
  417. package/src/ViewPager/InternalContext.ts +13 -0
  418. package/src/ViewPager/PageStateContext.ts +11 -0
  419. package/src/ViewPager/ViewPager.native.tsx +150 -0
  420. package/src/ViewPager/ViewPager.tsx +69 -0
  421. package/src/ViewPager/ViewPagerProps.ts +20 -35
  422. package/src/ViewPager/components/ChildrenMemoizedPage.tsx +124 -0
  423. package/src/ViewPager/components/FluxStoreProvider.tsx +27 -0
  424. package/src/ViewPager/components/index.ts +2 -0
  425. package/src/ViewPager/hooks/index.ts +7 -0
  426. package/src/ViewPager/hooks/useDispatch.ts +11 -0
  427. package/src/ViewPager/hooks/useEagerState.ts +14 -0
  428. package/src/ViewPager/hooks/useForceRender.ts +7 -0
  429. package/src/ViewPager/hooks/useLazyState.ts +32 -0
  430. package/src/ViewPager/hooks/usePageStore.ts +30 -0
  431. package/src/ViewPager/hooks/useStore.ts +15 -0
  432. package/src/ViewPager/hooks/useViewPagerPageState.ts +6 -0
  433. package/src/ViewPager/index.ts +11 -2
  434. package/src/ViewPager/types.ts +15 -0
  435. package/src/ViewPager/utils.tsx +9 -56
  436. package/src/ViewabilityTrackerView/Viewability.ts +3 -0
  437. package/src/ViewabilityTrackerView/ViewabilityTrackerView.tsx +33 -0
  438. package/src/ViewabilityTrackerView/ViewabilityTrackerViewProps.ts +25 -0
  439. package/src/ViewabilityTrackerView/index.ts +2 -0
  440. package/src/ViewabilityTrackerView/measureViewability.ts +54 -0
  441. package/src/ViewabilityTrackerView/useViewabilityTracker.ts +85 -0
  442. package/src/hooks/index.ts +2 -0
  443. package/src/hooks/useDeferredExecutor.ts +46 -0
  444. package/src/hooks/useHeight.ts +2 -2
  445. package/src/hooks/useIsMounted.ts +19 -0
  446. package/src/hooks/useUnstableCollapsibleAppBar.ts +62 -45
  447. package/src/hooks/useUnstableToggleDisplayStyle.ts +8 -6
  448. package/src/index.ts +3 -0
  449. package/build/commonjs/Carousel/CarouselNative.js +0 -72
  450. package/build/commonjs/Carousel/CarouselNative.js.map +0 -1
  451. package/build/commonjs/Carousel/CarouselWeb.js +0 -237
  452. package/build/commonjs/Carousel/CarouselWeb.js.map +0 -1
  453. package/build/commonjs/Carousel/index.native.js.map +0 -1
  454. package/build/commonjs/Carousel/utils.js +0 -19
  455. package/build/commonjs/Carousel/utils.js.map +0 -1
  456. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js +0 -49
  457. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  458. package/build/commonjs/ViewPager/ViewPagerNative.js +0 -72
  459. package/build/commonjs/ViewPager/ViewPagerNative.js.map +0 -1
  460. package/build/commonjs/ViewPager/ViewPagerWeb.js +0 -55
  461. package/build/commonjs/ViewPager/ViewPagerWeb.js.map +0 -1
  462. package/build/commonjs/ViewPager/index.native.js +0 -16
  463. package/build/commonjs/ViewPager/index.native.js.map +0 -1
  464. package/build/commonjs/hooks/useWidth.js +0 -29
  465. package/build/commonjs/hooks/useWidth.js.map +0 -1
  466. package/build/module/Carousel/CarouselNative.js +0 -54
  467. package/build/module/Carousel/CarouselNative.js.map +0 -1
  468. package/build/module/Carousel/CarouselWeb.js +0 -215
  469. package/build/module/Carousel/CarouselWeb.js.map +0 -1
  470. package/build/module/Carousel/index.native.js +0 -2
  471. package/build/module/Carousel/index.native.js.map +0 -1
  472. package/build/module/Carousel/utils.js +0 -7
  473. package/build/module/Carousel/utils.js.map +0 -1
  474. package/build/module/ViewPager/ChildrenMemoizedPage.js +0 -37
  475. package/build/module/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  476. package/build/module/ViewPager/ViewPagerNative.js +0 -53
  477. package/build/module/ViewPager/ViewPagerNative.js.map +0 -1
  478. package/build/module/ViewPager/ViewPagerWeb.js +0 -41
  479. package/build/module/ViewPager/ViewPagerWeb.js.map +0 -1
  480. package/build/module/ViewPager/index.native.js +0 -2
  481. package/build/module/ViewPager/index.native.js.map +0 -1
  482. package/build/module/hooks/useWidth.js +0 -15
  483. package/build/module/hooks/useWidth.js.map +0 -1
  484. package/build/typescript/Carousel/CarouselNative.d.ts +0 -3
  485. package/build/typescript/Carousel/CarouselWeb.d.ts +0 -4
  486. package/build/typescript/Carousel/index.native.d.ts +0 -1
  487. package/build/typescript/Carousel/utils.d.ts +0 -6
  488. package/build/typescript/ViewPager/ChildrenMemoizedPage.d.ts +0 -4
  489. package/build/typescript/ViewPager/ViewPagerNative.d.ts +0 -3
  490. package/build/typescript/ViewPager/ViewPagerWeb.d.ts +0 -3
  491. package/build/typescript/ViewPager/index.native.d.ts +0 -1
  492. package/build/typescript/hooks/useWidth.d.ts +0 -2
  493. package/src/Carousel/CarouselNative.tsx +0 -67
  494. package/src/Carousel/CarouselWeb.tsx +0 -222
  495. package/src/Carousel/index.native.ts +0 -1
  496. package/src/Carousel/utils.ts +0 -11
  497. package/src/ViewPager/ChildrenMemoizedPage.tsx +0 -36
  498. package/src/ViewPager/ViewPagerNative.tsx +0 -66
  499. package/src/ViewPager/ViewPagerWeb.tsx +0 -52
  500. package/src/ViewPager/index.native.ts +0 -1
  501. package/src/hooks/useWidth.ts +0 -17
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = AnimatedY;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
11
11
 
@@ -13,7 +13,10 @@ 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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ const ANIMATION_CONFIG = {
17
+ duration: 150,
18
+ easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.exp)
19
+ };
17
20
 
18
21
  function AnimatedY(props) {
19
22
  const {
@@ -21,24 +24,17 @@ function AnimatedY(props) {
21
24
  translateY,
22
25
  style
23
26
  } = props;
24
-
25
- const animatedY = _reactNativeReanimated.default.useSharedValue(translateY);
26
-
27
- const animatedStyle = _reactNativeReanimated.default.useAnimatedStyle(() => ({
27
+ const animatedY = (0, _reactNativeReanimated.useSharedValue)(translateY);
28
+ const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
28
29
  transform: [{
29
30
  translateY: animatedY.value
30
31
  }]
31
- }));
32
-
33
- _react.default.useEffect(() => {
32
+ }), []);
33
+ (0, _react.useEffect)(() => {
34
34
  if (translateY >= 0) {
35
- animatedY.value = _reactNativeReanimated.default.withTiming(translateY, {
36
- duration: 150,
37
- easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.exp)
38
- });
35
+ animatedY.value = (0, _reactNativeReanimated.withTiming)(translateY, ANIMATION_CONFIG);
39
36
  }
40
37
  }, [translateY]);
41
-
42
38
  return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
43
39
  children: children,
44
40
  style: [animatedStyle, style]
@@ -1 +1 @@
1
- {"version":3,"sources":["AnimatedY.tsx"],"names":["AnimatedY","props","children","translateY","style","animatedY","Animated","useSharedValue","animatedStyle","useAnimatedStyle","transform","value","React","useEffect","withTiming","duration","easing","Easing","out","exp"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;AAGe,SAASA,SAAT,CAAmBC,KAAnB,EAA0C;AACrD,QAAM;AACFC,IAAAA,QADE;AAEFC,IAAAA,UAFE;AAGFC,IAAAA;AAHE,MAIFH,KAJJ;;AAMA,QAAMI,SAAS,GAAGC,+BAASC,cAAT,CAAwBJ,UAAxB,CAAlB;;AACA,QAAMK,aAAa,GAAGF,+BAASG,gBAAT,CAA0B,OAAO;AACnDC,IAAAA,SAAS,EAAE,CAAC;AAAEP,MAAAA,UAAU,EAAEE,SAAS,CAACM;AAAxB,KAAD;AADwC,GAAP,CAA1B,CAAtB;;AAIAC,iBAAMC,SAAN,CAAgB,MAAM;AAClB,QAAIV,UAAU,IAAI,CAAlB,EAAqB;AACjBE,MAAAA,SAAS,CAACM,KAAV,GAAkBL,+BAASQ,UAAT,CAAoBX,UAApB,EAAgC;AAC9CY,QAAAA,QAAQ,EAAE,GADoC;AAE9CC,QAAAA,MAAM,EAAEC,8BAAOC,GAAP,CAAWD,8BAAOE,GAAlB;AAFsC,OAAhC,CAAlB;AAIH;AACJ,GAPD,EAOG,CAAChB,UAAD,CAPH;;AASA,sBACI,6BAAC,8BAAD,CAAU,IAAV;AACI,IAAA,QAAQ,EAAED,QADd;AAEI,IAAA,KAAK,EAAE,CACHM,aADG,EAEHJ,KAFG;AAFX,IADJ;AASH;;AAAA","sourcesContent":["import React from 'react';\nimport Animated, { Easing } from 'react-native-reanimated';\nimport type AnimatedYProps from './AnimatedYProps';\n\nexport default function AnimatedY(props: AnimatedYProps) {\n const {\n children,\n translateY,\n style,\n } = props;\n\n const animatedY = Animated.useSharedValue(translateY);\n const animatedStyle = Animated.useAnimatedStyle(() => ({\n transform: [{ translateY: animatedY.value }],\n }));\n\n React.useEffect(() => {\n if (translateY >= 0) {\n animatedY.value = Animated.withTiming(translateY, {\n duration: 150,\n easing: Easing.out(Easing.exp),\n });\n }\n }, [translateY]);\n\n return (\n <Animated.View\n children={children}\n style={[\n animatedStyle,\n style,\n ]}\n />\n );\n};\n"]}
1
+ {"version":3,"names":["ANIMATION_CONFIG","duration","easing","Easing","out","exp","AnimatedY","props","children","translateY","style","animatedY","useSharedValue","animatedStyle","useAnimatedStyle","transform","value","useEffect","withTiming"],"sources":["AnimatedY.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { Easing, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport type AnimatedYProps from './AnimatedYProps';\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = {\n duration: 150,\n easing: Easing.out(Easing.exp),\n};\n\nexport default function AnimatedY(props: AnimatedYProps) {\n const {\n children,\n translateY,\n style,\n } = props;\n\n const animatedY = useSharedValue(translateY);\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: animatedY.value }],\n }), []);\n\n useEffect(() => {\n if (translateY >= 0) {\n animatedY.value = withTiming(translateY, ANIMATION_CONFIG);\n }\n }, [translateY]);\n\n return (\n <Animated.View\n children={children}\n style={[\n animatedStyle,\n style,\n ]}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAGA,MAAMA,gBAA4C,GAAG;EACjDC,QAAQ,EAAE,GADuC;EAEjDC,MAAM,EAAEC,6BAAA,CAAOC,GAAP,CAAWD,6BAAA,CAAOE,GAAlB;AAFyC,CAArD;;AAKe,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;EACrD,MAAM;IACFC,QADE;IAEFC,UAFE;IAGFC;EAHE,IAIFH,KAJJ;EAMA,MAAMI,SAAS,GAAG,IAAAC,qCAAA,EAAeH,UAAf,CAAlB;EACA,MAAMI,aAAa,GAAG,IAAAC,uCAAA,EAAiB,OAAO;IAC1CC,SAAS,EAAE,CAAC;MAAEN,UAAU,EAAEE,SAAS,CAACK;IAAxB,CAAD;EAD+B,CAAP,CAAjB,EAElB,EAFkB,CAAtB;EAIA,IAAAC,gBAAA,EAAU,MAAM;IACZ,IAAIR,UAAU,IAAI,CAAlB,EAAqB;MACjBE,SAAS,CAACK,KAAV,GAAkB,IAAAE,iCAAA,EAAWT,UAAX,EAAuBT,gBAAvB,CAAlB;IACH;EACJ,CAJD,EAIG,CAACS,UAAD,CAJH;EAMA,oBACI,6BAAC,8BAAD,CAAU,IAAV;IACI,QAAQ,EAAED,QADd;IAEI,KAAK,EAAE,CACHK,aADG,EAEHH,KAFG;EAFX,EADJ;AASH;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["AnimatedYProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport default interface AnimatedYProps extends ComponentProps<{\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The translate y value of the component.\n */\n translateY: number;\n}> {}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA","sourcesContent":["export { default } from './AnimatedY';\nexport type { default as AnimatedYProps } from './AnimatedYProps';\n"]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './AnimatedY';\nexport type { default as AnimatedYProps } from './AnimatedYProps';\n"],"mappings":";;;;;;;;;;;;AAAA"}
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = BottomSheet;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _core = require("@fountain-ui/core");
13
+
14
+ var _useDynamicSnapPoints = _interopRequireDefault(require("./useDynamicSnapPoints"));
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ 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); }
19
+
20
+ 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; }
21
+
22
+ 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); }
23
+
24
+ const useStyles = function () {
25
+ const theme = (0, _core.useTheme)();
26
+ return {
27
+ root: {
28
+ justifyContent: 'flex-end',
29
+ zIndex: theme.zIndex.dialog
30
+ },
31
+ animated: {
32
+ alignSelf: 'center',
33
+ maxWidth: 720,
34
+ width: '100%'
35
+ },
36
+ paper: {
37
+ borderBottomLeftRadius: 0,
38
+ borderBottomRightRadius: 0,
39
+ flexGrow: 1,
40
+ overflow: 'hidden'
41
+ },
42
+ scrollView: {
43
+ flexGrow: 1
44
+ }
45
+ };
46
+ };
47
+
48
+ function BottomSheet(props) {
49
+ const {
50
+ backdropOpacity,
51
+ children,
52
+ header,
53
+ index,
54
+ onChange,
55
+ snapPoints: initialSnapPoints
56
+ } = props;
57
+ const styles = useStyles();
58
+ const contentLayout = (0, _react.useRef)({
59
+ x: 0,
60
+ y: 0,
61
+ width: 0,
62
+ height: 0
63
+ });
64
+ const currentScrollY = (0, _react.useRef)(0);
65
+ const {
66
+ snapPoints,
67
+ handleContentLayout
68
+ } = (0, _useDynamicSnapPoints.default)({
69
+ index,
70
+ initialSnapPoints
71
+ });
72
+ const height = snapPoints[snapPoints.length - 1] ?? 0;
73
+ const translateY = height - (snapPoints[index] ?? 0);
74
+ const animatedY = (0, _core.useAnimatedValue)(translateY);
75
+
76
+ const isInsideScrollView = (locationX, locationY) => {
77
+ const {
78
+ current: {
79
+ x,
80
+ y,
81
+ width,
82
+ height
83
+ }
84
+ } = contentLayout;
85
+ return locationX >= x && locationX <= x + width && locationY >= y && locationY <= y + height;
86
+ };
87
+
88
+ const panResponder = (0, _react.useMemo)(() => _reactNative.PanResponder.create({
89
+ onMoveShouldSetPanResponder: (event, gestureState) => {
90
+ const {
91
+ nativeEvent: {
92
+ locationX,
93
+ locationY
94
+ }
95
+ } = event;
96
+
97
+ if (isInsideScrollView(locationX, locationY)) {
98
+ return gestureState.dy > 0 && currentScrollY.current === 0;
99
+ }
100
+
101
+ return true;
102
+ },
103
+ onPanResponderMove: (_, gestureState) => {
104
+ if (gestureState.dy > 0) {
105
+ animatedY.setValue(translateY + gestureState.dy);
106
+ }
107
+ },
108
+ onPanResponderRelease: (_, gestureState) => {
109
+ if (gestureState.dy > 0 && gestureState.vy > 0.5) {
110
+ handleClose();
111
+ } else {
112
+ _reactNative.Animated.timing(animatedY, {
113
+ toValue: translateY,
114
+ useNativeDriver: false,
115
+ duration: 300
116
+ }).start();
117
+ }
118
+ }
119
+ }), [translateY]);
120
+ (0, _react.useEffect)(() => {
121
+ if (translateY >= 0) {
122
+ _reactNative.Animated.timing(animatedY, {
123
+ toValue: translateY,
124
+ useNativeDriver: false,
125
+ duration: 300
126
+ }).start();
127
+ }
128
+ }, [translateY]);
129
+
130
+ const handleClose = () => {
131
+ if (onChange) {
132
+ onChange(-1);
133
+ }
134
+ };
135
+
136
+ const handleScrollViewLayout = event => {
137
+ contentLayout.current = event.nativeEvent.layout;
138
+ };
139
+
140
+ const handleScroll = event => {
141
+ currentScrollY.current = event.nativeEvent.contentOffset.y;
142
+ };
143
+
144
+ const animatedStyles = [styles.animated, {
145
+ transform: [{
146
+ translateY: animatedY
147
+ }]
148
+ }];
149
+ const paperStyles = [styles.paper, { ...(height !== 0 ? {
150
+ height
151
+ } : {})
152
+ }];
153
+ const contentStyle = { ...(snapPoints[index] !== 0 ? {
154
+ height: snapPoints[index]
155
+ } : {})
156
+ };
157
+ return /*#__PURE__*/_react.default.createElement(_core.Modal, {
158
+ backdropOpacity: backdropOpacity,
159
+ onClose: handleClose,
160
+ visible: index >= 0,
161
+ style: (0, _core.css)([_core.StyleSheet.absoluteFill, styles.root])
162
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, _extends({
163
+ style: animatedStyles
164
+ }, panResponder.panHandlers), /*#__PURE__*/_react.default.createElement(_core.Paper, {
165
+ elevation: 12,
166
+ style: paperStyles
167
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
168
+ style: contentStyle,
169
+ onLayout: handleContentLayout
170
+ }, header, /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, {
171
+ onLayout: handleScrollViewLayout,
172
+ onScroll: handleScroll,
173
+ scrollEventThrottle: 300,
174
+ style: styles.scrollView
175
+ }, children)))));
176
+ }
177
+ //# sourceMappingURL=BottomSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useStyles","theme","useTheme","root","justifyContent","zIndex","dialog","animated","alignSelf","maxWidth","width","paper","borderBottomLeftRadius","borderBottomRightRadius","flexGrow","overflow","scrollView","BottomSheet","props","backdropOpacity","children","header","index","onChange","snapPoints","initialSnapPoints","styles","contentLayout","useRef","x","y","height","currentScrollY","handleContentLayout","useDynamicSnapPoints","length","translateY","animatedY","useAnimatedValue","isInsideScrollView","locationX","locationY","current","panResponder","useMemo","PanResponder","create","onMoveShouldSetPanResponder","event","gestureState","nativeEvent","dy","onPanResponderMove","_","setValue","onPanResponderRelease","vy","handleClose","Animated","timing","toValue","useNativeDriver","duration","start","useEffect","handleScrollViewLayout","layout","handleScroll","contentOffset","animatedStyles","transform","paperStyles","contentStyle","css","StyleSheet","absoluteFill","panHandlers"],"sources":["BottomSheet.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from 'react';\nimport {\n Animated,\n LayoutChangeEvent,\n LayoutRectangle,\n NativeScrollEvent,\n NativeSyntheticEvent,\n PanResponder,\n ScrollView,\n View,\n} from 'react-native';\nimport { css, Modal, Paper, StyleSheet, useAnimatedValue, useTheme } from '@fountain-ui/core';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport BottomSheetProps from './BottomSheetProps';\nimport useDynamicSnapPoints from './useDynamicSnapPoints';\n\ntype BottomSheetStyles = NamedStylesStringUnion<'root' | 'animated' | 'paper' | 'scrollView'>;\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 scrollView: {\n flexGrow: 1,\n },\n };\n};\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity,\n children,\n header,\n index,\n onChange,\n snapPoints: initialSnapPoints,\n } = props;\n\n const styles = useStyles();\n\n const contentLayout = useRef<LayoutRectangle>({ x: 0, y: 0, width: 0, height: 0 });\n const currentScrollY = useRef<number>(0);\n\n const {\n snapPoints,\n handleContentLayout,\n } = useDynamicSnapPoints({\n index,\n initialSnapPoints,\n });\n\n const height = snapPoints[snapPoints.length - 1] ?? 0;\n const translateY = height - (snapPoints[index] ?? 0);\n\n const animatedY = useAnimatedValue(translateY);\n\n const isInsideScrollView = (locationX: number, locationY: number): boolean => {\n const {\n current: { x, y, width, height },\n } = contentLayout;\n\n return locationX >= x && locationX <= x + width && locationY >= y && locationY <= y + height;\n };\n\n const panResponder = useMemo(() => (\n PanResponder.create({\n onMoveShouldSetPanResponder: (event, gestureState) => {\n const {\n nativeEvent: { locationX, locationY },\n } = event;\n\n if (isInsideScrollView(locationX, locationY)) {\n return gestureState.dy > 0 && currentScrollY.current === 0;\n }\n\n return true;\n },\n onPanResponderMove: (_, gestureState) => {\n if (gestureState.dy > 0) {\n animatedY.setValue(translateY + gestureState.dy);\n }\n },\n onPanResponderRelease: (_, gestureState) => {\n if (gestureState.dy > 0 && gestureState.vy > 0.5) {\n handleClose();\n } else {\n Animated.timing(animatedY, {\n toValue: translateY,\n useNativeDriver: false,\n duration: 300,\n }).start();\n }\n },\n })\n ), [translateY]);\n\n useEffect(() => {\n if (translateY >= 0) {\n Animated.timing(animatedY, {\n toValue: translateY,\n useNativeDriver: false,\n duration: 300,\n }).start();\n }\n }, [translateY]);\n\n const handleClose = () => {\n if (onChange) {\n onChange(-1);\n }\n };\n\n const handleScrollViewLayout = (event: LayoutChangeEvent) => {\n contentLayout.current = event.nativeEvent.layout;\n };\n\n const handleScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {\n currentScrollY.current = event.nativeEvent.contentOffset.y;\n };\n\n const animatedStyles = [\n styles.animated,\n { transform: [{ translateY: animatedY }] },\n ];\n\n const paperStyles = [\n styles.paper,\n { ...(height !== 0 ? { height } : {}) },\n ];\n\n const contentStyle = {\n ...(snapPoints[index] !== 0 ? { height: snapPoints[index] } : {}),\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 <Animated.View\n style={animatedStyles}\n {...panResponder.panHandlers}\n >\n <Paper\n elevation={12}\n style={paperStyles}\n >\n <View\n style={contentStyle}\n onLayout={handleContentLayout}\n >\n {header}\n\n <ScrollView\n onLayout={handleScrollViewLayout}\n onScroll={handleScroll}\n scrollEventThrottle={300}\n style={styles.scrollView}\n >\n {children}\n </ScrollView>\n </View>\n </Paper>\n </Animated.View>\n </Modal>\n );\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAUA;;AAGA;;;;;;;;;;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,sBAAsB,EAAE,CADrB;MAEHC,uBAAuB,EAAE,CAFtB;MAGHC,QAAQ,EAAE,CAHP;MAIHC,QAAQ,EAAE;IAJP,CAVJ;IAgBHC,UAAU,EAAE;MACRF,QAAQ,EAA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eAMI,6BAAC,uBAAD;IACI,QAAQ,EAAE4C,sBADd;IAEI,QAAQ,EAAEE,YAFd;IAGI,mBAAmB,EAAE,GAHzB;IAII,KAAK,EAAEzC,MAAM,CAACV;EAJlB,GAMKI,QANL,CANJ,CAJJ,CAJJ,CANJ,CADJ;AAkCH"}
@@ -17,7 +17,7 @@ var _TransparentBackdrop = _interopRequireDefault(require("./TransparentBackdrop
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
- function _extends() { _extends = Object.assign || 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); }
20
+ 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
21
 
22
22
  const NoHandle = () => null;
23
23
 
@@ -85,7 +85,8 @@ function BottomSheet(props) {
85
85
  const OpacityAwareBackdrop = props => /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetBackdrop, _extends({}, props, {
86
86
  appearsOnIndex: 0,
87
87
  disappearsOnIndex: -1,
88
- opacity: backdropOpacity
88
+ opacity: backdropOpacity,
89
+ pressBehavior: onChange ? 'close' : 'none'
89
90
  }));
90
91
 
91
92
  return /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetModalProvider, null, /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetModal, {
@@ -98,7 +99,8 @@ function BottomSheet(props) {
98
99
  onDismiss: handleDismiss,
99
100
  ref: bottomSheetRef,
100
101
  snapPoints: snapPoints,
101
- style: modalStyle
102
+ style: modalStyle,
103
+ enablePanDownToClose: Boolean(onChange)
102
104
  }, children));
103
105
  }
104
106
 
@@ -1 +1 @@
1
- {"version":3,"sources":["BottomSheetNative.tsx"],"names":["NoHandle","BottomSheet","props","backdropOpacity","children","index","onChange","snapPoints","indexRef","React","useRef","bottomSheetRef","handleChange","useCallback","newIndex","current","handleDismiss","useEffect","present","dismiss","snapToIndex","theme","shadow","modalStyle","backgroundColor","Platform","select","android","elevation","ios","web","boxShadow","backgroundStyle","palette","paper","default","isBackdropTransparent","OpacityAwareBackdrop","TransparentBackdrop"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;;;;;AAEA,MAAMA,QAAQ,GAAG,MAAM,IAAvB;;AAEe,SAASC,WAAT,CAAqBC,KAArB,EAA8C;AACzD,QAAM;AACFC,IAAAA,eAAe,GAAG,GADhB;AAEFC,IAAAA,QAFE;AAGFC,IAAAA,KAHE;AAIFC,IAAAA,QAJE;AAKFC,IAAAA;AALE,MAMFL,KANJ;;AAQA,QAAMM,QAAQ,GAAGC,eAAMC,MAAN,CAAqB,CAAC,CAAtB,CAAjB;;AACA,QAAMC,cAAc,GAAGF,eAAMC,MAAN,CAAsC,IAAtC,CAAvB;;AAEA,QAAME,YAAY,GAAGH,eAAMI,WAAN,CAAmBC,QAAD,IAAsB;AACzDN,IAAAA,QAAQ,CAACO,OAAT,GAAmBD,QAAnB;;AAEA,QAAIR,QAAJ,EAAc;AACVA,MAAAA,QAAQ,CAACQ,QAAD,CAAR;AACH;AACJ,GANoB,EAMlB,CAACR,QAAD,CANkB,CAArB;;AAQA,QAAMU,aAAa,GAAGP,eAAMI,WAAN,CAAkB,MAAM;AAC1CD,IAAAA,YAAY,CAAC,CAAC,CAAF,CAAZ;AACH,GAFqB,EAEnB,CAACA,YAAD,CAFmB,CAAtB;;AAIAH,iBAAMQ,SAAN,CAAgB,MAAM;AAClB,QAAIZ,KAAK,KAAKG,QAAQ,CAACO,OAAvB,EAAgC;AAC5B;AACH;;AAED,QAAIP,QAAQ,CAACO,OAAT,GAAmB,CAAnB,IAAwBV,KAAK,IAAI,CAArC,EAAwC;AAAA;;AACpC,+BA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eAHrB;AAII,IAAA,KAAK,EAAE3B,KAJX;AAKI,IAAA,eAAe,EAAEL,QALrB;AAMI,IAAA,QAAQ,EAAEY,YANd;AAOI,IAAA,SAAS,EAAEI,aAPf;AAQI,IAAA,GAAG,EAAEL,cART;AASI,IAAA,UAAU,EAAEJ,UAThB;AAUI,IAAA,KAAK,EAAEgB;AAVX,KAYKnB,QAZL,CADJ,CADJ;AAkBH;;AAAA","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"]}
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","Boolean"],"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 pressBehavior={onChange ? 'close' : 'none'}\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 enablePanDownToClose={Boolean(onChange)}\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;;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AG,EAAER,MAAF,aAAEA,MAAF,uBAAEA,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;IAKI,aAAa,EAAEG,QAAQ,GAAG,OAAH,GAAa;EALxC,GADJ;;EAUA,oBACI,6BAAC,qCAAD,qBACI,6BAAC,6BAAD;IACI,iBAAiB,EAAE+B,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,UAVX;IAWI,oBAAoB,EAAEgB,OAAO,CAAClC,QAAD;EAXjC,GAaKF,QAbL,CADJ,CADJ;AAmBH;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"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 * Area to be fixed on the top of the bottom sheet.\n */\n header?: 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 * Only number type or string type(~% format) can be used.\n */\n snapPoints: Array<number | string>;\n}> {}\n"],"mappings":""}
@@ -7,6 +7,8 @@ exports.default = BottomSheet;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
+ var _reactNative = require("react-native");
11
+
10
12
  var _core = require("@fountain-ui/core");
11
13
 
12
14
  var _AnimatedY = _interopRequireDefault(require("../AnimatedY"));
@@ -34,15 +36,22 @@ const useStyles = function () {
34
36
  };
35
37
  };
36
38
 
37
- const calculateHeight = points => {
38
- var _points;
39
+ const convertHeightAsPixel = (windowHeight, value) => {
40
+ if (typeof value === 'number') {
41
+ return value;
42
+ }
43
+
44
+ const percentageRegex = new RegExp(/^[0-9]+%$/);
45
+
46
+ if (percentageRegex.test(value)) {
47
+ const percentage = parseFloat(value) / 100;
48
+ return isNaN(percentage) ? 0 : Math.round(windowHeight * percentage);
49
+ }
39
50
 
40
- return (_points = points[points.length - 1]) !== null && _points !== void 0 ? _points : 0;
51
+ return 0;
41
52
  };
42
53
 
43
54
  function BottomSheet(props) {
44
- var _snapPoints$index;
45
-
46
55
  const {
47
56
  backdropOpacity,
48
57
  children,
@@ -51,6 +60,9 @@ function BottomSheet(props) {
51
60
  snapPoints
52
61
  } = props;
53
62
  const styles = useStyles();
63
+ const {
64
+ height: windowHeight
65
+ } = (0, _reactNative.useWindowDimensions)();
54
66
 
55
67
  const handleClose = () => {
56
68
  if (onChange) {
@@ -58,8 +70,8 @@ function BottomSheet(props) {
58
70
  }
59
71
  };
60
72
 
61
- const height = calculateHeight(snapPoints);
62
- const translateY = height - ((_snapPoints$index = snapPoints[index]) !== null && _snapPoints$index !== void 0 ? _snapPoints$index : 0);
73
+ const height = convertHeightAsPixel(windowHeight, snapPoints[snapPoints.length - 1] ?? 0);
74
+ const translateY = height - convertHeightAsPixel(windowHeight, snapPoints[index] ?? 0);
63
75
  return /*#__PURE__*/_react.default.createElement(_core.Modal, {
64
76
  backdropOpacity: backdropOpacity,
65
77
  onClose: handleClose,
@@ -1 +1 @@
1
- {"version":3,"sources":["BottomSheetWeb.tsx"],"names":["useStyles","theme","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","StyleSheet","absoluteFill"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;AAKA,MAAMA,SAAuC,GAAG,YAA+B;AAC3E,QAAMC,KAAK,GAAG,qBAAd;AAEA,SAAO;AACHC,IAAAA,IAAI,EAAE;AACFC,MAAAA,cAAc,EAAE,UADd;AAEFC,MAAAA,MAAM,EAAEH,KAAK,CAACG,MAAN,CAAaC;AAFnB,KADH;AAKHC,IAAAA,QAAQ,EAAE;AACNC,MAAAA,SAAS,EAAE,QADL;AAENC,MAAAA,QAAQ,EAAE,GAFJ;AAGNC,MAAAA,KAAK,EAAE;AAHD,KALP;AAUHC,IAAAA,KAAK,EAAE;AACHC,MAAAA,sBAAsB,EAAE,CADrB;AAEHC,MAAAA,uBAAuB,EAAE,CAFtB;AAGHC,MAAAA,QAAQ,EAAE,CAHP;AAIHC,MAAAA,QAAQ,EAAE;AAJP;AAVJ,GAAP;AAiBH,CApBD;;AAsBA,MAAMC,eAAe,GAAIC,MAAD,IAAoD;AAAA;;AACxE,oBAAOA,MAAM,CAACA,MAAM,CAACC,MAAP,GAAgB,CAAjB,CAAb,6CAAoC,CAApC;AACH,CAFD;;AAIe,SAASC,WAAT,CAAqBC,KAArB,EAA8C;AAAA;;AACzD,QAAM;AACFC,IAAAA,eADE;AAEFC,IAAAA,QAFE;AAGFC,IAAAA,KAHE;AAIFC,IAAAA,QAJE;AAKFC,IAAAA;AALE,MAMFL,KANJ;AAQA,QAAMM,MAAM,GAAGzB,SAAS,EAAxB;;AAEA,QAAM0B,WAAW,GAAG,MAAM;AACtB,QAAIH,QAAJ,EAAc;AACVA,MAAAA,QAAQ,CAAC,CAAC,CAAF,CAAR;AACH;AACJ,GAJD;;AAMA,QAAMI,MAAM,GAAGZ,eAAe,CAACS,UAAD,CAA9B;AACA,QAAMI,UAAU,GAAGD,MAAM,yBAAIH,UAAU,CAACF,KAAD,CAAd,iEAAyB,CAAzB,CAAzB;AAEA,sBACI,6BAAC,WAAD;AACI,IAAA,eAAe,EAAEF,eADrB;AAEI,IAAA,OAAO,EAAEM,WAFb;AAGI,IAAA,OAAO,EAAEJ,KAAK,IAAI,CAHtB;AAII,IAAA,KAAK,EAAE,eAAI,CAACO,iBAAWC,YAAZ,EAA0BL,MAAM,CAACvB,IAAjC,CAAJ;AAJX,kBAMI,6BAAC,kBAAD;AACI,IAAA,KAAK,EAAEuB,MAAM,CAACnB,QADlB;AAEI,IAAA,UAAU,EAAEsB;AAFhB,kBAII,6BAAC,WAAD;AACI,IAAA,SAAS,EAAE,EADf;AAEI,IAAA,KAAK,EAAE,CACHH,MAAM,CAACf,KADJ,EAEH;AAAEiB,MAAAA;AAAF,KAFG;AAFX,KAOKN,QAPL,CAJJ,CANJ,CADJ;AAuBH;;AAAA","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"]}
1
+ {"version":3,"names":["useStyles","theme","useTheme","root","justifyContent","zIndex","dialog","animated","alignSelf","maxWidth","width","paper","borderBottomLeftRadius","borderBottomRightRadius","flexGrow","overflow","convertHeightAsPixel","windowHeight","value","percentageRegex","RegExp","test","percentage","parseFloat","isNaN","Math","round","BottomSheet","props","backdropOpacity","children","index","onChange","snapPoints","styles","height","useWindowDimensions","handleClose","length","translateY","css","StyleSheet","absoluteFill"],"sources":["BottomSheetWeb.tsx"],"sourcesContent":["import React from 'react';\nimport { useWindowDimensions } from 'react-native';\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 convertHeightAsPixel = (windowHeight: number, value: number | string): number => {\n if (typeof value === 'number') {\n return value;\n }\n\n const percentageRegex = new RegExp(/^[0-9]+%$/);\n if (percentageRegex.test(value)) {\n const percentage = parseFloat(value) / 100;\n return isNaN(percentage) ? 0 : Math.round(windowHeight * percentage);\n }\n\n return 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 { height: windowHeight } = useWindowDimensions();\n\n const handleClose = () => {\n if (onChange) {\n onChange(-1);\n }\n };\n\n const height = convertHeightAsPixel(windowHeight, snapPoints[snapPoints.length - 1] ?? 0);\n const translateY = height - (convertHeightAsPixel(windowHeight, 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;;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;MAG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IAAI,CAHtB;IAII,KAAK,EAAE,IAAAS,SAAA,EAAI,CAACC,gBAAA,CAAWC,YAAZ,EAA0BR,MAAM,CAAC/B,IAAjC,CAAJ;EAJX,gBAMI,6BAAC,kBAAD;IACI,KAAK,EAAE+B,MAAM,CAAC3B,QADlB;IAEI,UAAU,EAAEgC;EAFhB,gBAII,6BAAC,WAAD;IACI,SAAS,EAAE,EADf;IAEI,KAAK,EAAE,CACHL,MAAM,CAACvB,KADJ,EAEH;MAAEwB;IAAF,CAFG;EAFX,GAOKL,QAPL,CAJJ,CANJ,CADJ;AAuBH;;AAAA"}
@@ -13,7 +13,7 @@ var _styles = require("@fountain-ui/styles");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- function _extends() { _extends = Object.assign || 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); }
16
+ 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); }
17
17
 
18
18
  function TransparentBackdrop(props) {
19
19
  // The reason that it did not use the opacity prop is that the close event is ignored in Android. (opacity < 0.1)
@@ -1 +1 @@
1
- {"version":3,"sources":["TransparentBackdrop.tsx"],"names":["TransparentBackdrop","props","backdropStyle","backgroundColor","bottom","left","position","right","top"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAEe,SAASA,mBAAT,CAA6BC,KAA7B,EAA8D;AACzE;AACA,QAAMC,aAAa,GAAG,iBAAI,CACtB;AACIC,IAAAA,eAAe,EAAE,WADrB;AAEIC,IAAAA,MAAM,EAAE,CAFZ;AAGIC,IAAAA,IAAI,EAAE,CAHV;AAIIC,IAAAA,QAAQ,EAAE,UAJd;AAKIC,IAAAA,KAAK,EAAE,CALX;AAMIC,IAAAA,GAAG,EAAE;AANT,GADsB,CAAJ,CAAtB;AAWA,sBACI,6BAAC,gCAAD,eACQP,KADR;AAEI,IAAA,cAAc,EAAE,CAFpB;AAGI,IAAA,iBAAiB,EAAE,CAAC,CAHxB;AAII,IAAA,KAAK,EAAEC;AAJX,KADJ;AAQH;;AAAA","sourcesContent":["import React from 'react';\nimport { BottomSheetBackdrop, BottomSheetBackdropProps } from '@gorhom/bottom-sheet';\nimport { css } from '@fountain-ui/styles';\n\nexport default function TransparentBackdrop(props: BottomSheetBackdropProps) {\n // The reason that it did not use the opacity prop is that the close event is ignored in Android. (opacity < 0.1)\n const backdropStyle = css([\n {\n backgroundColor: '#ffffff00',\n bottom: 0,\n left: 0,\n position: 'absolute',\n right: 0,\n top: 0,\n },\n ]);\n\n return (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n style={backdropStyle}\n />\n );\n};"]}
1
+ {"version":3,"names":["TransparentBackdrop","props","backdropStyle","css","backgroundColor","bottom","left","position","right","top"],"sources":["TransparentBackdrop.tsx"],"sourcesContent":["import React from 'react';\nimport { BottomSheetBackdrop, BottomSheetBackdropProps } from '@gorhom/bottom-sheet';\nimport { css } from '@fountain-ui/styles';\n\nexport default function TransparentBackdrop(props: BottomSheetBackdropProps) {\n // The reason that it did not use the opacity prop is that the close event is ignored in Android. (opacity < 0.1)\n const backdropStyle = css([\n {\n backgroundColor: '#ffffff00',\n bottom: 0,\n left: 0,\n position: 'absolute',\n right: 0,\n top: 0,\n },\n ]);\n\n return (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n style={backdropStyle}\n />\n );\n};"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAEe,SAASA,mBAAT,CAA6BC,KAA7B,EAA8D;EACzE;EACA,MAAMC,aAAa,GAAG,IAAAC,WAAA,EAAI,CACtB;IACIC,eAAe,EAAE,WADrB;IAEIC,MAAM,EAAE,CAFZ;IAGIC,IAAI,EAAE,CAHV;IAIIC,QAAQ,EAAE,UAJd;IAKIC,KAAK,EAAE,CALX;IAMIC,GAAG,EAAE;EANT,CADsB,CAAJ,CAAtB;EAWA,oBACI,6BAAC,gCAAD,eACQR,KADR;IAEI,cAAc,EAAE,CAFpB;IAGI,iBAAiB,EAAE,CAAC,CAHxB;IAII,KAAK,EAAEC;EAJX,GADJ;AAQH;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA","sourcesContent":["export { default } from './BottomSheetWeb';\nexport type { default as BottomSheetProps } from './BottomSheetProps';\n"]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './BottomSheetWeb';\nexport type { default as BottomSheetProps } from './BottomSheetProps';\n"],"mappings":";;;;;;;;;;;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.native.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA","sourcesContent":["export { default } from './BottomSheetNative';\n"]}
1
+ {"version":3,"names":[],"sources":["index.native.ts"],"sourcesContent":["export { default } from './BottomSheetNative';\n"],"mappings":";;;;;;;;;;;;AAAA"}
@@ -0,0 +1,49 @@
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
+ const convertHeightAsPixel = (windowHeight, value) => {
13
+ if (typeof value === 'number') {
14
+ return value;
15
+ }
16
+
17
+ const percentageRegex = new RegExp(/^[0-9]+%$/);
18
+
19
+ if (percentageRegex.test(value)) {
20
+ const percentage = parseFloat(value) / 100;
21
+ return isNaN(percentage) ? 0 : Math.round(windowHeight * percentage);
22
+ }
23
+
24
+ return 0;
25
+ };
26
+
27
+ function useDynamicSnapPoints(props) {
28
+ const {
29
+ index: currentIndex,
30
+ initialSnapPoints
31
+ } = props;
32
+ const {
33
+ height: WINDOW_HEIGHT
34
+ } = (0, _reactNative.useWindowDimensions)();
35
+ const [snapPoints, setSnapPoints] = (0, _react.useState)(initialSnapPoints.map(snapPoint => convertHeightAsPixel(WINDOW_HEIGHT, snapPoint)));
36
+ const handleContentLayout = (0, _react.useCallback)(event => {
37
+ if (initialSnapPoints[currentIndex] === 'CONTENT_HEIGHT') {
38
+ const contentHeight = Math.min(Math.round(WINDOW_HEIGHT * 0.9), event.nativeEvent.layout.height);
39
+ setSnapPoints(prevState => prevState.map((snapPoint, index) => {
40
+ return currentIndex === index ? contentHeight : snapPoint;
41
+ }));
42
+ }
43
+ }, [currentIndex, initialSnapPoints]);
44
+ return {
45
+ handleContentLayout,
46
+ snapPoints
47
+ };
48
+ }
49
+ //# sourceMappingURL=useDynamicSnapPoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["convertHeightAsPixel","windowHeight","value","percentageRegex","RegExp","test","percentage","parseFloat","isNaN","Math","round","useDynamicSnapPoints","props","index","currentIndex","initialSnapPoints","height","WINDOW_HEIGHT","useWindowDimensions","snapPoints","setSnapPoints","useState","map","snapPoint","handleContentLayout","useCallback","event","contentHeight","min","nativeEvent","layout","prevState"],"sources":["useDynamicSnapPoints.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport { LayoutChangeEvent, useWindowDimensions } from 'react-native';\n\ninterface UseDynamicSnapPointsParams {\n index: number;\n initialSnapPoints: (number | string)[];\n}\n\ninterface UseDynamicSnapPointsReturns {\n handleContentLayout: (e: LayoutChangeEvent) => void;\n snapPoints: number[];\n}\n\nconst convertHeightAsPixel = (windowHeight: number, value: number | string): number => {\n if (typeof value === 'number') {\n return value;\n }\n\n const percentageRegex = new RegExp(/^[0-9]+%$/);\n if (percentageRegex.test(value)) {\n const percentage = parseFloat(value) / 100;\n return isNaN(percentage) ? 0 : Math.round(windowHeight * percentage);\n }\n\n return 0;\n};\n\nexport default function useDynamicSnapPoints(props: UseDynamicSnapPointsParams): UseDynamicSnapPointsReturns {\n const {\n index: currentIndex,\n initialSnapPoints,\n } = props;\n\n const { height: WINDOW_HEIGHT } = useWindowDimensions();\n\n const [snapPoints, setSnapPoints] = useState(initialSnapPoints.map((snapPoint) => convertHeightAsPixel(WINDOW_HEIGHT, snapPoint)));\n\n const handleContentLayout = useCallback((event: LayoutChangeEvent) => {\n if (initialSnapPoints[currentIndex] === 'CONTENT_HEIGHT') {\n const contentHeight = Math.min(Math.round(WINDOW_HEIGHT * 0.9), event.nativeEvent.layout.height);\n \n setSnapPoints(prevState => prevState.map((snapPoint, index) => {\n return currentIndex === index ? contentHeight : snapPoint;\n }));\n }\n }, [currentIndex, initialSnapPoints]);\n\n return {\n handleContentLayout,\n snapPoints,\n };\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAYA,MAAMA,oBAAoB,GAAG,CAACC,YAAD,EAAuBC,KAAvB,KAA0D;EACnF,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;IAC3B,OAAOA,KAAP;EACH;;EAED,MAAMC,eAAe,GAAG,IAAIC,MAAJ,CAAW,WAAX,CAAxB;;EACA,IAAID,eAAe,CAACE,IAAhB,CAAqBH,KAArB,CAAJ,EAAiC;IAC7B,MAAMI,UAAU,GAAGC,UAAU,CAACL,KAAD,CAAV,GAAoB,GAAvC;IACA,OAAOM,KAAK,CAACF,UAAD,CAAL,GAAoB,CAApB,GAAwBG,IAAI,CAACC,KAAL,CAAWT,YAAY,GAAGK,UAA1B,CAA/B;EACH;;EAED,OAAO,CAAP;AACH,CAZD;;AAce,SAASK,oBAAT,CAA8BC,KAA9B,EAA8F;EACzG,MAAM;IACFC,KAAK,EAAEC,YADL;IAEFC;EAFE,IAGFH,KAHJ;EAKA,MAAM;IAAEI,MAAM,EAAEC;EAAV,IAA4B,IAAAC,gCAAA,GAAlC;EAEA,MAAM,CAACC,UAAD,EAAaC,aAAb,IAA8B,IAAAC,eAAA,EAASN,iBAAiB,CAACO,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