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.
- package/README.md +60 -28
- package/lib/commonjs/components/Carousel.js +1 -1
- package/lib/commonjs/components/Carousel.js.map +1 -1
- package/lib/commonjs/components/CarouselLayout.js +1 -1
- package/lib/commonjs/components/CarouselLayout.js.map +1 -1
- package/lib/commonjs/components/ItemLayout.js +1 -1
- package/lib/commonjs/components/ItemLayout.js.map +1 -1
- package/lib/commonjs/components/ItemRenderer.js +1 -1
- package/lib/commonjs/components/ItemRenderer.js.map +1 -1
- package/lib/commonjs/components/Pagination/PaginationItem.js +2 -0
- package/lib/commonjs/components/Pagination/PaginationItem.js.map +1 -0
- package/lib/commonjs/components/Pagination/index.js +1 -1
- package/lib/commonjs/components/Pagination/index.js.map +1 -1
- package/lib/commonjs/components/ScrollViewGesture.js +1 -1
- package/lib/commonjs/components/ScrollViewGesture.js.map +1 -1
- package/lib/commonjs/hooks/useAutoPlay.js +1 -1
- package/lib/commonjs/hooks/useAutoPlay.js.map +1 -1
- package/lib/commonjs/hooks/useCarouselController.js +1 -1
- package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js.map +1 -1
- package/lib/commonjs/hooks/useInitProps.js +1 -1
- package/lib/commonjs/hooks/useInitProps.js.map +1 -1
- package/lib/commonjs/hooks/useLayoutConfig.js +1 -1
- package/lib/commonjs/hooks/useLayoutConfig.js.map +1 -1
- package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
- package/lib/commonjs/hooks/usePanGestureProxy.js.map +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/commonjs/hooks/useUpdateGestureConfig.js.map +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layouts/index.js.map +1 -1
- package/lib/commonjs/layouts/normal.js +1 -1
- package/lib/commonjs/layouts/normal.js.map +1 -1
- package/lib/commonjs/layouts/parallax.js +1 -1
- package/lib/commonjs/layouts/parallax.js.map +1 -1
- package/lib/commonjs/layouts/stack.js +1 -1
- package/lib/commonjs/layouts/stack.js.map +1 -1
- package/lib/commonjs/public-types.js +2 -0
- package/lib/commonjs/public-types.js.map +1 -0
- package/lib/commonjs/store/index.js.map +1 -1
- package/lib/commonjs/utils/carousel-direction.js +2 -0
- package/lib/commonjs/utils/carousel-direction.js.map +1 -0
- package/lib/commonjs/utils/carousel-math.js +2 -0
- package/lib/commonjs/utils/carousel-math.js.map +1 -0
- package/lib/commonjs/utils/deal-with-animation.js +1 -1
- package/lib/commonjs/utils/deal-with-animation.js.map +1 -1
- package/lib/module/components/Carousel.js +1 -1
- package/lib/module/components/Carousel.js.map +1 -1
- package/lib/module/components/CarouselLayout.js +1 -1
- package/lib/module/components/CarouselLayout.js.map +1 -1
- package/lib/module/components/ItemLayout.js +1 -1
- package/lib/module/components/ItemLayout.js.map +1 -1
- package/lib/module/components/ItemRenderer.js +1 -1
- package/lib/module/components/ItemRenderer.js.map +1 -1
- package/lib/module/components/LazyView.js +1 -1
- package/lib/module/components/LazyView.js.map +1 -1
- package/lib/module/components/Pagination/PaginationItem.js +2 -0
- package/lib/module/components/Pagination/PaginationItem.js.map +1 -0
- package/lib/module/components/Pagination/index.js +1 -1
- package/lib/module/components/Pagination/index.js.map +1 -1
- package/lib/module/components/ScrollViewGesture.js +1 -1
- package/lib/module/components/ScrollViewGesture.js.map +1 -1
- package/lib/module/constants/index.js +1 -1
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/hooks/useAutoPlay.js +1 -1
- package/lib/module/hooks/useAutoPlay.js.map +1 -1
- package/lib/module/hooks/useCarouselController.js +1 -1
- package/lib/module/hooks/useCarouselController.js.map +1 -1
- package/lib/module/hooks/useCheckMounted.js +1 -1
- package/lib/module/hooks/useCheckMounted.js.map +1 -1
- package/lib/module/hooks/useCommonVariables.js +1 -1
- package/lib/module/hooks/useCommonVariables.js.map +1 -1
- package/lib/module/hooks/useInitProps.js +1 -1
- package/lib/module/hooks/useInitProps.js.map +1 -1
- package/lib/module/hooks/useLayoutConfig.js +1 -1
- package/lib/module/hooks/useLayoutConfig.js.map +1 -1
- package/lib/module/hooks/useOffsetX.js +1 -1
- package/lib/module/hooks/useOffsetX.js.map +1 -1
- package/lib/module/hooks/useOnProgressChange.js +1 -1
- package/lib/module/hooks/useOnProgressChange.js.map +1 -1
- package/lib/module/hooks/usePanGestureProxy.js +1 -1
- package/lib/module/hooks/usePanGestureProxy.js.map +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/module/hooks/useUpdateGestureConfig.js +1 -1
- package/lib/module/hooks/useUpdateGestureConfig.js.map +1 -1
- package/lib/module/hooks/useVisibleRanges.js +1 -1
- package/lib/module/hooks/useVisibleRanges.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layouts/index.js +1 -1
- package/lib/module/layouts/index.js.map +1 -1
- package/lib/module/layouts/normal.js +1 -1
- package/lib/module/layouts/normal.js.map +1 -1
- package/lib/module/layouts/parallax.js +1 -1
- package/lib/module/layouts/parallax.js.map +1 -1
- package/lib/module/layouts/stack.js +1 -1
- package/lib/module/layouts/stack.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/public-types.js +2 -0
- package/lib/module/public-types.js.map +1 -0
- package/lib/module/store/index.js +1 -1
- package/lib/module/store/index.js.map +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/utils/carousel-direction.js +2 -0
- package/lib/module/utils/carousel-direction.js.map +1 -0
- package/lib/module/utils/carousel-math.js +2 -0
- package/lib/module/utils/carousel-math.js.map +1 -0
- package/lib/module/utils/compute-gesture-translation.js +1 -1
- package/lib/module/utils/compute-gesture-translation.js.map +1 -1
- package/lib/module/utils/compute-offset-if-size-changed.js +1 -1
- package/lib/module/utils/compute-offset-if-size-changed.js.map +1 -1
- package/lib/module/utils/computed-with-auto-fill-data.js +1 -1
- package/lib/module/utils/computed-with-auto-fill-data.js.map +1 -1
- package/lib/module/utils/deal-with-animation.js +1 -1
- package/lib/module/utils/deal-with-animation.js.map +1 -1
- package/lib/module/utils/log.js +1 -1
- package/lib/module/utils/log.js.map +1 -1
- package/lib/module/utils/sanitize-animation-style.js +1 -1
- package/lib/module/utils/sanitize-animation-style.js.map +1 -1
- package/lib/typescript/commonjs/components/Carousel.d.ts +8 -0
- package/lib/typescript/commonjs/components/Carousel.d.ts.map +1 -0
- package/lib/typescript/{components → commonjs/components}/CarouselLayout.d.ts +5 -8
- package/lib/typescript/commonjs/components/CarouselLayout.d.ts.map +1 -0
- package/lib/typescript/{components → commonjs/components}/ItemLayout.d.ts +7 -6
- package/lib/typescript/commonjs/components/ItemLayout.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/ItemRenderer.d.ts +24 -0
- package/lib/typescript/commonjs/components/ItemRenderer.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/LazyView.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts +14 -0
- package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Pagination/index.d.ts +4 -0
- package/lib/typescript/commonjs/components/Pagination/index.d.ts.map +1 -0
- package/lib/typescript/{components → commonjs/components}/ScrollViewGesture.d.ts +3 -4
- package/lib/typescript/commonjs/components/ScrollViewGesture.d.ts.map +1 -0
- package/lib/typescript/commonjs/constants/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts +12 -0
- package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCarouselController.d.ts +29 -0
- package/lib/typescript/commonjs/hooks/useCarouselController.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCheckMounted.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts +18 -0
- package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useInitProps.d.ts +25 -0
- package/lib/typescript/commonjs/hooks/useInitProps.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts +8 -0
- package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useOffsetX.d.ts +13 -0
- package/lib/typescript/commonjs/hooks/useOffsetX.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts +12 -0
- package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts.map +1 -0
- package/lib/typescript/{hooks → commonjs/hooks}/usePanGestureProxy.d.ts +3 -2
- package/lib/typescript/commonjs/hooks/usePanGestureProxy.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts +3 -0
- package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts +9 -0
- package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts.map +1 -0
- package/lib/typescript/{hooks → commonjs/hooks}/useVisibleRanges.d.ts +2 -2
- package/lib/typescript/commonjs/hooks/useVisibleRanges.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +4 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/{layouts → commonjs/layouts}/index.d.ts +0 -1
- package/lib/typescript/commonjs/layouts/index.d.ts.map +1 -0
- package/lib/typescript/{layouts → commonjs/layouts}/normal.d.ts +3 -1
- package/lib/typescript/commonjs/layouts/normal.d.ts.map +1 -0
- package/lib/typescript/commonjs/layouts/parallax.d.ts +27 -0
- package/lib/typescript/commonjs/layouts/parallax.d.ts.map +1 -0
- package/lib/typescript/commonjs/layouts/stack.d.ts +10 -0
- package/lib/typescript/commonjs/layouts/stack.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/public-types.d.ts +161 -0
- package/lib/typescript/commonjs/public-types.d.ts.map +1 -0
- package/lib/typescript/{store → commonjs/store}/index.d.ts +8 -8
- package/lib/typescript/commonjs/store/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +15 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/carousel-direction.d.ts +9 -0
- package/lib/typescript/commonjs/utils/carousel-direction.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/carousel-math.d.ts +28 -0
- package/lib/typescript/commonjs/utils/carousel-math.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/compute-gesture-translation.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/compute-offset-if-size-changed.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/computed-with-auto-fill-data.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/deal-with-animation.d.ts +3 -0
- package/lib/typescript/commonjs/utils/deal-with-animation.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/log.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/sanitize-animation-style.d.ts.map +1 -0
- package/lib/typescript/module/components/Carousel.d.ts +8 -0
- package/lib/typescript/module/components/Carousel.d.ts.map +1 -0
- package/lib/typescript/module/components/CarouselLayout.d.ts +14 -0
- package/lib/typescript/module/components/CarouselLayout.d.ts.map +1 -0
- package/lib/typescript/module/components/ItemLayout.d.ts +21 -0
- package/lib/typescript/module/components/ItemLayout.d.ts.map +1 -0
- package/lib/typescript/module/components/ItemRenderer.d.ts +24 -0
- package/lib/typescript/module/components/ItemRenderer.d.ts.map +1 -0
- package/lib/typescript/module/components/LazyView.d.ts +8 -0
- package/lib/typescript/module/components/LazyView.d.ts.map +1 -0
- package/lib/typescript/module/components/Pagination/PaginationItem.d.ts +14 -0
- package/lib/typescript/module/components/Pagination/PaginationItem.d.ts.map +1 -0
- package/lib/typescript/module/components/Pagination/index.d.ts +4 -0
- package/lib/typescript/module/components/Pagination/index.d.ts.map +1 -0
- package/lib/typescript/module/components/ScrollViewGesture.d.ts +18 -0
- package/lib/typescript/module/components/ScrollViewGesture.d.ts.map +1 -0
- package/lib/typescript/module/constants/index.d.ts +9 -0
- package/lib/typescript/module/constants/index.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useAutoPlay.d.ts +12 -0
- package/lib/typescript/module/hooks/useAutoPlay.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCarouselController.d.ts +29 -0
- package/lib/typescript/module/hooks/useCarouselController.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCheckMounted.d.ts +3 -0
- package/lib/typescript/module/hooks/useCheckMounted.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCommonVariables.d.ts +18 -0
- package/lib/typescript/module/hooks/useCommonVariables.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useInitProps.d.ts +25 -0
- package/lib/typescript/module/hooks/useInitProps.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useLayoutConfig.d.ts +8 -0
- package/lib/typescript/module/hooks/useLayoutConfig.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useOffsetX.d.ts +13 -0
- package/lib/typescript/module/hooks/useOffsetX.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useOnProgressChange.d.ts +12 -0
- package/lib/typescript/module/hooks/useOnProgressChange.d.ts.map +1 -0
- package/lib/typescript/module/hooks/usePanGestureProxy.d.ts +11 -0
- package/lib/typescript/module/hooks/usePanGestureProxy.d.ts.map +1 -0
- package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts +3 -0
- package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts +9 -0
- package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useVisibleRanges.d.ts +22 -0
- package/lib/typescript/module/hooks/useVisibleRanges.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +4 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/layouts/index.d.ts +10 -0
- package/lib/typescript/module/layouts/index.d.ts.map +1 -0
- package/lib/typescript/module/layouts/normal.d.ts +15 -0
- package/lib/typescript/module/layouts/normal.d.ts.map +1 -0
- package/lib/typescript/module/layouts/parallax.d.ts +27 -0
- package/lib/typescript/module/layouts/parallax.d.ts.map +1 -0
- package/lib/typescript/module/layouts/stack.d.ts +10 -0
- package/lib/typescript/module/layouts/stack.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/public-types.d.ts +161 -0
- package/lib/typescript/module/public-types.d.ts.map +1 -0
- package/lib/typescript/module/store/index.d.ts +35 -0
- package/lib/typescript/module/store/index.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +15 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/lib/typescript/module/utils/carousel-direction.d.ts +9 -0
- package/lib/typescript/module/utils/carousel-direction.d.ts.map +1 -0
- package/lib/typescript/module/utils/carousel-math.d.ts +28 -0
- package/lib/typescript/module/utils/carousel-math.d.ts.map +1 -0
- package/lib/typescript/module/utils/compute-gesture-translation.d.ts +9 -0
- package/lib/typescript/module/utils/compute-gesture-translation.d.ts.map +1 -0
- package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts +6 -0
- package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts.map +1 -0
- package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts +23 -0
- package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts.map +1 -0
- package/lib/typescript/module/utils/deal-with-animation.d.ts +3 -0
- package/lib/typescript/module/utils/deal-with-animation.d.ts.map +1 -0
- package/lib/typescript/module/utils/log.d.ts +7 -0
- package/lib/typescript/module/utils/log.d.ts.map +1 -0
- package/lib/typescript/module/utils/sanitize-animation-style.d.ts +3 -0
- package/lib/typescript/module/utils/sanitize-animation-style.d.ts.map +1 -0
- package/package.json +34 -7
- package/scripts/codemods/v5.mjs +502 -0
- package/src/components/Carousel.tsx +5 -5
- package/src/components/CarouselLayout.tsx +53 -91
- package/src/components/ItemLayout.tsx +55 -46
- package/src/components/ItemRenderer.tsx +29 -18
- package/src/components/Pagination/PaginationItem.tsx +162 -0
- package/src/components/Pagination/index.tsx +105 -6
- package/src/components/ScrollViewGesture.tsx +92 -177
- package/src/hooks/useAutoPlay.ts +23 -18
- package/src/hooks/useCarouselController.tsx +194 -340
- package/src/hooks/useCommonVariables.ts +159 -71
- package/src/hooks/useInitProps.ts +161 -71
- package/src/hooks/useLayoutConfig.ts +21 -12
- package/src/hooks/useOffsetX.ts +3 -3
- package/src/hooks/useOnProgressChange.ts +23 -48
- package/src/hooks/usePanGestureProxy.ts +2 -2
- package/src/hooks/usePropsErrorBoundary.ts +32 -90
- package/src/hooks/useUpdateGestureConfig.ts +5 -2
- package/src/hooks/useVisibleRanges.tsx +2 -2
- package/src/index.tsx +14 -9
- package/src/layouts/index.tsx +0 -2
- package/src/layouts/normal.ts +14 -4
- package/src/layouts/parallax.ts +32 -59
- package/src/layouts/stack.ts +30 -70
- package/src/public-types.ts +198 -0
- package/src/store/index.tsx +7 -7
- package/src/types.ts +30 -322
- package/src/utils/carousel-direction.ts +39 -0
- package/src/utils/carousel-math.ts +156 -0
- package/src/utils/deal-with-animation.ts +11 -9
- package/lib/commonjs/components/Pagination/Basic/PaginationItem.js +0 -2
- package/lib/commonjs/components/Pagination/Basic/PaginationItem.js.map +0 -1
- package/lib/commonjs/components/Pagination/Basic/index.js +0 -2
- package/lib/commonjs/components/Pagination/Basic/index.js.map +0 -1
- package/lib/commonjs/components/Pagination/Custom/PaginationItem.js +0 -2
- package/lib/commonjs/components/Pagination/Custom/PaginationItem.js.map +0 -1
- package/lib/commonjs/components/Pagination/Custom/index.js +0 -2
- package/lib/commonjs/components/Pagination/Custom/index.js.map +0 -1
- package/lib/commonjs/utils/compute-offset-if-data-changed.js +0 -2
- package/lib/commonjs/utils/compute-offset-if-data-changed.js.map +0 -1
- package/lib/commonjs/utils/handleroffset-direction.js +0 -2
- package/lib/commonjs/utils/handleroffset-direction.js.map +0 -1
- package/lib/module/components/Pagination/Basic/PaginationItem.js +0 -2
- package/lib/module/components/Pagination/Basic/PaginationItem.js.map +0 -1
- package/lib/module/components/Pagination/Basic/index.js +0 -2
- package/lib/module/components/Pagination/Basic/index.js.map +0 -1
- package/lib/module/components/Pagination/Custom/PaginationItem.js +0 -2
- package/lib/module/components/Pagination/Custom/PaginationItem.js.map +0 -1
- package/lib/module/components/Pagination/Custom/index.js +0 -2
- package/lib/module/components/Pagination/Custom/index.js.map +0 -1
- package/lib/module/utils/compute-offset-if-data-changed.js +0 -2
- package/lib/module/utils/compute-offset-if-data-changed.js.map +0 -1
- package/lib/module/utils/handleroffset-direction.js +0 -2
- package/lib/module/utils/handleroffset-direction.js.map +0 -1
- package/lib/typescript/components/Carousel.d.ts +0 -8
- package/lib/typescript/components/Carousel.d.ts.map +0 -1
- package/lib/typescript/components/CarouselLayout.d.ts.map +0 -1
- package/lib/typescript/components/ItemLayout.d.ts.map +0 -1
- package/lib/typescript/components/ItemRenderer.d.ts +0 -23
- package/lib/typescript/components/ItemRenderer.d.ts.map +0 -1
- package/lib/typescript/components/LazyView.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts +0 -29
- package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Basic/index.d.ts +0 -23
- package/lib/typescript/components/Pagination/Basic/index.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts +0 -35
- package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Custom/index.d.ts +0 -26
- package/lib/typescript/components/Pagination/Custom/index.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/index.d.ts +0 -5
- package/lib/typescript/components/Pagination/index.d.ts.map +0 -1
- package/lib/typescript/components/ScrollViewGesture.d.ts.map +0 -1
- package/lib/typescript/constants/index.d.ts.map +0 -1
- package/lib/typescript/hooks/useAutoPlay.d.ts +0 -12
- package/lib/typescript/hooks/useAutoPlay.d.ts.map +0 -1
- package/lib/typescript/hooks/useCarouselController.d.ts +0 -28
- package/lib/typescript/hooks/useCarouselController.d.ts.map +0 -1
- package/lib/typescript/hooks/useCheckMounted.d.ts.map +0 -1
- package/lib/typescript/hooks/useCommonVariables.d.ts +0 -13
- package/lib/typescript/hooks/useCommonVariables.d.ts.map +0 -1
- package/lib/typescript/hooks/useInitProps.d.ts +0 -10
- package/lib/typescript/hooks/useInitProps.d.ts.map +0 -1
- package/lib/typescript/hooks/useLayoutConfig.d.ts +0 -8
- package/lib/typescript/hooks/useLayoutConfig.d.ts.map +0 -1
- package/lib/typescript/hooks/useOffsetX.d.ts +0 -13
- package/lib/typescript/hooks/useOffsetX.d.ts.map +0 -1
- package/lib/typescript/hooks/useOnProgressChange.d.ts +0 -11
- package/lib/typescript/hooks/useOnProgressChange.d.ts.map +0 -1
- package/lib/typescript/hooks/usePanGestureProxy.d.ts.map +0 -1
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +0 -5
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts.map +0 -1
- package/lib/typescript/hooks/useUpdateGestureConfig.d.ts +0 -6
- package/lib/typescript/hooks/useUpdateGestureConfig.d.ts.map +0 -1
- package/lib/typescript/hooks/useVisibleRanges.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -7
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/layouts/index.d.ts.map +0 -1
- package/lib/typescript/layouts/normal.d.ts.map +0 -1
- package/lib/typescript/layouts/parallax.d.ts +0 -47
- package/lib/typescript/layouts/parallax.d.ts.map +0 -1
- package/lib/typescript/layouts/stack.d.ts +0 -38
- package/lib/typescript/layouts/stack.d.ts.map +0 -1
- package/lib/typescript/store/index.d.ts.map +0 -1
- package/lib/typescript/types.d.ts +0 -302
- package/lib/typescript/types.d.ts.map +0 -1
- package/lib/typescript/utils/compute-gesture-translation.d.ts.map +0 -1
- package/lib/typescript/utils/compute-offset-if-data-changed.d.ts +0 -9
- package/lib/typescript/utils/compute-offset-if-data-changed.d.ts.map +0 -1
- package/lib/typescript/utils/compute-offset-if-size-changed.d.ts.map +0 -1
- package/lib/typescript/utils/computed-with-auto-fill-data.d.ts.map +0 -1
- package/lib/typescript/utils/deal-with-animation.d.ts +0 -3
- package/lib/typescript/utils/deal-with-animation.d.ts.map +0 -1
- package/lib/typescript/utils/handleroffset-direction.d.ts +0 -4
- package/lib/typescript/utils/handleroffset-direction.d.ts.map +0 -1
- package/lib/typescript/utils/log.d.ts.map +0 -1
- package/lib/typescript/utils/sanitize-animation-style.d.ts.map +0 -1
- package/src/components/Carousel.test.tsx +0 -1215
- package/src/components/LazyView.test.tsx +0 -61
- package/src/components/Pagination/Basic/PaginationItem.tsx +0 -149
- package/src/components/Pagination/Basic/index.tsx +0 -98
- package/src/components/Pagination/Custom/PaginationItem.tsx +0 -166
- package/src/components/Pagination/Custom/index.tsx +0 -111
- package/src/components/Pagination/Pagination.test.tsx +0 -178
- package/src/components/ScrollViewGesture.test.tsx +0 -155
- package/src/components/issue-899-parallax-reverse-loop.test.tsx +0 -131
- package/src/components/rnr-demo.test.tsx +0 -53
- package/src/hooks/useAutoPlay.test.ts +0 -194
- package/src/hooks/useCarouselController.test.tsx +0 -1158
- package/src/hooks/useCheckMounted.test.ts +0 -47
- package/src/hooks/useCommonVariables.test.tsx +0 -384
- package/src/hooks/useInitProps.test.tsx +0 -134
- package/src/hooks/useLayoutConfig.test.tsx +0 -247
- package/src/hooks/useOffsetX.test.ts +0 -54
- package/src/hooks/useOnProgressChange.test.tsx +0 -270
- package/src/hooks/usePanGestureProxy.test.tsx +0 -368
- package/src/hooks/usePropsErrorBoundary.test.tsx +0 -57
- package/src/hooks/useUpdateGestureConfig.test.ts +0 -89
- package/src/hooks/useVisibleRanges.test.tsx +0 -347
- package/src/layouts/parallax.test.ts +0 -239
- package/src/layouts/stack.test.ts +0 -252
- package/src/store/index.test.tsx +0 -314
- package/src/utils/compute-gesture-translation.test.ts +0 -70
- package/src/utils/compute-offset-if-data-changed.test.ts +0 -133
- package/src/utils/compute-offset-if-data-changed.ts +0 -44
- package/src/utils/compute-offset-if-size-changed.test.ts +0 -78
- package/src/utils/computed-with-auto-fill-data.test.ts +0 -298
- package/src/utils/deal-with-animation.test.ts +0 -181
- package/src/utils/handleroffset-direction.test.ts +0 -124
- package/src/utils/handleroffset-direction.ts +0 -18
- package/src/utils/index.test.ts +0 -90
- package/src/utils/log.test.ts +0 -134
- package/src/utils/sanitize-animation-style.test.ts +0 -40
- /package/lib/typescript/{components → commonjs/components}/LazyView.d.ts +0 -0
- /package/lib/typescript/{constants → commonjs/constants}/index.d.ts +0 -0
- /package/lib/typescript/{hooks → commonjs/hooks}/useCheckMounted.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/compute-gesture-translation.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/compute-offset-if-size-changed.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/computed-with-auto-fill-data.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/log.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/sanitize-animation-style.d.ts +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { renderHook } from "@testing-library/react-hooks";
|
|
2
|
-
|
|
3
|
-
import { useCheckMounted } from "./useCheckMounted";
|
|
4
|
-
|
|
5
|
-
describe("useCheckMounted", () => {
|
|
6
|
-
it("should be mounted after initialization", () => {
|
|
7
|
-
const { result } = renderHook(() => useCheckMounted());
|
|
8
|
-
|
|
9
|
-
expect(result.current.current).toBe(true);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("should be unmounted after cleanup", () => {
|
|
13
|
-
const { result, unmount } = renderHook(() => useCheckMounted());
|
|
14
|
-
|
|
15
|
-
expect(result.current.current).toBe(true);
|
|
16
|
-
|
|
17
|
-
unmount();
|
|
18
|
-
|
|
19
|
-
expect(result.current.current).toBe(false);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("should maintain mounted state during component lifecycle", () => {
|
|
23
|
-
const { result, rerender } = renderHook(() => useCheckMounted());
|
|
24
|
-
|
|
25
|
-
expect(result.current.current).toBe(true);
|
|
26
|
-
|
|
27
|
-
rerender();
|
|
28
|
-
|
|
29
|
-
expect(result.current.current).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("should handle multiple mount/unmount cycles", () => {
|
|
33
|
-
// First instance
|
|
34
|
-
const hook1 = renderHook(() => useCheckMounted());
|
|
35
|
-
expect(hook1.result.current.current).toBe(true);
|
|
36
|
-
|
|
37
|
-
hook1.unmount();
|
|
38
|
-
expect(hook1.result.current.current).toBe(false);
|
|
39
|
-
|
|
40
|
-
// Second instance
|
|
41
|
-
const hook2 = renderHook(() => useCheckMounted());
|
|
42
|
-
expect(hook2.result.current.current).toBe(true);
|
|
43
|
-
|
|
44
|
-
hook2.unmount();
|
|
45
|
-
expect(hook2.result.current.current).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
import { act, renderHook } from "@testing-library/react-hooks";
|
|
2
|
-
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
-
import { SharedValue, useSharedValue } from "react-native-reanimated";
|
|
4
|
-
|
|
5
|
-
import { useCommonVariables } from "./useCommonVariables";
|
|
6
|
-
import type { TInitializeCarouselProps } from "./useInitProps";
|
|
7
|
-
|
|
8
|
-
function createBaseProps(
|
|
9
|
-
overrides: Partial<TInitializeCarouselProps<any>> = {}
|
|
10
|
-
): TInitializeCarouselProps<any> {
|
|
11
|
-
return {
|
|
12
|
-
defaultIndex: 0,
|
|
13
|
-
loop: true,
|
|
14
|
-
scrollAnimationDuration: 500,
|
|
15
|
-
autoFillData: true,
|
|
16
|
-
autoPlayInterval: 2000,
|
|
17
|
-
autoPlay: false,
|
|
18
|
-
data: [0, 1, 2, 3],
|
|
19
|
-
dataLength: 4,
|
|
20
|
-
rawData: [0, 1, 2, 3],
|
|
21
|
-
rawDataLength: 4,
|
|
22
|
-
vertical: false,
|
|
23
|
-
style: { width: 700, height: 350 } as StyleProp<ViewStyle>,
|
|
24
|
-
renderItem: () => null,
|
|
25
|
-
pagingEnabled: true,
|
|
26
|
-
enabled: true,
|
|
27
|
-
overscrollEnabled: true,
|
|
28
|
-
snapEnabled: true,
|
|
29
|
-
testID: "carousel",
|
|
30
|
-
...overrides,
|
|
31
|
-
} as TInitializeCarouselProps<any>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
describe("useCommonVariables", () => {
|
|
35
|
-
it("returns expected values when style provides width", () => {
|
|
36
|
-
const props = createBaseProps();
|
|
37
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
38
|
-
|
|
39
|
-
expect(result.current.size).toBe(700);
|
|
40
|
-
expect(result.current.validLength).toBe(3);
|
|
41
|
-
expect(result.current.handlerOffset.value).toBeCloseTo(0);
|
|
42
|
-
expect(result.current.resolvedSize.value).toBe(700);
|
|
43
|
-
expect(result.current.sizePhase.value).toBe("ready");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("uses style.height as size when vertical", () => {
|
|
47
|
-
const props = createBaseProps({ vertical: true, style: { height: 360 } });
|
|
48
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
49
|
-
|
|
50
|
-
expect(result.current.size).toBe(360);
|
|
51
|
-
expect(result.current.resolvedSize.value).toBe(360);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("initializes handlerOffset when defaultIndex is non-zero", () => {
|
|
55
|
-
const props = createBaseProps({ defaultIndex: 2 });
|
|
56
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
57
|
-
|
|
58
|
-
expect(result.current.handlerOffset.value).toBe(-1400);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("respects custom defaultScrollOffsetValue", () => {
|
|
62
|
-
let shared!: SharedValue<number>;
|
|
63
|
-
const { result } = renderHook(() => {
|
|
64
|
-
shared = useSharedValue(-500);
|
|
65
|
-
const props = createBaseProps({ defaultScrollOffsetValue: shared });
|
|
66
|
-
return useCommonVariables(props);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
expect(result.current.handlerOffset).toBe(shared);
|
|
70
|
-
expect(result.current.handlerOffset.value).toBe(-500);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("sets validLength to 0 when dataLength is 1", () => {
|
|
74
|
-
const props = createBaseProps({ dataLength: 1, data: [0] });
|
|
75
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
76
|
-
|
|
77
|
-
expect(result.current.validLength).toBe(0);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("sets validLength to -1 when dataLength is 0", () => {
|
|
81
|
-
const props = createBaseProps({ dataLength: 0, data: [] });
|
|
82
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
83
|
-
|
|
84
|
-
expect(result.current.validLength).toBe(-1);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("handles negative defaultIndex", () => {
|
|
88
|
-
const props = createBaseProps({ defaultIndex: -1 });
|
|
89
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
90
|
-
|
|
91
|
-
expect(result.current.handlerOffset.value).toBe(-700);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("keeps size calculation when loop is disabled", () => {
|
|
95
|
-
const props = createBaseProps({ loop: false });
|
|
96
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
97
|
-
|
|
98
|
-
expect(result.current.size).toBe(700);
|
|
99
|
-
expect(result.current.validLength).toBe(3);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("syncs resolvedSize when style width changes", () => {
|
|
103
|
-
const initial = createBaseProps();
|
|
104
|
-
const hook = renderHook(({ p }) => useCommonVariables(p), { initialProps: { p: initial } });
|
|
105
|
-
expect(hook.result.current.resolvedSize.value).toBe(700);
|
|
106
|
-
|
|
107
|
-
const updated = createBaseProps({ style: { width: 800 } });
|
|
108
|
-
act(() => {
|
|
109
|
-
hook.rerender({ p: updated });
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
expect(hook.result.current.resolvedSize.value).toBe(800);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("updates validLength when dataLength changes", () => {
|
|
116
|
-
const hook = renderHook(({ p }) => useCommonVariables(p), {
|
|
117
|
-
initialProps: { p: createBaseProps() },
|
|
118
|
-
});
|
|
119
|
-
expect(hook.result.current.validLength).toBe(3);
|
|
120
|
-
|
|
121
|
-
act(() => {
|
|
122
|
-
hook.rerender({ p: createBaseProps({ dataLength: 6, data: [0, 1, 2, 3, 4, 5] }) });
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
expect(hook.result.current.validLength).toBe(5);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("remains pending when style lacks numeric size", () => {
|
|
129
|
-
const props = createBaseProps({ style: { width: "100%" } });
|
|
130
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
131
|
-
|
|
132
|
-
expect(result.current.size).toBe(0);
|
|
133
|
-
expect(result.current.resolvedSize.value).toBeNull();
|
|
134
|
-
expect(result.current.sizePhase.value).toBe("pending");
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("keeps handlerOffset at zero when width is 0", () => {
|
|
138
|
-
const props = createBaseProps({ style: { width: 0 } });
|
|
139
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
140
|
-
|
|
141
|
-
expect(result.current.size).toBe(0);
|
|
142
|
-
expect(result.current.handlerOffset.value).toBeCloseTo(0);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("handles large defaultIndex values", () => {
|
|
146
|
-
const props = createBaseProps({ defaultIndex: 10 });
|
|
147
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
148
|
-
|
|
149
|
-
expect(result.current.handlerOffset.value).toBe(-7000);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it("returns zero size when vertical height is 0", () => {
|
|
153
|
-
const props = createBaseProps({ vertical: true, style: { height: 0 } });
|
|
154
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
155
|
-
|
|
156
|
-
expect(result.current.size).toBe(0);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it("accepts floating point dimensions", () => {
|
|
160
|
-
const props = createBaseProps({ style: { width: 700.5 } });
|
|
161
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
162
|
-
|
|
163
|
-
expect(result.current.size).toBe(700.5);
|
|
164
|
-
expect(result.current.resolvedSize.value).toBe(700.5);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it("stays pending when only height is provided", () => {
|
|
168
|
-
const props = createBaseProps({ style: { height: 200 } });
|
|
169
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
170
|
-
|
|
171
|
-
expect(result.current.size).toBe(0);
|
|
172
|
-
expect(result.current.sizePhase.value).toBe("pending");
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
describe("itemWidth/itemHeight props", () => {
|
|
176
|
-
it("uses itemWidth for horizontal carousel size when provided", () => {
|
|
177
|
-
const props = createBaseProps({
|
|
178
|
-
style: { width: 700, height: 350 },
|
|
179
|
-
itemWidth: 350,
|
|
180
|
-
});
|
|
181
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
182
|
-
|
|
183
|
-
expect(result.current.size).toBe(350);
|
|
184
|
-
expect(result.current.resolvedSize.value).toBe(350);
|
|
185
|
-
expect(result.current.sizePhase.value).toBe("ready");
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it("uses itemHeight for vertical carousel size when provided", () => {
|
|
189
|
-
const props = createBaseProps({
|
|
190
|
-
vertical: true,
|
|
191
|
-
style: { width: 700, height: 350 },
|
|
192
|
-
itemHeight: 200,
|
|
193
|
-
});
|
|
194
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
195
|
-
|
|
196
|
-
expect(result.current.size).toBe(200);
|
|
197
|
-
expect(result.current.resolvedSize.value).toBe(200);
|
|
198
|
-
expect(result.current.sizePhase.value).toBe("ready");
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it("prioritizes itemWidth over style.width for horizontal carousel", () => {
|
|
202
|
-
const props = createBaseProps({
|
|
203
|
-
style: { width: 700 },
|
|
204
|
-
itemWidth: 350,
|
|
205
|
-
});
|
|
206
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
207
|
-
|
|
208
|
-
expect(result.current.size).toBe(350);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("prioritizes itemHeight over style.height for vertical carousel", () => {
|
|
212
|
-
const props = createBaseProps({
|
|
213
|
-
vertical: true,
|
|
214
|
-
style: { height: 400 },
|
|
215
|
-
itemHeight: 200,
|
|
216
|
-
});
|
|
217
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
218
|
-
|
|
219
|
-
expect(result.current.size).toBe(200);
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it("prioritizes itemWidth over deprecated width prop", () => {
|
|
223
|
-
const props = createBaseProps({
|
|
224
|
-
width: 700,
|
|
225
|
-
itemWidth: 350,
|
|
226
|
-
});
|
|
227
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
228
|
-
|
|
229
|
-
expect(result.current.size).toBe(350);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
it("prefers style.width over deprecated width prop when itemWidth not provided", () => {
|
|
233
|
-
const props = createBaseProps({
|
|
234
|
-
width: 500,
|
|
235
|
-
});
|
|
236
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
237
|
-
|
|
238
|
-
expect(result.current.size).toBe(700);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it("prefers style.height over deprecated height prop when itemHeight not provided in vertical mode", () => {
|
|
242
|
-
const props = createBaseProps({
|
|
243
|
-
vertical: true,
|
|
244
|
-
height: 400,
|
|
245
|
-
});
|
|
246
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
247
|
-
|
|
248
|
-
expect(result.current.size).toBe(350);
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it("falls back to deprecated width prop when style.width is not provided", () => {
|
|
252
|
-
const props = createBaseProps({
|
|
253
|
-
style: {},
|
|
254
|
-
width: 500,
|
|
255
|
-
});
|
|
256
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
257
|
-
|
|
258
|
-
expect(result.current.size).toBe(500);
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
it("falls back to deprecated height prop when style.height is not provided (vertical mode)", () => {
|
|
262
|
-
const props = createBaseProps({
|
|
263
|
-
vertical: true,
|
|
264
|
-
style: {},
|
|
265
|
-
height: 400,
|
|
266
|
-
});
|
|
267
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
268
|
-
|
|
269
|
-
expect(result.current.size).toBe(400);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it("ignores zero or negative itemWidth", () => {
|
|
273
|
-
const props = createBaseProps({
|
|
274
|
-
style: { width: 700 },
|
|
275
|
-
itemWidth: 0,
|
|
276
|
-
});
|
|
277
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
278
|
-
|
|
279
|
-
expect(result.current.size).toBe(700);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it("ignores zero or negative itemHeight", () => {
|
|
283
|
-
const props = createBaseProps({
|
|
284
|
-
vertical: true,
|
|
285
|
-
style: { height: 400 },
|
|
286
|
-
itemHeight: -10,
|
|
287
|
-
});
|
|
288
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
289
|
-
|
|
290
|
-
expect(result.current.size).toBe(400);
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it("calculates handlerOffset correctly with itemWidth", () => {
|
|
294
|
-
const props = createBaseProps({
|
|
295
|
-
style: { width: 700 },
|
|
296
|
-
itemWidth: 350,
|
|
297
|
-
defaultIndex: 2,
|
|
298
|
-
});
|
|
299
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
300
|
-
|
|
301
|
-
// defaultIndex 2 * itemWidth 350 = -700
|
|
302
|
-
expect(result.current.handlerOffset.value).toBe(-700);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it("updates resolvedSize when itemWidth changes", () => {
|
|
306
|
-
const initial = createBaseProps({ style: { width: 700 }, itemWidth: 350 });
|
|
307
|
-
const hook = renderHook(({ p }) => useCommonVariables(p), { initialProps: { p: initial } });
|
|
308
|
-
expect(hook.result.current.size).toBe(350);
|
|
309
|
-
expect(hook.result.current.resolvedSize.value).toBe(350);
|
|
310
|
-
|
|
311
|
-
const updated = createBaseProps({ style: { width: 700 }, itemWidth: 400 });
|
|
312
|
-
act(() => {
|
|
313
|
-
hook.rerender({ p: updated });
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
// resolvedSize (SharedValue) updates immediately via useEffect
|
|
317
|
-
expect(hook.result.current.resolvedSize.value).toBe(400);
|
|
318
|
-
// size (state) updates asynchronously via useAnimatedReaction
|
|
319
|
-
// In test environment, this requires waiting for the animated reaction to fire
|
|
320
|
-
});
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
describe("sizeExplicit flag", () => {
|
|
324
|
-
it("sets sizeExplicit to true when itemWidth is provided for horizontal carousel", () => {
|
|
325
|
-
const props = createBaseProps({
|
|
326
|
-
style: { width: 700 },
|
|
327
|
-
itemWidth: 350,
|
|
328
|
-
});
|
|
329
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
330
|
-
|
|
331
|
-
expect(result.current.sizeExplicit).toBe(true);
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
it("sets sizeExplicit to true when itemHeight is provided for vertical carousel", () => {
|
|
335
|
-
const props = createBaseProps({
|
|
336
|
-
vertical: true,
|
|
337
|
-
style: { height: 400 },
|
|
338
|
-
itemHeight: 200,
|
|
339
|
-
});
|
|
340
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
341
|
-
|
|
342
|
-
expect(result.current.sizeExplicit).toBe(true);
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
it("sets sizeExplicit to false when only style.width is provided", () => {
|
|
346
|
-
const props = createBaseProps({
|
|
347
|
-
style: { width: 700 },
|
|
348
|
-
});
|
|
349
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
350
|
-
|
|
351
|
-
expect(result.current.sizeExplicit).toBe(false);
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
it("sets sizeExplicit to false when only deprecated width prop is provided", () => {
|
|
355
|
-
const props = createBaseProps({
|
|
356
|
-
width: 700,
|
|
357
|
-
});
|
|
358
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
359
|
-
|
|
360
|
-
expect(result.current.sizeExplicit).toBe(false);
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
it("sets sizeExplicit to false when itemWidth is zero", () => {
|
|
364
|
-
const props = createBaseProps({
|
|
365
|
-
style: { width: 700 },
|
|
366
|
-
itemWidth: 0,
|
|
367
|
-
});
|
|
368
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
369
|
-
|
|
370
|
-
expect(result.current.sizeExplicit).toBe(false);
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
it("sets sizeExplicit to false when itemHeight is negative", () => {
|
|
374
|
-
const props = createBaseProps({
|
|
375
|
-
vertical: true,
|
|
376
|
-
style: { height: 400 },
|
|
377
|
-
itemHeight: -10,
|
|
378
|
-
});
|
|
379
|
-
const { result } = renderHook(() => useCommonVariables(props));
|
|
380
|
-
|
|
381
|
-
expect(result.current.sizeExplicit).toBe(false);
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
});
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Text } from "react-native";
|
|
3
|
-
|
|
4
|
-
import { renderHook } from "@testing-library/react-hooks";
|
|
5
|
-
|
|
6
|
-
import { useInitProps } from "./useInitProps";
|
|
7
|
-
|
|
8
|
-
import type { TCarouselProps } from "../types";
|
|
9
|
-
|
|
10
|
-
describe("useInitProps", () => {
|
|
11
|
-
const defaultData = [1, 2, 3, 4];
|
|
12
|
-
const defaultProps: TCarouselProps<number> = {
|
|
13
|
-
data: defaultData,
|
|
14
|
-
width: 300,
|
|
15
|
-
height: 200,
|
|
16
|
-
renderItem: ({ item: _item }) => <Text>Item</Text>,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
it("should initialize with default values", () => {
|
|
20
|
-
const { result } = renderHook(() => useInitProps(defaultProps));
|
|
21
|
-
|
|
22
|
-
expect(result.current).toEqual(
|
|
23
|
-
expect.objectContaining({
|
|
24
|
-
defaultIndex: 0,
|
|
25
|
-
loop: true,
|
|
26
|
-
autoPlayInterval: 1000,
|
|
27
|
-
scrollAnimationDuration: 500,
|
|
28
|
-
width: 300,
|
|
29
|
-
height: 200,
|
|
30
|
-
enabled: true,
|
|
31
|
-
autoFillData: true,
|
|
32
|
-
pagingEnabled: true,
|
|
33
|
-
snapEnabled: true,
|
|
34
|
-
overscrollEnabled: true,
|
|
35
|
-
data: defaultData,
|
|
36
|
-
rawData: defaultData,
|
|
37
|
-
dataLength: 4,
|
|
38
|
-
rawDataLength: 4,
|
|
39
|
-
})
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("should handle custom values", () => {
|
|
44
|
-
const customProps: TCarouselProps<number> = {
|
|
45
|
-
...defaultProps,
|
|
46
|
-
defaultIndex: 2,
|
|
47
|
-
loop: false,
|
|
48
|
-
autoPlayInterval: 2000,
|
|
49
|
-
scrollAnimationDuration: 300,
|
|
50
|
-
enabled: false,
|
|
51
|
-
autoFillData: false,
|
|
52
|
-
pagingEnabled: false,
|
|
53
|
-
snapEnabled: false,
|
|
54
|
-
overscrollEnabled: false,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const { result } = renderHook(() => useInitProps(customProps));
|
|
58
|
-
|
|
59
|
-
expect(result.current).toEqual(
|
|
60
|
-
expect.objectContaining({
|
|
61
|
-
...customProps,
|
|
62
|
-
data: defaultData,
|
|
63
|
-
rawData: defaultData,
|
|
64
|
-
dataLength: 4,
|
|
65
|
-
rawDataLength: 4,
|
|
66
|
-
})
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
it("should handle stack mode configuration", () => {
|
|
70
|
-
const stackProps: TCarouselProps<number> = {
|
|
71
|
-
...defaultProps,
|
|
72
|
-
mode: "horizontal-stack",
|
|
73
|
-
modeConfig: {
|
|
74
|
-
showLength: 3,
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const { result } = renderHook(() => useInitProps(stackProps));
|
|
79
|
-
|
|
80
|
-
expect(result.current.modeConfig).toBeDefined();
|
|
81
|
-
if (result.current.modeConfig && "showLength" in result.current.modeConfig)
|
|
82
|
-
expect(result.current.modeConfig.showLength).toBe(3); // dataLength - 1
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("should handle empty data array", () => {
|
|
86
|
-
const props: TCarouselProps<number> = {
|
|
87
|
-
...defaultProps,
|
|
88
|
-
data: [],
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const { result } = renderHook(() => useInitProps(props));
|
|
92
|
-
|
|
93
|
-
expect(result.current.dataLength).toBe(0);
|
|
94
|
-
expect(result.current.rawDataLength).toBe(0);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("should round width and height values", () => {
|
|
98
|
-
const props: TCarouselProps<number> = {
|
|
99
|
-
...defaultProps,
|
|
100
|
-
width: 300.6,
|
|
101
|
-
height: 200.4,
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const { result } = renderHook(() => useInitProps(props));
|
|
105
|
-
|
|
106
|
-
expect(result.current.width).toBe(301);
|
|
107
|
-
expect(result.current.height).toBe(200);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("should handle enableSnap property", () => {
|
|
111
|
-
const props: TCarouselProps<number> = {
|
|
112
|
-
...defaultProps,
|
|
113
|
-
enableSnap: false,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const { result } = renderHook(() => useInitProps(props));
|
|
117
|
-
|
|
118
|
-
expect(result.current.snapEnabled).toBe(false);
|
|
119
|
-
});
|
|
120
|
-
it("should handle vertical-stack mode", () => {
|
|
121
|
-
const props: TCarouselProps<number> = {
|
|
122
|
-
...defaultProps,
|
|
123
|
-
mode: "vertical-stack",
|
|
124
|
-
modeConfig: {
|
|
125
|
-
showLength: 3,
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const { result } = renderHook(() => useInitProps(props));
|
|
130
|
-
expect(result.current.modeConfig).toBeDefined();
|
|
131
|
-
if (result.current.modeConfig && "showLength" in result.current.modeConfig)
|
|
132
|
-
expect(result.current.modeConfig.showLength).toBe(3); // dataLength - 1
|
|
133
|
-
});
|
|
134
|
-
});
|