@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
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","useEffect","useRef","useState","Dimensions","View","RNSnapCarousel","defaultAutoplay","defaultAutoplayInterval","defaultInactiveSlideOpacity","defaultInactiveSlideScale","defaultInfinite","Carousel","props","autoplay","autoplayInterval","centerSlidePadding","data","inactiveSlideOpacity","inactiveSlideScale","index","infinite","onChange","renderItem","carouselRef","sliderWidth","setSliderWidth","get","width","itemWidth","undefined","carousel","current","currentIndex","snapToItem","handleSnapToItem","newIndex","event","nativeEvent","layout"],"sources":["CarouselNative.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport RNSnapCarousel from 'react-native-snap-carousel';\nimport type CarouselProps from './CarouselProps';\nimport {\n defaultAutoplay,\n defaultAutoplayInterval,\n defaultInactiveSlideOpacity,\n defaultInactiveSlideScale,\n defaultInfinite,\n} from './utils';\n\nexport default function Carousel<ItemT>(props: CarouselProps<ItemT>) {\n const {\n autoplay = defaultAutoplay,\n autoplayInterval = defaultAutoplayInterval,\n centerSlidePadding,\n data,\n inactiveSlideOpacity = defaultInactiveSlideOpacity,\n inactiveSlideScale = defaultInactiveSlideScale,\n index,\n infinite = defaultInfinite,\n onChange,\n renderItem,\n } = props;\n\n const carouselRef = useRef<RNSnapCarousel<ItemT> | null>(null);\n\n const [sliderWidth, setSliderWidth] = useState(() => Dimensions.get('window').width);\n\n const itemWidth = centerSlidePadding !== undefined\n ? sliderWidth - (centerSlidePadding * 2)\n : sliderWidth;\n\n useEffect(() => {\n const carousel = carouselRef.current;\n if (carousel && index !== carousel.currentIndex) {\n carousel.snapToItem(index, true);\n }\n }, [index]);\n\n const handleSnapToItem = (newIndex: number) => {\n if (onChange) {\n onChange(newIndex);\n }\n };\n\n return (\n <View onLayout={(event) => setSliderWidth(event.nativeEvent.layout.width)}>\n <RNSnapCarousel\n autoplay={autoplay}\n autoplayInterval={autoplayInterval}\n data={data}\n horizontal={true}\n inactiveSlideOpacity={inactiveSlideOpacity}\n inactiveSlideScale={inactiveSlideScale}\n itemWidth={itemWidth}\n loop={infinite}\n loopClonesPerSide={2}\n onSnapToItem={handleSnapToItem}\n ref={carouselRef}\n renderItem={renderItem}\n sliderWidth={sliderWidth}\n />\n </View>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,QAAmD,OAAnD;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AACA,OAAOC,cAAP,MAA2B,4BAA3B;AAEA,SACIC,eADJ,EAEIC,uBAFJ,EAGIC,2BAHJ,EAIIC,yBAJJ,EAKIC,eALJ,QAMO,SANP;AAQA,eAAe,SAASC,QAAT,CAAyBC,KAAzB,EAAsD;EACjE,MAAM;IACFC,QAAQ,GAAGP,eADT;IAEFQ,gBAAgB,GAAGP,uBAFjB;IAGFQ,kBAHE;IAIFC,IAJE;IAKFC,oBAAoB,GAAGT,2BALrB;IAMFU,kBAAkB,GAAGT,yBANnB;IAOFU,KAPE;IAQFC,QAAQ,GAAGV,eART;IASFW,QATE;IAUFC;EAVE,IAWFV,KAXJ;EAaA,MAAMW,WAAW,GAAGtB,MAAM,CAA+B,IAA/B,CAA1B;EAEA,MAAM,CAACuB,WAAD,EAAcC,cAAd,IAAgCvB,QAAQ,CAAC,MAAMC,UAAU,CAACuB,GAAX,CAAe,QAAf,EAAyBC,KAAhC,CAA9C;EAEA,MAAMC,SAAS,GAAGb,kBAAkB,KAAKc,SAAvB,GACZL,WAAW,GAAIT,kBAAkB,GAAG,CADxB,GAEZS,WAFN;EAIAxB,SAAS,CAAC,MAAM;IACZ,MAAM8B,QAAQ,GAAGP,WAAW,CAACQ,OAA7B;;IACA,IAAID,QAAQ,IAAIX,KAAK,KAAKW,QAAQ,CAACE,YAAnC,EAAiD;MAC7CF,QAAQ,CAACG,UAAT,CAAoBd,KAApB,EAA2B,IAA3B;IACH;EACJ,CALQ,EAKN,CAACA,KAAD,CALM,CAAT;;EAOA,MAAMe,gBAAgB,GAAIC,QAAD,IAAsB;IAC3C,IAAId,QAAJ,EAAc;MACVA,QAAQ,CAACc,QAAD,CAAR;IACH;EACJ,CAJD;;EAMA,oBACI,oBAAC,IAAD;IAAM,QAAQ,EAAGC,KAAD,IAAWX,cAAc,CAACW,KAAK,CAACC,WAAN,CAAkBC,MAAlB,CAAyBX,KAA1B;EAAzC,gBACI,oBAAC,cAAD;IACI,QAAQ,EAAEd,QADd;IAEI,gBAAgB,EAAEC,gBAFtB;IAGI,IAAI,EAAEE,IAHV;IAII,UAAU,EAAE,IAJhB;IAKI,oBAAoB,EAAEC,oBAL1B;IAMI,kBAAkB,EAAEC,kBANxB;IAOI,SAAS,EAAEU,SAPf;IAQI,IAAI,EAAER,QARV;IASI,iBAAiB,EAAE,CATvB;IAUI,YAAY,EAAEc,gBAVlB;IAWI,GAAG,EAAEX,WAXT;IAYI,UAAU,EAAED,UAZhB;IAaI,WAAW,EAAEE;EAbjB,EADJ,CADJ;AAmBH;AAAA"}
@@ -1,215 +0,0 @@
1
- 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); }
2
-
3
- import React from 'react';
4
- import { View } from 'react-native';
5
- import Slick from 'react-slick';
6
- import styled from '@emotion/styled';
7
- import { ChevronLeft, ChevronRight } from '@fountain-ui/icons';
8
- import { mapIndexed } from '@fountain-ui/utils';
9
- import { defaultActiveSlideScale, defaultAutoplay, defaultAutoplayInterval, defaultInactiveSlideOpacity, defaultInactiveSlideScale, defaultInfinite } from './utils';
10
- const baseSettings = {
11
- dots: false,
12
- draggable: true,
13
- lazyLoad: typeof window === 'undefined' ? undefined : 'ondemand',
14
- pauseOnFocus: true,
15
- pauseOnHover: true,
16
- rows: 1,
17
- swipe: true,
18
- slidesPerRow: 1,
19
- vertical: false
20
- };
21
-
22
- const noop = () => void 0;
23
-
24
- const StyledContainer = styled.div(props => ({
25
- ['& .slick-slider']: {
26
- display: 'block',
27
- position: 'relative',
28
- userSelect: 'none'
29
- },
30
- ['& .slick-list']: {
31
- display: 'block',
32
- position: 'relative',
33
- overflow: 'hidden',
34
- margin: 0,
35
- padding: 0,
36
- ['&:focus']: {
37
- outline: 'none'
38
- },
39
- ['&.dragging']: {
40
- cursor: 'pointer'
41
- }
42
- },
43
- ['& .slick-slider .slick-track, &.slick-slider .slick-list']: {
44
- transform: 'translate3d(0, 0, 0)'
45
- },
46
- ['& .slick-track']: {
47
- display: 'block',
48
- position: 'relative',
49
- top: 0,
50
- left: 0,
51
- ['&:before, &:after']: {
52
- display: 'table',
53
- content: '\'\''
54
- },
55
- ['&:after']: {
56
- clear: 'both'
57
- },
58
- ...props.trackStyle
59
- },
60
- ['& .slick-slide']: {
61
- display: 'none',
62
- float: 'left',
63
- height: '100%',
64
- minHeight: 1,
65
- ['& > div']: {
66
- justifyContent: 'center',
67
- display: 'flex',
68
- transform: `scale(${props.inactiveSlideScale})`,
69
- transition: 'transform .5s',
70
- opacity: props.inactiveSlideOpacity
71
- }
72
- },
73
- ['& .slick-current > div']: {
74
- transform: `scale(${props.activeSlideScale})`,
75
- opacity: 1
76
- },
77
- ['& .slick-initialized .slick-slide']: {
78
- display: 'block'
79
- },
80
- ...props.arrowsStyle
81
- }));
82
-
83
- const ArrowContainer = props => {
84
- const {
85
- children,
86
- currentSlide,
87
- slideCount,
88
- visible,
89
- ...otherProps
90
- } = props;
91
- return visible ?
92
- /*#__PURE__*/
93
- // If root component is not a div, there's no arrow class.
94
- React.createElement("div", _extends({}, otherProps, {
95
- style: {
96
- cursor: 'pointer'
97
- }
98
- }), /*#__PURE__*/React.createElement(View, {
99
- style: {
100
- height: '100%',
101
- justifyContent: 'center',
102
- alignItems: 'center',
103
- backgroundColor: 'white',
104
- borderRadius: 16
105
- }
106
- }, children)) : null;
107
- };
108
-
109
- export default /*#__PURE__*/React.forwardRef((props, ref) => {
110
- const {
111
- activeSlideScale = defaultActiveSlideScale,
112
- autoplay = defaultAutoplay,
113
- autoplayInterval = defaultAutoplayInterval,
114
- centerMode = false,
115
- centerSlidePadding = 0,
116
- data,
117
- inactiveSlideOpacity = defaultInactiveSlideOpacity,
118
- inactiveSlideScale = defaultInactiveSlideScale,
119
- index,
120
- infinite = defaultInfinite,
121
- onChange,
122
- renderItem,
123
- slidesToScroll = 1,
124
- slidesToShow = 1,
125
- arrows = false,
126
- arrowsStyle = {},
127
- trackStyle = {}
128
- } = props;
129
- const slickRef = React.useRef(null);
130
- const [visibleArrow, setVisibleArrow] = React.useState(false);
131
- React.useEffect(() => {
132
- if (slickRef.current) {
133
- slickRef.current.slickGoTo(index, false);
134
- }
135
- }, [index]);
136
-
137
- const fixOnClickNotWorkingAfterMobileSwipe = () => {
138
- // @ts-ignore
139
- if (slickRef.current && slickRef.current.innerSlider) {
140
- // @ts-ignore
141
- slickRef.current.innerSlider.clickHandler = noop;
142
- }
143
- };
144
-
145
- const handleAfterChange = newIndex => {
146
- fixOnClickNotWorkingAfterMobileSwipe();
147
-
148
- if (onChange) {
149
- onChange(newIndex);
150
- }
151
- };
152
-
153
- const handleBeforeChange = () => {
154
- fixOnClickNotWorkingAfterMobileSwipe();
155
- };
156
-
157
- const onPointerOver = () => setVisibleArrow(true);
158
-
159
- const onPointerLeave = () => setVisibleArrow(false);
160
-
161
- React.useEffect(() => {
162
- if (ref) {
163
- //@ts-ignore
164
- ref.current = slickRef.current;
165
- }
166
- }, []);
167
- return /*#__PURE__*/React.createElement(StyledContainer, {
168
- activeSlideScale: activeSlideScale,
169
- inactiveSlideOpacity: inactiveSlideOpacity,
170
- inactiveSlideScale: inactiveSlideScale,
171
- arrowsStyle: arrowsStyle,
172
- trackStyle: trackStyle,
173
- onPointerOver: onPointerOver,
174
- onPointerLeave: onPointerLeave
175
- }, /*#__PURE__*/React.createElement(Slick, _extends({}, baseSettings, {
176
- afterChange: handleAfterChange,
177
- autoplay: autoplay,
178
- autoplaySpeed: autoplayInterval,
179
- beforeChange: handleBeforeChange,
180
- centerMode: centerMode,
181
- centerPadding: `${centerSlidePadding}px`,
182
- infinite: infinite,
183
- initialSlide: index,
184
- ref: slickRef,
185
- slidesToScroll: slidesToScroll,
186
- slidesToShow: slidesToShow,
187
- arrows: arrows,
188
- prevArrow: /*#__PURE__*/React.createElement(ArrowContainer, {
189
- visible: visibleArrow,
190
- children: /*#__PURE__*/React.createElement(ChevronLeft, {
191
- fill: '#767676'
192
- })
193
- }),
194
- nextArrow: /*#__PURE__*/React.createElement(ArrowContainer, {
195
- visible: visibleArrow,
196
- children: /*#__PURE__*/React.createElement(ChevronRight, {
197
- fill: '#767676'
198
- })
199
- })
200
- }), mapIndexed((item, index) => {
201
- const child = renderItem({
202
- item,
203
- index
204
- });
205
-
206
- if (child) {
207
- return /*#__PURE__*/React.cloneElement(child, {
208
- key: index
209
- });
210
- }
211
-
212
- return child;
213
- }, data)));
214
- });
215
- //# sourceMappingURL=CarouselWeb.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","View","Slick","styled","ChevronLeft","ChevronRight","mapIndexed","defaultActiveSlideScale","defaultAutoplay","defaultAutoplayInterval","defaultInactiveSlideOpacity","defaultInactiveSlideScale","defaultInfinite","baseSettings","dots","draggable","lazyLoad","window","undefined","pauseOnFocus","pauseOnHover","rows","swipe","slidesPerRow","vertical","noop","StyledContainer","div","props","display","position","userSelect","overflow","margin","padding","outline","cursor","transform","top","left","content","clear","trackStyle","float","height","minHeight","justifyContent","inactiveSlideScale","transition","opacity","inactiveSlideOpacity","activeSlideScale","arrowsStyle","ArrowContainer","children","currentSlide","slideCount","visible","otherProps","alignItems","backgroundColor","borderRadius","forwardRef","ref","autoplay","autoplayInterval","centerMode","centerSlidePadding","data","index","infinite","onChange","renderItem","slidesToScroll","slidesToShow","arrows","slickRef","useRef","visibleArrow","setVisibleArrow","useState","useEffect","current","slickGoTo","fixOnClickNotWorkingAfterMobileSwipe","innerSlider","clickHandler","handleAfterChange","newIndex","handleBeforeChange","onPointerOver","onPointerLeave","item","child","cloneElement","key"],"sources":["CarouselWeb.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\nimport Slick, { Settings } from 'react-slick';\nimport styled from '@emotion/styled';\nimport { ChevronLeft, ChevronRight } from '@fountain-ui/icons';\nimport { mapIndexed } from '@fountain-ui/utils';\nimport type CarouselProps from './CarouselProps';\nimport {\n defaultActiveSlideScale,\n defaultAutoplay,\n defaultAutoplayInterval,\n defaultInactiveSlideOpacity,\n defaultInactiveSlideScale,\n defaultInfinite,\n} from './utils';\n\nconst baseSettings: Settings = {\n dots: false,\n draggable: true,\n lazyLoad: typeof window === 'undefined' ? undefined : 'ondemand',\n pauseOnFocus: true,\n pauseOnHover: true,\n rows: 1,\n swipe: true,\n slidesPerRow: 1,\n vertical: false,\n};\n\nconst noop = () => void 0;\n\nconst StyledContainer: any = styled.div((props: any) => ({\n ['& .slick-slider']: {\n display: 'block',\n position: 'relative',\n userSelect: 'none',\n },\n ['& .slick-list']: {\n display: 'block',\n position: 'relative',\n overflow: 'hidden',\n margin: 0,\n padding: 0,\n ['&:focus']: {\n outline: 'none',\n },\n ['&.dragging']: {\n cursor: 'pointer',\n },\n },\n ['& .slick-slider .slick-track, &.slick-slider .slick-list']: {\n transform: 'translate3d(0, 0, 0)',\n },\n ['& .slick-track']: {\n display: 'block',\n position: 'relative',\n top: 0,\n left: 0,\n ['&:before, &:after']: {\n display: 'table',\n content: '\\'\\'',\n },\n ['&:after']: {\n clear: 'both',\n },\n ...props.trackStyle,\n },\n ['& .slick-slide']: {\n display: 'none',\n float: 'left',\n height: '100%',\n minHeight: 1,\n ['& > div']: {\n justifyContent: 'center',\n display: 'flex',\n transform: `scale(${props.inactiveSlideScale})`,\n transition: 'transform .5s',\n opacity: props.inactiveSlideOpacity,\n },\n },\n ['& .slick-current > div']: {\n transform: `scale(${props.activeSlideScale})`,\n opacity: 1,\n },\n ['& .slick-initialized .slick-slide']: {\n display: 'block',\n },\n ...props.arrowsStyle,\n}));\n\ninterface ArrowContainerProps {\n children: React.ReactElement;\n visible: boolean;\n currentSlide?: any;\n slideCount?: any;\n}\n\nconst ArrowContainer = (props: ArrowContainerProps) => {\n const {\n children,\n currentSlide,\n slideCount,\n visible,\n ...otherProps\n } = props;\n\n return visible ? (\n // If root component is not a div, there's no arrow class.\n <div {...otherProps} style={{ cursor: 'pointer' }}>\n <View\n style={{\n height: '100%',\n justifyContent: 'center',\n alignItems: 'center',\n backgroundColor: 'white',\n borderRadius: 16,\n }}\n >\n {children}\n </View>\n </div>\n ) : null;\n};\n\nexport default React.forwardRef((props: CarouselProps, ref) => {\n const {\n activeSlideScale = defaultActiveSlideScale,\n autoplay = defaultAutoplay,\n autoplayInterval = defaultAutoplayInterval,\n centerMode = false,\n centerSlidePadding = 0,\n data,\n inactiveSlideOpacity = defaultInactiveSlideOpacity,\n inactiveSlideScale = defaultInactiveSlideScale,\n index,\n infinite = defaultInfinite,\n onChange,\n renderItem,\n slidesToScroll = 1,\n slidesToShow = 1,\n arrows = false,\n arrowsStyle = {},\n trackStyle = {},\n } = props;\n\n const slickRef = React.useRef<Slick | null>(null);\n const [visibleArrow, setVisibleArrow] = React.useState(false);\n\n React.useEffect(() => {\n if (slickRef.current) {\n slickRef.current.slickGoTo(index, false);\n }\n }, [index]);\n\n const fixOnClickNotWorkingAfterMobileSwipe = () => {\n // @ts-ignore\n if (slickRef.current && slickRef.current.innerSlider) {\n // @ts-ignore\n slickRef.current.innerSlider.clickHandler = noop;\n }\n };\n\n const handleAfterChange = (newIndex: number) => {\n fixOnClickNotWorkingAfterMobileSwipe();\n\n if (onChange) {\n onChange(newIndex);\n }\n };\n\n const handleBeforeChange = () => {\n fixOnClickNotWorkingAfterMobileSwipe();\n };\n\n const onPointerOver = () => setVisibleArrow(true);\n const onPointerLeave = () => setVisibleArrow(false);\n\n React.useEffect(() => {\n if (ref) {\n //@ts-ignore\n ref.current = slickRef.current;\n }\n }, []);\n\n return (\n <StyledContainer\n activeSlideScale={activeSlideScale}\n inactiveSlideOpacity={inactiveSlideOpacity}\n inactiveSlideScale={inactiveSlideScale}\n arrowsStyle={arrowsStyle}\n trackStyle={trackStyle}\n onPointerOver={onPointerOver}\n onPointerLeave={onPointerLeave}\n >\n <Slick\n {...baseSettings}\n afterChange={handleAfterChange}\n autoplay={autoplay}\n autoplaySpeed={autoplayInterval}\n beforeChange={handleBeforeChange}\n centerMode={centerMode}\n centerPadding={`${centerSlidePadding}px`}\n infinite={infinite}\n initialSlide={index}\n ref={slickRef}\n slidesToScroll={slidesToScroll}\n slidesToShow={slidesToShow}\n arrows={arrows}\n prevArrow={<ArrowContainer visible={visibleArrow} children={<ChevronLeft fill={'#767676'}/>}/>}\n nextArrow={<ArrowContainer visible={visibleArrow} children={<ChevronRight fill={'#767676'}/>}/>}\n >\n {mapIndexed((item, index) => {\n const child = renderItem({ item, index });\n\n if (child) {\n return React.cloneElement(child, { key: index });\n }\n return child;\n }, data)}\n </Slick>\n </StyledContainer>\n );\n});\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,QAAqB,cAArB;AACA,OAAOC,KAAP,MAAgC,aAAhC;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,SAASC,WAAT,EAAsBC,YAAtB,QAA0C,oBAA1C;AACA,SAASC,UAAT,QAA2B,oBAA3B;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oBAAO7F,KAAK,CAAC8F,YAAN,CAAmBD,KAAnB,EAA0B;QAAEE,GAAG,EAAE1B;MAAP,CAA1B,CAAP;IACH;;IACD,OAAOwB,KAAP;EACH,CAPU,EAORzB,IAPQ,CAjBf,CATJ,CADJ;AAsCH,CAlGc,CAAf"}
@@ -1,2 +0,0 @@
1
- export { default } from './CarouselNative';
2
- //# sourceMappingURL=index.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["default"],"sources":["index.native.ts"],"sourcesContent":["export { default } from './CarouselNative';"],"mappings":"AAAA,SAASA,OAAT,QAAwB,kBAAxB"}
@@ -1,7 +0,0 @@
1
- export const defaultAutoplay = false;
2
- export const defaultAutoplayInterval = 3000;
3
- export const defaultInactiveSlideOpacity = 1;
4
- export const defaultInactiveSlideScale = 0.9;
5
- export const defaultActiveSlideScale = 1;
6
- export const defaultInfinite = false;
7
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["defaultAutoplay","defaultAutoplayInterval","defaultInactiveSlideOpacity","defaultInactiveSlideScale","defaultActiveSlideScale","defaultInfinite"],"sources":["utils.ts"],"sourcesContent":["export const defaultAutoplay = false;\n\nexport const defaultAutoplayInterval = 3000;\n\nexport const defaultInactiveSlideOpacity = 1;\n\nexport const defaultInactiveSlideScale = 0.9;\n\nexport const defaultActiveSlideScale = 1;\n\nexport const defaultInfinite = false;\n"],"mappings":"AAAA,OAAO,MAAMA,eAAe,GAAG,KAAxB;AAEP,OAAO,MAAMC,uBAAuB,GAAG,IAAhC;AAEP,OAAO,MAAMC,2BAA2B,GAAG,CAApC;AAEP,OAAO,MAAMC,yBAAyB,GAAG,GAAlC;AAEP,OAAO,MAAMC,uBAAuB,GAAG,CAAhC;AAEP,OAAO,MAAMC,eAAe,GAAG,KAAxB"}
@@ -1,2 +0,0 @@
1
- import type CarouselProps from './CarouselProps';
2
- export default function Carousel<ItemT>(props: CarouselProps<ItemT>): JSX.Element;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type CarouselProps from './CarouselProps';
3
- declare const _default: React.ForwardRefExoticComponent<Pick<CarouselProps<any>, "style" | "index" | "onChange" | "data" | "autoplay" | "autoplayInterval" | "centerSlidePadding" | "inactiveSlideOpacity" | "inactiveSlideScale" | "activeSlideScale" | "infinite" | "renderItem" | "slidesToScroll" | "slidesToShow" | "centerMode" | "arrows" | "arrowsStyle" | "trackStyle"> & React.RefAttributes<unknown>>;
4
- export default _default;
@@ -1 +0,0 @@
1
- export { default } from './CarouselNative';
@@ -1,6 +0,0 @@
1
- export declare const defaultAutoplay = false;
2
- export declare const defaultAutoplayInterval = 3000;
3
- export declare const defaultInactiveSlideOpacity = 1;
4
- export declare const defaultInactiveSlideScale = 0.9;
5
- export declare const defaultActiveSlideScale = 1;
6
- export declare const defaultInfinite = false;
@@ -1,67 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react';
2
- import { Dimensions, View } from 'react-native';
3
- import RNSnapCarousel from 'react-native-snap-carousel';
4
- import type CarouselProps from './CarouselProps';
5
- import {
6
- defaultAutoplay,
7
- defaultAutoplayInterval,
8
- defaultInactiveSlideOpacity,
9
- defaultInactiveSlideScale,
10
- defaultInfinite,
11
- } from './utils';
12
-
13
- export default function Carousel<ItemT>(props: CarouselProps<ItemT>) {
14
- const {
15
- autoplay = defaultAutoplay,
16
- autoplayInterval = defaultAutoplayInterval,
17
- centerSlidePadding,
18
- data,
19
- inactiveSlideOpacity = defaultInactiveSlideOpacity,
20
- inactiveSlideScale = defaultInactiveSlideScale,
21
- index,
22
- infinite = defaultInfinite,
23
- onChange,
24
- renderItem,
25
- } = props;
26
-
27
- const carouselRef = useRef<RNSnapCarousel<ItemT> | null>(null);
28
-
29
- const [sliderWidth, setSliderWidth] = useState(() => Dimensions.get('window').width);
30
-
31
- const itemWidth = centerSlidePadding !== undefined
32
- ? sliderWidth - (centerSlidePadding * 2)
33
- : sliderWidth;
34
-
35
- useEffect(() => {
36
- const carousel = carouselRef.current;
37
- if (carousel && index !== carousel.currentIndex) {
38
- carousel.snapToItem(index, true);
39
- }
40
- }, [index]);
41
-
42
- const handleSnapToItem = (newIndex: number) => {
43
- if (onChange) {
44
- onChange(newIndex);
45
- }
46
- };
47
-
48
- return (
49
- <View onLayout={(event) => setSliderWidth(event.nativeEvent.layout.width)}>
50
- <RNSnapCarousel
51
- autoplay={autoplay}
52
- autoplayInterval={autoplayInterval}
53
- data={data}
54
- horizontal={true}
55
- inactiveSlideOpacity={inactiveSlideOpacity}
56
- inactiveSlideScale={inactiveSlideScale}
57
- itemWidth={itemWidth}
58
- loop={infinite}
59
- loopClonesPerSide={2}
60
- onSnapToItem={handleSnapToItem}
61
- ref={carouselRef}
62
- renderItem={renderItem}
63
- sliderWidth={sliderWidth}
64
- />
65
- </View>
66
- );
67
- };
@@ -1,222 +0,0 @@
1
- import React from 'react';
2
- import { View } from 'react-native';
3
- import Slick, { Settings } from 'react-slick';
4
- import styled from '@emotion/styled';
5
- import { ChevronLeft, ChevronRight } from '@fountain-ui/icons';
6
- import { mapIndexed } from '@fountain-ui/utils';
7
- import type CarouselProps from './CarouselProps';
8
- import {
9
- defaultActiveSlideScale,
10
- defaultAutoplay,
11
- defaultAutoplayInterval,
12
- defaultInactiveSlideOpacity,
13
- defaultInactiveSlideScale,
14
- defaultInfinite,
15
- } from './utils';
16
-
17
- const baseSettings: Settings = {
18
- dots: false,
19
- draggable: true,
20
- lazyLoad: typeof window === 'undefined' ? undefined : 'ondemand',
21
- pauseOnFocus: true,
22
- pauseOnHover: true,
23
- rows: 1,
24
- swipe: true,
25
- slidesPerRow: 1,
26
- vertical: false,
27
- };
28
-
29
- const noop = () => void 0;
30
-
31
- const StyledContainer: any = styled.div((props: any) => ({
32
- ['& .slick-slider']: {
33
- display: 'block',
34
- position: 'relative',
35
- userSelect: 'none',
36
- },
37
- ['& .slick-list']: {
38
- display: 'block',
39
- position: 'relative',
40
- overflow: 'hidden',
41
- margin: 0,
42
- padding: 0,
43
- ['&:focus']: {
44
- outline: 'none',
45
- },
46
- ['&.dragging']: {
47
- cursor: 'pointer',
48
- },
49
- },
50
- ['& .slick-slider .slick-track, &.slick-slider .slick-list']: {
51
- transform: 'translate3d(0, 0, 0)',
52
- },
53
- ['& .slick-track']: {
54
- display: 'block',
55
- position: 'relative',
56
- top: 0,
57
- left: 0,
58
- ['&:before, &:after']: {
59
- display: 'table',
60
- content: '\'\'',
61
- },
62
- ['&:after']: {
63
- clear: 'both',
64
- },
65
- ...props.trackStyle,
66
- },
67
- ['& .slick-slide']: {
68
- display: 'none',
69
- float: 'left',
70
- height: '100%',
71
- minHeight: 1,
72
- ['& > div']: {
73
- justifyContent: 'center',
74
- display: 'flex',
75
- transform: `scale(${props.inactiveSlideScale})`,
76
- transition: 'transform .5s',
77
- opacity: props.inactiveSlideOpacity,
78
- },
79
- },
80
- ['& .slick-current > div']: {
81
- transform: `scale(${props.activeSlideScale})`,
82
- opacity: 1,
83
- },
84
- ['& .slick-initialized .slick-slide']: {
85
- display: 'block',
86
- },
87
- ...props.arrowsStyle,
88
- }));
89
-
90
- interface ArrowContainerProps {
91
- children: React.ReactElement;
92
- visible: boolean;
93
- currentSlide?: any;
94
- slideCount?: any;
95
- }
96
-
97
- const ArrowContainer = (props: ArrowContainerProps) => {
98
- const {
99
- children,
100
- currentSlide,
101
- slideCount,
102
- visible,
103
- ...otherProps
104
- } = props;
105
-
106
- return visible ? (
107
- // If root component is not a div, there's no arrow class.
108
- <div {...otherProps} style={{ cursor: 'pointer' }}>
109
- <View
110
- style={{
111
- height: '100%',
112
- justifyContent: 'center',
113
- alignItems: 'center',
114
- backgroundColor: 'white',
115
- borderRadius: 16,
116
- }}
117
- >
118
- {children}
119
- </View>
120
- </div>
121
- ) : null;
122
- };
123
-
124
- export default React.forwardRef((props: CarouselProps, ref) => {
125
- const {
126
- activeSlideScale = defaultActiveSlideScale,
127
- autoplay = defaultAutoplay,
128
- autoplayInterval = defaultAutoplayInterval,
129
- centerMode = false,
130
- centerSlidePadding = 0,
131
- data,
132
- inactiveSlideOpacity = defaultInactiveSlideOpacity,
133
- inactiveSlideScale = defaultInactiveSlideScale,
134
- index,
135
- infinite = defaultInfinite,
136
- onChange,
137
- renderItem,
138
- slidesToScroll = 1,
139
- slidesToShow = 1,
140
- arrows = false,
141
- arrowsStyle = {},
142
- trackStyle = {},
143
- } = props;
144
-
145
- const slickRef = React.useRef<Slick | null>(null);
146
- const [visibleArrow, setVisibleArrow] = React.useState(false);
147
-
148
- React.useEffect(() => {
149
- if (slickRef.current) {
150
- slickRef.current.slickGoTo(index, false);
151
- }
152
- }, [index]);
153
-
154
- const fixOnClickNotWorkingAfterMobileSwipe = () => {
155
- // @ts-ignore
156
- if (slickRef.current && slickRef.current.innerSlider) {
157
- // @ts-ignore
158
- slickRef.current.innerSlider.clickHandler = noop;
159
- }
160
- };
161
-
162
- const handleAfterChange = (newIndex: number) => {
163
- fixOnClickNotWorkingAfterMobileSwipe();
164
-
165
- if (onChange) {
166
- onChange(newIndex);
167
- }
168
- };
169
-
170
- const handleBeforeChange = () => {
171
- fixOnClickNotWorkingAfterMobileSwipe();
172
- };
173
-
174
- const onPointerOver = () => setVisibleArrow(true);
175
- const onPointerLeave = () => setVisibleArrow(false);
176
-
177
- React.useEffect(() => {
178
- if (ref) {
179
- //@ts-ignore
180
- ref.current = slickRef.current;
181
- }
182
- }, []);
183
-
184
- return (
185
- <StyledContainer
186
- activeSlideScale={activeSlideScale}
187
- inactiveSlideOpacity={inactiveSlideOpacity}
188
- inactiveSlideScale={inactiveSlideScale}
189
- arrowsStyle={arrowsStyle}
190
- trackStyle={trackStyle}
191
- onPointerOver={onPointerOver}
192
- onPointerLeave={onPointerLeave}
193
- >
194
- <Slick
195
- {...baseSettings}
196
- afterChange={handleAfterChange}
197
- autoplay={autoplay}
198
- autoplaySpeed={autoplayInterval}
199
- beforeChange={handleBeforeChange}
200
- centerMode={centerMode}
201
- centerPadding={`${centerSlidePadding}px`}
202
- infinite={infinite}
203
- initialSlide={index}
204
- ref={slickRef}
205
- slidesToScroll={slidesToScroll}
206
- slidesToShow={slidesToShow}
207
- arrows={arrows}
208
- prevArrow={<ArrowContainer visible={visibleArrow} children={<ChevronLeft fill={'#767676'}/>}/>}
209
- nextArrow={<ArrowContainer visible={visibleArrow} children={<ChevronRight fill={'#767676'}/>}/>}
210
- >
211
- {mapIndexed((item, index) => {
212
- const child = renderItem({ item, index });
213
-
214
- if (child) {
215
- return React.cloneElement(child, { key: index });
216
- }
217
- return child;
218
- }, data)}
219
- </Slick>
220
- </StyledContainer>
221
- );
222
- });
@@ -1 +0,0 @@
1
- export { default } from './CarouselNative';
@@ -1,11 +0,0 @@
1
- export const defaultAutoplay = false;
2
-
3
- export const defaultAutoplayInterval = 3000;
4
-
5
- export const defaultInactiveSlideOpacity = 1;
6
-
7
- export const defaultInactiveSlideScale = 0.9;
8
-
9
- export const defaultActiveSlideScale = 1;
10
-
11
- export const defaultInfinite = false;