@tamagui/sheet 2.0.0-rc.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -0
- package/controller/index.cjs +2 -0
- package/controller/index.js +2 -0
- package/controller/index.native.cjs +2 -0
- package/controller/index.native.js +2 -0
- package/dist/cjs/GestureDetectorWrapper.cjs +27 -21
- package/dist/cjs/GestureDetectorWrapper.native.js +33 -28
- package/dist/cjs/GestureDetectorWrapper.native.js.map +1 -1
- package/dist/cjs/GestureSheetContext.cjs +14 -12
- package/dist/cjs/GestureSheetContext.native.js +29 -27
- package/dist/cjs/GestureSheetContext.native.js.map +1 -1
- package/dist/cjs/Sheet.cjs +88 -86
- package/dist/cjs/Sheet.native.js +88 -86
- package/dist/cjs/Sheet.native.js.map +1 -1
- package/dist/cjs/SheetContext.cjs +16 -14
- package/dist/cjs/SheetContext.native.js +16 -14
- package/dist/cjs/SheetContext.native.js.map +1 -1
- package/dist/cjs/SheetController.cjs +40 -32
- package/dist/cjs/SheetController.native.js +62 -54
- package/dist/cjs/SheetController.native.js.map +1 -1
- package/dist/cjs/SheetImplementationCustom.cjs +568 -429
- package/dist/cjs/SheetImplementationCustom.native.js +592 -474
- package/dist/cjs/SheetImplementationCustom.native.js.map +1 -1
- package/dist/cjs/SheetScrollView.cjs +184 -135
- package/dist/cjs/SheetScrollView.native.js +202 -163
- package/dist/cjs/SheetScrollView.native.js.map +1 -1
- package/dist/cjs/constants.cjs +16 -14
- package/dist/cjs/constants.native.js +16 -14
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/contexts.cjs +27 -25
- package/dist/cjs/contexts.native.js +29 -27
- package/dist/cjs/contexts.native.js.map +1 -1
- package/dist/cjs/controller.cjs +14 -12
- package/dist/cjs/controller.native.js +14 -12
- package/dist/cjs/controller.native.js.map +1 -1
- package/dist/cjs/createSheet.cjs +159 -160
- package/dist/cjs/createSheet.native.js +172 -180
- package/dist/cjs/createSheet.native.js.map +1 -1
- package/dist/cjs/gestureState.cjs +12 -10
- package/dist/cjs/gestureState.native.js +12 -10
- package/dist/cjs/gestureState.native.js.map +1 -1
- package/dist/cjs/helpers.cjs +17 -13
- package/dist/cjs/helpers.native.js +17 -13
- package/dist/cjs/helpers.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/keyboardAvoidance.cjs +42 -0
- package/dist/cjs/keyboardAvoidance.native.js +46 -0
- package/dist/cjs/keyboardAvoidance.native.js.map +1 -0
- package/dist/cjs/nativeSheet.cjs +65 -55
- package/dist/cjs/nativeSheet.native.js +74 -68
- package/dist/cjs/nativeSheet.native.js.map +1 -1
- package/dist/cjs/setupGestureHandler.cjs +24 -18
- package/dist/cjs/setupGestureHandler.native.js +24 -19
- package/dist/cjs/setupGestureHandler.native.js.map +1 -1
- package/dist/cjs/types.cjs +7 -5
- package/dist/cjs/types.native.js +7 -5
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/useGestureHandlerPan.cjs +181 -111
- package/dist/cjs/useGestureHandlerPan.native.js +183 -115
- package/dist/cjs/useGestureHandlerPan.native.js.map +1 -1
- package/dist/cjs/useKeyboardControllerSheet.cjs +15 -13
- package/dist/cjs/useKeyboardControllerSheet.native.js +100 -82
- package/dist/cjs/useKeyboardControllerSheet.native.js.map +1 -1
- package/dist/cjs/useSheet.cjs +12 -10
- package/dist/cjs/useSheet.native.js +16 -14
- package/dist/cjs/useSheet.native.js.map +1 -1
- package/dist/cjs/useSheetController.cjs +35 -33
- package/dist/cjs/useSheetController.native.js +37 -35
- package/dist/cjs/useSheetController.native.js.map +1 -1
- package/dist/cjs/useSheetOffscreenSize.cjs +35 -23
- package/dist/cjs/useSheetOffscreenSize.native.js +36 -27
- package/dist/cjs/useSheetOffscreenSize.native.js.map +1 -1
- package/dist/cjs/useSheetOpenState.cjs +28 -25
- package/dist/cjs/useSheetOpenState.native.js +39 -37
- package/dist/cjs/useSheetOpenState.native.js.map +1 -1
- package/dist/cjs/useSheetProviderProps.cjs +129 -81
- package/dist/cjs/useSheetProviderProps.native.js +165 -122
- package/dist/cjs/useSheetProviderProps.native.js.map +1 -1
- package/dist/cjs/useSheetScrollViewGestures.cjs +124 -81
- package/dist/cjs/useSheetScrollViewGestures.native.js +128 -79
- package/dist/cjs/useSheetScrollViewGestures.native.js.map +1 -1
- package/dist/esm/GestureDetectorWrapper.mjs +12 -8
- package/dist/esm/GestureDetectorWrapper.mjs.map +1 -1
- package/dist/esm/GestureDetectorWrapper.native.js +18 -15
- package/dist/esm/GestureDetectorWrapper.native.js.map +1 -1
- package/dist/esm/GestureSheetContext.native.js +14 -14
- package/dist/esm/GestureSheetContext.native.js.map +1 -1
- package/dist/esm/Sheet.mjs +70 -70
- package/dist/esm/Sheet.mjs.map +1 -1
- package/dist/esm/Sheet.native.js +70 -70
- package/dist/esm/Sheet.native.js.map +1 -1
- package/dist/esm/SheetContext.mjs +2 -2
- package/dist/esm/SheetContext.mjs.map +1 -1
- package/dist/esm/SheetContext.native.js +2 -2
- package/dist/esm/SheetContext.native.js.map +1 -1
- package/dist/esm/SheetController.mjs +12 -6
- package/dist/esm/SheetController.mjs.map +1 -1
- package/dist/esm/SheetController.native.js +18 -12
- package/dist/esm/SheetController.native.js.map +1 -1
- package/dist/esm/SheetImplementationCustom.mjs +526 -389
- package/dist/esm/SheetImplementationCustom.mjs.map +1 -1
- package/dist/esm/SheetImplementationCustom.native.js +546 -434
- package/dist/esm/SheetImplementationCustom.native.js.map +1 -1
- package/dist/esm/SheetScrollView.mjs +150 -103
- package/dist/esm/SheetScrollView.mjs.map +1 -1
- package/dist/esm/SheetScrollView.native.js +169 -132
- package/dist/esm/SheetScrollView.native.js.map +1 -1
- package/dist/esm/constants.mjs +4 -4
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +4 -4
- package/dist/esm/constants.native.js.map +1 -1
- package/dist/esm/contexts.mjs +3 -3
- package/dist/esm/contexts.mjs.map +1 -1
- package/dist/esm/contexts.native.js +3 -3
- package/dist/esm/contexts.native.js.map +1 -1
- package/dist/esm/createSheet.mjs +130 -133
- package/dist/esm/createSheet.mjs.map +1 -1
- package/dist/esm/createSheet.native.js +142 -152
- package/dist/esm/createSheet.native.js.map +1 -1
- package/dist/esm/helpers.mjs +5 -3
- package/dist/esm/helpers.mjs.map +1 -1
- package/dist/esm/helpers.native.js +5 -3
- package/dist/esm/helpers.native.js.map +1 -1
- package/dist/esm/index.js +11 -11
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/keyboardAvoidance.mjs +17 -0
- package/dist/esm/keyboardAvoidance.mjs.map +1 -0
- package/dist/esm/keyboardAvoidance.native.js +18 -0
- package/dist/esm/keyboardAvoidance.native.js.map +1 -0
- package/dist/esm/nativeSheet.mjs +46 -38
- package/dist/esm/nativeSheet.mjs.map +1 -1
- package/dist/esm/nativeSheet.native.js +52 -48
- package/dist/esm/nativeSheet.native.js.map +1 -1
- package/dist/esm/setupGestureHandler.mjs +12 -8
- package/dist/esm/setupGestureHandler.mjs.map +1 -1
- package/dist/esm/setupGestureHandler.native.js +12 -9
- package/dist/esm/setupGestureHandler.native.js.map +1 -1
- package/dist/esm/useGestureHandlerPan.mjs +167 -99
- package/dist/esm/useGestureHandlerPan.mjs.map +1 -1
- package/dist/esm/useGestureHandlerPan.native.js +168 -102
- package/dist/esm/useGestureHandlerPan.native.js.map +1 -1
- package/dist/esm/useKeyboardControllerSheet.mjs +3 -3
- package/dist/esm/useKeyboardControllerSheet.mjs.map +1 -1
- package/dist/esm/useKeyboardControllerSheet.native.js +85 -69
- package/dist/esm/useKeyboardControllerSheet.native.js.map +1 -1
- package/dist/esm/useSheetController.mjs +11 -11
- package/dist/esm/useSheetController.mjs.map +1 -1
- package/dist/esm/useSheetController.native.js +11 -11
- package/dist/esm/useSheetController.native.js.map +1 -1
- package/dist/esm/useSheetOffscreenSize.mjs +23 -13
- package/dist/esm/useSheetOffscreenSize.mjs.map +1 -1
- package/dist/esm/useSheetOffscreenSize.native.js +24 -17
- package/dist/esm/useSheetOffscreenSize.native.js.map +1 -1
- package/dist/esm/useSheetOpenState.mjs +14 -13
- package/dist/esm/useSheetOpenState.mjs.map +1 -1
- package/dist/esm/useSheetOpenState.native.js +17 -17
- package/dist/esm/useSheetOpenState.native.js.map +1 -1
- package/dist/esm/useSheetProviderProps.mjs +101 -55
- package/dist/esm/useSheetProviderProps.mjs.map +1 -1
- package/dist/esm/useSheetProviderProps.native.js +137 -96
- package/dist/esm/useSheetProviderProps.native.js.map +1 -1
- package/dist/esm/useSheetScrollViewGestures.mjs +112 -71
- package/dist/esm/useSheetScrollViewGestures.mjs.map +1 -1
- package/dist/esm/useSheetScrollViewGestures.native.js +116 -69
- package/dist/esm/useSheetScrollViewGestures.native.js.map +1 -1
- package/dist/jsx/GestureDetectorWrapper.mjs +12 -8
- package/dist/jsx/GestureDetectorWrapper.mjs.map +1 -1
- package/dist/jsx/GestureDetectorWrapper.native.js +33 -28
- package/dist/jsx/GestureDetectorWrapper.native.js.map +1 -1
- package/dist/jsx/GestureSheetContext.native.js +29 -27
- package/dist/jsx/GestureSheetContext.native.js.map +1 -1
- package/dist/jsx/Sheet.mjs +70 -70
- package/dist/jsx/Sheet.mjs.map +1 -1
- package/dist/jsx/Sheet.native.js +88 -86
- package/dist/jsx/Sheet.native.js.map +1 -1
- package/dist/jsx/SheetContext.mjs +2 -2
- package/dist/jsx/SheetContext.mjs.map +1 -1
- package/dist/jsx/SheetContext.native.js +16 -14
- package/dist/jsx/SheetContext.native.js.map +1 -1
- package/dist/jsx/SheetController.mjs +12 -6
- package/dist/jsx/SheetController.mjs.map +1 -1
- package/dist/jsx/SheetController.native.js +62 -54
- package/dist/jsx/SheetController.native.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.mjs +526 -389
- package/dist/jsx/SheetImplementationCustom.mjs.map +1 -1
- package/dist/jsx/SheetImplementationCustom.native.js +592 -474
- package/dist/jsx/SheetImplementationCustom.native.js.map +1 -1
- package/dist/jsx/SheetScrollView.mjs +150 -103
- package/dist/jsx/SheetScrollView.mjs.map +1 -1
- package/dist/jsx/SheetScrollView.native.js +202 -163
- package/dist/jsx/SheetScrollView.native.js.map +1 -1
- package/dist/jsx/constants.mjs +4 -4
- package/dist/jsx/constants.mjs.map +1 -1
- package/dist/jsx/constants.native.js +16 -14
- package/dist/jsx/constants.native.js.map +1 -1
- package/dist/jsx/contexts.mjs +3 -3
- package/dist/jsx/contexts.mjs.map +1 -1
- package/dist/jsx/contexts.native.js +29 -27
- package/dist/jsx/contexts.native.js.map +1 -1
- package/dist/jsx/controller.native.js +14 -12
- package/dist/jsx/createSheet.mjs +130 -133
- package/dist/jsx/createSheet.mjs.map +1 -1
- package/dist/jsx/createSheet.native.js +172 -180
- package/dist/jsx/createSheet.native.js.map +1 -1
- package/dist/jsx/gestureState.native.js +12 -10
- package/dist/jsx/gestureState.native.js.map +1 -1
- package/dist/jsx/helpers.mjs +5 -3
- package/dist/jsx/helpers.mjs.map +1 -1
- package/dist/jsx/helpers.native.js +17 -13
- package/dist/jsx/helpers.native.js.map +1 -1
- package/dist/jsx/index.js +11 -11
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/keyboardAvoidance.mjs +17 -0
- package/dist/jsx/keyboardAvoidance.mjs.map +1 -0
- package/dist/jsx/keyboardAvoidance.native.js +46 -0
- package/dist/jsx/keyboardAvoidance.native.js.map +1 -0
- package/dist/jsx/nativeSheet.mjs +46 -38
- package/dist/jsx/nativeSheet.mjs.map +1 -1
- package/dist/jsx/nativeSheet.native.js +74 -68
- package/dist/jsx/nativeSheet.native.js.map +1 -1
- package/dist/jsx/setupGestureHandler.mjs +12 -8
- package/dist/jsx/setupGestureHandler.mjs.map +1 -1
- package/dist/jsx/setupGestureHandler.native.js +24 -19
- package/dist/jsx/setupGestureHandler.native.js.map +1 -1
- package/dist/jsx/types.native.js +7 -5
- package/dist/jsx/useGestureHandlerPan.mjs +167 -99
- package/dist/jsx/useGestureHandlerPan.mjs.map +1 -1
- package/dist/jsx/useGestureHandlerPan.native.js +183 -115
- package/dist/jsx/useGestureHandlerPan.native.js.map +1 -1
- package/dist/jsx/useKeyboardControllerSheet.mjs +3 -3
- package/dist/jsx/useKeyboardControllerSheet.mjs.map +1 -1
- package/dist/jsx/useKeyboardControllerSheet.native.js +100 -82
- package/dist/jsx/useKeyboardControllerSheet.native.js.map +1 -1
- package/dist/jsx/useSheet.native.js +16 -14
- package/dist/jsx/useSheetController.mjs +11 -11
- package/dist/jsx/useSheetController.mjs.map +1 -1
- package/dist/jsx/useSheetController.native.js +37 -35
- package/dist/jsx/useSheetController.native.js.map +1 -1
- package/dist/jsx/useSheetOffscreenSize.mjs +23 -13
- package/dist/jsx/useSheetOffscreenSize.mjs.map +1 -1
- package/dist/jsx/useSheetOffscreenSize.native.js +36 -27
- package/dist/jsx/useSheetOffscreenSize.native.js.map +1 -1
- package/dist/jsx/useSheetOpenState.mjs +14 -13
- package/dist/jsx/useSheetOpenState.mjs.map +1 -1
- package/dist/jsx/useSheetOpenState.native.js +39 -37
- package/dist/jsx/useSheetOpenState.native.js.map +1 -1
- package/dist/jsx/useSheetProviderProps.mjs +101 -55
- package/dist/jsx/useSheetProviderProps.mjs.map +1 -1
- package/dist/jsx/useSheetProviderProps.native.js +165 -122
- package/dist/jsx/useSheetProviderProps.native.js.map +1 -1
- package/dist/jsx/useSheetScrollViewGestures.mjs +112 -71
- package/dist/jsx/useSheetScrollViewGestures.mjs.map +1 -1
- package/dist/jsx/useSheetScrollViewGestures.native.js +128 -79
- package/dist/jsx/useSheetScrollViewGestures.native.js.map +1 -1
- package/next.md +78 -0
- package/package.json +32 -54
- package/setup-gesture-handler/index.cjs +2 -0
- package/setup-gesture-handler/index.js +2 -0
- package/setup-gesture-handler/index.native.cjs +2 -0
- package/setup-gesture-handler/index.native.js +2 -0
- package/setup-gesture-handler.cjs +1 -0
- package/src/GestureDetectorWrapper.tsx +0 -3
- package/src/SheetController.tsx +4 -1
- package/src/SheetImplementationCustom.tsx +131 -45
- package/src/SheetScrollView.tsx +33 -7
- package/src/keyboardAvoidance.ts +30 -0
- package/src/nativeSheet.tsx +6 -1
- package/src/types.tsx +5 -0
- package/src/useGestureHandlerPan.tsx +5 -15
- package/src/useSheetController.tsx +4 -0
- package/src/useSheetProviderProps.tsx +1 -0
- package/test/keyboardAvoidance.test.ts +53 -0
- package/tsconfig.json +57 -0
- package/types/GestureDetectorWrapper.d.ts.map +1 -1
- package/types/Sheet.d.ts +3 -0
- package/types/Sheet.d.ts.map +1 -1
- package/types/SheetContext.d.ts +1 -0
- package/types/SheetContext.d.ts.map +1 -1
- package/types/SheetController.d.ts +1 -1
- package/types/SheetController.d.ts.map +1 -1
- package/types/SheetImplementationCustom.d.ts +3 -0
- package/types/SheetImplementationCustom.d.ts.map +1 -1
- package/types/SheetScrollView.d.ts.map +1 -1
- package/types/createSheet.d.ts +3 -0
- package/types/createSheet.d.ts.map +1 -1
- package/types/keyboardAvoidance.d.ts +8 -0
- package/types/keyboardAvoidance.d.ts.map +1 -0
- package/types/nativeSheet.d.ts.map +1 -1
- package/types/types.d.ts +6 -0
- package/types/types.d.ts.map +1 -1
- package/types/useGestureHandlerPan.d.ts.map +1 -1
- package/types/useSheetController.d.ts +3 -0
- package/types/useSheetController.d.ts.map +1 -1
- package/types/useSheetProviderProps.d.ts +1 -0
- package/types/useSheetProviderProps.d.ts.map +1 -1
- package/dist/cjs/GestureDetectorWrapper.js +0 -29
- package/dist/cjs/GestureDetectorWrapper.js.map +0 -6
- package/dist/cjs/GestureSheetContext.js +0 -43
- package/dist/cjs/GestureSheetContext.js.map +0 -6
- package/dist/cjs/Sheet.js +0 -104
- package/dist/cjs/Sheet.js.map +0 -6
- package/dist/cjs/SheetContext.js +0 -28
- package/dist/cjs/SheetContext.js.map +0 -6
- package/dist/cjs/SheetController.js +0 -52
- package/dist/cjs/SheetController.js.map +0 -6
- package/dist/cjs/SheetImplementationCustom.js +0 -393
- package/dist/cjs/SheetImplementationCustom.js.map +0 -6
- package/dist/cjs/SheetScrollView.js +0 -137
- package/dist/cjs/SheetScrollView.js.map +0 -6
- package/dist/cjs/constants.js +0 -24
- package/dist/cjs/constants.js.map +0 -6
- package/dist/cjs/contexts.js +0 -33
- package/dist/cjs/contexts.js.map +0 -6
- package/dist/cjs/controller.js +0 -23
- package/dist/cjs/controller.js.map +0 -6
- package/dist/cjs/createSheet.js +0 -152
- package/dist/cjs/createSheet.js.map +0 -6
- package/dist/cjs/gestureState.js +0 -34
- package/dist/cjs/gestureState.js.map +0 -6
- package/dist/cjs/helpers.js +0 -26
- package/dist/cjs/helpers.js.map +0 -6
- package/dist/cjs/index.js +0 -25
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/nativeSheet.js +0 -56
- package/dist/cjs/nativeSheet.js.map +0 -6
- package/dist/cjs/setupGestureHandler.js +0 -38
- package/dist/cjs/setupGestureHandler.js.map +0 -6
- package/dist/cjs/types.js +0 -14
- package/dist/cjs/types.js.map +0 -6
- package/dist/cjs/useGestureHandlerPan.js +0 -126
- package/dist/cjs/useGestureHandlerPan.js.map +0 -6
- package/dist/cjs/useKeyboardControllerSheet.js +0 -34
- package/dist/cjs/useKeyboardControllerSheet.js.map +0 -6
- package/dist/cjs/useSheet.js +0 -22
- package/dist/cjs/useSheet.js.map +0 -6
- package/dist/cjs/useSheetController.js +0 -39
- package/dist/cjs/useSheetController.js.map +0 -6
- package/dist/cjs/useSheetOffscreenSize.js +0 -43
- package/dist/cjs/useSheetOffscreenSize.js.map +0 -6
- package/dist/cjs/useSheetOpenState.js +0 -37
- package/dist/cjs/useSheetOpenState.js.map +0 -6
- package/dist/cjs/useSheetProviderProps.js +0 -130
- package/dist/cjs/useSheetProviderProps.js.map +0 -6
- package/dist/cjs/useSheetScrollViewGestures.js +0 -102
- package/dist/cjs/useSheetScrollViewGestures.js.map +0 -6
- package/dist/esm/GestureDetectorWrapper.js +0 -15
- package/dist/esm/GestureDetectorWrapper.js.map +0 -6
- package/dist/esm/GestureSheetContext.js +0 -28
- package/dist/esm/GestureSheetContext.js.map +0 -6
- package/dist/esm/Sheet.js +0 -92
- package/dist/esm/Sheet.js.map +0 -6
- package/dist/esm/SheetContext.js +0 -13
- package/dist/esm/SheetContext.js.map +0 -6
- package/dist/esm/SheetController.js +0 -31
- package/dist/esm/SheetController.js.map +0 -6
- package/dist/esm/SheetImplementationCustom.js +0 -395
- package/dist/esm/SheetImplementationCustom.js.map +0 -6
- package/dist/esm/SheetScrollView.js +0 -122
- package/dist/esm/SheetScrollView.js.map +0 -6
- package/dist/esm/constants.js +0 -8
- package/dist/esm/constants.js.map +0 -6
- package/dist/esm/contexts.js +0 -9
- package/dist/esm/contexts.js.map +0 -6
- package/dist/esm/controller.js +0 -11
- package/dist/esm/controller.js.map +0 -6
- package/dist/esm/createSheet.js +0 -153
- package/dist/esm/createSheet.js.map +0 -6
- package/dist/esm/gestureState.js +0 -18
- package/dist/esm/gestureState.js.map +0 -6
- package/dist/esm/helpers.js +0 -10
- package/dist/esm/helpers.js.map +0 -6
- package/dist/esm/nativeSheet.js +0 -46
- package/dist/esm/nativeSheet.js.map +0 -6
- package/dist/esm/setupGestureHandler.js +0 -22
- package/dist/esm/setupGestureHandler.js.map +0 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -6
- package/dist/esm/useGestureHandlerPan.js +0 -111
- package/dist/esm/useGestureHandlerPan.js.map +0 -6
- package/dist/esm/useKeyboardControllerSheet.js +0 -18
- package/dist/esm/useKeyboardControllerSheet.js.map +0 -6
- package/dist/esm/useSheet.js +0 -6
- package/dist/esm/useSheet.js.map +0 -6
- package/dist/esm/useSheetController.js +0 -15
- package/dist/esm/useSheetController.js.map +0 -6
- package/dist/esm/useSheetOffscreenSize.js +0 -27
- package/dist/esm/useSheetOffscreenSize.js.map +0 -6
- package/dist/esm/useSheetOpenState.js +0 -22
- package/dist/esm/useSheetOpenState.js.map +0 -6
- package/dist/esm/useSheetProviderProps.js +0 -109
- package/dist/esm/useSheetProviderProps.js.map +0 -6
- package/dist/esm/useSheetScrollViewGestures.js +0 -86
- package/dist/esm/useSheetScrollViewGestures.js.map +0 -6
- package/dist/jsx/GestureDetectorWrapper.js +0 -15
- package/dist/jsx/GestureDetectorWrapper.js.map +0 -6
- package/dist/jsx/GestureSheetContext.js +0 -28
- package/dist/jsx/GestureSheetContext.js.map +0 -6
- package/dist/jsx/Sheet.js +0 -92
- package/dist/jsx/Sheet.js.map +0 -6
- package/dist/jsx/SheetContext.js +0 -13
- package/dist/jsx/SheetContext.js.map +0 -6
- package/dist/jsx/SheetController.js +0 -31
- package/dist/jsx/SheetController.js.map +0 -6
- package/dist/jsx/SheetImplementationCustom.js +0 -395
- package/dist/jsx/SheetImplementationCustom.js.map +0 -6
- package/dist/jsx/SheetScrollView.js +0 -122
- package/dist/jsx/SheetScrollView.js.map +0 -6
- package/dist/jsx/constants.js +0 -8
- package/dist/jsx/constants.js.map +0 -6
- package/dist/jsx/contexts.js +0 -9
- package/dist/jsx/contexts.js.map +0 -6
- package/dist/jsx/controller.js +0 -11
- package/dist/jsx/controller.js.map +0 -6
- package/dist/jsx/createSheet.js +0 -153
- package/dist/jsx/createSheet.js.map +0 -6
- package/dist/jsx/gestureState.js +0 -18
- package/dist/jsx/gestureState.js.map +0 -6
- package/dist/jsx/helpers.js +0 -10
- package/dist/jsx/helpers.js.map +0 -6
- package/dist/jsx/nativeSheet.js +0 -46
- package/dist/jsx/nativeSheet.js.map +0 -6
- package/dist/jsx/setupGestureHandler.js +0 -22
- package/dist/jsx/setupGestureHandler.js.map +0 -6
- package/dist/jsx/types.js +0 -1
- package/dist/jsx/types.js.map +0 -6
- package/dist/jsx/useGestureHandlerPan.js +0 -111
- package/dist/jsx/useGestureHandlerPan.js.map +0 -6
- package/dist/jsx/useKeyboardControllerSheet.js +0 -18
- package/dist/jsx/useKeyboardControllerSheet.js.map +0 -6
- package/dist/jsx/useSheet.js +0 -6
- package/dist/jsx/useSheet.js.map +0 -6
- package/dist/jsx/useSheetController.js +0 -15
- package/dist/jsx/useSheetController.js.map +0 -6
- package/dist/jsx/useSheetOffscreenSize.js +0 -27
- package/dist/jsx/useSheetOffscreenSize.js.map +0 -6
- package/dist/jsx/useSheetOpenState.js +0 -22
- package/dist/jsx/useSheetOpenState.js.map +0 -6
- package/dist/jsx/useSheetProviderProps.js +0 -109
- package/dist/jsx/useSheetProviderProps.js.map +0 -6
- package/dist/jsx/useSheetScrollViewGestures.js +0 -86
- package/dist/jsx/useSheetScrollViewGestures.js.map +0 -6
- package/types/GestureDetectorWrapper.native.d.ts +0 -14
- package/types/gestureState.native.d.ts +0 -12
- package/types/setupGestureHandler.native.d.ts +0 -41
- package/types/useGestureHandlerPan.native.d.ts +0 -33
- package/types/useSheetScrollViewGestures.web.d.ts +0 -15
- package/types/useSheetScrollViewGestures.web.d.ts.map +0 -1
|
@@ -5,7 +5,6 @@ import { isWeb, useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
|
5
5
|
import {
|
|
6
6
|
LayoutMeasurementController,
|
|
7
7
|
View as TamaguiView,
|
|
8
|
-
Theme,
|
|
9
8
|
useConfiguration,
|
|
10
9
|
useDidFinishSSR,
|
|
11
10
|
useEvent,
|
|
@@ -23,8 +22,10 @@ import type {
|
|
|
23
22
|
import { Dimensions, PanResponder, View } from 'react-native'
|
|
24
23
|
import { ParentSheetContext, SheetInsideSheetContext } from './contexts'
|
|
25
24
|
import { GestureDetectorWrapper } from './GestureDetectorWrapper'
|
|
25
|
+
import { getGestureHandlerState } from './gestureState'
|
|
26
26
|
import { GestureSheetProvider } from './GestureSheetContext'
|
|
27
27
|
import { resisted } from './helpers'
|
|
28
|
+
import { getKeyboardOccludedHeight } from './keyboardAvoidance'
|
|
28
29
|
import { SheetProvider } from './SheetContext'
|
|
29
30
|
import type { SheetProps, SnapPointsMode } from './types'
|
|
30
31
|
import { useGestureHandlerPan } from './useGestureHandlerPan'
|
|
@@ -34,6 +35,14 @@ import { useSheetProviderProps } from './useSheetProviderProps'
|
|
|
34
35
|
|
|
35
36
|
const hiddenSize = 10_000.1
|
|
36
37
|
|
|
38
|
+
// the re-established rngh root for a modal sheet (see modal branch below).
|
|
39
|
+
// GestureHandlerRootView does its own native touch interception and ignores
|
|
40
|
+
// pointerEvents, so it would block the whole app while the sheet sits closed
|
|
41
|
+
// but mounted. instead it stays full-width for correct child layout/measurement
|
|
42
|
+
// and collapses to 0 height when closed so it has no hit area.
|
|
43
|
+
const rnghRootStyleOpen = { width: '100%', height: '100%' } as const
|
|
44
|
+
const rnghRootStyleClosed = { width: '100%', height: 0 } as const
|
|
45
|
+
|
|
37
46
|
// safe area top inset, cached per-session (device-constant value)
|
|
38
47
|
let _cachedSafeAreaTop: number | undefined
|
|
39
48
|
function getSafeAreaTopInset(): number {
|
|
@@ -61,6 +70,7 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
61
70
|
unmountChildrenWhenHidden = false,
|
|
62
71
|
portalProps,
|
|
63
72
|
containerComponent: ContainerComponent = React.Fragment,
|
|
73
|
+
onAnimationComplete,
|
|
64
74
|
} = props
|
|
65
75
|
|
|
66
76
|
const state = useSheetOpenState(props)
|
|
@@ -83,6 +93,8 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
83
93
|
maxSnapPoint,
|
|
84
94
|
} = providerProps
|
|
85
95
|
const { open, controller, isHidden } = state
|
|
96
|
+
const openRef = React.useRef(open)
|
|
97
|
+
openRef.current = open
|
|
86
98
|
|
|
87
99
|
const sheetRef = React.useRef<View>(undefined as unknown as View)
|
|
88
100
|
const ref = useComposedRefs(forwardedRef, sheetRef, providerProps.contentRef as any)
|
|
@@ -220,6 +232,14 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
220
232
|
return result
|
|
221
233
|
}, [positions, isKeyboardVisible, keyboardHeight, screenSize, isDragging])
|
|
222
234
|
|
|
235
|
+
const keyboardOccludedHeight = getKeyboardOccludedHeight({
|
|
236
|
+
frameSize,
|
|
237
|
+
isKeyboardVisible: !isWeb && isKeyboardVisible,
|
|
238
|
+
keyboardHeight,
|
|
239
|
+
screenSize,
|
|
240
|
+
sheetY: position >= 0 ? activePositions[position] : undefined,
|
|
241
|
+
})
|
|
242
|
+
|
|
223
243
|
const { useAnimatedNumber, useAnimatedNumberStyle, useAnimatedNumberReaction } =
|
|
224
244
|
animationDriver
|
|
225
245
|
const AnimatedView = (animationDriver.View ?? TamaguiView) as typeof Animated.View
|
|
@@ -254,6 +274,9 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
254
274
|
|
|
255
275
|
const hasScrollView = React.useRef(false)
|
|
256
276
|
|
|
277
|
+
// safety fallback timer for sheet close opacity
|
|
278
|
+
const opacityFallbackTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
279
|
+
|
|
257
280
|
useAnimatedNumberReaction(
|
|
258
281
|
{
|
|
259
282
|
value: animatedNumber,
|
|
@@ -273,6 +296,12 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
273
296
|
// when reaching top, enable scroll; when leaving top, disable scroll
|
|
274
297
|
// this preemptively sets scroll state before any gestures start
|
|
275
298
|
if (nowAtTop) {
|
|
299
|
+
// if scroll drifted during drag (e.g. fast swipe from position 1),
|
|
300
|
+
// reset it to 0 before enabling free scroll
|
|
301
|
+
if (scrollBridge.y > 0) {
|
|
302
|
+
scrollBridge.forceScrollTo?.(0)
|
|
303
|
+
scrollBridge.y = 0
|
|
304
|
+
}
|
|
276
305
|
scrollBridge.scrollLockY = undefined
|
|
277
306
|
scrollBridge.setScrollEnabled?.(true)
|
|
278
307
|
} else {
|
|
@@ -303,10 +332,50 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
303
332
|
at.current = toValue
|
|
304
333
|
stopSpring()
|
|
305
334
|
|
|
335
|
+
const isOpenAnimation = position !== -1 && !isHidden
|
|
336
|
+
|
|
337
|
+
// clear any pending fallback timer
|
|
338
|
+
if (opacityFallbackTimer.current) {
|
|
339
|
+
clearTimeout(opacityFallbackTimer.current)
|
|
340
|
+
opacityFallbackTimer.current = null
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const animationCompleteCallback = () => {
|
|
344
|
+
if (opacityFallbackTimer.current) {
|
|
345
|
+
clearTimeout(opacityFallbackTimer.current)
|
|
346
|
+
opacityFallbackTimer.current = null
|
|
347
|
+
}
|
|
348
|
+
// use openRef (live) not open (stale closure) — if the sheet
|
|
349
|
+
// was reopened before this callback fires (e.g. cancelled close
|
|
350
|
+
// animation), we must not hide it
|
|
351
|
+
if (!isOpenAnimation && !openRef.current) {
|
|
352
|
+
setOpacity(0)
|
|
353
|
+
}
|
|
354
|
+
onAnimationComplete?.({ open: isOpenAnimation })
|
|
355
|
+
// also notify the SheetController so a parent (e.g. Dialog adapt)
|
|
356
|
+
// can hold the sheet's children mounted until the slide-out is done
|
|
357
|
+
controller?.onAnimationComplete?.({ open: isOpenAnimation })
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// safety fallback: if animation callback never fires, still hide the sheet
|
|
361
|
+
if (!isOpenAnimation) {
|
|
362
|
+
opacityFallbackTimer.current = setTimeout(() => {
|
|
363
|
+
opacityFallbackTimer.current = null
|
|
364
|
+
// check live open state via ref — sheet may have reopened (e.g. adapt handoff)
|
|
365
|
+
if (!openRef.current) {
|
|
366
|
+
setOpacity(0)
|
|
367
|
+
}
|
|
368
|
+
}, 1000)
|
|
369
|
+
}
|
|
370
|
+
|
|
306
371
|
// skip animation when adapting from dialog to sheet
|
|
307
372
|
if (skipAdaptAnimation.current) {
|
|
308
373
|
skipAdaptAnimation.current = false
|
|
309
|
-
animatedNumber.setValue(
|
|
374
|
+
animatedNumber.setValue(
|
|
375
|
+
toValue,
|
|
376
|
+
{ type: 'timing', duration: 0 },
|
|
377
|
+
animationCompleteCallback
|
|
378
|
+
)
|
|
310
379
|
return
|
|
311
380
|
}
|
|
312
381
|
|
|
@@ -315,7 +384,8 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
315
384
|
animationOverride || {
|
|
316
385
|
type: 'spring',
|
|
317
386
|
...transitionConfig,
|
|
318
|
-
}
|
|
387
|
+
},
|
|
388
|
+
animationCompleteCallback
|
|
319
389
|
)
|
|
320
390
|
})
|
|
321
391
|
|
|
@@ -601,24 +671,21 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
601
671
|
pauseKeyboardHandler,
|
|
602
672
|
})
|
|
603
673
|
|
|
604
|
-
const handleAnimationViewLayout =
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
}
|
|
674
|
+
const handleAnimationViewLayout = useEvent((e: LayoutChangeEvent) => {
|
|
675
|
+
// don't update frameSize during exit animation to prevent position jumps
|
|
676
|
+
if (!open && stableFrameSize.current !== 0) {
|
|
677
|
+
return
|
|
678
|
+
}
|
|
610
679
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
[open, modal]
|
|
621
|
-
)
|
|
680
|
+
// avoid bugs where it grows forever for whatever reason
|
|
681
|
+
// For inline mode (non-modal), don't cap at window height - use actual layout
|
|
682
|
+
const layoutHeight = e.nativeEvent?.layout.height
|
|
683
|
+
const next = modal
|
|
684
|
+
? Math.min(layoutHeight, Dimensions.get(relativeDimensionTo).height)
|
|
685
|
+
: layoutHeight
|
|
686
|
+
if (!next) return
|
|
687
|
+
setFrameSize(next)
|
|
688
|
+
})
|
|
622
689
|
|
|
623
690
|
const handleMaxContentViewLayout = React.useCallback((e: LayoutChangeEvent) => {
|
|
624
691
|
// avoid bugs where it grows forever for whatever reason
|
|
@@ -630,32 +697,31 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
630
697
|
setMaxContentSize(next)
|
|
631
698
|
}, [])
|
|
632
699
|
|
|
633
|
-
const
|
|
634
|
-
|
|
635
|
-
|
|
700
|
+
const getAnimatedNumberStyle = React.useCallback(
|
|
701
|
+
(val: number) => {
|
|
702
|
+
'worklet'
|
|
703
|
+
const translateY = frameSize === 0 ? hiddenSize : val
|
|
636
704
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
705
|
+
return {
|
|
706
|
+
transform: [{ translateY }],
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
[frameSize]
|
|
710
|
+
)
|
|
711
|
+
|
|
712
|
+
const animatedStyle = useAnimatedNumberStyle(animatedNumber, getAnimatedNumberStyle)
|
|
641
713
|
|
|
642
714
|
// we need to set this *after* fully closed to 0, to avoid it overlapping
|
|
643
715
|
// the page when resizing quickly on web for example
|
|
644
716
|
const [opacity, setOpacity] = React.useState(open ? 1 : 0)
|
|
645
717
|
if (open && opacity === 0) {
|
|
646
718
|
setOpacity(1)
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
const tm = setTimeout(() => {
|
|
652
|
-
setOpacity(0)
|
|
653
|
-
}, 400)
|
|
654
|
-
return () => {
|
|
655
|
-
clearTimeout(tm)
|
|
656
|
-
}
|
|
719
|
+
// cancel any pending close fallback — sheet is reopening
|
|
720
|
+
if (opacityFallbackTimer.current) {
|
|
721
|
+
clearTimeout(opacityFallbackTimer.current)
|
|
722
|
+
opacityFallbackTimer.current = null
|
|
657
723
|
}
|
|
658
|
-
}
|
|
724
|
+
}
|
|
659
725
|
|
|
660
726
|
const forcedContentHeight = hasFit
|
|
661
727
|
? undefined
|
|
@@ -676,7 +742,11 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
676
742
|
let contents = (
|
|
677
743
|
<LayoutMeasurementController disable={!open}>
|
|
678
744
|
<ParentSheetContext.Provider value={nextParentContext}>
|
|
679
|
-
<SheetProvider
|
|
745
|
+
<SheetProvider
|
|
746
|
+
{...providerProps}
|
|
747
|
+
keyboardOccludedHeight={keyboardOccludedHeight}
|
|
748
|
+
setHasScrollView={setHasScrollView}
|
|
749
|
+
>
|
|
680
750
|
<GestureSheetProvider
|
|
681
751
|
isDragging={isDragging}
|
|
682
752
|
blockPan={blockPan}
|
|
@@ -761,14 +831,30 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
761
831
|
const shouldMountChildren = unmountChildrenWhenHidden ? !!opacity : true
|
|
762
832
|
|
|
763
833
|
if (modal) {
|
|
834
|
+
// a modal sheet is teleported through <Portal> to the root portal host.
|
|
835
|
+
// that host is mounted by TamaguiProvider, which may sit ABOVE the app's
|
|
836
|
+
// GestureHandlerRootView - so the teleported content lands outside any
|
|
837
|
+
// rngh root and every gesture inside the sheet (the drag pan, pressables
|
|
838
|
+
// on the rngh press path) silently goes dead. re-establish an rngh root
|
|
839
|
+
// around the teleported content so it works regardless of where the app
|
|
840
|
+
// mounts GestureHandlerRootView.
|
|
841
|
+
//
|
|
842
|
+
// the root stays mounted and full-width whenever the sheet content is
|
|
843
|
+
// (so child layout/measurement/close-animation are unaffected) and only
|
|
844
|
+
// collapses to 0 height while closed so it occupies no hit area - see
|
|
845
|
+
// rnghRootStyleOpen/Closed above for why pointerEvents can't be used.
|
|
846
|
+
const RNGHRoot = getGestureHandlerState().RootView
|
|
847
|
+
const mountedContents = shouldMountChildren ? (
|
|
848
|
+
<ContainerComponent>{contents}</ContainerComponent>
|
|
849
|
+
) : null
|
|
764
850
|
const modalContents = (
|
|
765
851
|
<Portal stackZIndex={zIndex} {...portalProps}>
|
|
766
|
-
{
|
|
767
|
-
<
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
852
|
+
{mountedContents && RNGHRoot ? (
|
|
853
|
+
<RNGHRoot style={open ? rnghRootStyleOpen : rnghRootStyleClosed}>
|
|
854
|
+
{mountedContents}
|
|
855
|
+
</RNGHRoot>
|
|
856
|
+
) : (
|
|
857
|
+
mountedContents
|
|
772
858
|
)}
|
|
773
859
|
</Portal>
|
|
774
860
|
)
|
package/src/SheetScrollView.tsx
CHANGED
|
@@ -29,13 +29,36 @@ export const SheetScrollView = React.forwardRef<
|
|
|
29
29
|
) => {
|
|
30
30
|
const context = useSheetContext(SHEET_SCROLL_VIEW_NAME, __scopeSheet)
|
|
31
31
|
const gestureContext = useGestureSheetContext()
|
|
32
|
-
const { scrollBridge, setHasScrollView } = context
|
|
32
|
+
const { scrollBridge, setHasScrollView, hasFit, screenSize } = context
|
|
33
|
+
const keyboardOccludedHeight = Math.max(0, context.keyboardOccludedHeight || 0)
|
|
33
34
|
const [scrollEnabled] = useControllableState({
|
|
34
35
|
prop: scrollEnabledProp,
|
|
35
36
|
defaultProp: true,
|
|
36
37
|
})
|
|
37
38
|
const scrollRef = React.useRef<RNScrollView | null>(null)
|
|
38
39
|
|
|
40
|
+
const [hasScrollableContent, setHasScrollableContent] = useState(true)
|
|
41
|
+
const parentHeight = useRef(0)
|
|
42
|
+
const contentHeight = useRef(0)
|
|
43
|
+
|
|
44
|
+
// with snapPointsMode="fit", Frame is content-sized (flex: 0, flex-basis: auto, height: undefined).
|
|
45
|
+
// a flex: 1 child can't grow inside a content-sized parent, so the ScrollView (and the Frame
|
|
46
|
+
// around it) collapse to 0 height. instead, let the ScrollView size to its content and cap it
|
|
47
|
+
// at the available viewport (screenSize / maxContentSize) so scrolling kicks in for tall content.
|
|
48
|
+
// when the keyboard forces the sheet against the top safe area, preserve the measured viewport
|
|
49
|
+
// height while adding scrollable tail padding so content can move above the keyboard.
|
|
50
|
+
const keyboardFrozenHeight =
|
|
51
|
+
hasFit && keyboardOccludedHeight > 0 && parentHeight.current
|
|
52
|
+
? parentHeight.current
|
|
53
|
+
: undefined
|
|
54
|
+
const fitSizingStyle = hasFit
|
|
55
|
+
? {
|
|
56
|
+
flex: undefined as undefined,
|
|
57
|
+
height: keyboardFrozenHeight,
|
|
58
|
+
maxHeight: screenSize || undefined,
|
|
59
|
+
}
|
|
60
|
+
: { flex: 1 }
|
|
61
|
+
|
|
39
62
|
const panGestureRef = gestureContext?.panGestureRef
|
|
40
63
|
const { ScrollView: RNGHScrollView } = getGestureHandlerState()
|
|
41
64
|
const useRNGHScrollView = isGestureHandlerEnabled() && RNGHScrollView && panGestureRef
|
|
@@ -73,10 +96,6 @@ export const SheetScrollView = React.forwardRef<
|
|
|
73
96
|
}
|
|
74
97
|
}, [])
|
|
75
98
|
|
|
76
|
-
const [hasScrollableContent, setHasScrollableContent] = useState(true)
|
|
77
|
-
const parentHeight = useRef(0)
|
|
78
|
-
const contentHeight = useRef(0)
|
|
79
|
-
|
|
80
99
|
const updateScrollable = () => {
|
|
81
100
|
if (parentHeight.current && contentHeight.current) {
|
|
82
101
|
setHasScrollableContent(contentHeight.current > parentHeight.current)
|
|
@@ -108,6 +127,13 @@ export const SheetScrollView = React.forwardRef<
|
|
|
108
127
|
}}
|
|
109
128
|
>
|
|
110
129
|
{children}
|
|
130
|
+
{keyboardOccludedHeight > 0 && (
|
|
131
|
+
<View
|
|
132
|
+
data-sheet-keyboard-scroll-pad
|
|
133
|
+
height={keyboardOccludedHeight}
|
|
134
|
+
width="100%"
|
|
135
|
+
/>
|
|
136
|
+
)}
|
|
111
137
|
</View>
|
|
112
138
|
)
|
|
113
139
|
|
|
@@ -117,7 +143,7 @@ export const SheetScrollView = React.forwardRef<
|
|
|
117
143
|
return (
|
|
118
144
|
<RNGHComponent
|
|
119
145
|
ref={composeRefs(scrollRef as any, ref)}
|
|
120
|
-
style={
|
|
146
|
+
style={fitSizingStyle}
|
|
121
147
|
scrollEventThrottle={1}
|
|
122
148
|
scrollEnabled={scrollEnabled}
|
|
123
149
|
simultaneousHandlers={[panGestureRef]}
|
|
@@ -174,7 +200,7 @@ export const SheetScrollView = React.forwardRef<
|
|
|
174
200
|
updateScrollable()
|
|
175
201
|
}}
|
|
176
202
|
ref={composeRefs(scrollRef as any, ref)}
|
|
177
|
-
|
|
203
|
+
{...fitSizingStyle}
|
|
178
204
|
scrollEventThrottle={1}
|
|
179
205
|
className="_ovs-contain"
|
|
180
206
|
scrollEnabled={scrollEnabled}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function getKeyboardOccludedHeight({
|
|
2
|
+
frameSize,
|
|
3
|
+
isKeyboardVisible,
|
|
4
|
+
keyboardHeight,
|
|
5
|
+
screenSize,
|
|
6
|
+
sheetY,
|
|
7
|
+
}: {
|
|
8
|
+
frameSize: number
|
|
9
|
+
isKeyboardVisible: boolean
|
|
10
|
+
keyboardHeight: number
|
|
11
|
+
screenSize: number
|
|
12
|
+
sheetY: number | undefined
|
|
13
|
+
}) {
|
|
14
|
+
if (
|
|
15
|
+
!isKeyboardVisible ||
|
|
16
|
+
keyboardHeight <= 0 ||
|
|
17
|
+
screenSize <= 0 ||
|
|
18
|
+
frameSize <= 0 ||
|
|
19
|
+
sheetY === undefined ||
|
|
20
|
+
sheetY >= screenSize
|
|
21
|
+
) {
|
|
22
|
+
return 0
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const keyboardTop = screenSize - keyboardHeight
|
|
26
|
+
const sheetBottom = sheetY + frameSize
|
|
27
|
+
const occludedHeight = Math.ceil(sheetBottom - keyboardTop)
|
|
28
|
+
|
|
29
|
+
return Math.min(frameSize, Math.max(0, occludedHeight))
|
|
30
|
+
}
|
package/src/nativeSheet.tsx
CHANGED
|
@@ -59,7 +59,12 @@ export function setupNativeSheet(
|
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
61
|
<>
|
|
62
|
-
<SheetProvider
|
|
62
|
+
<SheetProvider
|
|
63
|
+
setHasScrollView={emptyFn}
|
|
64
|
+
keyboardOccludedHeight={0}
|
|
65
|
+
{...providerProps}
|
|
66
|
+
onlyShowFrame
|
|
67
|
+
>
|
|
63
68
|
<ModalSheetView ref={ref} onModalDidDismiss={() => setOpenInternal(false)}>
|
|
64
69
|
<ModalSheetViewMainContent>
|
|
65
70
|
<View style={{ flex: 1 }}>{props.children}</View>
|
package/src/types.tsx
CHANGED
|
@@ -79,6 +79,11 @@ export type SheetProps = ScopedProps<
|
|
|
79
79
|
*/
|
|
80
80
|
moveOnKeyboardChange?: boolean
|
|
81
81
|
containerComponent?: React.ComponentType<any>
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Called when the sheet open/close animation completes.
|
|
85
|
+
*/
|
|
86
|
+
onAnimationComplete?: (info: { open: boolean }) => void
|
|
82
87
|
},
|
|
83
88
|
'Sheet'
|
|
84
89
|
>
|
|
@@ -122,7 +122,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
|
|
|
122
122
|
|
|
123
123
|
// simultaneousHandlers pattern from react-native-actions-sheet
|
|
124
124
|
// both gestures run simultaneously, we use blockPan to decide who handles
|
|
125
|
-
// console.warn('[RNGH-Pan] CREATING gesture, minY:', minY, 'frameSize:', frameSize)
|
|
126
125
|
const gesture = Gesture.Pan()
|
|
127
126
|
.withRef(panGestureRef)
|
|
128
127
|
// NO manualActivation - let both gestures run via simultaneousHandlers
|
|
@@ -148,7 +147,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
|
|
|
148
147
|
const pos = getCurrentPosition()
|
|
149
148
|
const atTop = pos <= minY + AT_TOP_THRESHOLD
|
|
150
149
|
const currentScrollY = scrollBridge.y
|
|
151
|
-
// console.warn('[RNGH-Pan] onBegin', { pos, minY, atTop, currentScrollY })
|
|
152
150
|
gs.startY = pos
|
|
153
151
|
gs.lastPanTranslationY = 0
|
|
154
152
|
gs.accumulatedOffset = 0
|
|
@@ -171,7 +169,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
|
|
|
171
169
|
gs.panStarted = true
|
|
172
170
|
setIsDragging(true)
|
|
173
171
|
|
|
174
|
-
// console.warn('[RNGH-Pan] onStart', { startY: gs.startY, minY })
|
|
175
172
|
scrollBridge.initialPosition = gs.startY
|
|
176
173
|
onStart()
|
|
177
174
|
})
|
|
@@ -195,8 +192,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
|
|
|
195
192
|
const isCurrentlyAtTop = currentPos <= minY + AT_TOP_THRESHOLD
|
|
196
193
|
const nodeIsScrolling = scrollY > 0
|
|
197
194
|
|
|
198
|
-
// console.warn('[RNGH-Pan] onChange', { translationY: translationY.toFixed(1), deltaY: deltaY.toFixed(1), currentPos: currentPos.toFixed(1), minY, isCurrentlyAtTop, isSwipingDown, scrollY, scrollEngaged: gs.scrollEngaged })
|
|
199
|
-
|
|
200
195
|
// decision matrix (from react-native-actions-sheet pattern)
|
|
201
196
|
// each frame, decide who handles the movement based on current state
|
|
202
197
|
//
|
|
@@ -229,7 +224,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
|
|
|
229
224
|
} else if (gs.scrollEngaged && hasScrollableContent) {
|
|
230
225
|
// scroll WAS > 0 but now is 0 -> handoff from scroll to pan
|
|
231
226
|
// pan takes over to drag sheet down
|
|
232
|
-
// console.warn('[RNGH-Pan] *** HANDOFF FROM SCROLL TO PAN ***')
|
|
233
227
|
panHandles = true
|
|
234
228
|
} else {
|
|
235
229
|
// scroll never engaged OR content not scrollable, just drag sheet down
|
|
@@ -249,13 +243,13 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
|
|
|
249
243
|
}
|
|
250
244
|
}
|
|
251
245
|
|
|
252
|
-
// console.warn('[RNGH-Pan] decision', { panHandles, isCurrentlyAtTop, isSwipingDown, nodeIsScrolling, scrollEngaged: gs.scrollEngaged, hasScrollableContent, currentPos: currentPos.toFixed(1), minY })
|
|
253
|
-
|
|
254
246
|
if (panHandles) {
|
|
255
247
|
// pan handles - disable scroll and move sheet
|
|
256
|
-
// when
|
|
257
|
-
//
|
|
258
|
-
|
|
248
|
+
// when swiping down at top after scroll was engaged: lock at current scroll position
|
|
249
|
+
// (handoff from scroll to pan — preserve scroll offset)
|
|
250
|
+
// otherwise: always lock scroll to 0 (prevents scroll from firing during sheet drag)
|
|
251
|
+
const lockTo =
|
|
252
|
+
isCurrentlyAtTop && isSwipingDown && gs.scrollEngaged ? undefined : 0
|
|
259
253
|
scrollBridge.setScrollEnabled?.(false, lockTo)
|
|
260
254
|
|
|
261
255
|
// accumulate the delta for position calculation
|
|
@@ -276,8 +270,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
|
|
|
276
270
|
const { velocityY } = event
|
|
277
271
|
const currentPos = gs.startY + gs.accumulatedOffset
|
|
278
272
|
|
|
279
|
-
// console.warn('[RNGH-Pan] onEnd', { velocityY, currentPos, accumulatedOffset: gs.accumulatedOffset, scrollY: scrollBridge.y })
|
|
280
|
-
|
|
281
273
|
// clear scroll lock
|
|
282
274
|
scrollBridge.scrollLockY = undefined
|
|
283
275
|
|
|
@@ -315,7 +307,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
|
|
|
315
307
|
onEnd(closestPoint)
|
|
316
308
|
})
|
|
317
309
|
.onFinalize(() => {
|
|
318
|
-
// console.warn('[RNGH-Pan] onFinalize', { panStarted: gs.panStarted })
|
|
319
310
|
// clear scroll lock on finalize too (safety)
|
|
320
311
|
scrollBridge.scrollLockY = undefined
|
|
321
312
|
if (gs.panStarted) {
|
|
@@ -334,7 +325,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
|
|
|
334
325
|
// if we have a scroll gesture ref, make pan simultaneous with it
|
|
335
326
|
// this allows both gestures to run and we decide in onChange who handles it
|
|
336
327
|
if (scrollGestureRef?.current) {
|
|
337
|
-
// console.warn('[RNGH-Pan] adding simultaneousWithExternalGesture for scroll')
|
|
338
328
|
return gesture.simultaneousWithExternalGesture(scrollGestureRef.current)
|
|
339
329
|
}
|
|
340
330
|
|
|
@@ -22,6 +22,10 @@ export type SheetControllerContextValue = {
|
|
|
22
22
|
// hide without "closing" to prevent re-animation when shown again
|
|
23
23
|
hidden?: boolean
|
|
24
24
|
onOpenChange?: React.Dispatch<React.SetStateAction<boolean>> | ((val: boolean) => void)
|
|
25
|
+
// fired by the sheet after its open/close animation finishes. used by
|
|
26
|
+
// Dialog adapt to know when it's safe to tear down adapted children
|
|
27
|
+
// without cutting off the slide-out mid-animation.
|
|
28
|
+
onAnimationComplete?: (state: { open: boolean }) => void
|
|
25
29
|
// when true, the sheet should skip its open animation (used for adapt handoff)
|
|
26
30
|
skipNextAnimation?: boolean
|
|
27
31
|
}
|
|
@@ -8,6 +8,7 @@ import type { ScrollBridge, SheetProps } from './types'
|
|
|
8
8
|
import type { SheetOpenState } from './useSheetOpenState'
|
|
9
9
|
|
|
10
10
|
export type SheetContextValue = ReturnType<typeof useSheetProviderProps> & {
|
|
11
|
+
keyboardOccludedHeight: number
|
|
11
12
|
setHasScrollView: (val: boolean) => void
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { getKeyboardOccludedHeight } from '../src/keyboardAvoidance'
|
|
4
|
+
|
|
5
|
+
describe('getKeyboardOccludedHeight', () => {
|
|
6
|
+
const base = {
|
|
7
|
+
frameSize: 700,
|
|
8
|
+
isKeyboardVisible: true,
|
|
9
|
+
keyboardHeight: 300,
|
|
10
|
+
screenSize: 844,
|
|
11
|
+
sheetY: 59,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
test('returns overflow below the keyboard top after the sheet is clamped', () => {
|
|
15
|
+
expect(getKeyboardOccludedHeight(base)).toBe(215)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test('returns zero when the keyboard-adjusted sheet clears the keyboard', () => {
|
|
19
|
+
expect(
|
|
20
|
+
getKeyboardOccludedHeight({
|
|
21
|
+
...base,
|
|
22
|
+
frameSize: 400,
|
|
23
|
+
sheetY: 144,
|
|
24
|
+
})
|
|
25
|
+
).toBe(0)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('ignores hidden keyboard and offscreen sheet positions', () => {
|
|
29
|
+
expect(
|
|
30
|
+
getKeyboardOccludedHeight({
|
|
31
|
+
...base,
|
|
32
|
+
isKeyboardVisible: false,
|
|
33
|
+
})
|
|
34
|
+
).toBe(0)
|
|
35
|
+
expect(
|
|
36
|
+
getKeyboardOccludedHeight({
|
|
37
|
+
...base,
|
|
38
|
+
sheetY: base.screenSize,
|
|
39
|
+
})
|
|
40
|
+
).toBe(0)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('clamps occlusion to the frame height', () => {
|
|
44
|
+
expect(
|
|
45
|
+
getKeyboardOccludedHeight({
|
|
46
|
+
...base,
|
|
47
|
+
frameSize: 120,
|
|
48
|
+
keyboardHeight: 1000,
|
|
49
|
+
sheetY: 0,
|
|
50
|
+
})
|
|
51
|
+
).toBe(120)
|
|
52
|
+
})
|
|
53
|
+
})
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"composite": true,
|
|
5
|
+
"strict": true
|
|
6
|
+
},
|
|
7
|
+
"references": [
|
|
8
|
+
{
|
|
9
|
+
"path": "../../core/animations-react-native"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "../../core/compose-refs"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "../../core/constants"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "../../core/core"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "../../core/create-context"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "../../core/helpers"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "../../core/use-constant"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "../../core/use-controllable-state"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"path": "../../core/use-keyboard-visible"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "../animate-presence"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"path": "../portal"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "../remove-scroll"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"path": "../scroll-view"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "../stacks"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"exclude": [
|
|
52
|
+
"types",
|
|
53
|
+
"dist",
|
|
54
|
+
"test",
|
|
55
|
+
"**/__tests__"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GestureDetectorWrapper.d.ts","sourceRoot":"","sources":["../src/GestureDetectorWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAGnD,UAAU,2BAA2B;IACnC,OAAO,EAAE,GAAG,CAAA;IACZ,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE,2BAA2B,
|
|
1
|
+
{"version":3,"file":"GestureDetectorWrapper.d.ts","sourceRoot":"","sources":["../src/GestureDetectorWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAGnD,UAAU,2BAA2B;IACnC,OAAO,EAAE,GAAG,CAAA;IACZ,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE,2BAA2B,2CAmB7B"}
|
package/types/Sheet.d.ts
CHANGED
|
@@ -43,6 +43,9 @@ export declare const Sheet: import("react").ForwardRefExoticComponent<{
|
|
|
43
43
|
portalProps?: import("@tamagui/portal").PortalProps;
|
|
44
44
|
moveOnKeyboardChange?: boolean;
|
|
45
45
|
containerComponent?: React.ComponentType<any>;
|
|
46
|
+
onAnimationComplete?: (info: {
|
|
47
|
+
open: boolean;
|
|
48
|
+
}) => void;
|
|
46
49
|
} & {
|
|
47
50
|
__scopeSheet?: import("@tamagui/create-context").Scope<any>;
|
|
48
51
|
} & import("react").RefAttributes<import("react-native").View>> & {
|
package/types/Sheet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sheet.d.ts","sourceRoot":"","sources":["../src/Sheet.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,cAAc,SAAS,CAAA;AAMvB,eAAO,MAAM,MAAM;;;;;8CAmCjB,CAAA;AAMF,eAAO,MAAM,OAAO;;;;;8CA2BlB,CAAA;AAMF,eAAO,MAAM,KAAK;;;;8CAoBhB,CAAA;AAEF,eAAO,MAAM,KAAK
|
|
1
|
+
{"version":3,"file":"Sheet.d.ts","sourceRoot":"","sources":["../src/Sheet.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,cAAc,SAAS,CAAA;AAMvB,eAAO,MAAM,MAAM;;;;;8CAmCjB,CAAA;AAMF,eAAO,MAAM,OAAO;;;;;8CA2BlB,CAAA;AAMF,eAAO,MAAM,KAAK;;;;8CAoBhB,CAAA;AAEF,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIhB,CAAA"}
|
package/types/SheetContext.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare const SheetProvider: (props: {
|
|
|
32
32
|
setPositionImmediate: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
33
33
|
onlyShowFrame: boolean;
|
|
34
34
|
} & {
|
|
35
|
+
keyboardOccludedHeight: number;
|
|
35
36
|
setHasScrollView: (val: boolean) => void;
|
|
36
37
|
} & {
|
|
37
38
|
scope: import("@tamagui/create-context").Scope<SheetContextValue>;
|