@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
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = usePagingAnimator;
7
+
8
+ var _react = require("react");
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _core = require("@fountain-ui/core");
13
+
14
+ function directionToValue(itemWidth) {
15
+ return function (direction) {
16
+ switch (direction) {
17
+ case 'next':
18
+ return -itemWidth;
19
+
20
+ case 'prev':
21
+ return itemWidth;
22
+
23
+ case 'stay':
24
+ return 0;
25
+ }
26
+ };
27
+ }
28
+
29
+ function toValueCompensator(itemWidth) {
30
+ return function (toValue, currentOffset) {
31
+ const remainder = Math.abs(currentOffset % itemWidth);
32
+ const halfOfItemWidth = Math.abs(itemWidth / 2);
33
+ const compensateVector = remainder > halfOfItemWidth ? remainder - itemWidth : remainder;
34
+ const direction = currentOffset > 0 ? -1 : 1;
35
+ return toValue + direction * compensateVector;
36
+ };
37
+ }
38
+
39
+ function usePagingAnimator(config) {
40
+ const {
41
+ createScrollAnimation,
42
+ itemWidth,
43
+ indexController,
44
+ initialIndex,
45
+ loop,
46
+ numberOfData
47
+ } = config;
48
+ const {
49
+ getCurrentIndex,
50
+ lastIndex,
51
+ notifyScrollStateHasChanged
52
+ } = indexController;
53
+ const initialOffsetX = itemWidth * initialIndex;
54
+ const accumulativeOffsetX = (0, _core.useAnimatedValue)(initialOffsetX);
55
+ const animationOffsetX = (0, _core.useAnimatedValue)(0);
56
+ const gestureTranslationX = (0, _core.useAnimatedValue)(0);
57
+ const globalInterpolation = (0, _react.useMemo)(() => {
58
+ return _reactNative.Animated.add(_reactNative.Animated.add(accumulativeOffsetX, animationOffsetX), gestureTranslationX);
59
+ }, []);
60
+ const toValueRef = (0, _react.useRef)(0);
61
+ const currentOffsetRef = (0, _react.useRef)(0);
62
+ const isAnimatingRef = (0, _react.useRef)(false);
63
+ const maxWidth = Math.abs(numberOfData * itemWidth);
64
+ const ensureOffsetBoundary = (0, _react.useCallback)(offset => {
65
+ if (loop) {
66
+ const isCloseToEnd = Math.abs(offset) >= maxWidth - itemWidth;
67
+
68
+ if (isCloseToEnd) {
69
+ const signOfOffset = offset > 0 ? 1 : -1;
70
+ return offset + -signOfOffset * maxWidth;
71
+ }
72
+ }
73
+
74
+ return offset % maxWidth;
75
+ }, [itemWidth, loop, maxWidth]);
76
+ const requireNewOffset = (0, _react.useCallback)(newOffset => {
77
+ const nextOffset = ensureOffsetBoundary(newOffset);
78
+ currentOffsetRef.current = nextOffset;
79
+ accumulativeOffsetX.setValue(nextOffset);
80
+ toValueRef.current = 0;
81
+ animationOffsetX.setValue(0);
82
+ }, [ensureOffsetBoundary]);
83
+ const interruptAnimation = (0, _react.useCallback)(() => {
84
+ if (!isAnimatingRef.current) {
85
+ return;
86
+ }
87
+
88
+ animationOffsetX.stopAnimation(lastValue => {
89
+ isAnimatingRef.current = false;
90
+ const prevOffset = currentOffsetRef.current;
91
+ const totalOffset = prevOffset + lastValue;
92
+ requireNewOffset(totalOffset);
93
+ notifyScrollStateHasChanged({
94
+ offset: totalOffset,
95
+ state: 'interrupted'
96
+ });
97
+ });
98
+ }, [notifyScrollStateHasChanged, requireNewOffset]);
99
+ const finalizeAnimation = (0, _react.useCallback)(() => {
100
+ isAnimatingRef.current = false;
101
+ const prevOffset = currentOffsetRef.current;
102
+ const toValue = toValueRef.current;
103
+ const totalOffset = prevOffset + toValue;
104
+ requireNewOffset(totalOffset);
105
+ notifyScrollStateHasChanged({
106
+ offset: totalOffset,
107
+ state: 'idle'
108
+ });
109
+ }, [notifyScrollStateHasChanged, requireNewOffset]);
110
+ const startPagingAnimation = (0, _react.useCallback)((type, config) => {
111
+ if (isAnimatingRef.current) {
112
+ return;
113
+ }
114
+
115
+ const configWithDefaults = {
116
+ animated: true,
117
+ ...config
118
+ };
119
+ const currentIndex = getCurrentIndex();
120
+ const getValueByDirectionOnAllAdjacentItemsVisible = directionToValue(itemWidth);
121
+ const compensateToValue = toValueCompensator(itemWidth);
122
+
123
+ const getValueByDirectionalPagingOnLoopDisabled = _config => {
124
+ const {
125
+ direction,
126
+ isOriginatedFromGesture
127
+ } = _config;
128
+
129
+ if (currentIndex === 0 && direction === 'prev') {
130
+ return isOriginatedFromGesture ? getValueByDirectionOnAllAdjacentItemsVisible('stay') : -lastIndex * itemWidth; // last position
131
+ } else if (currentIndex === lastIndex && direction === 'next') {
132
+ return isOriginatedFromGesture ? getValueByDirectionOnAllAdjacentItemsVisible('stay') : lastIndex * itemWidth; // first position
133
+ }
134
+
135
+ return getValueByDirectionOnAllAdjacentItemsVisible(direction);
136
+ };
137
+
138
+ const getValueByDirectionalPaging = _config => {
139
+ const _configWithDefaults = {
140
+ isOriginatedFromGesture: false,
141
+ ..._config
142
+ };
143
+ return loop ? getValueByDirectionOnAllAdjacentItemsVisible(_configWithDefaults.direction) : getValueByDirectionalPagingOnLoopDisabled(_configWithDefaults);
144
+ };
145
+
146
+ const getValueByIndexPaging = _ref => {
147
+ let {
148
+ index
149
+ } = _ref;
150
+
151
+ if (index < 0 || index > lastIndex || index === currentIndex) {
152
+ // no animation if index is invalid or equals to current index
153
+ return 0;
154
+ }
155
+
156
+ const distance = Math.abs(currentIndex - index) * itemWidth;
157
+ const direction = index > currentIndex ? -1 : 1;
158
+ return distance * direction;
159
+ };
160
+
161
+ const wantedToValue = type === 'directional' // @ts-ignore
162
+ ? getValueByDirectionalPaging(configWithDefaults) // @ts-ignore
163
+ : getValueByIndexPaging(configWithDefaults);
164
+ const toValue = compensateToValue(wantedToValue, currentOffsetRef.current);
165
+ toValueRef.current = toValue;
166
+ isAnimatingRef.current = true;
167
+ notifyScrollStateHasChanged({
168
+ offset: currentOffsetRef.current + toValue,
169
+ state: 'dragging'
170
+ });
171
+ const lastGestureTranslationX = configWithDefaults.lastGestureTranslationX ?? 0;
172
+
173
+ if (Number.isFinite(lastGestureTranslationX)) {
174
+ animationOffsetX.setValue(lastGestureTranslationX);
175
+ gestureTranslationX.setValue(0);
176
+ }
177
+
178
+ if (configWithDefaults.animated) {
179
+ const animation = createScrollAnimation(animationOffsetX, toValue);
180
+ animation.start(_ref2 => {
181
+ let {
182
+ finished
183
+ } = _ref2;
184
+
185
+ if (finished) {
186
+ finalizeAnimation();
187
+ }
188
+ });
189
+ } else {
190
+ finalizeAnimation();
191
+ }
192
+ }, [createScrollAnimation, getCurrentIndex, finalizeAnimation, itemWidth, lastIndex, loop, notifyScrollStateHasChanged]);
193
+ return {
194
+ gestureTranslationX,
195
+ globalInterpolation,
196
+ interruptAnimation,
197
+ startPagingAnimation
198
+ };
199
+ }
200
+
201
+ ;
202
+ //# sourceMappingURL=usePagingAnimator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["directionToValue","itemWidth","direction","toValueCompensator","toValue","currentOffset","remainder","Math","abs","halfOfItemWidth","compensateVector","usePagingAnimator","config","createScrollAnimation","indexController","initialIndex","loop","numberOfData","getCurrentIndex","lastIndex","notifyScrollStateHasChanged","initialOffsetX","accumulativeOffsetX","useAnimatedValue","animationOffsetX","gestureTranslationX","globalInterpolation","useMemo","Animated","add","toValueRef","useRef","currentOffsetRef","isAnimatingRef","maxWidth","ensureOffsetBoundary","useCallback","offset","isCloseToEnd","signOfOffset","requireNewOffset","newOffset","nextOffset","current","setValue","interruptAnimation","stopAnimation","lastValue","prevOffset","totalOffset","state","finalizeAnimation","startPagingAnimation","type","configWithDefaults","animated","currentIndex","getValueByDirectionOnAllAdjacentItemsVisible","compensateToValue","getValueByDirectionalPagingOnLoopDisabled","_config","isOriginatedFromGesture","getValueByDirectionalPaging","_configWithDefaults","getValueByIndexPaging","index","distance","wantedToValue","lastGestureTranslationX","Number","isFinite","animation","start","finished"],"sources":["usePagingAnimator.ts"],"sourcesContent":["import { useCallback, useMemo, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport { useAnimatedValue } from '@fountain-ui/core';\nimport type {\n CreateScrollAnimation,\n DirectionalPagingAnimationConfig,\n IndexController,\n IndexPagingAnimationConfig,\n PagingAnimationConfig,\n PagingAnimationType,\n PagingDirection,\n StartPagingAnimation,\n} from '../types';\n\nexport interface PagingAnimatorConfig {\n createScrollAnimation: CreateScrollAnimation;\n itemWidth: number;\n indexController: IndexController;\n initialIndex: number;\n loop: boolean;\n numberOfData: number;\n}\n\nexport interface PagingAnimator {\n gestureTranslationX: Animated.Value;\n globalInterpolation: Animated.AnimatedInterpolation;\n interruptAnimation: () => void;\n startPagingAnimation: StartPagingAnimation;\n}\n\nfunction directionToValue(itemWidth: number) {\n return function (direction: PagingDirection): number {\n switch (direction) {\n case 'next':\n return -itemWidth;\n case 'prev':\n return itemWidth;\n case 'stay':\n return 0;\n }\n };\n}\n\nfunction toValueCompensator(itemWidth: number) {\n return function (toValue: number, currentOffset: number): number {\n const remainder = Math.abs(currentOffset % itemWidth);\n\n const halfOfItemWidth = Math.abs(itemWidth / 2);\n const compensateVector = remainder > halfOfItemWidth\n ? remainder - itemWidth\n : remainder;\n\n const direction = currentOffset > 0 ? -1 : 1;\n\n return toValue + (direction * compensateVector);\n };\n}\n\nexport default function usePagingAnimator(config: PagingAnimatorConfig): PagingAnimator {\n const {\n createScrollAnimation,\n itemWidth,\n indexController,\n initialIndex,\n loop,\n numberOfData,\n } = config;\n\n const {\n getCurrentIndex,\n lastIndex,\n notifyScrollStateHasChanged,\n } = indexController;\n\n const initialOffsetX = itemWidth * initialIndex;\n const accumulativeOffsetX = useAnimatedValue(initialOffsetX);\n const animationOffsetX = useAnimatedValue(0);\n const gestureTranslationX = useAnimatedValue(0);\n\n const globalInterpolation = useMemo(() => {\n return Animated.add(\n Animated.add(accumulativeOffsetX, animationOffsetX),\n gestureTranslationX,\n );\n }, []);\n\n const toValueRef = useRef<number>(0);\n const currentOffsetRef = useRef<number>(0);\n\n const isAnimatingRef = useRef<boolean>(false);\n\n const maxWidth = Math.abs(numberOfData * itemWidth);\n\n const ensureOffsetBoundary: (offset: number) => number = useCallback((offset: number) => {\n if (loop) {\n const isCloseToEnd = Math.abs(offset) >= (maxWidth - itemWidth);\n if (isCloseToEnd) {\n const signOfOffset = offset > 0 ? 1 : -1;\n return offset + (-signOfOffset * maxWidth);\n }\n }\n\n return offset % maxWidth;\n }, [itemWidth, loop, maxWidth]);\n\n const requireNewOffset = useCallback((newOffset: number) => {\n const nextOffset = ensureOffsetBoundary(newOffset);\n\n currentOffsetRef.current = nextOffset;\n accumulativeOffsetX.setValue(nextOffset);\n\n toValueRef.current = 0;\n animationOffsetX.setValue(0);\n }, [\n ensureOffsetBoundary,\n ]);\n\n const interruptAnimation = useCallback(() => {\n if (!isAnimatingRef.current) {\n return;\n }\n\n animationOffsetX.stopAnimation(lastValue => {\n isAnimatingRef.current = false;\n\n const prevOffset = currentOffsetRef.current;\n const totalOffset = prevOffset + lastValue;\n\n requireNewOffset(totalOffset);\n\n notifyScrollStateHasChanged({ offset: totalOffset, state: 'interrupted' });\n });\n }, [\n notifyScrollStateHasChanged,\n requireNewOffset,\n ]);\n\n const finalizeAnimation = useCallback(() => {\n isAnimatingRef.current = false;\n\n const prevOffset = currentOffsetRef.current;\n const toValue = toValueRef.current;\n const totalOffset = prevOffset + toValue;\n\n requireNewOffset(totalOffset);\n\n notifyScrollStateHasChanged({ offset: totalOffset, state: 'idle' });\n }, [\n notifyScrollStateHasChanged,\n requireNewOffset,\n ]);\n\n const startPagingAnimation = useCallback((type: PagingAnimationType, config: PagingAnimationConfig) => {\n if (isAnimatingRef.current) {\n return;\n }\n\n const configWithDefaults: PagingAnimationConfig = {\n animated: true,\n ...config,\n };\n\n const currentIndex = getCurrentIndex();\n\n const getValueByDirectionOnAllAdjacentItemsVisible = directionToValue(itemWidth);\n const compensateToValue = toValueCompensator(itemWidth);\n\n const getValueByDirectionalPagingOnLoopDisabled = (_config: DirectionalPagingAnimationConfig): number => {\n const { direction, isOriginatedFromGesture } = _config;\n\n if (currentIndex === 0 && direction === 'prev') {\n return isOriginatedFromGesture\n ? getValueByDirectionOnAllAdjacentItemsVisible('stay')\n : -lastIndex * itemWidth; // last position\n } else if (currentIndex === lastIndex && direction === 'next') {\n return isOriginatedFromGesture\n ? getValueByDirectionOnAllAdjacentItemsVisible('stay')\n : lastIndex * itemWidth; // first position\n }\n return getValueByDirectionOnAllAdjacentItemsVisible(direction);\n };\n\n const getValueByDirectionalPaging = (_config: DirectionalPagingAnimationConfig): number => {\n const _configWithDefaults: DirectionalPagingAnimationConfig = {\n isOriginatedFromGesture: false,\n ..._config,\n };\n\n return loop\n ? getValueByDirectionOnAllAdjacentItemsVisible(_configWithDefaults.direction)\n : getValueByDirectionalPagingOnLoopDisabled(_configWithDefaults);\n };\n\n const getValueByIndexPaging = ({ index }: IndexPagingAnimationConfig): number => {\n if (index < 0 || index > lastIndex || index === currentIndex) {\n // no animation if index is invalid or equals to current index\n return 0;\n }\n\n const distance = Math.abs(currentIndex - index) * itemWidth;\n const direction = index > currentIndex ? -1 : 1;\n\n return distance * direction;\n };\n\n const wantedToValue = type === 'directional'\n // @ts-ignore\n ? getValueByDirectionalPaging(configWithDefaults)\n // @ts-ignore\n : getValueByIndexPaging(configWithDefaults);\n\n const toValue = compensateToValue(wantedToValue, currentOffsetRef.current);\n\n toValueRef.current = toValue;\n isAnimatingRef.current = true;\n\n notifyScrollStateHasChanged({\n offset: currentOffsetRef.current + toValue,\n state: 'dragging',\n });\n\n const lastGestureTranslationX: number = configWithDefaults.lastGestureTranslationX ?? 0;\n if (Number.isFinite(lastGestureTranslationX)) {\n animationOffsetX.setValue(lastGestureTranslationX);\n gestureTranslationX.setValue(0);\n }\n\n if (configWithDefaults.animated) {\n const animation = createScrollAnimation(animationOffsetX, toValue);\n\n animation.start(({ finished }) => {\n if (finished) {\n finalizeAnimation();\n }\n });\n } else {\n finalizeAnimation();\n }\n }, [\n createScrollAnimation,\n getCurrentIndex,\n finalizeAnimation,\n itemWidth,\n lastIndex,\n loop,\n notifyScrollStateHasChanged,\n ]);\n\n return {\n gestureTranslationX,\n globalInterpolation,\n interruptAnimation,\n startPagingAnimation,\n };\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AA4BA,SAASA,gBAAT,CAA0BC,SAA1B,EAA6C;EACzC,OAAO,UAAUC,SAAV,EAA8C;IACjD,QAAQA,SAAR;MACI,KAAK,MAAL;QACI,OAAO,CAACD,SAAR;;MACJ,KAAK,MAAL;QACI,OAAOA,SAAP;;MACJ,KAAK,MAAL;QACI,OAAO,CAAP;IANR;EAQH,CATD;AAUH;;AAED,SAASE,kBAAT,CAA4BF,SAA5B,EAA+C;EAC3C,OAAO,UAAUG,OAAV,EAA2BC,aAA3B,EAA0D;IAC7D,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAL,CAASH,aAAa,GAAGJ,SAAzB,CAAlB;IAEA,MAAMQ,eAAe,GAAGF,IAAI,CAACC,GAAL,CAASP,SAAS,GAAG,CAArB,CAAxB;IACA,MAAMS,gBAAgB,GAAGJ,SAAS,GAAGG,eAAZ,GACnBH,SAAS,GAAGL,SADO,GAEnBK,SAFN;IAIA,MAAMJ,SAAS,GAAGG,aAAa,GAAG,CAAhB,GAAoB,CAAC,CAArB,GAAyB,CAA3C;IAEA,OAAOD,OAAO,GAAIF,SAAS,GAAGQ,gBAA9B;EACH,CAXD;AAYH;;AAEc,SAASC,iBAAT,CAA2BC,MAA3B,EAAyE;EACpF,MAAM;IACFC,qBADE;IAEFZ,SAFE;IAGFa,eAHE;IAIFC,YAJE;IAKFC,IALE;IAMFC;EANE,IAOFL,MAPJ;EASA,MAAM;IACFM,eADE;IAEFC,SAFE;IAGFC;EAHE,IAIFN,eAJJ;EAMA,MAAMO,cAAc,GAAGpB,SAAS,GAAGc,YAAnC;EACA,MAAMO,mBAAmB,GAAG,IAAAC,sBAAA,EAAiBF,cAAjB,CAA5B;EACA,MAAMG,gBAAgB,GAAG,IAAAD,sBA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AO;IACHK,mBADG;IAEHC,mBAFG;IAGHmB,kBAHG;IAIHO;EAJG,CAAP;AAMH;;AAAA"}
@@ -6,11 +6,25 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "default", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _CarouselWeb.default;
9
+ return _Carousel.default;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "normalItemStyleFactory", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _animation.normalItemStyleFactory;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "parallaxItemStyleFactory", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _animation.parallaxItemStyleFactory;
22
+ }
23
+ });
24
+
25
+ var _Carousel = _interopRequireDefault(require("./Carousel"));
12
26
 
