@fountain-ui/lab 2.0.0-beta.11 → 2.0.0-beta.14

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 (289) hide show
  1. package/build/commonjs/Carousel/Carousel.js +142 -0
  2. package/build/commonjs/Carousel/Carousel.js.map +1 -0
  3. package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
  4. package/build/commonjs/Carousel/animation/animationUtils.js +9 -0
  5. package/build/commonjs/Carousel/animation/animationUtils.js.map +1 -0
  6. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js +15 -0
  7. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  8. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js +20 -0
  9. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  10. package/build/commonjs/Carousel/animation/index.js +40 -0
  11. package/build/commonjs/Carousel/animation/index.js.map +1 -0
  12. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js +27 -0
  13. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  14. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js +65 -0
  15. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  16. package/build/commonjs/Carousel/components/InternalContext.js +29 -0
  17. package/build/commonjs/Carousel/components/InternalContext.js.map +1 -0
  18. package/build/commonjs/Carousel/components/ItemView.js +66 -0
  19. package/build/commonjs/Carousel/components/ItemView.js.map +1 -0
  20. package/build/commonjs/Carousel/components/RootView.js +86 -0
  21. package/build/commonjs/Carousel/components/RootView.js.map +1 -0
  22. package/build/commonjs/Carousel/components/ScrollViewGesture.js +81 -0
  23. package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -0
  24. package/build/commonjs/Carousel/components/index.js +40 -0
  25. package/build/commonjs/Carousel/components/index.js.map +1 -0
  26. package/build/commonjs/Carousel/hooks/index.js +64 -0
  27. package/build/commonjs/Carousel/hooks/index.js.map +1 -0
  28. package/build/commonjs/Carousel/hooks/useAutoplayController.js +58 -0
  29. package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -0
  30. package/build/commonjs/Carousel/hooks/useDimensionChangeReaction.js +23 -0
  31. package/build/commonjs/Carousel/hooks/useDimensionChangeReaction.js.map +1 -0
  32. package/build/commonjs/Carousel/hooks/useIndexController.js +70 -0
  33. package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -0
  34. package/build/commonjs/Carousel/hooks/useItemInterpolation.js +63 -0
  35. package/build/commonjs/Carousel/hooks/useItemInterpolation.js.map +1 -0
  36. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js +95 -0
  37. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  38. package/build/commonjs/Carousel/hooks/useLoopedData.js +33 -0
  39. package/build/commonjs/Carousel/hooks/useLoopedData.js.map +1 -0
  40. package/build/commonjs/Carousel/hooks/usePagingAnimation.js +162 -0
  41. package/build/commonjs/Carousel/hooks/usePagingAnimation.js.map +1 -0
  42. package/build/commonjs/Carousel/index.js +16 -2
  43. package/build/commonjs/Carousel/index.js.map +1 -1
  44. package/build/commonjs/Carousel/types.js +7 -0
  45. package/build/commonjs/Carousel/types.js.map +1 -0
  46. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js +53 -59
  47. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +1 -1
  48. package/build/commonjs/ViewPager/InternalContext.js +17 -0
  49. package/build/commonjs/ViewPager/InternalContext.js.map +1 -0
  50. package/build/commonjs/ViewPager/PageStateContext.js +22 -0
  51. package/build/commonjs/ViewPager/PageStateContext.js.map +1 -0
  52. package/build/commonjs/ViewPager/ViewPagerNative.js +90 -25
  53. package/build/commonjs/ViewPager/ViewPagerNative.js.map +1 -1
  54. package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
  55. package/build/commonjs/ViewPager/ViewPagerWeb.js +27 -14
  56. package/build/commonjs/ViewPager/ViewPagerWeb.js.map +1 -1
  57. package/build/commonjs/ViewPager/index.js +8 -0
  58. package/build/commonjs/ViewPager/index.js.map +1 -1
  59. package/build/commonjs/ViewPager/index.native.js +8 -0
  60. package/build/commonjs/ViewPager/index.native.js.map +1 -1
  61. package/build/commonjs/ViewPager/types.js +6 -0
  62. package/build/commonjs/ViewPager/types.js.map +1 -0
  63. package/build/commonjs/ViewPager/usePageStore.js +30 -0
  64. package/build/commonjs/ViewPager/usePageStore.js.map +1 -0
  65. package/build/commonjs/ViewPager/utils.js +3 -1
  66. package/build/commonjs/ViewPager/utils.js.map +1 -1
  67. package/build/commonjs/ViewabilityTrackerView/Viewability.js +2 -0
  68. package/build/commonjs/ViewabilityTrackerView/Viewability.js.map +1 -0
  69. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js +45 -0
  70. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  71. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  72. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  73. package/build/commonjs/{Carousel/index.native.js → ViewabilityTrackerView/index.js} +3 -3
  74. package/build/commonjs/ViewabilityTrackerView/index.js.map +1 -0
  75. package/build/commonjs/ViewabilityTrackerView/measureViewability.js +42 -0
  76. package/build/commonjs/ViewabilityTrackerView/measureViewability.js.map +1 -0
  77. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js +88 -0
  78. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  79. package/build/commonjs/hooks/index.js +16 -0
  80. package/build/commonjs/hooks/index.js.map +1 -1
  81. package/build/commonjs/hooks/useDeferredExecutor.js +45 -0
  82. package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
  83. package/build/commonjs/hooks/useIsMounted.js +22 -0
  84. package/build/commonjs/hooks/useIsMounted.js.map +1 -0
  85. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +1 -1
  86. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  87. package/build/commonjs/index.js +22 -1
  88. package/build/commonjs/index.js.map +1 -1
  89. package/build/module/Carousel/Carousel.js +120 -0
  90. package/build/module/Carousel/Carousel.js.map +1 -0
  91. package/build/module/Carousel/CarouselProps.js.map +1 -1
  92. package/build/module/Carousel/animation/animationUtils.js +2 -0
  93. package/build/module/Carousel/animation/animationUtils.js.map +1 -0
  94. package/build/module/Carousel/animation/createDefaultItemStyle.js +3 -0
  95. package/build/module/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  96. package/build/module/Carousel/animation/createDefaultScrollAnimation.js +11 -0
  97. package/build/module/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  98. package/build/module/Carousel/animation/index.js +5 -0
  99. package/build/module/Carousel/animation/index.js.map +1 -0
  100. package/build/module/Carousel/animation/normalItemStyleFactory.js +18 -0
  101. package/build/module/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  102. package/build/module/Carousel/animation/parallaxItemStyleFactory.js +55 -0
  103. package/build/module/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  104. package/build/module/Carousel/components/InternalContext.js +19 -0
  105. package/build/module/Carousel/components/InternalContext.js.map +1 -0
  106. package/build/module/Carousel/components/ItemView.js +46 -0
  107. package/build/module/Carousel/components/ItemView.js.map +1 -0
  108. package/build/module/Carousel/components/RootView.js +65 -0
  109. package/build/module/Carousel/components/RootView.js.map +1 -0
  110. package/build/module/Carousel/components/ScrollViewGesture.js +67 -0
  111. package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -0
  112. package/build/module/Carousel/components/index.js +5 -0
  113. package/build/module/Carousel/components/index.js.map +1 -0
  114. package/build/module/Carousel/hooks/index.js +8 -0
  115. package/build/module/Carousel/hooks/index.js.map +1 -0
  116. package/build/module/Carousel/hooks/useAutoplayController.js +48 -0
  117. package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -0
  118. package/build/module/Carousel/hooks/useDimensionChangeReaction.js +14 -0
  119. package/build/module/Carousel/hooks/useDimensionChangeReaction.js.map +1 -0
  120. package/build/module/Carousel/hooks/useIndexController.js +54 -0
  121. package/build/module/Carousel/hooks/useIndexController.js.map +1 -0
  122. package/build/module/Carousel/hooks/useItemInterpolation.js +51 -0
  123. package/build/module/Carousel/hooks/useItemInterpolation.js.map +1 -0
  124. package/build/module/Carousel/hooks/useItemVisibilityStore.js +87 -0
  125. package/build/module/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  126. package/build/module/Carousel/hooks/useLoopedData.js +24 -0
  127. package/build/module/Carousel/hooks/useLoopedData.js.map +1 -0
  128. package/build/module/Carousel/hooks/usePagingAnimation.js +153 -0
  129. package/build/module/Carousel/hooks/usePagingAnimation.js.map +1 -0
  130. package/build/module/Carousel/index.js +2 -1
  131. package/build/module/Carousel/index.js.map +1 -1
  132. package/build/module/Carousel/types.js +3 -0
  133. package/build/module/Carousel/types.js.map +1 -0
  134. package/build/module/ViewPager/ChildrenMemoizedPage.js +48 -56
  135. package/build/module/ViewPager/ChildrenMemoizedPage.js.map +1 -1
  136. package/build/module/ViewPager/InternalContext.js +7 -0
  137. package/build/module/ViewPager/InternalContext.js.map +1 -0
  138. package/build/module/ViewPager/PageStateContext.js +10 -0
  139. package/build/module/ViewPager/PageStateContext.js.map +1 -0
  140. package/build/module/ViewPager/ViewPagerNative.js +90 -27
  141. package/build/module/ViewPager/ViewPagerNative.js.map +1 -1
  142. package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
  143. package/build/module/ViewPager/ViewPagerWeb.js +25 -15
  144. package/build/module/ViewPager/ViewPagerWeb.js.map +1 -1
  145. package/build/module/ViewPager/index.js +1 -0
  146. package/build/module/ViewPager/index.js.map +1 -1
  147. package/build/module/ViewPager/index.native.js +1 -0
  148. package/build/module/ViewPager/index.native.js.map +1 -1
  149. package/build/module/ViewPager/types.js +2 -0
  150. package/build/module/ViewPager/types.js.map +1 -0
  151. package/build/module/ViewPager/usePageStore.js +20 -0
  152. package/build/module/ViewPager/usePageStore.js.map +1 -0
  153. package/build/module/ViewPager/utils.js +1 -0
  154. package/build/module/ViewPager/utils.js.map +1 -1
  155. package/build/module/ViewabilityTrackerView/Viewability.js +2 -0
  156. package/build/module/ViewabilityTrackerView/Viewability.js.map +1 -0
  157. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js +28 -0
  158. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  159. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  160. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  161. package/build/module/ViewabilityTrackerView/index.js +2 -0
  162. package/build/module/ViewabilityTrackerView/index.js.map +1 -0
  163. package/build/module/ViewabilityTrackerView/measureViewability.js +34 -0
  164. package/build/module/ViewabilityTrackerView/measureViewability.js.map +1 -0
  165. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js +73 -0
  166. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  167. package/build/module/hooks/index.js +2 -0
  168. package/build/module/hooks/index.js.map +1 -1
  169. package/build/module/hooks/useDeferredExecutor.js +33 -0
  170. package/build/module/hooks/useDeferredExecutor.js.map +1 -0
  171. package/build/module/hooks/useIsMounted.js +13 -0
  172. package/build/module/hooks/useIsMounted.js.map +1 -0
  173. package/build/module/hooks/useUnstableCollapsibleAppBar.js +1 -1
  174. package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  175. package/build/module/index.js +2 -0
  176. package/build/module/index.js.map +1 -1
  177. package/build/typescript/Carousel/Carousel.d.ts +5 -0
  178. package/build/typescript/Carousel/CarouselProps.d.ts +33 -48
  179. package/build/typescript/Carousel/animation/animationUtils.d.ts +1 -0
  180. package/build/typescript/Carousel/animation/createDefaultItemStyle.d.ts +2 -0
  181. package/build/typescript/Carousel/animation/createDefaultScrollAnimation.d.ts +2 -0
  182. package/build/typescript/Carousel/animation/index.d.ts +4 -0
  183. package/build/typescript/Carousel/animation/normalItemStyleFactory.d.ts +2 -0
  184. package/build/typescript/Carousel/animation/parallaxItemStyleFactory.d.ts +9 -0
  185. package/build/typescript/Carousel/components/InternalContext.d.ts +14 -0
  186. package/build/typescript/Carousel/components/ItemView.d.ts +9 -0
  187. package/build/typescript/Carousel/components/RootView.d.ts +16 -0
  188. package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +12 -0
  189. package/build/typescript/Carousel/components/index.d.ts +4 -0
  190. package/build/typescript/Carousel/hooks/index.d.ts +7 -0
  191. package/build/typescript/Carousel/hooks/useAutoplayController.d.ts +7 -0
  192. package/build/typescript/Carousel/hooks/useDimensionChangeReaction.d.ts +7 -0
  193. package/build/typescript/Carousel/hooks/useIndexController.d.ts +10 -0
  194. package/build/typescript/Carousel/hooks/useItemInterpolation.d.ts +2 -0
  195. package/build/typescript/Carousel/hooks/useItemVisibilityStore.d.ts +7 -0
  196. package/build/typescript/Carousel/hooks/useLoopedData.d.ts +1 -0
  197. package/build/typescript/Carousel/hooks/usePagingAnimation.d.ts +18 -0
  198. package/build/typescript/Carousel/index.d.ts +3 -1
  199. package/build/typescript/Carousel/types.d.ts +79 -0
  200. package/build/typescript/ViewPager/ChildrenMemoizedPage.d.ts +1 -1
  201. package/build/typescript/ViewPager/InternalContext.d.ts +7 -0
  202. package/build/typescript/ViewPager/PageStateContext.d.ts +7 -0
  203. package/build/typescript/ViewPager/ViewPagerNative.d.ts +2 -2
  204. package/build/typescript/ViewPager/ViewPagerProps.d.ts +13 -20
  205. package/build/typescript/ViewPager/ViewPagerWeb.d.ts +2 -2
  206. package/build/typescript/ViewPager/index.d.ts +3 -1
  207. package/build/typescript/ViewPager/index.native.d.ts +1 -0
  208. package/build/typescript/ViewPager/types.d.ts +19 -0
  209. package/build/typescript/ViewPager/usePageStore.d.ts +2 -0
  210. package/build/typescript/ViewPager/utils.d.ts +2 -1
  211. package/build/typescript/ViewabilityTrackerView/Viewability.d.ts +3 -0
  212. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerView.d.ts +2 -0
  213. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerViewProps.d.ts +22 -0
  214. package/build/typescript/ViewabilityTrackerView/index.d.ts +2 -0
  215. package/build/typescript/ViewabilityTrackerView/measureViewability.d.ts +11 -0
  216. package/build/typescript/ViewabilityTrackerView/useViewabilityTracker.d.ts +11 -0
  217. package/build/typescript/hooks/index.d.ts +2 -0
  218. package/build/typescript/hooks/useDeferredExecutor.d.ts +11 -0
  219. package/build/typescript/hooks/useIsMounted.d.ts +4 -0
  220. package/build/typescript/index.d.ts +2 -0
  221. package/package.json +4 -19
  222. package/src/Carousel/Carousel.tsx +152 -0
  223. package/src/Carousel/CarouselProps.ts +35 -53
  224. package/src/Carousel/animation/animationUtils.ts +1 -0
  225. package/src/Carousel/animation/createDefaultItemStyle.ts +3 -0
  226. package/src/Carousel/animation/createDefaultScrollAnimation.ts +13 -0
  227. package/src/Carousel/animation/index.ts +4 -0
  228. package/src/Carousel/animation/normalItemStyleFactory.ts +19 -0
  229. package/src/Carousel/animation/parallaxItemStyleFactory.ts +79 -0
  230. package/src/Carousel/components/InternalContext.ts +33 -0
  231. package/src/Carousel/components/ItemView.tsx +66 -0
  232. package/src/Carousel/components/RootView.tsx +79 -0
  233. package/src/Carousel/components/ScrollViewGesture.tsx +87 -0
  234. package/src/Carousel/components/index.ts +4 -0
  235. package/src/Carousel/hooks/index.ts +7 -0
  236. package/src/Carousel/hooks/useAutoplayController.ts +57 -0
  237. package/src/Carousel/hooks/useDimensionChangeReaction.ts +25 -0
  238. package/src/Carousel/hooks/useIndexController.tsx +76 -0
  239. package/src/Carousel/hooks/useItemInterpolation.ts +107 -0
  240. package/src/Carousel/hooks/useItemVisibilityStore.ts +107 -0
  241. package/src/Carousel/hooks/useLoopedData.ts +26 -0
  242. package/src/Carousel/hooks/usePagingAnimation.ts +195 -0
  243. package/src/Carousel/index.ts +4 -2
  244. package/src/Carousel/types.ts +97 -0
  245. package/src/ViewPager/ChildrenMemoizedPage.tsx +55 -54
  246. package/src/ViewPager/InternalContext.ts +13 -0
  247. package/src/ViewPager/PageStateContext.ts +15 -0
  248. package/src/ViewPager/ViewPagerNative.tsx +114 -43
  249. package/src/ViewPager/ViewPagerProps.ts +15 -25
  250. package/src/ViewPager/ViewPagerWeb.tsx +30 -21
  251. package/src/ViewPager/index.native.ts +1 -0
  252. package/src/ViewPager/index.ts +3 -1
  253. package/src/ViewPager/types.ts +24 -0
  254. package/src/ViewPager/usePageStore.ts +24 -0
  255. package/src/ViewPager/utils.tsx +3 -2
  256. package/src/ViewabilityTrackerView/Viewability.ts +3 -0
  257. package/src/ViewabilityTrackerView/ViewabilityTrackerView.tsx +33 -0
  258. package/src/ViewabilityTrackerView/ViewabilityTrackerViewProps.ts +25 -0
  259. package/src/ViewabilityTrackerView/index.ts +2 -0
  260. package/src/ViewabilityTrackerView/measureViewability.ts +56 -0
  261. package/src/ViewabilityTrackerView/useViewabilityTracker.ts +85 -0
  262. package/src/hooks/index.ts +2 -0
  263. package/src/hooks/useDeferredExecutor.ts +46 -0
  264. package/src/hooks/useIsMounted.ts +19 -0
  265. package/src/hooks/useUnstableCollapsibleAppBar.ts +1 -1
  266. package/src/index.ts +3 -0
  267. package/build/commonjs/Carousel/CarouselNative.js +0 -72
  268. package/build/commonjs/Carousel/CarouselNative.js.map +0 -1
  269. package/build/commonjs/Carousel/CarouselWeb.js +0 -237
  270. package/build/commonjs/Carousel/CarouselWeb.js.map +0 -1
  271. package/build/commonjs/Carousel/index.native.js.map +0 -1
  272. package/build/commonjs/Carousel/utils.js +0 -19
  273. package/build/commonjs/Carousel/utils.js.map +0 -1
  274. package/build/module/Carousel/CarouselNative.js +0 -54
  275. package/build/module/Carousel/CarouselNative.js.map +0 -1
  276. package/build/module/Carousel/CarouselWeb.js +0 -215
  277. package/build/module/Carousel/CarouselWeb.js.map +0 -1
  278. package/build/module/Carousel/index.native.js +0 -2
  279. package/build/module/Carousel/index.native.js.map +0 -1
  280. package/build/module/Carousel/utils.js +0 -7
  281. package/build/module/Carousel/utils.js.map +0 -1
  282. package/build/typescript/Carousel/CarouselNative.d.ts +0 -2
  283. package/build/typescript/Carousel/CarouselWeb.d.ts +0 -4
  284. package/build/typescript/Carousel/index.native.d.ts +0 -1
  285. package/build/typescript/Carousel/utils.d.ts +0 -6
  286. package/src/Carousel/CarouselNative.tsx +0 -67
  287. package/src/Carousel/CarouselWeb.tsx +0 -222
  288. package/src/Carousel/index.native.ts +0 -1
  289. package/src/Carousel/utils.ts +0 -11
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _ViewabilityTrackerView = _interopRequireDefault(require("../ViewabilityTrackerView"));
13
+
14
+ var _hooks = require("./hooks");
15
+
16
+ var _animation = require("./animation");
17
+
18
+ var _components = require("./components");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ 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); }
23
+
24
+ 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; }
25
+
26
+ const Carousel = /*#__PURE__*/(0, _react.forwardRef)(function Carousel(props, ref) {
27
+ const {
28
+ autoplay = false,
29
+ autoplayInterval = 3000,
30
+ createItemStyle = _animation.createDefaultItemStyle,
31
+ createScrollAnimation = _animation.createDefaultScrollAnimation,
32
+ data: originalData,
33
+ disableSmartAutoplay = false,
34
+ initialIndex = 0,
35
+ itemHeight,
36
+ itemWidth,
37
+ loop = false,
38
+ onIndexChange,
39
+ renderItem,
40
+ scrollEnabled = true,
41
+ style,
42
+ windowSize = 5
43
+ } = props;
44
+ const data = (0, _hooks.useLoopedData)(originalData, loop);
45
+ const initialTx = itemWidth * initialIndex;
46
+ const controlledTx = (0, _react.useRef)(new _reactNative.Animated.Value(initialTx)).current;
47
+ const offsetTx = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
48
+ const {
49
+ currentIndex,
50
+ getCurrentIndex,
51
+ lastIndex,
52
+ monitorElement
53
+ } = (0, _hooks.useIndexController)({
54
+ controlledTx,
55
+ initialIndex,
56
+ itemWidth,
57
+ numberOfOriginalData: originalData.length,
58
+ onIndexChange
59
+ });
60
+ const itemVisibilityStore = (0, _hooks.useItemVisibilityStore)({
61
+ currentIndex,
62
+ numberOfData: data.length,
63
+ windowSize
64
+ });
65
+ const {
66
+ finalizeAnimation,
67
+ globalInterpolation,
68
+ startPagingAnimation
69
+ } = (0, _hooks.usePagingAnimation)({
70
+ controlledTx,
71
+ createScrollAnimation,
72
+ getCurrentIndex,
73
+ itemWidth,
74
+ lastIndex,
75
+ loop,
76
+ numberOfData: data.length,
77
+ offsetTx
78
+ });
79
+ const autoplayController = (0, _hooks.useAutoplayController)({
80
+ enabled: autoplay,
81
+ intervalMillis: autoplayInterval,
82
+ startPagingAnimation
83
+ });
84
+ (0, _hooks.useDimensionChangeReaction)({
85
+ controlledTx,
86
+ currentIndex,
87
+ itemWidth
88
+ });
89
+ (0, _react.useImperativeHandle)(ref, () => ({
90
+ getCurrentIndex,
91
+ next: () => startPagingAnimation('directional', {
92
+ direction: 'next'
93
+ }),
94
+ prev: () => startPagingAnimation('directional', {
95
+ direction: 'prev'
96
+ }),
97
+ scrollTo: option => startPagingAnimation('index', option)
98
+ }), [startPagingAnimation, getCurrentIndex]);
99
+ const contextValue = (0, _react.useMemo)(() => ({
100
+ createItemStyle,
101
+ data,
102
+ globalInterpolation,
103
+ itemHeight,
104
+ itemWidth,
105
+ itemVisibilityStore,
106
+ loop
107
+ }), [createItemStyle, data, globalInterpolation, itemHeight, itemWidth, itemVisibilityStore, loop]);
108
+ return /*#__PURE__*/_react.default.createElement(_components.InternalContext.Provider, {
109
+ value: contextValue
110
+ }, monitorElement, /*#__PURE__*/_react.default.createElement(_ViewabilityTrackerView.default, {
111
+ enabled: autoplay && !disableSmartAutoplay,
112
+ measurementIntervalMillis: Math.max(3000, autoplayInterval),
113
+ onViewabilityChange: _ref => {
114
+ let {
115
+ visible
116
+ } = _ref;
117
+
118
+ if (visible) {
119
+ autoplayController.resume();
120
+ } else {
121
+ autoplayController.pause();
122
+ }
123
+ }
124
+ }, /*#__PURE__*/_react.default.createElement(_components.ScrollViewGesture, {
125
+ autoplayController: autoplayController,
126
+ finalizeAnimation: finalizeAnimation,
127
+ offsetTx: offsetTx,
128
+ scrollEnabled: scrollEnabled,
129
+ startPagingAnimation: startPagingAnimation
130
+ }, /*#__PURE__*/_react.default.createElement(_components.RootView, {
131
+ data: data,
132
+ itemHeight: itemHeight,
133
+ originalData: originalData,
134
+ renderItem: renderItem,
135
+ style: style
136
+ }))));
137
+ });
138
+
139
+ var _default = /*#__PURE__*/(0, _react.memo)(Carousel);
140
+
141
+ exports.default = _default;
142
+ //# sourceMappingURL=Carousel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Carousel","forwardRef","props","ref","autoplay","autoplayInterval","createItemStyle","createDefaultItemStyle","createScrollAnimation","createDefaultScrollAnimation","data","originalData","disableSmartAutoplay","initialIndex","itemHeight","itemWidth","loop","onIndexChange","renderItem","scrollEnabled","style","windowSize","useLoopedData","initialTx","controlledTx","useRef","Animated","Value","current","offsetTx","currentIndex","getCurrentIndex","lastIndex","monitorElement","useIndexController","numberOfOriginalData","length","itemVisibilityStore","useItemVisibilityStore","numberOfData","finalizeAnimation","globalInterpolation","startPagingAnimation","usePagingAnimation","autoplayController","useAutoplayController","enabled","intervalMillis","useDimensionChangeReaction","useImperativeHandle","next","direction","prev","scrollTo","option","contextValue","useMemo","Math","max","visible","resume","pause","memo"],"sources":["Carousel.tsx"],"sourcesContent":["import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport ViewabilityTrackerView from '../ViewabilityTrackerView';\nimport type CarouselProps from './CarouselProps';\nimport type { CarouselInstance } from './types';\nimport {\n useAutoplayController,\n useDimensionChangeReaction,\n useIndexController,\n useItemVisibilityStore,\n useLoopedData,\n usePagingAnimation,\n} from './hooks';\nimport { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';\nimport { InternalContext, RootView, ScrollViewGesture } from './components';\n\nconst Carousel = forwardRef<CarouselInstance, CarouselProps>(function Carousel(props, ref) {\n const {\n autoplay = false,\n autoplayInterval = 3000,\n createItemStyle = createDefaultItemStyle,\n createScrollAnimation = createDefaultScrollAnimation,\n data: originalData,\n disableSmartAutoplay = false,\n initialIndex = 0,\n itemHeight,\n itemWidth,\n loop = false,\n onIndexChange,\n renderItem,\n scrollEnabled = true,\n style,\n windowSize = 5,\n } = props;\n\n const data = useLoopedData(originalData, loop);\n\n const initialTx = itemWidth * initialIndex;\n const controlledTx = useRef(new Animated.Value(initialTx)).current;\n const offsetTx = useRef(new Animated.Value(0)).current;\n\n const {\n currentIndex,\n getCurrentIndex,\n lastIndex,\n monitorElement,\n } = useIndexController({\n controlledTx,\n initialIndex,\n itemWidth,\n numberOfOriginalData: originalData.length,\n onIndexChange,\n });\n\n const itemVisibilityStore = useItemVisibilityStore({\n currentIndex,\n numberOfData: data.length,\n windowSize,\n });\n\n const {\n finalizeAnimation,\n globalInterpolation,\n startPagingAnimation,\n } = usePagingAnimation({\n controlledTx,\n createScrollAnimation,\n getCurrentIndex,\n itemWidth,\n lastIndex,\n loop,\n numberOfData: data.length,\n offsetTx,\n });\n\n const autoplayController = useAutoplayController({\n enabled: autoplay,\n intervalMillis: autoplayInterval,\n startPagingAnimation,\n });\n\n useDimensionChangeReaction({\n controlledTx,\n currentIndex,\n itemWidth,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n getCurrentIndex,\n next: () => startPagingAnimation('directional', { direction: 'next' }),\n prev: () => startPagingAnimation('directional', { direction: 'prev' }),\n scrollTo: (option) => startPagingAnimation('index', option),\n }),\n [startPagingAnimation, getCurrentIndex],\n );\n\n const contextValue = useMemo(() => ({\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n }), [\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n ]);\n\n return (\n <InternalContext.Provider value={contextValue}>\n {monitorElement}\n\n <ViewabilityTrackerView\n enabled={autoplay && !disableSmartAutoplay}\n measurementIntervalMillis={Math.max(3000, autoplayInterval)}\n onViewabilityChange={({ visible }) => {\n if (visible) {\n autoplayController.resume();\n } else {\n autoplayController.pause();\n }\n }}\n >\n <ScrollViewGesture\n autoplayController={autoplayController}\n finalizeAnimation={finalizeAnimation}\n offsetTx={offsetTx}\n scrollEnabled={scrollEnabled}\n startPagingAnimation={startPagingAnimation}\n >\n <RootView\n data={data}\n itemHeight={itemHeight}\n originalData={originalData}\n renderItem={renderItem}\n style={style}\n />\n </ScrollViewGesture>\n </ViewabilityTrackerView>\n </InternalContext.Provider>\n );\n});\n\nexport default memo(Carousel);\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAGA;;AAQA;;AACA;;;;;;;;AAEA,MAAMA,QAAQ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,CAAS,IAAT,EAAerD,gBAAf,CAF/B;IAGI,mBAAmB,EAAE,QAAiB;MAAA,IAAhB;QAAEsD;MAAF,CAAgB;;MAClC,IAAIA,OAAJ,EAAa;QACTf,kBAAkB,CAACgB,MAAnB;MACH,CAFD,MAEO;QACHhB,kBAAkB,CAACiB,KAAnB;MACH;IACJ;EATL,gBAWI,6BAAC,6BAAD;IACI,kBAAkB,EAAEjB,kBADxB;IAEI,iBAAiB,EAAEJ,iBAFvB;IAGI,QAAQ,EAAEX,QAHd;IAII,aAAa,EAAEV,aAJnB;IAKI,oBAAoB,EAAEuB;EAL1B,gBAOI,6BAAC,oBAAD;IACI,IAAI,EAAEhC,IADV;IAEI,UAAU,EAAEI,UAFhB;IAGI,YAAY,EAAEH,YAHlB;IAII,UAAU,EAAEO,UAJhB;IAKI,KAAK,EAAEE;EALX,EAPJ,CAXJ,CAHJ,CADJ;AAiCH,CArIgB,CAAjB;;4BAuIe,IAAA0C,WAAA,EAAK9D,QAAL,C"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import React, { RefObject } from 'react';\nimport type { ListRenderItemInfo } from 'react-native';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * Padding for center slide. If specified, `slidesToScroll` and `slidesToShow` set to 1.\n */\n centerSlidePadding?: number;\n\n /**\n * Delay in ms until navigating to the next item.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * Value of the opacity effect applied to inactive slides.\n * @default 0.7\n */\n inactiveSlideOpacity?: number;\n\n /**\n * Value of the 'scale' transform applied to inactive slides.\n * @default 0.9\n */\n inactiveSlideScale?: number;\n\n /**\n * Web only. Value of the 'scale' transform applied to a active slide.\n * @default 0.990\n */\n activeSlideScale?: number;\n\n /**\n * A number representing the index of the active slide.\n */\n index: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n infinite?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: (info: Omit<ListRenderItemInfo<ItemT>, 'separators'>) => React.ReactElement | null;\n\n /**\n * Web only. Number of slides to scroll at once.\n * @default 1\n */\n slidesToScroll?: number;\n\n /**\n * Web only. Number of slides to display.\n * @default 1\n */\n slidesToShow?: number;\n\n /**\n * Web only. Enable items to display at the center.\n * @default true\n */\n centerMode?: boolean;\n\n /**\n * Web only. Enable arrows to display.\n * @default true\n */\n arrows?: boolean;\n\n /**\n * Web only. Style of arrows\n * @default true\n */\n arrowsStyle?: object;\n\n /**\n * Web only. Style of track\n * @default object\n */\n trackStyle?: object;\n\n /**\n * Only web. Refer slick object\n */\n ref?: RefObject<any>;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\nimport type { CarouselInstance, CreateItemStyle, CreateScrollAnimation, ItemHeight, RenderItem } from './types';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n ref?: RefObject<CarouselInstance>;\n\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * The item style creator function.\n * @default createDefaultItemStyle\n */\n createItemStyle?: CreateItemStyle;\n\n /**\n * The scroll animation creator function.\n * @default createDefaultScrollAnimation\n */\n createScrollAnimation?: CreateScrollAnimation;\n\n /**\n * Data for render items.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * If `true`, carousel will detect its own viewability and control autoplay automatically.\n * @default false\n */\n disableSmartAutoplay?: boolean;\n\n /**\n * Index of initial item that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * The item height.\n * For a performance reason, always consider to provide a number value.\n */\n itemHeight: ItemHeight;\n\n /**\n * The item width.\n */\n itemWidth: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n loop?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onIndexChange?: (newIndex: number) => void;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: RenderItem<ItemT>;\n\n /**\n * Whether to enable scroll gesture.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * The maximum number of items that can respond to pan gesture events.\n * Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)\n * 0 means all items will respond to pan gesture events.\n * @default 5\n */\n windowSize?: number;\n}> {}\n"],"mappings":""}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.itemInterpolationInputRange = void 0;
7
+ const itemInterpolationInputRange = [-1, 0, 1];
8
+ exports.itemInterpolationInputRange = itemInterpolationInputRange;
9
+ //# sourceMappingURL=animationUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["itemInterpolationInputRange"],"sources":["animationUtils.ts"],"sourcesContent":["export const itemInterpolationInputRange = [-1, 0, 1];\n"],"mappings":";;;;;;AAAO,MAAMA,2BAA2B,GAAG,CAAC,CAAC,CAAF,EAAK,CAAL,EAAQ,CAAR,CAApC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _normalItemStyleFactory = _interopRequireDefault(require("./normalItemStyleFactory"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ var _default = (0, _normalItemStyleFactory.default)();
13
+
14
+ exports.default = _default;
15
+ //# sourceMappingURL=createDefaultItemStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalItemStyleFactory"],"sources":["createDefaultItemStyle.ts"],"sourcesContent":["import normalItemStyleFactory from './normalItemStyleFactory';\n\nexport default normalItemStyleFactory();\n"],"mappings":";;;;;;;AAAA;;;;eAEe,IAAAA,+BAAA,G"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = createDefaultScrollAnimation;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ function createDefaultScrollAnimation(animatedValue, toValue) {
11
+ return _reactNative.Animated.timing(animatedValue, {
12
+ toValue: toValue,
13
+ duration: 350,
14
+ easing: _reactNative.Easing.bezier(0.25, 1, 0.5, 1),
15
+ useNativeDriver: true
16
+ });
17
+ }
18
+
19
+ ;
20
+ //# sourceMappingURL=createDefaultScrollAnimation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createDefaultScrollAnimation","animatedValue","toValue","Animated","timing","duration","easing","Easing","bezier","useNativeDriver"],"sources":["createDefaultScrollAnimation.ts"],"sourcesContent":["import { Animated, Easing } from 'react-native';\n\nexport default function createDefaultScrollAnimation(\n animatedValue: Animated.Value,\n toValue: number,\n): Animated.CompositeAnimation {\n return Animated.timing(animatedValue, {\n toValue: toValue,\n duration: 350,\n easing: Easing.bezier(0.25, 1, 0.5, 1),\n useNativeDriver: true,\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAEe,SAASA,4BAAT,CACXC,aADW,EAEXC,OAFW,EAGgB;EAC3B,OAAOC,qBAAA,CAASC,MAAT,CAAgBH,aAAhB,EAA+B;IAClCC,OAAO,EAAEA,OADyB;IAElCG,QAAQ,EAAE,GAFwB;IAGlCC,MAAM,EAAEC,mBAAA,CAAOC,MAAP,CAAc,IAAd,EAAoB,CAApB,EAAuB,GAAvB,EAA4B,CAA5B,CAH0B;IAIlCC,eAAe,EAAE;EAJiB,CAA/B,CAAP;AAMH;;AAAA"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "createDefaultItemStyle", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _createDefaultItemStyle.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "createDefaultScrollAnimation", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _createDefaultScrollAnimation.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "normalItemStyleFactory", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _normalItemStyleFactory.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "parallaxItemStyleFactory", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _parallaxItemStyleFactory.default;
28
+ }
29
+ });
30
+
31
+ var _createDefaultItemStyle = _interopRequireDefault(require("./createDefaultItemStyle"));
32
+
33
+ var _createDefaultScrollAnimation = _interopRequireDefault(require("./createDefaultScrollAnimation"));
34
+
35
+ var _normalItemStyleFactory = _interopRequireDefault(require("./normalItemStyleFactory"));
36
+
37
+ var _parallaxItemStyleFactory = _interopRequireDefault(require("./parallaxItemStyleFactory"));
38
+
39
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as createDefaultItemStyle } from './createDefaultItemStyle';\nexport { default as createDefaultScrollAnimation } from './createDefaultScrollAnimation';\nexport { default as normalItemStyleFactory } from './normalItemStyleFactory';\nexport { default as parallaxItemStyleFactory } from './parallaxItemStyleFactory';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = normalItemStyleFactory;
7
+
8
+ var _animationUtils = require("./animationUtils");
9
+
10
+ function normalItemStyleFactory() {
11
+ const createItemStyle = (itemInterpolation, itemWidth) => {
12
+ const translate = itemInterpolation.interpolate({
13
+ inputRange: _animationUtils.itemInterpolationInputRange,
14
+ outputRange: [-itemWidth, 0, itemWidth]
15
+ });
16
+ return {
17
+ transform: [{
18
+ translateX: translate
19
+ }]
20
+ };
21
+ };
22
+
23
+ return createItemStyle;
24
+ }
25
+
26
+ ;
27
+ //# sourceMappingURL=normalItemStyleFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalItemStyleFactory","createItemStyle","itemInterpolation","itemWidth","translate","interpolate","inputRange","itemInterpolationInputRange","outputRange","transform","translateX"],"sources":["normalItemStyleFactory.ts"],"sourcesContent":["import type { CreateItemStyle } from '../types';\nimport { itemInterpolationInputRange } from './animationUtils';\n\nexport default function normalItemStyleFactory() {\n const createItemStyle: CreateItemStyle = (itemInterpolation, itemWidth) => {\n const translate = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n -itemWidth,\n 0,\n itemWidth,\n ],\n });\n\n return { transform: [{ translateX: translate }] };\n };\n\n return createItemStyle;\n};\n"],"mappings":";;;;;;;AACA;;AAEe,SAASA,sBAAT,GAAkC;EAC7C,MAAMC,eAAgC,GAAG,CAACC,iBAAD,EAAoBC,SAApB,KAAkC;IACvE,MAAMC,SAAS,GAAGF,iBAAiB,CAACG,WAAlB,CAA8B;MAC5CC,UAAU,EAAEC,2CADgC;MAE5CC,WAAW,EAAE,CACT,CAACL,SADQ,EAET,CAFS,EAGTA,SAHS;IAF+B,CAA9B,CAAlB;IASA,OAAO;MAAEM,SAAS,EAAE,CAAC;QAAEC,UAAU,EAAEN;MAAd,CAAD;IAAb,CAAP;EACH,CAXD;;EAaA,OAAOH,eAAP;AACH;;AAAA"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = parallaxItemStyleFactory;
7
+
8
+ var _animationUtils = require("./animationUtils");
9
+
10
+ const defaultParallaxAnimationConfig = {
11
+ activeItemScale: 0.9,
12
+ activeItemOpacity: 1,
13
+ adjacentItemScale: Math.pow(0.9, 2),
14
+ adjacentItemOpacity: 0.5,
15
+ scrollingOffset: 50
16
+ };
17
+
18
+ function parallaxItemStyleFactory() {
19
+ let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultParallaxAnimationConfig;
20
+ const {
21
+ activeItemOpacity,
22
+ activeItemScale,
23
+ adjacentItemOpacity,
24
+ adjacentItemScale,
25
+ scrollingOffset
26
+ } = { ...config,
27
+ ...defaultParallaxAnimationConfig
28
+ };
29
+
30
+ const createItemStyle = (itemInterpolation, itemWidth) => {
31
+ const translate = itemInterpolation.interpolate({
32
+ inputRange: _animationUtils.itemInterpolationInputRange,
33
+ outputRange: [-itemWidth + scrollingOffset, 0, itemWidth - scrollingOffset]
34
+ });
35
+ const zIndex = itemInterpolation.interpolate({
36
+ inputRange: _animationUtils.itemInterpolationInputRange,
37
+ outputRange: [0, itemWidth, 0],
38
+ extrapolate: 'clamp'
39
+ });
40
+ const scale = itemInterpolation.interpolate({
41
+ inputRange: _animationUtils.itemInterpolationInputRange,
42
+ outputRange: [adjacentItemScale, activeItemScale, adjacentItemScale],
43
+ extrapolate: 'clamp'
44
+ });
45
+ const opacity = itemInterpolation.interpolate({
46
+ inputRange: _animationUtils.itemInterpolationInputRange,
47
+ outputRange: [adjacentItemOpacity, activeItemOpacity, adjacentItemOpacity],
48
+ extrapolate: 'clamp'
49
+ });
50
+ return {
51
+ transform: [{
52
+ translateX: translate
53
+ }, {
54
+ scale
55
+ }],
56
+ zIndex,
57
+ opacity
58
+ };
59
+ };
60
+
61
+ return createItemStyle;
62
+ }
63
+
64
+ ;
65
+ //# sourceMappingURL=parallaxItemStyleFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["defaultParallaxAnimationConfig","activeItemScale","activeItemOpacity","adjacentItemScale","Math","pow","adjacentItemOpacity","scrollingOffset","parallaxItemStyleFactory","config","createItemStyle","itemInterpolation","itemWidth","translate","interpolate","inputRange","itemInterpolationInputRange","outputRange","zIndex","extrapolate","scale","opacity","transform","translateX"],"sources":["parallaxItemStyleFactory.ts"],"sourcesContent":["import type { CreateItemStyle } from '../types';\nimport { itemInterpolationInputRange } from './animationUtils';\n\nexport interface ParallaxAnimationConfig {\n activeItemScale?: number;\n activeItemOpacity?: number;\n adjacentItemScale?: number;\n adjacentItemOpacity?: number;\n scrollingOffset?: number;\n}\n\nconst defaultParallaxAnimationConfig: Required<Readonly<ParallaxAnimationConfig>> = {\n activeItemScale: 0.9,\n activeItemOpacity: 1,\n adjacentItemScale: Math.pow(0.9, 2),\n adjacentItemOpacity: 0.5,\n scrollingOffset: 50,\n};\n\nexport default function parallaxItemStyleFactory(config: ParallaxAnimationConfig = defaultParallaxAnimationConfig) {\n const {\n activeItemOpacity,\n activeItemScale,\n adjacentItemOpacity,\n adjacentItemScale,\n scrollingOffset,\n }: Required<ParallaxAnimationConfig> = {\n ...config,\n ...defaultParallaxAnimationConfig,\n };\n\n const createItemStyle: CreateItemStyle = (itemInterpolation, itemWidth) => {\n const translate = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n -itemWidth + scrollingOffset,\n 0,\n itemWidth - scrollingOffset,\n ],\n });\n\n const zIndex = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [0, itemWidth, 0],\n extrapolate: 'clamp',\n });\n\n const scale = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n adjacentItemScale,\n activeItemScale,\n adjacentItemScale,\n ],\n extrapolate: 'clamp',\n });\n\n const opacity = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n adjacentItemOpacity,\n activeItemOpacity,\n adjacentItemOpacity,\n ],\n extrapolate: 'clamp',\n });\n\n return {\n transform: [\n { translateX: translate },\n { scale },\n ],\n zIndex,\n opacity,\n };\n };\n\n return createItemStyle;\n};\n"],"mappings":";;;;;;;AACA;;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AE;IAP6B,CAA9B,CAAhB;IAUA,OAAO;MACHG,SAAS,EAAE,CACP;QAAEC,UAAU,EAAEV;MAAd,CADO,EAEP;QAAEO;MAAF,CAFO,CADR;MAKHF,MALG;MAMHG;IANG,CAAP;EAQH,CA5CD;;EA8CA,OAAOX,eAAP;AACH;;AAAA"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ const mockItemVisibilityStore = {
13
+ dispatch: () => void 0,
14
+ subscribe: () => () => void 0,
15
+ removeAllListeners: () => void 0
16
+ };
17
+ const initialValue = {
18
+ createItemStyle: () => ({}),
19
+ data: [],
20
+ globalInterpolation: _reactNative.Animated.add(new _reactNative.Animated.Value(0), 0),
21
+ itemHeight: 0,
22
+ itemWidth: 0,
23
+ itemVisibilityStore: mockItemVisibilityStore,
24
+ loop: false
25
+ };
26
+ const InternalContext = /*#__PURE__*/(0, _react.createContext)(initialValue);
27
+ var _default = InternalContext;
28
+ exports.default = _default;
29
+ //# sourceMappingURL=InternalContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["mockItemVisibilityStore","dispatch","subscribe","removeAllListeners","initialValue","createItemStyle","data","globalInterpolation","Animated","add","Value","itemHeight","itemWidth","itemVisibilityStore","loop","InternalContext","createContext"],"sources":["InternalContext.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\nimport type { CreateItemStyle, ItemHeight, ItemVisibilityStore } from '../types';\n\nexport interface InternalContextValue<ItemT> {\n createItemStyle: CreateItemStyle;\n data: ReadonlyArray<ItemT>;\n globalInterpolation: Animated.AnimatedInterpolation;\n itemHeight: ItemHeight;\n itemWidth: number;\n itemVisibilityStore: ItemVisibilityStore;\n loop: boolean;\n}\n\nconst mockItemVisibilityStore: ItemVisibilityStore = {\n dispatch: () => void 0,\n subscribe: () => () => void 0,\n removeAllListeners: () => void 0,\n};\n\nconst initialValue: Readonly<InternalContextValue<any>> = {\n createItemStyle: () => ({}),\n data: [],\n globalInterpolation: Animated.add(new Animated.Value(0), 0),\n itemHeight: 0,\n itemWidth: 0,\n itemVisibilityStore: mockItemVisibilityStore,\n loop: false,\n};\n\nconst InternalContext = createContext<InternalContextValue<any>>(initialValue);\n\nexport default InternalContext;\n"],"mappings":";;;;;;;AAAA;;AACA;;AAaA,MAAMA,uBAA4C,GAAG;EACjDC,QAAQ,EAAE,MAAM,KAAK,CAD4B;EAEjDC,SAAS,EAAE,MAAM,MAAM,KAAK,CAFqB;EAGjDC,kBAAkB,EAAE,MAAM,KAAK;AAHkB,CAArD;AAMA,MAAMC,YAAiD,GAAG;EACtDC,eAAe,EAAE,OAAO,EAAP,CADqC;EAEtDC,IAAI,EAAE,EAFgD;EAGtDC,mBAAmB,EAAEC,qBAAA,CAASC,GAAT,CAAa,IAAID,qBAAA,CAASE,KAAb,CAAmB,CAAnB,CAAb,EAAoC,CAApC,CAHiC;EAItDC,UAAU,EAAE,CAJ0C;EAKtDC,SAAS,EAAE,CAL2C;EAMtDC,mBAAmB,EAAEb,uBANiC;EAOtDc,IAAI,EAAE;AAPgD,CAA1D;AAUA,MAAMC,eAAe,gBAAG,IAAAC,oBAAA,EAAyCZ,YAAzC,CAAxB;eAEeW,e"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = ItemView;
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 _hooks = require("../hooks");
15
+
16
+ var _InternalContext = _interopRequireDefault(require("./InternalContext"));
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ function ItemView(props) {
25
+ const {
26
+ children,
27
+ index,
28
+ onLayout
29
+ } = props;
30
+ const {
31
+ createItemStyle,
32
+ itemHeight,
33
+ itemWidth,
34
+ itemVisibilityStore
35
+ } = (0, _react.useContext)(_InternalContext.default);
36
+ const [visible, setVisible] = (0, _react.useState)(false);
37
+ const interpolation = (0, _hooks.useItemInterpolation)(index);
38
+ const itemStyle = (0, _react.useMemo)(() => createItemStyle(interpolation, itemWidth), [createItemStyle, interpolation]);
39
+ (0, _react.useEffect)(() => {
40
+ return itemVisibilityStore.subscribe(ranges => {
41
+ const nextVisible = ranges.some(_ref => {
42
+ let [from, to] = _ref;
43
+ return index >= from && index <= to;
44
+ });
45
+ setVisible(nextVisible);
46
+ });
47
+ }, [itemVisibilityStore]);
48
+ return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
49
+ children: visible ? children(interpolation) : null,
50
+ onLayout: onLayout,
51
+ style: [{
52
+ width: itemWidth,
53
+ height: itemHeight !== 'auto' ? itemHeight : undefined
54
+ }, styles.absolute, // @ts-ignore
55
+ itemStyle]
56
+ });
57
+ }
58
+
59
+ ;
60
+
61
+ const styles = _core.StyleSheet.create({
62
+ absolute: {
63
+ position: 'absolute'
64
+ }
65
+ });
66
+ //# sourceMappingURL=ItemView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ItemView","props","children","index","onLayout","createItemStyle","itemHeight","itemWidth","itemVisibilityStore","useContext","InternalContext","visible","setVisible","useState","interpolation","useItemInterpolation","itemStyle","useMemo","useEffect","subscribe","ranges","nextVisible","some","from","to","width","height","undefined","styles","absolute","StyleSheet","create","position"],"sources":["ItemView.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport { useItemInterpolation } from '../hooks';\nimport InternalContext from './InternalContext';\n\nexport interface ItemViewProps {\n children: (interpolation: Animated.AnimatedInterpolation) => ReactElement | null;\n index: number;\n onLayout?: ViewProps['onLayout'];\n}\n\nexport default function ItemView(props: ItemViewProps) {\n const {\n children,\n index,\n onLayout,\n } = props;\n\n const {\n createItemStyle,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n } = useContext(InternalContext);\n\n const [visible, setVisible] = useState(false);\n\n const interpolation = useItemInterpolation(index);\n\n const itemStyle = useMemo(\n () => createItemStyle(interpolation, itemWidth),\n [createItemStyle, interpolation],\n );\n\n useEffect(() => {\n return itemVisibilityStore.subscribe(ranges => {\n const nextVisible = ranges.some(([from, to]) => index >= from && index <= to);\n setVisible(nextVisible);\n });\n }, [itemVisibilityStore]);\n\n return (\n <Animated.View\n children={visible ? children(interpolation) : null}\n onLayout={onLayout}\n style={[\n {\n width: itemWidth,\n height: itemHeight !== 'auto' ? itemHeight : undefined,\n },\n styles.absolute,\n // @ts-ignore\n itemStyle,\n ]}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: 'absolute',\n },\n});\n"],"mappings":";;;;;;;AACA;;AAEA;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,MAAX,CAAkB;EAC7BF,QAAQ,EAAE;IACNG,QAAQ,EAAE;EADJ;AADmB,CAAlB,CAAf"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _core = require("@fountain-ui/core");
13
+
14
+ var _ItemView = _interopRequireDefault(require("./ItemView"));
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 styles = _core.StyleSheet.create({
25
+ root: {
26
+ width: '100%',
27
+ justifyContent: 'center'
28
+ },
29
+ horizontal: {
30
+ flexDirection: 'row',
31
+ overflowX: 'hidden',
32
+ overflowY: 'visible'
33
+ }
34
+ });
35
+
36
+ const RootView = /*#__PURE__*/(0, _react.forwardRef)(function RootView(props, ref) {
37
+ const {
38
+ data,
39
+ itemHeight,
40
+ originalData,
41
+ renderItem,
42
+ style,
43
+ ...otherProps
44
+ } = props;
45
+ const [maxHeightOfRenderedItems, setMaxHeightOfRenderedItems] = (0, _react.useState)(0);
46
+
47
+ const handleItemLayout = e => {
48
+ const {
49
+ nativeEvent: {
50
+ layout: {
51
+ height
52
+ }
53
+ }
54
+ } = e;
55
+ const heightInt = Math.round(height);
56
+
57
+ if (heightInt > maxHeightOfRenderedItems) {
58
+ setMaxHeightOfRenderedItems(heightInt);
59
+ }
60
+ };
61
+
62
+ const renderItemView = (item, index) => /*#__PURE__*/_react.default.createElement(_ItemView.default, {
63
+ key: index,
64
+ index: index,
65
+ onLayout: itemHeight === 'auto' ? handleItemLayout : undefined
66
+ }, interpolation => renderItem({
67
+ item,
68
+ index: index % originalData.length,
69
+ interpolation
70
+ }));
71
+
72
+ const viewStyles = [styles.root, styles.horizontal, {
73
+ height: itemHeight === 'auto' ? maxHeightOfRenderedItems : itemHeight
74
+ }, style];
75
+ return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, _extends({
76
+ ref: ref
77
+ }, otherProps, {
78
+ children: data.map(renderItemView),
79
+ style: viewStyles
80
+ }));
81
+ });
82
+
83
+ var _default = /*#__PURE__*/(0, _react.memo)(RootView);
84
+
85
+ exports.default = _default;
86
+ //# sourceMappingURL=RootView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["styles","StyleSheet","create","root","width","justifyContent","horizontal","flexDirection","overflowX","overflowY","RootView","forwardRef","props","ref","data","itemHeight","originalData","renderItem","style","otherProps","maxHeightOfRenderedItems","setMaxHeightOfRenderedItems","useState","handleItemLayout","e","nativeEvent","layout","height","heightInt","Math","round","renderItemView","item","index","undefined","interpolation","length","viewStyles","map","memo"],"sources":["RootView.tsx"],"sourcesContent":["import React, { forwardRef, memo, ReactElement, useState } from 'react';\nimport type { View, ViewProps, LayoutChangeEvent } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type { ItemHeight, RenderItem } from '../types';\nimport ItemView from './ItemView';\n\nconst styles = StyleSheet.create({\n root: {\n width: '100%',\n justifyContent: 'center',\n },\n horizontal: {\n flexDirection: 'row',\n overflowX: 'hidden',\n overflowY: 'visible',\n },\n});\n\nexport type RootViewProps<ItemT> = ViewProps & {\n data: ReadonlyArray<ItemT>;\n itemHeight: ItemHeight;\n originalData: ReadonlyArray<ItemT>;\n renderItem: RenderItem<ItemT>;\n};\n\nconst RootView = forwardRef<View, RootViewProps<any>>(function RootView(props, ref) {\n const {\n data,\n itemHeight,\n originalData,\n renderItem,\n style,\n ...otherProps\n } = props;\n\n const [maxHeightOfRenderedItems, setMaxHeightOfRenderedItems] = useState(0);\n\n const handleItemLayout = (e: LayoutChangeEvent) => {\n const { nativeEvent: { layout: { height } } } = e;\n\n const heightInt = Math.round(height);\n if (heightInt > maxHeightOfRenderedItems) {\n setMaxHeightOfRenderedItems(heightInt);\n }\n };\n\n const renderItemView = (item: any, index: number): ReactElement => (\n <ItemView\n key={index}\n index={index}\n onLayout={itemHeight === 'auto' ? handleItemLayout : undefined}\n >\n {(interpolation) => renderItem({\n item,\n index: index % originalData.length,\n interpolation,\n })}\n </ItemView>\n );\n\n const viewStyles = [\n styles.root,\n styles.horizontal,\n { height: itemHeight === 'auto' ? maxHeightOfRenderedItems : itemHeight },\n style,\n ];\n\n return (\n <Animated.View\n ref={ref}\n {...otherProps}\n children={data.map(renderItemView)}\n style={viewStyles}\n />\n );\n});\n\nexport default memo(RootView);\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEA;;;;;;;;;;AAEA,MAAMA,MAAM,GAAGC,gBAAA,CAAWC,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACFC,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