@fountain-ui/lab 2.0.0-beta.4 → 2.0.0-beta.40
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/build/commonjs/AnimatedY/AnimatedY.js +10 -14
- package/build/commonjs/AnimatedY/AnimatedY.js.map +1 -1
- package/build/commonjs/AnimatedY/AnimatedYProps.js.map +1 -1
- package/build/commonjs/AnimatedY/index.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheet.js +177 -0
- package/build/commonjs/BottomSheet/BottomSheet.js.map +1 -0
- package/build/commonjs/BottomSheet/BottomSheetNative.js +5 -3
- package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetWeb.js +19 -7
- package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
- package/build/commonjs/BottomSheet/TransparentBackdrop.js +1 -1
- package/build/commonjs/BottomSheet/TransparentBackdrop.js.map +1 -1
- package/build/commonjs/BottomSheet/index.js.map +1 -1
- package/build/commonjs/BottomSheet/index.native.js.map +1 -1
- package/build/commonjs/BottomSheet/useDynamicSnapPoints.js +49 -0
- package/build/commonjs/BottomSheet/useDynamicSnapPoints.js.map +1 -0
- package/build/commonjs/Carousel/Carousel.js +130 -0
- package/build/commonjs/Carousel/Carousel.js.map +1 -0
- package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
- package/build/commonjs/Carousel/animation/animationUtils.js +9 -0
- package/build/commonjs/Carousel/animation/animationUtils.js.map +1 -0
- package/build/commonjs/Carousel/animation/createDefaultItemStyle.js +15 -0
- package/build/commonjs/Carousel/animation/createDefaultItemStyle.js.map +1 -0
- package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js +20 -0
- package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
- package/build/commonjs/Carousel/animation/index.js +40 -0
- package/build/commonjs/Carousel/animation/index.js.map +1 -0
- package/build/commonjs/Carousel/animation/normalItemStyleFactory.js +27 -0
- package/build/commonjs/Carousel/animation/normalItemStyleFactory.js.map +1 -0
- package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js +65 -0
- package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
- package/build/commonjs/Carousel/components/InternalContext.js +29 -0
- package/build/commonjs/Carousel/components/InternalContext.js.map +1 -0
- package/build/commonjs/Carousel/components/ItemView.js +66 -0
- package/build/commonjs/Carousel/components/ItemView.js.map +1 -0
- package/build/commonjs/Carousel/components/RootView.js +86 -0
- package/build/commonjs/Carousel/components/RootView.js.map +1 -0
- package/build/commonjs/Carousel/components/ScrollViewGesture.js +82 -0
- package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -0
- package/build/commonjs/Carousel/components/index.js +40 -0
- package/build/commonjs/Carousel/components/index.js.map +1 -0
- package/build/commonjs/Carousel/components/useItemInterpolation.js +65 -0
- package/build/commonjs/Carousel/components/useItemInterpolation.js.map +1 -0
- package/build/commonjs/Carousel/hooks/index.js +48 -0
- package/build/commonjs/Carousel/hooks/index.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useAutoplayController.js +58 -0
- package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useIndexController.js +55 -0
- package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js +95 -0
- package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useLoopedData.js +33 -0
- package/build/commonjs/Carousel/hooks/useLoopedData.js.map +1 -0
- package/build/commonjs/Carousel/hooks/usePagingAnimator.js +202 -0
- package/build/commonjs/Carousel/hooks/usePagingAnimator.js.map +1 -0
- package/build/commonjs/Carousel/index.js +16 -2
- package/build/commonjs/Carousel/index.js.map +1 -1
- package/build/commonjs/Carousel/tick.js +16 -0
- package/build/commonjs/Carousel/tick.js.map +1 -0
- package/build/commonjs/Carousel/types.js +8 -0
- package/build/commonjs/Carousel/types.js.map +1 -0
- package/build/commonjs/ComicViewer/ComicViewer.js +203 -86
- package/build/commonjs/ComicViewer/ComicViewer.js.map +1 -1
- package/build/commonjs/ComicViewer/ComicViewerProps.js.map +1 -1
- package/build/commonjs/ComicViewer/EncodedTile.js +10 -0
- package/build/commonjs/ComicViewer/EncodedTile.js.map +1 -0
- package/build/commonjs/ComicViewer/ReloadButton.js +48 -0
- package/build/commonjs/ComicViewer/ReloadButton.js.map +1 -0
- package/build/commonjs/ComicViewer/ViewerItem.js +49 -58
- package/build/commonjs/ComicViewer/ViewerItem.js.map +1 -1
- package/build/commonjs/ComicViewer/index.js.map +1 -1
- package/build/commonjs/DateTimePicker/DateTimePicker.js +2 -2
- package/build/commonjs/DateTimePicker/DateTimePicker.js.map +1 -1
- package/build/commonjs/DateTimePicker/DateTimePickerProps.js.map +1 -1
- package/build/commonjs/DateTimePicker/DateTimePickerProvider.js.map +1 -1
- package/build/commonjs/DateTimePicker/YearPicker.js +21 -17
- package/build/commonjs/DateTimePicker/YearPicker.js.map +1 -1
- package/build/commonjs/DateTimePicker/index.js +4 -4
- package/build/commonjs/DateTimePicker/index.js.map +1 -1
- package/build/commonjs/DateTimePicker/utils.js +2 -1
- package/build/commonjs/DateTimePicker/utils.js.map +1 -1
- package/build/commonjs/FlipCard/FlipCard.js +7 -13
- package/build/commonjs/FlipCard/FlipCard.js.map +1 -1
- package/build/commonjs/FlipCard/FlipCardProps.js.map +1 -1
- package/build/commonjs/FlipCard/index.js.map +1 -1
- package/build/commonjs/StatusBarProvider/Provider.js +1 -1
- package/build/commonjs/StatusBarProvider/Provider.js.map +1 -1
- package/build/commonjs/StatusBarProvider/StatusBarProvider.js.map +1 -1
- package/build/commonjs/StatusBarProvider/StatusBarProviderProps.js.map +1 -1
- package/build/commonjs/StatusBarProvider/index.js.map +1 -1
- package/build/commonjs/ViewPager/FluxContext.js +13 -0
- package/build/commonjs/ViewPager/FluxContext.js.map +1 -0
- package/build/commonjs/ViewPager/InternalContext.js +17 -0
- package/build/commonjs/ViewPager/InternalContext.js.map +1 -0
- package/build/commonjs/ViewPager/PageStateContext.js +16 -0
- package/build/commonjs/ViewPager/PageStateContext.js.map +1 -0
- package/build/commonjs/ViewPager/ViewPager.js +81 -0
- package/build/commonjs/ViewPager/ViewPager.js.map +1 -0
- package/build/commonjs/ViewPager/ViewPager.native.js +150 -0
- package/build/commonjs/ViewPager/ViewPager.native.js.map +1 -0
- package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
- package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js +122 -0
- package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
- package/build/commonjs/ViewPager/components/FluxStoreProvider.js +37 -0
- package/build/commonjs/ViewPager/components/FluxStoreProvider.js.map +1 -0
- package/build/commonjs/ViewPager/components/index.js +24 -0
- package/build/commonjs/ViewPager/components/index.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/index.js +64 -0
- package/build/commonjs/ViewPager/hooks/index.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useDispatch.js +22 -0
- package/build/commonjs/ViewPager/hooks/useDispatch.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useEagerState.js +24 -0
- package/build/commonjs/ViewPager/hooks/useEagerState.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useForceRender.js +16 -0
- package/build/commonjs/ViewPager/hooks/useForceRender.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useLazyState.js +45 -0
- package/build/commonjs/ViewPager/hooks/useLazyState.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/usePageStore.js +35 -0
- package/build/commonjs/ViewPager/hooks/usePageStore.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useStore.js +26 -0
- package/build/commonjs/ViewPager/hooks/useStore.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js +19 -0
- package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
- package/build/commonjs/ViewPager/index.js +42 -2
- package/build/commonjs/ViewPager/index.js.map +1 -1
- package/build/commonjs/ViewPager/types.js +2 -0
- package/build/commonjs/ViewPager/types.js.map +1 -0
- package/build/commonjs/ViewPager/utils.js +12 -43
- package/build/commonjs/ViewPager/utils.js.map +1 -1
- package/build/commonjs/ViewabilityTrackerView/Viewability.js +2 -0
- package/build/commonjs/ViewabilityTrackerView/Viewability.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js +45 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
- package/build/commonjs/{Carousel/index.native.js → ViewabilityTrackerView/index.js} +3 -3
- package/build/commonjs/ViewabilityTrackerView/index.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/measureViewability.js +42 -0
- package/build/commonjs/ViewabilityTrackerView/measureViewability.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js +88 -0
- package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
- package/build/commonjs/hooks/index.js +16 -0
- package/build/commonjs/hooks/index.js.map +1 -1
- package/build/commonjs/hooks/useAppbarStyles.js.map +1 -1
- package/build/commonjs/hooks/useDeferredExecutor.js +45 -0
- package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
- package/build/commonjs/hooks/useElevationStyle.js.map +1 -1
- package/build/commonjs/hooks/useHeight.js +5 -4
- package/build/commonjs/hooks/useHeight.js.map +1 -1
- package/build/commonjs/hooks/useIsMounted.js +22 -0
- package/build/commonjs/hooks/useIsMounted.js.map +1 -0
- package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +58 -61
- package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
- package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js +9 -11
- package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
- package/build/commonjs/index.js +28 -7
- package/build/commonjs/index.js.map +1 -1
- package/build/module/AnimatedY/AnimatedY.js +11 -10
- package/build/module/AnimatedY/AnimatedY.js.map +1 -1
- package/build/module/AnimatedY/AnimatedYProps.js.map +1 -1
- package/build/module/AnimatedY/index.js.map +1 -1
- package/build/module/BottomSheet/BottomSheet.js +161 -0
- package/build/module/BottomSheet/BottomSheet.js.map +1 -0
- package/build/module/BottomSheet/BottomSheetNative.js +5 -3
- package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetWeb.js +18 -7
- package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
- package/build/module/BottomSheet/TransparentBackdrop.js +1 -1
- package/build/module/BottomSheet/TransparentBackdrop.js.map +1 -1
- package/build/module/BottomSheet/index.js.map +1 -1
- package/build/module/BottomSheet/index.native.js.map +1 -1
- package/build/module/BottomSheet/useDynamicSnapPoints.js +41 -0
- package/build/module/BottomSheet/useDynamicSnapPoints.js.map +1 -0
- package/build/module/Carousel/Carousel.js +109 -0
- package/build/module/Carousel/Carousel.js.map +1 -0
- package/build/module/Carousel/CarouselProps.js.map +1 -1
- package/build/module/Carousel/animation/animationUtils.js +2 -0
- package/build/module/Carousel/animation/animationUtils.js.map +1 -0
- package/build/module/Carousel/animation/createDefaultItemStyle.js +3 -0
- package/build/module/Carousel/animation/createDefaultItemStyle.js.map +1 -0
- package/build/module/Carousel/animation/createDefaultScrollAnimation.js +11 -0
- package/build/module/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
- package/build/module/Carousel/animation/index.js +5 -0
- package/build/module/Carousel/animation/index.js.map +1 -0
- package/build/module/Carousel/animation/normalItemStyleFactory.js +18 -0
- package/build/module/Carousel/animation/normalItemStyleFactory.js.map +1 -0
- package/build/module/Carousel/animation/parallaxItemStyleFactory.js +55 -0
- package/build/module/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
- package/build/module/Carousel/components/InternalContext.js +19 -0
- package/build/module/Carousel/components/InternalContext.js.map +1 -0
- package/build/module/Carousel/components/ItemView.js +46 -0
- package/build/module/Carousel/components/ItemView.js.map +1 -0
- package/build/module/Carousel/components/RootView.js +65 -0
- package/build/module/Carousel/components/RootView.js.map +1 -0
- package/build/module/Carousel/components/ScrollViewGesture.js +68 -0
- package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -0
- package/build/module/Carousel/components/index.js +5 -0
- package/build/module/Carousel/components/index.js.map +1 -0
- package/build/module/Carousel/components/useItemInterpolation.js +51 -0
- package/build/module/Carousel/components/useItemInterpolation.js.map +1 -0
- package/build/module/Carousel/hooks/index.js +6 -0
- package/build/module/Carousel/hooks/index.js.map +1 -0
- package/build/module/Carousel/hooks/useAutoplayController.js +48 -0
- package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -0
- package/build/module/Carousel/hooks/useIndexController.js +44 -0
- package/build/module/Carousel/hooks/useIndexController.js.map +1 -0
- package/build/module/Carousel/hooks/useItemVisibilityStore.js +86 -0
- package/build/module/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
- package/build/module/Carousel/hooks/useLoopedData.js +24 -0
- package/build/module/Carousel/hooks/useLoopedData.js.map +1 -0
- package/build/module/Carousel/hooks/usePagingAnimator.js +192 -0
- package/build/module/Carousel/hooks/usePagingAnimator.js.map +1 -0
- package/build/module/Carousel/index.js +2 -1
- package/build/module/Carousel/index.js.map +1 -1
- package/build/module/Carousel/tick.js +6 -0
- package/build/module/Carousel/tick.js.map +1 -0
- package/build/module/Carousel/types.js +4 -0
- package/build/module/Carousel/types.js.map +1 -0
- package/build/module/ComicViewer/ComicViewer.js +201 -86
- package/build/module/ComicViewer/ComicViewer.js.map +1 -1
- package/build/module/ComicViewer/ComicViewerProps.js.map +1 -1
- package/build/module/ComicViewer/EncodedTile.js +3 -0
- package/build/module/ComicViewer/EncodedTile.js.map +1 -0
- package/build/module/ComicViewer/ReloadButton.js +33 -0
- package/build/module/ComicViewer/ReloadButton.js.map +1 -0
- package/build/module/ComicViewer/ViewerItem.js +49 -59
- package/build/module/ComicViewer/ViewerItem.js.map +1 -1
- package/build/module/ComicViewer/index.js.map +1 -1
- package/build/module/DateTimePicker/DateTimePicker.js +2 -2
- package/build/module/DateTimePicker/DateTimePicker.js.map +1 -1
- package/build/module/DateTimePicker/DateTimePickerProps.js.map +1 -1
- package/build/module/DateTimePicker/DateTimePickerProvider.js.map +1 -1
- package/build/module/DateTimePicker/YearPicker.js +21 -17
- package/build/module/DateTimePicker/YearPicker.js.map +1 -1
- package/build/module/DateTimePicker/index.js.map +1 -1
- package/build/module/DateTimePicker/utils.js +2 -1
- package/build/module/DateTimePicker/utils.js.map +1 -1
- package/build/module/FlipCard/FlipCard.js +7 -7
- package/build/module/FlipCard/FlipCard.js.map +1 -1
- package/build/module/FlipCard/FlipCardProps.js.map +1 -1
- package/build/module/FlipCard/index.js.map +1 -1
- package/build/module/StatusBarProvider/Provider.js.map +1 -1
- package/build/module/StatusBarProvider/StatusBarProvider.js.map +1 -1
- package/build/module/StatusBarProvider/StatusBarProviderProps.js.map +1 -1
- package/build/module/StatusBarProvider/index.js.map +1 -1
- package/build/module/ViewPager/FluxContext.js +4 -0
- package/build/module/ViewPager/FluxContext.js.map +1 -0
- package/build/module/ViewPager/InternalContext.js +7 -0
- package/build/module/ViewPager/InternalContext.js.map +1 -0
- package/build/module/ViewPager/PageStateContext.js +7 -0
- package/build/module/ViewPager/PageStateContext.js.map +1 -0
- package/build/module/ViewPager/ViewPager.js +57 -0
- package/build/module/ViewPager/ViewPager.js.map +1 -0
- package/build/module/ViewPager/ViewPager.native.js +127 -0
- package/build/module/ViewPager/ViewPager.native.js.map +1 -0
- package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
- package/build/module/ViewPager/components/ChildrenMemoizedPage.js +101 -0
- package/build/module/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
- package/build/module/ViewPager/components/FluxStoreProvider.js +20 -0
- package/build/module/ViewPager/components/FluxStoreProvider.js.map +1 -0
- package/build/module/ViewPager/components/index.js +3 -0
- package/build/module/ViewPager/components/index.js.map +1 -0
- package/build/module/ViewPager/hooks/index.js +8 -0
- package/build/module/ViewPager/hooks/index.js.map +1 -0
- package/build/module/ViewPager/hooks/useDispatch.js +10 -0
- package/build/module/ViewPager/hooks/useDispatch.js.map +1 -0
- package/build/module/ViewPager/hooks/useEagerState.js +12 -0
- package/build/module/ViewPager/hooks/useEagerState.js.map +1 -0
- package/build/module/ViewPager/hooks/useForceRender.js +7 -0
- package/build/module/ViewPager/hooks/useForceRender.js.map +1 -0
- package/build/module/ViewPager/hooks/useLazyState.js +30 -0
- package/build/module/ViewPager/hooks/useLazyState.js.map +1 -0
- package/build/module/ViewPager/hooks/usePageStore.js +25 -0
- package/build/module/ViewPager/hooks/usePageStore.js.map +1 -0
- package/build/module/ViewPager/hooks/useStore.js +14 -0
- package/build/module/ViewPager/hooks/useStore.js.map +1 -0
- package/build/module/ViewPager/hooks/useViewPagerPageState.js +7 -0
- package/build/module/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
- package/build/module/ViewPager/index.js +3 -1
- package/build/module/ViewPager/index.js.map +1 -1
- package/build/module/ViewPager/types.js +2 -0
- package/build/module/ViewPager/types.js.map +1 -0
- package/build/module/ViewPager/utils.js +6 -33
- package/build/module/ViewPager/utils.js.map +1 -1
- package/build/module/ViewabilityTrackerView/Viewability.js +2 -0
- package/build/module/ViewabilityTrackerView/Viewability.js.map +1 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js +28 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
- package/build/module/ViewabilityTrackerView/index.js +2 -0
- package/build/module/ViewabilityTrackerView/index.js.map +1 -0
- package/build/module/ViewabilityTrackerView/measureViewability.js +34 -0
- package/build/module/ViewabilityTrackerView/measureViewability.js.map +1 -0
- package/build/module/ViewabilityTrackerView/useViewabilityTracker.js +73 -0
- package/build/module/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
- package/build/module/hooks/index.js +2 -0
- package/build/module/hooks/index.js.map +1 -1
- package/build/module/hooks/useAppbarStyles.js.map +1 -1
- package/build/module/hooks/useDeferredExecutor.js +33 -0
- package/build/module/hooks/useDeferredExecutor.js.map +1 -0
- package/build/module/hooks/useElevationStyle.js.map +1 -1
- package/build/module/hooks/useHeight.js +4 -3
- package/build/module/hooks/useHeight.js.map +1 -1
- package/build/module/hooks/useIsMounted.js +13 -0
- package/build/module/hooks/useIsMounted.js.map +1 -0
- package/build/module/hooks/useUnstableCollapsibleAppBar.js +58 -45
- package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
- package/build/module/hooks/useUnstableToggleDisplayStyle.js +9 -7
- package/build/module/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
- package/build/module/index.js +2 -0
- package/build/module/index.js.map +1 -1
- package/build/typescript/AnimatedY/AnimatedY.d.ts +0 -1
- package/build/typescript/BottomSheet/BottomSheet.d.ts +2 -0
- package/build/typescript/BottomSheet/BottomSheetNative.d.ts +0 -1
- package/build/typescript/BottomSheet/BottomSheetProps.d.ts +6 -1
- package/build/typescript/BottomSheet/BottomSheetWeb.d.ts +0 -1
- package/build/typescript/BottomSheet/TransparentBackdrop.d.ts +0 -1
- package/build/typescript/BottomSheet/useDynamicSnapPoints.d.ts +11 -0
- package/build/typescript/Carousel/Carousel.d.ts +5 -0
- package/build/typescript/Carousel/CarouselProps.d.ts +33 -48
- package/build/typescript/Carousel/animation/animationUtils.d.ts +1 -0
- package/build/typescript/Carousel/animation/createDefaultItemStyle.d.ts +2 -0
- package/build/typescript/Carousel/animation/createDefaultScrollAnimation.d.ts +2 -0
- package/build/typescript/Carousel/animation/index.d.ts +4 -0
- package/build/typescript/Carousel/animation/normalItemStyleFactory.d.ts +2 -0
- package/build/typescript/Carousel/animation/parallaxItemStyleFactory.d.ts +9 -0
- package/build/typescript/Carousel/components/InternalContext.d.ts +14 -0
- package/build/typescript/Carousel/components/ItemView.d.ts +9 -0
- package/build/typescript/Carousel/components/RootView.d.ts +16 -0
- package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +12 -0
- package/build/typescript/Carousel/components/index.d.ts +4 -0
- package/build/typescript/Carousel/components/useItemInterpolation.d.ts +2 -0
- package/build/typescript/Carousel/hooks/index.d.ts +5 -0
- package/build/typescript/Carousel/hooks/useAutoplayController.d.ts +7 -0
- package/build/typescript/Carousel/hooks/useIndexController.d.ts +10 -0
- package/build/typescript/Carousel/hooks/useItemVisibilityStore.d.ts +7 -0
- package/build/typescript/Carousel/hooks/useLoopedData.d.ts +1 -0
- package/build/typescript/Carousel/hooks/usePagingAnimator.d.ts +17 -0
- package/build/typescript/Carousel/index.d.ts +3 -1
- package/build/typescript/Carousel/tick.d.ts +2 -0
- package/build/typescript/Carousel/types.d.ts +91 -0
- package/build/typescript/ComicViewer/ComicViewer.d.ts +1 -2
- package/build/typescript/ComicViewer/ComicViewerProps.d.ts +39 -44
- package/build/typescript/ComicViewer/EncodedTile.d.ts +2 -0
- package/build/typescript/ComicViewer/ReloadButton.d.ts +6 -0
- package/build/typescript/ComicViewer/ViewerItem.d.ts +37 -7
- package/build/typescript/ComicViewer/index.d.ts +2 -2
- package/build/typescript/DateTimePicker/DateTimePicker.d.ts +0 -1
- package/build/typescript/DateTimePicker/YearPicker.d.ts +0 -1
- package/build/typescript/FlipCard/FlipCard.d.ts +0 -1
- package/build/typescript/StatusBarProvider/StatusBarProvider.d.ts +0 -1
- package/build/typescript/ViewPager/FluxContext.d.ts +5 -0
- package/build/typescript/ViewPager/InternalContext.d.ts +7 -0
- package/build/typescript/ViewPager/PageStateContext.d.ts +6 -0
- package/build/typescript/ViewPager/ViewPager.d.ts +5 -0
- package/build/typescript/ViewPager/ViewPager.native.d.ts +5 -0
- package/build/typescript/ViewPager/ViewPagerProps.d.ts +18 -29
- package/build/typescript/ViewPager/components/ChildrenMemoizedPage.d.ts +14 -0
- package/build/typescript/ViewPager/components/FluxStoreProvider.d.ts +6 -0
- package/build/typescript/ViewPager/components/index.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/index.d.ts +7 -0
- package/build/typescript/ViewPager/hooks/useDispatch.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/useEagerState.d.ts +1 -0
- package/build/typescript/ViewPager/hooks/useForceRender.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/useLazyState.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/usePageStore.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/useStore.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/useViewPagerPageState.d.ts +1 -0
- package/build/typescript/ViewPager/index.d.ts +4 -1
- package/build/typescript/ViewPager/types.d.ts +12 -0
- package/build/typescript/ViewPager/utils.d.ts +5 -20
- package/build/typescript/ViewabilityTrackerView/Viewability.d.ts +3 -0
- package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerView.d.ts +2 -0
- package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerViewProps.d.ts +22 -0
- package/build/typescript/ViewabilityTrackerView/index.d.ts +2 -0
- package/build/typescript/ViewabilityTrackerView/measureViewability.d.ts +11 -0
- package/build/typescript/ViewabilityTrackerView/useViewabilityTracker.d.ts +11 -0
- package/build/typescript/hooks/index.d.ts +2 -0
- package/build/typescript/hooks/useDeferredExecutor.d.ts +11 -0
- package/build/typescript/hooks/useIsMounted.d.ts +4 -0
- package/build/typescript/hooks/useUnstableCollapsibleAppBar.d.ts +2 -3
- package/build/typescript/hooks/useUnstableToggleDisplayStyle.d.ts +2 -2
- package/build/typescript/index.d.ts +2 -0
- package/package.json +11 -25
- package/src/AnimatedY/AnimatedY.tsx +13 -10
- package/src/BottomSheet/BottomSheet.tsx +184 -0
- package/src/BottomSheet/BottomSheetNative.tsx +2 -0
- package/src/BottomSheet/BottomSheetProps.ts +7 -1
- package/src/BottomSheet/BottomSheetWeb.tsx +18 -5
- package/src/BottomSheet/useDynamicSnapPoints.ts +52 -0
- package/src/Carousel/Carousel.tsx +135 -0
- package/src/Carousel/CarouselProps.ts +42 -53
- package/src/Carousel/animation/animationUtils.ts +1 -0
- package/src/Carousel/animation/createDefaultItemStyle.ts +3 -0
- package/src/Carousel/animation/createDefaultScrollAnimation.ts +13 -0
- package/src/Carousel/animation/index.ts +4 -0
- package/src/Carousel/animation/normalItemStyleFactory.ts +19 -0
- package/src/Carousel/animation/parallaxItemStyleFactory.ts +79 -0
- package/src/Carousel/components/InternalContext.ts +33 -0
- package/src/Carousel/components/ItemView.tsx +66 -0
- package/src/Carousel/components/RootView.tsx +79 -0
- package/src/Carousel/components/ScrollViewGesture.tsx +92 -0
- package/src/Carousel/components/index.ts +4 -0
- package/src/Carousel/components/useItemInterpolation.ts +107 -0
- package/src/Carousel/hooks/index.ts +5 -0
- package/src/Carousel/hooks/useAutoplayController.ts +57 -0
- package/src/Carousel/hooks/useIndexController.tsx +57 -0
- package/src/Carousel/hooks/useItemVisibilityStore.ts +107 -0
- package/src/Carousel/hooks/useLoopedData.ts +26 -0
- package/src/Carousel/hooks/usePagingAnimator.ts +255 -0
- package/src/Carousel/index.ts +4 -2
- package/src/Carousel/tick.ts +6 -0
- package/src/Carousel/types.ts +114 -0
- package/src/ComicViewer/ComicViewer.tsx +222 -93
- package/src/ComicViewer/ComicViewerProps.ts +42 -48
- package/src/ComicViewer/EncodedTile.ts +3 -0
- package/src/ComicViewer/ReloadButton.tsx +36 -0
- package/src/ComicViewer/ViewerItem.tsx +91 -63
- package/src/ComicViewer/index.ts +2 -2
- package/src/DateTimePicker/DateTimePicker.tsx +2 -2
- package/src/FlipCard/FlipCard.tsx +8 -8
- package/src/ViewPager/FluxContext.ts +8 -0
- package/src/ViewPager/InternalContext.ts +13 -0
- package/src/ViewPager/PageStateContext.ts +11 -0
- package/src/ViewPager/ViewPager.native.tsx +150 -0
- package/src/ViewPager/ViewPager.tsx +69 -0
- package/src/ViewPager/ViewPagerProps.ts +20 -35
- package/src/ViewPager/components/ChildrenMemoizedPage.tsx +124 -0
- package/src/ViewPager/components/FluxStoreProvider.tsx +27 -0
- package/src/ViewPager/components/index.ts +2 -0
- package/src/ViewPager/hooks/index.ts +7 -0
- package/src/ViewPager/hooks/useDispatch.ts +11 -0
- package/src/ViewPager/hooks/useEagerState.ts +14 -0
- package/src/ViewPager/hooks/useForceRender.ts +7 -0
- package/src/ViewPager/hooks/useLazyState.ts +32 -0
- package/src/ViewPager/hooks/usePageStore.ts +30 -0
- package/src/ViewPager/hooks/useStore.ts +15 -0
- package/src/ViewPager/hooks/useViewPagerPageState.ts +6 -0
- package/src/ViewPager/index.ts +11 -2
- package/src/ViewPager/types.ts +15 -0
- package/src/ViewPager/utils.tsx +9 -56
- package/src/ViewabilityTrackerView/Viewability.ts +3 -0
- package/src/ViewabilityTrackerView/ViewabilityTrackerView.tsx +33 -0
- package/src/ViewabilityTrackerView/ViewabilityTrackerViewProps.ts +25 -0
- package/src/ViewabilityTrackerView/index.ts +2 -0
- package/src/ViewabilityTrackerView/measureViewability.ts +54 -0
- package/src/ViewabilityTrackerView/useViewabilityTracker.ts +85 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useDeferredExecutor.ts +46 -0
- package/src/hooks/useHeight.ts +2 -2
- package/src/hooks/useIsMounted.ts +19 -0
- package/src/hooks/useUnstableCollapsibleAppBar.ts +62 -45
- package/src/hooks/useUnstableToggleDisplayStyle.ts +8 -6
- package/src/index.ts +3 -0
- package/build/commonjs/Carousel/CarouselNative.js +0 -72
- package/build/commonjs/Carousel/CarouselNative.js.map +0 -1
- package/build/commonjs/Carousel/CarouselWeb.js +0 -237
- package/build/commonjs/Carousel/CarouselWeb.js.map +0 -1
- package/build/commonjs/Carousel/index.native.js.map +0 -1
- package/build/commonjs/Carousel/utils.js +0 -19
- package/build/commonjs/Carousel/utils.js.map +0 -1
- package/build/commonjs/ComicViewer/ComicViewerItemProps.js +0 -6
- package/build/commonjs/ComicViewer/ComicViewerItemProps.js.map +0 -1
- package/build/commonjs/ViewPager/ChildrenMemoizedPage.js +0 -49
- package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +0 -1
- package/build/commonjs/ViewPager/ViewPagerNative.js +0 -72
- package/build/commonjs/ViewPager/ViewPagerNative.js.map +0 -1
- package/build/commonjs/ViewPager/ViewPagerWeb.js +0 -55
- package/build/commonjs/ViewPager/ViewPagerWeb.js.map +0 -1
- package/build/commonjs/ViewPager/index.native.js +0 -16
- package/build/commonjs/ViewPager/index.native.js.map +0 -1
- package/build/commonjs/hooks/useWidth.js +0 -29
- package/build/commonjs/hooks/useWidth.js.map +0 -1
- package/build/module/Carousel/CarouselNative.js +0 -54
- package/build/module/Carousel/CarouselNative.js.map +0 -1
- package/build/module/Carousel/CarouselWeb.js +0 -215
- package/build/module/Carousel/CarouselWeb.js.map +0 -1
- package/build/module/Carousel/index.native.js +0 -2
- package/build/module/Carousel/index.native.js.map +0 -1
- package/build/module/Carousel/utils.js +0 -7
- package/build/module/Carousel/utils.js.map +0 -1
- package/build/module/ComicViewer/ComicViewerItemProps.js +0 -2
- package/build/module/ComicViewer/ComicViewerItemProps.js.map +0 -1
- package/build/module/ViewPager/ChildrenMemoizedPage.js +0 -37
- package/build/module/ViewPager/ChildrenMemoizedPage.js.map +0 -1
- package/build/module/ViewPager/ViewPagerNative.js +0 -53
- package/build/module/ViewPager/ViewPagerNative.js.map +0 -1
- package/build/module/ViewPager/ViewPagerWeb.js +0 -41
- package/build/module/ViewPager/ViewPagerWeb.js.map +0 -1
- package/build/module/ViewPager/index.native.js +0 -2
- package/build/module/ViewPager/index.native.js.map +0 -1
- package/build/module/hooks/useWidth.js +0 -15
- package/build/module/hooks/useWidth.js.map +0 -1
- package/build/typescript/Carousel/CarouselNative.d.ts +0 -3
- package/build/typescript/Carousel/CarouselWeb.d.ts +0 -4
- package/build/typescript/Carousel/index.native.d.ts +0 -1
- package/build/typescript/Carousel/utils.d.ts +0 -6
- package/build/typescript/ComicViewer/ComicViewerItemProps.d.ts +0 -12
- package/build/typescript/ViewPager/ChildrenMemoizedPage.d.ts +0 -4
- package/build/typescript/ViewPager/ViewPagerNative.d.ts +0 -3
- package/build/typescript/ViewPager/ViewPagerWeb.d.ts +0 -3
- package/build/typescript/ViewPager/index.native.d.ts +0 -1
- package/build/typescript/hooks/useWidth.d.ts +0 -2
- package/src/Carousel/CarouselNative.tsx +0 -67
- package/src/Carousel/CarouselWeb.tsx +0 -222
- package/src/Carousel/index.native.ts +0 -1
- package/src/Carousel/utils.ts +0 -11
- package/src/ComicViewer/ComicViewerItemProps.ts +0 -15
- package/src/ViewPager/ChildrenMemoizedPage.tsx +0 -36
- package/src/ViewPager/ViewPagerNative.tsx +0 -66
- package/src/ViewPager/ViewPagerWeb.tsx +0 -52
- package/src/ViewPager/index.native.ts +0 -1
- package/src/hooks/useWidth.ts +0 -17
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = AnimatedY;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
11
11
|
|
|
@@ -13,7 +13,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const ANIMATION_CONFIG = {
|
|
17
|
+
duration: 150,
|
|
18
|
+
easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.exp)
|
|
19
|
+
};
|
|
17
20
|
|
|
18
21
|
function AnimatedY(props) {
|
|
19
22
|
const {
|
|
@@ -21,24 +24,17 @@ function AnimatedY(props) {
|
|
|
21
24
|
translateY,
|
|
22
25
|
style
|
|
23
26
|
} = props;
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const animatedStyle = _reactNativeReanimated.default.useAnimatedStyle(() => ({
|
|
27
|
+
const animatedY = (0, _reactNativeReanimated.useSharedValue)(translateY);
|
|
28
|
+
const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
28
29
|
transform: [{
|
|
29
30
|
translateY: animatedY.value
|
|
30
31
|
}]
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
_react.default.useEffect(() => {
|
|
32
|
+
}), []);
|
|
33
|
+
(0, _react.useEffect)(() => {
|
|
34
34
|
if (translateY >= 0) {
|
|
35
|
-
animatedY.value = _reactNativeReanimated.
|
|
36
|
-
duration: 150,
|
|
37
|
-
easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.exp)
|
|
38
|
-
});
|
|
35
|
+
animatedY.value = (0, _reactNativeReanimated.withTiming)(translateY, ANIMATION_CONFIG);
|
|
39
36
|
}
|
|
40
37
|
}, [translateY]);
|
|
41
|
-
|
|
42
38
|
return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
43
39
|
children: children,
|
|
44
40
|
style: [animatedStyle, style]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["ANIMATION_CONFIG","duration","easing","Easing","out","exp","AnimatedY","props","children","translateY","style","animatedY","useSharedValue","animatedStyle","useAnimatedStyle","transform","value","useEffect","withTiming"],"sources":["AnimatedY.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { Easing, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport type AnimatedYProps from './AnimatedYProps';\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = {\n duration: 150,\n easing: Easing.out(Easing.exp),\n};\n\nexport default function AnimatedY(props: AnimatedYProps) {\n const {\n children,\n translateY,\n style,\n } = props;\n\n const animatedY = useSharedValue(translateY);\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: animatedY.value }],\n }), []);\n\n useEffect(() => {\n if (translateY >= 0) {\n animatedY.value = withTiming(translateY, ANIMATION_CONFIG);\n }\n }, [translateY]);\n\n return (\n <Animated.View\n children={children}\n style={[\n animatedStyle,\n style,\n ]}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAGA,MAAMA,gBAA4C,GAAG;EACjDC,QAAQ,EAAE,GADuC;EAEjDC,MAAM,EAAEC,6BAAA,CAAOC,GAAP,CAAWD,6BAAA,CAAOE,GAAlB;AAFyC,CAArD;;AAKe,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;EACrD,MAAM;IACFC,QADE;IAEFC,UAFE;IAGFC;EAHE,IAIFH,KAJJ;EAMA,MAAMI,SAAS,GAAG,IAAAC,qCAAA,EAAeH,UAAf,CAAlB;EACA,MAAMI,aAAa,GAAG,IAAAC,uCAAA,EAAiB,OAAO;IAC1CC,SAAS,EAAE,CAAC;MAAEN,UAAU,EAAEE,SAAS,CAACK;IAAxB,CAAD;EAD+B,CAAP,CAAjB,EAElB,EAFkB,CAAtB;EAIA,IAAAC,gBAAA,EAAU,MAAM;IACZ,IAAIR,UAAU,IAAI,CAAlB,EAAqB;MACjBE,SAAS,CAACK,KAAV,GAAkB,IAAAE,iCAAA,EAAWT,UAAX,EAAuBT,gBAAvB,CAAlB;IACH;EACJ,CAJD,EAIG,CAACS,UAAD,CAJH;EAMA,oBACI,6BAAC,8BAAD,CAAU,IAAV;IACI,QAAQ,EAAED,QADd;IAEI,KAAK,EAAE,CACHK,aADG,EAEHH,KAFG;EAFX,EADJ;AASH;;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["AnimatedYProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport default interface AnimatedYProps extends ComponentProps<{\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The translate y value of the component.\n */\n translateY: number;\n}> {}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './AnimatedY';\nexport type { default as AnimatedYProps } from './AnimatedYProps';\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = BottomSheet;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _core = require("@fountain-ui/core");
|
|
13
|
+
|
|
14
|
+
var _useDynamicSnapPoints = _interopRequireDefault(require("./useDynamicSnapPoints"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
|
+
|
|
24
|
+
const useStyles = function () {
|
|
25
|
+
const theme = (0, _core.useTheme)();
|
|
26
|
+
return {
|
|
27
|
+
root: {
|
|
28
|
+
justifyContent: 'flex-end',
|
|
29
|
+
zIndex: theme.zIndex.dialog
|
|
30
|
+
},
|
|
31
|
+
animated: {
|
|
32
|
+
alignSelf: 'center',
|
|
33
|
+
maxWidth: 720,
|
|
34
|
+
width: '100%'
|
|
35
|
+
},
|
|
36
|
+
paper: {
|
|
37
|
+
borderBottomLeftRadius: 0,
|
|
38
|
+
borderBottomRightRadius: 0,
|
|
39
|
+
flexGrow: 1,
|
|
40
|
+
overflow: 'hidden'
|
|
41
|
+
},
|
|
42
|
+
scrollView: {
|
|
43
|
+
flexGrow: 1
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
function BottomSheet(props) {
|
|
49
|
+
const {
|
|
50
|
+
backdropOpacity,
|
|
51
|
+
children,
|
|
52
|
+
header,
|
|
53
|
+
index,
|
|
54
|
+
onChange,
|
|
55
|
+
snapPoints: initialSnapPoints
|
|
56
|
+
} = props;
|
|
57
|
+
const styles = useStyles();
|
|
58
|
+
const contentLayout = (0, _react.useRef)({
|
|
59
|
+
x: 0,
|
|
60
|
+
y: 0,
|
|
61
|
+
width: 0,
|
|
62
|
+
height: 0
|
|
63
|
+
});
|
|
64
|
+
const currentScrollY = (0, _react.useRef)(0);
|
|
65
|
+
const {
|
|
66
|
+
snapPoints,
|
|
67
|
+
handleContentLayout
|
|
68
|
+
} = (0, _useDynamicSnapPoints.default)({
|
|
69
|
+
index,
|
|
70
|
+
initialSnapPoints
|
|
71
|
+
});
|
|
72
|
+
const height = snapPoints[snapPoints.length - 1] ?? 0;
|
|
73
|
+
const translateY = height - (snapPoints[index] ?? 0);
|
|
74
|
+
const animatedY = (0, _core.useAnimatedValue)(translateY);
|
|
75
|
+
|
|
76
|
+
const isInsideScrollView = (locationX, locationY) => {
|
|
77
|
+
const {
|
|
78
|
+
current: {
|
|
79
|
+
x,
|
|
80
|
+
y,
|
|
81
|
+
width,
|
|
82
|
+
height
|
|
83
|
+
}
|
|
84
|
+
} = contentLayout;
|
|
85
|
+
return locationX >= x && locationX <= x + width && locationY >= y && locationY <= y + height;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const panResponder = (0, _react.useMemo)(() => _reactNative.PanResponder.create({
|
|
89
|
+
onMoveShouldSetPanResponder: (event, gestureState) => {
|
|
90
|
+
const {
|
|
91
|
+
nativeEvent: {
|
|
92
|
+
locationX,
|
|
93
|
+
locationY
|
|
94
|
+
}
|
|
95
|
+
} = event;
|
|
96
|
+
|
|
97
|
+
if (isInsideScrollView(locationX, locationY)) {
|
|
98
|
+
return gestureState.dy > 0 && currentScrollY.current === 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return true;
|
|
102
|
+
},
|
|
103
|
+
onPanResponderMove: (_, gestureState) => {
|
|
104
|
+
if (gestureState.dy > 0) {
|
|
105
|
+
animatedY.setValue(translateY + gestureState.dy);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
onPanResponderRelease: (_, gestureState) => {
|
|
109
|
+
if (gestureState.dy > 0 && gestureState.vy > 0.5) {
|
|
110
|
+
handleClose();
|
|
111
|
+
} else {
|
|
112
|
+
_reactNative.Animated.timing(animatedY, {
|
|
113
|
+
toValue: translateY,
|
|
114
|
+
useNativeDriver: false,
|
|
115
|
+
duration: 300
|
|
116
|
+
}).start();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}), [translateY]);
|
|
120
|
+
(0, _react.useEffect)(() => {
|
|
121
|
+
if (translateY >= 0) {
|
|
122
|
+
_reactNative.Animated.timing(animatedY, {
|
|
123
|
+
toValue: translateY,
|
|
124
|
+
useNativeDriver: false,
|
|
125
|
+
duration: 300
|
|
126
|
+
}).start();
|
|
127
|
+
}
|
|
128
|
+
}, [translateY]);
|
|
129
|
+
|
|
130
|
+
const handleClose = () => {
|
|
131
|
+
if (onChange) {
|
|
132
|
+
onChange(-1);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const handleScrollViewLayout = event => {
|
|
137
|
+
contentLayout.current = event.nativeEvent.layout;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const handleScroll = event => {
|
|
141
|
+
currentScrollY.current = event.nativeEvent.contentOffset.y;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const animatedStyles = [styles.animated, {
|
|
145
|
+
transform: [{
|
|
146
|
+
translateY: animatedY
|
|
147
|
+
}]
|
|
148
|
+
}];
|
|
149
|
+
const paperStyles = [styles.paper, { ...(height !== 0 ? {
|
|
150
|
+
height
|
|
151
|
+
} : {})
|
|
152
|
+
}];
|
|
153
|
+
const contentStyle = { ...(snapPoints[index] !== 0 ? {
|
|
154
|
+
height: snapPoints[index]
|
|
155
|
+
} : {})
|
|
156
|
+
};
|
|
157
|
+
return /*#__PURE__*/_react.default.createElement(_core.Modal, {
|
|
158
|
+
backdropOpacity: backdropOpacity,
|
|
159
|
+
onClose: handleClose,
|
|
160
|
+
visible: index >= 0,
|
|
161
|
+
style: (0, _core.css)([_core.StyleSheet.absoluteFill, styles.root])
|
|
162
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, _extends({
|
|
163
|
+
style: animatedStyles
|
|
164
|
+
}, panResponder.panHandlers), /*#__PURE__*/_react.default.createElement(_core.Paper, {
|
|
165
|
+
elevation: 12,
|
|
166
|
+
style: paperStyles
|
|
167
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
168
|
+
style: contentStyle,
|
|
169
|
+
onLayout: handleContentLayout
|
|
170
|
+
}, header, /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, {
|
|
171
|
+
onLayout: handleScrollViewLayout,
|
|
172
|
+
onScroll: handleScroll,
|
|
173
|
+
scrollEventThrottle: 300,
|
|
174
|
+
style: styles.scrollView
|
|
175
|
+
}, children)))));
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=BottomSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useStyles","theme","useTheme","root","justifyContent","zIndex","dialog","animated","alignSelf","maxWidth","width","paper","borderBottomLeftRadius","borderBottomRightRadius","flexGrow","overflow","scrollView","BottomSheet","props","backdropOpacity","children","header","index","onChange","snapPoints","initialSnapPoints","styles","contentLayout","useRef","x","y","height","currentScrollY","handleContentLayout","useDynamicSnapPoints","length","translateY","animatedY","useAnimatedValue","isInsideScrollView","locationX","locationY","current","panResponder","useMemo","PanResponder","create","onMoveShouldSetPanResponder","event","gestureState","nativeEvent","dy","onPanResponderMove","_","setValue","onPanResponderRelease","vy","handleClose","Animated","timing","toValue","useNativeDriver","duration","start","useEffect","handleScrollViewLayout","layout","handleScroll","contentOffset","animatedStyles","transform","paperStyles","contentStyle","css","StyleSheet","absoluteFill","panHandlers"],"sources":["BottomSheet.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from 'react';\nimport {\n Animated,\n LayoutChangeEvent,\n LayoutRectangle,\n NativeScrollEvent,\n NativeSyntheticEvent,\n PanResponder,\n ScrollView,\n View,\n} from 'react-native';\nimport { css, Modal, Paper, StyleSheet, useAnimatedValue, useTheme } from '@fountain-ui/core';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport BottomSheetProps from './BottomSheetProps';\nimport useDynamicSnapPoints from './useDynamicSnapPoints';\n\ntype BottomSheetStyles = NamedStylesStringUnion<'root' | 'animated' | 'paper' | 'scrollView'>;\n\nconst useStyles: UseStyles<BottomSheetStyles> = function (): BottomSheetStyles {\n const theme = useTheme();\n\n return {\n root: {\n justifyContent: 'flex-end',\n zIndex: theme.zIndex.dialog,\n },\n animated: {\n alignSelf: 'center',\n maxWidth: 720,\n width: '100%',\n },\n paper: {\n borderBottomLeftRadius: 0,\n borderBottomRightRadius: 0,\n flexGrow: 1,\n overflow: 'hidden',\n },\n scrollView: {\n flexGrow: 1,\n },\n };\n};\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity,\n children,\n header,\n index,\n onChange,\n snapPoints: initialSnapPoints,\n } = props;\n\n const styles = useStyles();\n\n const contentLayout = useRef<LayoutRectangle>({ x: 0, y: 0, width: 0, height: 0 });\n const currentScrollY = useRef<number>(0);\n\n const {\n snapPoints,\n handleContentLayout,\n } = useDynamicSnapPoints({\n index,\n initialSnapPoints,\n });\n\n const height = snapPoints[snapPoints.length - 1] ?? 0;\n const translateY = height - (snapPoints[index] ?? 0);\n\n const animatedY = useAnimatedValue(translateY);\n\n const isInsideScrollView = (locationX: number, locationY: number): boolean => {\n const {\n current: { x, y, width, height },\n } = contentLayout;\n\n return locationX >= x && locationX <= x + width && locationY >= y && locationY <= y + height;\n };\n\n const panResponder = useMemo(() => (\n PanResponder.create({\n onMoveShouldSetPanResponder: (event, gestureState) => {\n const {\n nativeEvent: { locationX, locationY },\n } = event;\n\n if (isInsideScrollView(locationX, locationY)) {\n return gestureState.dy > 0 && currentScrollY.current === 0;\n }\n\n return true;\n },\n onPanResponderMove: (_, gestureState) => {\n if (gestureState.dy > 0) {\n animatedY.setValue(translateY + gestureState.dy);\n }\n },\n onPanResponderRelease: (_, gestureState) => {\n if (gestureState.dy > 0 && gestureState.vy > 0.5) {\n handleClose();\n } else {\n Animated.timing(animatedY, {\n toValue: translateY,\n useNativeDriver: false,\n duration: 300,\n }).start();\n }\n },\n })\n ), [translateY]);\n\n useEffect(() => {\n if (translateY >= 0) {\n Animated.timing(animatedY, {\n toValue: translateY,\n useNativeDriver: false,\n duration: 300,\n }).start();\n }\n }, [translateY]);\n\n const handleClose = () => {\n if (onChange) {\n onChange(-1);\n }\n };\n\n const handleScrollViewLayout = (event: LayoutChangeEvent) => {\n contentLayout.current = event.nativeEvent.layout;\n };\n\n const handleScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {\n currentScrollY.current = event.nativeEvent.contentOffset.y;\n };\n\n const animatedStyles = [\n styles.animated,\n { transform: [{ translateY: animatedY }] },\n ];\n\n const paperStyles = [\n styles.paper,\n { ...(height !== 0 ? { height } : {}) },\n ];\n\n const contentStyle = {\n ...(snapPoints[index] !== 0 ? { height: snapPoints[index] } : {}),\n };\n\n return (\n <Modal\n backdropOpacity={backdropOpacity}\n onClose={handleClose}\n visible={index >= 0}\n style={css([StyleSheet.absoluteFill, styles.root])}\n >\n <Animated.View\n style={animatedStyles}\n {...panResponder.panHandlers}\n >\n <Paper\n elevation={12}\n style={paperStyles}\n >\n <View\n style={contentStyle}\n onLayout={handleContentLayout}\n >\n {header}\n\n <ScrollView\n onLayout={handleScrollViewLayout}\n onScroll={handleScroll}\n scrollEventThrottle={300}\n style={styles.scrollView}\n >\n {children}\n </ScrollView>\n </View>\n </Paper>\n </Animated.View>\n </Modal>\n );\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAUA;;AAGA;;;;;;;;;;AAIA,MAAMA,SAAuC,GAAG,YAA+B;EAC3E,MAAMC,KAAK,GAAG,IAAAC,cAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,cAAc,EAAE,UADd;MAEFC,MAAM,EAAEJ,KAAK,CAACI,MAAN,CAAaC;IAFnB,CADH;IAKHC,QAAQ,EAAE;MACNC,SAAS,EAAE,QADL;MAENC,QAAQ,EAAE,GAFJ;MAGNC,KAAK,EAAE;IAHD,CALP;IAUHC,KAAK,EAAE;MACHC,sBAAsB,EAAE,CADrB;MAEHC,uBAAuB,EAAE,CAFtB;MAGHC,QAAQ,EAAE,CAHP;MAIHC,QAAQ,EAAE;IAJP,CAVJ;IAgBHC,UAAU,EAAE;MACRF,QAAQ,EAAE;IADF;EAhBT,CAAP;AAoBH,CAvBD;;AAyBe,SAASG,WAAT,CAAqBC,KAArB,EAA8C;EACzD,MAAM;IACFC,eADE;IAEFC,QAFE;IAGFC,MAHE;IAIFC,KAJE;IAKFC,QALE;IAMFC,UAAU,EAAEC;EANV,IAOFP,KAPJ;EASA,MAAMQ,MAAM,GAAG1B,SAAS,EAAxB;EAEA,MAAM2B,aAAa,GAAG,IAAAC,aAAA,EAAwB;IAAEC,CAAC,EAAE,CAAL;IAAQC,CAAC,EAAE,CAAX;IAAcpB,KAAK,EAAE,CAArB;IAAwBqB,MAAM,EAAE;EAAhC,CAAxB,CAAtB;EACA,MAAMC,cAAc,GAAG,IAAAJ,aAAA,EAAe,CAAf,CAAvB;EAEA,MAAM;IACFJ,UADE;IAEFS;EAFE,IAGF,IAAAC,6BAAA,EAAqB;IACrBZ,KADqB;IAErBG;EAFqB,CAArB,CAHJ;EAQA,MAAMM,MAAM,GAAGP,UAAU,CAACA,UAAU,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A,MAAMyC,YAAY,GAAG,EACjB,IAAIhD,UAAU,CAACF,KAAD,CAAV,KAAsB,CAAtB,GAA0B;MAAES,MAAM,EAAEP,UAAU,CAACF,KAAD;IAApB,CAA1B,GAA0D,EAA9D;EADiB,CAArB;EAIA,oBACI,6BAAC,WAAD;IACI,eAAe,EAAEH,eADrB;IAEI,OAAO,EAAEsC,WAFb;IAGI,OAAO,EAAEnC,KAAK,IAAI,CAHtB;IAII,KAAK,EAAE,IAAAmD,SAAA,EAAI,CAACC,gBAAA,CAAWC,YAAZ,EAA0BjD,MAAM,CAACvB,IAAjC,CAAJ;EAJX,gBAMI,6BAAC,qBAAD,CAAU,IAAV;IACI,KAAK,EAAEkE;EADX,GAEQ1B,YAAY,CAACiC,WAFrB,gBAII,6BAAC,WAAD;IACI,SAAS,EAAE,EADf;IAEI,KAAK,EAAEL;EAFX,gBAII,6BAAC,iBAAD;IACI,KAAK,EAAEC,YADX;IAEI,QAAQ,EAAEvC;EAFd,GAIKZ,MAJL,eAMI,6BAAC,uBAAD;IACI,QAAQ,EAAE4C,sBADd;IAEI,QAAQ,EAAEE,YAFd;IAGI,mBAAmB,EAAE,GAHzB;IAII,KAAK,EAAEzC,MAAM,CAACV;EAJlB,GAMKI,QANL,CANJ,CAJJ,CAJJ,CANJ,CADJ;AAkCH"}
|
|
@@ -17,7 +17,7 @@ var _TransparentBackdrop = _interopRequireDefault(require("./TransparentBackdrop
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
|
-
function _extends() { _extends = Object.assign
|
|
20
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
21
|
|
|
22
22
|
const NoHandle = () => null;
|
|
23
23
|
|
|
@@ -85,7 +85,8 @@ function BottomSheet(props) {
|
|
|
85
85
|
const OpacityAwareBackdrop = props => /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetBackdrop, _extends({}, props, {
|
|
86
86
|
appearsOnIndex: 0,
|
|
87
87
|
disappearsOnIndex: -1,
|
|
88
|
-
opacity: backdropOpacity
|
|
88
|
+
opacity: backdropOpacity,
|
|
89
|
+
pressBehavior: onChange ? 'close' : 'none'
|
|
89
90
|
}));
|
|
90
91
|
|
|
91
92
|
return /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetModalProvider, null, /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetModal, {
|
|
@@ -98,7 +99,8 @@ function BottomSheet(props) {
|
|
|
98
99
|
onDismiss: handleDismiss,
|
|
99
100
|
ref: bottomSheetRef,
|
|
100
101
|
snapPoints: snapPoints,
|
|
101
|
-
style: modalStyle
|
|
102
|
+
style: modalStyle,
|
|
103
|
+
enablePanDownToClose: Boolean(onChange)
|
|
102
104
|
}, children));
|
|
103
105
|
}
|
|
104
106
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["NoHandle","BottomSheet","props","backdropOpacity","children","index","onChange","snapPoints","indexRef","React","useRef","bottomSheetRef","handleChange","useCallback","newIndex","current","handleDismiss","useEffect","present","dismiss","snapToIndex","theme","useTheme","shadow","modalStyle","backgroundColor","Platform","select","android","elevation","ios","web","boxShadow","backgroundStyle","palette","paper","default","isBackdropTransparent","OpacityAwareBackdrop","TransparentBackdrop","Boolean"],"sources":["BottomSheetNative.tsx"],"sourcesContent":["import React from 'react';\nimport { Platform } from 'react-native';\nimport { useTheme } from '@fountain-ui/styles';\nimport {\n BottomSheetBackdrop,\n BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetModalProvider,\n} from '@gorhom/bottom-sheet';\nimport type BottomSheetProps from './BottomSheetProps';\nimport TransparentBackdrop from './TransparentBackdrop';\n\nconst NoHandle = () => null;\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity = 0.5,\n children,\n index,\n onChange,\n snapPoints,\n } = props;\n\n const indexRef = React.useRef<number>(-1);\n const bottomSheetRef = React.useRef<BottomSheetModal | null>(null);\n\n const handleChange = React.useCallback((newIndex: number) => {\n indexRef.current = newIndex;\n\n if (onChange) {\n onChange(newIndex);\n }\n }, [onChange]);\n\n const handleDismiss = React.useCallback(() => {\n handleChange(-1);\n }, [handleChange]);\n\n React.useEffect(() => {\n if (index === indexRef.current) {\n return;\n }\n\n if (indexRef.current < 0 && index >= 0) {\n bottomSheetRef.current?.present();\n } else if (indexRef.current >= 0 && index < 0) {\n bottomSheetRef.current?.dismiss();\n } else {\n // @ts-ignore\n bottomSheetRef.current?.snapToIndex(index);\n }\n }, [index]);\n\n const theme = useTheme();\n const shadow = theme.shadow[12];\n const modalStyle = {\n backgroundColor: '#ffffff00',\n ...Platform.select<object>({\n android: shadow?.elevation,\n ios: shadow?.shadow,\n web: shadow?.boxShadow,\n }),\n };\n const backgroundStyle = {\n backgroundColor: theme.palette.paper.default,\n };\n\n const isBackdropTransparent = backdropOpacity <= 0;\n\n const OpacityAwareBackdrop = (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={backdropOpacity}\n pressBehavior={onChange ? 'close' : 'none'}\n />\n );\n\n return (\n <BottomSheetModalProvider>\n <BottomSheetModal\n backdropComponent={isBackdropTransparent ? TransparentBackdrop : OpacityAwareBackdrop}\n // @ts-ignore\n backgroundStyle={backgroundStyle}\n index={index}\n handleComponent={NoHandle}\n onChange={handleChange}\n onDismiss={handleDismiss}\n ref={bottomSheetRef}\n snapPoints={snapPoints}\n style={modalStyle}\n enablePanDownToClose={Boolean(onChange)}\n >\n {children}\n </BottomSheetModal>\n </BottomSheetModalProvider>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;;;;;AAEA,MAAMA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],"sources":["BottomSheetProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport default interface BottomSheetProps extends ComponentProps<{\n /**\n * Opacity for BackdropComponent\n * @default 0.5\n */\n backdropOpacity?: number;\n\n /**\n * BottomSheet children, usually the included sub-components.\n */\n children?: React.ReactNode;\n\n /**\n * Area to be fixed on the top of the bottom sheet.\n */\n header?: React.ReactNode;\n\n /**\n * Snap index. You could also provide -1 to bottom sheet in closed state.\n */\n index: number;\n\n /**\n * Callback fired when the index is changed.\n * Important! Use memoized value.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * Points for the bottom sheet to snap to, points should be sorted from bottom to top.\n * Important! Use memoized value.\n * Only number type or string type(~% format) can be used.\n */\n snapPoints: Array<number | string>;\n}> {}\n"],"mappings":""}
|
|
@@ -7,6 +7,8 @@ exports.default = BottomSheet;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
10
12
|
var _core = require("@fountain-ui/core");
|
|
11
13
|
|
|
12
14
|
var _AnimatedY = _interopRequireDefault(require("../AnimatedY"));
|
|
@@ -34,15 +36,22 @@ const useStyles = function () {
|
|
|
34
36
|
};
|
|
35
37
|
};
|
|
36
38
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
+
const convertHeightAsPixel = (windowHeight, value) => {
|
|
40
|
+
if (typeof value === 'number') {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const percentageRegex = new RegExp(/^[0-9]+%$/);
|
|
45
|
+
|
|
46
|
+
if (percentageRegex.test(value)) {
|
|
47
|
+
const percentage = parseFloat(value) / 100;
|
|
48
|
+
return isNaN(percentage) ? 0 : Math.round(windowHeight * percentage);
|
|
49
|
+
}
|
|
39
50
|
|
|
40
|
-
return
|
|
51
|
+
return 0;
|
|
41
52
|
};
|
|
42
53
|
|
|
43
54
|
function BottomSheet(props) {
|
|
44
|
-
var _snapPoints$index;
|
|
45
|
-
|
|
46
55
|
const {
|
|
47
56
|
backdropOpacity,
|
|
48
57
|
children,
|
|
@@ -51,6 +60,9 @@ function BottomSheet(props) {
|
|
|
51
60
|
snapPoints
|
|
52
61
|
} = props;
|
|
53
62
|
const styles = useStyles();
|
|
63
|
+
const {
|
|
64
|
+
height: windowHeight
|
|
65
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
54
66
|
|
|
55
67
|
const handleClose = () => {
|
|
56
68
|
if (onChange) {
|
|
@@ -58,8 +70,8 @@ function BottomSheet(props) {
|
|
|
58
70
|
}
|
|
59
71
|
};
|
|
60
72
|
|
|
61
|
-
const height =
|
|
62
|
-
const translateY = height - (
|
|
73
|
+
const height = convertHeightAsPixel(windowHeight, snapPoints[snapPoints.length - 1] ?? 0);
|
|
74
|
+
const translateY = height - convertHeightAsPixel(windowHeight, snapPoints[index] ?? 0);
|
|
63
75
|
return /*#__PURE__*/_react.default.createElement(_core.Modal, {
|
|
64
76
|
backdropOpacity: backdropOpacity,
|
|
65
77
|
onClose: handleClose,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["useStyles","theme","useTheme","root","justifyContent","zIndex","dialog","animated","alignSelf","maxWidth","width","paper","borderBottomLeftRadius","borderBottomRightRadius","flexGrow","overflow","convertHeightAsPixel","windowHeight","value","percentageRegex","RegExp","test","percentage","parseFloat","isNaN","Math","round","BottomSheet","props","backdropOpacity","children","index","onChange","snapPoints","styles","height","useWindowDimensions","handleClose","length","translateY","css","StyleSheet","absoluteFill"],"sources":["BottomSheetWeb.tsx"],"sourcesContent":["import React from 'react';\nimport { useWindowDimensions } from 'react-native';\nimport { Modal, Paper, StyleSheet, css, useTheme } from '@fountain-ui/core';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport AnimatedY from '../AnimatedY';\nimport type BottomSheetProps from './BottomSheetProps';\n\ntype BottomSheetStyles = NamedStylesStringUnion<'root' | 'animated' | 'paper'>;\n\nconst useStyles: UseStyles<BottomSheetStyles> = function (): BottomSheetStyles {\n const theme = useTheme();\n\n return {\n root: {\n justifyContent: 'flex-end',\n zIndex: theme.zIndex.dialog,\n },\n animated: {\n alignSelf: 'center',\n maxWidth: 720,\n width: '100%',\n },\n paper: {\n borderBottomLeftRadius: 0,\n borderBottomRightRadius: 0,\n flexGrow: 1,\n overflow: 'hidden',\n },\n };\n};\n\nconst convertHeightAsPixel = (windowHeight: number, value: number | string): number => {\n if (typeof value === 'number') {\n return value;\n }\n\n const percentageRegex = new RegExp(/^[0-9]+%$/);\n if (percentageRegex.test(value)) {\n const percentage = parseFloat(value) / 100;\n return isNaN(percentage) ? 0 : Math.round(windowHeight * percentage);\n }\n\n return 0;\n};\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity,\n children,\n index,\n onChange,\n snapPoints,\n } = props;\n\n const styles = useStyles();\n\n const { height: windowHeight } = useWindowDimensions();\n\n const handleClose = () => {\n if (onChange) {\n onChange(-1);\n }\n };\n\n const height = convertHeightAsPixel(windowHeight, snapPoints[snapPoints.length - 1] ?? 0);\n const translateY = height - (convertHeightAsPixel(windowHeight, snapPoints[index] ?? 0));\n\n return (\n <Modal\n backdropOpacity={backdropOpacity}\n onClose={handleClose}\n visible={index >= 0}\n style={css([StyleSheet.absoluteFill, styles.root])}\n >\n <AnimatedY\n style={styles.animated}\n translateY={translateY}\n >\n <Paper\n elevation={12}\n style={[\n styles.paper,\n { height },\n ]}\n >\n {children}\n </Paper>\n </AnimatedY>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;AAKA,MAAMA,SAAuC,GAAG,YAA+B;EAC3E,MAAMC,KAAK,GAAG,IAAAC,cAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,cAAc,EAAE,UADd;MAEFC,MAAM,EAAEJ,KAAK,CAACI,MAAN,CAAaC;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J,MAAM,GAAInB,oBAAoB,CAACC,YAAD,EAAegB,UAAU,CAACF,KAAD,CAAV,IAAqB,CAApC,CAAjD;EAEA,oBACI,6BAAC,WAAD;IACI,eAAe,EAAEF,eADrB;IAEI,OAAO,EAAEQ,WAFb;IAGI,OAAO,EAAEN,KAAK,IAAI,CAHtB;IAII,KAAK,EAAE,IAAAS,SAAA,EAAI,CAACC,gBAAA,CAAWC,YAAZ,EAA0BR,MAAM,CAAC/B,IAAjC,CAAJ;EAJX,gBAMI,6BAAC,kBAAD;IACI,KAAK,EAAE+B,MAAM,CAAC3B,QADlB;IAEI,UAAU,EAAEgC;EAFhB,gBAII,6BAAC,WAAD;IACI,SAAS,EAAE,EADf;IAEI,KAAK,EAAE,CACHL,MAAM,CAACvB,KADJ,EAEH;MAAEwB;IAAF,CAFG;EAFX,GAOKL,QAPL,CAJJ,CANJ,CADJ;AAuBH;;AAAA"}
|
|
@@ -13,7 +13,7 @@ var _styles = require("@fountain-ui/styles");
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
function _extends() { _extends = Object.assign
|
|
16
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
17
|
|
|
18
18
|
function TransparentBackdrop(props) {
|
|
19
19
|
// The reason that it did not use the opacity prop is that the close event is ignored in Android. (opacity < 0.1)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["TransparentBackdrop","props","backdropStyle","css","backgroundColor","bottom","left","position","right","top"],"sources":["TransparentBackdrop.tsx"],"sourcesContent":["import React from 'react';\nimport { BottomSheetBackdrop, BottomSheetBackdropProps } from '@gorhom/bottom-sheet';\nimport { css } from '@fountain-ui/styles';\n\nexport default function TransparentBackdrop(props: BottomSheetBackdropProps) {\n // The reason that it did not use the opacity prop is that the close event is ignored in Android. (opacity < 0.1)\n const backdropStyle = css([\n {\n backgroundColor: '#ffffff00',\n bottom: 0,\n left: 0,\n position: 'absolute',\n right: 0,\n top: 0,\n },\n ]);\n\n return (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n style={backdropStyle}\n />\n );\n};"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAEe,SAASA,mBAAT,CAA6BC,KAA7B,EAA8D;EACzE;EACA,MAAMC,aAAa,GAAG,IAAAC,WAAA,EAAI,CACtB;IACIC,eAAe,EAAE,WADrB;IAEIC,MAAM,EAAE,CAFZ;IAGIC,IAAI,EAAE,CAHV;IAIIC,QAAQ,EAAE,UAJd;IAKIC,KAAK,EAAE,CALX;IAMIC,GAAG,EAAE;EANT,CADsB,CAAJ,CAAtB;EAWA,oBACI,6BAAC,gCAAD,eACQR,KADR;IAEI,cAAc,EAAE,CAFpB;IAGI,iBAAiB,EAAE,CAAC,CAHxB;IAII,KAAK,EAAEC;EAJX,GADJ;AAQH;;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './BottomSheetWeb';\nexport type { default as BottomSheetProps } from './BottomSheetProps';\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.native.ts"],"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.native.ts"],"sourcesContent":["export { default } from './BottomSheetNative';\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useDynamicSnapPoints;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
const convertHeightAsPixel = (windowHeight, value) => {
|
|
13
|
+
if (typeof value === 'number') {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const percentageRegex = new RegExp(/^[0-9]+%$/);
|
|
18
|
+
|
|
19
|
+
if (percentageRegex.test(value)) {
|
|
20
|
+
const percentage = parseFloat(value) / 100;
|
|
21
|
+
return isNaN(percentage) ? 0 : Math.round(windowHeight * percentage);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return 0;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function useDynamicSnapPoints(props) {
|
|
28
|
+
const {
|
|
29
|
+
index: currentIndex,
|
|
30
|
+
initialSnapPoints
|
|
31
|
+
} = props;
|
|
32
|
+
const {
|
|
33
|
+
height: WINDOW_HEIGHT
|
|
34
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
35
|
+
const [snapPoints, setSnapPoints] = (0, _react.useState)(initialSnapPoints.map(snapPoint => convertHeightAsPixel(WINDOW_HEIGHT, snapPoint)));
|
|
36
|
+
const handleContentLayout = (0, _react.useCallback)(event => {
|
|
37
|
+
if (initialSnapPoints[currentIndex] === 'CONTENT_HEIGHT') {
|
|
38
|
+
const contentHeight = Math.min(Math.round(WINDOW_HEIGHT * 0.9), event.nativeEvent.layout.height);
|
|
39
|
+
setSnapPoints(prevState => prevState.map((snapPoint, index) => {
|
|
40
|
+
return currentIndex === index ? contentHeight : snapPoint;
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
}, [currentIndex, initialSnapPoints]);
|
|
44
|
+
return {
|
|
45
|
+
handleContentLayout,
|
|
46
|
+
snapPoints
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=useDynamicSnapPoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["convertHeightAsPixel","windowHeight","value","percentageRegex","RegExp","test","percentage","parseFloat","isNaN","Math","round","useDynamicSnapPoints","props","index","currentIndex","initialSnapPoints","height","WINDOW_HEIGHT","useWindowDimensions","snapPoints","setSnapPoints","useState","map","snapPoint","handleContentLayout","useCallback","event","contentHeight","min","nativeEvent","layout","prevState"],"sources":["useDynamicSnapPoints.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport { LayoutChangeEvent, useWindowDimensions } from 'react-native';\n\ninterface UseDynamicSnapPointsParams {\n index: number;\n initialSnapPoints: (number | string)[];\n}\n\ninterface UseDynamicSnapPointsReturns {\n handleContentLayout: (e: LayoutChangeEvent) => void;\n snapPoints: number[];\n}\n\nconst convertHeightAsPixel = (windowHeight: number, value: number | string): number => {\n if (typeof value === 'number') {\n return value;\n }\n\n const percentageRegex = new RegExp(/^[0-9]+%$/);\n if (percentageRegex.test(value)) {\n const percentage = parseFloat(value) / 100;\n return isNaN(percentage) ? 0 : Math.round(windowHeight * percentage);\n }\n\n return 0;\n};\n\nexport default function useDynamicSnapPoints(props: UseDynamicSnapPointsParams): UseDynamicSnapPointsReturns {\n const {\n index: currentIndex,\n initialSnapPoints,\n } = props;\n\n const { height: WINDOW_HEIGHT } = useWindowDimensions();\n\n const [snapPoints, setSnapPoints] = useState(initialSnapPoints.map((snapPoint) => convertHeightAsPixel(WINDOW_HEIGHT, snapPoint)));\n\n const handleContentLayout = useCallback((event: LayoutChangeEvent) => {\n if (initialSnapPoints[currentIndex] === 'CONTENT_HEIGHT') {\n const contentHeight = Math.min(Math.round(WINDOW_HEIGHT * 0.9), event.nativeEvent.layout.height);\n \n setSnapPoints(prevState => prevState.map((snapPoint, index) => {\n return currentIndex === index ? contentHeight : snapPoint;\n }));\n }\n }, [currentIndex, initialSnapPoints]);\n\n return {\n handleContentLayout,\n snapPoints,\n };\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAYA,MAAMA,oBAAoB,GAAG,CAACC,YAAD,E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