@tamagui/sheet 2.7.7 → 3.0.0-beta.643.1
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/dist/cjs/GestureDetectorWrapper.cjs +32 -41
- package/dist/cjs/GestureDetectorWrapper.native.cjs +48 -0
- package/dist/cjs/GestureDetectorWrapper.native.js +32 -40
- package/dist/cjs/GestureDetectorWrapper.native.js.map +1 -1
- package/dist/cjs/GestureSheetContext.cjs +29 -37
- package/dist/cjs/GestureSheetContext.native.cjs +49 -0
- package/dist/cjs/GestureSheetContext.native.js +30 -37
- package/dist/cjs/GestureSheetContext.native.js.map +1 -1
- package/dist/cjs/Sheet.cjs +206 -99
- package/dist/cjs/Sheet.native.cjs +234 -0
- package/dist/cjs/Sheet.native.js +212 -98
- package/dist/cjs/Sheet.native.js.map +1 -1
- package/dist/cjs/SheetContext.cjs +44 -22
- package/dist/cjs/SheetContext.native.cjs +58 -0
- package/dist/cjs/SheetContext.native.js +45 -22
- package/dist/cjs/SheetContext.native.js.map +1 -1
- package/dist/cjs/SheetController.cjs +50 -56
- package/dist/cjs/SheetController.native.cjs +72 -0
- package/dist/cjs/SheetController.native.js +53 -58
- package/dist/cjs/SheetController.native.js.map +1 -1
- package/dist/cjs/SheetImplementationCustom.cjs +674 -605
- package/dist/cjs/SheetImplementationCustom.native.cjs +762 -0
- package/dist/cjs/SheetImplementationCustom.native.js +713 -644
- package/dist/cjs/SheetImplementationCustom.native.js.map +1 -1
- package/dist/cjs/SheetScrollView.cjs +291 -312
- package/dist/cjs/SheetScrollView.native.cjs +326 -0
- package/dist/cjs/SheetScrollView.native.js +299 -319
- package/dist/cjs/SheetScrollView.native.js.map +1 -1
- package/dist/cjs/constants.cjs +22 -21
- package/dist/cjs/constants.native.cjs +37 -0
- package/dist/cjs/constants.native.js +22 -20
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/contexts.cjs +20 -28
- package/dist/cjs/contexts.native.cjs +38 -0
- package/dist/cjs/contexts.native.js +20 -27
- package/dist/cjs/contexts.native.js.map +1 -1
- package/dist/cjs/controller.cjs +17 -18
- package/dist/cjs/controller.native.cjs +32 -0
- package/dist/cjs/controller.native.js +17 -17
- package/dist/cjs/controller.native.js.map +1 -1
- package/dist/cjs/gestureState.cjs +29 -30
- package/dist/cjs/gestureState.native.cjs +54 -0
- package/dist/cjs/gestureState.native.js +30 -30
- package/dist/cjs/gestureState.native.js.map +1 -1
- package/dist/cjs/helpers.cjs +21 -24
- package/dist/cjs/helpers.native.cjs +35 -0
- package/dist/cjs/helpers.native.js +22 -24
- package/dist/cjs/helpers.native.js.map +1 -1
- package/dist/cjs/index.cjs +15 -21
- package/dist/cjs/index.native.cjs +37 -0
- package/dist/cjs/index.native.js +16 -21
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/keyboardAvoidance.cjs +56 -79
- package/dist/cjs/keyboardAvoidance.native.cjs +75 -0
- package/dist/cjs/keyboardAvoidance.native.js +56 -78
- package/dist/cjs/keyboardAvoidance.native.js.map +1 -1
- package/dist/cjs/nativeSheet.cjs +64 -76
- package/dist/cjs/nativeSheet.native.cjs +94 -0
- package/dist/cjs/nativeSheet.native.js +70 -83
- package/dist/cjs/nativeSheet.native.js.map +1 -1
- package/dist/cjs/types.cjs +10 -11
- package/dist/cjs/types.native.cjs +19 -0
- package/dist/cjs/types.native.js +10 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/useGestureHandlerPan.cjs +245 -257
- package/dist/cjs/useGestureHandlerPan.native.cjs +273 -0
- package/dist/cjs/useGestureHandlerPan.native.js +254 -265
- package/dist/cjs/useGestureHandlerPan.native.js.map +1 -1
- package/dist/cjs/useKeyboardControllerSheet.cjs +83 -88
- package/dist/cjs/useKeyboardControllerSheet.native.cjs +119 -0
- package/dist/cjs/useKeyboardControllerSheet.native.js +100 -111
- package/dist/cjs/useKeyboardControllerSheet.native.js.map +1 -1
- package/dist/cjs/useSafeAreaInsets.cjs +20 -26
- package/dist/cjs/useSafeAreaInsets.native.cjs +51 -0
- package/dist/cjs/useSafeAreaInsets.native.js +30 -25
- package/dist/cjs/useSafeAreaInsets.native.js.map +1 -1
- package/dist/cjs/useSheetController.cjs +27 -39
- package/dist/cjs/useSheetController.native.cjs +42 -0
- package/dist/cjs/useSheetController.native.js +28 -39
- package/dist/cjs/useSheetController.native.js.map +1 -1
- package/dist/cjs/useSheetOffscreenSize.cjs +44 -53
- package/dist/cjs/useSheetOffscreenSize.native.cjs +60 -0
- package/dist/cjs/useSheetOffscreenSize.native.js +48 -56
- package/dist/cjs/useSheetOffscreenSize.native.js.map +1 -1
- package/dist/cjs/useSheetOpenState.cjs +69 -40
- package/dist/cjs/useSheetOpenState.native.cjs +88 -0
- package/dist/cjs/useSheetOpenState.native.js +74 -42
- package/dist/cjs/useSheetOpenState.native.js.map +1 -1
- package/dist/cjs/useSheetProviderProps.cjs +146 -164
- package/dist/cjs/useSheetProviderProps.native.cjs +176 -0
- package/dist/cjs/useSheetProviderProps.native.js +156 -174
- package/dist/cjs/useSheetProviderProps.native.js.map +1 -1
- package/dist/cjs/useSheetScrollViewGestures.cjs +172 -180
- package/dist/cjs/useSheetScrollViewGestures.native.cjs +150 -0
- package/dist/cjs/useSheetScrollViewGestures.native.js +136 -147
- package/dist/cjs/useSheetScrollViewGestures.native.js.map +1 -1
- package/dist/cjs/webViewport.cjs +47 -48
- package/dist/cjs/webViewport.native.cjs +79 -0
- package/dist/cjs/webViewport.native.js +50 -50
- package/dist/cjs/webViewport.native.js.map +1 -1
- package/dist/esm/GestureDetectorWrapper.mjs +19 -23
- package/dist/esm/GestureDetectorWrapper.mjs.map +1 -1
- package/dist/esm/GestureDetectorWrapper.native.js +20 -24
- package/dist/esm/GestureDetectorWrapper.native.js.map +1 -1
- package/dist/esm/GestureSheetContext.mjs +15 -20
- package/dist/esm/GestureSheetContext.mjs.map +1 -1
- package/dist/esm/GestureSheetContext.native.js +17 -22
- package/dist/esm/GestureSheetContext.native.js.map +1 -1
- package/dist/esm/Sheet.mjs +191 -83
- package/dist/esm/Sheet.mjs.map +1 -1
- package/dist/esm/Sheet.native.js +198 -83
- package/dist/esm/Sheet.native.js.map +1 -1
- package/dist/esm/SheetContext.mjs +21 -5
- package/dist/esm/SheetContext.mjs.map +1 -1
- package/dist/esm/SheetContext.native.js +21 -5
- package/dist/esm/SheetContext.native.js.map +1 -1
- package/dist/esm/SheetController.mjs +34 -30
- package/dist/esm/SheetController.mjs.map +1 -1
- package/dist/esm/SheetController.native.js +38 -34
- package/dist/esm/SheetController.native.js.map +1 -1
- package/dist/esm/SheetImplementationCustom.mjs +655 -580
- package/dist/esm/SheetImplementationCustom.mjs.map +1 -1
- package/dist/esm/SheetImplementationCustom.native.js +691 -612
- package/dist/esm/SheetImplementationCustom.native.js.map +1 -1
- package/dist/esm/SheetScrollView.mjs +277 -288
- package/dist/esm/SheetScrollView.mjs.map +1 -1
- package/dist/esm/SheetScrollView.native.js +286 -297
- package/dist/esm/SheetScrollView.native.js.map +1 -1
- package/dist/esm/constants.mjs +5 -3
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +5 -3
- 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/controller.mjs +2 -2
- package/dist/esm/controller.native.js +2 -2
- package/dist/esm/gestureState.mjs +13 -11
- package/dist/esm/gestureState.mjs.map +1 -1
- package/dist/esm/gestureState.native.js +14 -12
- package/dist/esm/gestureState.native.js.map +1 -1
- package/dist/esm/helpers.mjs +7 -6
- package/dist/esm/helpers.mjs.map +1 -1
- package/dist/esm/helpers.native.js +8 -7
- package/dist/esm/helpers.native.js.map +1 -1
- package/dist/esm/index.js +21 -14
- package/dist/esm/index.mjs +21 -14
- package/dist/esm/index.native.js +21 -14
- package/dist/esm/keyboardAvoidance.mjs +40 -61
- package/dist/esm/keyboardAvoidance.mjs.map +1 -1
- package/dist/esm/keyboardAvoidance.native.js +40 -61
- package/dist/esm/keyboardAvoidance.native.js.map +1 -1
- package/dist/esm/nativeSheet.mjs +52 -61
- package/dist/esm/nativeSheet.mjs.map +1 -1
- package/dist/esm/nativeSheet.native.js +58 -69
- package/dist/esm/nativeSheet.native.js.map +1 -1
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/dist/esm/useGestureHandlerPan.mjs +232 -239
- package/dist/esm/useGestureHandlerPan.mjs.map +1 -1
- package/dist/esm/useGestureHandlerPan.native.js +241 -248
- package/dist/esm/useGestureHandlerPan.native.js.map +1 -1
- package/dist/esm/useKeyboardControllerSheet.mjs +71 -71
- package/dist/esm/useKeyboardControllerSheet.mjs.map +1 -1
- package/dist/esm/useKeyboardControllerSheet.native.js +92 -94
- package/dist/esm/useKeyboardControllerSheet.native.js.map +1 -1
- package/dist/esm/useSafeAreaInsets.mjs +3 -1
- package/dist/esm/useSafeAreaInsets.mjs.map +1 -1
- package/dist/esm/useSafeAreaInsets.native.js +15 -3
- package/dist/esm/useSafeAreaInsets.native.js.map +1 -1
- package/dist/esm/useSheetController.mjs +14 -12
- package/dist/esm/useSheetController.mjs.map +1 -1
- package/dist/esm/useSheetController.native.js +14 -12
- package/dist/esm/useSheetController.native.js.map +1 -1
- package/dist/esm/useSheetOffscreenSize.mjs +30 -35
- package/dist/esm/useSheetOffscreenSize.mjs.map +1 -1
- package/dist/esm/useSheetOffscreenSize.native.js +34 -39
- package/dist/esm/useSheetOffscreenSize.native.js.map +1 -1
- package/dist/esm/useSheetOpenState.mjs +50 -22
- package/dist/esm/useSheetOpenState.mjs.map +1 -1
- package/dist/esm/useSheetOpenState.native.js +55 -25
- package/dist/esm/useSheetOpenState.native.js.map +1 -1
- package/dist/esm/useSheetProviderProps.mjs +130 -138
- package/dist/esm/useSheetProviderProps.mjs.map +1 -1
- package/dist/esm/useSheetProviderProps.native.js +140 -149
- package/dist/esm/useSheetProviderProps.native.js.map +1 -1
- package/dist/esm/useSheetScrollViewGestures.mjs +159 -162
- package/dist/esm/useSheetScrollViewGestures.mjs.map +1 -1
- package/dist/esm/useSheetScrollViewGestures.native.js +123 -130
- package/dist/esm/useSheetScrollViewGestures.native.js.map +1 -1
- package/dist/esm/webViewport.mjs +26 -25
- package/dist/esm/webViewport.mjs.map +1 -1
- package/dist/esm/webViewport.native.js +29 -28
- package/dist/esm/webViewport.native.js.map +1 -1
- package/dist/jsx/GestureDetectorWrapper.mjs +19 -23
- package/dist/jsx/GestureDetectorWrapper.mjs.map +1 -1
- package/dist/jsx/GestureDetectorWrapper.native.cjs +48 -0
- package/dist/jsx/GestureDetectorWrapper.native.js +32 -40
- package/dist/jsx/GestureDetectorWrapper.native.js.map +1 -1
- package/dist/jsx/GestureSheetContext.mjs +15 -20
- package/dist/jsx/GestureSheetContext.mjs.map +1 -1
- package/dist/jsx/GestureSheetContext.native.cjs +49 -0
- package/dist/jsx/GestureSheetContext.native.js +30 -37
- package/dist/jsx/GestureSheetContext.native.js.map +1 -1
- package/dist/jsx/Sheet.mjs +191 -83
- package/dist/jsx/Sheet.mjs.map +1 -1
- package/dist/jsx/Sheet.native.cjs +234 -0
- package/dist/jsx/Sheet.native.js +212 -98
- package/dist/jsx/Sheet.native.js.map +1 -1
- package/dist/jsx/SheetContext.mjs +21 -5
- package/dist/jsx/SheetContext.mjs.map +1 -1
- package/dist/jsx/SheetContext.native.cjs +58 -0
- package/dist/jsx/SheetContext.native.js +45 -22
- package/dist/jsx/SheetContext.native.js.map +1 -1
- package/dist/jsx/SheetController.mjs +34 -30
- package/dist/jsx/SheetController.mjs.map +1 -1
- package/dist/jsx/SheetController.native.cjs +72 -0
- package/dist/jsx/SheetController.native.js +53 -58
- package/dist/jsx/SheetController.native.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.mjs +655 -580
- package/dist/jsx/SheetImplementationCustom.mjs.map +1 -1
- package/dist/jsx/SheetImplementationCustom.native.cjs +762 -0
- package/dist/jsx/SheetImplementationCustom.native.js +713 -644
- package/dist/jsx/SheetImplementationCustom.native.js.map +1 -1
- package/dist/jsx/SheetScrollView.mjs +277 -288
- package/dist/jsx/SheetScrollView.mjs.map +1 -1
- package/dist/jsx/SheetScrollView.native.cjs +326 -0
- package/dist/jsx/SheetScrollView.native.js +299 -319
- package/dist/jsx/SheetScrollView.native.js.map +1 -1
- package/dist/jsx/constants.mjs +5 -3
- package/dist/jsx/constants.mjs.map +1 -1
- package/dist/jsx/constants.native.cjs +37 -0
- package/dist/jsx/constants.native.js +22 -20
- 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.cjs +38 -0
- package/dist/jsx/contexts.native.js +20 -27
- package/dist/jsx/contexts.native.js.map +1 -1
- package/dist/jsx/controller.mjs +2 -2
- package/dist/jsx/controller.native.cjs +32 -0
- package/dist/jsx/controller.native.js +17 -17
- package/dist/jsx/controller.native.js.map +1 -1
- package/dist/jsx/gestureState.mjs +13 -11
- package/dist/jsx/gestureState.mjs.map +1 -1
- package/dist/jsx/gestureState.native.cjs +54 -0
- package/dist/jsx/gestureState.native.js +30 -30
- package/dist/jsx/gestureState.native.js.map +1 -1
- package/dist/jsx/helpers.mjs +7 -6
- package/dist/jsx/helpers.mjs.map +1 -1
- package/dist/jsx/helpers.native.cjs +35 -0
- package/dist/jsx/helpers.native.js +22 -24
- package/dist/jsx/helpers.native.js.map +1 -1
- package/dist/jsx/index.js +21 -14
- package/dist/jsx/index.mjs +21 -14
- package/dist/jsx/index.native.cjs +37 -0
- package/dist/jsx/index.native.js +16 -21
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/keyboardAvoidance.mjs +40 -61
- package/dist/jsx/keyboardAvoidance.mjs.map +1 -1
- package/dist/jsx/keyboardAvoidance.native.cjs +75 -0
- package/dist/jsx/keyboardAvoidance.native.js +56 -78
- package/dist/jsx/keyboardAvoidance.native.js.map +1 -1
- package/dist/jsx/nativeSheet.mjs +52 -61
- package/dist/jsx/nativeSheet.mjs.map +1 -1
- package/dist/jsx/nativeSheet.native.cjs +94 -0
- package/dist/jsx/nativeSheet.native.js +70 -83
- package/dist/jsx/nativeSheet.native.js.map +1 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +19 -0
- package/dist/jsx/types.native.js +10 -10
- package/dist/jsx/types.native.js.map +1 -1
- package/dist/jsx/useGestureHandlerPan.mjs +232 -239
- package/dist/jsx/useGestureHandlerPan.mjs.map +1 -1
- package/dist/jsx/useGestureHandlerPan.native.cjs +273 -0
- package/dist/jsx/useGestureHandlerPan.native.js +254 -265
- package/dist/jsx/useGestureHandlerPan.native.js.map +1 -1
- package/dist/jsx/useKeyboardControllerSheet.mjs +71 -71
- package/dist/jsx/useKeyboardControllerSheet.mjs.map +1 -1
- package/dist/jsx/useKeyboardControllerSheet.native.cjs +119 -0
- package/dist/jsx/useKeyboardControllerSheet.native.js +100 -111
- package/dist/jsx/useKeyboardControllerSheet.native.js.map +1 -1
- package/dist/jsx/useSafeAreaInsets.mjs +3 -1
- package/dist/jsx/useSafeAreaInsets.mjs.map +1 -1
- package/dist/jsx/useSafeAreaInsets.native.cjs +51 -0
- package/dist/jsx/useSafeAreaInsets.native.js +30 -25
- package/dist/jsx/useSafeAreaInsets.native.js.map +1 -1
- package/dist/jsx/useSheetController.mjs +14 -12
- package/dist/jsx/useSheetController.mjs.map +1 -1
- package/dist/jsx/useSheetController.native.cjs +42 -0
- package/dist/jsx/useSheetController.native.js +28 -39
- package/dist/jsx/useSheetController.native.js.map +1 -1
- package/dist/jsx/useSheetOffscreenSize.mjs +30 -35
- package/dist/jsx/useSheetOffscreenSize.mjs.map +1 -1
- package/dist/jsx/useSheetOffscreenSize.native.cjs +60 -0
- package/dist/jsx/useSheetOffscreenSize.native.js +48 -56
- package/dist/jsx/useSheetOffscreenSize.native.js.map +1 -1
- package/dist/jsx/useSheetOpenState.mjs +50 -22
- package/dist/jsx/useSheetOpenState.mjs.map +1 -1
- package/dist/jsx/useSheetOpenState.native.cjs +88 -0
- package/dist/jsx/useSheetOpenState.native.js +74 -42
- package/dist/jsx/useSheetOpenState.native.js.map +1 -1
- package/dist/jsx/useSheetProviderProps.mjs +130 -138
- package/dist/jsx/useSheetProviderProps.mjs.map +1 -1
- package/dist/jsx/useSheetProviderProps.native.cjs +176 -0
- package/dist/jsx/useSheetProviderProps.native.js +156 -174
- package/dist/jsx/useSheetProviderProps.native.js.map +1 -1
- package/dist/jsx/useSheetScrollViewGestures.mjs +159 -162
- package/dist/jsx/useSheetScrollViewGestures.mjs.map +1 -1
- package/dist/jsx/useSheetScrollViewGestures.native.cjs +150 -0
- package/dist/jsx/useSheetScrollViewGestures.native.js +136 -147
- package/dist/jsx/useSheetScrollViewGestures.native.js.map +1 -1
- package/dist/jsx/webViewport.mjs +26 -25
- package/dist/jsx/webViewport.mjs.map +1 -1
- package/dist/jsx/webViewport.native.cjs +79 -0
- package/dist/jsx/webViewport.native.js +50 -50
- package/dist/jsx/webViewport.native.js.map +1 -1
- package/package.json +33 -39
- package/src/Sheet.tsx +316 -77
- package/src/SheetContext.tsx +57 -7
- package/src/SheetController.tsx +7 -6
- package/src/SheetImplementationCustom.tsx +343 -140
- package/src/SheetScrollView.tsx +24 -13
- package/src/constants.tsx +3 -3
- package/src/helpers.tsx +0 -14
- package/src/index.ts +3 -6
- package/src/nativeSheet.tsx +5 -15
- package/src/types.tsx +104 -92
- package/src/useKeyboardControllerSheet.native.ts +7 -2
- package/src/useSafeAreaInsets.native.ts +20 -13
- package/src/useSheetController.tsx +15 -7
- package/src/useSheetOpenState.tsx +50 -4
- package/src/useSheetProviderProps.tsx +4 -27
- package/src/useSheetScrollViewGestures.ts +2 -2
- package/types/GestureDetectorWrapper.d.ts +1 -1
- package/types/GestureDetectorWrapper.d.ts.map +1 -1
- package/types/GestureSheetContext.d.ts +1 -1
- package/types/GestureSheetContext.d.ts.map +1 -1
- package/types/Sheet.d.ts +384 -135
- package/types/Sheet.d.ts.map +1 -1
- package/types/SheetContext.d.ts +28 -42
- package/types/SheetContext.d.ts.map +1 -1
- package/types/SheetController.d.ts +4 -2
- package/types/SheetController.d.ts.map +1 -1
- package/types/SheetImplementationCustom.d.ts +3 -35
- package/types/SheetImplementationCustom.d.ts.map +1 -1
- package/types/SheetScrollView.d.ts +57 -23
- package/types/SheetScrollView.d.ts.map +1 -1
- package/types/constants.d.ts +3 -2
- package/types/constants.d.ts.map +1 -1
- package/types/index.d.ts +1 -3
- package/types/index.d.ts.map +1 -1
- package/types/nativeSheet.d.ts.map +1 -1
- package/types/types.d.ts +28 -17
- package/types/types.d.ts.map +1 -1
- package/types/useKeyboardControllerSheet.native.d.ts.map +1 -1
- package/types/useSafeAreaInsets.native.d.ts +4 -12
- package/types/useSafeAreaInsets.native.d.ts.map +1 -1
- package/types/useSheetController.d.ts +6 -6
- package/types/useSheetController.d.ts.map +1 -1
- package/types/useSheetOffscreenSize.d.ts.map +1 -1
- package/types/useSheetOpenState.d.ts +3 -2
- package/types/useSheetOpenState.d.ts.map +1 -1
- package/types/useSheetProviderProps.d.ts +5 -8
- package/types/useSheetProviderProps.d.ts.map +1 -1
- package/types/useSheetScrollViewGestures.d.ts +2 -2
- package/types/useSheetScrollViewGestures.d.ts.map +1 -1
- package/.turbo/turbo-build.log +0 -2
- package/controller/index.cjs +0 -2
- package/controller/index.d.ts +0 -5
- package/controller/index.js +0 -2
- package/controller/index.native.cjs +0 -2
- package/controller/index.native.js +0 -2
- package/dist/cjs/createSheet.cjs +0 -194
- package/dist/cjs/createSheet.native.js +0 -204
- package/dist/cjs/createSheet.native.js.map +0 -1
- package/dist/cjs/setupGestureHandler.cjs +0 -55
- package/dist/cjs/setupGestureHandler.native.js +0 -60
- package/dist/cjs/setupGestureHandler.native.js.map +0 -1
- package/dist/cjs/useSheet.cjs +0 -29
- package/dist/cjs/useSheet.native.js +0 -34
- package/dist/cjs/useSheet.native.js.map +0 -1
- package/dist/esm/controller.mjs.map +0 -1
- package/dist/esm/controller.native.js.map +0 -1
- package/dist/esm/createSheet.mjs +0 -168
- package/dist/esm/createSheet.mjs.map +0 -1
- package/dist/esm/createSheet.native.js +0 -176
- package/dist/esm/createSheet.native.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/setupGestureHandler.mjs +0 -29
- package/dist/esm/setupGestureHandler.mjs.map +0 -1
- package/dist/esm/setupGestureHandler.native.js +0 -31
- package/dist/esm/setupGestureHandler.native.js.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js.map +0 -1
- package/dist/esm/useSheet.mjs +0 -4
- package/dist/esm/useSheet.mjs.map +0 -1
- package/dist/esm/useSheet.native.js +0 -6
- package/dist/esm/useSheet.native.js.map +0 -1
- package/dist/jsx/controller.mjs.map +0 -1
- package/dist/jsx/createSheet.mjs +0 -168
- package/dist/jsx/createSheet.mjs.map +0 -1
- package/dist/jsx/createSheet.native.js +0 -204
- package/dist/jsx/createSheet.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/setupGestureHandler.mjs +0 -29
- package/dist/jsx/setupGestureHandler.mjs.map +0 -1
- package/dist/jsx/setupGestureHandler.native.js +0 -60
- package/dist/jsx/setupGestureHandler.native.js.map +0 -1
- package/dist/jsx/types.mjs.map +0 -1
- package/dist/jsx/useSheet.mjs +0 -4
- package/dist/jsx/useSheet.mjs.map +0 -1
- package/dist/jsx/useSheet.native.js +0 -34
- package/dist/jsx/useSheet.native.js.map +0 -1
- package/next.md +0 -78
- package/setup-gesture-handler/index.cjs +0 -2
- package/setup-gesture-handler/index.js +0 -2
- package/setup-gesture-handler/index.native.cjs +0 -2
- package/setup-gesture-handler/index.native.js +0 -2
- package/setup-gesture-handler.cjs +0 -1
- package/src/createSheet.tsx +0 -309
- package/src/setupGestureHandler.ts +0 -43
- package/src/useSheet.tsx +0 -3
- package/test/keyboardAvoidance.test.ts +0 -269
- package/tsconfig.json +0 -57
- package/types/createSheet.d.ts +0 -195
- package/types/createSheet.d.ts.map +0 -1
- package/types/setupGestureHandler.d.ts +0 -11
- package/types/setupGestureHandler.d.ts.map +0 -1
- package/types/useSheet.d.ts +0 -2
- package/types/useSheet.d.ts.map +0 -1
package/src/SheetScrollView.tsx
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { composeRefs } from '@tamagui/compose-refs'
|
|
2
|
-
import { isWeb, View, type
|
|
3
|
-
import type {
|
|
2
|
+
import { createStyledHOC, isWeb, View, type GetProps } from '@tamagui/core'
|
|
3
|
+
import type { ScrollViewRef } from '@tamagui/scroll-view'
|
|
4
4
|
import { ScrollView } from '@tamagui/scroll-view'
|
|
5
5
|
import { useControllableState } from '@tamagui/use-controllable-state'
|
|
6
6
|
import React, { useEffect, useRef, useState } from 'react'
|
|
7
|
-
import type { ScrollView as RNScrollView } from 'react-native'
|
|
8
7
|
import { useGestureSheetContext } from './GestureSheetContext'
|
|
9
8
|
import { getGestureHandlerState, isGestureHandlerEnabled } from './gestureState'
|
|
10
9
|
import { useSheetContext } from './SheetContext'
|
|
@@ -20,21 +19,29 @@ import {
|
|
|
20
19
|
|
|
21
20
|
const SHEET_SCROLL_VIEW_NAME = 'SheetScrollView'
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
type SheetScrollViewBaseProps = GetProps<typeof ScrollView>
|
|
23
|
+
|
|
24
|
+
type SheetScrollViewProps = SheetScopedProps<
|
|
25
|
+
SheetScrollViewBaseProps & {
|
|
26
|
+
h?: SheetScrollViewBaseProps['height']
|
|
27
|
+
o?: SheetScrollViewBaseProps['opacity']
|
|
28
|
+
pos?: SheetScrollViewBaseProps['position']
|
|
29
|
+
}
|
|
30
|
+
>
|
|
31
|
+
|
|
32
|
+
export const SheetScrollView = createStyledHOC(
|
|
33
|
+
ScrollView,
|
|
27
34
|
(
|
|
28
35
|
{
|
|
29
|
-
|
|
36
|
+
scope,
|
|
30
37
|
children,
|
|
31
38
|
onScroll,
|
|
32
39
|
scrollEnabled: scrollEnabledProp,
|
|
33
40
|
...props
|
|
34
|
-
}:
|
|
41
|
+
}: SheetScrollViewProps,
|
|
35
42
|
ref
|
|
36
43
|
) => {
|
|
37
|
-
const context = useSheetContext(
|
|
44
|
+
const context = useSheetContext(scope)
|
|
38
45
|
const gestureContext = useGestureSheetContext()
|
|
39
46
|
const { scrollBridge, setHasScrollView, hasFit, screenSize } = context
|
|
40
47
|
const keyboardOccludedHeight = Math.max(0, context.keyboardOccludedHeight || 0)
|
|
@@ -50,7 +57,7 @@ export const SheetScrollView = React.forwardRef<
|
|
|
50
57
|
prop: scrollEnabledProp,
|
|
51
58
|
defaultProp: true,
|
|
52
59
|
})
|
|
53
|
-
const scrollRef = React.useRef<
|
|
60
|
+
const scrollRef = React.useRef<ScrollViewRef | null>(null)
|
|
54
61
|
|
|
55
62
|
const [hasScrollableContent, setHasScrollableContent] = useState(true)
|
|
56
63
|
const parentHeight = useRef(0)
|
|
@@ -61,8 +68,8 @@ export const SheetScrollView = React.forwardRef<
|
|
|
61
68
|
// closed), so the height now comes from the sheet, which doesn't remount.
|
|
62
69
|
const frozenFrameHeight = Math.max(0, context.keyboardStableFrameHeight || 0)
|
|
63
70
|
|
|
64
|
-
// with snapPointsMode="fit",
|
|
65
|
-
// a flex: 1 child can't grow inside a content-sized parent, so the ScrollView (and the
|
|
71
|
+
// with snapPointsMode="fit", Container is content-sized (flex: 0, flex-basis: auto, height: undefined).
|
|
72
|
+
// a flex: 1 child can't grow inside a content-sized parent, so the ScrollView (and the Container
|
|
66
73
|
// around it) collapse to 0 height. instead, let the ScrollView size to its content and cap it
|
|
67
74
|
// at the available viewport (screenSize / maxContentSize) so scrolling kicks in for tall content.
|
|
68
75
|
const fitSizingStyle = hasFit
|
|
@@ -364,5 +371,9 @@ export const SheetScrollView = React.forwardRef<
|
|
|
364
371
|
{contentWrapper}
|
|
365
372
|
</ScrollView>
|
|
366
373
|
)
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
disableTheme: true,
|
|
377
|
+
displayName: SHEET_SCROLL_VIEW_NAME,
|
|
367
378
|
}
|
|
368
379
|
)
|
package/src/constants.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
3
|
-
export const SHEET_NAME = 'Sheet'
|
|
1
|
+
export const SHEET_CONTAINER_NAME = 'SheetContainer'
|
|
2
|
+
export const SHEET_BACKGROUND_NAME = 'SheetBackground'
|
|
4
3
|
export const SHEET_HANDLE_NAME = 'SheetHandle'
|
|
5
4
|
export const SHEET_OVERLAY_NAME = 'SheetOverlay'
|
|
5
|
+
export const SHEET_OVERLAY_MARKER = Symbol('SheetOverlay')
|
package/src/helpers.tsx
CHANGED
|
@@ -15,17 +15,3 @@ export function resisted(y: number, minY: number, maxOverflow = 25) {
|
|
|
15
15
|
// Return the position with resistance applied
|
|
16
16
|
return minY - resistedDistance
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
// // set all the way off screen
|
|
20
|
-
// // + 0.1 ensures this is unique - see hasntMeasured ref
|
|
21
|
-
|
|
22
|
-
// let hiddenSize: number
|
|
23
|
-
|
|
24
|
-
// export function getHiddenSize() {
|
|
25
|
-
// if (hiddenSize == undefined) {
|
|
26
|
-
// // this trigger reflow on web avoid doing on startup
|
|
27
|
-
// const screen = Dimensions.get('screen')
|
|
28
|
-
// hiddenSize = Math.max(screen.height, screen.width) + 0.1
|
|
29
|
-
// }
|
|
30
|
-
// return hiddenSize
|
|
31
|
-
// }
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './Sheet'
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// public so copied skins can forward the open state into their own styled parts
|
|
3
|
+
// (e.g. the Handle's open-driven opacity variant).
|
|
4
|
+
export { useSheetContext } from './SheetContext'
|
|
4
5
|
export * from './SheetController'
|
|
5
6
|
export * from './useSheetController'
|
|
6
7
|
export * from './useSheetOpenState'
|
|
@@ -9,7 +10,3 @@ export * from './SheetScrollView'
|
|
|
9
10
|
export * from './nativeSheet'
|
|
10
11
|
export * from './types'
|
|
11
12
|
export * from './contexts'
|
|
12
|
-
export {
|
|
13
|
-
getGestureHandlerState as unstable_getSheetGestureHandlerState,
|
|
14
|
-
isGestureHandlerEnabled as unstable_isSheetGestureHandlerEnabled,
|
|
15
|
-
} from './gestureState'
|
package/src/nativeSheet.tsx
CHANGED
|
@@ -2,13 +2,11 @@ import { YStack } from '@tamagui/stacks'
|
|
|
2
2
|
import type { FunctionComponent } from 'react'
|
|
3
3
|
import { useEffect, useRef } from 'react'
|
|
4
4
|
import { View } from 'react-native'
|
|
5
|
-
import { SheetProvider } from './SheetContext'
|
|
5
|
+
import { SheetNativeSystemContext, SheetProvider } from './SheetContext'
|
|
6
6
|
import type { SheetProps } from './types'
|
|
7
7
|
import { useSheetOpenState } from './useSheetOpenState'
|
|
8
8
|
import { useSheetProviderProps } from './useSheetProviderProps'
|
|
9
9
|
|
|
10
|
-
// import { useSheetSnapPoints } from './useSheetSnapPoints'
|
|
11
|
-
|
|
12
10
|
type SheetNativePlatforms = 'ios'
|
|
13
11
|
|
|
14
12
|
const nativeSheets: Record<SheetNativePlatforms, FunctionComponent<SheetProps> | null> = {
|
|
@@ -29,8 +27,6 @@ export function setupNativeSheet(
|
|
|
29
27
|
nativeSheets[platform] = (props: SheetProps) => {
|
|
30
28
|
const state = useSheetOpenState(props)
|
|
31
29
|
const providerProps = useSheetProviderProps(props, state)
|
|
32
|
-
// const { position } = providerProps
|
|
33
|
-
// const { positions } = useSheetSnapPoints(providerProps)
|
|
34
30
|
|
|
35
31
|
const { open, setOpen } = state
|
|
36
32
|
const ref = useRef<{
|
|
@@ -51,21 +47,15 @@ export function setupNativeSheet(
|
|
|
51
47
|
setOpen(next)
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
// modalContentPreferredContentSize={{
|
|
55
|
-
// mode: 'percent',
|
|
56
|
-
// percentWidth: '100%',
|
|
57
|
-
// percentHeight:
|
|
58
|
-
// }}
|
|
59
|
-
|
|
60
50
|
return (
|
|
61
|
-
|
|
51
|
+
<SheetNativeSystemContext.Provider value>
|
|
62
52
|
<SheetProvider
|
|
63
53
|
setHasScrollView={emptyFn}
|
|
64
54
|
keyboardOccludedHeight={0}
|
|
65
55
|
isKeyboardVisible={false}
|
|
66
56
|
keyboardStableFrameHeight={0}
|
|
67
57
|
{...providerProps}
|
|
68
|
-
|
|
58
|
+
onlyShowContainer
|
|
69
59
|
>
|
|
70
60
|
<ModalSheetView ref={ref} onModalDidDismiss={() => setOpenInternal(false)}>
|
|
71
61
|
<ModalSheetViewMainContent>
|
|
@@ -77,7 +67,7 @@ export function setupNativeSheet(
|
|
|
77
67
|
{/* so just hiding it here for now... not great... */}
|
|
78
68
|
<YStack
|
|
79
69
|
position="absolute"
|
|
80
|
-
|
|
70
|
+
display="none"
|
|
81
71
|
pointerEvents="none"
|
|
82
72
|
width={0}
|
|
83
73
|
height={0}
|
|
@@ -85,7 +75,7 @@ export function setupNativeSheet(
|
|
|
85
75
|
{props.children}
|
|
86
76
|
</YStack>
|
|
87
77
|
</SheetProvider>
|
|
88
|
-
|
|
78
|
+
</SheetNativeSystemContext.Provider>
|
|
89
79
|
)
|
|
90
80
|
}
|
|
91
81
|
}
|
package/src/types.tsx
CHANGED
|
@@ -1,99 +1,113 @@
|
|
|
1
1
|
import type { AnimatedNumberStrategy, TransitionProp } from '@tamagui/core'
|
|
2
|
-
import type { ScopedProps } from '@tamagui/create-context'
|
|
3
2
|
import type { PortalProps } from '@tamagui/portal'
|
|
4
3
|
import type { RemoveScroll } from '@tamagui/remove-scroll'
|
|
5
4
|
import type { ReactNode } from 'react'
|
|
6
5
|
import type React from 'react'
|
|
7
6
|
|
|
8
|
-
export type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
7
|
+
export type SheetScopes = string
|
|
8
|
+
|
|
9
|
+
export type SheetScopedProps<P> = Omit<P, 'scope'> & {
|
|
10
|
+
scope?: SheetScopes
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type SheetProps = SheetScopedProps<{
|
|
14
|
+
open?: boolean
|
|
15
|
+
defaultOpen?: boolean
|
|
16
|
+
onOpenChange?: OpenChangeHandler
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Control the index of the position in the `snapPoints` array
|
|
20
|
+
*/
|
|
21
|
+
position?: number
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Initial position from the `snapPoints` array
|
|
25
|
+
*/
|
|
26
|
+
defaultPosition?: number
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Array of pixels or percents the Sheet will attempt to move to when dragged.
|
|
30
|
+
* The first is the topmost and default when first opened via open prop.
|
|
31
|
+
*/
|
|
32
|
+
snapPoints?: (string | number)[]
|
|
33
|
+
|
|
34
|
+
snapPointsMode?: SnapPointsMode
|
|
35
|
+
onPositionChange?: PositionChangeHandler
|
|
36
|
+
children?: ReactNode
|
|
37
|
+
dismissOnOverlayPress?: boolean
|
|
38
|
+
dismissOnSnapToBottom?: boolean
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Disables the RemoveScroll behavior that prevents body scrolling while sheet is open.
|
|
42
|
+
* By default, RemoveScroll is enabled when the sheet is open and modal.
|
|
43
|
+
*/
|
|
44
|
+
disableRemoveScroll?: boolean
|
|
45
|
+
|
|
46
|
+
transitionConfig?: AnimatedNumberStrategy
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* By default Sheet will prefer the open prop over a parent component that is
|
|
50
|
+
* controlling it via Adapt. In general if you want to Adapt to a sheet, you'd
|
|
51
|
+
* leave the open prop undefined. If you'd like to have the parent override the
|
|
52
|
+
* prop you've set manually on Sheet, set this to true.
|
|
53
|
+
*/
|
|
54
|
+
preferAdaptParentOpenState?: boolean
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* (experimental) Remove the children while hidden (to save some performance, but can cause issues with animations)
|
|
58
|
+
*/
|
|
59
|
+
unmountChildrenWhenHidden?: boolean
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* By default a fully-closed sheet wrapper is hidden with `display: 'none'`.
|
|
63
|
+
* Set this to keep the closed wrapper laid out (e.g. for native visual effects
|
|
64
|
+
* that cannot initialize below a hidden ancestor). `pointerEvents` still gates
|
|
65
|
+
* interaction while closed.
|
|
66
|
+
*/
|
|
67
|
+
disableHideWhenClosed?: boolean
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Adapts the sheet to use native sheet on the given platform (if available)
|
|
71
|
+
* The iOS system sheet does not expose continuous position, so
|
|
72
|
+
* `Sheet.useAnimatedPosition` and `onTransition` are unavailable in this mode.
|
|
73
|
+
*/
|
|
74
|
+
native?: 'ios'[] | boolean
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Pass if you're using the CSS animation driver
|
|
78
|
+
*/
|
|
79
|
+
transition?: TransitionProp
|
|
80
|
+
handleDisableScroll?: boolean
|
|
81
|
+
disableDrag?: boolean
|
|
82
|
+
modal?: boolean
|
|
83
|
+
zIndex?: number
|
|
84
|
+
portalProps?: PortalProps
|
|
85
|
+
/**
|
|
86
|
+
* Makes the sheet move up when the mobile keyboard opens so the focused input remains visible.
|
|
87
|
+
* Works on native (via keyboard events) and on mobile web (via the VisualViewport API).
|
|
88
|
+
*/
|
|
89
|
+
moveOnKeyboardChange?: boolean
|
|
90
|
+
containerComponent?: React.ComponentType<any>
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Fires at the start and end of the sheet's position transition. `cause` is
|
|
94
|
+
* `open` when moving from closed, `close` when moving off screen, and `snap`
|
|
95
|
+
* when moving between snap points while open. On the `end` phase, `finished`
|
|
96
|
+
* is `false` when the transition was interrupted (e.g. a close canceled by a
|
|
97
|
+
* re-open). `position` is the resolved translateY (px from screen top) target.
|
|
98
|
+
* Available on Tamagui's custom Sheet, not the native iOS system sheet.
|
|
99
|
+
*/
|
|
100
|
+
onTransition?: (e: SheetTransitionEvent) => void
|
|
101
|
+
}>
|
|
102
|
+
|
|
103
|
+
export type SheetTransitionCause = 'open' | 'close' | 'snap'
|
|
104
|
+
|
|
105
|
+
export type SheetTransitionEvent = {
|
|
106
|
+
phase: 'start' | 'end'
|
|
107
|
+
cause: SheetTransitionCause
|
|
108
|
+
position: number
|
|
109
|
+
finished?: boolean
|
|
110
|
+
}
|
|
97
111
|
|
|
98
112
|
export type PositionChangeHandler = (position: number) => void
|
|
99
113
|
|
|
@@ -105,8 +119,6 @@ export type RemoveScrollProps = React.ComponentProps<typeof RemoveScroll>
|
|
|
105
119
|
|
|
106
120
|
export type SnapPointsMode = 'percent' | 'constant' | 'fit' | 'mixed'
|
|
107
121
|
|
|
108
|
-
export type SheetScopedProps<A> = ScopedProps<A, 'Sheet'>
|
|
109
|
-
|
|
110
122
|
export type ScrollBridge = {
|
|
111
123
|
enabled: boolean
|
|
112
124
|
y: number
|
|
@@ -97,10 +97,15 @@ export function useKeyboardControllerSheet(
|
|
|
97
97
|
}
|
|
98
98
|
}, [enabled, keyboardControllerEnabled])
|
|
99
99
|
|
|
100
|
-
//
|
|
100
|
+
// basic Keyboard API listeners, always on: keyboard-controller's events only
|
|
101
|
+
// fire when the app mounts its KeyboardProvider, and `enabled` above only
|
|
102
|
+
// proves the module is linked. an app (or the detox harness, which launches
|
|
103
|
+
// with disableKeyboardController) that skips the provider would otherwise get
|
|
104
|
+
// silently dead keyboard tracking - the sheet never moves and the scroll
|
|
105
|
+
// occlusion padding never applies. RN's Keyboard events always fire, so they
|
|
106
|
+
// are the baseline; when both fire the extra setState is a same-value no-op.
|
|
101
107
|
useEffect(() => {
|
|
102
108
|
if (!enabled) return
|
|
103
|
-
if (keyboardControllerEnabled) return
|
|
104
109
|
|
|
105
110
|
const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow'
|
|
106
111
|
const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide'
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getSafeArea } from '@tamagui/native'
|
|
1
2
|
import * as React from 'react'
|
|
2
3
|
import { SafeAreaInsetsContext as RNSafeAreaInsetsContext } from 'react-native-safe-area-context'
|
|
3
4
|
|
|
@@ -9,21 +10,27 @@ import type { SafeAreaInsets } from './useSafeAreaInsets'
|
|
|
9
10
|
export const SafeAreaInsetsContext =
|
|
10
11
|
RNSafeAreaInsetsContext as unknown as React.Context<SafeAreaInsets | null>
|
|
11
12
|
|
|
13
|
+
const safeArea = getSafeArea()
|
|
14
|
+
|
|
15
|
+
function useContextInsets(): SafeAreaInsets | null {
|
|
16
|
+
return React.useContext(SafeAreaInsetsContext)
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
/**
|
|
13
|
-
*
|
|
14
|
-
* context the app's SafeAreaProvider provides.
|
|
20
|
+
* live safe-area insets (notch / status bar / home indicator).
|
|
15
21
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* native bundles:
|
|
20
|
-
* - `getSafeArea()` (the @tamagui/native abstraction) is frequently NOT enabled
|
|
21
|
-
* against the instance a component reads, so it returns 0.
|
|
22
|
-
* - a dynamic `require('react-native-safe-area-context')` throws "Unknown named
|
|
23
|
-
* module" in metro/rolldown bundles where the package isn't in the importing
|
|
24
|
-
* module's graph.
|
|
25
|
-
* A static import + context read avoids both.
|
|
22
|
+
* setup-safe-area installs a context-to-store feed so every store subscriber
|
|
23
|
+
* sees provider updates. Without that setup, keep the direct context read that
|
|
24
|
+
* lets Sheet work independently.
|
|
26
25
|
*/
|
|
27
26
|
export function useSafeAreaInsets(): SafeAreaInsets | null {
|
|
28
|
-
|
|
27
|
+
const [useFeed] = React.useState(() => safeArea.state.useSafeAreaInsets)
|
|
28
|
+
const contextInsets = (useFeed || useContextInsets)()
|
|
29
|
+
const storeInsets = React.useSyncExternalStore(
|
|
30
|
+
safeArea.subscribe,
|
|
31
|
+
safeArea.getInsets,
|
|
32
|
+
safeArea.getInsets
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return useFeed ? storeInsets : contextInsets
|
|
29
36
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import { createStyledContext, type StyledContext } from '@tamagui/core'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import type { SheetTransitionEvent } from './types'
|
|
5
|
+
|
|
6
|
+
export const useSheetController = (scope?: string) => {
|
|
7
|
+
const controller = SheetControllerContext.useStyledContext(
|
|
8
|
+
scope
|
|
9
|
+
) as SheetControllerContextValue | null
|
|
5
10
|
const isHidden = controller?.hidden
|
|
6
11
|
const isShowingNonSheet = isHidden && controller?.open
|
|
7
12
|
return {
|
|
@@ -12,8 +17,11 @@ export const useSheetController = () => {
|
|
|
12
17
|
}
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
export const SheetControllerContext =
|
|
16
|
-
|
|
20
|
+
export const SheetControllerContext = createStyledContext<SheetControllerContextValue>(
|
|
21
|
+
null as any,
|
|
22
|
+
'SheetController__'
|
|
23
|
+
) as StyledContext<SheetControllerContextValue> &
|
|
24
|
+
React.Context<SheetControllerContextValue | null>
|
|
17
25
|
|
|
18
26
|
export type SheetControllerContextValue = {
|
|
19
27
|
id?: string
|
|
@@ -22,10 +30,10 @@ export type SheetControllerContextValue = {
|
|
|
22
30
|
// hide without "closing" to prevent re-animation when shown again
|
|
23
31
|
hidden?: boolean
|
|
24
32
|
onOpenChange?: React.Dispatch<React.SetStateAction<boolean>> | ((val: boolean) => void)
|
|
25
|
-
// fired by the sheet
|
|
33
|
+
// fired by the sheet at the start/end of its position transition. used by
|
|
26
34
|
// Dialog adapt to know when it's safe to tear down adapted children
|
|
27
35
|
// without cutting off the slide-out mid-animation.
|
|
28
|
-
|
|
36
|
+
onTransition?: (e: SheetTransitionEvent) => void
|
|
29
37
|
// when true, the sheet should skip its open animation (used for adapt handoff)
|
|
30
38
|
skipNextAnimation?: boolean
|
|
31
39
|
}
|
|
@@ -1,19 +1,65 @@
|
|
|
1
|
+
import { useAdaptContext, useAdaptTarget } from '@tamagui/adapt'
|
|
2
|
+
import React from 'react'
|
|
1
3
|
import { useControllableState } from '@tamagui/use-controllable-state'
|
|
2
4
|
|
|
3
5
|
import type { SheetProps } from './types'
|
|
6
|
+
import type { SheetControllerContextValue } from './useSheetController'
|
|
4
7
|
import { useSheetController } from './useSheetController'
|
|
5
8
|
|
|
6
9
|
export const useSheetOpenState = (props: SheetProps) => {
|
|
7
|
-
const
|
|
10
|
+
const adaptContext = useAdaptContext()
|
|
11
|
+
const adapt = useAdaptTarget()
|
|
12
|
+
const { isHidden: controllerIsHidden, controller: legacyController } =
|
|
13
|
+
useSheetController(props.scope)
|
|
14
|
+
const shouldUseAdapt = Boolean(
|
|
15
|
+
adaptContext.open !== undefined || adaptContext.onOpenChange
|
|
16
|
+
)
|
|
17
|
+
// Dialog no longer mounts SheetController while Adapt is inactive, so the
|
|
18
|
+
// hidden state must come from the Adapt parent context even before a target
|
|
19
|
+
// can register through useAdaptTarget().
|
|
20
|
+
const isHidden = shouldUseAdapt ? !adaptContext.active : controllerIsHidden
|
|
21
|
+
const wasHiddenRef = React.useRef(isHidden)
|
|
22
|
+
// when the adapt target is exiting (media flipped off while the dialog stays
|
|
23
|
+
// open), Adapt keeps `active` true so the sheet stays mounted, and signals
|
|
24
|
+
// the close through handoff.hidden: drive the sheet's open state to false so
|
|
25
|
+
// it plays its exit animation and reports onTransition back to Adapt
|
|
26
|
+
const controllerOpen = shouldUseAdapt
|
|
27
|
+
? Boolean(adaptContext.open) && !adaptContext.handoff.hidden
|
|
28
|
+
: legacyController?.open
|
|
29
|
+
const localSkipNextAnimation = Boolean(
|
|
30
|
+
wasHiddenRef.current && !isHidden && controllerOpen
|
|
31
|
+
)
|
|
32
|
+
const skipNextAnimation =
|
|
33
|
+
(shouldUseAdapt ? adapt?.handoff.skipNextAnimation : undefined) ??
|
|
34
|
+
localSkipNextAnimation
|
|
35
|
+
|
|
36
|
+
wasHiddenRef.current = isHidden
|
|
37
|
+
|
|
38
|
+
const adaptController = React.useMemo<SheetControllerContextValue | null>(() => {
|
|
39
|
+
if (!adapt || !shouldUseAdapt) return null
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
open: adaptContext.open,
|
|
43
|
+
hidden: isHidden,
|
|
44
|
+
onOpenChange: adaptContext.active ? adaptContext.onOpenChange : undefined,
|
|
45
|
+
onTransition: adapt?.handoff.onTransition,
|
|
46
|
+
skipNextAnimation,
|
|
47
|
+
}
|
|
48
|
+
}, [adapt, adaptContext, isHidden, shouldUseAdapt, skipNextAnimation])
|
|
49
|
+
|
|
50
|
+
const controller = adaptController ?? legacyController
|
|
51
|
+
const controllerOnOpenChange =
|
|
52
|
+
(shouldUseAdapt && adaptContext.active ? adaptContext.onOpenChange : undefined) ??
|
|
53
|
+
legacyController?.onOpenChange
|
|
8
54
|
|
|
9
55
|
const onOpenChangeInternal = (val: boolean) => {
|
|
10
|
-
|
|
56
|
+
controllerOnOpenChange?.(val)
|
|
11
57
|
props.onOpenChange?.(val)
|
|
12
58
|
}
|
|
13
59
|
|
|
14
60
|
const propVal = props.preferAdaptParentOpenState
|
|
15
|
-
? (
|
|
16
|
-
: (props.open ??
|
|
61
|
+
? (controllerOpen ?? props.open)
|
|
62
|
+
: (props.open ?? controllerOpen)
|
|
17
63
|
|
|
18
64
|
const [open, setOpen] = useControllableState({
|
|
19
65
|
prop: propVal,
|
|
@@ -22,13 +22,7 @@ export type SheetContextValue = ReturnType<typeof useSheetProviderProps> & {
|
|
|
22
22
|
setHasScrollView: (val: boolean) => void
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export function useSheetProviderProps(
|
|
26
|
-
props: SheetProps,
|
|
27
|
-
state: SheetOpenState,
|
|
28
|
-
options: {
|
|
29
|
-
onOverlayComponent?: (comp: any) => void
|
|
30
|
-
} = {}
|
|
31
|
-
) {
|
|
25
|
+
export function useSheetProviderProps(props: SheetProps, state: SheetOpenState) {
|
|
32
26
|
const handleRef = React.useRef<TamaguiElement>(null)
|
|
33
27
|
const contentRef = React.useRef<TamaguiElement>(null)
|
|
34
28
|
const [frameSize, setFrameSize] = React.useState<number>(0)
|
|
@@ -179,23 +173,7 @@ export function useSheetProviderProps(
|
|
|
179
173
|
return bridge
|
|
180
174
|
})
|
|
181
175
|
|
|
182
|
-
|
|
183
|
-
let disableRemoveScroll: boolean | undefined
|
|
184
|
-
if (props.disableRemoveScroll !== undefined) {
|
|
185
|
-
// New prop: disableRemoveScroll={true} means RemoveScroll is disabled
|
|
186
|
-
disableRemoveScroll = props.disableRemoveScroll || !open || !props.modal
|
|
187
|
-
} else if (props.forceRemoveScrollEnabled !== undefined) {
|
|
188
|
-
// Deprecated prop: forceRemoveScrollEnabled can override the default
|
|
189
|
-
if (process.env.NODE_ENV === 'development') {
|
|
190
|
-
console.warn(
|
|
191
|
-
'[Sheet] forceRemoveScrollEnabled is deprecated. Use disableRemoveScroll instead.'
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
disableRemoveScroll = !props.forceRemoveScrollEnabled
|
|
195
|
-
} else {
|
|
196
|
-
// Default: disabled when not open or not modal
|
|
197
|
-
disableRemoveScroll = !open || !props.modal
|
|
198
|
-
}
|
|
176
|
+
const disableRemoveScroll = props.disableRemoveScroll || !open || !props.modal
|
|
199
177
|
|
|
200
178
|
const maxSnapPoint = snapPoints[0]
|
|
201
179
|
const screenSize =
|
|
@@ -218,8 +196,7 @@ export function useSheetProviderProps(
|
|
|
218
196
|
setFrameSize,
|
|
219
197
|
dismissOnOverlayPress: props.dismissOnOverlayPress ?? true,
|
|
220
198
|
dismissOnSnapToBottom: props.dismissOnSnapToBottom ?? false,
|
|
221
|
-
|
|
222
|
-
scope: props.__scopeSheet,
|
|
199
|
+
scope: props.scope ?? '',
|
|
223
200
|
hasFit,
|
|
224
201
|
position,
|
|
225
202
|
snapPoints,
|
|
@@ -227,7 +204,7 @@ export function useSheetProviderProps(
|
|
|
227
204
|
setMaxContentSize,
|
|
228
205
|
setPosition,
|
|
229
206
|
setPositionImmediate,
|
|
230
|
-
|
|
207
|
+
onlyShowContainer: false,
|
|
231
208
|
}
|
|
232
209
|
|
|
233
210
|
return providerProps
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { ScrollViewRef } from '@tamagui/scroll-view'
|
|
1
2
|
import { useEffect, useRef } from 'react'
|
|
2
|
-
import type { ScrollView as RNScrollView } from 'react-native'
|
|
3
3
|
import type { ScrollBridge } from './types'
|
|
4
4
|
|
|
5
5
|
type GestureOwner = 'none' | 'pan' | 'scroll'
|
|
@@ -15,7 +15,7 @@ interface GestureState {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
interface UseSheetScrollViewGesturesProps {
|
|
18
|
-
scrollRef: React.RefObject<
|
|
18
|
+
scrollRef: React.RefObject<ScrollViewRef | null>
|
|
19
19
|
scrollBridge: ScrollBridge
|
|
20
20
|
hasScrollableContent: boolean
|
|
21
21
|
scrollEnabled: boolean
|