@tamagui/sheet 2.7.7 → 3.0.0-beta.1091.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/GestureSheetContext.cjs +28 -37
- package/dist/cjs/GestureSheetContext.native.cjs +48 -0
- package/dist/cjs/GestureSheetContext.native.js +29 -37
- package/dist/cjs/GestureSheetContext.native.js.map +1 -1
- package/dist/cjs/Sheet.cjs +220 -99
- package/dist/cjs/Sheet.native.cjs +245 -0
- package/dist/cjs/Sheet.native.js +223 -98
- package/dist/cjs/Sheet.native.js.map +1 -1
- package/dist/cjs/SheetContext.cjs +43 -22
- package/dist/cjs/SheetContext.native.cjs +57 -0
- package/dist/cjs/SheetContext.native.js +44 -22
- package/dist/cjs/SheetContext.native.js.map +1 -1
- package/dist/cjs/SheetController.cjs +49 -56
- package/dist/cjs/SheetController.native.cjs +71 -0
- package/dist/cjs/SheetController.native.js +52 -58
- package/dist/cjs/SheetController.native.js.map +1 -1
- package/dist/cjs/SheetDragSurface.cjs +50 -0
- package/dist/cjs/SheetDragSurface.native.cjs +61 -0
- package/dist/cjs/SheetDragSurface.native.js +63 -0
- package/dist/cjs/SheetDragSurface.native.js.map +1 -0
- package/dist/cjs/SheetImplementationCustom.cjs +664 -610
- package/dist/cjs/SheetImplementationCustom.native.cjs +748 -0
- package/dist/cjs/SheetImplementationCustom.native.js +704 -649
- 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 +21 -21
- package/dist/cjs/constants.native.cjs +36 -0
- package/dist/cjs/constants.native.js +21 -20
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/contexts.cjs +19 -28
- package/dist/cjs/contexts.native.cjs +37 -0
- package/dist/cjs/contexts.native.js +19 -27
- package/dist/cjs/contexts.native.js.map +1 -1
- package/dist/cjs/controller.cjs +16 -18
- package/dist/cjs/controller.native.cjs +31 -0
- package/dist/cjs/controller.native.js +16 -17
- package/dist/cjs/controller.native.js.map +1 -1
- package/dist/cjs/gestureState.cjs +28 -30
- package/dist/cjs/gestureState.native.cjs +53 -0
- package/dist/cjs/gestureState.native.js +29 -30
- package/dist/cjs/gestureState.native.js.map +1 -1
- package/dist/cjs/helpers.cjs +20 -24
- package/dist/cjs/helpers.native.cjs +34 -0
- package/dist/cjs/helpers.native.js +21 -24
- package/dist/cjs/helpers.native.js.map +1 -1
- package/dist/cjs/index.cjs +14 -21
- package/dist/cjs/index.native.cjs +36 -0
- package/dist/cjs/index.native.js +15 -21
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/keyboardAvoidance.cjs +55 -79
- package/dist/cjs/keyboardAvoidance.native.cjs +74 -0
- package/dist/cjs/keyboardAvoidance.native.js +55 -78
- package/dist/cjs/keyboardAvoidance.native.js.map +1 -1
- package/dist/cjs/nativeSheet.cjs +17 -86
- package/dist/cjs/nativeSheet.native.cjs +94 -0
- package/dist/cjs/nativeSheet.native.js +73 -86
- package/dist/cjs/nativeSheet.native.js.map +1 -1
- package/dist/cjs/stableViewportHeight.cjs +27 -0
- package/dist/cjs/stableViewportHeight.native.cjs +29 -0
- package/dist/cjs/stableViewportHeight.native.js +31 -0
- package/dist/cjs/stableViewportHeight.native.js.map +1 -0
- package/dist/cjs/types.cjs +9 -11
- package/dist/cjs/types.native.cjs +18 -0
- package/dist/cjs/types.native.js +9 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/useGestureHandlerPan.cjs +244 -257
- package/dist/cjs/useGestureHandlerPan.native.cjs +272 -0
- package/dist/cjs/useGestureHandlerPan.native.js +253 -265
- package/dist/cjs/useGestureHandlerPan.native.js.map +1 -1
- package/dist/cjs/useKeyboardControllerSheet.cjs +82 -88
- package/dist/cjs/useKeyboardControllerSheet.native.cjs +92 -0
- package/dist/cjs/useKeyboardControllerSheet.native.js +73 -111
- package/dist/cjs/useKeyboardControllerSheet.native.js.map +1 -1
- package/dist/cjs/useSafeAreaInsets.cjs +19 -26
- package/dist/cjs/useSafeAreaInsets.native.cjs +50 -0
- package/dist/cjs/useSafeAreaInsets.native.js +29 -25
- package/dist/cjs/useSafeAreaInsets.native.js.map +1 -1
- package/dist/cjs/useSheetController.cjs +26 -39
- package/dist/cjs/useSheetController.native.cjs +41 -0
- package/dist/cjs/useSheetController.native.js +27 -39
- package/dist/cjs/useSheetController.native.js.map +1 -1
- package/dist/cjs/useSheetOffscreenSize.cjs +43 -53
- package/dist/cjs/useSheetOffscreenSize.native.cjs +59 -0
- package/dist/cjs/useSheetOffscreenSize.native.js +47 -56
- package/dist/cjs/useSheetOffscreenSize.native.js.map +1 -1
- package/dist/cjs/useSheetOpenState.cjs +68 -40
- package/dist/cjs/useSheetOpenState.native.cjs +87 -0
- package/dist/cjs/useSheetOpenState.native.js +73 -42
- package/dist/cjs/useSheetOpenState.native.js.map +1 -1
- package/dist/cjs/useSheetProviderProps.cjs +145 -164
- package/dist/cjs/useSheetProviderProps.native.cjs +175 -0
- package/dist/cjs/useSheetProviderProps.native.js +155 -174
- package/dist/cjs/useSheetProviderProps.native.js.map +1 -1
- package/dist/cjs/useSheetScrollViewGestures.cjs +171 -180
- package/dist/cjs/useSheetScrollViewGestures.native.cjs +149 -0
- package/dist/cjs/useSheetScrollViewGestures.native.js +135 -147
- package/dist/cjs/useSheetScrollViewGestures.native.js.map +1 -1
- package/dist/cjs/webViewport.cjs +46 -48
- package/dist/cjs/webViewport.native.cjs +78 -0
- package/dist/cjs/webViewport.native.js +49 -50
- package/dist/cjs/webViewport.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 +207 -83
- package/dist/esm/Sheet.mjs.map +1 -1
- package/dist/esm/Sheet.native.js +210 -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/SheetDragSurface.mjs +25 -0
- package/dist/esm/SheetDragSurface.mjs.map +1 -0
- package/dist/esm/SheetDragSurface.native.js +34 -0
- package/dist/esm/SheetDragSurface.native.js.map +1 -0
- package/dist/esm/SheetImplementationCustom.mjs +647 -586
- package/dist/esm/SheetImplementationCustom.mjs.map +1 -1
- package/dist/esm/SheetImplementationCustom.native.js +684 -618
- package/dist/esm/SheetImplementationCustom.native.js.map +1 -1
- package/dist/esm/SheetScrollView.mjs +278 -288
- package/dist/esm/SheetScrollView.mjs.map +1 -1
- package/dist/esm/SheetScrollView.native.js +287 -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 +4 -70
- package/dist/esm/nativeSheet.mjs.map +1 -1
- package/dist/esm/nativeSheet.native.js +60 -70
- package/dist/esm/nativeSheet.native.js.map +1 -1
- package/dist/esm/stableViewportHeight.mjs +8 -0
- package/dist/esm/stableViewportHeight.mjs.map +1 -0
- package/dist/esm/stableViewportHeight.native.js +8 -0
- package/dist/esm/stableViewportHeight.native.js.map +1 -0
- 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 +66 -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/GestureSheetContext.mjs +15 -20
- package/dist/jsx/GestureSheetContext.mjs.map +1 -1
- package/dist/jsx/GestureSheetContext.native.cjs +48 -0
- package/dist/jsx/GestureSheetContext.native.js +29 -37
- package/dist/jsx/GestureSheetContext.native.js.map +1 -1
- package/dist/jsx/Sheet.mjs +207 -83
- package/dist/jsx/Sheet.mjs.map +1 -1
- package/dist/jsx/Sheet.native.cjs +245 -0
- package/dist/jsx/Sheet.native.js +223 -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 +57 -0
- package/dist/jsx/SheetContext.native.js +44 -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 +71 -0
- package/dist/jsx/SheetController.native.js +52 -58
- package/dist/jsx/SheetController.native.js.map +1 -1
- package/dist/jsx/SheetDragSurface.mjs +25 -0
- package/dist/jsx/SheetDragSurface.mjs.map +1 -0
- package/dist/jsx/SheetDragSurface.native.cjs +61 -0
- package/dist/jsx/SheetDragSurface.native.js +63 -0
- package/dist/jsx/SheetDragSurface.native.js.map +1 -0
- package/dist/jsx/SheetImplementationCustom.mjs +647 -586
- package/dist/jsx/SheetImplementationCustom.mjs.map +1 -1
- package/dist/jsx/SheetImplementationCustom.native.cjs +748 -0
- package/dist/jsx/SheetImplementationCustom.native.js +704 -649
- package/dist/jsx/SheetImplementationCustom.native.js.map +1 -1
- package/dist/jsx/SheetScrollView.mjs +278 -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 +36 -0
- package/dist/jsx/constants.native.js +21 -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 +37 -0
- package/dist/jsx/contexts.native.js +19 -27
- package/dist/jsx/contexts.native.js.map +1 -1
- package/dist/jsx/controller.mjs +2 -2
- package/dist/jsx/controller.native.cjs +31 -0
- package/dist/jsx/controller.native.js +16 -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 +53 -0
- package/dist/jsx/gestureState.native.js +29 -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 +34 -0
- package/dist/jsx/helpers.native.js +21 -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 +36 -0
- package/dist/jsx/index.native.js +15 -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 +74 -0
- package/dist/jsx/keyboardAvoidance.native.js +55 -78
- package/dist/jsx/keyboardAvoidance.native.js.map +1 -1
- package/dist/jsx/nativeSheet.mjs +4 -70
- package/dist/jsx/nativeSheet.mjs.map +1 -1
- package/dist/jsx/nativeSheet.native.cjs +94 -0
- package/dist/jsx/nativeSheet.native.js +73 -86
- package/dist/jsx/nativeSheet.native.js.map +1 -1
- package/dist/jsx/stableViewportHeight.mjs +8 -0
- package/dist/jsx/stableViewportHeight.mjs.map +1 -0
- package/dist/jsx/stableViewportHeight.native.cjs +29 -0
- package/dist/jsx/stableViewportHeight.native.js +31 -0
- package/dist/jsx/stableViewportHeight.native.js.map +1 -0
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +18 -0
- package/dist/jsx/types.native.js +9 -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 +272 -0
- package/dist/jsx/useGestureHandlerPan.native.js +253 -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 +92 -0
- package/dist/jsx/useKeyboardControllerSheet.native.js +73 -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 +50 -0
- package/dist/jsx/useSafeAreaInsets.native.js +29 -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 +41 -0
- package/dist/jsx/useSheetController.native.js +27 -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 +59 -0
- package/dist/jsx/useSheetOffscreenSize.native.js +47 -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 +87 -0
- package/dist/jsx/useSheetOpenState.native.js +73 -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 +175 -0
- package/dist/jsx/useSheetProviderProps.native.js +155 -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 +149 -0
- package/dist/jsx/useSheetScrollViewGestures.native.js +135 -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 +78 -0
- package/dist/jsx/webViewport.native.js +49 -50
- package/dist/jsx/webViewport.native.js.map +1 -1
- package/package.json +38 -40
- package/src/Sheet.tsx +314 -77
- package/src/SheetContext.tsx +57 -7
- package/src/SheetController.tsx +7 -6
- package/src/SheetDragSurface.native.tsx +42 -0
- package/src/SheetDragSurface.tsx +40 -0
- package/src/SheetImplementationCustom.tsx +364 -181
- package/src/SheetScrollView.tsx +36 -20
- package/src/constants.tsx +3 -3
- package/src/helpers.tsx +0 -14
- package/src/index.ts +3 -6
- package/src/{nativeSheet.tsx → nativeSheet.native.tsx} +9 -20
- package/src/nativeSheet.ts +19 -0
- package/src/stableViewportHeight.native.ts +9 -0
- package/src/stableViewportHeight.ts +15 -0
- package/src/types.tsx +122 -92
- package/src/useKeyboardControllerSheet.native.ts +10 -39
- 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/GestureSheetContext.d.ts +1 -1
- package/types/GestureSheetContext.d.ts.map +1 -1
- package/types/Sheet.d.ts +247 -151
- 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/SheetDragSurface.d.ts +11 -0
- package/types/SheetDragSurface.d.ts.map +1 -0
- package/types/SheetDragSurface.native.d.ts +11 -0
- package/types/SheetDragSurface.native.d.ts.map +1 -0
- package/types/SheetImplementationCustom.d.ts +4 -36
- package/types/SheetImplementationCustom.d.ts.map +1 -1
- package/types/SheetScrollView.d.ts +21 -38
- 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 +8 -8
- package/types/nativeSheet.d.ts.map +1 -1
- package/types/nativeSheet.native.d.ts +5 -0
- package/types/nativeSheet.native.d.ts.map +1 -0
- package/types/stableViewportHeight.d.ts +12 -0
- package/types/stableViewportHeight.d.ts.map +1 -0
- package/types/stableViewportHeight.native.d.ts +6 -0
- package/types/stableViewportHeight.native.d.ts.map +1 -0
- package/types/types.d.ts +43 -17
- package/types/types.d.ts.map +1 -1
- package/types/useKeyboardControllerSheet.native.d.ts +6 -6
- 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/GestureDetectorWrapper.cjs +0 -54
- package/dist/cjs/GestureDetectorWrapper.native.js +0 -58
- package/dist/cjs/GestureDetectorWrapper.native.js.map +0 -1
- 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/GestureDetectorWrapper.mjs +0 -29
- package/dist/esm/GestureDetectorWrapper.mjs.map +0 -1
- package/dist/esm/GestureDetectorWrapper.native.js +0 -30
- package/dist/esm/GestureDetectorWrapper.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/GestureDetectorWrapper.mjs +0 -29
- package/dist/jsx/GestureDetectorWrapper.mjs.map +0 -1
- package/dist/jsx/GestureDetectorWrapper.native.js +0 -58
- package/dist/jsx/GestureDetectorWrapper.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/GestureDetectorWrapper.tsx +0 -38
- 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/GestureDetectorWrapper.d.ts +0 -14
- package/types/GestureDetectorWrapper.d.ts.map +0 -1
- 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/Sheet.tsx
CHANGED
|
@@ -1,59 +1,78 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AdaptCapabilities, useAdaptContext, useAdaptIsActive } from '@tamagui/adapt'
|
|
2
|
+
import { useComposedRefs } from '@tamagui/compose-refs'
|
|
3
|
+
import { isWeb } from '@tamagui/constants'
|
|
4
|
+
import {
|
|
5
|
+
createRefComponent,
|
|
6
|
+
createStyledHOC,
|
|
7
|
+
styled,
|
|
8
|
+
View,
|
|
9
|
+
type TamaguiElement,
|
|
10
|
+
type ViewProps,
|
|
11
|
+
} from '@tamagui/core'
|
|
12
|
+
import { composeEventHandlers, withStaticProperties } from '@tamagui/helpers'
|
|
13
|
+
import { resolveViewZIndex } from '@tamagui/portal'
|
|
14
|
+
import { RemoveScroll } from '@tamagui/remove-scroll'
|
|
2
15
|
import { XStack, YStack } from '@tamagui/stacks'
|
|
16
|
+
import { useDidFinishSSR } from '@tamagui/use-did-finish-ssr'
|
|
17
|
+
import { StackZIndexContext } from '@tamagui/z-index-stack'
|
|
18
|
+
import type { FunctionComponent, Ref } from 'react'
|
|
19
|
+
import { useContext, useEffect, useMemo, useRef } from 'react'
|
|
20
|
+
import type { View as RNView } from '@tamagui/react-native-types'
|
|
21
|
+
import {
|
|
22
|
+
SHEET_BACKGROUND_NAME,
|
|
23
|
+
SHEET_CONTAINER_NAME,
|
|
24
|
+
SHEET_HANDLE_NAME,
|
|
25
|
+
SHEET_OVERLAY_MARKER,
|
|
26
|
+
SHEET_OVERLAY_NAME,
|
|
27
|
+
} from './constants'
|
|
28
|
+
import { getNativeSheet } from './nativeSheet'
|
|
29
|
+
import {
|
|
30
|
+
SheetOverlayLayerContext,
|
|
31
|
+
useAnimatedPosition,
|
|
32
|
+
useSheetContext,
|
|
33
|
+
} from './SheetContext'
|
|
34
|
+
import { SheetImplementationCustom } from './SheetImplementationCustom'
|
|
35
|
+
import { SheetScrollView } from './SheetScrollView'
|
|
36
|
+
import type { SheetProps, SheetScopedProps } from './types'
|
|
37
|
+
import { useSheetController } from './useSheetController'
|
|
38
|
+
import { useSheetOffscreenSize } from './useSheetOffscreenSize'
|
|
39
|
+
import { getMaxViewportHeight } from './webViewport'
|
|
3
40
|
|
|
4
|
-
import { SHEET_HANDLE_NAME, SHEET_NAME, SHEET_OVERLAY_NAME } from './constants'
|
|
5
|
-
import { createSheet } from './createSheet'
|
|
6
|
-
|
|
7
|
-
export { createSheetScope } from './SheetContext'
|
|
8
41
|
export * from './types'
|
|
9
42
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
43
|
+
type SheetStyleShorthandProps = {
|
|
44
|
+
h?: ViewProps['height']
|
|
45
|
+
o?: ViewProps['opacity']
|
|
46
|
+
pos?: ViewProps['position']
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type SheetViewProps<ExtraProps extends object = {}> = SheetScopedProps<
|
|
50
|
+
ViewProps & SheetStyleShorthandProps & ExtraProps
|
|
51
|
+
>
|
|
13
52
|
|
|
14
|
-
|
|
15
|
-
|
|
53
|
+
const SheetHandleFrame = styled(XStack, {
|
|
54
|
+
displayName: SHEET_HANDLE_NAME,
|
|
16
55
|
|
|
56
|
+
// the behavior Handle ships no opacity rules; open/close aesthetics (fade in
|
|
57
|
+
// when open, dim when idle) live in the copied skin. see the canonical skin.
|
|
17
58
|
variants: {
|
|
18
59
|
open: {
|
|
19
60
|
true: {
|
|
20
|
-
opacity: 1,
|
|
21
61
|
pointerEvents: 'auto',
|
|
22
62
|
},
|
|
23
63
|
false: {
|
|
24
|
-
opacity: 0,
|
|
25
64
|
pointerEvents: 'none',
|
|
26
65
|
},
|
|
27
66
|
},
|
|
28
|
-
|
|
29
|
-
unstyled: {
|
|
30
|
-
false: {
|
|
31
|
-
height: 10,
|
|
32
|
-
borderRadius: 100,
|
|
33
|
-
backgroundColor: '$background',
|
|
34
|
-
zIndex: 10,
|
|
35
|
-
marginHorizontal: '35%',
|
|
36
|
-
marginBottom: '$2',
|
|
37
|
-
opacity: 0.5,
|
|
38
|
-
|
|
39
|
-
hoverStyle: {
|
|
40
|
-
opacity: 0.7,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
67
|
} as const,
|
|
45
|
-
|
|
46
|
-
defaultVariants: {
|
|
47
|
-
unstyled: process.env.TAMAGUI_HEADLESS === '1',
|
|
48
|
-
},
|
|
49
68
|
})
|
|
50
69
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
70
|
+
const SheetOverlayFrame = styled(YStack, {
|
|
71
|
+
displayName: SHEET_OVERLAY_NAME,
|
|
72
|
+
inset: 0,
|
|
73
|
+
position: 'absolute',
|
|
74
|
+
zIndex: 100_000 - 1,
|
|
75
|
+
pointerEvents: 'auto',
|
|
57
76
|
|
|
58
77
|
variants: {
|
|
59
78
|
open: {
|
|
@@ -64,51 +83,269 @@ export const Overlay = styled(YStack, {
|
|
|
64
83
|
pointerEvents: 'none',
|
|
65
84
|
},
|
|
66
85
|
},
|
|
67
|
-
|
|
68
|
-
unstyled: {
|
|
69
|
-
false: {
|
|
70
|
-
fullscreen: true,
|
|
71
|
-
position: 'absolute',
|
|
72
|
-
backgroundColor: '$background',
|
|
73
|
-
zIndex: 100_000 - 1,
|
|
74
|
-
pointerEvents: 'auto',
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
86
|
} as const,
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
Object.assign(SheetOverlayFrame.staticConfig, { [SHEET_OVERLAY_MARKER]: true })
|
|
78
90
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
const SheetContainerFrame = styled(YStack, {
|
|
92
|
+
displayName: SHEET_CONTAINER_NAME,
|
|
93
|
+
flex: 1,
|
|
94
|
+
position: 'relative',
|
|
95
|
+
zIndex: 0,
|
|
96
|
+
width: '100%',
|
|
97
|
+
maxHeight: '100%',
|
|
82
98
|
})
|
|
83
99
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
100
|
+
const SheetBackgroundFrame = styled(YStack, {
|
|
101
|
+
displayName: SHEET_BACKGROUND_NAME,
|
|
102
|
+
position: 'absolute',
|
|
103
|
+
top: 0,
|
|
104
|
+
left: 0,
|
|
105
|
+
right: 0,
|
|
106
|
+
zIndex: -1,
|
|
107
|
+
pointerEvents: 'none',
|
|
108
|
+
})
|
|
87
109
|
|
|
88
|
-
export const
|
|
89
|
-
|
|
110
|
+
export const SheetHandle = createStyledHOC(
|
|
111
|
+
SheetHandleFrame,
|
|
112
|
+
({ scope, ...props }: SheetViewProps, forwardedRef) => {
|
|
113
|
+
const context = useSheetContext(scope)
|
|
114
|
+
const composedRef = useComposedRefs<TamaguiElement>(context.handleRef, forwardedRef)
|
|
115
|
+
const wasDraggingRef = useRef(false)
|
|
90
116
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
maxHeight: '100%',
|
|
100
|
-
overflow: 'hidden',
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
} as const,
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
if (!context.scrollBridge) return
|
|
119
|
+
return context.scrollBridge.onParentDragging((isDragging: boolean) => {
|
|
120
|
+
if (isDragging) {
|
|
121
|
+
wasDraggingRef.current = true
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
}, [context.scrollBridge])
|
|
104
125
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
126
|
+
if (context.onlyShowContainer) {
|
|
127
|
+
return null
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<SheetHandleFrame
|
|
132
|
+
ref={composedRef}
|
|
133
|
+
onPressIn={() => {
|
|
134
|
+
wasDraggingRef.current = false
|
|
135
|
+
}}
|
|
136
|
+
onPress={() => {
|
|
137
|
+
if (wasDraggingRef.current) {
|
|
138
|
+
wasDraggingRef.current = false
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
const max = context.snapPoints.length + (context.dismissOnSnapToBottom ? -1 : 0)
|
|
142
|
+
const nextPos = (context.position + 1) % max
|
|
143
|
+
context.setPosition(nextPos)
|
|
144
|
+
}}
|
|
145
|
+
open={context.open}
|
|
146
|
+
{...props}
|
|
147
|
+
/>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
export const SheetOverlay = createStyledHOC(
|
|
153
|
+
SheetOverlayFrame,
|
|
154
|
+
(propsIn: SheetViewProps, ref) => {
|
|
155
|
+
const { scope, ...props } = propsIn
|
|
156
|
+
const context = useSheetContext(scope)
|
|
157
|
+
const isInOverlayLayer = useContext(SheetOverlayLayerContext)
|
|
158
|
+
const didWarn = useRef(false)
|
|
159
|
+
|
|
160
|
+
if (context.onlyShowContainer) {
|
|
161
|
+
return null
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!isInOverlayLayer) {
|
|
165
|
+
if (process.env.NODE_ENV === 'development' && !didWarn.current) {
|
|
166
|
+
didWarn.current = true
|
|
167
|
+
console.error(
|
|
168
|
+
'Sheet.Overlay must be a direct child of Sheet. Move it next to Sheet.Handle and Sheet.Container.'
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return null
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<SheetOverlayFrame
|
|
177
|
+
{...props}
|
|
178
|
+
ref={ref}
|
|
179
|
+
onPress={composeEventHandlers(
|
|
180
|
+
props.onPress,
|
|
181
|
+
context.dismissOnOverlayPress
|
|
182
|
+
? () => {
|
|
183
|
+
context.setOpen(false)
|
|
184
|
+
}
|
|
185
|
+
: undefined
|
|
186
|
+
)}
|
|
187
|
+
/>
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
type ExtraContainerProps = {
|
|
193
|
+
/**
|
|
194
|
+
* Adds padding accounting for the currently offscreen content, so if you put a flex element inside
|
|
195
|
+
* the sheet, it will always flex to the height of the visible amount of the sheet. If this is not
|
|
196
|
+
* turned on, the inner content is always set to the max height of the sheet.
|
|
197
|
+
*/
|
|
198
|
+
adjustPaddingForOffscreenContent?: boolean
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export const SheetContainer = createStyledHOC(
|
|
202
|
+
SheetContainerFrame,
|
|
203
|
+
(
|
|
204
|
+
{
|
|
205
|
+
scope,
|
|
206
|
+
adjustPaddingForOffscreenContent,
|
|
207
|
+
children,
|
|
208
|
+
...props
|
|
209
|
+
}: SheetViewProps<ExtraContainerProps>,
|
|
210
|
+
forwardedRef
|
|
211
|
+
) => {
|
|
212
|
+
const context = useSheetContext(scope)
|
|
213
|
+
const { hasFit, disableRemoveScroll, frameSize, contentRef, open } = context
|
|
214
|
+
const composedContentRef = useComposedRefs(forwardedRef, contentRef)
|
|
215
|
+
const offscreenSize = useSheetOffscreenSize(context)
|
|
216
|
+
const stableFrameSize = useRef(frameSize)
|
|
217
|
+
|
|
218
|
+
useEffect(() => {
|
|
219
|
+
if (open && frameSize) {
|
|
220
|
+
stableFrameSize.current = frameSize
|
|
221
|
+
}
|
|
222
|
+
}, [open, frameSize])
|
|
223
|
+
|
|
224
|
+
const sheetContents = useMemo(() => {
|
|
225
|
+
const shouldUseFixedHeight = hasFit && !open && stableFrameSize.current
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<SheetContainerFrame
|
|
229
|
+
ref={composedContentRef}
|
|
230
|
+
flex={hasFit && open ? 0 : 1}
|
|
231
|
+
flexBasis={hasFit ? 'auto' : undefined}
|
|
232
|
+
height={
|
|
233
|
+
shouldUseFixedHeight
|
|
234
|
+
? stableFrameSize.current
|
|
235
|
+
: hasFit
|
|
236
|
+
? undefined
|
|
237
|
+
: frameSize
|
|
238
|
+
}
|
|
239
|
+
pointerEvents={open ? 'auto' : 'none'}
|
|
240
|
+
data-state={open ? 'open' : 'closed'}
|
|
241
|
+
{...props}
|
|
242
|
+
>
|
|
243
|
+
<StackZIndexContext zIndex={resolveViewZIndex(props.zIndex)}>
|
|
244
|
+
{children}
|
|
245
|
+
</StackZIndexContext>
|
|
246
|
+
|
|
247
|
+
{adjustPaddingForOffscreenContent && (
|
|
248
|
+
<View data-sheet-offscreen-pad height={offscreenSize} width="100%" />
|
|
249
|
+
)}
|
|
250
|
+
</SheetContainerFrame>
|
|
251
|
+
)
|
|
252
|
+
}, [open, props, frameSize, offscreenSize, adjustPaddingForOffscreenContent, hasFit])
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<RemoveScroll enabled={!disableRemoveScroll && context.open}>
|
|
256
|
+
{sheetContents}
|
|
257
|
+
</RemoveScroll>
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
type ExtraBackgroundProps = {
|
|
263
|
+
/**
|
|
264
|
+
* Disables the default background extension below the sheet. Leave this off
|
|
265
|
+
* when a spring can overshoot on open so page content never shows through.
|
|
266
|
+
*/
|
|
267
|
+
disableHideBottomOverflow?: boolean
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export const SheetBackground = createStyledHOC(
|
|
271
|
+
SheetBackgroundFrame,
|
|
272
|
+
(
|
|
273
|
+
{ scope, disableHideBottomOverflow, ...props }: SheetViewProps<ExtraBackgroundProps>,
|
|
274
|
+
forwardedRef
|
|
275
|
+
) => {
|
|
276
|
+
const context = useSheetContext(scope)
|
|
277
|
+
const bottomOverflow = isWeb
|
|
278
|
+
? Math.max(context.frameSize, getMaxViewportHeight())
|
|
279
|
+
: context.frameSize
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<SheetBackgroundFrame
|
|
283
|
+
ref={forwardedRef}
|
|
284
|
+
data-sheet-background=""
|
|
285
|
+
bottom={disableHideBottomOverflow ? 0 : -bottomOverflow}
|
|
286
|
+
{...props}
|
|
287
|
+
/>
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
export const SheetRoot = createRefComponent<RNView, SheetProps>(
|
|
293
|
+
function SheetRoot(props, ref) {
|
|
294
|
+
const hydrated = useDidFinishSSR()
|
|
295
|
+
const isAdapted = useAdaptIsActive()
|
|
296
|
+
const adaptContext = useAdaptContext()
|
|
297
|
+
const { isShowingNonSheet } = useSheetController(props.scope)
|
|
298
|
+
const shouldUseAdapt = Boolean(
|
|
299
|
+
adaptContext.open !== undefined || adaptContext.onOpenChange
|
|
300
|
+
)
|
|
301
|
+
const isShowingAdaptNonSheet =
|
|
302
|
+
shouldUseAdapt && !adaptContext.active && adaptContext.open
|
|
303
|
+
|
|
304
|
+
let SheetImplementation = SheetImplementationCustom
|
|
305
|
+
|
|
306
|
+
if (props.native) {
|
|
307
|
+
// null unless this is ios and the app registered a native sheet
|
|
308
|
+
const impl = getNativeSheet('ios')
|
|
309
|
+
if (impl) {
|
|
310
|
+
// @ts-expect-error accepting external sheet implementation
|
|
311
|
+
SheetImplementation = impl
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (isShowingAdaptNonSheet || isShowingNonSheet || !hydrated) {
|
|
316
|
+
return null
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const implementation = <SheetImplementation ref={ref} {...props} />
|
|
320
|
+
|
|
321
|
+
return isAdapted ? (
|
|
322
|
+
<AdaptCapabilities scroll overlay dismiss>
|
|
323
|
+
{implementation}
|
|
324
|
+
</AdaptCapabilities>
|
|
325
|
+
) : (
|
|
326
|
+
implementation
|
|
327
|
+
)
|
|
328
|
+
}
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
const sheetParts = {
|
|
332
|
+
Container: SheetContainer,
|
|
333
|
+
Background: SheetBackground,
|
|
334
|
+
Overlay: SheetOverlay,
|
|
335
|
+
Handle: SheetHandle,
|
|
336
|
+
ScrollView: SheetScrollView,
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export const SheetControlled = withStaticProperties(
|
|
340
|
+
SheetRoot as unknown as FunctionComponent<
|
|
341
|
+
Omit<SheetProps, 'open' | 'onOpenChange'> & { ref?: Ref<RNView> }
|
|
342
|
+
>,
|
|
343
|
+
sheetParts
|
|
344
|
+
)
|
|
109
345
|
|
|
110
|
-
export const Sheet =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
346
|
+
export const Sheet = withStaticProperties(SheetRoot, {
|
|
347
|
+
Root: SheetRoot,
|
|
348
|
+
Controlled: SheetControlled,
|
|
349
|
+
useAnimatedPosition,
|
|
350
|
+
...sheetParts,
|
|
114
351
|
})
|
package/src/SheetContext.tsx
CHANGED
|
@@ -1,11 +1,61 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createStyledContext, type UniversalAnimatedNumber } from '@tamagui/core'
|
|
2
|
+
import React from 'react'
|
|
2
3
|
|
|
3
|
-
import { SHEET_NAME } from './constants'
|
|
4
4
|
import type { SheetContextValue } from './useSheetProviderProps'
|
|
5
5
|
|
|
6
|
-
export const
|
|
6
|
+
export const SheetContext = createStyledContext<SheetContextValue>({}, 'Sheet__')
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export const { Provider: SheetProvider, useStyledContext: useSheetContext } = SheetContext
|
|
9
|
+
|
|
10
|
+
export const SheetOverlayLayerContext = React.createContext(false)
|
|
11
|
+
|
|
12
|
+
// the UIKit system sheet does not expose the continuous position that powers
|
|
13
|
+
// Sheet.useAnimatedPosition. mark that implementation separately so the hook
|
|
14
|
+
// can explain how to opt back into the custom Sheet instead of claiming the
|
|
15
|
+
// caller is outside Sheet entirely.
|
|
16
|
+
export const SheetNativeSystemContext = React.createContext(false)
|
|
17
|
+
|
|
18
|
+
export type SheetAnimatedPositionContextValue = {
|
|
19
|
+
// the exact animated number driving the frame's translateY (px from screen
|
|
20
|
+
// top). drive drag-linked effects off this via useAnimatedNumberStyle.
|
|
21
|
+
value: UniversalAnimatedNumber<any>
|
|
22
|
+
// height of the viewport the sheet positions against
|
|
23
|
+
screenSize: number
|
|
24
|
+
// measured height of the sheet frame
|
|
25
|
+
frameSize: number
|
|
26
|
+
// resolved px positions (translateY) matching snapPoints order
|
|
27
|
+
snapOffsets: number[]
|
|
28
|
+
// the top-most (fully open) position
|
|
29
|
+
minY: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const SheetAnimatedPositionContext =
|
|
33
|
+
React.createContext<SheetAnimatedPositionContextValue | null>(null)
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Read the sheet's live animated position. Call inside a `Sheet` to build
|
|
37
|
+
* drag-linked effects (e.g. an overlay fade) on the public animation hooks:
|
|
38
|
+
*
|
|
39
|
+
* ```tsx
|
|
40
|
+
* const { value, screenSize } = Sheet.useAnimatedPosition()
|
|
41
|
+
* const style = useAnimatedNumberStyle(value, (y) => {
|
|
42
|
+
* 'worklet'
|
|
43
|
+
* return { opacity: Math.max(0, 0.5 * (1 - y / screenSize)) }
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function useAnimatedPosition(): SheetAnimatedPositionContextValue {
|
|
48
|
+
const context = React.useContext(SheetAnimatedPositionContext)
|
|
49
|
+
const isNativeSystemSheet = React.useContext(SheetNativeSystemContext)
|
|
50
|
+
if (!context) {
|
|
51
|
+
if (isNativeSystemSheet) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
"Sheet.useAnimatedPosition() is unavailable when Sheet uses the native iOS system sheet because UIKit does not expose its continuous position. Remove the `native` prop to use Tamagui's custom Sheet and animated position hooks."
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
throw new Error(
|
|
57
|
+
'Sheet.useAnimatedPosition() must be used inside a <Sheet>. Render the component that calls it as a child of Sheet.'
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
return context
|
|
61
|
+
}
|
package/src/SheetController.tsx
CHANGED
|
@@ -8,13 +8,14 @@ import { SheetControllerContext } from './useSheetController'
|
|
|
8
8
|
export const SheetController = ({
|
|
9
9
|
children,
|
|
10
10
|
onOpenChange: onOpenChangeProp,
|
|
11
|
-
|
|
11
|
+
onTransition: onTransitionProp,
|
|
12
12
|
open,
|
|
13
13
|
hidden,
|
|
14
14
|
disableDrag,
|
|
15
|
-
|
|
15
|
+
scope = '',
|
|
16
|
+
}: Partial<SheetControllerContextValue> & { children?: ReactNode; scope?: string }) => {
|
|
16
17
|
const onOpenChange = useEvent(onOpenChangeProp)
|
|
17
|
-
const
|
|
18
|
+
const onTransition = useEvent(onTransitionProp)
|
|
18
19
|
const id = useId()
|
|
19
20
|
|
|
20
21
|
// track hidden transitions to signal adapt handoff
|
|
@@ -33,14 +34,14 @@ export const SheetController = ({
|
|
|
33
34
|
hidden,
|
|
34
35
|
disableDrag,
|
|
35
36
|
onOpenChange,
|
|
36
|
-
|
|
37
|
+
onTransition,
|
|
37
38
|
skipNextAnimation,
|
|
38
39
|
}),
|
|
39
|
-
[id, onOpenChange,
|
|
40
|
+
[id, onOpenChange, onTransition, open, hidden, disableDrag, skipNextAnimation]
|
|
40
41
|
)
|
|
41
42
|
|
|
42
43
|
return (
|
|
43
|
-
<SheetControllerContext.Provider
|
|
44
|
+
<SheetControllerContext.Provider scope={scope} {...memoValue}>
|
|
44
45
|
{children}
|
|
45
46
|
</SheetControllerContext.Provider>
|
|
46
47
|
)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { PanResponder, View } from 'react-native'
|
|
3
|
+
|
|
4
|
+
import { getGestureHandlerState } from './gestureState'
|
|
5
|
+
import type { SheetDragSurfaceProps } from './types'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The surface the sheet is dragged by.
|
|
9
|
+
*
|
|
10
|
+
* With react-native-gesture-handler set up the drag is a `Gesture.Pan`, which
|
|
11
|
+
* needs a native View of its own to attach to. Without it the drag runs on
|
|
12
|
+
* PanResponder, the same as web.
|
|
13
|
+
*/
|
|
14
|
+
export function SheetDragSurface({
|
|
15
|
+
gestureHandlerEnabled,
|
|
16
|
+
panGesture,
|
|
17
|
+
panConfig,
|
|
18
|
+
children,
|
|
19
|
+
}: SheetDragSurfaceProps) {
|
|
20
|
+
const { GestureDetector } = getGestureHandlerState()
|
|
21
|
+
|
|
22
|
+
const panHandlers = React.useMemo(
|
|
23
|
+
() => (panConfig ? PanResponder.create(panConfig).panHandlers : undefined),
|
|
24
|
+
[panConfig]
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
if (gestureHandlerEnabled && panGesture && GestureDetector) {
|
|
28
|
+
return (
|
|
29
|
+
<GestureDetector gesture={panGesture}>
|
|
30
|
+
<View style={{ flex: 1 }} collapsable={false}>
|
|
31
|
+
{children}
|
|
32
|
+
</View>
|
|
33
|
+
</GestureDetector>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View {...panHandlers} style={{ flex: 1, width: '100%', height: '100%' }}>
|
|
39
|
+
{children}
|
|
40
|
+
</View>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { TamaguiElement } from '@tamagui/core'
|
|
2
|
+
import { View } from '@tamagui/core'
|
|
3
|
+
import { PanResponder } from '@tamagui/react-native-pan-responder'
|
|
4
|
+
import { useResponderEvents } from '@tamagui/react-native-use-responder-events'
|
|
5
|
+
import * as React from 'react'
|
|
6
|
+
|
|
7
|
+
import type { SheetDragSurfaceProps } from './types'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The surface the sheet is dragged by.
|
|
11
|
+
*
|
|
12
|
+
* Web runs the same PanResponder react-native does, over the same responder
|
|
13
|
+
* system, so the drag behaves as it did when this was a react-native `View`.
|
|
14
|
+
* `gestureHandler` is native-only, so the props for it are ignored here.
|
|
15
|
+
*/
|
|
16
|
+
export function SheetDragSurface({ panConfig, children }: SheetDragSurfaceProps) {
|
|
17
|
+
const ref = React.useRef<TamaguiElement>(null)
|
|
18
|
+
|
|
19
|
+
const panHandlers = React.useMemo(
|
|
20
|
+
() => (panConfig ? PanResponder.create(panConfig).panHandlers : undefined),
|
|
21
|
+
[panConfig]
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
const { onClickCapture, ...responderHandlers } = panHandlers ?? {}
|
|
25
|
+
useResponderEvents(ref, responderHandlers)
|
|
26
|
+
|
|
27
|
+
// onClickCapture is a DOM prop: tamagui forwards it to the element untouched
|
|
28
|
+
// but only types react-native's prop surface
|
|
29
|
+
const domProps = { onClickCapture } as Record<string, unknown>
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
// flexBasis auto, like the container frame: under the web style compat
|
|
33
|
+
// `flex={1}` means a basis of 0, which collapses this surface inside the
|
|
34
|
+
// animated wrapper (that wrapper has no height of its own in fit mode), and
|
|
35
|
+
// a collapsed surface leaves the frame unmeasured and parked off-screen
|
|
36
|
+
<View ref={ref} {...domProps} flex={1} flexBasis="auto" width="100%" height="100%">
|
|
37
|
+
{children}
|
|
38
|
+
</View>
|
|
39
|
+
)
|
|
40
|
+
}
|