react-native-reanimated-carousel 5.0.0-beta.7 → 5.0.0

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 (428) hide show
  1. package/README.md +60 -28
  2. package/lib/commonjs/components/Carousel.js +1 -1
  3. package/lib/commonjs/components/Carousel.js.map +1 -1
  4. package/lib/commonjs/components/CarouselLayout.js +1 -1
  5. package/lib/commonjs/components/CarouselLayout.js.map +1 -1
  6. package/lib/commonjs/components/ItemLayout.js +1 -1
  7. package/lib/commonjs/components/ItemLayout.js.map +1 -1
  8. package/lib/commonjs/components/ItemRenderer.js +1 -1
  9. package/lib/commonjs/components/ItemRenderer.js.map +1 -1
  10. package/lib/commonjs/components/Pagination/PaginationItem.js +2 -0
  11. package/lib/commonjs/components/Pagination/PaginationItem.js.map +1 -0
  12. package/lib/commonjs/components/Pagination/index.js +1 -1
  13. package/lib/commonjs/components/Pagination/index.js.map +1 -1
  14. package/lib/commonjs/components/ScrollViewGesture.js +1 -1
  15. package/lib/commonjs/components/ScrollViewGesture.js.map +1 -1
  16. package/lib/commonjs/hooks/useAutoPlay.js +1 -1
  17. package/lib/commonjs/hooks/useAutoPlay.js.map +1 -1
  18. package/lib/commonjs/hooks/useCarouselController.js +1 -1
  19. package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
  20. package/lib/commonjs/hooks/useCommonVariables.js +1 -1
  21. package/lib/commonjs/hooks/useCommonVariables.js.map +1 -1
  22. package/lib/commonjs/hooks/useInitProps.js +1 -1
  23. package/lib/commonjs/hooks/useInitProps.js.map +1 -1
  24. package/lib/commonjs/hooks/useLayoutConfig.js +1 -1
  25. package/lib/commonjs/hooks/useLayoutConfig.js.map +1 -1
  26. package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
  27. package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
  28. package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
  29. package/lib/commonjs/hooks/usePanGestureProxy.js.map +1 -1
  30. package/lib/commonjs/hooks/usePropsErrorBoundary.js +1 -1
  31. package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -1
  32. package/lib/commonjs/hooks/useUpdateGestureConfig.js.map +1 -1
  33. package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
  34. package/lib/commonjs/index.js +1 -1
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/commonjs/layouts/index.js.map +1 -1
  37. package/lib/commonjs/layouts/normal.js +1 -1
  38. package/lib/commonjs/layouts/normal.js.map +1 -1
  39. package/lib/commonjs/layouts/parallax.js +1 -1
  40. package/lib/commonjs/layouts/parallax.js.map +1 -1
  41. package/lib/commonjs/layouts/stack.js +1 -1
  42. package/lib/commonjs/layouts/stack.js.map +1 -1
  43. package/lib/commonjs/public-types.js +2 -0
  44. package/lib/commonjs/public-types.js.map +1 -0
  45. package/lib/commonjs/store/index.js.map +1 -1
  46. package/lib/commonjs/utils/carousel-direction.js +2 -0
  47. package/lib/commonjs/utils/carousel-direction.js.map +1 -0
  48. package/lib/commonjs/utils/carousel-math.js +2 -0
  49. package/lib/commonjs/utils/carousel-math.js.map +1 -0
  50. package/lib/commonjs/utils/deal-with-animation.js +1 -1
  51. package/lib/commonjs/utils/deal-with-animation.js.map +1 -1
  52. package/lib/module/components/Carousel.js +1 -1
  53. package/lib/module/components/Carousel.js.map +1 -1
  54. package/lib/module/components/CarouselLayout.js +1 -1
  55. package/lib/module/components/CarouselLayout.js.map +1 -1
  56. package/lib/module/components/ItemLayout.js +1 -1
  57. package/lib/module/components/ItemLayout.js.map +1 -1
  58. package/lib/module/components/ItemRenderer.js +1 -1
  59. package/lib/module/components/ItemRenderer.js.map +1 -1
  60. package/lib/module/components/LazyView.js +1 -1
  61. package/lib/module/components/LazyView.js.map +1 -1
  62. package/lib/module/components/Pagination/PaginationItem.js +2 -0
  63. package/lib/module/components/Pagination/PaginationItem.js.map +1 -0
  64. package/lib/module/components/Pagination/index.js +1 -1
  65. package/lib/module/components/Pagination/index.js.map +1 -1
  66. package/lib/module/components/ScrollViewGesture.js +1 -1
  67. package/lib/module/components/ScrollViewGesture.js.map +1 -1
  68. package/lib/module/constants/index.js +1 -1
  69. package/lib/module/constants/index.js.map +1 -1
  70. package/lib/module/hooks/useAutoPlay.js +1 -1
  71. package/lib/module/hooks/useAutoPlay.js.map +1 -1
  72. package/lib/module/hooks/useCarouselController.js +1 -1
  73. package/lib/module/hooks/useCarouselController.js.map +1 -1
  74. package/lib/module/hooks/useCheckMounted.js +1 -1
  75. package/lib/module/hooks/useCheckMounted.js.map +1 -1
  76. package/lib/module/hooks/useCommonVariables.js +1 -1
  77. package/lib/module/hooks/useCommonVariables.js.map +1 -1
  78. package/lib/module/hooks/useInitProps.js +1 -1
  79. package/lib/module/hooks/useInitProps.js.map +1 -1
  80. package/lib/module/hooks/useLayoutConfig.js +1 -1
  81. package/lib/module/hooks/useLayoutConfig.js.map +1 -1
  82. package/lib/module/hooks/useOffsetX.js +1 -1
  83. package/lib/module/hooks/useOffsetX.js.map +1 -1
  84. package/lib/module/hooks/useOnProgressChange.js +1 -1
  85. package/lib/module/hooks/useOnProgressChange.js.map +1 -1
  86. package/lib/module/hooks/usePanGestureProxy.js +1 -1
  87. package/lib/module/hooks/usePanGestureProxy.js.map +1 -1
  88. package/lib/module/hooks/usePropsErrorBoundary.js +1 -1
  89. package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -1
  90. package/lib/module/hooks/useUpdateGestureConfig.js +1 -1
  91. package/lib/module/hooks/useUpdateGestureConfig.js.map +1 -1
  92. package/lib/module/hooks/useVisibleRanges.js +1 -1
  93. package/lib/module/hooks/useVisibleRanges.js.map +1 -1
  94. package/lib/module/index.js +1 -1
  95. package/lib/module/index.js.map +1 -1
  96. package/lib/module/layouts/index.js +1 -1
  97. package/lib/module/layouts/index.js.map +1 -1
  98. package/lib/module/layouts/normal.js +1 -1
  99. package/lib/module/layouts/normal.js.map +1 -1
  100. package/lib/module/layouts/parallax.js +1 -1
  101. package/lib/module/layouts/parallax.js.map +1 -1
  102. package/lib/module/layouts/stack.js +1 -1
  103. package/lib/module/layouts/stack.js.map +1 -1
  104. package/lib/module/package.json +1 -0
  105. package/lib/module/public-types.js +2 -0
  106. package/lib/module/public-types.js.map +1 -0
  107. package/lib/module/store/index.js +1 -1
  108. package/lib/module/store/index.js.map +1 -1
  109. package/lib/module/types.js +1 -1
  110. package/lib/module/utils/carousel-direction.js +2 -0
  111. package/lib/module/utils/carousel-direction.js.map +1 -0
  112. package/lib/module/utils/carousel-math.js +2 -0
  113. package/lib/module/utils/carousel-math.js.map +1 -0
  114. package/lib/module/utils/compute-gesture-translation.js +1 -1
  115. package/lib/module/utils/compute-gesture-translation.js.map +1 -1
  116. package/lib/module/utils/compute-offset-if-size-changed.js +1 -1
  117. package/lib/module/utils/compute-offset-if-size-changed.js.map +1 -1
  118. package/lib/module/utils/computed-with-auto-fill-data.js +1 -1
  119. package/lib/module/utils/computed-with-auto-fill-data.js.map +1 -1
  120. package/lib/module/utils/deal-with-animation.js +1 -1
  121. package/lib/module/utils/deal-with-animation.js.map +1 -1
  122. package/lib/module/utils/log.js +1 -1
  123. package/lib/module/utils/log.js.map +1 -1
  124. package/lib/module/utils/sanitize-animation-style.js +1 -1
  125. package/lib/module/utils/sanitize-animation-style.js.map +1 -1
  126. package/lib/typescript/commonjs/components/Carousel.d.ts +8 -0
  127. package/lib/typescript/commonjs/components/Carousel.d.ts.map +1 -0
  128. package/lib/typescript/{components → commonjs/components}/CarouselLayout.d.ts +5 -8
  129. package/lib/typescript/commonjs/components/CarouselLayout.d.ts.map +1 -0
  130. package/lib/typescript/{components → commonjs/components}/ItemLayout.d.ts +7 -6
  131. package/lib/typescript/commonjs/components/ItemLayout.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/components/ItemRenderer.d.ts +24 -0
  133. package/lib/typescript/commonjs/components/ItemRenderer.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/components/LazyView.d.ts.map +1 -0
  135. package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts +14 -0
  136. package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts.map +1 -0
  137. package/lib/typescript/commonjs/components/Pagination/index.d.ts +4 -0
  138. package/lib/typescript/commonjs/components/Pagination/index.d.ts.map +1 -0
  139. package/lib/typescript/{components → commonjs/components}/ScrollViewGesture.d.ts +3 -4
  140. package/lib/typescript/commonjs/components/ScrollViewGesture.d.ts.map +1 -0
  141. package/lib/typescript/commonjs/constants/index.d.ts.map +1 -0
  142. package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts +12 -0
  143. package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts.map +1 -0
  144. package/lib/typescript/commonjs/hooks/useCarouselController.d.ts +29 -0
  145. package/lib/typescript/commonjs/hooks/useCarouselController.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/hooks/useCheckMounted.d.ts.map +1 -0
  147. package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts +18 -0
  148. package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts.map +1 -0
  149. package/lib/typescript/commonjs/hooks/useInitProps.d.ts +25 -0
  150. package/lib/typescript/commonjs/hooks/useInitProps.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts +8 -0
  152. package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts.map +1 -0
  153. package/lib/typescript/commonjs/hooks/useOffsetX.d.ts +13 -0
  154. package/lib/typescript/commonjs/hooks/useOffsetX.d.ts.map +1 -0
  155. package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts +12 -0
  156. package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts.map +1 -0
  157. package/lib/typescript/{hooks → commonjs/hooks}/usePanGestureProxy.d.ts +3 -2
  158. package/lib/typescript/commonjs/hooks/usePanGestureProxy.d.ts.map +1 -0
  159. package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts +3 -0
  160. package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts.map +1 -0
  161. package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts +9 -0
  162. package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts.map +1 -0
  163. package/lib/typescript/{hooks → commonjs/hooks}/useVisibleRanges.d.ts +2 -2
  164. package/lib/typescript/commonjs/hooks/useVisibleRanges.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/index.d.ts +4 -0
  166. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  167. package/lib/typescript/{layouts → commonjs/layouts}/index.d.ts +0 -1
  168. package/lib/typescript/commonjs/layouts/index.d.ts.map +1 -0
  169. package/lib/typescript/{layouts → commonjs/layouts}/normal.d.ts +3 -1
  170. package/lib/typescript/commonjs/layouts/normal.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/layouts/parallax.d.ts +27 -0
  172. package/lib/typescript/commonjs/layouts/parallax.d.ts.map +1 -0
  173. package/lib/typescript/commonjs/layouts/stack.d.ts +10 -0
  174. package/lib/typescript/commonjs/layouts/stack.d.ts.map +1 -0
  175. package/lib/typescript/commonjs/package.json +1 -0
  176. package/lib/typescript/commonjs/public-types.d.ts +161 -0
  177. package/lib/typescript/commonjs/public-types.d.ts.map +1 -0
  178. package/lib/typescript/{store → commonjs/store}/index.d.ts +8 -8
  179. package/lib/typescript/commonjs/store/index.d.ts.map +1 -0
  180. package/lib/typescript/commonjs/types.d.ts +15 -0
  181. package/lib/typescript/commonjs/types.d.ts.map +1 -0
  182. package/lib/typescript/commonjs/utils/carousel-direction.d.ts +9 -0
  183. package/lib/typescript/commonjs/utils/carousel-direction.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/utils/carousel-math.d.ts +28 -0
  185. package/lib/typescript/commonjs/utils/carousel-math.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/utils/compute-gesture-translation.d.ts.map +1 -0
  187. package/lib/typescript/commonjs/utils/compute-offset-if-size-changed.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/utils/computed-with-auto-fill-data.d.ts.map +1 -0
  189. package/lib/typescript/commonjs/utils/deal-with-animation.d.ts +3 -0
  190. package/lib/typescript/commonjs/utils/deal-with-animation.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/utils/log.d.ts.map +1 -0
  192. package/lib/typescript/commonjs/utils/sanitize-animation-style.d.ts.map +1 -0
  193. package/lib/typescript/module/components/Carousel.d.ts +8 -0
  194. package/lib/typescript/module/components/Carousel.d.ts.map +1 -0
  195. package/lib/typescript/module/components/CarouselLayout.d.ts +14 -0
  196. package/lib/typescript/module/components/CarouselLayout.d.ts.map +1 -0
  197. package/lib/typescript/module/components/ItemLayout.d.ts +21 -0
  198. package/lib/typescript/module/components/ItemLayout.d.ts.map +1 -0
  199. package/lib/typescript/module/components/ItemRenderer.d.ts +24 -0
  200. package/lib/typescript/module/components/ItemRenderer.d.ts.map +1 -0
  201. package/lib/typescript/module/components/LazyView.d.ts +8 -0
  202. package/lib/typescript/module/components/LazyView.d.ts.map +1 -0
  203. package/lib/typescript/module/components/Pagination/PaginationItem.d.ts +14 -0
  204. package/lib/typescript/module/components/Pagination/PaginationItem.d.ts.map +1 -0
  205. package/lib/typescript/module/components/Pagination/index.d.ts +4 -0
  206. package/lib/typescript/module/components/Pagination/index.d.ts.map +1 -0
  207. package/lib/typescript/module/components/ScrollViewGesture.d.ts +18 -0
  208. package/lib/typescript/module/components/ScrollViewGesture.d.ts.map +1 -0
  209. package/lib/typescript/module/constants/index.d.ts +9 -0
  210. package/lib/typescript/module/constants/index.d.ts.map +1 -0
  211. package/lib/typescript/module/hooks/useAutoPlay.d.ts +12 -0
  212. package/lib/typescript/module/hooks/useAutoPlay.d.ts.map +1 -0
  213. package/lib/typescript/module/hooks/useCarouselController.d.ts +29 -0
  214. package/lib/typescript/module/hooks/useCarouselController.d.ts.map +1 -0
  215. package/lib/typescript/module/hooks/useCheckMounted.d.ts +3 -0
  216. package/lib/typescript/module/hooks/useCheckMounted.d.ts.map +1 -0
  217. package/lib/typescript/module/hooks/useCommonVariables.d.ts +18 -0
  218. package/lib/typescript/module/hooks/useCommonVariables.d.ts.map +1 -0
  219. package/lib/typescript/module/hooks/useInitProps.d.ts +25 -0
  220. package/lib/typescript/module/hooks/useInitProps.d.ts.map +1 -0
  221. package/lib/typescript/module/hooks/useLayoutConfig.d.ts +8 -0
  222. package/lib/typescript/module/hooks/useLayoutConfig.d.ts.map +1 -0
  223. package/lib/typescript/module/hooks/useOffsetX.d.ts +13 -0
  224. package/lib/typescript/module/hooks/useOffsetX.d.ts.map +1 -0
  225. package/lib/typescript/module/hooks/useOnProgressChange.d.ts +12 -0
  226. package/lib/typescript/module/hooks/useOnProgressChange.d.ts.map +1 -0
  227. package/lib/typescript/module/hooks/usePanGestureProxy.d.ts +11 -0
  228. package/lib/typescript/module/hooks/usePanGestureProxy.d.ts.map +1 -0
  229. package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts +3 -0
  230. package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts.map +1 -0
  231. package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts +9 -0
  232. package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts.map +1 -0
  233. package/lib/typescript/module/hooks/useVisibleRanges.d.ts +22 -0
  234. package/lib/typescript/module/hooks/useVisibleRanges.d.ts.map +1 -0
  235. package/lib/typescript/module/index.d.ts +4 -0
  236. package/lib/typescript/module/index.d.ts.map +1 -0
  237. package/lib/typescript/module/layouts/index.d.ts +10 -0
  238. package/lib/typescript/module/layouts/index.d.ts.map +1 -0
  239. package/lib/typescript/module/layouts/normal.d.ts +15 -0
  240. package/lib/typescript/module/layouts/normal.d.ts.map +1 -0
  241. package/lib/typescript/module/layouts/parallax.d.ts +27 -0
  242. package/lib/typescript/module/layouts/parallax.d.ts.map +1 -0
  243. package/lib/typescript/module/layouts/stack.d.ts +10 -0
  244. package/lib/typescript/module/layouts/stack.d.ts.map +1 -0
  245. package/lib/typescript/module/package.json +1 -0
  246. package/lib/typescript/module/public-types.d.ts +161 -0
  247. package/lib/typescript/module/public-types.d.ts.map +1 -0
  248. package/lib/typescript/module/store/index.d.ts +35 -0
  249. package/lib/typescript/module/store/index.d.ts.map +1 -0
  250. package/lib/typescript/module/types.d.ts +15 -0
  251. package/lib/typescript/module/types.d.ts.map +1 -0
  252. package/lib/typescript/module/utils/carousel-direction.d.ts +9 -0
  253. package/lib/typescript/module/utils/carousel-direction.d.ts.map +1 -0
  254. package/lib/typescript/module/utils/carousel-math.d.ts +28 -0
  255. package/lib/typescript/module/utils/carousel-math.d.ts.map +1 -0
  256. package/lib/typescript/module/utils/compute-gesture-translation.d.ts +9 -0
  257. package/lib/typescript/module/utils/compute-gesture-translation.d.ts.map +1 -0
  258. package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts +6 -0
  259. package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts.map +1 -0
  260. package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts +23 -0
  261. package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts.map +1 -0
  262. package/lib/typescript/module/utils/deal-with-animation.d.ts +3 -0
  263. package/lib/typescript/module/utils/deal-with-animation.d.ts.map +1 -0
  264. package/lib/typescript/module/utils/log.d.ts +7 -0
  265. package/lib/typescript/module/utils/log.d.ts.map +1 -0
  266. package/lib/typescript/module/utils/sanitize-animation-style.d.ts +3 -0
  267. package/lib/typescript/module/utils/sanitize-animation-style.d.ts.map +1 -0
  268. package/package.json +34 -7
  269. package/scripts/codemods/v5.mjs +502 -0
  270. package/src/components/Carousel.tsx +5 -5
  271. package/src/components/CarouselLayout.tsx +53 -91
  272. package/src/components/ItemLayout.tsx +55 -46
  273. package/src/components/ItemRenderer.tsx +29 -18
  274. package/src/components/Pagination/PaginationItem.tsx +162 -0
  275. package/src/components/Pagination/index.tsx +105 -6
  276. package/src/components/ScrollViewGesture.tsx +92 -177
  277. package/src/hooks/useAutoPlay.ts +23 -18
  278. package/src/hooks/useCarouselController.tsx +194 -340
  279. package/src/hooks/useCommonVariables.ts +159 -71
  280. package/src/hooks/useInitProps.ts +161 -71
  281. package/src/hooks/useLayoutConfig.ts +21 -12
  282. package/src/hooks/useOffsetX.ts +3 -3
  283. package/src/hooks/useOnProgressChange.ts +23 -48
  284. package/src/hooks/usePanGestureProxy.ts +2 -2
  285. package/src/hooks/usePropsErrorBoundary.ts +32 -90
  286. package/src/hooks/useUpdateGestureConfig.ts +5 -2
  287. package/src/hooks/useVisibleRanges.tsx +2 -2
  288. package/src/index.tsx +14 -9
  289. package/src/layouts/index.tsx +0 -2
  290. package/src/layouts/normal.ts +14 -4
  291. package/src/layouts/parallax.ts +32 -59
  292. package/src/layouts/stack.ts +30 -70
  293. package/src/public-types.ts +198 -0
  294. package/src/store/index.tsx +7 -7
  295. package/src/types.ts +30 -322
  296. package/src/utils/carousel-direction.ts +39 -0
  297. package/src/utils/carousel-math.ts +156 -0
  298. package/src/utils/deal-with-animation.ts +11 -9
  299. package/lib/commonjs/components/Pagination/Basic/PaginationItem.js +0 -2
  300. package/lib/commonjs/components/Pagination/Basic/PaginationItem.js.map +0 -1
  301. package/lib/commonjs/components/Pagination/Basic/index.js +0 -2
  302. package/lib/commonjs/components/Pagination/Basic/index.js.map +0 -1
  303. package/lib/commonjs/components/Pagination/Custom/PaginationItem.js +0 -2
  304. package/lib/commonjs/components/Pagination/Custom/PaginationItem.js.map +0 -1
  305. package/lib/commonjs/components/Pagination/Custom/index.js +0 -2
  306. package/lib/commonjs/components/Pagination/Custom/index.js.map +0 -1
  307. package/lib/commonjs/utils/compute-offset-if-data-changed.js +0 -2
  308. package/lib/commonjs/utils/compute-offset-if-data-changed.js.map +0 -1
  309. package/lib/commonjs/utils/handleroffset-direction.js +0 -2
  310. package/lib/commonjs/utils/handleroffset-direction.js.map +0 -1
  311. package/lib/module/components/Pagination/Basic/PaginationItem.js +0 -2
  312. package/lib/module/components/Pagination/Basic/PaginationItem.js.map +0 -1
  313. package/lib/module/components/Pagination/Basic/index.js +0 -2
  314. package/lib/module/components/Pagination/Basic/index.js.map +0 -1
  315. package/lib/module/components/Pagination/Custom/PaginationItem.js +0 -2
  316. package/lib/module/components/Pagination/Custom/PaginationItem.js.map +0 -1
  317. package/lib/module/components/Pagination/Custom/index.js +0 -2
  318. package/lib/module/components/Pagination/Custom/index.js.map +0 -1
  319. package/lib/module/utils/compute-offset-if-data-changed.js +0 -2
  320. package/lib/module/utils/compute-offset-if-data-changed.js.map +0 -1
  321. package/lib/module/utils/handleroffset-direction.js +0 -2
  322. package/lib/module/utils/handleroffset-direction.js.map +0 -1
  323. package/lib/typescript/components/Carousel.d.ts +0 -8
  324. package/lib/typescript/components/Carousel.d.ts.map +0 -1
  325. package/lib/typescript/components/CarouselLayout.d.ts.map +0 -1
  326. package/lib/typescript/components/ItemLayout.d.ts.map +0 -1
  327. package/lib/typescript/components/ItemRenderer.d.ts +0 -23
  328. package/lib/typescript/components/ItemRenderer.d.ts.map +0 -1
  329. package/lib/typescript/components/LazyView.d.ts.map +0 -1
  330. package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts +0 -29
  331. package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts.map +0 -1
  332. package/lib/typescript/components/Pagination/Basic/index.d.ts +0 -23
  333. package/lib/typescript/components/Pagination/Basic/index.d.ts.map +0 -1
  334. package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts +0 -35
  335. package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts.map +0 -1
  336. package/lib/typescript/components/Pagination/Custom/index.d.ts +0 -26
  337. package/lib/typescript/components/Pagination/Custom/index.d.ts.map +0 -1
  338. package/lib/typescript/components/Pagination/index.d.ts +0 -5
  339. package/lib/typescript/components/Pagination/index.d.ts.map +0 -1
  340. package/lib/typescript/components/ScrollViewGesture.d.ts.map +0 -1
  341. package/lib/typescript/constants/index.d.ts.map +0 -1
  342. package/lib/typescript/hooks/useAutoPlay.d.ts +0 -12
  343. package/lib/typescript/hooks/useAutoPlay.d.ts.map +0 -1
  344. package/lib/typescript/hooks/useCarouselController.d.ts +0 -28
  345. package/lib/typescript/hooks/useCarouselController.d.ts.map +0 -1
  346. package/lib/typescript/hooks/useCheckMounted.d.ts.map +0 -1
  347. package/lib/typescript/hooks/useCommonVariables.d.ts +0 -13
  348. package/lib/typescript/hooks/useCommonVariables.d.ts.map +0 -1
  349. package/lib/typescript/hooks/useInitProps.d.ts +0 -10
  350. package/lib/typescript/hooks/useInitProps.d.ts.map +0 -1
  351. package/lib/typescript/hooks/useLayoutConfig.d.ts +0 -8
  352. package/lib/typescript/hooks/useLayoutConfig.d.ts.map +0 -1
  353. package/lib/typescript/hooks/useOffsetX.d.ts +0 -13
  354. package/lib/typescript/hooks/useOffsetX.d.ts.map +0 -1
  355. package/lib/typescript/hooks/useOnProgressChange.d.ts +0 -11
  356. package/lib/typescript/hooks/useOnProgressChange.d.ts.map +0 -1
  357. package/lib/typescript/hooks/usePanGestureProxy.d.ts.map +0 -1
  358. package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +0 -5
  359. package/lib/typescript/hooks/usePropsErrorBoundary.d.ts.map +0 -1
  360. package/lib/typescript/hooks/useUpdateGestureConfig.d.ts +0 -6
  361. package/lib/typescript/hooks/useUpdateGestureConfig.d.ts.map +0 -1
  362. package/lib/typescript/hooks/useVisibleRanges.d.ts.map +0 -1
  363. package/lib/typescript/index.d.ts +0 -7
  364. package/lib/typescript/index.d.ts.map +0 -1
  365. package/lib/typescript/layouts/index.d.ts.map +0 -1
  366. package/lib/typescript/layouts/normal.d.ts.map +0 -1
  367. package/lib/typescript/layouts/parallax.d.ts +0 -47
  368. package/lib/typescript/layouts/parallax.d.ts.map +0 -1
  369. package/lib/typescript/layouts/stack.d.ts +0 -38
  370. package/lib/typescript/layouts/stack.d.ts.map +0 -1
  371. package/lib/typescript/store/index.d.ts.map +0 -1
  372. package/lib/typescript/types.d.ts +0 -302
  373. package/lib/typescript/types.d.ts.map +0 -1
  374. package/lib/typescript/utils/compute-gesture-translation.d.ts.map +0 -1
  375. package/lib/typescript/utils/compute-offset-if-data-changed.d.ts +0 -9
  376. package/lib/typescript/utils/compute-offset-if-data-changed.d.ts.map +0 -1
  377. package/lib/typescript/utils/compute-offset-if-size-changed.d.ts.map +0 -1
  378. package/lib/typescript/utils/computed-with-auto-fill-data.d.ts.map +0 -1
  379. package/lib/typescript/utils/deal-with-animation.d.ts +0 -3
  380. package/lib/typescript/utils/deal-with-animation.d.ts.map +0 -1
  381. package/lib/typescript/utils/handleroffset-direction.d.ts +0 -4
  382. package/lib/typescript/utils/handleroffset-direction.d.ts.map +0 -1
  383. package/lib/typescript/utils/log.d.ts.map +0 -1
  384. package/lib/typescript/utils/sanitize-animation-style.d.ts.map +0 -1
  385. package/src/components/Carousel.test.tsx +0 -1215
  386. package/src/components/LazyView.test.tsx +0 -61
  387. package/src/components/Pagination/Basic/PaginationItem.tsx +0 -149
  388. package/src/components/Pagination/Basic/index.tsx +0 -98
  389. package/src/components/Pagination/Custom/PaginationItem.tsx +0 -166
  390. package/src/components/Pagination/Custom/index.tsx +0 -111
  391. package/src/components/Pagination/Pagination.test.tsx +0 -178
  392. package/src/components/ScrollViewGesture.test.tsx +0 -155
  393. package/src/components/issue-899-parallax-reverse-loop.test.tsx +0 -131
  394. package/src/components/rnr-demo.test.tsx +0 -53
  395. package/src/hooks/useAutoPlay.test.ts +0 -194
  396. package/src/hooks/useCarouselController.test.tsx +0 -1158
  397. package/src/hooks/useCheckMounted.test.ts +0 -47
  398. package/src/hooks/useCommonVariables.test.tsx +0 -384
  399. package/src/hooks/useInitProps.test.tsx +0 -134
  400. package/src/hooks/useLayoutConfig.test.tsx +0 -247
  401. package/src/hooks/useOffsetX.test.ts +0 -54
  402. package/src/hooks/useOnProgressChange.test.tsx +0 -270
  403. package/src/hooks/usePanGestureProxy.test.tsx +0 -368
  404. package/src/hooks/usePropsErrorBoundary.test.tsx +0 -57
  405. package/src/hooks/useUpdateGestureConfig.test.ts +0 -89
  406. package/src/hooks/useVisibleRanges.test.tsx +0 -347
  407. package/src/layouts/parallax.test.ts +0 -239
  408. package/src/layouts/stack.test.ts +0 -252
  409. package/src/store/index.test.tsx +0 -314
  410. package/src/utils/compute-gesture-translation.test.ts +0 -70
  411. package/src/utils/compute-offset-if-data-changed.test.ts +0 -133
  412. package/src/utils/compute-offset-if-data-changed.ts +0 -44
  413. package/src/utils/compute-offset-if-size-changed.test.ts +0 -78
  414. package/src/utils/computed-with-auto-fill-data.test.ts +0 -298
  415. package/src/utils/deal-with-animation.test.ts +0 -181
  416. package/src/utils/handleroffset-direction.test.ts +0 -124
  417. package/src/utils/handleroffset-direction.ts +0 -18
  418. package/src/utils/index.test.ts +0 -90
  419. package/src/utils/log.test.ts +0 -134
  420. package/src/utils/sanitize-animation-style.test.ts +0 -40
  421. /package/lib/typescript/{components → commonjs/components}/LazyView.d.ts +0 -0
  422. /package/lib/typescript/{constants → commonjs/constants}/index.d.ts +0 -0
  423. /package/lib/typescript/{hooks → commonjs/hooks}/useCheckMounted.d.ts +0 -0
  424. /package/lib/typescript/{utils → commonjs/utils}/compute-gesture-translation.d.ts +0 -0
  425. /package/lib/typescript/{utils → commonjs/utils}/compute-offset-if-size-changed.d.ts +0 -0
  426. /package/lib/typescript/{utils → commonjs/utils}/computed-with-auto-fill-data.d.ts +0 -0
  427. /package/lib/typescript/{utils → commonjs/utils}/log.d.ts +0 -0
  428. /package/lib/typescript/{utils → commonjs/utils}/sanitize-animation-style.d.ts +0 -0
