@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
package/lib/module/TrueSheet.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { PureComponent, createRef, isValidElement, createElement } from 'react';
|
|
3
|
+
import { PureComponent, createRef, isValidElement, createElement, useEffect } from 'react';
|
|
4
4
|
import TrueSheetViewNativeComponent from './fabric/TrueSheetViewNativeComponent';
|
|
5
5
|
import TrueSheetContainerViewNativeComponent from './fabric/TrueSheetContainerViewNativeComponent';
|
|
6
6
|
import TrueSheetContentViewNativeComponent from './fabric/TrueSheetContentViewNativeComponent';
|
|
7
|
+
import TrueSheetHeaderViewNativeComponent from './fabric/TrueSheetHeaderViewNativeComponent';
|
|
7
8
|
import TrueSheetFooterViewNativeComponent from './fabric/TrueSheetFooterViewNativeComponent';
|
|
8
9
|
import TrueSheetModule from "./specs/NativeTrueSheetModule.js";
|
|
9
|
-
import { Platform,
|
|
10
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Platform, StyleSheet, BackHandler, RootTagContext, findNodeHandle, processColor } from 'react-native';
|
|
11
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
// RN has no public API for hosting the element inspector inside a presented view;
|
|
13
|
+
// this is the internal RN's Modal uses. Dev-only so prod bundles never resolve it.
|
|
14
|
+
// The template literal keeps the RN babel preset's deep-import warning off while
|
|
15
|
+
// Metro still resolves the module statically.
|
|
16
|
+
const AppContainer = __DEV__ ? require(`react-native/Libraries/ReactNative/AppContainer`).default : null;
|
|
11
17
|
const LINKING_ERROR = `The package '@lodev09/react-native-true-sheet' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
12
18
|
ios: "- You have run 'pod install'\n",
|
|
13
19
|
default: ''
|
|
@@ -15,8 +21,41 @@ const LINKING_ERROR = `The package '@lodev09/react-native-true-sheet' doesn't se
|
|
|
15
21
|
if (!TrueSheetModule) {
|
|
16
22
|
throw new Error(LINKING_ERROR);
|
|
17
23
|
}
|
|
24
|
+
// Stop raw touch events from bubbling past the sheet to outside ancestors
|
|
25
|
+
const stopTouchPropagation = event => event.stopPropagation();
|
|
26
|
+
|
|
27
|
+
// Stop the responder negotiation at the sheet boundary without claiming the
|
|
28
|
+
// responder. Views inside the sheet are asked before this one, so in-sheet
|
|
29
|
+
// touchables work normally; views outside are asked after, so stopping here
|
|
30
|
+
// keeps unclaimed touches from leaking to touchables behind the sheet.
|
|
31
|
+
// Claiming instead (returning true) would steal the responder from a pressed
|
|
32
|
+
// touchable whenever the negotiation re-runs mid-gesture — e.g. a second
|
|
33
|
+
// finger, or the duplicate touch stream from a nested react-native-screens
|
|
34
|
+
// screen that attaches its own touch handler inside the sheet.
|
|
35
|
+
const stopResponderNegotiation = event => {
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
return false;
|
|
38
|
+
};
|
|
39
|
+
// Gates auto-present (initialDetentIndex) by one commit. Rendered last in the
|
|
40
|
+
// sheet subtree so its mount effect runs after the content's mount effects —
|
|
41
|
+
// updates they schedule (e.g. a navigation footer via setOptions) batch with
|
|
42
|
+
// onReady's, so native receives initialDetentIndex together with the settled
|
|
43
|
+
// tree and presents at the final height instead of resizing mid-flight.
|
|
44
|
+
const InitialPresentGate = ({
|
|
45
|
+
onReady
|
|
46
|
+
}) => {
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
onReady();
|
|
49
|
+
}, [onReady]);
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
18
52
|
export class TrueSheet extends PureComponent {
|
|
19
53
|
displayName = 'TrueSheet';
|
|
54
|
+
static contextType = RootTagContext;
|
|
55
|
+
backHandlerSubscription = null;
|
|
56
|
+
isPresented = false;
|
|
57
|
+
isSheetVisible = true;
|
|
58
|
+
|
|
20
59
|
/**
|
|
21
60
|
* Map of sheet names against their instances.
|
|
22
61
|
*/
|
|
@@ -26,21 +65,27 @@ export class TrueSheet extends PureComponent {
|
|
|
26
65
|
* Resolver to be called when mount event is received
|
|
27
66
|
*/
|
|
28
67
|
presentationResolver = null;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Tracks if a present operation is in progress
|
|
71
|
+
*/
|
|
72
|
+
isPresenting = false;
|
|
29
73
|
constructor(props) {
|
|
30
74
|
super(props);
|
|
31
75
|
this.nativeRef = /*#__PURE__*/createRef();
|
|
32
76
|
this.validateDetents();
|
|
33
77
|
|
|
34
|
-
// Lazy load by default, except when
|
|
35
|
-
const shouldRenderImmediately = props.initialDetentIndex !== undefined && props.initialDetentIndex >= 0;
|
|
78
|
+
// Lazy load by default, except when auto-presenting or when lazy is disabled
|
|
79
|
+
const shouldRenderImmediately = props.initialDetentIndex !== undefined && props.initialDetentIndex >= 0 || props.lazy === false;
|
|
36
80
|
this.state = {
|
|
37
81
|
shouldRenderNativeView: shouldRenderImmediately,
|
|
38
|
-
|
|
39
|
-
|
|
82
|
+
initialPresentReady: false,
|
|
83
|
+
scrollableHandle: null
|
|
40
84
|
};
|
|
41
85
|
this.onMount = this.onMount.bind(this);
|
|
42
86
|
this.onWillDismiss = this.onWillDismiss.bind(this);
|
|
43
87
|
this.onDidDismiss = this.onDidDismiss.bind(this);
|
|
88
|
+
this.onDismissAttempt = this.onDismissAttempt.bind(this);
|
|
44
89
|
this.onWillPresent = this.onWillPresent.bind(this);
|
|
45
90
|
this.onDidPresent = this.onDidPresent.bind(this);
|
|
46
91
|
this.onDetentChange = this.onDetentChange.bind(this);
|
|
@@ -48,7 +93,32 @@ export class TrueSheet extends PureComponent {
|
|
|
48
93
|
this.onDragChange = this.onDragChange.bind(this);
|
|
49
94
|
this.onDragEnd = this.onDragEnd.bind(this);
|
|
50
95
|
this.onPositionChange = this.onPositionChange.bind(this);
|
|
51
|
-
this.
|
|
96
|
+
this.onWillFocus = this.onWillFocus.bind(this);
|
|
97
|
+
this.onDidFocus = this.onDidFocus.bind(this);
|
|
98
|
+
this.onWillBlur = this.onWillBlur.bind(this);
|
|
99
|
+
this.onDidBlur = this.onDidBlur.bind(this);
|
|
100
|
+
this.handleBackPress = this.handleBackPress.bind(this);
|
|
101
|
+
this.onVisibilityChange = this.onVisibilityChange.bind(this);
|
|
102
|
+
this.onInitialPresentReady = this.onInitialPresentReady.bind(this);
|
|
103
|
+
}
|
|
104
|
+
onInitialPresentReady() {
|
|
105
|
+
this.setState({
|
|
106
|
+
initialPresentReady: true
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Resolves after commit (didMount/didUpdate) — the scrollable mounts with the
|
|
111
|
+
// sheet content, so its ref is only populated once the native tree renders.
|
|
112
|
+
updateScrollableHandle() {
|
|
113
|
+
const {
|
|
114
|
+
scrollableRef
|
|
115
|
+
} = this.props;
|
|
116
|
+
const scrollableHandle = scrollableRef?.current ? findNodeHandle(scrollableRef.current) : null;
|
|
117
|
+
if (scrollableHandle !== this.state.scrollableHandle) {
|
|
118
|
+
this.setState({
|
|
119
|
+
scrollableHandle
|
|
120
|
+
});
|
|
121
|
+
}
|
|
52
122
|
}
|
|
53
123
|
validateDetents() {
|
|
54
124
|
const {
|
|
@@ -64,7 +134,7 @@ export class TrueSheet extends PureComponent {
|
|
|
64
134
|
// Warn for invalid detent fractions
|
|
65
135
|
if (detents) {
|
|
66
136
|
detents.forEach((detent, index) => {
|
|
67
|
-
if (detent
|
|
137
|
+
if (typeof detent === 'number' && detent !== -1 && detent !== -2) {
|
|
68
138
|
if (detent <= 0 || detent > 1) {
|
|
69
139
|
console.warn(`TrueSheet: detent at index ${index} (${detent}) should be between 0 and 1. It will be clamped.`);
|
|
70
140
|
}
|
|
@@ -100,29 +170,46 @@ export class TrueSheet extends PureComponent {
|
|
|
100
170
|
* Present the sheet by given `name` (Promise-based)
|
|
101
171
|
* @param name - Sheet name (must match sheet's name prop)
|
|
102
172
|
* @param index - Detent index (default: 0)
|
|
173
|
+
* @param animated - Whether to animate the presentation (default: true)
|
|
103
174
|
* @returns Promise that resolves when sheet is fully presented
|
|
104
175
|
* @throws Error if sheet not found or presentation fails
|
|
105
176
|
*/
|
|
106
|
-
static async present(name, index = 0) {
|
|
177
|
+
static async present(name, index = 0, animated = true) {
|
|
107
178
|
const instance = TrueSheet.getInstance(name);
|
|
108
179
|
if (!instance) {
|
|
109
180
|
throw new Error(`Sheet with name "${name}" not found`);
|
|
110
181
|
}
|
|
111
|
-
return instance.present(index);
|
|
182
|
+
return instance.present(index, animated);
|
|
112
183
|
}
|
|
113
184
|
|
|
114
185
|
/**
|
|
115
186
|
* Dismiss the sheet by given `name` (Promise-based)
|
|
116
187
|
* @param name - Sheet name
|
|
188
|
+
* @param animated - Whether to animate the dismissal (default: true)
|
|
117
189
|
* @returns Promise that resolves when sheet is fully dismissed
|
|
118
190
|
* @throws Error if sheet not found or dismissal fails
|
|
119
191
|
*/
|
|
120
|
-
static async dismiss(name) {
|
|
192
|
+
static async dismiss(name, animated = true) {
|
|
121
193
|
const instance = TrueSheet.getInstance(name);
|
|
122
194
|
if (!instance) {
|
|
123
195
|
throw new Error(`Sheet with name "${name}" not found`);
|
|
124
196
|
}
|
|
125
|
-
return instance.dismiss();
|
|
197
|
+
return instance.dismiss(animated);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Dismiss only the sheets presented on top of a sheet by given `name`
|
|
202
|
+
* @param name - Sheet name
|
|
203
|
+
* @param animated - Whether to animate the dismissal (default: true)
|
|
204
|
+
* @returns Promise that resolves when all child sheets are dismissed
|
|
205
|
+
* @throws Error if sheet not found
|
|
206
|
+
*/
|
|
207
|
+
static async dismissStack(name, animated = true) {
|
|
208
|
+
const instance = TrueSheet.getInstance(name);
|
|
209
|
+
if (!instance) {
|
|
210
|
+
throw new Error(`Sheet with name "${name}" not found`);
|
|
211
|
+
}
|
|
212
|
+
return instance.dismissStack(animated);
|
|
126
213
|
}
|
|
127
214
|
|
|
128
215
|
/**
|
|
@@ -139,6 +226,16 @@ export class TrueSheet extends PureComponent {
|
|
|
139
226
|
}
|
|
140
227
|
return instance.resize(index);
|
|
141
228
|
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Dismiss all presented sheets by dismissing from the bottom of the stack.
|
|
232
|
+
* This ensures child sheets are dismissed first before their parent.
|
|
233
|
+
* @param animated - Whether to animate the dismissals (default: true)
|
|
234
|
+
* @returns Promise that resolves when all sheets are dismissed
|
|
235
|
+
*/
|
|
236
|
+
static async dismissAll(animated = true) {
|
|
237
|
+
return TrueSheetModule?.dismissAll(animated);
|
|
238
|
+
}
|
|
142
239
|
registerInstance() {
|
|
143
240
|
if (this.props.name) {
|
|
144
241
|
TrueSheet.instances[this.props.name] = this;
|
|
@@ -156,16 +253,31 @@ export class TrueSheet extends PureComponent {
|
|
|
156
253
|
this.props.onWillPresent?.(event);
|
|
157
254
|
}
|
|
158
255
|
onDidPresent(event) {
|
|
256
|
+
this.isPresented = true;
|
|
257
|
+
if (Platform.OS === 'android') {
|
|
258
|
+
this.backHandlerSubscription?.remove();
|
|
259
|
+
this.backHandlerSubscription = BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
|
|
260
|
+
}
|
|
159
261
|
this.props.onDidPresent?.(event);
|
|
160
262
|
}
|
|
161
263
|
onWillDismiss(event) {
|
|
162
264
|
this.props.onWillDismiss?.(event);
|
|
163
265
|
}
|
|
266
|
+
onDismissAttempt(event) {
|
|
267
|
+
this.props.onDismissAttempt?.(event);
|
|
268
|
+
}
|
|
164
269
|
onDidDismiss(event) {
|
|
165
|
-
|
|
166
|
-
this.
|
|
167
|
-
|
|
168
|
-
|
|
270
|
+
this.isPresented = false;
|
|
271
|
+
this.isSheetVisible = true;
|
|
272
|
+
this.backHandlerSubscription?.remove();
|
|
273
|
+
this.backHandlerSubscription = null;
|
|
274
|
+
|
|
275
|
+
// Non-lazy content stays mounted; otherwise clean it up unless another presentation is active.
|
|
276
|
+
if (!this.isPresenting && this.props.lazy !== false) {
|
|
277
|
+
this.setState({
|
|
278
|
+
shouldRenderNativeView: false
|
|
279
|
+
});
|
|
280
|
+
}
|
|
169
281
|
this.props.onDidDismiss?.(event);
|
|
170
282
|
}
|
|
171
283
|
onMount(event) {
|
|
@@ -188,30 +300,57 @@ export class TrueSheet extends PureComponent {
|
|
|
188
300
|
onPositionChange(event) {
|
|
189
301
|
this.props.onPositionChange?.(event);
|
|
190
302
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
303
|
+
onWillFocus(event) {
|
|
304
|
+
this.props.onWillFocus?.(event);
|
|
305
|
+
}
|
|
306
|
+
onDidFocus(event) {
|
|
307
|
+
this.props.onDidFocus?.(event);
|
|
308
|
+
}
|
|
309
|
+
onWillBlur(event) {
|
|
310
|
+
this.props.onWillBlur?.(event);
|
|
311
|
+
}
|
|
312
|
+
onDidBlur(event) {
|
|
313
|
+
this.props.onDidBlur?.(event);
|
|
314
|
+
}
|
|
315
|
+
onVisibilityChange(event) {
|
|
316
|
+
this.isSheetVisible = event.nativeEvent.visible;
|
|
317
|
+
}
|
|
318
|
+
handleBackPress() {
|
|
319
|
+
if (!this.isPresented || !this.isSheetVisible) return false;
|
|
196
320
|
|
|
197
|
-
//
|
|
198
|
-
this.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
321
|
+
// The native view can be detached (e.g. host screen unmounted by navigation)
|
|
322
|
+
// before onDidDismiss removes this subscription. Treat back press as a no-op
|
|
323
|
+
// instead of throwing from the handle getter.
|
|
324
|
+
const nodeHandle = findNodeHandle(this.nativeRef.current);
|
|
325
|
+
if (nodeHandle == null || nodeHandle === -1) return false;
|
|
202
326
|
|
|
203
|
-
//
|
|
327
|
+
// When not dismissible, report the attempt. An attempt handler consumes the back
|
|
328
|
+
// press; otherwise let it propagate (e.g. navigation goes back to the previous screen)
|
|
329
|
+
if (this.props.dismissible === false) {
|
|
330
|
+
const {
|
|
331
|
+
onDismissAttempt,
|
|
332
|
+
onBackPress
|
|
333
|
+
} = this.props;
|
|
334
|
+
onDismissAttempt?.({
|
|
335
|
+
nativeEvent: null
|
|
336
|
+
});
|
|
337
|
+
return onBackPress?.() ?? onDismissAttempt != null;
|
|
338
|
+
}
|
|
339
|
+
TrueSheetModule?.handleBackPress(nodeHandle);
|
|
340
|
+
return this.props.onBackPress?.() ?? true;
|
|
204
341
|
}
|
|
205
342
|
|
|
206
343
|
/**
|
|
207
|
-
* Present the
|
|
208
|
-
* @param index -
|
|
344
|
+
* Present the sheet at a given detent index.
|
|
345
|
+
* @param index - The detent index to present at (default: 0)
|
|
346
|
+
* @param animated - Whether to animate the presentation (default: true)
|
|
209
347
|
*/
|
|
210
|
-
async present(index = 0) {
|
|
348
|
+
async present(index = 0, animated = true) {
|
|
211
349
|
const detentsLength = Math.min(this.props.detents?.length ?? 2, 3); // Max 3 detents
|
|
212
350
|
if (index < 0 || index >= detentsLength) {
|
|
213
351
|
throw new Error(`TrueSheet: present index (${index}) is out of bounds. detents array has ${detentsLength} item(s)`);
|
|
214
352
|
}
|
|
353
|
+
this.isPresenting = true;
|
|
215
354
|
|
|
216
355
|
// Lazy load: render native view if not already rendered
|
|
217
356
|
if (!this.state.shouldRenderNativeView) {
|
|
@@ -222,64 +361,108 @@ export class TrueSheet extends PureComponent {
|
|
|
222
361
|
});
|
|
223
362
|
});
|
|
224
363
|
}
|
|
225
|
-
|
|
364
|
+
await TrueSheetModule?.presentByRef(this.handle, index, animated);
|
|
365
|
+
this.isPresenting = false;
|
|
226
366
|
}
|
|
227
367
|
|
|
228
368
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
369
|
+
* Resize the sheet to a given detent index.
|
|
370
|
+
* @param index - The detent index to resize to
|
|
231
371
|
*/
|
|
232
372
|
async resize(index) {
|
|
233
|
-
await this.
|
|
373
|
+
await TrueSheetModule?.resizeByRef(this.handle, index);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Dismiss this sheet and all sheets presented on top of it in a single animation.
|
|
378
|
+
* @param animated - Whether to animate the dismissal (default: true)
|
|
379
|
+
*/
|
|
380
|
+
async dismiss(animated = true) {
|
|
381
|
+
return TrueSheetModule?.dismissByRef(this.handle, animated);
|
|
234
382
|
}
|
|
235
383
|
|
|
236
384
|
/**
|
|
237
|
-
*
|
|
385
|
+
* Dismiss only the sheets presented on top of this sheet, keeping this sheet presented.
|
|
386
|
+
* If no sheets are presented on top, this method does nothing.
|
|
387
|
+
* @param animated - Whether to animate the dismissal (default: true)
|
|
238
388
|
*/
|
|
239
|
-
async
|
|
240
|
-
return TrueSheetModule?.
|
|
389
|
+
async dismissStack(animated = true) {
|
|
390
|
+
return TrueSheetModule?.dismissStackByRef(this.handle, animated);
|
|
241
391
|
}
|
|
242
392
|
componentDidMount() {
|
|
243
393
|
this.registerInstance();
|
|
394
|
+
this.updateScrollableHandle();
|
|
244
395
|
}
|
|
245
396
|
componentDidUpdate(prevProps) {
|
|
246
397
|
this.registerInstance();
|
|
398
|
+
this.updateScrollableHandle();
|
|
399
|
+
if (prevProps.lazy !== false && this.props.lazy === false && !this.state.shouldRenderNativeView) {
|
|
400
|
+
this.setState({
|
|
401
|
+
shouldRenderNativeView: true
|
|
402
|
+
});
|
|
403
|
+
}
|
|
247
404
|
|
|
248
405
|
// Validate when detents prop changes
|
|
249
406
|
if (prevProps.detents !== this.props.detents) {
|
|
250
407
|
this.validateDetents();
|
|
251
408
|
}
|
|
409
|
+
|
|
410
|
+
// initialDetentIndex set at runtime on a lazily-mounted sheet: render the
|
|
411
|
+
// native tree so InitialPresentGate can deliver the index (constructor
|
|
412
|
+
// only computes this for the initial prop).
|
|
413
|
+
const prevInitialDetentIndex = prevProps.initialDetentIndex ?? -1;
|
|
414
|
+
const initialDetentIndex = this.props.initialDetentIndex ?? -1;
|
|
415
|
+
if (prevInitialDetentIndex < 0 && initialDetentIndex >= 0 && !this.state.shouldRenderNativeView) {
|
|
416
|
+
this.setState({
|
|
417
|
+
shouldRenderNativeView: true
|
|
418
|
+
});
|
|
419
|
+
}
|
|
252
420
|
}
|
|
253
421
|
componentWillUnmount() {
|
|
254
422
|
this.unregisterInstance();
|
|
255
|
-
|
|
256
|
-
|
|
423
|
+
this.backHandlerSubscription?.remove();
|
|
424
|
+
this.backHandlerSubscription = null;
|
|
257
425
|
this.presentationResolver = null;
|
|
258
426
|
}
|
|
259
427
|
render() {
|
|
260
428
|
const {
|
|
261
429
|
detents = [0.5, 1],
|
|
262
|
-
backgroundColor
|
|
430
|
+
backgroundColor,
|
|
263
431
|
dismissible = true,
|
|
432
|
+
draggable = true,
|
|
264
433
|
grabber = true,
|
|
434
|
+
grabberOptions,
|
|
435
|
+
accessibilityOptions,
|
|
265
436
|
dimmed = true,
|
|
266
437
|
initialDetentIndex = -1,
|
|
267
438
|
initialDetentAnimated = true,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
439
|
+
dimmedDetentIndex,
|
|
440
|
+
backgroundBlur,
|
|
441
|
+
blurOptions,
|
|
271
442
|
cornerRadius,
|
|
272
|
-
|
|
273
|
-
|
|
443
|
+
maxContentHeight,
|
|
444
|
+
maxContentWidth,
|
|
445
|
+
anchor = 'center',
|
|
446
|
+
anchorOffset,
|
|
447
|
+
scrollableOptions,
|
|
448
|
+
footerOptions,
|
|
449
|
+
presentation = 'page',
|
|
274
450
|
children,
|
|
275
451
|
style,
|
|
452
|
+
header,
|
|
453
|
+
headerStyle,
|
|
454
|
+
headerOptions,
|
|
276
455
|
footer,
|
|
277
|
-
|
|
456
|
+
footerStyle,
|
|
457
|
+
insetAdjustment = 'automatic',
|
|
458
|
+
...rest
|
|
278
459
|
} = this.props;
|
|
460
|
+
delete rest.lazy;
|
|
279
461
|
|
|
280
462
|
// Trim to max 3 detents and clamp fractions
|
|
281
463
|
const resolvedDetents = detents.slice(0, 3).map(detent => {
|
|
282
464
|
if (detent === 'auto' || detent === -1) return -1;
|
|
465
|
+
if (detent === 'peek' || detent === -2) return -2;
|
|
283
466
|
|
|
284
467
|
// Default to 0.1 if zero or below
|
|
285
468
|
if (detent <= 0) return 0.1;
|
|
@@ -287,63 +470,155 @@ export class TrueSheet extends PureComponent {
|
|
|
287
470
|
// Clamp to maximum of 1
|
|
288
471
|
return Math.min(1, detent);
|
|
289
472
|
});
|
|
473
|
+
|
|
474
|
+
// Hold initialDetentIndex back from native until the gate's effect flushes
|
|
475
|
+
// (see InitialPresentGate) — native presents when the prop lands.
|
|
476
|
+
const autoPresent = initialDetentIndex >= 0;
|
|
477
|
+
const gatedInitialDetentIndex = autoPresent && !this.state.initialPresentReady ? -1 : initialDetentIndex;
|
|
478
|
+
|
|
479
|
+
// Cache grabberOptions to avoid creating a new object every render
|
|
480
|
+
if (grabberOptions !== this.cachedGrabberOptions) {
|
|
481
|
+
this.cachedGrabberOptions = grabberOptions;
|
|
482
|
+
this.resolvedGrabberOptions = {
|
|
483
|
+
...grabberOptions,
|
|
484
|
+
color: processColor(grabberOptions?.color)
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
const sheetContent = /*#__PURE__*/_jsxs(_Fragment, {
|
|
488
|
+
children: [header && /*#__PURE__*/_jsx(TrueSheetHeaderViewNativeComponent, {
|
|
489
|
+
style: [styles.header, headerOptions?.position === 'absolute' && styles.absoluteHeader, headerStyle],
|
|
490
|
+
children: /*#__PURE__*/isValidElement(header) ? header : /*#__PURE__*/createElement(header)
|
|
491
|
+
}), /*#__PURE__*/_jsx(TrueSheetContentViewNativeComponent, {
|
|
492
|
+
style: style,
|
|
493
|
+
children: children
|
|
494
|
+
}), footer && /*#__PURE__*/_jsx(TrueSheetFooterViewNativeComponent, {
|
|
495
|
+
autoBottomInset: insetAdjustment === 'automatic',
|
|
496
|
+
style: [styles.footer, footerOptions?.position === 'absolute' ? styles.absoluteFooter : styles.relativeFooter, footerStyle],
|
|
497
|
+
children: /*#__PURE__*/isValidElement(footer) ? footer : /*#__PURE__*/createElement(footer)
|
|
498
|
+
}), autoPresent && !this.state.initialPresentReady && /*#__PURE__*/_jsx(InitialPresentGate, {
|
|
499
|
+
onReady: this.onInitialPresentReady
|
|
500
|
+
})]
|
|
501
|
+
});
|
|
290
502
|
return /*#__PURE__*/_jsx(TrueSheetViewNativeComponent, {
|
|
503
|
+
...rest,
|
|
291
504
|
ref: this.nativeRef,
|
|
292
505
|
style: styles.sheetView,
|
|
293
506
|
detents: resolvedDetents,
|
|
294
|
-
|
|
295
|
-
|
|
507
|
+
backgroundBlur: backgroundBlur,
|
|
508
|
+
blurOptions: blurOptions,
|
|
509
|
+
backgroundColor: backgroundColor,
|
|
296
510
|
cornerRadius: cornerRadius,
|
|
297
511
|
grabber: grabber,
|
|
512
|
+
grabberOptions: this.resolvedGrabberOptions,
|
|
513
|
+
accessibilityOptions: accessibilityOptions,
|
|
298
514
|
dimmed: dimmed,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
initialDetentIndex: initialDetentIndex,
|
|
515
|
+
dimmedDetentIndex: dimmedDetentIndex,
|
|
516
|
+
initialDetentIndex: gatedInitialDetentIndex,
|
|
302
517
|
initialDetentAnimated: initialDetentAnimated,
|
|
303
518
|
dismissible: dismissible,
|
|
304
|
-
|
|
305
|
-
|
|
519
|
+
draggable: draggable,
|
|
520
|
+
maxContentHeight: maxContentHeight,
|
|
521
|
+
maxContentWidth: maxContentWidth,
|
|
522
|
+
anchor: anchor,
|
|
523
|
+
anchorOffset: anchorOffset,
|
|
524
|
+
scrollableHandle: this.state.scrollableHandle ?? -1,
|
|
525
|
+
scrollableOptions: scrollableOptions,
|
|
526
|
+
headerOptions: headerOptions,
|
|
527
|
+
footerOptions: {
|
|
528
|
+
footerPosition: footerOptions?.position,
|
|
529
|
+
keyboardOffset: footerOptions?.keyboardOffset
|
|
530
|
+
},
|
|
531
|
+
presentation: presentation,
|
|
532
|
+
insetAdjustment: insetAdjustment,
|
|
306
533
|
onMount: this.onMount,
|
|
307
534
|
onWillPresent: this.onWillPresent,
|
|
308
535
|
onDidPresent: this.onDidPresent,
|
|
309
536
|
onWillDismiss: this.onWillDismiss,
|
|
310
537
|
onDidDismiss: this.onDidDismiss,
|
|
538
|
+
onDismissAttempt: this.onDismissAttempt,
|
|
311
539
|
onDetentChange: this.onDetentChange,
|
|
312
540
|
onDragBegin: this.onDragBegin,
|
|
313
541
|
onDragChange: this.onDragChange,
|
|
314
542
|
onDragEnd: this.onDragEnd,
|
|
315
543
|
onPositionChange: this.onPositionChange,
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
544
|
+
onWillFocus: this.onWillFocus,
|
|
545
|
+
onDidFocus: this.onDidFocus,
|
|
546
|
+
onWillBlur: this.onWillBlur,
|
|
547
|
+
onDidBlur: this.onDidBlur,
|
|
548
|
+
onVisibilityChange: this.onVisibilityChange
|
|
549
|
+
// These must stay on this host view, not on the container. The container is
|
|
550
|
+
// reparented into the native sheet, so this view is never a native ancestor of
|
|
551
|
+
// the sheet content — this is the React-tree boundary between the sheet and
|
|
552
|
+
// the presenting screen, where both the responder negotiation and raw touch
|
|
553
|
+
// bubbling must stop.
|
|
554
|
+
,
|
|
555
|
+
onStartShouldSetResponder: stopResponderNegotiation,
|
|
556
|
+
onMoveShouldSetResponder: stopResponderNegotiation,
|
|
557
|
+
onTouchStart: stopTouchPropagation,
|
|
558
|
+
onTouchMove: stopTouchPropagation,
|
|
559
|
+
onTouchEnd: stopTouchPropagation,
|
|
560
|
+
onTouchCancel: stopTouchPropagation,
|
|
561
|
+
children: this.state.shouldRenderNativeView && /*#__PURE__*/_jsx(TrueSheetContainerViewNativeComponent, {
|
|
562
|
+
style: styles.container,
|
|
563
|
+
children: AppContainer ?
|
|
564
|
+
/*#__PURE__*/
|
|
565
|
+
// Hosts the element inspector inside the sheet, like RN's Modal does —
|
|
566
|
+
// the app-level one sits behind the presented sheet.
|
|
567
|
+
// `display: contents` keeps AppContainer's wrapper views out of both
|
|
568
|
+
// Yoga layout and the native tree, so header/content/footer remain the
|
|
569
|
+
// container's direct native children, while the inspector overlay
|
|
570
|
+
// anchors to the container and lines up with measured frames.
|
|
571
|
+
_jsx(AppContainer, {
|
|
572
|
+
rootTag: this.context,
|
|
573
|
+
rootViewStyle: styles.inspectorHost,
|
|
574
|
+
internal_excludeLogBox: true,
|
|
575
|
+
children: sheetContent
|
|
576
|
+
}) : sheetContent
|
|
333
577
|
})
|
|
334
578
|
});
|
|
335
579
|
}
|
|
336
580
|
}
|
|
581
|
+
|
|
582
|
+
// Compile-time check: `TrueSheet`'s static surface must satisfy `TrueSheetStaticMethods`.
|
|
583
|
+
TrueSheet;
|
|
337
584
|
const styles = StyleSheet.create({
|
|
338
585
|
sheetView: {
|
|
586
|
+
...StyleSheet.absoluteFill,
|
|
587
|
+
zIndex: -9999,
|
|
588
|
+
pointerEvents: 'box-none'
|
|
589
|
+
},
|
|
590
|
+
// Fill the sheet so flex layouts track the sheet's size per detent
|
|
591
|
+
container: {
|
|
592
|
+
...StyleSheet.absoluteFill
|
|
593
|
+
},
|
|
594
|
+
inspectorHost: {
|
|
595
|
+
display: 'contents'
|
|
596
|
+
},
|
|
597
|
+
header: {
|
|
598
|
+
pointerEvents: 'box-none'
|
|
599
|
+
},
|
|
600
|
+
// Floats over the content so it doesn't take up layout space
|
|
601
|
+
absoluteHeader: {
|
|
339
602
|
position: 'absolute',
|
|
340
|
-
|
|
341
|
-
|
|
603
|
+
top: 0,
|
|
604
|
+
left: 0,
|
|
605
|
+
right: 0,
|
|
606
|
+
zIndex: 1
|
|
342
607
|
},
|
|
343
608
|
footer: {
|
|
609
|
+
pointerEvents: 'box-none'
|
|
610
|
+
},
|
|
611
|
+
// Pinned to the sheet's bottom edge via Yoga since the container tracks the
|
|
612
|
+
// sheet's visible height — takes up layout space below the content
|
|
613
|
+
relativeFooter: {
|
|
614
|
+
marginTop: 'auto'
|
|
615
|
+
},
|
|
616
|
+
// Floats over the content so it doesn't take up layout space
|
|
617
|
+
absoluteFooter: {
|
|
344
618
|
position: 'absolute',
|
|
345
619
|
left: 0,
|
|
346
|
-
right: 0
|
|
620
|
+
right: 0,
|
|
621
|
+
bottom: 0
|
|
347
622
|
}
|
|
348
623
|
});
|
|
349
624
|
//# sourceMappingURL=TrueSheet.js.map
|