@hanzogui/sheet 7.3.1 → 8.0.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/.turbo/turbo-build.log +2 -0
- package/controller/index.cjs +2 -0
- package/controller/index.d.ts +5 -0
- package/controller/index.js +2 -0
- package/controller/index.native.cjs +2 -0
- package/controller/index.native.js +2 -0
- package/dist/cjs/GestureDetectorWrapper.native.js.map +1 -1
- package/dist/cjs/SheetImplementationCustom.cjs +137 -74
- package/dist/cjs/SheetImplementationCustom.native.js +162 -83
- package/dist/cjs/SheetImplementationCustom.native.js.map +1 -1
- package/dist/cjs/SheetScrollView.cjs +155 -34
- package/dist/cjs/SheetScrollView.native.js +160 -35
- package/dist/cjs/SheetScrollView.native.js.map +1 -1
- package/dist/cjs/createSheet.cjs +7 -3
- package/dist/cjs/createSheet.native.js +7 -3
- package/dist/cjs/createSheet.native.js.map +1 -1
- package/dist/cjs/gestureState.cjs +13 -2
- package/dist/cjs/gestureState.native.js +14 -2
- package/dist/cjs/gestureState.native.js.map +1 -1
- package/dist/cjs/index.cjs +12 -1
- package/dist/cjs/index.native.js +11 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/keyboardAvoidance.cjs +93 -0
- package/dist/cjs/keyboardAvoidance.native.js +99 -0
- package/dist/cjs/keyboardAvoidance.native.js.map +1 -0
- package/dist/cjs/nativeSheet.cjs +3 -0
- package/dist/cjs/nativeSheet.native.js +3 -0
- package/dist/cjs/nativeSheet.native.js.map +1 -1
- package/dist/cjs/setupGestureHandler.cjs +9 -6
- package/dist/cjs/setupGestureHandler.native.js +11 -6
- package/dist/cjs/setupGestureHandler.native.js.map +1 -1
- package/dist/cjs/useGestureHandlerPan.cjs +86 -18
- package/dist/cjs/useGestureHandlerPan.native.js +91 -18
- package/dist/cjs/useGestureHandlerPan.native.js.map +1 -1
- package/dist/cjs/useKeyboardControllerSheet.cjs +68 -6
- package/dist/cjs/useSafeAreaInsets.cjs +44 -0
- package/dist/cjs/useSafeAreaInsets.native.js +48 -0
- package/dist/cjs/useSafeAreaInsets.native.js.map +1 -0
- package/dist/cjs/useSheetProviderProps.cjs +1 -1
- package/dist/cjs/useSheetProviderProps.native.js +1 -1
- package/dist/cjs/useSheetProviderProps.native.js.map +1 -1
- package/dist/cjs/useSheetScrollViewGestures.cjs +30 -5
- package/dist/cjs/useSheetScrollViewGestures.native.js +4 -0
- package/dist/cjs/useSheetScrollViewGestures.native.js.map +1 -1
- package/dist/cjs/webViewport.cjs +75 -0
- package/dist/cjs/webViewport.native.js +81 -0
- package/dist/cjs/webViewport.native.js.map +1 -0
- package/dist/esm/GestureDetectorWrapper.mjs.map +1 -1
- package/dist/esm/GestureDetectorWrapper.native.js.map +1 -1
- package/dist/esm/SheetImplementationCustom.mjs +143 -84
- package/dist/esm/SheetImplementationCustom.mjs.map +1 -1
- package/dist/esm/SheetImplementationCustom.native.js +173 -102
- package/dist/esm/SheetImplementationCustom.native.js.map +1 -1
- package/dist/esm/SheetScrollView.mjs +157 -36
- package/dist/esm/SheetScrollView.mjs.map +1 -1
- package/dist/esm/SheetScrollView.native.js +162 -37
- package/dist/esm/SheetScrollView.native.js.map +1 -1
- package/dist/esm/createSheet.mjs +9 -6
- package/dist/esm/createSheet.mjs.map +1 -1
- package/dist/esm/createSheet.native.js +19 -15
- package/dist/esm/createSheet.native.js.map +1 -1
- package/dist/esm/gestureState.mjs +13 -2
- package/dist/esm/gestureState.mjs.map +1 -1
- package/dist/esm/gestureState.native.js +14 -2
- package/dist/esm/gestureState.native.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +2 -0
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/keyboardAvoidance.mjs +66 -0
- package/dist/esm/keyboardAvoidance.mjs.map +1 -0
- package/dist/esm/keyboardAvoidance.native.js +69 -0
- package/dist/esm/keyboardAvoidance.native.js.map +1 -0
- package/dist/esm/nativeSheet.mjs +3 -0
- package/dist/esm/nativeSheet.mjs.map +1 -1
- package/dist/esm/nativeSheet.native.js +3 -0
- package/dist/esm/nativeSheet.native.js.map +1 -1
- package/dist/esm/setupGestureHandler.mjs +9 -6
- package/dist/esm/setupGestureHandler.mjs.map +1 -1
- package/dist/esm/setupGestureHandler.native.js +11 -6
- package/dist/esm/setupGestureHandler.native.js.map +1 -1
- package/dist/esm/useGestureHandlerPan.mjs +87 -19
- package/dist/esm/useGestureHandlerPan.mjs.map +1 -1
- package/dist/esm/useGestureHandlerPan.native.js +92 -19
- package/dist/esm/useGestureHandlerPan.native.js.map +1 -1
- package/dist/esm/useKeyboardControllerSheet.mjs +69 -7
- package/dist/esm/useKeyboardControllerSheet.mjs.map +1 -1
- package/dist/esm/useSafeAreaInsets.mjs +7 -0
- package/dist/esm/useSafeAreaInsets.mjs.map +1 -0
- package/dist/esm/useSafeAreaInsets.native.js +8 -0
- package/dist/esm/useSafeAreaInsets.native.js.map +1 -0
- package/dist/esm/useSheetProviderProps.mjs +1 -1
- package/dist/esm/useSheetProviderProps.mjs.map +1 -1
- package/dist/esm/useSheetProviderProps.native.js +1 -1
- package/dist/esm/useSheetProviderProps.native.js.map +1 -1
- package/dist/esm/useSheetScrollViewGestures.mjs +30 -5
- package/dist/esm/useSheetScrollViewGestures.mjs.map +1 -1
- package/dist/esm/useSheetScrollViewGestures.native.js +4 -0
- package/dist/esm/useSheetScrollViewGestures.native.js.map +1 -1
- package/dist/esm/webViewport.mjs +43 -0
- package/dist/esm/webViewport.mjs.map +1 -0
- package/dist/esm/webViewport.native.js +46 -0
- package/dist/esm/webViewport.native.js.map +1 -0
- package/dist/jsx/GestureDetectorWrapper.mjs.map +1 -1
- package/dist/jsx/GestureDetectorWrapper.native.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.mjs +143 -84
- package/dist/jsx/SheetImplementationCustom.mjs.map +1 -1
- package/dist/jsx/SheetImplementationCustom.native.js +162 -83
- package/dist/jsx/SheetImplementationCustom.native.js.map +1 -1
- package/dist/jsx/SheetScrollView.mjs +157 -36
- package/dist/jsx/SheetScrollView.mjs.map +1 -1
- package/dist/jsx/SheetScrollView.native.js +160 -35
- package/dist/jsx/SheetScrollView.native.js.map +1 -1
- package/dist/jsx/createSheet.mjs +9 -6
- package/dist/jsx/createSheet.mjs.map +1 -1
- package/dist/jsx/createSheet.native.js +7 -3
- package/dist/jsx/createSheet.native.js.map +1 -1
- package/dist/jsx/gestureState.mjs +13 -2
- package/dist/jsx/gestureState.mjs.map +1 -1
- package/dist/jsx/gestureState.native.js +14 -2
- package/dist/jsx/gestureState.native.js.map +1 -1
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +2 -0
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +11 -0
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/keyboardAvoidance.mjs +66 -0
- package/dist/jsx/keyboardAvoidance.mjs.map +1 -0
- package/dist/jsx/keyboardAvoidance.native.js +99 -0
- package/dist/jsx/keyboardAvoidance.native.js.map +1 -0
- package/dist/jsx/nativeSheet.mjs +3 -0
- package/dist/jsx/nativeSheet.mjs.map +1 -1
- package/dist/jsx/nativeSheet.native.js +3 -0
- package/dist/jsx/nativeSheet.native.js.map +1 -1
- package/dist/jsx/setupGestureHandler.mjs +9 -6
- package/dist/jsx/setupGestureHandler.mjs.map +1 -1
- package/dist/jsx/setupGestureHandler.native.js +11 -6
- package/dist/jsx/setupGestureHandler.native.js.map +1 -1
- package/dist/jsx/useGestureHandlerPan.mjs +87 -19
- package/dist/jsx/useGestureHandlerPan.mjs.map +1 -1
- package/dist/jsx/useGestureHandlerPan.native.js +91 -18
- package/dist/jsx/useGestureHandlerPan.native.js.map +1 -1
- package/dist/jsx/useKeyboardControllerSheet.mjs +69 -7
- package/dist/jsx/useKeyboardControllerSheet.mjs.map +1 -1
- package/dist/jsx/useSafeAreaInsets.mjs +7 -0
- package/dist/jsx/useSafeAreaInsets.mjs.map +1 -0
- package/dist/jsx/useSafeAreaInsets.native.js +48 -0
- package/dist/jsx/useSafeAreaInsets.native.js.map +1 -0
- package/dist/jsx/useSheetProviderProps.mjs +1 -1
- package/dist/jsx/useSheetProviderProps.mjs.map +1 -1
- package/dist/jsx/useSheetProviderProps.native.js +1 -1
- package/dist/jsx/useSheetProviderProps.native.js.map +1 -1
- package/dist/jsx/useSheetScrollViewGestures.mjs +30 -5
- package/dist/jsx/useSheetScrollViewGestures.mjs.map +1 -1
- package/dist/jsx/useSheetScrollViewGestures.native.js +4 -0
- package/dist/jsx/useSheetScrollViewGestures.native.js.map +1 -1
- package/dist/jsx/webViewport.mjs +43 -0
- package/dist/jsx/webViewport.mjs.map +1 -0
- package/dist/jsx/webViewport.native.js +81 -0
- package/dist/jsx/webViewport.native.js.map +1 -0
- package/next.md +78 -0
- package/package.json +30 -52
- package/setup-gesture-handler/index.cjs +2 -0
- package/setup-gesture-handler/index.js +2 -0
- package/setup-gesture-handler/index.native.cjs +2 -0
- package/setup-gesture-handler/index.native.js +2 -0
- package/src/GestureDetectorWrapper.tsx +0 -3
- package/src/SheetImplementationCustom.tsx +387 -127
- package/src/SheetScrollView.tsx +195 -22
- package/src/createSheet.tsx +20 -7
- package/src/gestureState.ts +22 -2
- package/src/index.ts +4 -0
- package/src/keyboardAvoidance.ts +121 -0
- package/src/nativeSheet.tsx +8 -1
- package/src/setupGestureHandler.ts +14 -5
- package/src/types.tsx +20 -1
- package/src/useGestureHandlerPan.tsx +94 -35
- package/src/useKeyboardControllerSheet.ts +127 -10
- package/src/useSafeAreaInsets.native.ts +29 -0
- package/src/useSafeAreaInsets.ts +19 -0
- package/src/useSheetProviderProps.tsx +12 -1
- package/src/useSheetScrollViewGestures.native.ts +4 -0
- package/src/useSheetScrollViewGestures.ts +52 -5
- package/src/webViewport.ts +100 -0
- package/test/keyboardAvoidance.test.ts +269 -0
- package/tsconfig.json +57 -0
- package/types/GestureDetectorWrapper.d.ts +1 -1
- package/types/GestureDetectorWrapper.d.ts.map +1 -1
- package/types/GestureSheetContext.d.ts +1 -1
- package/types/GestureSheetContext.d.ts.map +1 -1
- package/types/Sheet.d.ts +6 -5
- package/types/Sheet.d.ts.map +1 -1
- package/types/SheetContext.d.ts +5 -2
- package/types/SheetContext.d.ts.map +1 -1
- package/types/SheetController.d.ts +1 -2
- package/types/SheetController.d.ts.map +1 -1
- package/types/SheetImplementationCustom.d.ts +1 -0
- package/types/SheetImplementationCustom.d.ts.map +1 -1
- package/types/SheetScrollView.d.ts.map +1 -1
- package/types/createSheet.d.ts +13 -12
- package/types/createSheet.d.ts.map +1 -1
- package/types/gestureState.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/keyboardAvoidance.d.ts +26 -0
- package/types/keyboardAvoidance.d.ts.map +1 -0
- package/types/nativeSheet.d.ts.map +1 -1
- package/types/setupGestureHandler.d.ts.map +1 -1
- package/types/types.d.ts +10 -1
- package/types/types.d.ts.map +1 -1
- package/types/useGestureHandlerPan.d.ts +4 -1
- package/types/useGestureHandlerPan.d.ts.map +1 -1
- package/types/useKeyboardControllerSheet.d.ts +14 -3
- package/types/useKeyboardControllerSheet.d.ts.map +1 -1
- package/types/useSafeAreaInsets.d.ts +10 -0
- package/types/useSafeAreaInsets.d.ts.map +1 -0
- package/types/useSafeAreaInsets.native.d.ts +20 -0
- package/types/useSafeAreaInsets.native.d.ts.map +1 -0
- package/types/useSheetProviderProps.d.ts +3 -0
- package/types/useSheetProviderProps.d.ts.map +1 -1
- package/types/useSheetScrollViewGestures.d.ts +2 -1
- package/types/useSheetScrollViewGestures.d.ts.map +1 -1
- package/types/useSheetScrollViewGestures.native.d.ts.map +1 -1
- package/types/webViewport.d.ts +36 -0
- package/types/webViewport.d.ts.map +1 -0
- package/LICENSE +0 -42
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Type declarations for @hanzogui/sheet/controller path resolution
|
|
2
|
+
// Runtime uses exports field -> dist/esm/controller.mjs
|
|
3
|
+
|
|
4
|
+
export { SheetController } from '../src/SheetController'
|
|
5
|
+
export { SheetControllerContext, useSheetController, type SheetControllerContextValue } from '../src/useSheetController'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","GestureDetectorWrapper_exports","__export","GestureDetectorWrapper","module","exports","import_jsx_runtime","require","import_react_native","import_gestureState","param","gesture","children","style","GestureDetector","getGestureHandlerState","enabled","isGestureHandlerEnabled","jsx","View","collapsable"],"sources":["../../src/GestureDetectorWrapper.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,8BAAA;AAAAC,QAAA,CAAAD,8BAAA;EAAAE,sBAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAAqC,CAAAK,8BAAA;AACrC,IAAAK,kBAAA,GAAAC,OAAgE;
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","GestureDetectorWrapper_exports","__export","GestureDetectorWrapper","module","exports","import_jsx_runtime","require","import_react_native","import_gestureState","param","gesture","children","style","GestureDetector","getGestureHandlerState","enabled","isGestureHandlerEnabled","jsx","View","collapsable"],"sources":["../../src/GestureDetectorWrapper.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,8BAAA;AAAAC,QAAA,CAAAD,8BAAA;EAAAE,sBAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAAqC,CAAAK,8BAAA;AACrC,IAAAK,kBAAA,GAAAC,OAAgE;AA0BxD,IAAAC,mBAAA,GAAAD,OAAA;AAdD,IAAAE,mBAAS,GAAAF,OAAuB;AAAA,SACrCJ,uBAAAO,KAAA;EACA;IAAAC,OAAA;IAAAC,QAAA;IAAAC;EAAA,IAAAH,KAAA;EACA;IAAAI;EAAA,QAAAL,mBAAA,CAAAM,sBAAA;EACF,IAAgCC,OAAA,OAAAP,mBAAA,CAAAQ,uBAAA;EAC9B,IAAAD,OAAQ,IAAAF,eAAgB,IAAIH,OAAA;IAC5B,OAAM,eAAU,IAAAL,kBAAA,CAAAY,GAAA,EAAAJ,eAAwB;MAGpCH,OAAA;MAGFC,QACE,qBAAAN,kBAAA,CAACY,GAAA,EAAAV,mBAAgB,CAAAW,IACf;QAKNN,KAAA;QAGAO,WAAO;QACTR","ignoreList":[]}
|
|
@@ -41,31 +41,41 @@ var import_animate_presence = require("@hanzogui/animate-presence");
|
|
|
41
41
|
var import_compose_refs = require("@hanzogui/compose-refs");
|
|
42
42
|
var import_constants = require("@hanzogui/constants");
|
|
43
43
|
var import_core = require("@hanzogui/core");
|
|
44
|
-
var import_native = require("@hanzogui/native");
|
|
45
44
|
var import_portal = require("@hanzogui/portal");
|
|
46
45
|
var import_react = __toESM(require("react"), 1);
|
|
47
46
|
var import_react_native = require("react-native-web");
|
|
48
47
|
var import_contexts = require("./contexts.cjs");
|
|
49
48
|
var import_GestureDetectorWrapper = require("./GestureDetectorWrapper.cjs");
|
|
49
|
+
var import_gestureState = require("./gestureState.cjs");
|
|
50
50
|
var import_GestureSheetContext = require("./GestureSheetContext.cjs");
|
|
51
51
|
var import_helpers = require("./helpers.cjs");
|
|
52
|
+
var import_keyboardAvoidance = require("./keyboardAvoidance.cjs");
|
|
53
|
+
var import_webViewport = require("./webViewport.cjs");
|
|
52
54
|
var import_SheetContext = require("./SheetContext.cjs");
|
|
53
55
|
var import_useGestureHandlerPan = require("./useGestureHandlerPan.cjs");
|
|
54
56
|
var import_useKeyboardControllerSheet = require("./useKeyboardControllerSheet.cjs");
|
|
57
|
+
var import_useSafeAreaInsets = require("./useSafeAreaInsets.cjs");
|
|
55
58
|
var import_useSheetOpenState = require("./useSheetOpenState.cjs");
|
|
56
59
|
var import_useSheetProviderProps = require("./useSheetProviderProps.cjs");
|
|
57
60
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
58
61
|
const hiddenSize = 10000.1;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const rnghRootStyleOpen = {
|
|
63
|
+
width: "100%",
|
|
64
|
+
height: "100%"
|
|
65
|
+
};
|
|
66
|
+
const rnghRootStyleClosed = {
|
|
67
|
+
width: "100%",
|
|
68
|
+
height: 0
|
|
69
|
+
};
|
|
65
70
|
let sheetHiddenStyleSheet = null;
|
|
66
71
|
const relativeDimensionTo = import_constants.isWeb ? "window" : "screen";
|
|
72
|
+
function getStableViewportHeight() {
|
|
73
|
+
if (import_constants.isWeb && typeof window !== "undefined") return (0, import_webViewport.getStableLayoutViewportHeight)();
|
|
74
|
+
return import_react_native.Dimensions.get(relativeDimensionTo).height;
|
|
75
|
+
}
|
|
67
76
|
const SheetImplementationCustom = import_react.default.forwardRef(function SheetImplementationCustom2(props, forwardedRef) {
|
|
68
77
|
const parentSheet = import_react.default.useContext(import_contexts.ParentSheetContext);
|
|
78
|
+
const safeAreaTopInset = (0, import_useSafeAreaInsets.useSafeAreaInsets)()?.top ?? 0;
|
|
69
79
|
const {
|
|
70
80
|
transition,
|
|
71
81
|
transitionConfig: transitionConfigProp,
|
|
@@ -73,6 +83,7 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
73
83
|
zIndex = parentSheet.zIndex + 1,
|
|
74
84
|
moveOnKeyboardChange = false,
|
|
75
85
|
unmountChildrenWhenHidden = false,
|
|
86
|
+
disableTransparencyHide = false,
|
|
76
87
|
portalProps,
|
|
77
88
|
containerComponent: ContainerComponent = import_react.default.Fragment,
|
|
78
89
|
onAnimationComplete
|
|
@@ -85,6 +96,7 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
85
96
|
const {
|
|
86
97
|
frameSize,
|
|
87
98
|
setFrameSize,
|
|
99
|
+
dismissOnSnapToBottom,
|
|
88
100
|
snapPoints,
|
|
89
101
|
snapPointsMode,
|
|
90
102
|
hasFit,
|
|
@@ -123,12 +135,6 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
123
135
|
const onInnerSheet = import_react.default.useCallback(hasChild => {
|
|
124
136
|
setIsShowingInnerSheet(hasChild);
|
|
125
137
|
}, []);
|
|
126
|
-
const stableFrameSize = import_react.default.useRef(frameSize);
|
|
127
|
-
import_react.default.useEffect(() => {
|
|
128
|
-
if (open && frameSize) stableFrameSize.current = frameSize;
|
|
129
|
-
}, [open, frameSize]);
|
|
130
|
-
const effectiveFrameSize = open ? frameSize : stableFrameSize.current || frameSize;
|
|
131
|
-
const positions = import_react.default.useMemo(() => snapPoints.map(point => getYPositions(snapPointsMode, point, screenSize, effectiveFrameSize)), [screenSize, effectiveFrameSize, snapPoints, snapPointsMode]);
|
|
132
138
|
const {
|
|
133
139
|
keyboardHeight,
|
|
134
140
|
isKeyboardVisible,
|
|
@@ -136,8 +142,21 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
136
142
|
pauseKeyboardHandler,
|
|
137
143
|
flushPendingHide
|
|
138
144
|
} = (0, import_useKeyboardControllerSheet.useKeyboardControllerSheet)({
|
|
139
|
-
enabled:
|
|
145
|
+
enabled: Boolean(moveOnKeyboardChange)
|
|
140
146
|
});
|
|
147
|
+
const stableFrameSize = import_react.default.useRef(frameSize);
|
|
148
|
+
import_react.default.useEffect(() => {
|
|
149
|
+
if (open && frameSize) stableFrameSize.current = frameSize;
|
|
150
|
+
}, [open, frameSize]);
|
|
151
|
+
const isWebKbSheet = import_constants.isWeb && hasFit && moveOnKeyboardChange;
|
|
152
|
+
const isNativeKbFitSheet = !import_constants.isWeb && hasFit && Boolean(moveOnKeyboardChange);
|
|
153
|
+
const preKeyboardFrameSize = import_react.default.useRef(0);
|
|
154
|
+
import_react.default.useEffect(() => {
|
|
155
|
+
if (isNativeKbFitSheet && open && !isKeyboardVisible && frameSize > 0) preKeyboardFrameSize.current = frameSize;
|
|
156
|
+
}, [isNativeKbFitSheet, open, isKeyboardVisible, frameSize]);
|
|
157
|
+
const effScreenSize = isWebKbSheet ? getStableViewportHeight() : screenSize;
|
|
158
|
+
const effectiveFrameSize = open ? frameSize : stableFrameSize.current || frameSize;
|
|
159
|
+
const positions = import_react.default.useMemo(() => snapPoints.map(point => getYPositions(snapPointsMode, point, effScreenSize, effectiveFrameSize)), [effScreenSize, effectiveFrameSize, snapPoints, snapPointsMode]);
|
|
141
160
|
const [isDragging, setIsDragging_] = import_react.default.useState(false);
|
|
142
161
|
const isDraggingRef = import_react.default.useRef(false);
|
|
143
162
|
const setIsDragging = import_react.default.useCallback(val => {
|
|
@@ -150,20 +169,28 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
150
169
|
const activePositions = import_react.default.useMemo(() => {
|
|
151
170
|
if (isDragging || isDraggingRef.current) return activePositionsRef.current;
|
|
152
171
|
let result;
|
|
153
|
-
if (!isKeyboardVisible || keyboardHeight <= 0) result = positions;else {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
172
|
+
if (!isKeyboardVisible || keyboardHeight <= 0) result = positions;else result = positions.map(p => (0, import_keyboardAvoidance.getKeyboardAdjustedSheetY)({
|
|
173
|
+
sheetY: p,
|
|
174
|
+
screenSize: effScreenSize,
|
|
175
|
+
isKeyboardVisible,
|
|
176
|
+
keyboardHeight,
|
|
177
|
+
shouldTranslate: true,
|
|
178
|
+
safeAreaTop: import_constants.isWeb ? (0, import_webViewport.getWebVisualViewportOffsetTop)() : safeAreaTopInset
|
|
179
|
+
}));
|
|
160
180
|
activePositionsRef.current = result;
|
|
161
181
|
return result;
|
|
162
|
-
}, [positions, isKeyboardVisible, keyboardHeight,
|
|
182
|
+
}, [positions, isKeyboardVisible, keyboardHeight, effScreenSize, isDragging, safeAreaTopInset]);
|
|
183
|
+
const keyboardOccludedHeight = (0, import_keyboardAvoidance.getKeyboardOccludedHeight)({
|
|
184
|
+
frameSize: effectiveFrameSize,
|
|
185
|
+
isKeyboardVisible,
|
|
186
|
+
keyboardHeight,
|
|
187
|
+
screenSize: effScreenSize,
|
|
188
|
+
sheetY: position >= 0 ? activePositions[position] : void 0
|
|
189
|
+
});
|
|
190
|
+
const keyboardStableFrameHeight = isWebKbSheet && isKeyboardVisible && frameSize > 0 ? frameSize : isNativeKbFitSheet && isKeyboardVisible && preKeyboardFrameSize.current > 0 ? preKeyboardFrameSize.current : 0;
|
|
163
191
|
const {
|
|
164
192
|
useAnimatedNumber,
|
|
165
|
-
useAnimatedNumberStyle
|
|
166
|
-
useAnimatedNumberReaction
|
|
193
|
+
useAnimatedNumberStyle
|
|
167
194
|
} = animationDriver;
|
|
168
195
|
const AnimatedView = animationDriver.View ?? import_core.View;
|
|
169
196
|
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
@@ -185,30 +212,46 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
185
212
|
if (controller?.skipNextAnimation) skipAdaptAnimation.current = true;
|
|
186
213
|
const hasScrollView = import_react.default.useRef(false);
|
|
187
214
|
const opacityFallbackTimer = import_react.default.useRef(null);
|
|
188
|
-
|
|
189
|
-
value: animatedNumber,
|
|
190
|
-
hostRef: sheetRef
|
|
191
|
-
}, import_react.default.useCallback(value => {
|
|
215
|
+
const syncAnimatedPosition = (0, import_core.useEvent)(value => {
|
|
192
216
|
at.current = value;
|
|
193
217
|
scrollBridge.paneY = value;
|
|
194
218
|
const minY = activePositions[0];
|
|
195
219
|
const wasAtTop = scrollBridge.isAtTop;
|
|
196
220
|
const nowAtTop = value <= minY + 5;
|
|
197
|
-
if (wasAtTop
|
|
198
|
-
|
|
199
|
-
|
|
221
|
+
if (wasAtTop === nowAtTop) return;
|
|
222
|
+
scrollBridge.isAtTop = nowAtTop;
|
|
223
|
+
if (nowAtTop) {
|
|
224
|
+
if (scrollBridge.lockScrollAtTop) {
|
|
200
225
|
if (scrollBridge.y > 0) {
|
|
201
226
|
scrollBridge.forceScrollTo?.(0);
|
|
202
227
|
scrollBridge.y = 0;
|
|
203
228
|
}
|
|
204
|
-
scrollBridge.scrollLockY = void 0;
|
|
205
|
-
scrollBridge.setScrollEnabled?.(true);
|
|
206
|
-
} else {
|
|
207
229
|
scrollBridge.scrollLockY = 0;
|
|
208
|
-
scrollBridge.setScrollEnabled?.(false);
|
|
230
|
+
scrollBridge.setScrollEnabled?.(false, 0);
|
|
231
|
+
return;
|
|
209
232
|
}
|
|
233
|
+
if (scrollBridge.y > 0) {
|
|
234
|
+
scrollBridge.forceScrollTo?.(0);
|
|
235
|
+
scrollBridge.y = 0;
|
|
236
|
+
}
|
|
237
|
+
scrollBridge.scrollLockY = void 0;
|
|
238
|
+
scrollBridge.setScrollEnabled?.(true);
|
|
239
|
+
} else {
|
|
240
|
+
scrollBridge.scrollLockY = 0;
|
|
241
|
+
scrollBridge.setScrollEnabled?.(false);
|
|
210
242
|
}
|
|
211
|
-
}
|
|
243
|
+
});
|
|
244
|
+
const setAnimatedPositionDirect = (0, import_core.useEvent)(value => {
|
|
245
|
+
syncAnimatedPosition(value);
|
|
246
|
+
animatedNumber.setValue(value, {
|
|
247
|
+
type: "direct"
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
const getAnimatedPosition = (0, import_core.useEvent)(() => {
|
|
251
|
+
const value = animatedNumber.getValue();
|
|
252
|
+
syncAnimatedPosition(value);
|
|
253
|
+
return value;
|
|
254
|
+
});
|
|
212
255
|
function stopSpring() {
|
|
213
256
|
animatedNumber.stop();
|
|
214
257
|
if (scrollBridge.onFinishAnimate) {
|
|
@@ -218,7 +261,8 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
218
261
|
}
|
|
219
262
|
const animateTo = (0, import_core.useEvent)((position2, animationOverride) => {
|
|
220
263
|
if (frameSize === 0) return;
|
|
221
|
-
|
|
264
|
+
const closeTarget = import_constants.isWeb ? Math.max(effScreenSize, (0, import_webViewport.getMaxViewportHeight)()) : effScreenSize;
|
|
265
|
+
let toValue = isHidden || position2 === -1 ? closeTarget : activePositions[position2];
|
|
222
266
|
if (at.current === toValue) return;
|
|
223
267
|
at.current = toValue;
|
|
224
268
|
stopSpring();
|
|
@@ -228,6 +272,7 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
228
272
|
opacityFallbackTimer.current = null;
|
|
229
273
|
}
|
|
230
274
|
const animationCompleteCallback = () => {
|
|
275
|
+
syncAnimatedPosition(toValue);
|
|
231
276
|
if (opacityFallbackTimer.current) {
|
|
232
277
|
clearTimeout(opacityFallbackTimer.current);
|
|
233
278
|
opacityFallbackTimer.current = null;
|
|
@@ -264,6 +309,7 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
264
309
|
type: "timing",
|
|
265
310
|
duration: 0
|
|
266
311
|
}, () => {
|
|
312
|
+
syncAnimatedPosition(screenSize);
|
|
267
313
|
setTimeout(() => {
|
|
268
314
|
setDisableAnimation(false);
|
|
269
315
|
}, 10);
|
|
@@ -271,6 +317,7 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
271
317
|
return;
|
|
272
318
|
}
|
|
273
319
|
if (disableAnimation) return;
|
|
320
|
+
if (isDraggingRef.current) return;
|
|
274
321
|
if (!frameSize || !screenSize || isHidden || hasntMeasured && !open) return;
|
|
275
322
|
animateTo(position);
|
|
276
323
|
if (position === -1) {
|
|
@@ -296,7 +343,7 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
296
343
|
if (disableDrag) return;
|
|
297
344
|
if (!frameSize) return;
|
|
298
345
|
if (isShowingInnerSheet) return;
|
|
299
|
-
const minY =
|
|
346
|
+
const minY = activePositions[0];
|
|
300
347
|
scrollBridge.paneMinY = minY;
|
|
301
348
|
let startY = at.current;
|
|
302
349
|
function setPanning(val) {
|
|
@@ -315,17 +362,18 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
315
362
|
isExternalDrag = false;
|
|
316
363
|
previouslyScrolling = false;
|
|
317
364
|
setPanning(false);
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
365
|
+
const currentPos = at.current;
|
|
366
|
+
const end = currentPos + frameSize * vy * .2;
|
|
367
|
+
const closestPoint = (0, import_keyboardAvoidance.getSheetReleasePosition)({
|
|
368
|
+
positions: activePositions,
|
|
369
|
+
projectedEnd: end,
|
|
370
|
+
currentPosition: currentPos,
|
|
371
|
+
frameSize,
|
|
372
|
+
dismissOnSnapToBottom,
|
|
373
|
+
snapPointsMode,
|
|
374
|
+
isKeyboardVisible,
|
|
375
|
+
isWeb: import_constants.isWeb
|
|
376
|
+
});
|
|
329
377
|
setPosition(closestPoint);
|
|
330
378
|
animateTo(closestPoint);
|
|
331
379
|
};
|
|
@@ -341,6 +389,7 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
341
389
|
}) => {
|
|
342
390
|
function getShouldSet() {
|
|
343
391
|
if (e.target === providerProps.handleRef.current) return true;
|
|
392
|
+
if (scrollBridge.scrollNodeTouched) return false;
|
|
344
393
|
if (scrollBridge.hasScrollableContent === true) {
|
|
345
394
|
if (scrollBridge.scrollLock) return false;
|
|
346
395
|
const isScrolled = scrollBridge.y !== 0;
|
|
@@ -360,18 +409,20 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
360
409
|
const grant = () => {
|
|
361
410
|
setPanning(true);
|
|
362
411
|
stopSpring();
|
|
363
|
-
startY =
|
|
412
|
+
startY = getAnimatedPosition();
|
|
364
413
|
};
|
|
365
414
|
let isExternalDrag = false;
|
|
415
|
+
scrollBridge.startPanDrag = () => {
|
|
416
|
+
isExternalDrag = true;
|
|
417
|
+
grant();
|
|
418
|
+
};
|
|
366
419
|
scrollBridge.drag = dy => {
|
|
367
420
|
if (!isExternalDrag) {
|
|
368
421
|
isExternalDrag = true;
|
|
369
422
|
grant();
|
|
370
423
|
}
|
|
371
424
|
const to = dy + startY;
|
|
372
|
-
|
|
373
|
-
type: "direct"
|
|
374
|
-
});
|
|
425
|
+
setAnimatedPositionDirect((0, import_helpers.resisted)(to, minY));
|
|
375
426
|
};
|
|
376
427
|
scrollBridge.release = release;
|
|
377
428
|
scrollBridge.snapToPosition = positionIndex => {
|
|
@@ -382,6 +433,7 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
382
433
|
};
|
|
383
434
|
return import_react_native.PanResponder.create({
|
|
384
435
|
onMoveShouldSetPanResponder: onMoveShouldSet,
|
|
436
|
+
onPanResponderTerminationRequest: () => false,
|
|
385
437
|
onPanResponderGrant: grant,
|
|
386
438
|
onPanResponderMove: (_e, {
|
|
387
439
|
dy
|
|
@@ -389,15 +441,13 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
389
441
|
const toFull = dy + startY;
|
|
390
442
|
const to = (0, import_helpers.resisted)(toFull, minY);
|
|
391
443
|
if (to <= minY) scrollBridge.setParentDragging(false);else scrollBridge.setParentDragging(true);
|
|
392
|
-
|
|
393
|
-
type: "direct"
|
|
394
|
-
});
|
|
444
|
+
setAnimatedPositionDirect(to);
|
|
395
445
|
},
|
|
396
446
|
onPanResponderEnd: finish,
|
|
397
447
|
onPanResponderTerminate: finish,
|
|
398
448
|
onPanResponderRelease: finish
|
|
399
449
|
});
|
|
400
|
-
}, [disableDrag, isShowingInnerSheet, animateTo, frameSize,
|
|
450
|
+
}, [disableDrag, isShowingInnerSheet, animateTo, frameSize, activePositions, setPosition, dismissOnSnapToBottom, snapPointsMode]);
|
|
401
451
|
import_react.default.useEffect(() => {
|
|
402
452
|
if (isDragging || isHidden || !open || disableAnimation) return;
|
|
403
453
|
if (!frameSize || !screenSize) return;
|
|
@@ -418,7 +468,11 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
418
468
|
animateTo(position);
|
|
419
469
|
}, [isDragging]);
|
|
420
470
|
import_react.default.useEffect(() => {
|
|
421
|
-
if (!open && isKeyboardVisible)
|
|
471
|
+
if (!open && isKeyboardVisible) {
|
|
472
|
+
dismissKeyboard();
|
|
473
|
+
pauseKeyboardHandler.current = false;
|
|
474
|
+
flushPendingHide();
|
|
475
|
+
}
|
|
422
476
|
}, [open]);
|
|
423
477
|
const {
|
|
424
478
|
panGesture,
|
|
@@ -432,30 +486,31 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
432
486
|
stopSpring,
|
|
433
487
|
scrollBridge,
|
|
434
488
|
setIsDragging,
|
|
435
|
-
getCurrentPosition:
|
|
489
|
+
getCurrentPosition: getAnimatedPosition,
|
|
436
490
|
resisted: import_helpers.resisted,
|
|
437
491
|
disableDrag,
|
|
438
492
|
isShowingInnerSheet,
|
|
439
|
-
setAnimatedPosition:
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
});
|
|
444
|
-
},
|
|
493
|
+
setAnimatedPosition: setAnimatedPositionDirect,
|
|
494
|
+
dismissOnSnapToBottom,
|
|
495
|
+
snapPointsMode,
|
|
496
|
+
isKeyboardVisible,
|
|
445
497
|
pauseKeyboardHandler
|
|
446
498
|
});
|
|
499
|
+
const ignoreLayoutForKeyboard = (0, import_core.useEvent)(() => import_constants.isWeb && moveOnKeyboardChange && (0, import_webViewport.getWebKeyboardResizeHeight)() >= import_webViewport.MIN_KEYBOARD_HEIGHT);
|
|
447
500
|
const handleAnimationViewLayout = (0, import_core.useEvent)(e => {
|
|
448
501
|
if (!open && stableFrameSize.current !== 0) return;
|
|
449
502
|
const layoutHeight = e.nativeEvent?.layout.height;
|
|
450
|
-
|
|
503
|
+
if (ignoreLayoutForKeyboard() && frameSize > 0) return;
|
|
504
|
+
const next = modal ? Math.min(layoutHeight, getStableViewportHeight()) : layoutHeight;
|
|
451
505
|
if (!next) return;
|
|
452
|
-
setFrameSize(next);
|
|
506
|
+
setFrameSize(Math.round(next));
|
|
453
507
|
});
|
|
454
508
|
const handleMaxContentViewLayout = import_react.default.useCallback(e => {
|
|
455
|
-
|
|
509
|
+
if (ignoreLayoutForKeyboard() && screenSize > 0) return;
|
|
510
|
+
const next = Math.min(e.nativeEvent?.layout.height, getStableViewportHeight());
|
|
456
511
|
if (!next) return;
|
|
457
|
-
setMaxContentSize(next);
|
|
458
|
-
}, []);
|
|
512
|
+
setMaxContentSize(Math.round(next));
|
|
513
|
+
}, [ignoreLayoutForKeyboard, screenSize]);
|
|
459
514
|
const animatedStyle = useAnimatedNumberStyle(animatedNumber, import_react.default.useCallback(val => {
|
|
460
515
|
"worklet";
|
|
461
516
|
|
|
@@ -483,6 +538,9 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
483
538
|
value: nextParentContext,
|
|
484
539
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_SheetContext.SheetProvider, {
|
|
485
540
|
...providerProps,
|
|
541
|
+
keyboardOccludedHeight,
|
|
542
|
+
isKeyboardVisible,
|
|
543
|
+
keyboardStableFrameHeight,
|
|
486
544
|
setHasScrollView,
|
|
487
545
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_GestureSheetContext.GestureSheetProvider, {
|
|
488
546
|
isDragging,
|
|
@@ -517,7 +575,7 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
517
575
|
width: "100%",
|
|
518
576
|
height: forcedContentHeight,
|
|
519
577
|
minHeight: forcedContentHeight,
|
|
520
|
-
opacity:
|
|
578
|
+
opacity: shouldHideParentSheet ? 0 : disableTransparencyHide ? 1 : opacity,
|
|
521
579
|
...((shouldHideParentSheet || !open) && {
|
|
522
580
|
pointerEvents: "none"
|
|
523
581
|
})
|
|
@@ -544,12 +602,17 @@ const SheetImplementationCustom = import_react.default.forwardRef(function Sheet
|
|
|
544
602
|
});
|
|
545
603
|
const shouldMountChildren = unmountChildrenWhenHidden ? !!opacity : true;
|
|
546
604
|
if (modal) {
|
|
605
|
+
const RNGHRoot = (0, import_gestureState.getGestureHandlerState)().RootView;
|
|
606
|
+
const mountedContents = shouldMountChildren ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(ContainerComponent, {
|
|
607
|
+
children: contents
|
|
608
|
+
}) : null;
|
|
547
609
|
const modalContents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.Portal, {
|
|
548
610
|
stackZIndex: zIndex,
|
|
549
611
|
...portalProps,
|
|
550
|
-
children:
|
|
551
|
-
|
|
552
|
-
|
|
612
|
+
children: mountedContents && RNGHRoot ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(RNGHRoot, {
|
|
613
|
+
style: open ? rnghRootStyleOpen : rnghRootStyleClosed,
|
|
614
|
+
children: mountedContents
|
|
615
|
+
}) : mountedContents
|
|
553
616
|
});
|
|
554
617
|
if (import_constants.isWeb) return modalContents;
|
|
555
618
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_contexts.SheetInsideSheetContext.Provider, {
|