@hanzogui/sheet 7.0.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +40 -19
- package/dist/cjs/GestureDetectorWrapper.cjs +54 -0
- package/dist/cjs/GestureDetectorWrapper.native.js +58 -0
- package/dist/cjs/GestureDetectorWrapper.native.js.map +1 -0
- package/dist/cjs/GestureSheetContext.cjs +54 -0
- package/dist/cjs/GestureSheetContext.native.js +58 -0
- package/dist/cjs/GestureSheetContext.native.js.map +1 -0
- package/dist/cjs/Sheet.cjs +119 -0
- package/dist/cjs/Sheet.native.js +122 -0
- package/dist/cjs/Sheet.native.js.map +1 -0
- package/dist/cjs/SheetContext.cjs +34 -0
- package/dist/cjs/SheetContext.native.js +37 -0
- package/dist/cjs/SheetContext.native.js.map +1 -0
- package/dist/cjs/SheetController.cjs +73 -0
- package/dist/cjs/SheetController.native.js +79 -0
- package/dist/cjs/SheetController.native.js.map +1 -0
- package/dist/cjs/SheetImplementationCustom.cjs +589 -0
- package/dist/cjs/SheetImplementationCustom.native.js +615 -0
- package/dist/cjs/SheetImplementationCustom.native.js.map +1 -0
- package/dist/cjs/SheetScrollView.cjs +216 -0
- package/dist/cjs/SheetScrollView.native.js +223 -0
- package/dist/cjs/SheetScrollView.native.js.map +1 -0
- package/dist/cjs/constants.cjs +34 -0
- package/dist/cjs/constants.native.js +37 -0
- package/dist/cjs/constants.native.js.map +1 -0
- package/dist/cjs/contexts.cjs +44 -0
- package/dist/cjs/contexts.native.js +47 -0
- package/dist/cjs/contexts.native.js.map +1 -0
- package/dist/cjs/controller.cjs +31 -0
- package/dist/cjs/controller.native.js +34 -0
- package/dist/cjs/controller.native.js.map +1 -0
- package/dist/cjs/createSheet.cjs +190 -0
- package/dist/cjs/createSheet.native.js +200 -0
- package/dist/cjs/createSheet.native.js.map +1 -0
- package/dist/cjs/gestureState.cjs +41 -0
- package/dist/cjs/gestureState.native.js +44 -0
- package/dist/cjs/gestureState.native.js.map +1 -0
- package/dist/cjs/helpers.cjs +35 -0
- package/dist/cjs/helpers.native.js +39 -0
- package/dist/cjs/helpers.native.js.map +1 -0
- package/dist/cjs/index.cjs +30 -0
- package/dist/cjs/index.native.js +33 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/nativeSheet.cjs +96 -0
- package/dist/cjs/nativeSheet.native.js +106 -0
- package/dist/cjs/nativeSheet.native.js.map +1 -0
- package/dist/cjs/setupGestureHandler.cjs +52 -0
- package/dist/cjs/setupGestureHandler.native.js +55 -0
- package/dist/cjs/setupGestureHandler.native.js.map +1 -0
- package/dist/cjs/types.cjs +18 -0
- package/dist/cjs/types.native.js +21 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/cjs/useGestureHandlerPan.cjs +206 -0
- package/dist/cjs/useGestureHandlerPan.native.js +213 -0
- package/dist/cjs/useGestureHandlerPan.native.js.map +1 -0
- package/dist/cjs/useKeyboardControllerSheet.cjs +40 -0
- package/dist/cjs/useKeyboardControllerSheet.native.js +132 -0
- package/dist/cjs/useKeyboardControllerSheet.native.js.map +1 -0
- package/dist/cjs/useSheet.cjs +29 -0
- package/dist/cjs/useSheet.native.js +34 -0
- package/dist/cjs/useSheet.native.js.map +1 -0
- package/dist/cjs/useSheetController.cjs +52 -0
- package/dist/cjs/useSheetController.native.js +55 -0
- package/dist/cjs/useSheetController.native.js.map +1 -0
- package/dist/cjs/useSheetOffscreenSize.cjs +63 -0
- package/dist/cjs/useSheetOffscreenSize.native.js +70 -0
- package/dist/cjs/useSheetOffscreenSize.native.js.map +1 -0
- package/dist/cjs/useSheetOpenState.cjs +52 -0
- package/dist/cjs/useSheetOpenState.native.js +58 -0
- package/dist/cjs/useSheetOpenState.native.js.map +1 -0
- package/dist/cjs/useSheetProviderProps.cjs +181 -0
- package/dist/cjs/useSheetProviderProps.native.js +196 -0
- package/dist/cjs/useSheetProviderProps.native.js.map +1 -0
- package/dist/cjs/useSheetScrollViewGestures.cjs +166 -0
- package/dist/cjs/useSheetScrollViewGestures.native.js +159 -0
- package/dist/cjs/useSheetScrollViewGestures.native.js.map +1 -0
- package/dist/esm/GestureDetectorWrapper.mjs +29 -0
- package/dist/esm/GestureDetectorWrapper.mjs.map +1 -0
- package/dist/esm/GestureDetectorWrapper.native.js +30 -0
- package/dist/esm/GestureDetectorWrapper.native.js.map +1 -0
- package/dist/esm/GestureSheetContext.mjs +28 -0
- package/dist/esm/GestureSheetContext.mjs.map +1 -0
- package/dist/esm/GestureSheetContext.native.js +29 -0
- package/dist/esm/GestureSheetContext.native.js.map +1 -0
- package/dist/esm/Sheet.mjs +89 -0
- package/dist/esm/Sheet.mjs.map +1 -0
- package/dist/esm/Sheet.native.js +89 -0
- package/dist/esm/Sheet.native.js.map +1 -0
- package/dist/esm/SheetContext.mjs +6 -0
- package/dist/esm/SheetContext.mjs.map +1 -0
- package/dist/esm/SheetContext.native.js +6 -0
- package/dist/esm/SheetContext.native.js.map +1 -0
- package/dist/esm/SheetController.mjs +37 -0
- package/dist/esm/SheetController.mjs.map +1 -0
- package/dist/esm/SheetController.native.js +40 -0
- package/dist/esm/SheetController.native.js.map +1 -0
- package/dist/esm/SheetImplementationCustom.mjs +552 -0
- package/dist/esm/SheetImplementationCustom.mjs.map +1 -0
- package/dist/esm/SheetImplementationCustom.native.js +572 -0
- package/dist/esm/SheetImplementationCustom.native.js.map +1 -0
- package/dist/esm/SheetScrollView.mjs +180 -0
- package/dist/esm/SheetScrollView.mjs.map +1 -0
- package/dist/esm/SheetScrollView.native.js +184 -0
- package/dist/esm/SheetScrollView.native.js.map +1 -0
- package/dist/esm/constants.mjs +6 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/constants.native.js +6 -0
- package/dist/esm/constants.native.js.map +1 -0
- package/dist/esm/contexts.mjs +7 -0
- package/dist/esm/contexts.mjs.map +1 -0
- package/dist/esm/contexts.native.js +7 -0
- package/dist/esm/contexts.native.js.map +1 -0
- package/dist/esm/controller.mjs +4 -0
- package/dist/esm/controller.mjs.map +1 -0
- package/dist/esm/controller.native.js +4 -0
- package/dist/esm/controller.native.js.map +1 -0
- package/dist/esm/createSheet.mjs +165 -0
- package/dist/esm/createSheet.mjs.map +1 -0
- package/dist/esm/createSheet.native.js +172 -0
- package/dist/esm/createSheet.native.js.map +1 -0
- package/dist/esm/gestureState.mjs +13 -0
- package/dist/esm/gestureState.mjs.map +1 -0
- package/dist/esm/gestureState.native.js +13 -0
- package/dist/esm/gestureState.native.js.map +1 -0
- package/dist/esm/helpers.mjs +10 -0
- package/dist/esm/helpers.mjs.map +1 -0
- package/dist/esm/helpers.native.js +11 -0
- package/dist/esm/helpers.native.js.map +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +12 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +12 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/nativeSheet.mjs +70 -0
- package/dist/esm/nativeSheet.mjs.map +1 -0
- package/dist/esm/nativeSheet.native.js +77 -0
- package/dist/esm/nativeSheet.native.js.map +1 -0
- package/dist/esm/setupGestureHandler.mjs +26 -0
- package/dist/esm/setupGestureHandler.mjs.map +1 -0
- package/dist/esm/setupGestureHandler.native.js +26 -0
- package/dist/esm/setupGestureHandler.native.js.map +1 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/esm/useGestureHandlerPan.mjs +181 -0
- package/dist/esm/useGestureHandlerPan.mjs.map +1 -0
- package/dist/esm/useGestureHandlerPan.native.js +185 -0
- package/dist/esm/useGestureHandlerPan.native.js.map +1 -0
- package/dist/esm/useKeyboardControllerSheet.mjs +15 -0
- package/dist/esm/useKeyboardControllerSheet.mjs.map +1 -0
- package/dist/esm/useKeyboardControllerSheet.native.js +104 -0
- package/dist/esm/useKeyboardControllerSheet.native.js.map +1 -0
- package/dist/esm/useSheet.mjs +4 -0
- package/dist/esm/useSheet.mjs.map +1 -0
- package/dist/esm/useSheet.native.js +6 -0
- package/dist/esm/useSheet.native.js.map +1 -0
- package/dist/esm/useSheetController.mjs +15 -0
- package/dist/esm/useSheetController.mjs.map +1 -0
- package/dist/esm/useSheetController.native.js +15 -0
- package/dist/esm/useSheetController.native.js.map +1 -0
- package/dist/esm/useSheetOffscreenSize.mjs +38 -0
- package/dist/esm/useSheetOffscreenSize.mjs.map +1 -0
- package/dist/esm/useSheetOffscreenSize.native.js +42 -0
- package/dist/esm/useSheetOffscreenSize.native.js.map +1 -0
- package/dist/esm/useSheetOpenState.mjs +27 -0
- package/dist/esm/useSheetOpenState.mjs.map +1 -0
- package/dist/esm/useSheetOpenState.native.js +30 -0
- package/dist/esm/useSheetOpenState.native.js.map +1 -0
- package/dist/esm/useSheetProviderProps.mjs +145 -0
- package/dist/esm/useSheetProviderProps.mjs.map +1 -0
- package/dist/esm/useSheetProviderProps.native.js +157 -0
- package/dist/esm/useSheetProviderProps.native.js.map +1 -0
- package/dist/esm/useSheetScrollViewGestures.mjs +141 -0
- package/dist/esm/useSheetScrollViewGestures.mjs.map +1 -0
- package/dist/esm/useSheetScrollViewGestures.native.js +131 -0
- package/dist/esm/useSheetScrollViewGestures.native.js.map +1 -0
- package/dist/jsx/GestureDetectorWrapper.mjs +29 -0
- package/dist/jsx/GestureDetectorWrapper.mjs.map +1 -0
- package/dist/jsx/GestureDetectorWrapper.native.js +58 -0
- package/dist/jsx/GestureDetectorWrapper.native.js.map +1 -0
- package/dist/jsx/GestureSheetContext.mjs +28 -0
- package/dist/jsx/GestureSheetContext.mjs.map +1 -0
- package/dist/jsx/GestureSheetContext.native.js +58 -0
- package/dist/jsx/GestureSheetContext.native.js.map +1 -0
- package/dist/jsx/Sheet.mjs +89 -0
- package/dist/jsx/Sheet.mjs.map +1 -0
- package/dist/jsx/Sheet.native.js +122 -0
- package/dist/jsx/Sheet.native.js.map +1 -0
- package/dist/jsx/SheetContext.mjs +6 -0
- package/dist/jsx/SheetContext.mjs.map +1 -0
- package/dist/jsx/SheetContext.native.js +37 -0
- package/dist/jsx/SheetContext.native.js.map +1 -0
- package/dist/jsx/SheetController.mjs +37 -0
- package/dist/jsx/SheetController.mjs.map +1 -0
- package/dist/jsx/SheetController.native.js +79 -0
- package/dist/jsx/SheetController.native.js.map +1 -0
- package/dist/jsx/SheetImplementationCustom.mjs +552 -0
- package/dist/jsx/SheetImplementationCustom.mjs.map +1 -0
- package/dist/jsx/SheetImplementationCustom.native.js +615 -0
- package/dist/jsx/SheetImplementationCustom.native.js.map +1 -0
- package/dist/jsx/SheetScrollView.mjs +180 -0
- package/dist/jsx/SheetScrollView.mjs.map +1 -0
- package/dist/jsx/SheetScrollView.native.js +223 -0
- package/dist/jsx/SheetScrollView.native.js.map +1 -0
- package/dist/jsx/constants.mjs +6 -0
- package/dist/jsx/constants.mjs.map +1 -0
- package/dist/jsx/constants.native.js +37 -0
- package/dist/jsx/constants.native.js.map +1 -0
- package/dist/jsx/contexts.mjs +7 -0
- package/dist/jsx/contexts.mjs.map +1 -0
- package/dist/jsx/contexts.native.js +47 -0
- package/dist/jsx/contexts.native.js.map +1 -0
- package/dist/jsx/controller.mjs +4 -0
- package/dist/jsx/controller.mjs.map +1 -0
- package/dist/jsx/controller.native.js +34 -0
- package/dist/jsx/controller.native.js.map +1 -0
- package/dist/jsx/createSheet.mjs +165 -0
- package/dist/jsx/createSheet.mjs.map +1 -0
- package/dist/jsx/createSheet.native.js +200 -0
- package/dist/jsx/createSheet.native.js.map +1 -0
- package/dist/jsx/gestureState.mjs +13 -0
- package/dist/jsx/gestureState.mjs.map +1 -0
- package/dist/jsx/gestureState.native.js +44 -0
- package/dist/jsx/gestureState.native.js.map +1 -0
- package/dist/jsx/helpers.mjs +10 -0
- package/dist/jsx/helpers.mjs.map +1 -0
- package/dist/jsx/helpers.native.js +39 -0
- package/dist/jsx/helpers.native.js.map +1 -0
- package/dist/jsx/index.js +12 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/index.mjs +12 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/index.native.js +33 -0
- package/dist/jsx/index.native.js.map +1 -0
- package/dist/jsx/nativeSheet.mjs +70 -0
- package/dist/jsx/nativeSheet.mjs.map +1 -0
- package/dist/jsx/nativeSheet.native.js +106 -0
- package/dist/jsx/nativeSheet.native.js.map +1 -0
- package/dist/jsx/setupGestureHandler.mjs +26 -0
- package/dist/jsx/setupGestureHandler.mjs.map +1 -0
- package/dist/jsx/setupGestureHandler.native.js +55 -0
- package/dist/jsx/setupGestureHandler.native.js.map +1 -0
- package/dist/jsx/types.mjs +2 -0
- package/dist/jsx/types.mjs.map +1 -0
- package/dist/jsx/types.native.js +21 -0
- package/dist/jsx/types.native.js.map +1 -0
- package/dist/jsx/useGestureHandlerPan.mjs +181 -0
- package/dist/jsx/useGestureHandlerPan.mjs.map +1 -0
- package/dist/jsx/useGestureHandlerPan.native.js +213 -0
- package/dist/jsx/useGestureHandlerPan.native.js.map +1 -0
- package/dist/jsx/useKeyboardControllerSheet.mjs +15 -0
- package/dist/jsx/useKeyboardControllerSheet.mjs.map +1 -0
- package/dist/jsx/useKeyboardControllerSheet.native.js +132 -0
- package/dist/jsx/useKeyboardControllerSheet.native.js.map +1 -0
- package/dist/jsx/useSheet.mjs +4 -0
- package/dist/jsx/useSheet.mjs.map +1 -0
- package/dist/jsx/useSheet.native.js +34 -0
- package/dist/jsx/useSheet.native.js.map +1 -0
- package/dist/jsx/useSheetController.mjs +15 -0
- package/dist/jsx/useSheetController.mjs.map +1 -0
- package/dist/jsx/useSheetController.native.js +55 -0
- package/dist/jsx/useSheetController.native.js.map +1 -0
- package/dist/jsx/useSheetOffscreenSize.mjs +38 -0
- package/dist/jsx/useSheetOffscreenSize.mjs.map +1 -0
- package/dist/jsx/useSheetOffscreenSize.native.js +70 -0
- package/dist/jsx/useSheetOffscreenSize.native.js.map +1 -0
- package/dist/jsx/useSheetOpenState.mjs +27 -0
- package/dist/jsx/useSheetOpenState.mjs.map +1 -0
- package/dist/jsx/useSheetOpenState.native.js +58 -0
- package/dist/jsx/useSheetOpenState.native.js.map +1 -0
- package/dist/jsx/useSheetProviderProps.mjs +145 -0
- package/dist/jsx/useSheetProviderProps.mjs.map +1 -0
- package/dist/jsx/useSheetProviderProps.native.js +196 -0
- package/dist/jsx/useSheetProviderProps.native.js.map +1 -0
- package/dist/jsx/useSheetScrollViewGestures.mjs +141 -0
- package/dist/jsx/useSheetScrollViewGestures.mjs.map +1 -0
- package/dist/jsx/useSheetScrollViewGestures.native.js +159 -0
- package/dist/jsx/useSheetScrollViewGestures.native.js.map +1 -0
- package/package.json +36 -26
- package/src/Sheet.tsx +3 -3
- package/src/SheetImplementationCustom.tsx +5 -5
- package/src/createSheet.tsx +9 -9
- package/src/setupGestureHandler.ts +2 -2
- package/src/useSheetProviderProps.tsx +4 -4
- package/types/GestureDetectorWrapper.d.ts +1 -1
- package/types/GestureDetectorWrapper.d.ts.map +1 -0
- package/types/GestureSheetContext.d.ts +1 -1
- package/types/GestureSheetContext.d.ts.map +1 -0
- package/types/Sheet.d.ts +15 -15
- package/types/Sheet.d.ts.map +1 -0
- package/types/SheetContext.d.ts +4 -4
- package/types/SheetContext.d.ts.map +1 -0
- package/types/SheetController.d.ts +2 -1
- package/types/SheetController.d.ts.map +1 -0
- package/types/SheetImplementationCustom.d.ts.map +1 -0
- package/types/SheetScrollView.d.ts +1 -1
- package/types/SheetScrollView.d.ts.map +1 -0
- package/types/constants.d.ts.map +1 -0
- package/types/contexts.d.ts.map +1 -0
- package/types/controller.d.ts.map +1 -0
- package/types/createSheet.d.ts +11 -11
- package/types/createSheet.d.ts.map +1 -0
- package/types/gestureState.d.ts.map +1 -0
- package/types/helpers.d.ts.map +1 -0
- package/types/index.d.ts.map +1 -0
- package/types/nativeSheet.d.ts.map +1 -0
- package/types/setupGestureHandler.d.ts.map +1 -0
- package/types/types.d.ts.map +1 -0
- package/types/useGestureHandlerPan.d.ts.map +1 -0
- package/types/useKeyboardControllerSheet.d.ts.map +1 -0
- package/types/useKeyboardControllerSheet.native.d.ts.map +1 -0
- package/types/useSheet.d.ts.map +1 -0
- package/types/useSheetController.d.ts.map +1 -0
- package/types/useSheetOffscreenSize.d.ts.map +1 -0
- package/types/useSheetOpenState.d.ts.map +1 -0
- package/types/useSheetProviderProps.d.ts +3 -3
- package/types/useSheetProviderProps.d.ts.map +1 -0
- package/types/useSheetScrollViewGestures.d.ts.map +1 -0
- package/types/useSheetScrollViewGestures.native.d.ts.map +1 -0
- 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/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/tsconfig.json +0 -56
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createContextScope } from "@hanzogui/create-context";
|
|
2
|
+
import { SHEET_NAME } from "./constants.native.js";
|
|
3
|
+
var [createSheetContext, createSheetScope] = createContextScope(SHEET_NAME);
|
|
4
|
+
var [SheetProvider, useSheetContext] = createSheetContext(SHEET_NAME, {});
|
|
5
|
+
export { SheetProvider, createSheetContext, createSheetScope, useSheetContext };
|
|
6
|
+
//# sourceMappingURL=SheetContext.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContextScope","SHEET_NAME","createSheetContext","createSheetScope","SheetProvider","useSheetContext"],"sources":["../../src/SheetContext.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B;AAEnC,SAASC,UAAA,QAAkB;AAGpB,KAAAC,kBAAO,EAAAC,gBAAoB,IAAgBH,kBAAI,CAAAC,UAAmB;AAElE,KAAAG,aAAO,EAAAC,eAAe,IAAeH,kBAAI,CAAAD,UAAA;AAAA,SAE9CG,aAAC,EACHF,kBAAA,E","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { useId, useRef } from "react";
|
|
2
|
+
import { useEvent } from "@hanzogui/core";
|
|
3
|
+
import { SheetControllerContext } from "./useSheetController.mjs";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
const SheetController = ({
|
|
6
|
+
children,
|
|
7
|
+
onOpenChange: onOpenChangeProp,
|
|
8
|
+
onAnimationComplete: onAnimationCompleteProp,
|
|
9
|
+
open,
|
|
10
|
+
hidden,
|
|
11
|
+
disableDrag
|
|
12
|
+
}) => {
|
|
13
|
+
const onOpenChange = useEvent(onOpenChangeProp);
|
|
14
|
+
const onAnimationComplete = useEvent(onAnimationCompleteProp);
|
|
15
|
+
const id = useId();
|
|
16
|
+
const wasHiddenRef = useRef(hidden);
|
|
17
|
+
let skipNextAnimation = false;
|
|
18
|
+
if (wasHiddenRef.current && !hidden && open) {
|
|
19
|
+
skipNextAnimation = true;
|
|
20
|
+
}
|
|
21
|
+
wasHiddenRef.current = hidden;
|
|
22
|
+
const memoValue = React.useMemo(() => ({
|
|
23
|
+
id,
|
|
24
|
+
open,
|
|
25
|
+
hidden,
|
|
26
|
+
disableDrag,
|
|
27
|
+
onOpenChange,
|
|
28
|
+
onAnimationComplete,
|
|
29
|
+
skipNextAnimation
|
|
30
|
+
}), [id, onOpenChange, onAnimationComplete, open, hidden, disableDrag, skipNextAnimation]);
|
|
31
|
+
return /* @__PURE__ */jsx(SheetControllerContext.Provider, {
|
|
32
|
+
value: memoValue,
|
|
33
|
+
children
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
export { SheetController };
|
|
37
|
+
//# sourceMappingURL=SheetController.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useId","useRef","useEvent","SheetControllerContext","jsx","SheetController","children","onOpenChange","onOpenChangeProp","onAnimationComplete","onAnimationCompleteProp","open","hidden","disableDrag","id","wasHiddenRef","skipNextAnimation","current","memoValue","useMemo","Provider","value"],"sources":["../../src/SheetController.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,IAASC,KAAA,EAAOC,MAAA,QAAc;AACrC,SAASC,QAAA,QAAgB;AAIzB,SAASC,sBAAA,QAA8B;AAqCnC,SAAAC,GAAA;AAnCG,MAAMC,eAAA,GAAkBA,CAAC;EAC9BC,QAAA;EACAC,YAAA,EAAcC,gBAAA;EACdC,mBAAA,EAAqBC,uBAAA;EACrBC,IAAA;EACAC,MAAA;EACAC;AACF,MAAuE;EACrE,MAAMN,YAAA,GAAeL,QAAA,CAASM,gBAAgB;EAC9C,MAAMC,mBAAA,GAAsBP,QAAA,CAASQ,uBAAuB;EAC5D,MAAMI,EAAA,GAAKd,KAAA,CAAM;EAIjB,MAAMe,YAAA,GAAed,MAAA,CAAOW,MAAM;EAClC,IAAII,iBAAA,GAAoB;EACxB,IAAID,YAAA,CAAaE,OAAA,IAAW,CAACL,MAAA,IAAUD,IAAA,EAAM;IAC3CK,iBAAA,GAAoB;EACtB;EACAD,YAAA,CAAaE,OAAA,GAAUL,MAAA;EAEvB,MAAMM,SAAA,GAAYnB,KAAA,CAAMoB,OAAA,CACtB,OAAO;IACLL,EAAA;IACAH,IAAA;IACAC,MAAA;IACAC,WAAA;IACAN,YAAA;IACAE,mBAAA;IACAO;EACF,IACA,CAACF,EAAA,EAAIP,YAAA,EAAcE,mBAAA,EAAqBE,IAAA,EAAMC,MAAA,EAAQC,WAAA,EAAaG,iBAAiB,CACtF;EAEA,OACE,eAAAZ,GAAA,CAACD,sBAAA,CAAuBiB,QAAA,EAAvB;IAAgCC,KAAA,EAAOH,SAAA;IACrCZ;EAAA,CACH;AAEJ","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { useId, useRef } from "react";
|
|
3
|
+
import { useEvent } from "@hanzogui/core";
|
|
4
|
+
import { SheetControllerContext } from "./useSheetController.native.js";
|
|
5
|
+
var SheetController = function (param) {
|
|
6
|
+
var {
|
|
7
|
+
children,
|
|
8
|
+
onOpenChange: onOpenChangeProp,
|
|
9
|
+
onAnimationComplete: onAnimationCompleteProp,
|
|
10
|
+
open,
|
|
11
|
+
hidden,
|
|
12
|
+
disableDrag
|
|
13
|
+
} = param;
|
|
14
|
+
var onOpenChange = useEvent(onOpenChangeProp);
|
|
15
|
+
var onAnimationComplete = useEvent(onAnimationCompleteProp);
|
|
16
|
+
var id = useId();
|
|
17
|
+
var wasHiddenRef = useRef(hidden);
|
|
18
|
+
var skipNextAnimation = false;
|
|
19
|
+
if (wasHiddenRef.current && !hidden && open) {
|
|
20
|
+
skipNextAnimation = true;
|
|
21
|
+
}
|
|
22
|
+
wasHiddenRef.current = hidden;
|
|
23
|
+
var memoValue = React.useMemo(function () {
|
|
24
|
+
return {
|
|
25
|
+
id,
|
|
26
|
+
open,
|
|
27
|
+
hidden,
|
|
28
|
+
disableDrag,
|
|
29
|
+
onOpenChange,
|
|
30
|
+
onAnimationComplete,
|
|
31
|
+
skipNextAnimation
|
|
32
|
+
};
|
|
33
|
+
}, [id, onOpenChange, onAnimationComplete, open, hidden, disableDrag, skipNextAnimation]);
|
|
34
|
+
return /* @__PURE__ */_jsx(SheetControllerContext.Provider, {
|
|
35
|
+
value: memoValue,
|
|
36
|
+
children
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export { SheetController };
|
|
40
|
+
//# sourceMappingURL=SheetController.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","React","useId","useRef","useEvent","SheetControllerContext","SheetController","param","children","onOpenChange","onOpenChangeProp","onAnimationComplete","onAnimationCompleteProp","open","hidden","disableDrag","id","wasHiddenRef","skipNextAnimation","current","memoValue","useMemo","Provider"],"sources":["../../src/SheetController.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAAOA,GAAA,IAASC,IAAA,QAAO,mBAAc;AACrC,OAAAC,KAAS,IAAAC,KAAA,EAAAC,MAAgB;AAIzB,SAASC,QAAA,wBAA8B;AAqCnC,SAAAC,sBAAA;AAnCG,IAAAC,eAAM,YAAAA,CAAmBC,KAAA;EAC9B;IAAAC,QAAA;IAAAC,YAAA,EAAAC,gBAAA;IAAAC,mBAAA,EAAAC,uBAAA;IAAAC,IAAA;IAAAC,MAAA;IAAAC;EAAA,IAAAR,KAAA;EACA,IAAAE,YAAc,GAAAL,QAAA,CAAAM,gBAAA;EACd,IAAAC,mBAAqB,GAAAP,QAAA,CAAAQ,uBAAA;EACrB,IAAAI,EAAA,GAAAd,KAAA;EACA,IAAAe,YAAA,GAAAd,MAAA,CAAAW,MAAA;EACA,IAAAI,iBAAA;EACF,IAAuED,YAAA,CAAAE,OAAA,KAAAL,MAAA,IAAAD,IAAA;IACrEK,iBAAM,GAAe;EACrB;EACAD,YAAW,CAAAE,OAAM,GAAAL,MAAA;EAIjB,IAAAM,SAAM,GAAAnB,KAAe,CAAAoB,OAAO,aAAM;IAClC,OAAI;MACAL,EAAA;MACFH,IAAA;MACFC,MAAA;MACAC,WAAa;MAEbN,YAAM;MACJE,mBAAO;MACLO;IAAA;EACA,IACAF,EACA,EAAAP,YACA,EAAAE,mBACA,EAAAE,IACA,EACFC,MAAA,EACAC,WAAK,EACPG,iBAAA,CAEA;EAKF,sBAAAlB,IAAA,CAAAK,sBAAA,CAAAiB,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
import { ProvideAdaptContext, useAdaptContext } from "@hanzogui/adapt";
|
|
2
|
+
import { AnimatePresence } from "@hanzogui/animate-presence";
|
|
3
|
+
import { useComposedRefs } from "@hanzogui/compose-refs";
|
|
4
|
+
import { isWeb, useIsomorphicLayoutEffect } from "@hanzogui/constants";
|
|
5
|
+
import { LayoutMeasurementController, View as GuiView, useConfiguration, useDidFinishSSR, useEvent, useThemeName } from "@hanzogui/core";
|
|
6
|
+
import { getSafeArea } from "@hanzogui/native";
|
|
7
|
+
import { needsPortalRepropagation, Portal } from "@hanzogui/portal";
|
|
8
|
+
import React, { useState } from "react";
|
|
9
|
+
import { Dimensions, PanResponder, View } from "react-native-web";
|
|
10
|
+
import { ParentSheetContext, SheetInsideSheetContext } from "./contexts.mjs";
|
|
11
|
+
import { GestureDetectorWrapper } from "./GestureDetectorWrapper.mjs";
|
|
12
|
+
import { GestureSheetProvider } from "./GestureSheetContext.mjs";
|
|
13
|
+
import { resisted } from "./helpers.mjs";
|
|
14
|
+
import { SheetProvider } from "./SheetContext.mjs";
|
|
15
|
+
import { useGestureHandlerPan } from "./useGestureHandlerPan.mjs";
|
|
16
|
+
import { useKeyboardControllerSheet } from "./useKeyboardControllerSheet.mjs";
|
|
17
|
+
import { useSheetOpenState } from "./useSheetOpenState.mjs";
|
|
18
|
+
import { useSheetProviderProps } from "./useSheetProviderProps.mjs";
|
|
19
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
const hiddenSize = 10000.1;
|
|
21
|
+
let _cachedSafeAreaTop;
|
|
22
|
+
function getSafeAreaTopInset() {
|
|
23
|
+
if (_cachedSafeAreaTop !== void 0) return _cachedSafeAreaTop;
|
|
24
|
+
_cachedSafeAreaTop = getSafeArea().getInsets().top;
|
|
25
|
+
return _cachedSafeAreaTop;
|
|
26
|
+
}
|
|
27
|
+
let sheetHiddenStyleSheet = null;
|
|
28
|
+
const relativeDimensionTo = isWeb ? "window" : "screen";
|
|
29
|
+
const SheetImplementationCustom = React.forwardRef(function SheetImplementationCustom2(props, forwardedRef) {
|
|
30
|
+
const parentSheet = React.useContext(ParentSheetContext);
|
|
31
|
+
const {
|
|
32
|
+
transition,
|
|
33
|
+
transitionConfig: transitionConfigProp,
|
|
34
|
+
modal = false,
|
|
35
|
+
zIndex = parentSheet.zIndex + 1,
|
|
36
|
+
moveOnKeyboardChange = false,
|
|
37
|
+
unmountChildrenWhenHidden = false,
|
|
38
|
+
portalProps,
|
|
39
|
+
containerComponent: ContainerComponent = React.Fragment,
|
|
40
|
+
onAnimationComplete
|
|
41
|
+
} = props;
|
|
42
|
+
const state = useSheetOpenState(props);
|
|
43
|
+
const [overlayComponent, setOverlayComponent] = React.useState(null);
|
|
44
|
+
const providerProps = useSheetProviderProps(props, state, {
|
|
45
|
+
onOverlayComponent: setOverlayComponent
|
|
46
|
+
});
|
|
47
|
+
const {
|
|
48
|
+
frameSize,
|
|
49
|
+
setFrameSize,
|
|
50
|
+
snapPoints,
|
|
51
|
+
snapPointsMode,
|
|
52
|
+
hasFit,
|
|
53
|
+
position,
|
|
54
|
+
setPosition,
|
|
55
|
+
scrollBridge,
|
|
56
|
+
screenSize,
|
|
57
|
+
setMaxContentSize,
|
|
58
|
+
maxSnapPoint
|
|
59
|
+
} = providerProps;
|
|
60
|
+
const {
|
|
61
|
+
open,
|
|
62
|
+
controller,
|
|
63
|
+
isHidden
|
|
64
|
+
} = state;
|
|
65
|
+
const openRef = React.useRef(open);
|
|
66
|
+
openRef.current = open;
|
|
67
|
+
const sheetRef = React.useRef(void 0);
|
|
68
|
+
const ref = useComposedRefs(forwardedRef, sheetRef, providerProps.contentRef);
|
|
69
|
+
const {
|
|
70
|
+
animationDriver
|
|
71
|
+
} = useConfiguration();
|
|
72
|
+
if (!animationDriver) throw new Error(`Sheet requires an animation driver to be set`);
|
|
73
|
+
const transitionConfig = (() => {
|
|
74
|
+
if (transitionConfigProp) return transitionConfigProp;
|
|
75
|
+
const [animationProp, animationPropConfig] = !transition ? [] : Array.isArray(transition) ? transition : [transition];
|
|
76
|
+
if (animationProp && animationDriver.animations?.[animationProp]) return {
|
|
77
|
+
...animationDriver.animations[animationProp],
|
|
78
|
+
...animationPropConfig
|
|
79
|
+
};
|
|
80
|
+
return null;
|
|
81
|
+
})();
|
|
82
|
+
const [isShowingInnerSheet, setIsShowingInnerSheet] = React.useState(false);
|
|
83
|
+
const shouldHideParentSheet = !isWeb && modal && isShowingInnerSheet && needsPortalRepropagation();
|
|
84
|
+
const sheetInsideSheet = React.useContext(SheetInsideSheetContext);
|
|
85
|
+
const onInnerSheet = React.useCallback(hasChild => {
|
|
86
|
+
setIsShowingInnerSheet(hasChild);
|
|
87
|
+
}, []);
|
|
88
|
+
const stableFrameSize = React.useRef(frameSize);
|
|
89
|
+
React.useEffect(() => {
|
|
90
|
+
if (open && frameSize) stableFrameSize.current = frameSize;
|
|
91
|
+
}, [open, frameSize]);
|
|
92
|
+
const effectiveFrameSize = open ? frameSize : stableFrameSize.current || frameSize;
|
|
93
|
+
const positions = React.useMemo(() => snapPoints.map(point => getYPositions(snapPointsMode, point, screenSize, effectiveFrameSize)), [screenSize, effectiveFrameSize, snapPoints, snapPointsMode]);
|
|
94
|
+
const {
|
|
95
|
+
keyboardHeight,
|
|
96
|
+
isKeyboardVisible,
|
|
97
|
+
dismissKeyboard,
|
|
98
|
+
pauseKeyboardHandler,
|
|
99
|
+
flushPendingHide
|
|
100
|
+
} = useKeyboardControllerSheet({
|
|
101
|
+
enabled: !isWeb && Boolean(moveOnKeyboardChange)
|
|
102
|
+
});
|
|
103
|
+
const [isDragging, setIsDragging_] = React.useState(false);
|
|
104
|
+
const isDraggingRef = React.useRef(false);
|
|
105
|
+
const setIsDragging = React.useCallback(val => {
|
|
106
|
+
isDraggingRef.current = val;
|
|
107
|
+
pauseKeyboardHandler.current = val;
|
|
108
|
+
setIsDragging_(val);
|
|
109
|
+
if (!val) flushPendingHide();
|
|
110
|
+
}, [pauseKeyboardHandler, flushPendingHide]);
|
|
111
|
+
const activePositionsRef = React.useRef(positions);
|
|
112
|
+
const activePositions = React.useMemo(() => {
|
|
113
|
+
if (isDragging || isDraggingRef.current) return activePositionsRef.current;
|
|
114
|
+
let result;
|
|
115
|
+
if (!isKeyboardVisible || keyboardHeight <= 0) result = positions;else {
|
|
116
|
+
const safeAreaTop = isWeb ? 0 : getSafeAreaTopInset();
|
|
117
|
+
result = positions.map(p => {
|
|
118
|
+
if (screenSize && p >= screenSize) return p;
|
|
119
|
+
return Math.max(safeAreaTop, p - keyboardHeight);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
activePositionsRef.current = result;
|
|
123
|
+
return result;
|
|
124
|
+
}, [positions, isKeyboardVisible, keyboardHeight, screenSize, isDragging]);
|
|
125
|
+
const {
|
|
126
|
+
useAnimatedNumber,
|
|
127
|
+
useAnimatedNumberStyle,
|
|
128
|
+
useAnimatedNumberReaction
|
|
129
|
+
} = animationDriver;
|
|
130
|
+
const AnimatedView = animationDriver.View ?? GuiView;
|
|
131
|
+
useIsomorphicLayoutEffect(() => {
|
|
132
|
+
if (!(sheetInsideSheet && open)) return;
|
|
133
|
+
sheetInsideSheet(true);
|
|
134
|
+
return () => {
|
|
135
|
+
sheetInsideSheet(false);
|
|
136
|
+
};
|
|
137
|
+
}, [sheetInsideSheet, open]);
|
|
138
|
+
const nextParentContext = React.useMemo(() => ({
|
|
139
|
+
zIndex
|
|
140
|
+
}), [zIndex]);
|
|
141
|
+
const startPosition = useDidFinishSSR() && screenSize ? screenSize : hiddenSize;
|
|
142
|
+
const animatedNumber = useAnimatedNumber(startPosition);
|
|
143
|
+
const at = React.useRef(startPosition);
|
|
144
|
+
const hasntMeasured = at.current === hiddenSize;
|
|
145
|
+
const [disableAnimation, setDisableAnimation] = useState(hasntMeasured);
|
|
146
|
+
const skipAdaptAnimation = React.useRef(false);
|
|
147
|
+
if (controller?.skipNextAnimation) skipAdaptAnimation.current = true;
|
|
148
|
+
const hasScrollView = React.useRef(false);
|
|
149
|
+
const opacityFallbackTimer = React.useRef(null);
|
|
150
|
+
useAnimatedNumberReaction({
|
|
151
|
+
value: animatedNumber,
|
|
152
|
+
hostRef: sheetRef
|
|
153
|
+
}, React.useCallback(value => {
|
|
154
|
+
at.current = value;
|
|
155
|
+
scrollBridge.paneY = value;
|
|
156
|
+
const minY = activePositions[0];
|
|
157
|
+
const wasAtTop = scrollBridge.isAtTop;
|
|
158
|
+
const nowAtTop = value <= minY + 5;
|
|
159
|
+
if (wasAtTop !== nowAtTop) {
|
|
160
|
+
scrollBridge.isAtTop = nowAtTop;
|
|
161
|
+
if (nowAtTop) {
|
|
162
|
+
if (scrollBridge.y > 0) {
|
|
163
|
+
scrollBridge.forceScrollTo?.(0);
|
|
164
|
+
scrollBridge.y = 0;
|
|
165
|
+
}
|
|
166
|
+
scrollBridge.scrollLockY = void 0;
|
|
167
|
+
scrollBridge.setScrollEnabled?.(true);
|
|
168
|
+
} else {
|
|
169
|
+
scrollBridge.scrollLockY = 0;
|
|
170
|
+
scrollBridge.setScrollEnabled?.(false);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}, [animationDriver, activePositions]));
|
|
174
|
+
function stopSpring() {
|
|
175
|
+
animatedNumber.stop();
|
|
176
|
+
if (scrollBridge.onFinishAnimate) {
|
|
177
|
+
scrollBridge.onFinishAnimate();
|
|
178
|
+
scrollBridge.onFinishAnimate = void 0;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const animateTo = useEvent((position2, animationOverride) => {
|
|
182
|
+
if (frameSize === 0) return;
|
|
183
|
+
let toValue = isHidden || position2 === -1 ? screenSize : activePositions[position2];
|
|
184
|
+
if (at.current === toValue) return;
|
|
185
|
+
at.current = toValue;
|
|
186
|
+
stopSpring();
|
|
187
|
+
const isOpenAnimation = position2 !== -1 && !isHidden;
|
|
188
|
+
if (opacityFallbackTimer.current) {
|
|
189
|
+
clearTimeout(opacityFallbackTimer.current);
|
|
190
|
+
opacityFallbackTimer.current = null;
|
|
191
|
+
}
|
|
192
|
+
const animationCompleteCallback = () => {
|
|
193
|
+
if (opacityFallbackTimer.current) {
|
|
194
|
+
clearTimeout(opacityFallbackTimer.current);
|
|
195
|
+
opacityFallbackTimer.current = null;
|
|
196
|
+
}
|
|
197
|
+
if (!isOpenAnimation && !openRef.current) setOpacity(0);
|
|
198
|
+
onAnimationComplete?.({
|
|
199
|
+
open: isOpenAnimation
|
|
200
|
+
});
|
|
201
|
+
controller?.onAnimationComplete?.({
|
|
202
|
+
open: isOpenAnimation
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
if (!isOpenAnimation) opacityFallbackTimer.current = setTimeout(() => {
|
|
206
|
+
opacityFallbackTimer.current = null;
|
|
207
|
+
if (!openRef.current) setOpacity(0);
|
|
208
|
+
}, 1e3);
|
|
209
|
+
if (skipAdaptAnimation.current) {
|
|
210
|
+
skipAdaptAnimation.current = false;
|
|
211
|
+
animatedNumber.setValue(toValue, {
|
|
212
|
+
type: "timing",
|
|
213
|
+
duration: 0
|
|
214
|
+
}, animationCompleteCallback);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
animatedNumber.setValue(toValue, animationOverride || {
|
|
218
|
+
type: "spring",
|
|
219
|
+
...transitionConfig
|
|
220
|
+
}, animationCompleteCallback);
|
|
221
|
+
});
|
|
222
|
+
useIsomorphicLayoutEffect(() => {
|
|
223
|
+
if (hasntMeasured && screenSize && frameSize) {
|
|
224
|
+
at.current = screenSize;
|
|
225
|
+
animatedNumber.setValue(screenSize, {
|
|
226
|
+
type: "timing",
|
|
227
|
+
duration: 0
|
|
228
|
+
}, () => {
|
|
229
|
+
setTimeout(() => {
|
|
230
|
+
setDisableAnimation(false);
|
|
231
|
+
}, 10);
|
|
232
|
+
});
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (disableAnimation) return;
|
|
236
|
+
if (!frameSize || !screenSize || isHidden || hasntMeasured && !open) return;
|
|
237
|
+
animateTo(position);
|
|
238
|
+
if (position === -1) {
|
|
239
|
+
scrollBridge.scrollLock = false;
|
|
240
|
+
scrollBridge.scrollStartY = -1;
|
|
241
|
+
}
|
|
242
|
+
if (open && position >= 0) {
|
|
243
|
+
const isTopPosition = position === 0;
|
|
244
|
+
scrollBridge.isAtTop = isTopPosition;
|
|
245
|
+
if (isTopPosition) {
|
|
246
|
+
scrollBridge.scrollLockY = void 0;
|
|
247
|
+
scrollBridge.setScrollEnabled?.(true);
|
|
248
|
+
} else {
|
|
249
|
+
scrollBridge.scrollLockY = 0;
|
|
250
|
+
scrollBridge.setScrollEnabled?.(false);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}, [hasntMeasured, disableAnimation, isHidden, frameSize, screenSize, open, position]);
|
|
254
|
+
const disableDrag = props.disableDrag ?? controller?.disableDrag;
|
|
255
|
+
useThemeName();
|
|
256
|
+
const [blockPan, setBlockPan] = React.useState(false);
|
|
257
|
+
const panResponder = React.useMemo(() => {
|
|
258
|
+
if (disableDrag) return;
|
|
259
|
+
if (!frameSize) return;
|
|
260
|
+
if (isShowingInnerSheet) return;
|
|
261
|
+
const minY = positions[0];
|
|
262
|
+
scrollBridge.paneMinY = minY;
|
|
263
|
+
let startY = at.current;
|
|
264
|
+
function setPanning(val) {
|
|
265
|
+
setIsDragging(val);
|
|
266
|
+
if (!sheetHiddenStyleSheet) {
|
|
267
|
+
sheetHiddenStyleSheet = document.createElement("style");
|
|
268
|
+
if (typeof document.head !== "undefined") document.head.appendChild(sheetHiddenStyleSheet);
|
|
269
|
+
}
|
|
270
|
+
if (!val) sheetHiddenStyleSheet.innerText = "";else sheetHiddenStyleSheet.innerText = ":root * { user-select: none !important; -webkit-user-select: none !important; }";
|
|
271
|
+
}
|
|
272
|
+
const release = ({
|
|
273
|
+
vy
|
|
274
|
+
}) => {
|
|
275
|
+
scrollBridge.setParentDragging(false);
|
|
276
|
+
if (scrollBridge.scrollLock) return;
|
|
277
|
+
isExternalDrag = false;
|
|
278
|
+
previouslyScrolling = false;
|
|
279
|
+
setPanning(false);
|
|
280
|
+
const end = at.current + frameSize * vy * .2;
|
|
281
|
+
let closestPoint = 0;
|
|
282
|
+
let dist = Number.POSITIVE_INFINITY;
|
|
283
|
+
for (let i = 0; i < positions.length; i++) {
|
|
284
|
+
const position2 = positions[i];
|
|
285
|
+
const curDist = end > position2 ? end - position2 : position2 - end;
|
|
286
|
+
if (curDist < dist) {
|
|
287
|
+
dist = curDist;
|
|
288
|
+
closestPoint = i;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
setPosition(closestPoint);
|
|
292
|
+
animateTo(closestPoint);
|
|
293
|
+
};
|
|
294
|
+
const finish = (_e, state2) => {
|
|
295
|
+
release({
|
|
296
|
+
vy: state2.vy,
|
|
297
|
+
dragAt: state2.dy
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
let previouslyScrolling = false;
|
|
301
|
+
const onMoveShouldSet = (e, {
|
|
302
|
+
dy
|
|
303
|
+
}) => {
|
|
304
|
+
function getShouldSet() {
|
|
305
|
+
if (e.target === providerProps.handleRef.current) return true;
|
|
306
|
+
if (scrollBridge.hasScrollableContent === true) {
|
|
307
|
+
if (scrollBridge.scrollLock) return false;
|
|
308
|
+
const isScrolled = scrollBridge.y !== 0;
|
|
309
|
+
const isDraggingUp = dy < 0;
|
|
310
|
+
const isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
|
|
311
|
+
if (isScrolled) return false;
|
|
312
|
+
if (isNearTop) {
|
|
313
|
+
if (hasScrollView.current && isDraggingUp) return false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return Math.abs(dy) > 10;
|
|
317
|
+
}
|
|
318
|
+
const granted = getShouldSet();
|
|
319
|
+
if (granted) scrollBridge.setParentDragging(true);
|
|
320
|
+
return granted;
|
|
321
|
+
};
|
|
322
|
+
const grant = () => {
|
|
323
|
+
setPanning(true);
|
|
324
|
+
stopSpring();
|
|
325
|
+
startY = at.current;
|
|
326
|
+
};
|
|
327
|
+
let isExternalDrag = false;
|
|
328
|
+
scrollBridge.drag = dy => {
|
|
329
|
+
if (!isExternalDrag) {
|
|
330
|
+
isExternalDrag = true;
|
|
331
|
+
grant();
|
|
332
|
+
}
|
|
333
|
+
const to = dy + startY;
|
|
334
|
+
animatedNumber.setValue(resisted(to, minY), {
|
|
335
|
+
type: "direct"
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
scrollBridge.release = release;
|
|
339
|
+
scrollBridge.snapToPosition = positionIndex => {
|
|
340
|
+
isExternalDrag = false;
|
|
341
|
+
setPanning(false);
|
|
342
|
+
setPosition(positionIndex);
|
|
343
|
+
animateTo(positionIndex);
|
|
344
|
+
};
|
|
345
|
+
return PanResponder.create({
|
|
346
|
+
onMoveShouldSetPanResponder: onMoveShouldSet,
|
|
347
|
+
onPanResponderGrant: grant,
|
|
348
|
+
onPanResponderMove: (_e, {
|
|
349
|
+
dy
|
|
350
|
+
}) => {
|
|
351
|
+
const to = resisted(dy + startY, minY);
|
|
352
|
+
if (to <= minY) scrollBridge.setParentDragging(false);else scrollBridge.setParentDragging(true);
|
|
353
|
+
animatedNumber.setValue(to, {
|
|
354
|
+
type: "direct"
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
onPanResponderEnd: finish,
|
|
358
|
+
onPanResponderTerminate: finish,
|
|
359
|
+
onPanResponderRelease: finish
|
|
360
|
+
});
|
|
361
|
+
}, [disableDrag, isShowingInnerSheet, animateTo, frameSize, positions, setPosition]);
|
|
362
|
+
React.useEffect(() => {
|
|
363
|
+
if (isDragging || isHidden || !open || disableAnimation) return;
|
|
364
|
+
if (!frameSize || !screenSize) return;
|
|
365
|
+
animateTo(position, {
|
|
366
|
+
type: "timing",
|
|
367
|
+
duration: 250
|
|
368
|
+
});
|
|
369
|
+
}, [isKeyboardVisible, keyboardHeight]);
|
|
370
|
+
const wasDragging = React.useRef(false);
|
|
371
|
+
React.useEffect(() => {
|
|
372
|
+
if (isDragging) {
|
|
373
|
+
wasDragging.current = true;
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (!wasDragging.current) return;
|
|
377
|
+
wasDragging.current = false;
|
|
378
|
+
if (!frameSize || !screenSize || isHidden || !open) return;
|
|
379
|
+
animateTo(position);
|
|
380
|
+
}, [isDragging]);
|
|
381
|
+
React.useEffect(() => {
|
|
382
|
+
if (!open && isKeyboardVisible) dismissKeyboard();
|
|
383
|
+
}, [open]);
|
|
384
|
+
const {
|
|
385
|
+
panGesture,
|
|
386
|
+
panGestureRef,
|
|
387
|
+
gestureHandlerEnabled
|
|
388
|
+
} = useGestureHandlerPan({
|
|
389
|
+
positions: activePositions,
|
|
390
|
+
frameSize,
|
|
391
|
+
setPosition,
|
|
392
|
+
animateTo,
|
|
393
|
+
stopSpring,
|
|
394
|
+
scrollBridge,
|
|
395
|
+
setIsDragging,
|
|
396
|
+
getCurrentPosition: () => at.current,
|
|
397
|
+
resisted,
|
|
398
|
+
disableDrag,
|
|
399
|
+
isShowingInnerSheet,
|
|
400
|
+
setAnimatedPosition: val => {
|
|
401
|
+
at.current = val;
|
|
402
|
+
animatedNumber.setValue(val, {
|
|
403
|
+
type: "direct"
|
|
404
|
+
});
|
|
405
|
+
},
|
|
406
|
+
pauseKeyboardHandler
|
|
407
|
+
});
|
|
408
|
+
const handleAnimationViewLayout = useEvent(e => {
|
|
409
|
+
if (!open && stableFrameSize.current !== 0) return;
|
|
410
|
+
const layoutHeight = e.nativeEvent?.layout.height;
|
|
411
|
+
const next = modal ? Math.min(layoutHeight, Dimensions.get(relativeDimensionTo).height) : layoutHeight;
|
|
412
|
+
if (!next) return;
|
|
413
|
+
setFrameSize(next);
|
|
414
|
+
});
|
|
415
|
+
const handleMaxContentViewLayout = React.useCallback(e => {
|
|
416
|
+
const next = Math.min(e.nativeEvent?.layout.height, Dimensions.get(relativeDimensionTo).height);
|
|
417
|
+
if (!next) return;
|
|
418
|
+
setMaxContentSize(next);
|
|
419
|
+
}, []);
|
|
420
|
+
const animatedStyle = useAnimatedNumberStyle(animatedNumber, React.useCallback(val => {
|
|
421
|
+
"worklet";
|
|
422
|
+
|
|
423
|
+
return {
|
|
424
|
+
transform: [{
|
|
425
|
+
translateY: frameSize === 0 ? hiddenSize : val
|
|
426
|
+
}]
|
|
427
|
+
};
|
|
428
|
+
}, [frameSize]));
|
|
429
|
+
const [opacity, setOpacity] = React.useState(open ? 1 : 0);
|
|
430
|
+
if (open && opacity === 0) {
|
|
431
|
+
setOpacity(1);
|
|
432
|
+
if (opacityFallbackTimer.current) {
|
|
433
|
+
clearTimeout(opacityFallbackTimer.current);
|
|
434
|
+
opacityFallbackTimer.current = null;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
const forcedContentHeight = hasFit ? void 0 : snapPointsMode === "percent" ? `${maxSnapPoint}${isWeb ? modal ? "dvh" : "%" : "%"}` : maxSnapPoint;
|
|
438
|
+
const setHasScrollView = React.useCallback(val => {
|
|
439
|
+
hasScrollView.current = val;
|
|
440
|
+
}, []);
|
|
441
|
+
let contents = /* @__PURE__ */jsx(LayoutMeasurementController, {
|
|
442
|
+
disable: !open,
|
|
443
|
+
children: /* @__PURE__ */jsx(ParentSheetContext.Provider, {
|
|
444
|
+
value: nextParentContext,
|
|
445
|
+
children: /* @__PURE__ */jsx(SheetProvider, {
|
|
446
|
+
...providerProps,
|
|
447
|
+
setHasScrollView,
|
|
448
|
+
children: /* @__PURE__ */jsxs(GestureSheetProvider, {
|
|
449
|
+
isDragging,
|
|
450
|
+
blockPan,
|
|
451
|
+
setBlockPan,
|
|
452
|
+
panGesture,
|
|
453
|
+
panGestureRef,
|
|
454
|
+
children: [/* @__PURE__ */jsx(AnimatePresence, {
|
|
455
|
+
custom: {
|
|
456
|
+
open
|
|
457
|
+
},
|
|
458
|
+
children: shouldHideParentSheet || !open ? null : overlayComponent
|
|
459
|
+
}), snapPointsMode !== "percent" && /* @__PURE__ */jsx(View, {
|
|
460
|
+
style: {
|
|
461
|
+
opacity: 0,
|
|
462
|
+
position: "absolute",
|
|
463
|
+
top: 0,
|
|
464
|
+
left: 0,
|
|
465
|
+
right: 0,
|
|
466
|
+
bottom: 0,
|
|
467
|
+
pointerEvents: "none"
|
|
468
|
+
},
|
|
469
|
+
onLayout: handleMaxContentViewLayout
|
|
470
|
+
}), /* @__PURE__ */jsx(AnimatedView, {
|
|
471
|
+
ref,
|
|
472
|
+
onLayout: handleAnimationViewLayout,
|
|
473
|
+
transition: isDragging || disableAnimation ? null : transition,
|
|
474
|
+
disableClassName: true,
|
|
475
|
+
style: [{
|
|
476
|
+
position: "absolute",
|
|
477
|
+
zIndex,
|
|
478
|
+
width: "100%",
|
|
479
|
+
height: forcedContentHeight,
|
|
480
|
+
minHeight: forcedContentHeight,
|
|
481
|
+
opacity: !shouldHideParentSheet ? opacity : 0,
|
|
482
|
+
...((shouldHideParentSheet || !open) && {
|
|
483
|
+
pointerEvents: "none"
|
|
484
|
+
})
|
|
485
|
+
}, animatedStyle],
|
|
486
|
+
children: gestureHandlerEnabled && panGesture ? /* @__PURE__ */jsx(GestureDetectorWrapper, {
|
|
487
|
+
gesture: panGesture,
|
|
488
|
+
style: {
|
|
489
|
+
flex: 1
|
|
490
|
+
},
|
|
491
|
+
children: props.children
|
|
492
|
+
}) : /* @__PURE__ */jsx(View, {
|
|
493
|
+
...panResponder?.panHandlers,
|
|
494
|
+
style: {
|
|
495
|
+
flex: 1,
|
|
496
|
+
width: "100%",
|
|
497
|
+
height: "100%"
|
|
498
|
+
},
|
|
499
|
+
children: props.children
|
|
500
|
+
})
|
|
501
|
+
})]
|
|
502
|
+
})
|
|
503
|
+
})
|
|
504
|
+
})
|
|
505
|
+
});
|
|
506
|
+
const shouldMountChildren = unmountChildrenWhenHidden ? !!opacity : true;
|
|
507
|
+
if (modal) {
|
|
508
|
+
const modalContents = /* @__PURE__ */jsx(Portal, {
|
|
509
|
+
stackZIndex: zIndex,
|
|
510
|
+
...portalProps,
|
|
511
|
+
children: shouldMountChildren && /* @__PURE__ */jsx(ContainerComponent, {
|
|
512
|
+
children: contents
|
|
513
|
+
})
|
|
514
|
+
});
|
|
515
|
+
if (isWeb) return modalContents;
|
|
516
|
+
return /* @__PURE__ */jsx(SheetInsideSheetContext.Provider, {
|
|
517
|
+
value: onInnerSheet,
|
|
518
|
+
children: modalContents
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
return contents;
|
|
522
|
+
});
|
|
523
|
+
function getYPositions(mode, point, screenSize, frameSize) {
|
|
524
|
+
if (!screenSize || !frameSize) return 0;
|
|
525
|
+
if (mode === "mixed") {
|
|
526
|
+
if (typeof point === "number") return screenSize - Math.min(screenSize, Math.max(0, point));
|
|
527
|
+
if (point === "fit") return screenSize - Math.min(screenSize, frameSize);
|
|
528
|
+
if (point.endsWith("%")) {
|
|
529
|
+
const pct2 = Math.min(100, Math.max(0, Number(point.slice(0, -1)))) / 100;
|
|
530
|
+
if (Number.isNaN(pct2)) {
|
|
531
|
+
console.warn("Invalid snapPoint percentage string");
|
|
532
|
+
return 0;
|
|
533
|
+
}
|
|
534
|
+
return Math.round(screenSize - pct2 * screenSize);
|
|
535
|
+
}
|
|
536
|
+
console.warn("Invalid snapPoint unknown value");
|
|
537
|
+
return 0;
|
|
538
|
+
}
|
|
539
|
+
if (mode === "fit") {
|
|
540
|
+
if (point === 0) return screenSize;
|
|
541
|
+
return screenSize - Math.min(screenSize, frameSize);
|
|
542
|
+
}
|
|
543
|
+
if (mode === "constant" && typeof point === "number") return screenSize - Math.min(screenSize, Math.max(0, point));
|
|
544
|
+
const pct = Math.min(100, Math.max(0, Number(point))) / 100;
|
|
545
|
+
if (Number.isNaN(pct)) {
|
|
546
|
+
console.warn("Invalid snapPoint percentage");
|
|
547
|
+
return 0;
|
|
548
|
+
}
|
|
549
|
+
return Math.round(screenSize - pct * screenSize);
|
|
550
|
+
}
|
|
551
|
+
export { SheetImplementationCustom };
|
|
552
|
+
//# sourceMappingURL=SheetImplementationCustom.mjs.map
|