13
- var _CarouselWeb = _interopRequireDefault(require("./CarouselWeb"));
27
+ var _animation = require("./animation");
14
28
 
15
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA","sourcesContent":["export { default } from './CarouselWeb';\nexport type { default as CarouselProps } from './CarouselProps';"]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './Carousel';\nexport type { default as CarouselProps } from './CarouselProps';\nexport type { CarouselInstance } from './types';\nexport { normalItemStyleFactory, parallaxItemStyleFactory } from './animation';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAGA"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("@fountain-ui/utils");
9
+
10
+ var _default = (0, _utils.logger)('Carousel', {
11
+ enabled: __DEV__,
12
+ format: 'diff'
13
+ });
14
+
15
+ exports.default = _default;
16
+ //# sourceMappingURL=tick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["logger","enabled","__DEV__","format"],"sources":["tick.ts"],"sourcesContent":["import { logger } from '@fountain-ui/utils';\n\nexport default logger('Carousel', {\n enabled: __DEV__,\n format: 'diff',\n});\n"],"mappings":";;;;;;;AAAA;;eAEe,IAAAA,aAAA,EAAO,UAAP,EAAmB;EAC9BC,OAAO,EAAEC,OADqB;EAE9BC,MAAM,EAAE;AAFsB,CAAnB,C"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ const directions = ['next', 'prev', 'stay'];
7
+ const scrollStates = ['idle', 'dragging', 'interrupted'];
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["directions","scrollStates"],"sources":["types.ts"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type { Animated, ViewProps } from 'react-native';\n\nconst directions = ['next', 'prev', 'stay'] as const;\n\nexport type PagingDirection = (typeof directions)[number];\n\nconst scrollStates = ['idle', 'dragging', 'interrupted'] as const;\n\nexport type ScrollState = (typeof scrollStates)[number];\n\nexport type ItemHeight = number | 'auto';\n\nexport interface RenderItem<T> {\n (info: { item: T, index: number, interpolation: Animated.AnimatedInterpolation }): ReactElement | null;\n}\n\nexport interface CreateScrollAnimation {\n (aValue: Animated.AnimatedValue, toValue: number): Animated.CompositeAnimation;\n}\n\nexport interface CreateItemStyle {\n (itemInterpolation: Animated.AnimatedInterpolation, itemWidth: number): Animated.AnimatedProps<ViewProps['style']>;\n}\n\nexport interface GetCurrentIndex {\n (): number;\n}\n\nexport interface OnIndexChange {\n (itemIndex: number): void;\n}\n\nexport interface OnPositionChange {\n (position: number): void;\n}\n\nexport interface ScrollStateChangeEvent {\n offset: number;\n state: ScrollState;\n}\n\nexport interface IndexController {\n getCurrentIndex: GetCurrentIndex;\n lastIndex: number;\n notifyScrollStateHasChanged: (event: ScrollStateChangeEvent) => void;\n}\n\nexport type PagingAnimationType = 'directional' | 'index';\n\nexport interface BasePagingAnimationConfig {\n animated?: boolean;\n lastGestureTranslationX?: number;\n}\n\nexport interface DirectionalPagingAnimationConfig extends BasePagingAnimationConfig {\n direction: PagingDirection;\n isOriginatedFromGesture?: boolean;\n}\n\nexport interface IndexPagingAnimationConfig extends BasePagingAnimationConfig {\n index: number;\n}\n\nexport type PagingAnimationConfig = DirectionalPagingAnimationConfig | IndexPagingAnimationConfig;\n\nexport interface StartPagingAnimation {\n (type: PagingAnimationType, config: PagingAnimationConfig): void;\n}\n\nexport type VisibleIndexRanges = Array<[number, number]>;\n\nexport interface StoreSubscription {\n (): void;\n}\n\nexport interface ItemVisibilityStore {\n dispatch: (ranges: VisibleIndexRanges) => void;\n subscribe: (listener: (ranges: VisibleIndexRanges) => void) => StoreSubscription;\n removeAllListeners: () => void;\n}\n\nexport interface AutoplayController {\n pause: () => void;\n resume: () => void;\n}\n\nexport interface ScrollToOption {\n index: number;\n animated?: boolean;\n}\n\nexport interface CarouselInstance {\n /**\n * Get current visible item index.\n */\n getCurrentIndex: GetCurrentIndex;\n\n /**\n * Scroll to next visible item.\n */\n next: () => void;\n\n /**\n * Scroll to previous visible item.\n */\n prev: () => void;\n\n /**\n * Scroll to desired indexed item.\n * Invalid index is ignored.\n */\n scrollTo: (option: ScrollToOption) => void;\n}\n"],"mappings":";;;;;AAGA,MAAMA,UAAU,GAAG,CAAC,MAAD,EAAS,MAAT,EAAiB,MAAjB,CAAnB;AAIA,MAAMC,YAAY,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,aAArB,CAArB"}
@@ -11,6 +11,8 @@ var _reactNative = require("react-native");
11
11
 
12
12
  var R = _interopRequireWildcard(require("ramda"));
13
13
 
14
+ var _ComicViewerProps = require("./ComicViewerProps");
15
+
14
16
  var _ViewerItem = _interopRequireDefault(require("./ViewerItem"));
15
17
 
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -19,7 +21,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
19
21
 
20
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; }
21
23
 
