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,61 +0,0 @@
|
|
|
1
|
-
import { render } from "@testing-library/react-native";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Text } from "react-native";
|
|
4
|
-
|
|
5
|
-
import { LazyView } from "./LazyView";
|
|
6
|
-
|
|
7
|
-
describe("LazyView", () => {
|
|
8
|
-
it("should render children when shouldUpdate is true", () => {
|
|
9
|
-
const { getByText } = render(
|
|
10
|
-
<LazyView shouldUpdate={true}>
|
|
11
|
-
<Text>Test Child</Text>
|
|
12
|
-
</LazyView>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
expect(getByText("Test Child")).toBeTruthy();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("should not render children when shouldUpdate is false", () => {
|
|
19
|
-
const { queryByText } = render(
|
|
20
|
-
<LazyView shouldUpdate={false}>
|
|
21
|
-
<Text>Test Child</Text>
|
|
22
|
-
</LazyView>
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
expect(queryByText("Test Child")).toBeNull();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("should render empty fragment when shouldUpdate is false", () => {
|
|
29
|
-
const { toJSON } = render(
|
|
30
|
-
<LazyView shouldUpdate={false}>
|
|
31
|
-
<Text>Test Child</Text>
|
|
32
|
-
</LazyView>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
expect(toJSON()).toBeNull();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("should handle multiple children when shouldUpdate is true", () => {
|
|
39
|
-
const { getByText } = render(
|
|
40
|
-
<LazyView shouldUpdate={true}>
|
|
41
|
-
<Text>First Child</Text>
|
|
42
|
-
<Text>Second Child</Text>
|
|
43
|
-
</LazyView>
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
expect(getByText("First Child")).toBeTruthy();
|
|
47
|
-
expect(getByText("Second Child")).toBeTruthy();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("should not render multiple children when shouldUpdate is false", () => {
|
|
51
|
-
const { queryByText } = render(
|
|
52
|
-
<LazyView shouldUpdate={false}>
|
|
53
|
-
<Text>First Child</Text>
|
|
54
|
-
<Text>Second Child</Text>
|
|
55
|
-
</LazyView>
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
expect(queryByText("First Child")).toBeNull();
|
|
59
|
-
expect(queryByText("Second Child")).toBeNull();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import type { PropsWithChildren } from "react";
|
|
2
|
-
import React, { useState } from "react";
|
|
3
|
-
import type { AccessibilityRole, AccessibilityState, ViewStyle } from "react-native";
|
|
4
|
-
import { Pressable, View } from "react-native";
|
|
5
|
-
import type { SharedValue } from "react-native-reanimated";
|
|
6
|
-
import Animated, {
|
|
7
|
-
Extrapolation,
|
|
8
|
-
interpolate,
|
|
9
|
-
useAnimatedReaction,
|
|
10
|
-
useAnimatedStyle,
|
|
11
|
-
} from "react-native-reanimated";
|
|
12
|
-
import { scheduleOnRN } from "react-native-worklets";
|
|
13
|
-
|
|
14
|
-
export type DotStyle = Omit<ViewStyle, "width" | "height"> & {
|
|
15
|
-
width?: number;
|
|
16
|
-
height?: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type PaginationItemAccessibilityOverrides = {
|
|
20
|
-
accessibilityLabel?: string;
|
|
21
|
-
accessibilityHint?: string;
|
|
22
|
-
accessibilityRole?: AccessibilityRole;
|
|
23
|
-
accessibilityState?: AccessibilityState;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const PaginationItem: React.FC<
|
|
27
|
-
PropsWithChildren<{
|
|
28
|
-
index: number;
|
|
29
|
-
count: number;
|
|
30
|
-
size?: number;
|
|
31
|
-
animValue: SharedValue<number>;
|
|
32
|
-
horizontal?: boolean;
|
|
33
|
-
dotStyle?: DotStyle;
|
|
34
|
-
activeDotStyle?: DotStyle;
|
|
35
|
-
onPress: () => void;
|
|
36
|
-
accessibilityLabel?: string;
|
|
37
|
-
accessibilityHint?: string;
|
|
38
|
-
accessibilityRole?: AccessibilityRole;
|
|
39
|
-
accessibilityState?: AccessibilityState;
|
|
40
|
-
}>
|
|
41
|
-
> = (props) => {
|
|
42
|
-
const {
|
|
43
|
-
animValue,
|
|
44
|
-
dotStyle,
|
|
45
|
-
activeDotStyle,
|
|
46
|
-
index,
|
|
47
|
-
count,
|
|
48
|
-
size,
|
|
49
|
-
horizontal,
|
|
50
|
-
children,
|
|
51
|
-
onPress,
|
|
52
|
-
accessibilityLabel,
|
|
53
|
-
accessibilityHint,
|
|
54
|
-
accessibilityRole,
|
|
55
|
-
accessibilityState,
|
|
56
|
-
} = props;
|
|
57
|
-
|
|
58
|
-
const defaultDotSize = 10;
|
|
59
|
-
|
|
60
|
-
const sizes = {
|
|
61
|
-
width: size || dotStyle?.width || defaultDotSize,
|
|
62
|
-
height: size || dotStyle?.height || defaultDotSize,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* TODO: Keep this for future implementation
|
|
67
|
-
* Used to change the size of the active dot with animation
|
|
68
|
-
*/
|
|
69
|
-
// const animatedSize = {
|
|
70
|
-
// width: activeDotStyle?.width,
|
|
71
|
-
// height: activeDotStyle?.height,
|
|
72
|
-
// };
|
|
73
|
-
|
|
74
|
-
const width = sizes.width;
|
|
75
|
-
const height = sizes.height;
|
|
76
|
-
|
|
77
|
-
const [isSelected, setIsSelected] = useState(false);
|
|
78
|
-
const resolvedAccessibilityLabel = accessibilityLabel ?? `Slide ${index + 1} of ${count}`;
|
|
79
|
-
const resolvedAccessibilityHint =
|
|
80
|
-
accessibilityHint ?? (isSelected ? "" : `Go to ${resolvedAccessibilityLabel}`);
|
|
81
|
-
const resolvedAccessibilityRole = accessibilityRole ?? "button";
|
|
82
|
-
const resolvedAccessibilityState = accessibilityState ?? { selected: isSelected };
|
|
83
|
-
|
|
84
|
-
useAnimatedReaction(
|
|
85
|
-
() => animValue.value,
|
|
86
|
-
(value) => {
|
|
87
|
-
scheduleOnRN(setIsSelected, value === index);
|
|
88
|
-
},
|
|
89
|
-
[animValue, index]
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const animStyle = useAnimatedStyle(() => {
|
|
93
|
-
const size = horizontal ? height : width;
|
|
94
|
-
let inputRange = [index - 1, index, index + 1];
|
|
95
|
-
let outputRange = [-size, 0, size];
|
|
96
|
-
|
|
97
|
-
if (index === 0 && animValue?.value > count - 1) {
|
|
98
|
-
inputRange = [count - 1, count, count + 1];
|
|
99
|
-
outputRange = [-size, 0, size];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
transform: [
|
|
104
|
-
{
|
|
105
|
-
translateX: interpolate(animValue?.value, inputRange, outputRange, Extrapolation.CLAMP),
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
};
|
|
109
|
-
}, [animValue, index, count, horizontal]);
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<Pressable
|
|
113
|
-
onPress={onPress}
|
|
114
|
-
accessibilityLabel={resolvedAccessibilityLabel}
|
|
115
|
-
accessibilityRole={resolvedAccessibilityRole}
|
|
116
|
-
accessibilityHint={resolvedAccessibilityHint}
|
|
117
|
-
accessibilityState={resolvedAccessibilityState}
|
|
118
|
-
>
|
|
119
|
-
<View
|
|
120
|
-
style={[
|
|
121
|
-
{
|
|
122
|
-
width,
|
|
123
|
-
height,
|
|
124
|
-
overflow: "hidden",
|
|
125
|
-
transform: [
|
|
126
|
-
{
|
|
127
|
-
rotateZ: horizontal ? "90deg" : "0deg",
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
dotStyle,
|
|
132
|
-
]}
|
|
133
|
-
>
|
|
134
|
-
<Animated.View
|
|
135
|
-
style={[
|
|
136
|
-
{
|
|
137
|
-
backgroundColor: "black",
|
|
138
|
-
flex: 1,
|
|
139
|
-
},
|
|
140
|
-
animStyle,
|
|
141
|
-
activeDotStyle,
|
|
142
|
-
]}
|
|
143
|
-
>
|
|
144
|
-
{children}
|
|
145
|
-
</Animated.View>
|
|
146
|
-
</View>
|
|
147
|
-
</Pressable>
|
|
148
|
-
);
|
|
149
|
-
};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
2
|
-
import type { SharedValue } from "react-native-reanimated";
|
|
3
|
-
|
|
4
|
-
import React from "react";
|
|
5
|
-
import type { DotStyle, PaginationItemAccessibilityOverrides } from "./PaginationItem";
|
|
6
|
-
import { PaginationItem } from "./PaginationItem";
|
|
7
|
-
|
|
8
|
-
export interface BasicProps<T> {
|
|
9
|
-
progress: SharedValue<number>;
|
|
10
|
-
horizontal?: boolean;
|
|
11
|
-
data: Array<T>;
|
|
12
|
-
renderItem?: (item: T, index: number) => React.ReactNode;
|
|
13
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
14
|
-
dotStyle?: DotStyle;
|
|
15
|
-
activeDotStyle?: DotStyle;
|
|
16
|
-
size?: number;
|
|
17
|
-
onPress?: (index: number) => void;
|
|
18
|
-
carouselName?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Optional accessibility overrides for each pagination item.
|
|
21
|
-
* Use this to fully control screen reader announcements per dot.
|
|
22
|
-
*/
|
|
23
|
-
paginationItemAccessibility?: (
|
|
24
|
-
index: number,
|
|
25
|
-
length: number
|
|
26
|
-
) => PaginationItemAccessibilityOverrides;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const Basic = <T extends {}>(props: BasicProps<T>) => {
|
|
30
|
-
const {
|
|
31
|
-
activeDotStyle,
|
|
32
|
-
dotStyle,
|
|
33
|
-
progress,
|
|
34
|
-
horizontal = true,
|
|
35
|
-
data,
|
|
36
|
-
size,
|
|
37
|
-
containerStyle,
|
|
38
|
-
renderItem,
|
|
39
|
-
onPress,
|
|
40
|
-
carouselName,
|
|
41
|
-
paginationItemAccessibility,
|
|
42
|
-
} = props;
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
typeof size === "string" ||
|
|
46
|
-
typeof dotStyle?.width === "string" ||
|
|
47
|
-
typeof dotStyle?.height === "string"
|
|
48
|
-
)
|
|
49
|
-
throw new Error("size/width/height must be a number");
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<View
|
|
53
|
-
style={[
|
|
54
|
-
{
|
|
55
|
-
justifyContent: "space-between",
|
|
56
|
-
alignSelf: "center",
|
|
57
|
-
},
|
|
58
|
-
horizontal
|
|
59
|
-
? {
|
|
60
|
-
flexDirection: "row",
|
|
61
|
-
}
|
|
62
|
-
: {
|
|
63
|
-
flexDirection: "column",
|
|
64
|
-
},
|
|
65
|
-
containerStyle,
|
|
66
|
-
]}
|
|
67
|
-
>
|
|
68
|
-
{data.map((item, index) => {
|
|
69
|
-
const defaultAccessibilityLabel = carouselName
|
|
70
|
-
? `Slide ${index + 1} of ${data.length} - ${carouselName}`
|
|
71
|
-
: `Slide ${index + 1} of ${data.length}`;
|
|
72
|
-
const accessibilityOverrides = paginationItemAccessibility?.(index, data.length) ?? {};
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<PaginationItem
|
|
76
|
-
key={index}
|
|
77
|
-
index={index}
|
|
78
|
-
size={size}
|
|
79
|
-
count={data.length}
|
|
80
|
-
dotStyle={dotStyle}
|
|
81
|
-
animValue={progress}
|
|
82
|
-
horizontal={!horizontal}
|
|
83
|
-
activeDotStyle={activeDotStyle}
|
|
84
|
-
onPress={() => onPress?.(index)}
|
|
85
|
-
accessibilityLabel={
|
|
86
|
-
accessibilityOverrides.accessibilityLabel ?? defaultAccessibilityLabel
|
|
87
|
-
}
|
|
88
|
-
accessibilityHint={accessibilityOverrides.accessibilityHint}
|
|
89
|
-
accessibilityRole={accessibilityOverrides.accessibilityRole}
|
|
90
|
-
accessibilityState={accessibilityOverrides.accessibilityState}
|
|
91
|
-
>
|
|
92
|
-
{renderItem?.(item, index)}
|
|
93
|
-
</PaginationItem>
|
|
94
|
-
);
|
|
95
|
-
})}
|
|
96
|
-
</View>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import type { PropsWithChildren } from "react";
|
|
2
|
-
import React, { useState } from "react";
|
|
3
|
-
import type { AccessibilityRole, AccessibilityState } from "react-native";
|
|
4
|
-
import { Pressable } from "react-native";
|
|
5
|
-
import type { ImageStyle, TextStyle, ViewStyle } from "react-native";
|
|
6
|
-
import type { SharedValue } from "react-native-reanimated";
|
|
7
|
-
import Animated, {
|
|
8
|
-
Extrapolation,
|
|
9
|
-
interpolate,
|
|
10
|
-
interpolateColor,
|
|
11
|
-
useAnimatedStyle,
|
|
12
|
-
useSharedValue,
|
|
13
|
-
useDerivedValue,
|
|
14
|
-
useAnimatedReaction,
|
|
15
|
-
} from "react-native-reanimated";
|
|
16
|
-
import { scheduleOnRN } from "react-native-worklets";
|
|
17
|
-
|
|
18
|
-
type AnimatedDefaultStyle = ViewStyle | ImageStyle | TextStyle;
|
|
19
|
-
|
|
20
|
-
export type PaginationItemAccessibilityOverrides = {
|
|
21
|
-
accessibilityLabel?: string;
|
|
22
|
-
accessibilityHint?: string;
|
|
23
|
-
accessibilityRole?: AccessibilityRole;
|
|
24
|
-
accessibilityState?: AccessibilityState;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type DotStyle = Omit<ViewStyle, "width" | "height" | "backgroundColor" | "borderRadius"> & {
|
|
28
|
-
width?: number;
|
|
29
|
-
height?: number;
|
|
30
|
-
backgroundColor?: string;
|
|
31
|
-
borderRadius?: number;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const PaginationItem: React.FC<
|
|
35
|
-
PropsWithChildren<{
|
|
36
|
-
index: number;
|
|
37
|
-
count: number;
|
|
38
|
-
size?: number;
|
|
39
|
-
animValue: SharedValue<number>;
|
|
40
|
-
horizontal?: boolean;
|
|
41
|
-
dotStyle?: DotStyle;
|
|
42
|
-
activeDotStyle?: DotStyle;
|
|
43
|
-
onPress: () => void;
|
|
44
|
-
customReanimatedStyle?: (
|
|
45
|
-
progress: number,
|
|
46
|
-
index: number,
|
|
47
|
-
length: number
|
|
48
|
-
) => AnimatedDefaultStyle;
|
|
49
|
-
accessibilityLabel?: string;
|
|
50
|
-
accessibilityHint?: string;
|
|
51
|
-
accessibilityRole?: AccessibilityRole;
|
|
52
|
-
accessibilityState?: AccessibilityState;
|
|
53
|
-
}>
|
|
54
|
-
> = (props) => {
|
|
55
|
-
const defaultDotSize = 10;
|
|
56
|
-
const {
|
|
57
|
-
animValue,
|
|
58
|
-
dotStyle,
|
|
59
|
-
activeDotStyle,
|
|
60
|
-
index,
|
|
61
|
-
count,
|
|
62
|
-
size,
|
|
63
|
-
horizontal,
|
|
64
|
-
children,
|
|
65
|
-
customReanimatedStyle,
|
|
66
|
-
onPress,
|
|
67
|
-
accessibilityLabel,
|
|
68
|
-
accessibilityHint,
|
|
69
|
-
accessibilityRole,
|
|
70
|
-
accessibilityState,
|
|
71
|
-
} = props;
|
|
72
|
-
const customReanimatedStyleRef = useSharedValue<AnimatedDefaultStyle>({});
|
|
73
|
-
const handleCustomAnimation = (progress: number) => {
|
|
74
|
-
customReanimatedStyleRef.value = customReanimatedStyle?.(progress, index, count) ?? {};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const [isSelected, setIsSelected] = useState(false);
|
|
78
|
-
const resolvedAccessibilityLabel = accessibilityLabel ?? `Slide ${index + 1} of ${count}`;
|
|
79
|
-
const resolvedAccessibilityHint =
|
|
80
|
-
accessibilityHint ?? (isSelected ? "" : `Go to ${resolvedAccessibilityLabel}`);
|
|
81
|
-
const resolvedAccessibilityRole = accessibilityRole ?? "button";
|
|
82
|
-
const resolvedAccessibilityState = accessibilityState ?? { selected: isSelected };
|
|
83
|
-
|
|
84
|
-
useDerivedValue(() => {
|
|
85
|
-
scheduleOnRN(handleCustomAnimation, animValue?.value);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
useAnimatedReaction(
|
|
89
|
-
() => animValue.value,
|
|
90
|
-
(value) => {
|
|
91
|
-
scheduleOnRN(setIsSelected, value === index);
|
|
92
|
-
},
|
|
93
|
-
[animValue, index]
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const animStyle = useAnimatedStyle((): AnimatedDefaultStyle => {
|
|
97
|
-
const {
|
|
98
|
-
width = size || defaultDotSize,
|
|
99
|
-
height = size || defaultDotSize,
|
|
100
|
-
borderRadius,
|
|
101
|
-
backgroundColor = "#FFF",
|
|
102
|
-
...restDotStyle
|
|
103
|
-
} = dotStyle ?? {};
|
|
104
|
-
const {
|
|
105
|
-
width: activeWidth = width,
|
|
106
|
-
height: activeHeight = height,
|
|
107
|
-
borderRadius: activeBorderRadius,
|
|
108
|
-
backgroundColor: activeBackgroundColor = "#000",
|
|
109
|
-
...restActiveDotStyle
|
|
110
|
-
} = activeDotStyle ?? {};
|
|
111
|
-
let val = Math.abs(animValue?.value - index);
|
|
112
|
-
if (index === 0 && animValue?.value > count - 1) val = Math.abs(animValue?.value - count);
|
|
113
|
-
|
|
114
|
-
const inputRange = [0, 1, 2];
|
|
115
|
-
const restStyle = (val === 0 ? restActiveDotStyle : restDotStyle) ?? {};
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
width: interpolate(val, inputRange, [activeWidth, width, width], Extrapolation.CLAMP),
|
|
119
|
-
height: interpolate(val, inputRange, [activeHeight, height, height], Extrapolation.CLAMP),
|
|
120
|
-
borderRadius: interpolate(
|
|
121
|
-
val,
|
|
122
|
-
inputRange,
|
|
123
|
-
[activeBorderRadius ?? borderRadius ?? 0, borderRadius ?? 0, borderRadius ?? 0],
|
|
124
|
-
Extrapolation.CLAMP
|
|
125
|
-
),
|
|
126
|
-
backgroundColor: interpolateColor(val, inputRange, [
|
|
127
|
-
activeBackgroundColor,
|
|
128
|
-
backgroundColor,
|
|
129
|
-
backgroundColor,
|
|
130
|
-
]),
|
|
131
|
-
...restStyle,
|
|
132
|
-
...(customReanimatedStyleRef.value ?? {}),
|
|
133
|
-
transform: [
|
|
134
|
-
...(restStyle?.transform ?? []),
|
|
135
|
-
...(customReanimatedStyleRef.value?.transform ?? []),
|
|
136
|
-
] as AnimatedDefaultStyle["transform"],
|
|
137
|
-
};
|
|
138
|
-
}, [animValue, index, count, horizontal, dotStyle, activeDotStyle, customReanimatedStyle]);
|
|
139
|
-
|
|
140
|
-
return (
|
|
141
|
-
<Pressable
|
|
142
|
-
onPress={onPress}
|
|
143
|
-
accessibilityLabel={resolvedAccessibilityLabel}
|
|
144
|
-
accessibilityRole={resolvedAccessibilityRole}
|
|
145
|
-
accessibilityHint={resolvedAccessibilityHint}
|
|
146
|
-
accessibilityState={resolvedAccessibilityState}
|
|
147
|
-
>
|
|
148
|
-
<Animated.View
|
|
149
|
-
style={[
|
|
150
|
-
{
|
|
151
|
-
overflow: "hidden",
|
|
152
|
-
transform: [
|
|
153
|
-
{
|
|
154
|
-
rotateZ: horizontal ? "90deg" : "0deg",
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
dotStyle,
|
|
159
|
-
animStyle,
|
|
160
|
-
]}
|
|
161
|
-
>
|
|
162
|
-
{children}
|
|
163
|
-
</Animated.View>
|
|
164
|
-
</Pressable>
|
|
165
|
-
);
|
|
166
|
-
};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
3
|
-
import { View } from "react-native";
|
|
4
|
-
import type { SharedValue } from "react-native-reanimated";
|
|
5
|
-
|
|
6
|
-
import type { DotStyle, PaginationItemAccessibilityOverrides } from "./PaginationItem";
|
|
7
|
-
import { PaginationItem } from "./PaginationItem";
|
|
8
|
-
|
|
9
|
-
export interface ShapeProps<T extends {}> {
|
|
10
|
-
progress: SharedValue<number>;
|
|
11
|
-
horizontal?: boolean;
|
|
12
|
-
data: Array<T>;
|
|
13
|
-
renderItem?: (item: T, index: number) => React.ReactNode;
|
|
14
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
15
|
-
dotStyle?: DotStyle;
|
|
16
|
-
activeDotStyle?: DotStyle;
|
|
17
|
-
size?: number;
|
|
18
|
-
onPress?: (index: number) => void;
|
|
19
|
-
customReanimatedStyle?: (progress: number, index: number, length: number) => AnimatedDefaultStyle;
|
|
20
|
-
carouselName?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Optional accessibility overrides for each pagination item.
|
|
23
|
-
* Use this to fully control screen reader announcements per dot.
|
|
24
|
-
*/
|
|
25
|
-
paginationItemAccessibility?: (
|
|
26
|
-
index: number,
|
|
27
|
-
length: number
|
|
28
|
-
) => PaginationItemAccessibilityOverrides;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type AnimatedDefaultStyle = ViewStyle | ImageStyle | TextStyle;
|
|
32
|
-
|
|
33
|
-
export const Custom = <T extends {}>(props: ShapeProps<T>) => {
|
|
34
|
-
const {
|
|
35
|
-
activeDotStyle,
|
|
36
|
-
dotStyle,
|
|
37
|
-
progress,
|
|
38
|
-
horizontal = true,
|
|
39
|
-
data,
|
|
40
|
-
size,
|
|
41
|
-
containerStyle,
|
|
42
|
-
renderItem,
|
|
43
|
-
onPress,
|
|
44
|
-
customReanimatedStyle,
|
|
45
|
-
carouselName,
|
|
46
|
-
paginationItemAccessibility,
|
|
47
|
-
} = props;
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
typeof size === "string" ||
|
|
51
|
-
typeof dotStyle?.width === "string" ||
|
|
52
|
-
typeof dotStyle?.height === "string" ||
|
|
53
|
-
typeof activeDotStyle?.width === "string" ||
|
|
54
|
-
typeof activeDotStyle?.height === "string"
|
|
55
|
-
)
|
|
56
|
-
throw new Error("size/width/height must be a number");
|
|
57
|
-
|
|
58
|
-
const maxItemWidth = Math.max(size ?? 0, dotStyle?.width ?? 0, activeDotStyle?.width ?? 0);
|
|
59
|
-
const maxItemHeight = Math.max(size ?? 0, dotStyle?.height ?? 0, activeDotStyle?.height ?? 0);
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<View
|
|
63
|
-
style={[
|
|
64
|
-
{
|
|
65
|
-
justifyContent: "space-between",
|
|
66
|
-
alignSelf: "center",
|
|
67
|
-
minWidth: maxItemWidth,
|
|
68
|
-
minHeight: maxItemHeight,
|
|
69
|
-
},
|
|
70
|
-
horizontal
|
|
71
|
-
? {
|
|
72
|
-
flexDirection: "row",
|
|
73
|
-
}
|
|
74
|
-
: {
|
|
75
|
-
flexDirection: "column",
|
|
76
|
-
},
|
|
77
|
-
containerStyle,
|
|
78
|
-
]}
|
|
79
|
-
>
|
|
80
|
-
{data.map((item, index) => {
|
|
81
|
-
const defaultAccessibilityLabel = carouselName
|
|
82
|
-
? `Slide ${index + 1} of ${data.length} - ${carouselName}`
|
|
83
|
-
: `Slide ${index + 1} of ${data.length}`;
|
|
84
|
-
const accessibilityOverrides = paginationItemAccessibility?.(index, data.length) ?? {};
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<PaginationItem
|
|
88
|
-
key={index}
|
|
89
|
-
index={index}
|
|
90
|
-
size={size}
|
|
91
|
-
count={data.length}
|
|
92
|
-
dotStyle={dotStyle}
|
|
93
|
-
animValue={progress}
|
|
94
|
-
horizontal={!horizontal}
|
|
95
|
-
activeDotStyle={activeDotStyle}
|
|
96
|
-
customReanimatedStyle={customReanimatedStyle}
|
|
97
|
-
onPress={() => onPress?.(index)}
|
|
98
|
-
accessibilityLabel={
|
|
99
|
-
accessibilityOverrides.accessibilityLabel ?? defaultAccessibilityLabel
|
|
100
|
-
}
|
|
101
|
-
accessibilityHint={accessibilityOverrides.accessibilityHint}
|
|
102
|
-
accessibilityRole={accessibilityOverrides.accessibilityRole}
|
|
103
|
-
accessibilityState={accessibilityOverrides.accessibilityState}
|
|
104
|
-
>
|
|
105
|
-
{renderItem?.(item, index)}
|
|
106
|
-
</PaginationItem>
|
|
107
|
-
);
|
|
108
|
-
})}
|
|
109
|
-
</View>
|
|
110
|
-
);
|
|
111
|
-
};
|