@lodev09/react-native-true-sheet 4.0.0-beta.0 → 4.0.0-beta.10
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/LICENSE +1 -1
- package/README.md +62 -30
- package/RNTrueSheet.podspec +10 -2
- package/android/build.gradle +24 -2
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +189 -47
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerViewManager.kt +7 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt +401 -19
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentViewManager.kt +18 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterView.kt +145 -21
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterViewManager.kt +14 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetHeaderView.kt +38 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetHeaderViewManager.kt +28 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +84 -24
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetOverlayView.kt +106 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetOverlayViewManager.kt +45 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetPackage.kt +6 -4
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetPeekView.kt +72 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetPeekViewManager.kt +33 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetStateUpdater.kt +63 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +564 -226
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +1399 -598
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +161 -29
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensEventObserver.kt +63 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetBehavior.kt +36 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetView.kt +255 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetCoordinatorLayout.kt +375 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDetentCalculator.kt +299 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDimView.kt +162 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetGrabberView.kt +180 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetKeyboardObserver.kt +207 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetOverlayRootView.kt +137 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetStackManager.kt +220 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetDragEvents.kt +71 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetFocusEvents.kt +65 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetLifecycleEvents.kt +127 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetStateEvents.kt +56 -0
- package/android/src/main/java/com/lodev09/truesheet/utils/KeyboardUtils.kt +84 -0
- package/android/src/main/java/com/lodev09/truesheet/utils/ScreenUtils.kt +93 -67
- package/android/src/main/java/com/lodev09/truesheet/utils/TouchEventDeduper.kt +31 -0
- package/android/src/main/java/com/lodev09/truesheet/utils/ViewUtils.kt +42 -0
- package/android/src/main/jni/CMakeLists.txt +63 -0
- package/android/src/main/jni/TrueSheetSpec.h +20 -0
- package/android/src/main/jni/TrueSheetStateUpdater.cpp +96 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewComponentDescriptor.h +16 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.cpp +68 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.h +33 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.cpp +11 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.h +39 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewComponentDescriptor.h +24 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewShadowNode.cpp +63 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewShadowNode.h +28 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewState.cpp +11 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewState.h +41 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetInsets.cpp +18 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetInsets.h +16 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetLayoutUtils.h +46 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewComponentDescriptor.h +21 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewShadowNode.cpp +17 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewShadowNode.h +36 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewComponentDescriptor.h +28 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.cpp +30 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.h +45 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.cpp +23 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.h +52 -0
- package/ios/TrueSheetContainerView.h +88 -6
- package/ios/TrueSheetContainerView.mm +278 -21
- package/ios/TrueSheetContentView.h +54 -1
- package/ios/TrueSheetContentView.mm +371 -47
- package/ios/TrueSheetFooterView.h +33 -2
- package/ios/TrueSheetFooterView.mm +187 -35
- package/ios/{events/OnWillDismissEvent.h → TrueSheetHeaderView.h} +10 -7
- package/ios/TrueSheetHeaderView.mm +64 -0
- package/ios/TrueSheetModule.h +2 -7
- package/ios/TrueSheetModule.mm +98 -20
- package/ios/TrueSheetOverlayView.h +32 -0
- package/ios/TrueSheetOverlayView.mm +161 -0
- package/ios/TrueSheetPeekView.h +32 -0
- package/ios/TrueSheetPeekView.mm +99 -0
- package/ios/TrueSheetView.h +7 -15
- package/ios/TrueSheetView.mm +775 -215
- package/ios/TrueSheetViewController.h +94 -16
- package/ios/TrueSheetViewController.mm +1316 -331
- package/ios/core/RNScreensEventObserver.h +46 -0
- package/ios/core/RNScreensEventObserver.mm +280 -0
- package/ios/core/TrueSheetBlurView.h +27 -0
- package/ios/core/TrueSheetBlurView.mm +82 -0
- package/ios/core/TrueSheetDetentCalculator.h +107 -0
- package/ios/core/TrueSheetDetentCalculator.mm +197 -0
- package/ios/core/TrueSheetGrabberView.h +72 -0
- package/ios/core/TrueSheetGrabberView.mm +188 -0
- package/ios/core/TrueSheetKeyboardObserver.h +39 -0
- package/ios/core/TrueSheetKeyboardObserver.mm +112 -0
- package/ios/core/TrueSheetOverlayContainerView.h +31 -0
- package/ios/core/TrueSheetOverlayContainerView.mm +35 -0
- package/ios/events/TrueSheetDragEvents.h +39 -0
- package/ios/events/TrueSheetDragEvents.mm +62 -0
- package/ios/events/{OnPositionChangeEvent.h → TrueSheetFocusEvents.h} +8 -5
- package/ios/events/TrueSheetFocusEvents.mm +49 -0
- package/ios/events/TrueSheetLifecycleEvents.h +42 -0
- package/ios/events/TrueSheetLifecycleEvents.mm +79 -0
- package/ios/events/TrueSheetStateEvents.h +35 -0
- package/ios/events/TrueSheetStateEvents.mm +49 -0
- package/ios/tvos/TrueSheetStubs.mm +166 -0
- package/ios/{events/OnMountEvent.h → utils/BlurUtil.h} +5 -7
- package/ios/utils/BlurUtil.mm +69 -0
- package/ios/utils/GestureUtil.h +7 -0
- package/ios/utils/GestureUtil.mm +12 -0
- package/ios/utils/PlatformUtil.h +15 -0
- package/ios/utils/UIView+FirstResponder.h +15 -0
- package/ios/utils/UIView+FirstResponder.mm +26 -0
- package/ios/utils/UIView+ScrollEdgeInteraction.h +26 -0
- package/ios/utils/UIView+ScrollEdgeInteraction.mm +84 -0
- package/ios/utils/WindowUtil.mm +17 -1
- package/lib/module/TrueSheet.js +349 -74
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheet.web.js +1270 -0
- package/lib/module/TrueSheet.web.js.map +1 -0
- package/lib/module/TrueSheetOverlay.js +30 -0
- package/lib/module/TrueSheetOverlay.js.map +1 -0
- package/lib/module/TrueSheetOverlay.web.js +35 -0
- package/lib/module/TrueSheetOverlay.web.js.map +1 -0
- package/lib/module/TrueSheetPeek.js +15 -0
- package/lib/module/TrueSheetPeek.js.map +1 -0
- package/lib/module/TrueSheetPeek.web.js +55 -0
- package/lib/module/TrueSheetPeek.web.js.map +1 -0
- package/lib/module/TrueSheetProvider.js +28 -0
- package/lib/module/TrueSheetProvider.js.map +1 -0
- package/lib/module/TrueSheetProvider.web.js +157 -0
- package/lib/module/TrueSheetProvider.web.js.map +1 -0
- package/lib/module/fabric/TrueSheetContainerViewNativeComponent.ts +1 -1
- package/lib/module/fabric/TrueSheetContentViewNativeComponent.ts +5 -1
- package/lib/module/fabric/TrueSheetFooterViewNativeComponent.ts +10 -2
- package/lib/module/fabric/TrueSheetHeaderViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetOverlayViewNativeComponent.ts +12 -0
- package/lib/module/fabric/TrueSheetPeekViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +110 -18
- package/lib/module/index.js +4 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/mocks/index.js +103 -0
- package/lib/module/mocks/index.js.map +1 -0
- package/lib/module/mocks/navigation.js +95 -0
- package/lib/module/mocks/navigation.js.map +1 -0
- package/lib/module/mocks/navigationExpoRouter.js +21 -0
- package/lib/module/mocks/navigationExpoRouter.js.map +1 -0
- package/lib/module/mocks/reanimated.js +91 -0
- package/lib/module/mocks/reanimated.js.map +1 -0
- package/lib/module/navigation/TrueSheetNavigatorContent.js +73 -0
- package/lib/module/navigation/TrueSheetNavigatorContent.js.map +1 -0
- package/lib/module/navigation/actions.js +50 -0
- package/lib/module/navigation/actions.js.map +1 -0
- package/lib/module/navigation/base-types.js +2 -0
- package/lib/module/navigation/base-types.js.map +1 -0
- package/lib/module/navigation/createTrueSheetRouter.js +157 -0
- package/lib/module/navigation/createTrueSheetRouter.js.map +1 -0
- package/lib/module/navigation/expo-router/base-types.js +2 -0
- package/lib/module/navigation/expo-router/base-types.js.map +1 -0
- package/lib/module/navigation/expo-router/index.js +50 -0
- package/lib/module/navigation/expo-router/index.js.map +1 -0
- package/lib/module/navigation/expo-router/types.js +4 -0
- package/lib/module/navigation/expo-router/types.js.map +1 -0
- package/lib/module/navigation/index.js +47 -0
- package/lib/module/navigation/index.js.map +1 -0
- package/lib/module/navigation/navigator.js +10 -0
- package/lib/module/navigation/navigator.js.map +1 -0
- package/lib/module/navigation/screen/ReanimatedTrueSheetScreen.js +56 -0
- package/lib/module/navigation/screen/ReanimatedTrueSheetScreen.js.map +1 -0
- package/lib/module/navigation/screen/TrueSheetScreen.js +49 -0
- package/lib/module/navigation/screen/TrueSheetScreen.js.map +1 -0
- package/lib/module/navigation/screen/index.js +5 -0
- package/lib/module/navigation/screen/index.js.map +1 -0
- package/lib/module/navigation/screen/types.js +4 -0
- package/lib/module/navigation/screen/types.js.map +1 -0
- package/lib/module/navigation/screen/useSheetScreenState.js +69 -0
- package/lib/module/navigation/screen/useSheetScreenState.js.map +1 -0
- package/lib/module/navigation/types.js +4 -0
- package/lib/module/navigation/types.js.map +1 -0
- package/lib/module/navigation/useTrueSheetNavigation.js +24 -0
- package/lib/module/navigation/useTrueSheetNavigation.js.map +1 -0
- package/lib/module/reanimated/ReanimatedTrueSheet.js +15 -9
- package/lib/module/reanimated/ReanimatedTrueSheet.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTrueSheet.web.js +81 -0
- package/lib/module/reanimated/ReanimatedTrueSheet.web.js.map +1 -0
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js +4 -2
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js.map +1 -1
- package/lib/module/reanimated/index.js +2 -2
- package/lib/module/reanimated/index.js.map +1 -1
- package/lib/module/reanimated/useReanimatedPositionChangeHandler.web.js +20 -0
- package/lib/module/reanimated/useReanimatedPositionChangeHandler.web.js.map +1 -0
- package/lib/module/specs/NativeTrueSheetModule.js.map +1 -1
- package/lib/module/web/constants.js +16 -0
- package/lib/module/web/constants.js.map +1 -0
- package/lib/module/web/dom.js +10 -0
- package/lib/module/web/dom.js.map +1 -0
- package/lib/module/web/vaul/README.md +9 -0
- package/lib/module/web/vaul/browser.js +30 -0
- package/lib/module/web/vaul/browser.js.map +1 -0
- package/lib/module/web/vaul/constants.js +19 -0
- package/lib/module/web/vaul/constants.js.map +1 -0
- package/lib/module/web/vaul/context.js +59 -0
- package/lib/module/web/vaul/context.js.map +1 -0
- package/lib/module/web/vaul/helpers.js +99 -0
- package/lib/module/web/vaul/helpers.js.map +1 -0
- package/lib/module/web/vaul/index.js +1342 -0
- package/lib/module/web/vaul/index.js.map +1 -0
- package/lib/module/web/vaul/style.css +287 -0
- package/lib/module/web/vaul/style.css.d.js +2 -0
- package/lib/module/web/vaul/style.css.d.js.map +1 -0
- package/lib/module/web/vaul/types.js +2 -0
- package/lib/module/web/vaul/types.js.map +1 -0
- package/lib/module/web/vaul/use-composed-refs.js +34 -0
- package/lib/module/web/vaul/use-composed-refs.js.map +1 -0
- package/lib/module/web/vaul/use-controllable-state.js +54 -0
- package/lib/module/web/vaul/use-controllable-state.js.map +1 -0
- package/lib/module/web/vaul/use-position-fixed.js +123 -0
- package/lib/module/web/vaul/use-position-fixed.js.map +1 -0
- package/lib/module/web/vaul/use-prevent-scroll.js +258 -0
- package/lib/module/web/vaul/use-prevent-scroll.js.map +1 -0
- package/lib/module/web/vaul/use-scale-background.js +57 -0
- package/lib/module/web/vaul/use-scale-background.js.map +1 -0
- package/lib/module/web/vaul/use-snap-points.js +305 -0
- package/lib/module/web/vaul/use-snap-points.js.map +1 -0
- package/lib/typescript/src/TrueSheet.d.ts +57 -14
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +535 -55
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.web.d.ts +5 -0
- package/lib/typescript/src/TrueSheet.web.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetOverlay.d.ts +8 -0
- package/lib/typescript/src/TrueSheetOverlay.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetOverlay.web.d.ts +8 -0
- package/lib/typescript/src/TrueSheetOverlay.web.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetPeek.d.ts +9 -0
- package/lib/typescript/src/TrueSheetPeek.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetPeek.web.d.ts +28 -0
- package/lib/typescript/src/TrueSheetPeek.web.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetProvider.d.ts +18 -0
- package/lib/typescript/src/TrueSheetProvider.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetProvider.web.d.ts +27 -0
- package/lib/typescript/src/TrueSheetProvider.web.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetContentViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts +2 -0
- package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetHeaderViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetHeaderViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetOverlayViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetOverlayViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetPeekViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetPeekViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +71 -16
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mocks/index.d.ts +47 -0
- package/lib/typescript/src/mocks/index.d.ts.map +1 -0
- package/lib/typescript/src/mocks/navigation.d.ts +70 -0
- package/lib/typescript/src/mocks/navigation.d.ts.map +1 -0
- package/lib/typescript/src/mocks/navigationExpoRouter.d.ts +22 -0
- package/lib/typescript/src/mocks/navigationExpoRouter.d.ts.map +1 -0
- package/lib/typescript/src/mocks/reanimated.d.ts +48 -0
- package/lib/typescript/src/mocks/reanimated.d.ts.map +1 -0
- package/lib/typescript/src/navigation/TrueSheetNavigatorContent.d.ts +5 -0
- package/lib/typescript/src/navigation/TrueSheetNavigatorContent.d.ts.map +1 -0
- package/lib/typescript/src/navigation/actions.d.ts +71 -0
- package/lib/typescript/src/navigation/actions.d.ts.map +1 -0
- package/lib/typescript/src/navigation/base-types.d.ts +9 -0
- package/lib/typescript/src/navigation/base-types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts +3 -0
- package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts.map +1 -0
- package/lib/typescript/src/navigation/expo-router/base-types.d.ts +8 -0
- package/lib/typescript/src/navigation/expo-router/base-types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/expo-router/index.d.ts +37 -0
- package/lib/typescript/src/navigation/expo-router/index.d.ts.map +1 -0
- package/lib/typescript/src/navigation/expo-router/types.d.ts +44 -0
- package/lib/typescript/src/navigation/expo-router/types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/index.d.ts +45 -0
- package/lib/typescript/src/navigation/index.d.ts.map +1 -0
- package/lib/typescript/src/navigation/navigator.d.ts +7 -0
- package/lib/typescript/src/navigation/navigator.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen/ReanimatedTrueSheetScreen.d.ts +3 -0
- package/lib/typescript/src/navigation/screen/ReanimatedTrueSheetScreen.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen/TrueSheetScreen.d.ts +3 -0
- package/lib/typescript/src/navigation/screen/TrueSheetScreen.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen/index.d.ts +4 -0
- package/lib/typescript/src/navigation/screen/index.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen/types.d.ts +14 -0
- package/lib/typescript/src/navigation/screen/types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen/useSheetScreenState.d.ts +34 -0
- package/lib/typescript/src/navigation/screen/useSheetScreenState.d.ts.map +1 -0
- package/lib/typescript/src/navigation/types.d.ts +213 -0
- package/lib/typescript/src/navigation/types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts +23 -0
- package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.web.d.ts +41 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.web.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts +8 -2
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.web.d.ts +15 -0
- package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.web.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts +25 -3
- package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts.map +1 -1
- package/lib/typescript/src/web/constants.d.ts +14 -0
- package/lib/typescript/src/web/constants.d.ts.map +1 -0
- package/lib/typescript/src/web/dom.d.ts +7 -0
- package/lib/typescript/src/web/dom.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/browser.d.ts +8 -0
- package/lib/typescript/src/web/vaul/browser.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/constants.d.ts +14 -0
- package/lib/typescript/src/web/vaul/constants.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/context.d.ts +54 -0
- package/lib/typescript/src/web/vaul/context.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/helpers.d.ts +17 -0
- package/lib/typescript/src/web/vaul/helpers.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/index.d.ts +234 -0
- package/lib/typescript/src/web/vaul/index.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/types.d.ts +7 -0
- package/lib/typescript/src/web/vaul/types.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-composed-refs.d.ts +14 -0
- package/lib/typescript/src/web/vaul/use-composed-refs.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-controllable-state.d.ts +9 -0
- package/lib/typescript/src/web/vaul/use-controllable-state.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-position-fixed.d.ts +19 -0
- package/lib/typescript/src/web/vaul/use-position-fixed.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-prevent-scroll.d.ts +18 -0
- package/lib/typescript/src/web/vaul/use-prevent-scroll.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-scale-background.d.ts +2 -0
- package/lib/typescript/src/web/vaul/use-scale-background.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-snap-points.d.ts +38 -0
- package/lib/typescript/src/web/vaul/use-snap-points.d.ts.map +1 -0
- package/package.json +104 -37
- package/react-native.config.js +10 -2
- package/src/TrueSheet.tsx +424 -70
- package/src/TrueSheet.types.ts +602 -72
- package/src/TrueSheet.web.tsx +1437 -0
- package/src/TrueSheetOverlay.tsx +24 -0
- package/src/TrueSheetOverlay.web.tsx +33 -0
- package/src/TrueSheetPeek.tsx +11 -0
- package/src/TrueSheetPeek.web.tsx +64 -0
- package/src/TrueSheetProvider.tsx +33 -0
- package/src/TrueSheetProvider.web.tsx +220 -0
- package/src/fabric/TrueSheetContainerViewNativeComponent.ts +1 -1
- package/src/fabric/TrueSheetContentViewNativeComponent.ts +5 -1
- package/src/fabric/TrueSheetFooterViewNativeComponent.ts +10 -2
- package/src/fabric/TrueSheetHeaderViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetOverlayViewNativeComponent.ts +12 -0
- package/src/fabric/TrueSheetPeekViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetViewNativeComponent.ts +110 -18
- package/src/index.ts +3 -2
- package/src/mocks/index.ts +96 -0
- package/src/mocks/navigation.ts +79 -0
- package/src/mocks/navigationExpoRouter.ts +41 -0
- package/src/mocks/reanimated.ts +100 -0
- package/src/navigation/TrueSheetNavigatorContent.tsx +106 -0
- package/src/navigation/actions.ts +78 -0
- package/src/navigation/base-types.ts +20 -0
- package/src/navigation/createTrueSheetRouter.ts +194 -0
- package/src/navigation/expo-router/base-types.ts +18 -0
- package/src/navigation/expo-router/index.ts +90 -0
- package/src/navigation/expo-router/types.ts +116 -0
- package/src/navigation/index.ts +80 -0
- package/src/navigation/navigator.ts +18 -0
- package/src/navigation/screen/ReanimatedTrueSheetScreen.tsx +61 -0
- package/src/navigation/screen/TrueSheetScreen.tsx +54 -0
- package/src/navigation/screen/index.ts +3 -0
- package/src/navigation/screen/types.ts +19 -0
- package/src/navigation/screen/useSheetScreenState.ts +102 -0
- package/src/navigation/types.ts +302 -0
- package/src/navigation/useTrueSheetNavigation.ts +26 -0
- package/src/reanimated/ReanimatedTrueSheet.tsx +12 -7
- package/src/reanimated/ReanimatedTrueSheet.web.tsx +75 -0
- package/src/reanimated/ReanimatedTrueSheetProvider.tsx +12 -8
- package/src/reanimated/useReanimatedPositionChangeHandler.web.ts +31 -0
- package/src/specs/NativeTrueSheetModule.ts +28 -3
- package/src/web/constants.ts +13 -0
- package/src/web/dom.ts +9 -0
- package/src/web/vaul/README.md +9 -0
- package/src/web/vaul/browser.ts +38 -0
- package/src/web/vaul/constants.ts +24 -0
- package/src/web/vaul/context.ts +102 -0
- package/src/web/vaul/helpers.ts +131 -0
- package/src/web/vaul/index.tsx +1785 -0
- package/src/web/vaul/style.css +287 -0
- package/src/web/vaul/style.css.d.ts +1 -0
- package/src/web/vaul/types.ts +7 -0
- package/src/web/vaul/use-composed-refs.ts +35 -0
- package/src/web/vaul/use-controllable-state.ts +66 -0
- package/src/web/vaul/use-position-fixed.ts +147 -0
- package/src/web/vaul/use-prevent-scroll.ts +309 -0
- package/src/web/vaul/use-scale-background.ts +64 -0
- package/src/web/vaul/use-snap-points.ts +455 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DetentChangeEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DidDismissEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/DidPresentEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragBeginEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragChangeEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragEndEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/PositionChangeEvent.kt +0 -32
- package/android/src/main/java/com/lodev09/truesheet/events/SizeChangeEvent.kt +0 -27
- package/android/src/main/java/com/lodev09/truesheet/events/WillDismissEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/WillPresentEvent.kt +0 -26
- package/android/src/main/res/values/styles.xml +0 -8
- package/ios/events/OnDetentChangeEvent.h +0 -28
- package/ios/events/OnDetentChangeEvent.mm +0 -30
- package/ios/events/OnDidDismissEvent.h +0 -26
- package/ios/events/OnDidDismissEvent.mm +0 -25
- package/ios/events/OnDidPresentEvent.h +0 -28
- package/ios/events/OnDidPresentEvent.mm +0 -30
- package/ios/events/OnDragBeginEvent.h +0 -28
- package/ios/events/OnDragBeginEvent.mm +0 -30
- package/ios/events/OnDragChangeEvent.h +0 -28
- package/ios/events/OnDragChangeEvent.mm +0 -30
- package/ios/events/OnDragEndEvent.h +0 -28
- package/ios/events/OnDragEndEvent.mm +0 -30
- package/ios/events/OnMountEvent.mm +0 -25
- package/ios/events/OnPositionChangeEvent.mm +0 -32
- package/ios/events/OnSizeChangeEvent.h +0 -28
- package/ios/events/OnSizeChangeEvent.mm +0 -30
- package/ios/events/OnWillDismissEvent.mm +0 -25
- package/ios/events/OnWillPresentEvent.h +0 -28
- package/ios/events/OnWillPresentEvent.mm +0 -30
- package/ios/utils/LayoutUtil.h +0 -44
- package/ios/utils/LayoutUtil.mm +0 -50
- package/lib/module/TrueSheetGrabber.js +0 -51
- package/lib/module/TrueSheetGrabber.js.map +0 -1
- package/lib/typescript/src/TrueSheetGrabber.d.ts +0 -39
- package/lib/typescript/src/TrueSheetGrabber.d.ts.map +0 -1
- package/src/TrueSheetGrabber.tsx +0 -82
- package/src/__mocks__/index.js +0 -67
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { TrueSheetActions } from './actions';
|
|
2
|
+
import type { TrueSheetRouter, TrueSheetRouterFactory, TrueSheetRouterOptions } from './types';
|
|
3
|
+
|
|
4
|
+
const uid = () => Math.random().toString(36).slice(2, 10);
|
|
5
|
+
|
|
6
|
+
const ensureBaseRoute = <T extends { routes: { name: string }[] }>(
|
|
7
|
+
state: T,
|
|
8
|
+
baseRouteName: string | undefined,
|
|
9
|
+
routeParamList: Record<string, object | undefined> | undefined
|
|
10
|
+
): T & { index: number; routes: T['routes'] } => {
|
|
11
|
+
if (!baseRouteName) {
|
|
12
|
+
return state as T & { index: number; routes: T['routes'] };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const hasBaseRoute = state.routes.some((r) => r.name === baseRouteName);
|
|
16
|
+
|
|
17
|
+
if (!hasBaseRoute) {
|
|
18
|
+
const baseRoute = {
|
|
19
|
+
key: `${baseRouteName}-${uid()}`,
|
|
20
|
+
name: baseRouteName,
|
|
21
|
+
params: routeParamList?.[baseRouteName],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
...state,
|
|
26
|
+
index: state.routes.length,
|
|
27
|
+
routes: [baseRoute, ...state.routes],
|
|
28
|
+
} as T & { index: number; routes: T['routes'] };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return state as T & { index: number; routes: T['routes'] };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const createTrueSheetRouter =
|
|
35
|
+
(stackRouter: TrueSheetRouterFactory) =>
|
|
36
|
+
(routerOptions: TrueSheetRouterOptions): TrueSheetRouter => {
|
|
37
|
+
const baseRouter = stackRouter(routerOptions);
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
...baseRouter,
|
|
41
|
+
type: 'true-sheet',
|
|
42
|
+
|
|
43
|
+
getInitialState(options) {
|
|
44
|
+
const state = baseRouter.getInitialState(options);
|
|
45
|
+
const baseRouteName = routerOptions.initialRouteName ?? options.routeNames[0];
|
|
46
|
+
const stateWithBaseRoute = ensureBaseRoute(state, baseRouteName, options.routeParamList);
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
...stateWithBaseRoute,
|
|
50
|
+
stale: false,
|
|
51
|
+
type: 'true-sheet',
|
|
52
|
+
key: `true-sheet-${uid()}`,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
getStateForAction(state, action, options) {
|
|
57
|
+
switch (action.type) {
|
|
58
|
+
case 'RESIZE': {
|
|
59
|
+
const routeIndex =
|
|
60
|
+
action.target === state.key && action.source
|
|
61
|
+
? state.routes.findIndex((r) => r.key === action.source)
|
|
62
|
+
: state.index;
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
...state,
|
|
66
|
+
routes: state.routes.map((route, i) =>
|
|
67
|
+
i === routeIndex
|
|
68
|
+
? {
|
|
69
|
+
...route,
|
|
70
|
+
resizeIndex: action.index,
|
|
71
|
+
resizeKey: (route.resizeKey ?? 0) + 1,
|
|
72
|
+
}
|
|
73
|
+
: route
|
|
74
|
+
),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
case 'GO_BACK':
|
|
79
|
+
case 'DISMISS': {
|
|
80
|
+
return this.getStateForAction(state, TrueSheetActions.pop(1), options);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
case 'POP': {
|
|
84
|
+
// Only base screen remains - let parent navigator handle it
|
|
85
|
+
if (state.routes.length <= 1) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const count =
|
|
90
|
+
'payload' in action && typeof action.payload?.count === 'number'
|
|
91
|
+
? action.payload.count
|
|
92
|
+
: 1;
|
|
93
|
+
|
|
94
|
+
// Calculate how many routes we can actually pop (don't pop base screen)
|
|
95
|
+
const maxPopCount = state.routes.length - 1;
|
|
96
|
+
const actualCount = Math.min(count, maxPopCount);
|
|
97
|
+
|
|
98
|
+
// Base screen - let parent navigator handle it
|
|
99
|
+
if (actualCount <= 0) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Target index is the route we want to stay on (land on after pop)
|
|
104
|
+
// closingIndex is the first route to be dismissed (the one after target)
|
|
105
|
+
const targetIndex = state.routes.length - 1 - actualCount;
|
|
106
|
+
const closingIndex = targetIndex + 1;
|
|
107
|
+
|
|
108
|
+
// Mark only the bottom-most route to pop as closing
|
|
109
|
+
// The sheet's dismiss() will handle dismissing sheets above it first
|
|
110
|
+
return {
|
|
111
|
+
...state,
|
|
112
|
+
index: closingIndex,
|
|
113
|
+
routes: state.routes.map((route, i) =>
|
|
114
|
+
i === closingIndex ? { ...route, closing: true } : route
|
|
115
|
+
),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
case 'POP_TO_TOP': {
|
|
120
|
+
const popCount = state.routes.length - 1;
|
|
121
|
+
return this.getStateForAction(state, TrueSheetActions.pop(popCount), options);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
case 'POP_TO': {
|
|
125
|
+
const targetName =
|
|
126
|
+
'payload' in action && typeof action.payload?.name === 'string'
|
|
127
|
+
? action.payload.name
|
|
128
|
+
: null;
|
|
129
|
+
|
|
130
|
+
if (!targetName) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const targetIndex = state.routes.findIndex((r) => r.name === targetName);
|
|
135
|
+
|
|
136
|
+
// Target not found or is the current route
|
|
137
|
+
if (targetIndex === -1 || targetIndex >= state.index) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const popCount = state.routes.length - 1 - targetIndex;
|
|
142
|
+
return this.getStateForAction(state, TrueSheetActions.pop(popCount), options);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
case 'REMOVE': {
|
|
146
|
+
// Actually remove the closing route and all routes above it
|
|
147
|
+
const routeKey = action.source;
|
|
148
|
+
const routeIndex = routeKey
|
|
149
|
+
? state.routes.findIndex((r) => r.key === routeKey)
|
|
150
|
+
: state.routes.findIndex((r) => r.closing);
|
|
151
|
+
|
|
152
|
+
if (routeIndex === -1) {
|
|
153
|
+
return state;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Remove the route and all routes above it (they were dismissed together)
|
|
157
|
+
const routes = state.routes.filter((_, i) => i < routeIndex);
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
...state,
|
|
161
|
+
index: Math.min(state.index, routes.length - 1),
|
|
162
|
+
routes,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
default:
|
|
167
|
+
return baseRouter.getStateForAction(state, action, options);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
getRehydratedState(partialState, { routeNames, routeParamList, routeGetIdList }) {
|
|
172
|
+
if (partialState.stale === false) {
|
|
173
|
+
return partialState;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const state = baseRouter.getRehydratedState(partialState, {
|
|
177
|
+
routeNames,
|
|
178
|
+
routeParamList,
|
|
179
|
+
routeGetIdList,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const baseRouteName = routerOptions.initialRouteName ?? routeNames[0];
|
|
183
|
+
const stateWithBaseRoute = ensureBaseRoute(state, baseRouteName, routeParamList);
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
...stateWithBaseRoute,
|
|
187
|
+
type: 'true-sheet',
|
|
188
|
+
key: `true-sheet-${uid()}`,
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
actionCreators: TrueSheetActions,
|
|
193
|
+
};
|
|
194
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base navigation types for the Expo Router entry point.
|
|
3
|
+
*
|
|
4
|
+
* Sourced from Expo Router's vendored React Navigation so apps that only install
|
|
5
|
+
* `expo-router` still get real types — see `../base-types` for the React Navigation copy.
|
|
6
|
+
*/
|
|
7
|
+
export type {
|
|
8
|
+
DefaultNavigatorOptions,
|
|
9
|
+
NavigationAction,
|
|
10
|
+
NavigationHelpers,
|
|
11
|
+
NavigationProp,
|
|
12
|
+
NavigationState,
|
|
13
|
+
ParamListBase,
|
|
14
|
+
RouteProp,
|
|
15
|
+
Router,
|
|
16
|
+
StackActionHelpers,
|
|
17
|
+
StackRouterOptions,
|
|
18
|
+
} from 'expo-router/react-navigation';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { StackRouter, unstable_integrateWithRouter, useNavigation } from 'expo-router';
|
|
2
|
+
|
|
3
|
+
import { createTrueSheetRouter } from '../createTrueSheetRouter';
|
|
4
|
+
import { trueSheetNavigator } from '../navigator';
|
|
5
|
+
import type { ParamListBase } from './base-types';
|
|
6
|
+
import type {
|
|
7
|
+
StackRouterFactory,
|
|
8
|
+
TrueSheetNavigationOptions,
|
|
9
|
+
TrueSheetNavigationProp,
|
|
10
|
+
TrueSheetNavigationState,
|
|
11
|
+
TrueSheetNavigatorContentExtraProps,
|
|
12
|
+
TrueSheetNavigatorProps,
|
|
13
|
+
TrueSheetRouterFactory,
|
|
14
|
+
TrueSheetRouterOptions,
|
|
15
|
+
TrueSheetStandardEventMap,
|
|
16
|
+
} from './types';
|
|
17
|
+
|
|
18
|
+
// expo-router's vendored StackRouter is structurally identical to @react-navigation's.
|
|
19
|
+
// Pinned to this entry's own router types: `createTrueSheetRouter` is shared and typed
|
|
20
|
+
// against React Navigation, which resolves to `any` in apps that only install expo-router.
|
|
21
|
+
const sheetRouter: TrueSheetRouterFactory = createTrueSheetRouter(
|
|
22
|
+
StackRouter as StackRouterFactory
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const SheetNavigator = unstable_integrateWithRouter<
|
|
26
|
+
TrueSheetNavigationOptions,
|
|
27
|
+
TrueSheetNavigationState<ParamListBase>,
|
|
28
|
+
TrueSheetStandardEventMap,
|
|
29
|
+
TrueSheetNavigatorContentExtraProps,
|
|
30
|
+
TrueSheetRouterOptions
|
|
31
|
+
>(trueSheetNavigator, sheetRouter, {
|
|
32
|
+
createProps: ({ state, dispatch }) => ({
|
|
33
|
+
routes: state.routes,
|
|
34
|
+
dispatch,
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Public props: `routes`/`dispatch` are injected by `createProps` (optional here
|
|
39
|
+
// so the navigator type stays comparable), and expo-router intersects the event
|
|
40
|
+
// map with an index signature which breaks precisely typed `screenListeners`
|
|
41
|
+
// callbacks - replace it with the exact map
|
|
42
|
+
type SheetProps = Omit<
|
|
43
|
+
React.ComponentProps<typeof SheetNavigator>,
|
|
44
|
+
'screenListeners' | 'routes' | 'dispatch'
|
|
45
|
+
> &
|
|
46
|
+
Partial<Pick<React.ComponentProps<typeof SheetNavigator>, 'routes' | 'dispatch'>> &
|
|
47
|
+
Pick<TrueSheetNavigatorProps, 'screenListeners'>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* TrueSheet navigator layout for Expo Router.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* // app/sheet/_layout.tsx
|
|
55
|
+
* import { Sheet } from '@lodev09/react-native-true-sheet/navigation/expo-router';
|
|
56
|
+
*
|
|
57
|
+
* export default function SheetLayout() {
|
|
58
|
+
* return (
|
|
59
|
+
* <Sheet initialRouteName="(home)">
|
|
60
|
+
* <Sheet.Screen name="details" options={{ detents: [0.5, 1] }} />
|
|
61
|
+
* </Sheet>
|
|
62
|
+
* );
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export const Sheet = SheetNavigator as React.ComponentType<SheetProps> & {
|
|
67
|
+
Screen: typeof SheetNavigator.Screen;
|
|
68
|
+
Protected: typeof SheetNavigator.Protected;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Hook to access TrueSheet navigation with the resize helper.
|
|
73
|
+
* Built on expo-router's `useNavigation`.
|
|
74
|
+
*/
|
|
75
|
+
export const useTrueSheetNavigation = <
|
|
76
|
+
T extends ParamListBase = ParamListBase,
|
|
77
|
+
>(): TrueSheetNavigationProp<T> => useNavigation<TrueSheetNavigationProp<T>>();
|
|
78
|
+
|
|
79
|
+
export { TrueSheetActions, type TrueSheetActionType } from '../actions';
|
|
80
|
+
|
|
81
|
+
export type { DetentInfoEventPayload, PositionChangeEventPayload } from '../../TrueSheet.types';
|
|
82
|
+
|
|
83
|
+
export type {
|
|
84
|
+
TrueSheetNavigationEventMap,
|
|
85
|
+
TrueSheetNavigationHelpers,
|
|
86
|
+
TrueSheetNavigationOptions,
|
|
87
|
+
TrueSheetNavigationProp,
|
|
88
|
+
TrueSheetNavigationState,
|
|
89
|
+
TrueSheetScreenProps,
|
|
90
|
+
} from './types';
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expo Router flavour of `../types`: same shapes, but bound to Expo Router's
|
|
3
|
+
* vendored React Navigation types so apps that only install `expo-router` still
|
|
4
|
+
* get real types instead of `any` — see `./base-types`.
|
|
5
|
+
*/
|
|
6
|
+
import type { TrueSheetActionType } from '../actions';
|
|
7
|
+
import type {
|
|
8
|
+
TrueSheetActionHelpersOf,
|
|
9
|
+
TrueSheetDispatch,
|
|
10
|
+
TrueSheetNavigationEventMap,
|
|
11
|
+
TrueSheetNavigationOptions,
|
|
12
|
+
TrueSheetStateOf,
|
|
13
|
+
} from '../types';
|
|
14
|
+
import type {
|
|
15
|
+
DefaultNavigatorOptions,
|
|
16
|
+
NavigationAction,
|
|
17
|
+
NavigationHelpers,
|
|
18
|
+
NavigationProp,
|
|
19
|
+
NavigationState,
|
|
20
|
+
ParamListBase,
|
|
21
|
+
RouteProp,
|
|
22
|
+
Router,
|
|
23
|
+
StackActionHelpers,
|
|
24
|
+
StackRouterOptions,
|
|
25
|
+
} from './base-types';
|
|
26
|
+
|
|
27
|
+
export type TrueSheetRouterOptions = StackRouterOptions;
|
|
28
|
+
|
|
29
|
+
export type TrueSheetNavigationState<ParamList extends ParamListBase> = TrueSheetStateOf<
|
|
30
|
+
NavigationState<ParamList>
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
export type TrueSheetRouterState = TrueSheetNavigationState<ParamListBase>;
|
|
34
|
+
|
|
35
|
+
export type TrueSheetRouter = Router<TrueSheetRouterState, TrueSheetActionType>;
|
|
36
|
+
|
|
37
|
+
export type TrueSheetRouterFactory = (options: TrueSheetRouterOptions) => TrueSheetRouter;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The base `StackRouter` factory to wrap — see `../types` for the shared contract.
|
|
41
|
+
*/
|
|
42
|
+
export type StackRouterFactory = <
|
|
43
|
+
State extends NavigationState<ParamListBase>,
|
|
44
|
+
Action extends NavigationAction,
|
|
45
|
+
>(
|
|
46
|
+
options: TrueSheetRouterOptions
|
|
47
|
+
) => Router<State, Action>;
|
|
48
|
+
|
|
49
|
+
export type TrueSheetRoute = TrueSheetNavigationState<ParamListBase>['routes'][number];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Props injected into the navigator content by Expo Router's `createProps`.
|
|
53
|
+
* Raw routes carry the custom fields (`closing`, `resizeIndex`, `resizeKey`)
|
|
54
|
+
* that the standard state strips out.
|
|
55
|
+
*/
|
|
56
|
+
export interface TrueSheetNavigatorContentExtraProps {
|
|
57
|
+
routes: TrueSheetRoute[];
|
|
58
|
+
dispatch: TrueSheetDispatch;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type TrueSheetActionHelpers<ParamList extends ParamListBase> = TrueSheetActionHelpersOf<
|
|
62
|
+
StackActionHelpers<ParamList>
|
|
63
|
+
>;
|
|
64
|
+
|
|
65
|
+
export type TrueSheetNavigationProp<
|
|
66
|
+
ParamList extends ParamListBase,
|
|
67
|
+
RouteName extends keyof ParamList = string,
|
|
68
|
+
NavigatorID extends string | undefined = undefined,
|
|
69
|
+
> = NavigationProp<
|
|
70
|
+
ParamList,
|
|
71
|
+
RouteName,
|
|
72
|
+
NavigatorID,
|
|
73
|
+
TrueSheetNavigationState<ParamList>,
|
|
74
|
+
TrueSheetNavigationOptions,
|
|
75
|
+
TrueSheetNavigationEventMap
|
|
76
|
+
> &
|
|
77
|
+
TrueSheetActionHelpers<ParamList>;
|
|
78
|
+
|
|
79
|
+
export type TrueSheetScreenProps<
|
|
80
|
+
ParamList extends ParamListBase,
|
|
81
|
+
RouteName extends keyof ParamList = string,
|
|
82
|
+
NavigatorID extends string | undefined = undefined,
|
|
83
|
+
> = {
|
|
84
|
+
navigation: TrueSheetNavigationProp<ParamList, RouteName, NavigatorID>;
|
|
85
|
+
route: RouteProp<ParamList, RouteName>;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type TrueSheetNavigationHelpers = NavigationHelpers<
|
|
89
|
+
ParamListBase,
|
|
90
|
+
TrueSheetNavigationEventMap
|
|
91
|
+
>;
|
|
92
|
+
|
|
93
|
+
export type TrueSheetNavigatorProps = DefaultNavigatorOptions<
|
|
94
|
+
ParamListBase,
|
|
95
|
+
string | undefined,
|
|
96
|
+
TrueSheetNavigationState<ParamListBase>,
|
|
97
|
+
TrueSheetNavigationOptions,
|
|
98
|
+
TrueSheetNavigationEventMap,
|
|
99
|
+
unknown
|
|
100
|
+
> & {
|
|
101
|
+
/**
|
|
102
|
+
* The name of the route to use as the base screen.
|
|
103
|
+
* This screen will be rendered as a regular screen, while other screens are presented as sheets.
|
|
104
|
+
* Defaults to the first screen defined in the navigator.
|
|
105
|
+
*/
|
|
106
|
+
initialRouteName?: string;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type {
|
|
110
|
+
PositionChangeHandler,
|
|
111
|
+
TrueSheetDispatch,
|
|
112
|
+
TrueSheetNavigationEventMap,
|
|
113
|
+
TrueSheetNavigationOptions,
|
|
114
|
+
TrueSheetNavigationSheetProps,
|
|
115
|
+
TrueSheetStandardEventMap,
|
|
116
|
+
} from '../types';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createStandardNavigationFactories,
|
|
3
|
+
StackRouter,
|
|
4
|
+
type StandardNavigationTypeBagBase,
|
|
5
|
+
} from '@react-navigation/native';
|
|
6
|
+
|
|
7
|
+
import { createTrueSheetRouter } from './createTrueSheetRouter';
|
|
8
|
+
import { trueSheetNavigator } from './navigator';
|
|
9
|
+
import type {
|
|
10
|
+
StackRouterFactory,
|
|
11
|
+
TrueSheetActionHelpers,
|
|
12
|
+
TrueSheetNavigationOptions,
|
|
13
|
+
TrueSheetNavigationEventMap,
|
|
14
|
+
TrueSheetNavigationState,
|
|
15
|
+
TrueSheetNavigatorContentExtraProps,
|
|
16
|
+
TrueSheetRouterOptions,
|
|
17
|
+
} from './types';
|
|
18
|
+
|
|
19
|
+
export interface TrueSheetNavigationTypeBag extends StandardNavigationTypeBagBase {
|
|
20
|
+
State: TrueSheetNavigationState<this['ParamList']>;
|
|
21
|
+
ActionHelpers: TrueSheetActionHelpers<this['ParamList']>;
|
|
22
|
+
ScreenOptions: TrueSheetNavigationOptions;
|
|
23
|
+
EventMap: TrueSheetNavigationEventMap;
|
|
24
|
+
RouterOptions: TrueSheetRouterOptions;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const { createNavigator, createScreen } = createStandardNavigationFactories<
|
|
28
|
+
TrueSheetNavigationTypeBag,
|
|
29
|
+
{},
|
|
30
|
+
TrueSheetNavigatorContentExtraProps
|
|
31
|
+
>(
|
|
32
|
+
trueSheetNavigator,
|
|
33
|
+
createTrueSheetRouter(StackRouter as StackRouterFactory),
|
|
34
|
+
({ state, navigation }) => ({ routes: state.routes, dispatch: navigation.dispatch })
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates a TrueSheet navigator.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* const Sheet = createTrueSheetNavigator();
|
|
43
|
+
*
|
|
44
|
+
* function App() {
|
|
45
|
+
* return (
|
|
46
|
+
* <Sheet.Navigator>
|
|
47
|
+
* <Sheet.Screen name="Home" component={HomeScreen} />
|
|
48
|
+
* <Sheet.Screen
|
|
49
|
+
* name="Details"
|
|
50
|
+
* component={DetailsSheet}
|
|
51
|
+
* options={{ detents: [0.5, 1] }}
|
|
52
|
+
* />
|
|
53
|
+
* </Sheet.Navigator>
|
|
54
|
+
* );
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export const createTrueSheetNavigator = createNavigator;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Creates a screen configuration for the static API.
|
|
62
|
+
*/
|
|
63
|
+
export const createTrueSheetScreen = createScreen;
|
|
64
|
+
|
|
65
|
+
export { TrueSheetActions, type TrueSheetActionType } from './actions';
|
|
66
|
+
export { createTrueSheetRouter } from './createTrueSheetRouter';
|
|
67
|
+
export { useTrueSheetNavigation } from './useTrueSheetNavigation';
|
|
68
|
+
|
|
69
|
+
export type { DetentInfoEventPayload, PositionChangeEventPayload } from '../TrueSheet.types';
|
|
70
|
+
|
|
71
|
+
export type {
|
|
72
|
+
StackRouterFactory,
|
|
73
|
+
TrueSheetNavigationEventMap,
|
|
74
|
+
TrueSheetNavigationHelpers,
|
|
75
|
+
TrueSheetNavigationOptions,
|
|
76
|
+
TrueSheetNavigationProp,
|
|
77
|
+
TrueSheetNavigationState,
|
|
78
|
+
TrueSheetRouterOptions,
|
|
79
|
+
TrueSheetScreenProps,
|
|
80
|
+
} from './types';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createStandardNavigator } from 'standard-navigation';
|
|
2
|
+
|
|
3
|
+
import { TrueSheetNavigatorContent } from './TrueSheetNavigatorContent';
|
|
4
|
+
import type {
|
|
5
|
+
TrueSheetNavigationOptions,
|
|
6
|
+
TrueSheetNavigatorContentExtraProps,
|
|
7
|
+
TrueSheetStandardEventMap,
|
|
8
|
+
} from './types';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Framework-agnostic TrueSheet navigator.
|
|
12
|
+
* Wired into React Navigation via `./index` and Expo Router via `./expo-router`.
|
|
13
|
+
*/
|
|
14
|
+
export const trueSheetNavigator = createStandardNavigator<
|
|
15
|
+
TrueSheetNavigationOptions,
|
|
16
|
+
TrueSheetStandardEventMap,
|
|
17
|
+
TrueSheetNavigatorContentExtraProps
|
|
18
|
+
>(TrueSheetNavigatorContent);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import Animated from 'react-native-reanimated';
|
|
2
|
+
import { scheduleOnRN } from 'react-native-worklets';
|
|
3
|
+
|
|
4
|
+
import { useReanimatedPositionChangeHandler } from '../../reanimated';
|
|
5
|
+
import { TrueSheet } from '../../TrueSheet';
|
|
6
|
+
import type { PositionChangeEvent } from '../../TrueSheet.types';
|
|
7
|
+
import type { TrueSheetScreenProps } from './types';
|
|
8
|
+
import { useSheetScreenState } from './useSheetScreenState';
|
|
9
|
+
|
|
10
|
+
const AnimatedTrueSheet = Animated.createAnimatedComponent(TrueSheet);
|
|
11
|
+
|
|
12
|
+
export const ReanimatedTrueSheetScreen = ({
|
|
13
|
+
detentIndex,
|
|
14
|
+
resizeKey,
|
|
15
|
+
dispatch,
|
|
16
|
+
emit,
|
|
17
|
+
routeKey,
|
|
18
|
+
closing,
|
|
19
|
+
detents,
|
|
20
|
+
children,
|
|
21
|
+
positionChangeHandler,
|
|
22
|
+
...sheetProps
|
|
23
|
+
}: TrueSheetScreenProps) => {
|
|
24
|
+
const {
|
|
25
|
+
ref,
|
|
26
|
+
initialDetentIndex,
|
|
27
|
+
eventHandlers: { onPositionChange, ...eventHandlers },
|
|
28
|
+
} = useSheetScreenState({
|
|
29
|
+
detentIndex,
|
|
30
|
+
resizeKey,
|
|
31
|
+
closing,
|
|
32
|
+
dispatch,
|
|
33
|
+
routeKey,
|
|
34
|
+
emit,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const reanimatedPositionChangeHandler = useReanimatedPositionChangeHandler(
|
|
38
|
+
(payload) => {
|
|
39
|
+
'worklet';
|
|
40
|
+
positionChangeHandler?.(payload);
|
|
41
|
+
scheduleOnRN(onPositionChange, {
|
|
42
|
+
nativeEvent: payload,
|
|
43
|
+
} as PositionChangeEvent);
|
|
44
|
+
},
|
|
45
|
+
[onPositionChange, positionChangeHandler]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<AnimatedTrueSheet
|
|
50
|
+
ref={ref}
|
|
51
|
+
name={`navigation-sheet-${routeKey}`}
|
|
52
|
+
initialDetentIndex={initialDetentIndex}
|
|
53
|
+
detents={detents}
|
|
54
|
+
onPositionChange={reanimatedPositionChangeHandler}
|
|
55
|
+
{...sheetProps}
|
|
56
|
+
{...eventHandlers}
|
|
57
|
+
>
|
|
58
|
+
{children}
|
|
59
|
+
</AnimatedTrueSheet>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import { TrueSheet } from '../../TrueSheet';
|
|
4
|
+
import type { PositionChangeEvent } from '../../TrueSheet.types';
|
|
5
|
+
import type { TrueSheetScreenProps } from './types';
|
|
6
|
+
import { useSheetScreenState } from './useSheetScreenState';
|
|
7
|
+
|
|
8
|
+
export const TrueSheetScreen = ({
|
|
9
|
+
detentIndex,
|
|
10
|
+
resizeKey,
|
|
11
|
+
dispatch,
|
|
12
|
+
emit,
|
|
13
|
+
routeKey,
|
|
14
|
+
closing,
|
|
15
|
+
detents,
|
|
16
|
+
children,
|
|
17
|
+
positionChangeHandler,
|
|
18
|
+
...sheetProps
|
|
19
|
+
}: TrueSheetScreenProps) => {
|
|
20
|
+
const {
|
|
21
|
+
ref,
|
|
22
|
+
initialDetentIndex,
|
|
23
|
+
eventHandlers: { onPositionChange, ...eventHandlers },
|
|
24
|
+
} = useSheetScreenState({
|
|
25
|
+
detentIndex,
|
|
26
|
+
resizeKey,
|
|
27
|
+
closing,
|
|
28
|
+
dispatch,
|
|
29
|
+
routeKey,
|
|
30
|
+
emit,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const handlePositionChange = useCallback(
|
|
34
|
+
(e: PositionChangeEvent) => {
|
|
35
|
+
onPositionChange(e);
|
|
36
|
+
positionChangeHandler?.(e.nativeEvent);
|
|
37
|
+
},
|
|
38
|
+
[onPositionChange, positionChangeHandler]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<TrueSheet
|
|
43
|
+
ref={ref}
|
|
44
|
+
name={`navigation-sheet-${routeKey}`}
|
|
45
|
+
initialDetentIndex={initialDetentIndex}
|
|
46
|
+
detents={detents}
|
|
47
|
+
onPositionChange={handlePositionChange}
|
|
48
|
+
{...sheetProps}
|
|
49
|
+
{...eventHandlers}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
</TrueSheet>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TrueSheetProps } from '../../TrueSheet.types';
|
|
2
|
+
import type {
|
|
3
|
+
PositionChangeHandler,
|
|
4
|
+
TrueSheetDispatch,
|
|
5
|
+
TrueSheetEmitFn,
|
|
6
|
+
TrueSheetNavigationSheetProps,
|
|
7
|
+
} from '../types';
|
|
8
|
+
|
|
9
|
+
export interface TrueSheetScreenProps extends TrueSheetNavigationSheetProps {
|
|
10
|
+
detentIndex: number;
|
|
11
|
+
resizeKey?: number;
|
|
12
|
+
dispatch: TrueSheetDispatch;
|
|
13
|
+
emit: TrueSheetEmitFn;
|
|
14
|
+
routeKey: string;
|
|
15
|
+
closing?: boolean;
|
|
16
|
+
detents: TrueSheetProps['detents'];
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
positionChangeHandler?: PositionChangeHandler;
|
|
19
|
+
}
|