22
- 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); }
24
+ 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
25
 
24
26
  const getItemHeights = items => R.map(content => content.height)(items);
25
27
 
@@ -27,7 +29,7 @@ const appender = (left, right) => [left + right, left + right];
27
29
 
28
30
  const getHeightAccum = itemHeights => R.mapAccum(appender, 0, itemHeights);
29
31
 
30
- const keyExtractor = item => item.id;
32
+ const keyExtractor = item => `${item.sortKey}`;
31
33
 
32
34
  function ComicViewer(props) {
33
35
  const {
@@ -38,21 +40,29 @@ function ComicViewer(props) {
38
40
  initialScrollPercentage = 0,
39
41
  itemVisiblePercentThreshold = 0,
40
42
  onError,
43
+ onScroll,
44
+ getNextPage,
41
45
  viewerWidth,
42
46
  windowSize = 3,
47
+ pageUnit,
48
+ ListFooterComponent,
43
49
  ...otherProps
44
50
  } = props;
45
51
  const flatListRef = (0, _react.useRef)(null);
46
52
  const errors = (0, _react.useRef)(new Map());
47
53
  const debounceTimeOut = (0, _react.useRef)(null);
48
- const resourceString = R.toString(R.map(itemData => itemData.sourceUrl)(data));
54
+ const resourceString = R.toString(R.map(itemData => itemData.url)(data));
49
55
  const initialItems = R.map(itemData => ({ ...itemData,
50
56
  isViewable: false,
51
57
  width: viewerWidth,
52
58
  height: itemData.height * viewerWidth / itemData.width
53
59
  }))(data);
54
60
  const [items, setItems] = (0, _react.useState)(initialItems);
55
- const itemHeights = getItemHeights(items);
61
+ const initialItemState = R.map(() => ({
62
+ state: _ComicViewerProps.STATE.UNLOAD
63
+ }))(data);
64
+ const itemStates = (0, _react.useRef)(initialItemState);
65
+ const itemHeights = [...getItemHeights(items)];
56
66
  const itemHeightAccum = getHeightAccum(itemHeights);
57
67
  const viewabilityConfig = (0, _react.useMemo)(() => ({
58
68
  itemVisiblePercentThreshold
@@ -65,67 +75,89 @@ function ComicViewer(props) {
65
75
  index
66
76
  };
67
77
  }, [itemHeights]);
68
- const onViewableItemsChanged = (0, _react.useRef)(({
69
- viewableItems
70
- }) => {
78
+ const onViewableItemsChanged = (0, _react.useRef)(_ref => {
79
+ let {
80
+ viewableItems
81
+ } = _ref;
71
82
  setItems(prev => {
72
- const viewableItemIds = R.map(viewableItem => viewableItem.item.id)(viewableItems);
73
- return R.map(prevItem => ({ ...prevItem,
74
- isViewable: R.includes(prevItem.id, viewableItemIds)
83
+ const viewableItemSortKeys = R.map(viewableItem => viewableItem.item.sortKey)(viewableItems);
84
+ const newItems = R.map(prevItem => ({ ...prevItem,
85
+ isViewable: R.includes(prevItem.sortKey, viewableItemSortKeys)
75
86
  }))([...prev]);
87
+ return newItems;
76
88
  });
77
89
  });
90
+ const itemLoadedHandler = (0, _react.useCallback)(sortKey => {
91
+ const itemState = itemStates.current[sortKey - 1];
92
+ itemState.state = _ComicViewerProps.STATE.LOADED;
93
+ itemState.error = undefined;
94
+ }, [itemStates]);
95
+ const itemErrorHandler = (0, _react.useCallback)(errorInfo => {
96
+ const {
97
+ sortKey,
98
+ count
99
+ } = errorInfo;
78
100
 
79
- const onErrorHandler = errors => {
80
- const isRetryLimited = R.any(error => error.count >= errorRetryCount)(errors);
81
-
82
- if (isRetryLimited) {
101
+ if (count >= errorRetryCount) {
83
102
  return;
84
103
  }
85
104
 
86
- onError && onError(errors);
87
- };
105
+ errors.current.set(sortKey, errorInfo);
106
+ const itemState = itemStates.current[sortKey - 1];
107
+ itemState.state = _ComicViewerProps.STATE.FAIL;
108
+ itemState.error = errorInfo;
88
109
 
89
- const itemErrorHandler = (0, _react.useCallback)(errorInfo => {
90
- errors.current.set(errorInfo.id, errorInfo.count);
110
+ const handleError = () => {
111
+ const errorsArray = Array.from(errors.current.entries());
112
+ const errorsInfo = R.map(_ref2 => {
113
+ let [key, value] = _ref2;
114
+ return value;
115
+ })(errorsArray);
116
+ onError && onError([...errorsInfo]);
117
+ errors.current.clear();
118
+ };
91
119
 
92
120
  if (debounceTimeOut.current) {
93
121
  clearTimeout(debounceTimeOut.current);
94
122
  }
95
123
 
96
- debounceTimeOut.current = setTimeout(function () {
97
- const errorsArray = Array.from(errors.current.entries());
98
- const errorsInfo = R.map(([key, value]) => ({
99
- id: key,
100
- count: value
101
- }))(errorsArray);
102
- onErrorHandler([...errorsInfo]);
103
- errors.current.clear();
104
- }, errorDebounceMillis);
105
- }, [errorDebounceMillis, errors.current]);
106
- const renderItem = (0, _react.useCallback)(({
107
- item
108
- }) => {
124
+ if (errors.current.size === pageUnit) {
125
+ handleError();
126
+ } else {
127
+ debounceTimeOut.current = setTimeout(handleError, errorDebounceMillis);
128
+ }
129
+ }, [errors.current, itemStates]);
130
+ const renderItem = (0, _react.useCallback)(_ref3 => {
131
+ let {
132
+ item
133
+ } = _ref3;
134
+ const itemState = itemStates.current[item.sortKey - 1];
109
135
  const props = { ...item,
110
- onError: itemErrorHandler
136
+ itemState,
137
+ errorRetryCount,
138
+ onError: itemErrorHandler,
139
+ onLoaded: itemLoadedHandler,
140
+ getNextPage
111
141
  };
112
142
  return /*#__PURE__*/_react.default.createElement(_ViewerItem.default, {
113
143
  props: props
114
144
  });
115
- }, []);
145
+ }, [resourceString, itemStates, itemErrorHandler, itemLoadedHandler]);
116
146
  (0, _react.useEffect)(() => {
117
147
  setItems(prev => {
118
148
  return R.map(prevItem => {
119
- const currentData = R.find(currentItemData => prevItem.id === currentItemData.id)(data);
149
+ const currentData = R.find(currentItemData => prevItem.sortKey === currentItemData.sortKey)(data);
120
150
 
121
- if (currentData && currentData.sourceUrl !== prevItem.sourceUrl) {
151
+ if (currentData && itemStates.current[currentData.sortKey - 1].state !== _ComicViewerProps.STATE.LOADED && currentData.url !== prevItem.url) {
122
152
  return { ...prevItem,
123
- sourceUrl: currentData.sourceUrl
153
+ url: currentData.url,
154
+ expiresAt: currentData.expiresAt
124
155
  };
125
156
  }
126
157
 
127
158
  return prevItem;
128
159
  })([...prev]);
160
+ ;
129
161
  });
130
162
  }, [resourceString]);
131
163
  (0, _react.useEffect)(() => {
@@ -152,10 +184,12 @@ function ComicViewer(props) {
152
184
  initialNumToRender: initialNumToRender,
153
185
  keyExtractor: keyExtractor,
154
186
  onViewableItemsChanged: onViewableItemsChanged.current,
187
+ onScroll: onScroll,
155
188
  ref: flatListRef,
156
189
  renderItem: renderItem,
157
190
  viewabilityConfig: viewabilityConfig,
158
- windowSize: windowSize
191
+ windowSize: windowSize,
192
+ ListFooterComponent: ListFooterComponent
159
193
  }, otherProps));
160
194
  }
161
195
 
@@ -1 +1 @@
1
- {"version":3,"sources":["ComicViewer.tsx"],"names":["getItemHeights","items","R","map","content","height","appender","left","right","getHeightAccum","itemHeights","mapAccum","keyExtractor","item","id","ComicViewer","props","data","errorDebounceMillis","errorRetryCount","initialNumToRender","initialScrollPercentage","itemVisiblePercentThreshold","onError","viewerWidth","windowSize","otherProps","flatListRef","errors","Map","debounceTimeOut","resourceString","toString","itemData","sourceUrl","initialItems","isViewable","width","setItems","itemHeightAccum","viewabilityConfig","getItemLayout","index","offsets","prepend","length","offset","onViewableItemsChanged","viewableItems","prev","viewableItemIds","viewableItem","prevItem","includes","onErrorHandler","isRetryLimited","any","error","count","itemErrorHandler","errorInfo","current","set","clearTimeout","setTimeout","errorsArray","Array","from","entries","errorsInfo","key","value","clear","renderItem","currentData","find","currentItemData","newItems","totalHeight","Math","floor","scrollToOffset","animated"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAGA;;;;;;;;;;AAEA,MAAMA,cAAc,GAASC,KAAN,IAAqDC,CAAC,CAACC,GAAF,CAAOC,OAAD,IAAsCA,OAAO,CAACC,MAApD,EAA4DJ,KAA5D,CAA5E;;AACA,MAAMK,QAAQ,GAAG,CAACC,IAAD,EAAeC,KAAf,KAAmD,CAACD,IAAI,GAAGC,KAAR,EAAeD,IAAI,GAAGC,KAAtB,CAApE;;AACA,MAAMC,cAAc,GAAIC,WAAD,IAA+CR,CAAC,CAACS,QAAF,CAAWL,QAAX,EAAqB,CAArB,EAAwBI,WAAxB,CAAtE;;AAEA,MAAME,YAAY,GAASC,IAAN,IAAwCA,IAAI,CAACC,EAAlE;;AAEe,SAASC,WAAT,CAAwBC,KAAxB,EAAoD;AAC/D,QAAM;AACFC,IAAAA,IADE;AAEFC,IAAAA,mBAAmB,GAAG,GAFpB;AAGFC,IAAAA,eAAe,GAAG,CAHhB;AAIFC,IAAAA,kBAAkB,GAAG,CAJnB;AAKFC,IAAAA,uBAAuB,GAAG,CALxB;AAMFC,IAAAA,2BAA2B,GAAG,CAN5B;AAOFC,IAAAA,OAPE;AAQFC,IAAAA,WARE;AASFC,IAAAA,UAAU,GAAG,CATX;AAUF,OAAGC;AAVD,MAWFV,KAXJ;AAaA,QAAMW,WAAW,GAAG,mBAAiB,IAAjB,CAApB;AAEA,QAAMC,MAAM,GAAG,mBAA4B,IAAIC,GAAJ,EAA5B,CAAf;AACA,QAAMC,eAAe,GAAG,mBAA8B,IAA9B,CA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gD;AAGvDnB,MAAAA,MAAM,EAAGQ,IAAI,CAACR,MAAL,GAAcmB,WAAf,GAA8BX,IAAI,CAACwB;AAHY,KAApC,CAAN,EAIbpC,KAJa,CAAjB;AAMAqC,IAAAA,QAAQ,CAACuC,QAAD,CAAR;AACH,GARD,EAQG,CAACrD,WAAD,CARH;AAUA,wBAAU,MAAM;AACZ,UAAMsD,WAAW,GAAGvC,eAAe,CAAC,CAAD,CAAnC;AACA,UAAMO,MAAM,GAAGiC,IAAI,CAACC,KAAL,CAAY3D,uBAAuB,GAAG,GAA3B,GAAkCyD,WAA7C,CAAf;;AAEA,QAAInD,WAAW,CAACkC,OAAhB,EAAyB;AACrBlC,MAAAA,WAAW,CAACkC,OAAZ,CAAoBoB,cAApB,CAAmC;AAAEnC,QAAAA,MAAF;AAAUoC,QAAAA,QAAQ,EAAE;AAApB,OAAnC;AACH;AACJ,GAPD,EAOG,CAACvD,WAAW,CAACkC,OAAb,CAPH;AASA,sBACI,6BAAC,qBAAD;AACI,IAAA,IAAI,EAAE5D,KADV;AAEI,IAAA,aAAa,EAAEwC,aAFnB;AAGI,IAAA,kBAAkB,EAAErB,kBAHxB;AAII,IAAA,YAAY,EAAER,YAJlB;AAKI,IAAA,sBAAsB,EAAEmC,sBAAsB,CAACc,OALnD;AAMI,IAAA,GAAG,EAAElC,WANT;AAOI,IAAA,UAAU,EAAE8C,UAPhB;AAQI,IAAA,iBAAiB,EAAEjC,iBARvB;AASI,IAAA,UAAU,EAAEf;AAThB,KAUQC,UAVR,EADJ;AAcH;;AAAA","sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { FlatList, ListRenderItem, ViewToken } from 'react-native';\nimport * as R from 'ramda';\nimport { ComicViewerItemData, default as ComicViewerProps, ErrorInfo } from './ComicViewerProps';\nimport type ComicViewerItemProps from './ComicViewerItemProps';\nimport ViewerItem from './ViewerItem';\n\nconst getItemHeights = <T, >(items: ComicViewerItemProps<T>[]): number[] => R.map((content: ComicViewerItemProps<T>) => content.height)(items);\nconst appender = (left: number, right: number): [number, number] => [left + right, left + right];\nconst getHeightAccum = (itemHeights: number[]): [number, number[]] => R.mapAccum(appender, 0, itemHeights);\n\nconst keyExtractor = <T, >(item: ComicViewerItemProps<T>) => item.id;\n\nexport default function ComicViewer<T>(props: ComicViewerProps<T>) {\n const {\n data,\n errorDebounceMillis = 500,\n errorRetryCount = 3,\n initialNumToRender = 1,\n initialScrollPercentage = 0,\n itemVisiblePercentThreshold = 0,\n onError,\n viewerWidth,\n windowSize = 3,\n ...otherProps\n } = props;\n\n const flatListRef = useRef<FlatList>(null);\n\n const errors = useRef<Map<string, number>>(new Map());\n const debounceTimeOut = useRef<NodeJS.Timeout | null>(null);\n\n const resourceString = R.toString(R.map((itemData: ComicViewerItemData) => itemData.sourceUrl)(data));\n\n const initialItems = R.map((itemData: ComicViewerItemData<T>) => ({\n ...itemData,\n isViewable: false,\n width: viewerWidth,\n height: (itemData.height * viewerWidth) / itemData.width,\n }))(data);\n\n const [items, setItems] = useState<ComicViewerItemProps<T>[]>(initialItems);\n\n const itemHeights = getItemHeights(items);\n const itemHeightAccum = getHeightAccum(itemHeights);\n\n const viewabilityConfig = useMemo(() => ({\n itemVisiblePercentThreshold,\n }), [itemVisiblePercentThreshold]);\n\n const getItemLayout = useCallback((data: any, index: number) => {\n const offsets = R.prepend(0, itemHeightAccum[1]);\n\n return {\n length: itemHeights[index],\n offset: offsets[index],\n index,\n };\n }, [itemHeights]);\n\n const onViewableItemsChanged = useRef(({ viewableItems }: {\n viewableItems: Array<ViewToken>,\n }) => {\n setItems((prev: ComicViewerItemProps<T>[]) => {\n const viewableItemIds = R.map((viewableItem: ViewToken) => viewableItem.item.id)(viewableItems);\n\n return R.map((prevItem: ComicViewerItemProps<T>) => ({\n ...prevItem,\n isViewable: R.includes(prevItem.id, viewableItemIds),\n }))([...prev]);\n });\n });\n\n const onErrorHandler = (errors: ErrorInfo[]) => {\n const isRetryLimited = R.any((error: ErrorInfo) => error.count >= errorRetryCount)(errors);\n\n if (isRetryLimited) {\n return;\n }\n\n onError && onError(errors);\n };\n\n const itemErrorHandler = useCallback((errorInfo: ErrorInfo) => {\n errors.current.set(errorInfo.id, errorInfo.count);\n\n if (debounceTimeOut.current) {\n clearTimeout(debounceTimeOut.current);\n }\n\n debounceTimeOut.current = setTimeout(function () {\n const errorsArray = Array.from(errors.current.entries());\n const errorsInfo = R.map(([key, value]: [string, number]) => ({\n id: key,\n count: value,\n }))(errorsArray);\n\n onErrorHandler([...errorsInfo]);\n errors.current.clear();\n }, errorDebounceMillis);\n }, [errorDebounceMillis, errors.current]);\n\n const renderItem: ListRenderItem<ComicViewerItemProps<T>> = useCallback(({ item }) => {\n const props = {\n ...item,\n onError: itemErrorHandler,\n };\n\n return <ViewerItem props={props}/>;\n }, []);\n\n useEffect(() => {\n setItems((prev: ComicViewerItemProps<T>[]) => {\n return R.map((prevItem: ComicViewerItemProps<T>) => {\n const currentData = R.find((currentItemData: ComicViewerItemData<T>) => prevItem.id === currentItemData.id)(data);\n\n if (currentData && (currentData.sourceUrl !== prevItem.sourceUrl)) {\n return {\n ...prevItem,\n sourceUrl: currentData.sourceUrl,\n };\n }\n\n return prevItem;\n })([...prev]);\n });\n }, [resourceString]);\n\n useEffect(() => {\n const newItems = R.map((item: ComicViewerItemProps<T>) => ({\n ...item,\n width: viewerWidth,\n height: (item.height * viewerWidth) / item.width,\n }))(items);\n\n setItems(newItems);\n }, [viewerWidth]);\n\n useEffect(() => {\n const totalHeight = itemHeightAccum[0];\n const offset = Math.floor((initialScrollPercentage / 100) * totalHeight);\n\n if (flatListRef.current) {\n flatListRef.current.scrollToOffset({ offset, animated: false });\n }\n }, [flatListRef.current]);\n\n return (\n <FlatList\n data={items}\n getItemLayout={getItemLayout}\n initialNumToRender={initialNumToRender}\n keyExtractor={keyExtractor}\n onViewableItemsChanged={onViewableItemsChanged.current}\n ref={flatListRef}\n renderItem={renderItem}\n viewabilityConfig={viewabilityConfig}\n windowSize={windowSize}\n {...otherProps}\n />\n );\n};\n"]}
1
+ {"version":3,"names":["getItemHeights","items","R","map","content","height","appender","left","right","getHeightAccum","itemHeights","mapAccum","keyExtractor","item","sortKey","ComicViewer","props","data","errorDebounceMillis","errorRetryCount","initialNumToRender","initialScrollPercentage","itemVisiblePercentThreshold","onError","onScroll","getNextPage","viewerWidth","windowSize","pageUnit","ListFooterComponent","otherProps","flatListRef","useRef","errors","Map","debounceTimeOut","resourceString","toString","itemData","url","initialItems","isViewable","width","setItems","useState","initialItemState","state","STATE","UNLOAD","itemStates","itemHeightAccum","viewabilityConfig","useMemo","getItemLayout","useCallback","index","offsets","prepend","length","offset","onViewableItemsChanged","viewableItems","prev","viewableItemSortKeys","viewableItem","newItems","prevItem","includes","itemLoadedHandler","itemState","current","LOADED","error","undefined","itemErrorHandler","errorInfo","count","set","FAIL","handleError","errorsArray","Array","from","entries","errorsInfo","key","value","clear","clearTimeout","size","setTimeout","renderItem","onLoaded","useEffect","currentData","find","currentItemData","expiresAt","totalHeight","Math","floor","scrollToOffset","animated"],"sources":["ComicViewer.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { FlatList, ListRenderItem, ViewToken } from 'react-native';\nimport * as R from 'ramda';\nimport {\n ComicViewerItemData,\n ComicViewerItemState,\n default as ComicViewerProps,\n ErrorInfo,\n STATE,\n} from './ComicViewerProps';\nimport type ComicViewerItemProps from './ComicViewerItemProps';\nimport ViewerItem from './ViewerItem';\n\nconst getItemHeights = <T, >(items: ComicViewerItemProps<T>[]): number[] => R.map((content: ComicViewerItemProps<T>) => content.height)(items);\nconst appender = (left: number, right: number): [number, number] => [left + right, left + right];\nconst getHeightAccum = (itemHeights: number[]): [number, number[]] => R.mapAccum(appender, 0, itemHeights);\n\nconst keyExtractor = <T, >(item: ComicViewerItemProps<T>) => `${item.sortKey}`;\n\nexport default function ComicViewer<T>(props: ComicViewerProps<T>) {\n const {\n data,\n errorDebounceMillis = 500,\n errorRetryCount = 3,\n initialNumToRender = 1,\n initialScrollPercentage = 0,\n itemVisiblePercentThreshold = 0,\n onError,\n onScroll,\n getNextPage,\n viewerWidth,\n windowSize = 3,\n pageUnit,\n ListFooterComponent,\n ...otherProps\n } = props;\n\n const flatListRef = useRef<FlatList>(null);\n\n const errors = useRef<Map<number, ErrorInfo>>(new Map());\n\n const debounceTimeOut = useRef<NodeJS.Timeout | null>(null);\n\n const resourceString = R.toString(R.map((itemData: ComicViewerItemData) => itemData.url)(data));\n\n const initialItems = R.map((itemData: ComicViewerItemData<T>) => ({\n ...itemData,\n isViewable: false,\n width: viewerWidth,\n height: (itemData.height * viewerWidth) / itemData.width,\n }))(data);\n\n const [items, setItems] = useState<ComicViewerItemProps<T>[]>(initialItems);\n\n const initialItemState: ComicViewerItemState[] = R.map(() => ({\n state: STATE.UNLOAD,\n }))(data);\n\n const itemStates = useRef<Array<ComicViewerItemState>>(initialItemState);\n\n const itemHeights = [...getItemHeights(items)];\n const itemHeightAccum = getHeightAccum(itemHeights);\n\n const viewabilityConfig = useMemo(() => ({\n itemVisiblePercentThreshold,\n }), [itemVisiblePercentThreshold]);\n\n const getItemLayout = useCallback((data: any, index: number) => {\n const offsets = R.prepend(0, itemHeightAccum[1]);\n\n return {\n length: itemHeights[index],\n offset: offsets[index],\n index,\n };\n }, [itemHeights]);\n\n const onViewableItemsChanged = useRef(({ viewableItems }: {\n viewableItems: Array<ViewToken>,\n }) => {\n setItems((prev: ComicViewerItemProps<T>[]) => {\n const viewableItemSortKeys = R.map((viewableItem: ViewToken) => viewableItem.item.sortKey)(viewableItems);\n\n const newItems = R.map((prevItem: ComicViewerItemProps<T>) => ({\n ...prevItem,\n isViewable: R.includes(prevItem.sortKey, viewableItemSortKeys),\n }))([...prev]);\n\n return newItems;\n });\n });\n\n const itemLoadedHandler = useCallback((sortKey: number) => {\n const itemState = itemStates.current[sortKey - 1];\n itemState.state = STATE.LOADED;\n itemState.error = undefined;\n }, [itemStates]);\n\n const itemErrorHandler = useCallback((errorInfo: ErrorInfo) => {\n const { sortKey, count } = errorInfo;\n\n if (count >= errorRetryCount) {\n return;\n }\n\n errors.current.set(sortKey, errorInfo);\n\n const itemState = itemStates.current[sortKey - 1];\n itemState.state = STATE.FAIL;\n itemState.error = errorInfo;\n\n const handleError = () => {\n const errorsArray = Array.from(errors.current.entries());\n const errorsInfo = R.map(([key, value]: [number, ErrorInfo]) => value)(errorsArray);\n\n onError && onError([...errorsInfo]);\n errors.current.clear();\n };\n\n if (debounceTimeOut.current) {\n clearTimeout(debounceTimeOut.current);\n }\n\n if (errors.current.size === pageUnit) {\n handleError();\n } else {\n debounceTimeOut.current = setTimeout(handleError, errorDebounceMillis);\n }\n }, [errors.current, itemStates]);\n\n const renderItem: ListRenderItem<ComicViewerItemProps<T>> = useCallback(({ item }) => {\n const itemState = itemStates.current[item.sortKey - 1];\n\n const props = {\n ...item,\n itemState,\n errorRetryCount,\n onError: itemErrorHandler,\n onLoaded: itemLoadedHandler,\n getNextPage,\n };\n\n return <ViewerItem props={props}/>;\n }, [resourceString, itemStates, itemErrorHandler, itemLoadedHandler]);\n\n useEffect(() => {\n setItems((prev: ComicViewerItemProps<T>[]) => {\n return R.map((prevItem: ComicViewerItemProps<T>) => {\n const currentData = R.find((currentItemData: ComicViewerItemData<T>) => prevItem.sortKey === currentItemData.sortKey)(data);\n\n if (currentData\n && itemStates.current[currentData.sortKey - 1].state !== STATE.LOADED\n && (currentData.url !== prevItem.url)) {\n return {\n ...prevItem,\n url: currentData.url,\n expiresAt: currentData.expiresAt,\n };\n }\n\n return prevItem;\n })([...prev]);\n ;\n });\n }, [resourceString]);\n\n useEffect(() => {\n const newItems = R.map((item: ComicViewerItemProps<T>) => ({\n ...item,\n width: viewerWidth,\n height: (item.height * viewerWidth) / item.width,\n }))(items);\n\n setItems(newItems);\n }, [viewerWidth]);\n\n useEffect(() => {\n const totalHeight = itemHeightAccum[0];\n const offset = Math.floor((initialScrollPercentage / 100) * totalHeight);\n\n if (flatListRef.current) {\n flatListRef.current.scrollToOffset({ offset, animated: false });\n }\n }, [flatListRef.current]);\n\n return (\n <FlatList\n data={items}\n getItemLayout={getItemLayout}\n initialNumToRender={initialNumToRender}\n keyExtractor={keyExtractor}\n onViewableItemsChanged={onViewableItemsChanged.current}\n onScroll={onScroll}\n ref={flatListRef}\n renderItem={renderItem}\n viewabilityConfig={viewabilityConfig}\n windowSize={windowSize}\n ListFooterComponent={ListFooterComponent}\n {...otherProps}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAQA;;;;;;;;;;AAEA,MAAMA,cAAc,GAASC,KAAN,IAAqDC,CAAC,CAACC,GAAF,CAAOC,OAAD,IAAsCA,OAAO,CAACC,MAApD,EAA4DJ,KAA5D,CAA5E;;AACA,MAAMK,QAAQ,GAAG,CAACC,IAAD,EAAeC,KAAf,KAAmD,CAACD,IAAI,GAAGC,KAAR,EAAeD,IAAI,GAAGC,KAAtB,CAApE;;AACA,MAAMC,cAAc,GAAIC,WAAD,IAA+CR,CAAC,CAACS,QAAF,CAAWL,QAAX,EAAqB,CAArB,EAAwBI,WAAxB,CAAtE;;AAEA,MAAME,YAAY,GAASC,IAAN,IAAyC,GAAEA,IAAI,CAACC,OAAQ,EAA7E;;AAEe,SAASC,WAAT,CAAwBC,KAAxB,EAAoD;EAC/D,MAAM;IACFC,IADE;IAEFC,mBAAmB,GAAG,GAFpB;IAGFC,eAAe,GAAG,CAHhB;IAIFC,kBAAkB,GAAG,CAJnB;IAKFC,uBAAuB,GAAG,CALxB;IAMFC,2BAA2B,GAAG,CAN5B;IAOFC,OAPE;IAQFC,QARE;IASFC,WATE;IAUFC,WAVE;IAWFC,UAAU,GAAG,CAXX;IAYFC,QAZE;IAaFC,mBAbE;IAcF,GAAGC;EAdD,IAeFd,KAfJ;EAiBA,MAAMe,WAAW,GAAG,IAAAC,aAAA,EAAiB,IAAjB,CAApB;EAEA,MAAMC,MAAM,GAAG,IAAAD,aAAA,EAA+B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;IAMA0C,QAAQ,CAACsB,QAAD,CAAR;EACH,CARD,EAQG,CAACvC,WAAD,CARH;EAUA,IAAAmE,gBAAA,EAAU,MAAM;IACZ,MAAMK,WAAW,GAAGhD,eAAe,CAAC,CAAD,CAAnC;IACA,MAAMS,MAAM,GAAGwC,IAAI,CAACC,KAAL,CAAY/E,uBAAuB,GAAG,GAA3B,GAAkC6E,WAA7C,CAAf;;IAEA,IAAInE,WAAW,CAACuC,OAAhB,EAAyB;MACrBvC,WAAW,CAACuC,OAAZ,CAAoB+B,cAApB,CAAmC;QAAE1C,MAAF;QAAU2C,QAAQ,EAAE;MAApB,CAAnC;IACH;EACJ,CAPD,EAOG,CAACvE,WAAW,CAACuC,OAAb,CAPH;EASA,oBACI,6BAAC,qBAAD;IACI,IAAI,EAAErE,KADV;IAEI,aAAa,EAAEoD,aAFnB;IAGI,kBAAkB,EAAEjC,kBAHxB;IAII,YAAY,EAAER,YAJlB;IAKI,sBAAsB,EAAEgD,sBAAsB,CAACU,OALnD;IAMI,QAAQ,EAAE9C,QANd;IAOI,GAAG,EAAEO,WAPT;IAQI,UAAU,EAAE4D,UARhB;IASI,iBAAiB,EAAExC,iBATvB;IAUI,UAAU,EAAExB,UAVhB;IAWI,mBAAmB,EAAEE;EAXzB,GAYQC,UAZR,EADJ;AAgBH;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["ComicViewerItemProps.ts"],"sourcesContent":["import { ComicViewerItemData, ErrorInfo, ComicViewerItemState } from './ComicViewerProps';\n\ntype ComicViewerItemProps<T> = ComicViewerItemData<T> & {\n /**\n * FlatListItem is viewable in screen.\n */\n isViewable: boolean;\n\n /**\n * How many times retry onError when same item error occur\n * @default 3\n */\n errorRetryCount?: number;\n\n /**\n * Error handler\n */\n onError?: (errorInfo: ErrorInfo) => void;\n\n /**\n * Load handler\n */\n onLoaded?: (sortKey: number) => void;\n\n getNextPage?: (sortKey: number) => void;\n\n itemState?: ComicViewerItemState;\n}\n\nexport default ComicViewerItemProps;"],"mappings":""}
@@ -1,2 +1,14 @@
1
1
  "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.STATE = void 0;
7
+ const STATE = {
8
+ UNLOAD: 'unload',
9
+ LOADING: 'loading',
10
+ LOADED: 'loaded',
11
+ FAIL: 'fail'
12
+ };
13
+ exports.STATE = STATE;
2
14
  //# sourceMappingURL=ComicViewerProps.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":["STATE","UNLOAD","LOADING","LOADED","FAIL"],"sources":["ComicViewerProps.ts"],"sourcesContent":["import React from 'react';\nimport { ComponentProps } from '@fountain-ui/core';\nimport { NativeScrollEvent, NativeSyntheticEvent } from 'react-native';\n\nexport const STATE = {\n UNLOAD: 'unload',\n LOADING: 'loading',\n LOADED: 'loaded',\n FAIL: 'fail',\n} as const;\n\nexport type LoadingState = typeof STATE[keyof typeof STATE];\n\nexport interface ComicViewerItemState{\n /**\n * Content's loading state.\n */\n state: LoadingState,\n\n /***\n * Content's error Info.\n */\n error?: ErrorInfo,\n}\n\nexport interface ErrorInfo {\n /**\n * ComicViewerItemData.sortKey.\n */\n sortKey: number;\n\n /**\n * Number of times an error occurred.\n */\n count: number;\n\n /**\n * Content is Expired: true\n */\n expired: boolean;\n}\n\nexport type ComicViewerItemData<T = {}> = T & {\n /**\n * Image height.\n */\n height: number;\n\n /**\n * Unique value for identifying.\n */\n id: number | undefined;\n\n /**\n * Image sourceUrl for displaying.\n */\n url: string;\n\n /**\n * Image width.\n */\n width: number;\n\n /**\n * SortKey\n */\n sortKey: number;\n\n /**\n * Image expire date.\n */\n expiresAt: string;\n}\n\nexport default interface ComicViewerProps<T> extends ComponentProps <{\n /**\n * Data for render.\n */\n data: ComicViewerItemData<T>[];\n\n /**\n * Delay Time to call the error handler.\n * @default 500\n */\n errorDebounceMillis?: number;\n\n /**\n * How many times retry onError when same item error occur\n * @default 3\n */\n errorRetryCount?: number;\n\n /**\n * How many items to render in the initial batch.\n * @default 1\n */\n initialNumToRender?: number;\n\n /**\n * Start at initialScrollPercentage.\n * If over 100, scroll to end.\n * @default 0\n */\n initialScrollPercentage?: number;\n\n /**\n * The value for FlatList viewabilityConfig.itemVisiblePercentThreshold.\n * @default 0\n */\n itemVisiblePercentThreshold?: number;\n\n /**\n * Comic viewer width.\n */\n viewerWidth: number;\n\n /**\n * The value for FlatList windowSize.\n * @default 3\n */\n windowSize?: number;\n\n /**\n * How many images in one page.\n */\n pageUnit: number;\n\n /**\n * Method for getting next page contents.\n * @param sortKey\n */\n getNextPage?: (sortKey: number) => void;\n\n /**\n * Handling all viewerItem errors at once.\n * @param errors Array of ViewerItems errorInfo.\n */\n onError?: (errors: ErrorInfo[]) => void;\n\n /**\n * Handle scroll event.\n * @param event Scroll event.\n */\n onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;\n\n /**\n * Component for comic viewer footer.\n */\n ListFooterComponent?: React.ReactElement;\n}> {}"],"mappings":";;;;;;AAIO,MAAMA,KAAK,GAAG;EACjBC,MAAM,EAAE,QADS;EAEjBC,OAAO,EAAE,SAFQ;EAGjBC,MAAM,EAAE,QAHS;EAIjBC,IAAI,EAAE;AAJW,CAAd"}