@@ -1,368 +0,0 @@
1
- import React from "react";
2
- import { Text } from "react-native";
3
- import type { PanGesture, PanGestureHandler, TapGesture } from "react-native-gesture-handler";
4
- import {
5
- Gesture,
6
- GestureDetector,
7
- GestureHandlerRootView,
8
- State,
9
- } from "react-native-gesture-handler";
10
-
11
- import { cleanup, render } from "@testing-library/react-native";
12
- import { fireGestureHandler, getByGestureTestId } from "react-native-gesture-handler/jest-utils";
13
-
14
- import { usePanGestureProxy } from "./usePanGestureProxy";
15
-
16
- beforeEach(cleanup);
17
-
18
- const mockedEventHandlers = () => {
19
- return {
20
- begin: jest.fn(),
21
- start: jest.fn(),
22
- active: jest.fn(),
23
- end: jest.fn(),
24
- fail: jest.fn(),
25
- cancel: jest.fn(),
26
- finish: jest.fn(),
27
- };
28
- };
29
-
30
- const mockedEventHandlersFromUser = () => {
31
- return {
32
- begin: jest.fn(),
33
- start: jest.fn(),
34
- active: jest.fn(),
35
- end: jest.fn(),
36
- fail: jest.fn(),
37
- cancel: jest.fn(),
38
- finish: jest.fn(),
39
- };
40
- };
41
-
42
- describe("Using RNGH v2 gesture API", () => {
43
- interface SingleHandlerProps {
44
- handlers: ReturnType<typeof mockedEventHandlers>;
45
- handlersFromUser: ReturnType<typeof mockedEventHandlers>;
46
- treatStartAsUpdate?: boolean;
47
- }
48
-
49
- function SingleHandler({ handlers, handlersFromUser, treatStartAsUpdate }: SingleHandlerProps) {
50
- const pan = usePanGestureProxy({
51
- onConfigurePanGesture: (gesture: PanGesture) => {
52
- // This is user's customizations
53
- gesture
54
- .onBegin(handlersFromUser.begin)
55
- .onUpdate(handlersFromUser.active)
56
- .onEnd(handlersFromUser.end)
57
- .onFinalize(handlers.finish)
58
- .withTestId("pan");
59
- },
60
- onGestureStart: treatStartAsUpdate ? handlers.active : handlers.start,
61
- onGestureUpdate: handlers.active,
62
- onGestureEnd: handlers.end,
63
- options: { enabled: true },
64
- });
65
-
66
- return (
67
- <GestureHandlerRootView>
68
- <GestureDetector gesture={pan}>
69
- <Text>v2 API test</Text>
70
- </GestureDetector>
71
- </GestureHandlerRootView>
72
- );
73
- }
74
-
75
- interface RacingHandlersProps {
76
- tapHandlers: ReturnType<typeof mockedEventHandlers>;
77
- panHandlers: ReturnType<typeof mockedEventHandlers>;
78
- }
79
-
80
- function RacingHandlers({ tapHandlers, panHandlers }: RacingHandlersProps) {
81
- const tap = Gesture.Tap().onBegin(tapHandlers.begin).onEnd(tapHandlers.end).withTestId("tap");
82
-
83
- const pan = usePanGestureProxy({
84
- onConfigurePanGesture: (_: PanGesture) => {
85
- _.onBegin(panHandlers.begin).onFinalize(panHandlers.finish).withTestId("pan");
86
- },
87
- onGestureStart: panHandlers.start,
88
- onGestureUpdate: panHandlers.active,
89
- onGestureEnd: panHandlers.end,
90
- options: { enabled: true },
91
- });
92
-
93
- return (
94
- <GestureHandlerRootView>
95
- <GestureDetector gesture={Gesture.Race(tap, pan)}>
96
- <Text>v2 API test</Text>
97
- </GestureDetector>
98
- </GestureHandlerRootView>
99
- );
100
- }
101
-
102
- it("sends events to handlers", () => {
103
- const tapHandlers = mockedEventHandlers();
104
- const panHandlers = mockedEventHandlers();
105
- render(<RacingHandlers tapHandlers={tapHandlers} panHandlers={panHandlers} />);
106
-
107
- fireGestureHandler<PanGesture>(getByGestureTestId("pan"), [
108
- { state: State.BEGAN },
109
- { state: State.ACTIVE },
110
- { state: State.END },
111
- ]);
112
- expect(panHandlers.begin).toBeCalledWith(expect.objectContaining({ state: State.BEGAN }));
113
- expect(panHandlers.finish).toBeCalled();
114
- expect(tapHandlers.begin).not.toBeCalled();
115
- });
116
-
117
- it("sends events with additional data to handlers", () => {
118
- const panHandlers = mockedEventHandlers();
119
- const panHandlersFromUser = mockedEventHandlersFromUser();
120
- render(
121
- <SingleHandler
122
- handlers={panHandlers}
123
- handlersFromUser={panHandlersFromUser}
124
- treatStartAsUpdate
125
- />
126
- );
127
- fireGestureHandler<PanGesture>(getByGestureTestId("pan"), [
128
- { state: State.BEGAN, translationX: 0 },
129
- { state: State.ACTIVE, translationX: 10 },
130
- { translationX: 20 },
131
- { translationX: 20 },
132
- { state: State.END, translationX: 30 },
133
- ]);
134
-
135
- expect(panHandlersFromUser.begin).toBeCalledTimes(1);
136
- expect(panHandlersFromUser.active).toBeCalledTimes(2);
137
- expect(panHandlersFromUser.end).toBeCalledTimes(1);
138
-
139
- expect(panHandlers.active).toBeCalledTimes(3);
140
- expect(panHandlers.active).toHaveBeenLastCalledWith(
141
- expect.objectContaining({ translationX: 20 })
142
- );
143
- });
144
-
145
- it("does not include console.error in the output", () => {
146
- // if react-native-gesture-handler detects that some handlers are
147
- // workletized and some are not, it will log an error to the
148
- // console. We'd like to make sure that this doesn't happen.
149
-
150
- // The error that would be shown looks like:
151
- // [react-native-gesture-handler] Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.scheduleOnRN(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.
152
-
153
- const panHandlers = mockedEventHandlers();
154
- const panHandlersFromUser = mockedEventHandlersFromUser();
155
-
156
- jest.spyOn(console, "error");
157
-
158
- render(
159
- <SingleHandler
160
- handlers={panHandlers}
161
- handlersFromUser={panHandlersFromUser}
162
- treatStartAsUpdate
163
- />
164
- );
165
- fireGestureHandler<PanGesture>(getByGestureTestId("pan"), [
166
- { state: State.BEGAN },
167
- { state: State.ACTIVE },
168
- { state: State.END },
169
- ]);
170
-
171
- expect(console.error).not.toBeCalled();
172
- });
173
- });
174
-
175
- describe("Event list validation", () => {
176
- interface SingleHandlerProps {
177
- handlers: ReturnType<typeof mockedEventHandlers>;
178
- handlersFromUser: ReturnType<typeof mockedEventHandlers>;
179
- treatStartAsUpdate?: boolean;
180
- }
181
-
182
- function SingleHandler({ handlers, handlersFromUser, treatStartAsUpdate }: SingleHandlerProps) {
183
- const pan = usePanGestureProxy({
184
- onConfigurePanGesture: (_: PanGesture) => {
185
- _.onBegin(handlersFromUser.begin)
186
- .onUpdate(handlersFromUser.active)
187
- .onEnd(handlersFromUser.end)
188
- .onFinalize(handlers.finish)
189
- .withTestId("pan");
190
- },
191
- onGestureStart: treatStartAsUpdate ? handlers.active : handlers.start,
192
- onGestureUpdate: handlers.active,
193
- onGestureEnd: handlers.end,
194
- options: { enabled: true },
195
- });
196
-
197
- return (
198
- <GestureHandlerRootView>
199
- <GestureDetector gesture={pan}>
200
- <Text>v2 API test</Text>
201
- </GestureDetector>
202
- </GestureHandlerRootView>
203
- );
204
- }
205
-
206
- it("throws error when oldState doesn't correspond to previous event's state", () => {
207
- const panHandlers = mockedEventHandlers();
208
- const panHandlersFromUser = mockedEventHandlersFromUser();
209
- render(<SingleHandler handlers={panHandlers} handlersFromUser={panHandlersFromUser} />);
210
-
211
- expect(() => {
212
- fireGestureHandler<PanGesture>(getByGestureTestId("pan"), [
213
- { oldState: State.UNDETERMINED, state: State.BEGAN, x: 0, y: 10 },
214
- { oldState: State.UNDETERMINED, state: State.ACTIVE, x: 1, y: 11 },
215
- ]);
216
- }).toThrow("when state changes, oldState should be the same as previous event' state");
217
- });
218
-
219
- it.each([[State.END], [State.FAILED], [State.CANCELLED]])(
220
- "correctly handles events ending with state %s",
221
- (lastState) => {
222
- const panHandlers = mockedEventHandlers();
223
- const panHandlersFromUser = mockedEventHandlersFromUser();
224
- render(<SingleHandler handlers={panHandlers} handlersFromUser={panHandlersFromUser} />);
225
- fireGestureHandler<PanGesture>(getByGestureTestId("pan"), [
226
- { state: State.BEGAN },
227
- { state: State.ACTIVE },
228
- { state: lastState },
229
- ]);
230
-
231
- expect(panHandlersFromUser.begin).toBeCalledTimes(1);
232
- expect(panHandlersFromUser.active).toBeCalledTimes(0);
233
- expect(panHandlersFromUser.end).toBeCalledTimes(1);
234
-
235
- if (lastState === State.END) expect(panHandlers.end).toBeCalled();
236
- else expect(panHandlers.finish).toBeCalledWith(expect.any(Object), false);
237
- }
238
- );
239
- });
240
-
241
- describe("Filling event list with defaults", () => {
242
- interface RacingTapAndPanProps {
243
- handlers: ReturnType<typeof mockedEventHandlers>;
244
- treatStartAsUpdate?: boolean;
245
- }
246
-
247
- function RacingTapAndPan({ handlers, treatStartAsUpdate }: RacingTapAndPanProps) {
248
- const tap = Gesture.Tap().onBegin(handlers.begin).onEnd(handlers.end).withTestId("tap");
249
-
250
- const pan = usePanGestureProxy({
251
- onConfigurePanGesture: (_: PanGesture) => {
252
- _.onBegin(handlers.begin).onFinalize(handlers.finish).withTestId("pan");
253
- },
254
- onGestureStart: treatStartAsUpdate ? handlers.active : handlers.start,
255
- onGestureUpdate: handlers.active,
256
- onGestureEnd: handlers.end,
257
- options: { enabled: true },
258
- });
259
-
260
- return (
261
- <GestureHandlerRootView>
262
- <GestureDetector gesture={Gesture.Exclusive(pan, tap)}>
263
- <Text>v2 API test</Text>
264
- </GestureDetector>
265
- </GestureHandlerRootView>
266
- );
267
- }
268
-
269
- it("fills oldState if not passed", () => {
270
- const handlers = mockedEventHandlers();
271
- render(<RacingTapAndPan handlers={handlers} treatStartAsUpdate />);
272
- fireGestureHandler<PanGestureHandler>(getByGestureTestId("pan"), [
273
- { state: State.BEGAN },
274
- { state: State.ACTIVE },
275
- { state: State.ACTIVE },
276
- { state: State.ACTIVE },
277
- { state: State.END },
278
- ]);
279
-
280
- expect(handlers.begin).toBeCalledWith(
281
- expect.objectContaining({ oldState: State.UNDETERMINED })
282
- );
283
- expect(handlers.active).nthCalledWith(1, expect.objectContaining({ oldState: State.BEGAN }));
284
- expect(handlers.active).lastCalledWith(
285
- expect.not.objectContaining({ oldState: expect.anything() })
286
- );
287
- expect(handlers.end).toBeCalledWith(expect.objectContaining({ oldState: State.ACTIVE }), true);
288
- });
289
-
290
- it("fills missing ACTIVE states", () => {
291
- const panHandlers = mockedEventHandlers();
292
- render(<RacingTapAndPan handlers={panHandlers} treatStartAsUpdate />);
293
- fireGestureHandler<PanGesture>(getByGestureTestId("pan"), [
294
- { state: State.BEGAN, x: 0, y: 10 },
295
- { state: State.ACTIVE, x: 1, y: 11 },
296
- { x: 2, y: 12 },
297
- { x: 3, y: 13 },
298
- { state: State.END, x: 4, y: 14 },
299
- ]);
300
-
301
- expect(panHandlers.active).toBeCalledTimes(3);
302
- expect(panHandlers.active).toHaveBeenLastCalledWith(expect.objectContaining({ x: 3, y: 13 }));
303
- });
304
-
305
- it("fills BEGIN and END events for discrete handlers", () => {
306
- const handlers = mockedEventHandlers();
307
- render(<RacingTapAndPan handlers={handlers} treatStartAsUpdate />);
308
- fireGestureHandler<TapGesture>(getByGestureTestId("tap"), [{ x: 5 }]);
309
- expect(handlers.begin).toBeCalledTimes(1);
310
- expect(handlers.end).toBeCalledTimes(1);
311
- });
312
-
313
- it("with FAILED event, fills BEGIN event for discrete handlers", () => {
314
- const handlers = mockedEventHandlers();
315
- render(<RacingTapAndPan handlers={handlers} treatStartAsUpdate />);
316
- fireGestureHandler<TapGesture>(getByGestureTestId("tap"), [{ state: State.FAILED }]);
317
- expect(handlers.begin).toBeCalledTimes(1);
318
- expect(handlers.end).toBeCalledTimes(1);
319
- expect(handlers.end).toBeCalledWith(expect.anything(), false);
320
- });
321
-
322
- it("uses event data from first event in filled BEGIN, ACTIVE events", () => {
323
- const handlers = mockedEventHandlers();
324
- render(<RacingTapAndPan handlers={handlers} treatStartAsUpdate />);
325
- fireGestureHandler<PanGesture>(getByGestureTestId("pan"), [{ x: 120 }]);
326
- expect(handlers.begin).toBeCalledWith(expect.objectContaining({ x: 120 }));
327
- expect(handlers.active).toHaveBeenNthCalledWith(1, expect.objectContaining({ x: 120 }));
328
- });
329
-
330
- it("uses event data from last event in filled END events", () => {
331
- const handlers = mockedEventHandlers();
332
- render(<RacingTapAndPan handlers={handlers} treatStartAsUpdate />);
333
- fireGestureHandler<PanGesture>(getByGestureTestId("pan"), [{ x: 120, state: State.FAILED }]);
334
- expect(handlers.begin).toBeCalledTimes(1);
335
- expect(handlers.active).toBeCalledTimes(1);
336
- expect(handlers.end).toBeCalledWith(expect.objectContaining({ x: 120 }), false);
337
- });
338
-
339
- it("uses event data filled events", () => {
340
- const handlers = mockedEventHandlers();
341
- render(<RacingTapAndPan handlers={handlers} treatStartAsUpdate />);
342
- fireGestureHandler<PanGesture>(getByGestureTestId("pan"), [
343
- { x: 5, y: 15 },
344
- { x: 6, y: 16 },
345
- { x: 7, y: 17 },
346
- ]);
347
- expect(handlers.begin).toBeCalledWith(expect.objectContaining({ x: 5, y: 15 }));
348
- expect(handlers.active).toBeCalledTimes(3);
349
- expect(handlers.end).toBeCalledWith(expect.objectContaining({ x: 7, y: 17 }), true);
350
- });
351
-
352
- it("fills BEGIN and END events when they're not present, for discrete handlers", () => {
353
- const handlers = mockedEventHandlers();
354
- render(<RacingTapAndPan handlers={handlers} treatStartAsUpdate />);
355
- fireGestureHandler<TapGesture>(getByGestureTestId("tap"));
356
- expect(handlers.begin).toBeCalledTimes(1);
357
- expect(handlers.end).toHaveBeenCalledTimes(1);
358
- });
359
-
360
- it("fills BEGIN, ACTIVE and END events when they're not present, for continuous handlers", () => {
361
- const handlers = mockedEventHandlers();
362
- render(<RacingTapAndPan handlers={handlers} treatStartAsUpdate />);
363
- fireGestureHandler<PanGesture>(getByGestureTestId("pan"));
364
- expect(handlers.begin).toBeCalledTimes(1);
365
- expect(handlers.active).toBeCalledTimes(1);
366
- expect(handlers.end).toHaveBeenCalledTimes(1);
367
- });
368
- });
@@ -1,57 +0,0 @@
1
- import { renderHook } from "@testing-library/react-hooks";
2
-
3
- import { usePropsErrorBoundary } from "./usePropsErrorBoundary";
4
-
5
- import type { TCarouselProps } from "../types";
6
-
7
- function createProps(overrides: Partial<TCarouselProps<number>> = {}): TCarouselProps<number> & {
8
- dataLength: number;
9
- } {
10
- return {
11
- data: [0, 1, 2],
12
- dataLength: 3,
13
- renderItem: () => null,
14
- ...overrides,
15
- } as TCarouselProps<number> & { dataLength: number };
16
- }
17
-
18
- describe("usePropsErrorBoundary", () => {
19
- afterEach(() => {
20
- jest.restoreAllMocks();
21
- });
22
-
23
- it("accepts percentage and flex container sizing without contradictory warnings", () => {
24
- const warnSpy = jest.spyOn(console, "warn").mockImplementation(() => {});
25
-
26
- renderHook(() =>
27
- usePropsErrorBoundary(
28
- createProps({
29
- style: { width: "100%", height: 190 },
30
- itemWidth: 280,
31
- })
32
- )
33
- );
34
- renderHook(() =>
35
- usePropsErrorBoundary(
36
- createProps({
37
- vertical: true,
38
- style: { flex: 1 },
39
- itemHeight: 190,
40
- })
41
- )
42
- );
43
-
44
- expect(warnSpy).not.toHaveBeenCalledWith(expect.stringContaining("Horizontal mode"));
45
- expect(warnSpy).not.toHaveBeenCalledWith(expect.stringContaining("`itemWidth` sets"));
46
- expect(warnSpy).not.toHaveBeenCalledWith(expect.stringContaining("Vertical mode"));
47
- expect(warnSpy).not.toHaveBeenCalledWith(expect.stringContaining("`itemHeight` sets"));
48
-
49
- warnSpy.mockClear();
50
- renderHook(() => usePropsErrorBoundary(createProps({ style: { flex: 0, height: 190 } })));
51
- expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("Horizontal mode"));
52
-
53
- warnSpy.mockClear();
54
- renderHook(() => usePropsErrorBoundary(createProps({ vertical: true })));
55
- expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("Vertical mode"));
56
- });
57
- });
@@ -1,89 +0,0 @@
1
- import { renderHook } from "@testing-library/react-hooks";
2
-
3
- import { useUpdateGestureConfig } from "./useUpdateGestureConfig";
4
-
5
- describe("useUpdateGestureConfig", () => {
6
- const mockGesture = {
7
- enabled: jest.fn().mockReturnThis(),
8
- };
9
-
10
- beforeEach(() => {
11
- jest.clearAllMocks();
12
- });
13
-
14
- it("should update gesture enabled state", () => {
15
- renderHook(() =>
16
- useUpdateGestureConfig(mockGesture as any, {
17
- enabled: true,
18
- })
19
- );
20
-
21
- expect(mockGesture.enabled).toHaveBeenCalledWith(true);
22
- });
23
-
24
- it("should handle undefined enabled state", () => {
25
- renderHook(() => useUpdateGestureConfig(mockGesture as any, {}));
26
-
27
- expect(mockGesture.enabled).not.toHaveBeenCalled();
28
- });
29
-
30
- it("should update when enabled state changes", () => {
31
- const { rerender } = renderHook((props) => useUpdateGestureConfig(mockGesture as any, props), {
32
- initialProps: { enabled: true },
33
- });
34
-
35
- expect(mockGesture.enabled).toHaveBeenCalledWith(true);
36
-
37
- rerender({ enabled: false });
38
- expect(mockGesture.enabled).toHaveBeenCalledWith(false);
39
- });
40
-
41
- it("should not update when enabled state remains the same", () => {
42
- const { rerender } = renderHook((props) => useUpdateGestureConfig(mockGesture as any, props), {
43
- initialProps: { enabled: true },
44
- });
45
-
46
- mockGesture.enabled.mockClear();
47
-
48
- rerender({ enabled: true });
49
- expect(mockGesture.enabled).not.toHaveBeenCalled();
50
- });
51
-
52
- it("should handle gesture object changes", () => {
53
- const newMockGesture = {
54
- enabled: jest.fn().mockReturnThis(),
55
- };
56
-
57
- const { rerender } = renderHook(
58
- ({ gesture, config }) => useUpdateGestureConfig(gesture as any, config),
59
- {
60
- initialProps: {
61
- gesture: mockGesture,
62
- config: { enabled: true },
63
- },
64
- }
65
- );
66
-
67
- expect(mockGesture.enabled).toHaveBeenCalledWith(true);
68
-
69
- rerender({
70
- gesture: newMockGesture,
71
- config: { enabled: true },
72
- });
73
-
74
- expect(newMockGesture.enabled).toHaveBeenCalledWith(true);
75
- });
76
-
77
- it("should cleanup properly on unmount", () => {
78
- const { unmount } = renderHook(() =>
79
- useUpdateGestureConfig(mockGesture as any, {
80
- enabled: true,
81
- })
82
- );
83
-
84
- mockGesture.enabled.mockClear();
85
- unmount();
86
-
87
- expect(mockGesture.enabled).not.toHaveBeenCalled();
88
- });
89
- });