@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
|
@@ -5,10 +5,14 @@ import { isWeb, useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
|
5
5
|
import {
|
|
6
6
|
LayoutMeasurementController,
|
|
7
7
|
View as TamaguiView,
|
|
8
|
-
|
|
8
|
+
useAnimationDriver,
|
|
9
|
+
useAnimatedNumber,
|
|
10
|
+
useAnimatedNumberStyle,
|
|
9
11
|
useDidFinishSSR,
|
|
10
12
|
useEvent,
|
|
11
13
|
useThemeName,
|
|
14
|
+
createRefComponent,
|
|
15
|
+
formatDiagnostic,
|
|
12
16
|
} from '@tamagui/core'
|
|
13
17
|
import { needsPortalRepropagation, Portal } from '@tamagui/portal'
|
|
14
18
|
import React, { useState } from 'react'
|
|
@@ -20,6 +24,7 @@ import type {
|
|
|
20
24
|
} from 'react-native'
|
|
21
25
|
import { Dimensions, PanResponder, View } from 'react-native'
|
|
22
26
|
import { ParentSheetContext, SheetInsideSheetContext } from './contexts'
|
|
27
|
+
import { SHEET_OVERLAY_MARKER } from './constants'
|
|
23
28
|
import { GestureDetectorWrapper } from './GestureDetectorWrapper'
|
|
24
29
|
import { getGestureHandlerState } from './gestureState'
|
|
25
30
|
import { GestureSheetProvider } from './GestureSheetContext'
|
|
@@ -36,8 +41,17 @@ import {
|
|
|
36
41
|
getWebVisualViewportOffsetTop,
|
|
37
42
|
MIN_KEYBOARD_HEIGHT,
|
|
38
43
|
} from './webViewport'
|
|
39
|
-
import {
|
|
40
|
-
|
|
44
|
+
import {
|
|
45
|
+
SheetAnimatedPositionContext,
|
|
46
|
+
SheetOverlayLayerContext,
|
|
47
|
+
SheetProvider,
|
|
48
|
+
} from './SheetContext'
|
|
49
|
+
import type {
|
|
50
|
+
SheetProps,
|
|
51
|
+
SheetTransitionCause,
|
|
52
|
+
SheetTransitionEvent,
|
|
53
|
+
SnapPointsMode,
|
|
54
|
+
} from './types'
|
|
41
55
|
import { useGestureHandlerPan } from './useGestureHandlerPan'
|
|
42
56
|
import { useKeyboardControllerSheet } from './useKeyboardControllerSheet'
|
|
43
57
|
import { SafeAreaInsetsContext, useSafeAreaInsets } from './useSafeAreaInsets'
|
|
@@ -56,6 +70,11 @@ const rnghRootStyleClosed = { width: '100%', height: 0 } as const
|
|
|
56
70
|
|
|
57
71
|
let sheetHiddenStyleSheet: HTMLStyleElement | null = null
|
|
58
72
|
|
|
73
|
+
// stack of open modal sheets on web so escape only closes the top-most one.
|
|
74
|
+
// pushed on open (child sheets mount their effect after the parent, so the
|
|
75
|
+
// deepest sheet sits last), popped on close/unmount.
|
|
76
|
+
const sheetEscapeLayers: object[] = []
|
|
77
|
+
|
|
59
78
|
// on web we are always relative to window, on to screen
|
|
60
79
|
const relativeDimensionTo = isWeb ? 'window' : 'screen'
|
|
61
80
|
|
|
@@ -72,7 +91,7 @@ function getStableViewportHeight(): number {
|
|
|
72
91
|
return Dimensions.get(relativeDimensionTo).height
|
|
73
92
|
}
|
|
74
93
|
|
|
75
|
-
export const SheetImplementationCustom =
|
|
94
|
+
export const SheetImplementationCustom = createRefComponent<View, SheetProps>(
|
|
76
95
|
function SheetImplementationCustom(props, forwardedRef) {
|
|
77
96
|
const parentSheet = React.useContext(ParentSheetContext)
|
|
78
97
|
|
|
@@ -93,18 +112,15 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
93
112
|
zIndex = parentSheet.zIndex + 1,
|
|
94
113
|
moveOnKeyboardChange = false,
|
|
95
114
|
unmountChildrenWhenHidden = false,
|
|
96
|
-
|
|
115
|
+
disableHideWhenClosed = false,
|
|
97
116
|
portalProps,
|
|
98
117
|
containerComponent: ContainerComponent = React.Fragment,
|
|
99
|
-
|
|
118
|
+
onTransition,
|
|
100
119
|
} = props
|
|
101
120
|
|
|
102
121
|
const state = useSheetOpenState(props)
|
|
103
|
-
const [overlayComponent, setOverlayComponent] = React.useState<React.ReactNode>(null)
|
|
104
122
|
|
|
105
|
-
const providerProps = useSheetProviderProps(props, state
|
|
106
|
-
onOverlayComponent: setOverlayComponent,
|
|
107
|
-
})
|
|
123
|
+
const providerProps = useSheetProviderProps(props, state)
|
|
108
124
|
const {
|
|
109
125
|
frameSize,
|
|
110
126
|
setFrameSize,
|
|
@@ -126,12 +142,7 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
126
142
|
const sheetRef = React.useRef<View>(undefined as unknown as View)
|
|
127
143
|
const ref = useComposedRefs(forwardedRef, sheetRef, providerProps.contentRef as any)
|
|
128
144
|
|
|
129
|
-
|
|
130
|
-
const { animationDriver } = useConfiguration()
|
|
131
|
-
|
|
132
|
-
if (!animationDriver) {
|
|
133
|
-
throw new Error(`Sheet requires an animation driver to be set`)
|
|
134
|
-
}
|
|
145
|
+
const animationDriver = useAnimationDriver()
|
|
135
146
|
|
|
136
147
|
const transitionConfig = (() => {
|
|
137
148
|
// explicit transitionConfig prop always takes precedence
|
|
@@ -146,9 +157,17 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
146
157
|
: ([transition] as const)
|
|
147
158
|
|
|
148
159
|
// look up named animation config from driver if available
|
|
149
|
-
|
|
160
|
+
const namedConfig =
|
|
161
|
+
animationProp && animationDriver.animations?.[animationProp as string]
|
|
162
|
+
if (namedConfig) {
|
|
163
|
+
// css stores string configs (e.g. '150ms ease-out'); object-spreading a
|
|
164
|
+
// string produces char-indexed junk. the css visual is driven by the DOM
|
|
165
|
+
// `transition` prop, so pass only any explicit override object through.
|
|
166
|
+
if (typeof namedConfig === 'string') {
|
|
167
|
+
return animationPropConfig ?? null
|
|
168
|
+
}
|
|
150
169
|
return {
|
|
151
|
-
...
|
|
170
|
+
...namedConfig,
|
|
152
171
|
...animationPropConfig,
|
|
153
172
|
}
|
|
154
173
|
}
|
|
@@ -334,7 +353,6 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
334
353
|
? preKeyboardFrameSize.current
|
|
335
354
|
: 0
|
|
336
355
|
|
|
337
|
-
const { useAnimatedNumber, useAnimatedNumberStyle } = animationDriver
|
|
338
356
|
const AnimatedView = (animationDriver.View ?? TamaguiView) as typeof Animated.View
|
|
339
357
|
|
|
340
358
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -367,8 +385,31 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
367
385
|
|
|
368
386
|
const hasScrollView = React.useRef(false)
|
|
369
387
|
|
|
370
|
-
//
|
|
371
|
-
|
|
388
|
+
// snap index of the last animated move, so a transition can be classified
|
|
389
|
+
// as open (from closed), snap (between snap points), or close.
|
|
390
|
+
const lastPositionIndexRef = React.useRef(-1)
|
|
391
|
+
// the in-flight transition, so a superseding move reports it interrupted.
|
|
392
|
+
const pendingTransitionRef = React.useRef<{
|
|
393
|
+
cause: SheetTransitionCause
|
|
394
|
+
position: number
|
|
395
|
+
} | null>(null)
|
|
396
|
+
|
|
397
|
+
const emitTransition = useEvent(
|
|
398
|
+
(
|
|
399
|
+
phase: 'start' | 'end',
|
|
400
|
+
event: { cause: SheetTransitionCause; position: number },
|
|
401
|
+
finished?: boolean
|
|
402
|
+
) => {
|
|
403
|
+
const e: SheetTransitionEvent = {
|
|
404
|
+
phase,
|
|
405
|
+
cause: event.cause,
|
|
406
|
+
position: event.position,
|
|
407
|
+
}
|
|
408
|
+
if (phase === 'end') e.finished = finished
|
|
409
|
+
onTransition?.(e)
|
|
410
|
+
controller?.onTransition?.(e)
|
|
411
|
+
}
|
|
412
|
+
)
|
|
372
413
|
|
|
373
414
|
const syncAnimatedPosition = useEvent((value: number) => {
|
|
374
415
|
at.current = value
|
|
@@ -440,21 +481,54 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
440
481
|
const closeTarget = isWeb
|
|
441
482
|
? Math.max(effScreenSize, getMaxViewportHeight())
|
|
442
483
|
: effScreenSize
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
484
|
+
// dismissOnSnapToBottom appends an offscreen snap point. Gesture release
|
|
485
|
+
// calls setPosition(dismissIndex) and animateTo(dismissIndex) in the same
|
|
486
|
+
// event, before React commits open=false and turns the provider position
|
|
487
|
+
// into -1. Treat that synthetic snap as close here so its in-flight
|
|
488
|
+
// callback owns display-none hiding and the Adapt presence handoff.
|
|
489
|
+
const isDismissPosition =
|
|
490
|
+
dismissOnSnapToBottom && position === activePositions.length - 1
|
|
491
|
+
const isOpenAnimation = position !== -1 && !isHidden && !isDismissPosition
|
|
492
|
+
const toValue = isOpenAnimation ? activePositions[position] : closeTarget
|
|
493
|
+
|
|
494
|
+
if (at.current === toValue) {
|
|
495
|
+
// a drag can land exactly on the synthetic dismiss point. there is no
|
|
496
|
+
// remaining distance to animate, but it is still a completed close and
|
|
497
|
+
// must release the same lifecycle consumers as an animated dismissal.
|
|
498
|
+
if (isDismissPosition) {
|
|
499
|
+
if (pendingTransitionRef.current) {
|
|
500
|
+
emitTransition('end', pendingTransitionRef.current, false)
|
|
501
|
+
pendingTransitionRef.current = null
|
|
502
|
+
}
|
|
503
|
+
stopSpring()
|
|
504
|
+
const event = { cause: 'close' as const, position: toValue }
|
|
505
|
+
lastPositionIndexRef.current = -1
|
|
506
|
+
emitTransition('start', event)
|
|
507
|
+
syncAnimatedPosition(toValue)
|
|
508
|
+
setIsFullyClosed(true)
|
|
509
|
+
emitTransition('end', event, true)
|
|
510
|
+
}
|
|
511
|
+
return
|
|
512
|
+
}
|
|
446
513
|
|
|
447
514
|
at.current = toValue
|
|
448
|
-
stopSpring()
|
|
449
515
|
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
516
|
+
const cause: SheetTransitionCause = !isOpenAnimation
|
|
517
|
+
? 'close'
|
|
518
|
+
: lastPositionIndexRef.current < 0
|
|
519
|
+
? 'open'
|
|
520
|
+
: 'snap'
|
|
521
|
+
lastPositionIndexRef.current = isOpenAnimation ? position : -1
|
|
522
|
+
const event = { cause, position: toValue }
|
|
523
|
+
|
|
524
|
+
// a new move supersedes any in-flight one: report it interrupted
|
|
525
|
+
if (pendingTransitionRef.current) {
|
|
526
|
+
emitTransition('end', pendingTransitionRef.current, false)
|
|
527
|
+
pendingTransitionRef.current = null
|
|
456
528
|
}
|
|
457
529
|
|
|
530
|
+
stopSpring()
|
|
531
|
+
|
|
458
532
|
const animationCompleteCallback = () => {
|
|
459
533
|
// a newer animateTo supersedes this one: drivers still fire the owed
|
|
460
534
|
// completion callback when a new setValue replaces an in-flight one.
|
|
@@ -462,34 +536,22 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
462
536
|
// this stale toValue would make the next animateTo to this position
|
|
463
537
|
// no-op (at === toValue) while the dom sits somewhere else — on web
|
|
464
538
|
// that leaves a reopened sheet parked offscreen at its close target.
|
|
539
|
+
// it would also null out the superseding move's pending transition
|
|
540
|
+
// and double-emit a completed end for an already-interrupted event.
|
|
465
541
|
if (at.current !== toValue) return
|
|
466
542
|
syncAnimatedPosition(toValue)
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
// use openRef (live) not open (stale closure) — if the sheet
|
|
472
|
-
// was reopened before this callback fires (e.g. cancelled close
|
|
473
|
-
// animation), we must not hide it
|
|
543
|
+
pendingTransitionRef.current = null
|
|
544
|
+
// use openRef (live) not open (stale closure) — if the sheet was
|
|
545
|
+
// reopened before this callback fires (e.g. cancelled close animation),
|
|
546
|
+
// we must not hide it
|
|
474
547
|
if (!isOpenAnimation && !openRef.current) {
|
|
475
|
-
|
|
548
|
+
setIsFullyClosed(true)
|
|
476
549
|
}
|
|
477
|
-
|
|
478
|
-
// also notify the SheetController so a parent (e.g. Dialog adapt)
|
|
479
|
-
// can hold the sheet's children mounted until the slide-out is done
|
|
480
|
-
controller?.onAnimationComplete?.({ open: isOpenAnimation })
|
|
550
|
+
emitTransition('end', event, true)
|
|
481
551
|
}
|
|
482
552
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
opacityFallbackTimer.current = setTimeout(() => {
|
|
486
|
-
opacityFallbackTimer.current = null
|
|
487
|
-
// check live open state via ref — sheet may have reopened (e.g. adapt handoff)
|
|
488
|
-
if (!openRef.current) {
|
|
489
|
-
setOpacity(0)
|
|
490
|
-
}
|
|
491
|
-
}, 1000)
|
|
492
|
-
}
|
|
553
|
+
pendingTransitionRef.current = event
|
|
554
|
+
emitTransition('start', event)
|
|
493
555
|
|
|
494
556
|
// skip animation when adapting from dialog to sheet
|
|
495
557
|
if (skipAdaptAnimation.current) {
|
|
@@ -502,14 +564,32 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
502
564
|
return
|
|
503
565
|
}
|
|
504
566
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
)
|
|
567
|
+
const resolvedConfig = animationOverride || {
|
|
568
|
+
type: 'spring',
|
|
569
|
+
...transitionConfig,
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// the sheet position spring moves hundreds of px. the spring drivers'
|
|
573
|
+
// default rest detection is tuned for tiny values (react-native Animated:
|
|
574
|
+
// 0.001px thresholds; reanimated 4: relative energyThreshold 6e-9), so for
|
|
575
|
+
// a sheet-sized move completion would fire 1.4-1.7s after the animation is
|
|
576
|
+
// visually done. these px-sized rest thresholds make close-complete prompt
|
|
577
|
+
// (~0.5-0.8s), which is what now drives display:none hiding and the Adapt
|
|
578
|
+
// presence release (no timers). user config still wins via spread order;
|
|
579
|
+
// each driver ignores the other driver's keys.
|
|
580
|
+
const springConfig =
|
|
581
|
+
!resolvedConfig.type || resolvedConfig.type === 'spring'
|
|
582
|
+
? {
|
|
583
|
+
// react-native Animated (absolute px)
|
|
584
|
+
restDisplacementThreshold: 1,
|
|
585
|
+
restSpeedThreshold: 10,
|
|
586
|
+
// reanimated 4 (relative energy): ~0.3% of travel amplitude
|
|
587
|
+
energyThreshold: 1e-5,
|
|
588
|
+
...resolvedConfig,
|
|
589
|
+
}
|
|
590
|
+
: resolvedConfig
|
|
591
|
+
|
|
592
|
+
animatedNumber.setValue(toValue, springConfig, animationCompleteCallback)
|
|
513
593
|
})
|
|
514
594
|
|
|
515
595
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -833,6 +913,32 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
833
913
|
}
|
|
834
914
|
}, [open])
|
|
835
915
|
|
|
916
|
+
React.useEffect(() => {
|
|
917
|
+
if (!isWeb || !modal || !open || shouldHideParentSheet) return
|
|
918
|
+
|
|
919
|
+
const layer = {}
|
|
920
|
+
sheetEscapeLayers.push(layer)
|
|
921
|
+
|
|
922
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
923
|
+
if (event.key === 'Escape') {
|
|
924
|
+
// only the top-most open modal sheet responds so a nested sheet
|
|
925
|
+
// doesn't take its parent down with it
|
|
926
|
+
if (sheetEscapeLayers[sheetEscapeLayers.length - 1] === layer) {
|
|
927
|
+
state.setOpen(false)
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
document.addEventListener('keydown', onKeyDown)
|
|
933
|
+
return () => {
|
|
934
|
+
const index = sheetEscapeLayers.indexOf(layer)
|
|
935
|
+
if (index > -1) {
|
|
936
|
+
sheetEscapeLayers.splice(index, 1)
|
|
937
|
+
}
|
|
938
|
+
document.removeEventListener('keydown', onKeyDown)
|
|
939
|
+
}
|
|
940
|
+
}, [modal, open, shouldHideParentSheet, state.setOpen])
|
|
941
|
+
|
|
836
942
|
// gesture handler hook for RNGH-based gesture coordination
|
|
837
943
|
const { panGesture, panGestureRef, gestureHandlerEnabled } = useGestureHandlerPan({
|
|
838
944
|
positions: activePositions,
|
|
@@ -923,17 +1029,32 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
923
1029
|
|
|
924
1030
|
const animatedStyle = useAnimatedNumberStyle(animatedNumber, getAnimatedNumberStyle)
|
|
925
1031
|
|
|
926
|
-
//
|
|
927
|
-
//
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1032
|
+
// a fully-closed sheet is hidden with display:none (set from the
|
|
1033
|
+
// close-complete transition event) so it never overlaps the page when
|
|
1034
|
+
// resizing quickly on web. it starts NOT hidden — the frame must be laid
|
|
1035
|
+
// out to measure its size (display:none has no layout box, so hiding before
|
|
1036
|
+
// the first measurement would leave frameSize/screenSize at 0). it un-hides
|
|
1037
|
+
// synchronously in render on re-open, before layout, keeping the retained
|
|
1038
|
+
// frame size. the closed-but-never-opened frame stays off screen via its
|
|
1039
|
+
// translateY, so leaving it laid out is not visible.
|
|
1040
|
+
const [isFullyClosed, setIsFullyClosed] = React.useState(false)
|
|
1041
|
+
if (open && isFullyClosed) {
|
|
1042
|
+
setIsFullyClosed(false)
|
|
1043
|
+
}
|
|
1044
|
+
// whether the sheet is visually active: open, or still animating out.
|
|
1045
|
+
// isFullyClosed only flips true from the close-animation-complete callback,
|
|
1046
|
+
// so it stays false for a mounted-but-never-opened sheet - track first open
|
|
1047
|
+
// separately so a closed sheet is inactive from mount. drives the portal
|
|
1048
|
+
// host's visibility (see Portal.tsx on why closed hosts must be hidden).
|
|
1049
|
+
const hasEverOpened = React.useRef(open)
|
|
1050
|
+
if (open) {
|
|
1051
|
+
hasEverOpened.current = true
|
|
936
1052
|
}
|
|
1053
|
+
const isVisuallyActive = open || (hasEverOpened.current && !isFullyClosed)
|
|
1054
|
+
// shouldHideParentSheet (a nested sheet on native gorhom) hides the parent
|
|
1055
|
+
// immediately; disableHideWhenClosed opts the closed wrapper out of hiding
|
|
1056
|
+
// but never overrides the nested-sheet hide.
|
|
1057
|
+
const applyHidden = shouldHideParentSheet || (isFullyClosed && !disableHideWhenClosed)
|
|
937
1058
|
|
|
938
1059
|
const forcedContentHeight = hasFit
|
|
939
1060
|
? undefined
|
|
@@ -945,12 +1066,25 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
945
1066
|
const setHasScrollView = React.useCallback((val: boolean) => {
|
|
946
1067
|
hasScrollView.current = val
|
|
947
1068
|
}, [])
|
|
948
|
-
// const id = useId()
|
|
949
|
-
// const { AdaptProvider, when, children } = useAdaptParent({
|
|
950
|
-
// scope: `${id}Sheet`,
|
|
951
|
-
// portal: true,
|
|
952
|
-
// })
|
|
953
1069
|
|
|
1070
|
+
// publish the live animated position so user code can build drag-linked
|
|
1071
|
+
// effects (e.g. an overlay fade) via Sheet.useAnimatedPosition(). positions
|
|
1072
|
+
// are the resolved px offsets matching snapPoints order; minY is topmost.
|
|
1073
|
+
const animatedPositionValue = React.useMemo(
|
|
1074
|
+
() => ({
|
|
1075
|
+
value: animatedNumber,
|
|
1076
|
+
screenSize: effScreenSize,
|
|
1077
|
+
frameSize,
|
|
1078
|
+
snapOffsets: activePositions,
|
|
1079
|
+
minY: activePositions[0] ?? 0,
|
|
1080
|
+
}),
|
|
1081
|
+
[animatedNumber, effScreenSize, frameSize, activePositions]
|
|
1082
|
+
)
|
|
1083
|
+
|
|
1084
|
+
const { overlayChildren, animatedChildren } = React.useMemo(
|
|
1085
|
+
() => partitionSheetChildren(props.children),
|
|
1086
|
+
[props.children]
|
|
1087
|
+
)
|
|
954
1088
|
let contents = (
|
|
955
1089
|
<LayoutMeasurementController disable={!open}>
|
|
956
1090
|
<ParentSheetContext.Provider value={nextParentContext}>
|
|
@@ -968,66 +1102,66 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
968
1102
|
panGesture={panGesture}
|
|
969
1103
|
panGestureRef={panGestureRef}
|
|
970
1104
|
>
|
|
971
|
-
<
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
position: 'absolute',
|
|
980
|
-
top: 0,
|
|
981
|
-
left: 0,
|
|
982
|
-
right: 0,
|
|
983
|
-
bottom: 0,
|
|
984
|
-
pointerEvents: 'none',
|
|
985
|
-
}}
|
|
986
|
-
onLayout={handleMaxContentViewLayout}
|
|
987
|
-
/>
|
|
988
|
-
)}
|
|
989
|
-
|
|
990
|
-
<AnimatedView
|
|
991
|
-
ref={ref}
|
|
992
|
-
onLayout={handleAnimationViewLayout}
|
|
993
|
-
// @ts-ignore for CSS driver this is necessary to attach the transition
|
|
994
|
-
// also motion driver at least though i suspect all drivers?
|
|
995
|
-
transition={isDragging || disableAnimation ? null : transition}
|
|
996
|
-
// @ts-ignore
|
|
997
|
-
disableClassName
|
|
998
|
-
style={[
|
|
999
|
-
{
|
|
1000
|
-
position: 'absolute',
|
|
1001
|
-
zIndex,
|
|
1002
|
-
width: '100%',
|
|
1003
|
-
height: forcedContentHeight,
|
|
1004
|
-
minHeight: forcedContentHeight,
|
|
1005
|
-
opacity: shouldHideParentSheet
|
|
1006
|
-
? 0
|
|
1007
|
-
: disableTransparencyHide
|
|
1008
|
-
? 1
|
|
1009
|
-
: opacity,
|
|
1010
|
-
...((shouldHideParentSheet || !open) && {
|
|
1011
|
-
pointerEvents: 'none',
|
|
1012
|
-
}),
|
|
1013
|
-
},
|
|
1014
|
-
animatedStyle,
|
|
1015
|
-
]}
|
|
1016
|
-
>
|
|
1017
|
-
{/* wrap children with plain RN View for panResponder - tamagui views no longer handle responder events on web */}
|
|
1018
|
-
{gestureHandlerEnabled && panGesture ? (
|
|
1019
|
-
<GestureDetectorWrapper gesture={panGesture} style={{ flex: 1 }}>
|
|
1020
|
-
{props.children}
|
|
1021
|
-
</GestureDetectorWrapper>
|
|
1022
|
-
) : (
|
|
1105
|
+
<SheetAnimatedPositionContext.Provider value={animatedPositionValue}>
|
|
1106
|
+
<SheetOverlayLayerContext.Provider value>
|
|
1107
|
+
<AnimatePresence custom={{ open }}>
|
|
1108
|
+
{shouldHideParentSheet || !open ? null : overlayChildren}
|
|
1109
|
+
</AnimatePresence>
|
|
1110
|
+
</SheetOverlayLayerContext.Provider>
|
|
1111
|
+
|
|
1112
|
+
{snapPointsMode !== 'percent' && (
|
|
1023
1113
|
<View
|
|
1024
|
-
{
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1114
|
+
style={{
|
|
1115
|
+
opacity: 0,
|
|
1116
|
+
position: 'absolute',
|
|
1117
|
+
top: 0,
|
|
1118
|
+
left: 0,
|
|
1119
|
+
right: 0,
|
|
1120
|
+
bottom: 0,
|
|
1121
|
+
pointerEvents: 'none',
|
|
1122
|
+
}}
|
|
1123
|
+
onLayout={handleMaxContentViewLayout}
|
|
1124
|
+
/>
|
|
1029
1125
|
)}
|
|
1030
|
-
|
|
1126
|
+
|
|
1127
|
+
<AnimatedView
|
|
1128
|
+
ref={ref}
|
|
1129
|
+
onLayout={handleAnimationViewLayout}
|
|
1130
|
+
// @ts-ignore for CSS driver this is necessary to attach the transition
|
|
1131
|
+
// also motion driver at least though i suspect all drivers?
|
|
1132
|
+
transition={isDragging || disableAnimation ? null : transition}
|
|
1133
|
+
// @ts-ignore
|
|
1134
|
+
disableClassName
|
|
1135
|
+
style={[
|
|
1136
|
+
{
|
|
1137
|
+
position: 'absolute',
|
|
1138
|
+
zIndex,
|
|
1139
|
+
width: '100%',
|
|
1140
|
+
height: forcedContentHeight,
|
|
1141
|
+
minHeight: forcedContentHeight,
|
|
1142
|
+
...(applyHidden && { display: 'none' }),
|
|
1143
|
+
...((shouldHideParentSheet || !open) && {
|
|
1144
|
+
pointerEvents: 'none',
|
|
1145
|
+
}),
|
|
1146
|
+
},
|
|
1147
|
+
animatedStyle,
|
|
1148
|
+
]}
|
|
1149
|
+
>
|
|
1150
|
+
{/* wrap children with plain RN View for panResponder - tamagui views no longer handle responder events on web */}
|
|
1151
|
+
{gestureHandlerEnabled && panGesture ? (
|
|
1152
|
+
<GestureDetectorWrapper gesture={panGesture} style={{ flex: 1 }}>
|
|
1153
|
+
{animatedChildren}
|
|
1154
|
+
</GestureDetectorWrapper>
|
|
1155
|
+
) : (
|
|
1156
|
+
<View
|
|
1157
|
+
{...panResponder?.panHandlers}
|
|
1158
|
+
style={{ flex: 1, width: '100%', height: '100%' }}
|
|
1159
|
+
>
|
|
1160
|
+
{animatedChildren}
|
|
1161
|
+
</View>
|
|
1162
|
+
)}
|
|
1163
|
+
</AnimatedView>
|
|
1164
|
+
</SheetAnimatedPositionContext.Provider>
|
|
1031
1165
|
</GestureSheetProvider>
|
|
1032
1166
|
</SheetProvider>
|
|
1033
1167
|
</ParentSheetContext.Provider>
|
|
@@ -1035,7 +1169,6 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
1035
1169
|
)
|
|
1036
1170
|
|
|
1037
1171
|
if (process.env.TAMAGUI_TARGET === 'native' && needsPortalRepropagation()) {
|
|
1038
|
-
// TODO alongside sheet scope="" need to pass scope here
|
|
1039
1172
|
const adaptContext = useAdaptContext()
|
|
1040
1173
|
contents = (
|
|
1041
1174
|
<ProvideAdaptContext {...adaptContext}>
|
|
@@ -1051,7 +1184,7 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
1051
1184
|
}
|
|
1052
1185
|
|
|
1053
1186
|
// start mounted so we get an accurate measurement the first time
|
|
1054
|
-
const shouldMountChildren = unmountChildrenWhenHidden ?
|
|
1187
|
+
const shouldMountChildren = unmountChildrenWhenHidden ? !isFullyClosed : true
|
|
1055
1188
|
|
|
1056
1189
|
if (modal) {
|
|
1057
1190
|
// a modal sheet is teleported through <Portal> to the root portal host.
|
|
@@ -1071,7 +1204,7 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
1071
1204
|
<ContainerComponent>{contents}</ContainerComponent>
|
|
1072
1205
|
) : null
|
|
1073
1206
|
const modalContents = (
|
|
1074
|
-
<Portal stackZIndex={zIndex} {...portalProps}>
|
|
1207
|
+
<Portal stackZIndex={zIndex} hidden={!isVisuallyActive} {...portalProps}>
|
|
1075
1208
|
{mountedContents && RNGHRoot ? (
|
|
1076
1209
|
<RNGHRoot style={open ? rnghRootStyleOpen : rnghRootStyleClosed}>
|
|
1077
1210
|
{mountedContents}
|
|
@@ -1098,6 +1231,49 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
1098
1231
|
}
|
|
1099
1232
|
)
|
|
1100
1233
|
|
|
1234
|
+
type SheetPartStaticConfig = {
|
|
1235
|
+
[SHEET_OVERLAY_MARKER]?: boolean
|
|
1236
|
+
parentStaticConfig?: SheetPartStaticConfig
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
export function isSheetOverlayComponent(type: unknown) {
|
|
1240
|
+
let staticConfig = (type as { staticConfig?: SheetPartStaticConfig } | null)
|
|
1241
|
+
?.staticConfig
|
|
1242
|
+
|
|
1243
|
+
while (staticConfig) {
|
|
1244
|
+
if (staticConfig[SHEET_OVERLAY_MARKER]) {
|
|
1245
|
+
return true
|
|
1246
|
+
}
|
|
1247
|
+
staticConfig = staticConfig.parentStaticConfig
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
return false
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
function partitionSheetChildren(children: React.ReactNode) {
|
|
1254
|
+
const overlayChildren: React.ReactNode[] = []
|
|
1255
|
+
const animatedChildren: React.ReactNode[] = []
|
|
1256
|
+
|
|
1257
|
+
React.Children.forEach(children, (child) => {
|
|
1258
|
+
if (!React.isValidElement(child)) {
|
|
1259
|
+
animatedChildren.push(child)
|
|
1260
|
+
return
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
if (isSheetOverlayComponent(child.type)) {
|
|
1264
|
+
overlayChildren.push(child)
|
|
1265
|
+
return
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
animatedChildren.push(child)
|
|
1269
|
+
})
|
|
1270
|
+
|
|
1271
|
+
return {
|
|
1272
|
+
overlayChildren,
|
|
1273
|
+
animatedChildren,
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1101
1277
|
function getYPositions(
|
|
1102
1278
|
mode: SnapPointsMode,
|
|
1103
1279
|
point: string | number,
|
|
@@ -1118,12 +1294,30 @@ function getYPositions(
|
|
|
1118
1294
|
if (point.endsWith('%')) {
|
|
1119
1295
|
const pct = Math.min(100, Math.max(0, Number(point.slice(0, -1)))) / 100
|
|
1120
1296
|
if (Number.isNaN(pct)) {
|
|
1121
|
-
console.warn(
|
|
1297
|
+
console.warn(
|
|
1298
|
+
formatDiagnostic(
|
|
1299
|
+
'TAMAGUI_SHEET_SNAP_POINT',
|
|
1300
|
+
'Sheet',
|
|
1301
|
+
'snapPoints contains an invalid percentage string',
|
|
1302
|
+
'Use "fit", a pixel number, or a percentage such as "50%"',
|
|
1303
|
+
'snapPoint',
|
|
1304
|
+
point
|
|
1305
|
+
)
|
|
1306
|
+
)
|
|
1122
1307
|
return 0
|
|
1123
1308
|
}
|
|
1124
1309
|
return Math.round(screenSize - pct * screenSize)
|
|
1125
1310
|
}
|
|
1126
|
-
console.warn(
|
|
1311
|
+
console.warn(
|
|
1312
|
+
formatDiagnostic(
|
|
1313
|
+
'TAMAGUI_SHEET_SNAP_POINT',
|
|
1314
|
+
'Sheet',
|
|
1315
|
+
'snapPoints contains an unsupported mixed-mode value',
|
|
1316
|
+
'Use "fit", a pixel number, or a percentage such as "50%"',
|
|
1317
|
+
'snapPoint',
|
|
1318
|
+
point
|
|
1319
|
+
)
|
|
1320
|
+
)
|
|
1127
1321
|
return 0
|
|
1128
1322
|
}
|
|
1129
1323
|
|
|
@@ -1138,7 +1332,16 @@ function getYPositions(
|
|
|
1138
1332
|
|
|
1139
1333
|
const pct = Math.min(100, Math.max(0, Number(point))) / 100
|
|
1140
1334
|
if (Number.isNaN(pct)) {
|
|
1141
|
-
console.warn(
|
|
1335
|
+
console.warn(
|
|
1336
|
+
formatDiagnostic(
|
|
1337
|
+
'TAMAGUI_SHEET_SNAP_POINT',
|
|
1338
|
+
'Sheet',
|
|
1339
|
+
'snapPoints contains a value that cannot be converted to a percentage',
|
|
1340
|
+
'Use a numeric percentage such as 50',
|
|
1341
|
+
'snapPoint',
|
|
1342
|
+
point
|
|
1343
|
+
)
|
|
1344
|
+
)
|
|
1142
1345
|
return 0
|
|
1143
1346
|
}
|
|
1144
1347
|
|