@hanzogui/sheet 2.0.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 +21 -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.cjs +48 -0
- package/dist/cjs/GestureDetectorWrapper.native.js +53 -0
- package/dist/cjs/GestureDetectorWrapper.native.js.map +1 -0
- package/dist/cjs/GestureSheetContext.cjs +52 -0
- package/dist/cjs/GestureSheetContext.native.js +56 -0
- package/dist/cjs/GestureSheetContext.native.js.map +1 -0
- package/dist/cjs/Sheet.cjs +117 -0
- package/dist/cjs/Sheet.native.js +120 -0
- package/dist/cjs/Sheet.native.js.map +1 -0
- package/dist/cjs/SheetContext.cjs +32 -0
- package/dist/cjs/SheetContext.native.js +35 -0
- package/dist/cjs/SheetContext.native.js.map +1 -0
- package/dist/cjs/SheetController.cjs +65 -0
- package/dist/cjs/SheetController.native.js +71 -0
- package/dist/cjs/SheetController.native.js.map +1 -0
- package/dist/cjs/SheetImplementationCustom.cjs +472 -0
- package/dist/cjs/SheetImplementationCustom.native.js +524 -0
- package/dist/cjs/SheetImplementationCustom.native.js.map +1 -0
- package/dist/cjs/SheetScrollView.cjs +180 -0
- package/dist/cjs/SheetScrollView.native.js +197 -0
- package/dist/cjs/SheetScrollView.native.js.map +1 -0
- package/dist/cjs/constants.cjs +32 -0
- package/dist/cjs/constants.native.js +35 -0
- package/dist/cjs/constants.native.js.map +1 -0
- package/dist/cjs/contexts.cjs +42 -0
- package/dist/cjs/contexts.native.js +45 -0
- package/dist/cjs/contexts.native.js.map +1 -0
- package/dist/cjs/controller.cjs +29 -0
- package/dist/cjs/controller.native.js +32 -0
- package/dist/cjs/controller.native.js.map +1 -0
- package/dist/cjs/createSheet.cjs +191 -0
- package/dist/cjs/createSheet.native.js +208 -0
- package/dist/cjs/createSheet.native.js.map +1 -0
- package/dist/cjs/gestureState.cjs +39 -0
- package/dist/cjs/gestureState.native.js +42 -0
- package/dist/cjs/gestureState.native.js.map +1 -0
- package/dist/cjs/helpers.cjs +31 -0
- package/dist/cjs/helpers.native.js +35 -0
- package/dist/cjs/helpers.native.js.map +1 -0
- package/dist/cjs/index.cjs +28 -0
- package/dist/cjs/index.native.js +31 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/nativeSheet.cjs +87 -0
- package/dist/cjs/nativeSheet.native.js +101 -0
- package/dist/cjs/nativeSheet.native.js.map +1 -0
- package/dist/cjs/setupGestureHandler.cjs +46 -0
- package/dist/cjs/setupGestureHandler.native.js +50 -0
- package/dist/cjs/setupGestureHandler.native.js.map +1 -0
- package/dist/cjs/types.cjs +16 -0
- package/dist/cjs/types.native.js +19 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/cjs/useGestureHandlerPan.cjs +136 -0
- package/dist/cjs/useGestureHandlerPan.native.js +145 -0
- package/dist/cjs/useGestureHandlerPan.native.js.map +1 -0
- package/dist/cjs/useKeyboardControllerSheet.cjs +38 -0
- package/dist/cjs/useKeyboardControllerSheet.native.js +114 -0
- package/dist/cjs/useKeyboardControllerSheet.native.js.map +1 -0
- package/dist/cjs/useSheet.cjs +27 -0
- package/dist/cjs/useSheet.native.js +32 -0
- package/dist/cjs/useSheet.native.js.map +1 -0
- package/dist/cjs/useSheetController.cjs +50 -0
- package/dist/cjs/useSheetController.native.js +53 -0
- package/dist/cjs/useSheetController.native.js.map +1 -0
- package/dist/cjs/useSheetOffscreenSize.cjs +51 -0
- package/dist/cjs/useSheetOffscreenSize.native.js +61 -0
- package/dist/cjs/useSheetOffscreenSize.native.js.map +1 -0
- package/dist/cjs/useSheetOpenState.cjs +49 -0
- package/dist/cjs/useSheetOpenState.native.js +56 -0
- package/dist/cjs/useSheetOpenState.native.js.map +1 -0
- package/dist/cjs/useSheetProviderProps.cjs +133 -0
- package/dist/cjs/useSheetProviderProps.native.js +153 -0
- package/dist/cjs/useSheetProviderProps.native.js.map +1 -0
- package/dist/cjs/useSheetScrollViewGestures.cjs +123 -0
- package/dist/cjs/useSheetScrollViewGestures.native.js +110 -0
- package/dist/cjs/useSheetScrollViewGestures.native.js.map +1 -0
- package/dist/esm/GestureDetectorWrapper.mjs +25 -0
- package/dist/esm/GestureDetectorWrapper.mjs.map +1 -0
- package/dist/esm/GestureDetectorWrapper.native.js +27 -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 +31 -0
- package/dist/esm/SheetController.mjs.map +1 -0
- package/dist/esm/SheetController.native.js +34 -0
- package/dist/esm/SheetController.native.js.map +1 -0
- package/dist/esm/SheetImplementationCustom.mjs +437 -0
- package/dist/esm/SheetImplementationCustom.mjs.map +1 -0
- package/dist/esm/SheetImplementationCustom.native.js +487 -0
- package/dist/esm/SheetImplementationCustom.native.js.map +1 -0
- package/dist/esm/SheetScrollView.mjs +146 -0
- package/dist/esm/SheetScrollView.mjs.map +1 -0
- package/dist/esm/SheetScrollView.native.js +160 -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 +168 -0
- package/dist/esm/createSheet.mjs.map +1 -0
- package/dist/esm/createSheet.native.js +182 -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 +8 -0
- package/dist/esm/helpers.mjs.map +1 -0
- package/dist/esm/helpers.native.js +9 -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 +63 -0
- package/dist/esm/nativeSheet.mjs.map +1 -0
- package/dist/esm/nativeSheet.native.js +74 -0
- package/dist/esm/nativeSheet.native.js.map +1 -0
- package/dist/esm/setupGestureHandler.mjs +22 -0
- package/dist/esm/setupGestureHandler.mjs.map +1 -0
- package/dist/esm/setupGestureHandler.native.js +23 -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 +113 -0
- package/dist/esm/useGestureHandlerPan.mjs.map +1 -0
- package/dist/esm/useGestureHandlerPan.native.js +119 -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 +88 -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 +28 -0
- package/dist/esm/useSheetOffscreenSize.mjs.map +1 -0
- package/dist/esm/useSheetOffscreenSize.native.js +35 -0
- package/dist/esm/useSheetOffscreenSize.native.js.map +1 -0
- package/dist/esm/useSheetOpenState.mjs +26 -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 +99 -0
- package/dist/esm/useSheetProviderProps.mjs.map +1 -0
- package/dist/esm/useSheetProviderProps.native.js +116 -0
- package/dist/esm/useSheetProviderProps.native.js.map +1 -0
- package/dist/esm/useSheetScrollViewGestures.mjs +100 -0
- package/dist/esm/useSheetScrollViewGestures.mjs.map +1 -0
- package/dist/esm/useSheetScrollViewGestures.native.js +84 -0
- package/dist/esm/useSheetScrollViewGestures.native.js.map +1 -0
- package/dist/jsx/GestureDetectorWrapper.mjs +25 -0
- package/dist/jsx/GestureDetectorWrapper.mjs.map +1 -0
- package/dist/jsx/GestureDetectorWrapper.native.js +53 -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 +56 -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 +120 -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 +35 -0
- package/dist/jsx/SheetContext.native.js.map +1 -0
- package/dist/jsx/SheetController.mjs +31 -0
- package/dist/jsx/SheetController.mjs.map +1 -0
- package/dist/jsx/SheetController.native.js +71 -0
- package/dist/jsx/SheetController.native.js.map +1 -0
- package/dist/jsx/SheetImplementationCustom.mjs +437 -0
- package/dist/jsx/SheetImplementationCustom.mjs.map +1 -0
- package/dist/jsx/SheetImplementationCustom.native.js +524 -0
- package/dist/jsx/SheetImplementationCustom.native.js.map +1 -0
- package/dist/jsx/SheetScrollView.mjs +146 -0
- package/dist/jsx/SheetScrollView.mjs.map +1 -0
- package/dist/jsx/SheetScrollView.native.js +197 -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 +35 -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 +45 -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 +32 -0
- package/dist/jsx/controller.native.js.map +1 -0
- package/dist/jsx/createSheet.mjs +168 -0
- package/dist/jsx/createSheet.mjs.map +1 -0
- package/dist/jsx/createSheet.native.js +208 -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 +42 -0
- package/dist/jsx/gestureState.native.js.map +1 -0
- package/dist/jsx/helpers.mjs +8 -0
- package/dist/jsx/helpers.mjs.map +1 -0
- package/dist/jsx/helpers.native.js +35 -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 +31 -0
- package/dist/jsx/index.native.js.map +1 -0
- package/dist/jsx/nativeSheet.mjs +63 -0
- package/dist/jsx/nativeSheet.mjs.map +1 -0
- package/dist/jsx/nativeSheet.native.js +101 -0
- package/dist/jsx/nativeSheet.native.js.map +1 -0
- package/dist/jsx/setupGestureHandler.mjs +22 -0
- package/dist/jsx/setupGestureHandler.mjs.map +1 -0
- package/dist/jsx/setupGestureHandler.native.js +50 -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 +19 -0
- package/dist/jsx/types.native.js.map +1 -0
- package/dist/jsx/useGestureHandlerPan.mjs +113 -0
- package/dist/jsx/useGestureHandlerPan.mjs.map +1 -0
- package/dist/jsx/useGestureHandlerPan.native.js +145 -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 +114 -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 +32 -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 +53 -0
- package/dist/jsx/useSheetController.native.js.map +1 -0
- package/dist/jsx/useSheetOffscreenSize.mjs +28 -0
- package/dist/jsx/useSheetOffscreenSize.mjs.map +1 -0
- package/dist/jsx/useSheetOffscreenSize.native.js +61 -0
- package/dist/jsx/useSheetOffscreenSize.native.js.map +1 -0
- package/dist/jsx/useSheetOpenState.mjs +26 -0
- package/dist/jsx/useSheetOpenState.mjs.map +1 -0
- package/dist/jsx/useSheetOpenState.native.js +56 -0
- package/dist/jsx/useSheetOpenState.native.js.map +1 -0
- package/dist/jsx/useSheetProviderProps.mjs +99 -0
- package/dist/jsx/useSheetProviderProps.mjs.map +1 -0
- package/dist/jsx/useSheetProviderProps.native.js +153 -0
- package/dist/jsx/useSheetProviderProps.native.js.map +1 -0
- package/dist/jsx/useSheetScrollViewGestures.mjs +100 -0
- package/dist/jsx/useSheetScrollViewGestures.mjs.map +1 -0
- package/dist/jsx/useSheetScrollViewGestures.native.js +110 -0
- package/dist/jsx/useSheetScrollViewGestures.native.js.map +1 -0
- package/next.md +78 -0
- package/package.json +96 -0
- 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/setup-gesture-handler.cjs +1 -0
- package/src/GestureDetectorWrapper.tsx +41 -0
- package/src/GestureSheetContext.tsx +62 -0
- package/src/Sheet.tsx +114 -0
- package/src/SheetContext.tsx +11 -0
- package/src/SheetController.tsx +44 -0
- package/src/SheetImplementationCustom.tsx +868 -0
- package/src/SheetScrollView.tsx +195 -0
- package/src/constants.tsx +5 -0
- package/src/contexts.ts +9 -0
- package/src/controller.ts +9 -0
- package/src/createSheet.tsx +296 -0
- package/src/gestureState.ts +24 -0
- package/src/helpers.tsx +31 -0
- package/src/index.ts +11 -0
- package/src/nativeSheet.tsx +89 -0
- package/src/setupGestureHandler.ts +34 -0
- package/src/types.tsx +181 -0
- package/src/useGestureHandlerPan.tsx +364 -0
- package/src/useKeyboardControllerSheet.native.ts +136 -0
- package/src/useKeyboardControllerSheet.ts +26 -0
- package/src/useSheet.tsx +3 -0
- package/src/useSheetController.tsx +27 -0
- package/src/useSheetOffscreenSize.tsx +49 -0
- package/src/useSheetOpenState.tsx +33 -0
- package/src/useSheetProviderProps.tsx +223 -0
- package/src/useSheetScrollViewGestures.native.ts +163 -0
- package/src/useSheetScrollViewGestures.ts +194 -0
- package/tsconfig.json +56 -0
- package/types/GestureDetectorWrapper.d.ts +14 -0
- package/types/GestureSheetContext.d.ts +36 -0
- package/types/Sheet.d.ts +183 -0
- package/types/SheetContext.d.ts +43 -0
- package/types/SheetController.d.ts +6 -0
- package/types/SheetImplementationCustom.d.ts +36 -0
- package/types/SheetScrollView.d.ts +40 -0
- package/types/constants.d.ts +5 -0
- package/types/contexts.d.ts +6 -0
- package/types/controller.d.ts +3 -0
- package/types/createSheet.d.ts +194 -0
- package/types/gestureState.d.ts +11 -0
- package/types/helpers.d.ts +2 -0
- package/types/index.d.ts +12 -0
- package/types/nativeSheet.d.ts +10 -0
- package/types/setupGestureHandler.d.ts +11 -0
- package/types/types.d.ts +147 -0
- package/types/useGestureHandlerPan.d.ts +44 -0
- package/types/useKeyboardControllerSheet.d.ts +7 -0
- package/types/useKeyboardControllerSheet.native.d.ts +13 -0
- package/types/useSheet.d.ts +2 -0
- package/types/useSheetController.d.ts +17 -0
- package/types/useSheetOffscreenSize.d.ts +3 -0
- package/types/useSheetOpenState.d.ts +9 -0
- package/types/useSheetProviderProps.d.ts +36 -0
- package/types/useSheetScrollViewGestures.d.ts +12 -0
- package/types/useSheetScrollViewGestures.native.d.ts +21 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
__copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: !0
|
|
30
|
+
}) : target, mod)),
|
|
31
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: !0
|
|
33
|
+
}), mod);
|
|
34
|
+
var SheetController_exports = {};
|
|
35
|
+
__export(SheetController_exports, {
|
|
36
|
+
SheetController: () => SheetController
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(SheetController_exports);
|
|
39
|
+
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
40
|
+
import_react = __toESM(require("react"), 1),
|
|
41
|
+
import_gui_core = require("@hanzo/gui-core"),
|
|
42
|
+
import_useSheetController = require("./useSheetController.native.js"),
|
|
43
|
+
SheetController = function (param) {
|
|
44
|
+
var {
|
|
45
|
+
children,
|
|
46
|
+
onOpenChange: onOpenChangeProp,
|
|
47
|
+
open,
|
|
48
|
+
hidden,
|
|
49
|
+
disableDrag
|
|
50
|
+
} = param,
|
|
51
|
+
onOpenChange = (0, import_gui_core.useEvent)(onOpenChangeProp),
|
|
52
|
+
id = (0, import_react.useId)(),
|
|
53
|
+
wasHiddenRef = (0, import_react.useRef)(hidden),
|
|
54
|
+
skipNextAnimation = !1;
|
|
55
|
+
wasHiddenRef.current && !hidden && open && (skipNextAnimation = !0), wasHiddenRef.current = hidden;
|
|
56
|
+
var memoValue = import_react.default.useMemo(function () {
|
|
57
|
+
return {
|
|
58
|
+
id,
|
|
59
|
+
open,
|
|
60
|
+
hidden,
|
|
61
|
+
disableDrag,
|
|
62
|
+
onOpenChange,
|
|
63
|
+
skipNextAnimation
|
|
64
|
+
};
|
|
65
|
+
}, [id, onOpenChange, open, hidden, disableDrag, skipNextAnimation]);
|
|
66
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_useSheetController.SheetControllerContext.Provider, {
|
|
67
|
+
value: memoValue,
|
|
68
|
+
children
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=SheetController.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","SheetController_exports","__export","SheetController","module","exports","import_jsx_runtime","require","import_react","__toESM","import_gui_core","import_useSheetController","param","children","onOpenChange","onOpenChangeProp","open","hidden","disableDrag","useEvent","id","useId","wasHiddenRef","useRef","skipNextAnimation","current","memoValue","default","useMemo","jsx","SheetControllerContext","Provider"],"sources":["../../src/SheetController.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,uBAAA;AAAAC,QAAA,CAAAD,uBAAA;EAAAE,eAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAqC,CAAAK,uBACrC;AAMO,IAAAK,kBAAM,GAAmBC,OAAA;EAAAC,YAAA,GAAAC,OAAA,CAAAF,OAAA;EAAAG,eAAA,GAAAH,OAAA;EAAAI,yBAAA,GAAAJ,OAAA;EAAAJ,eAAA,YAAAA,CAAAS,KAAA;IAC9B;QAAAC,QAAA;QAAAC,YAAA,EAAAC,gBAAA;QAAAC,IAAA;QAAAC,MAAA;QAAAC;MAAA,IAAAN,KAAA;MAAAE,YAAA,OAAAJ,eAAA,CAAAS,QAAA,EAAAJ,gBAAA;MAAAK,EAAA,OAAAZ,YAAA,CAAAa,KAAA;MAAAC,YAAA,OAAAd,YAAA,CAAAe,MAAA,EAAAN,MAAA;MAAAO,iBAAA;IACAF,YAAA,CAAAG,OAAc,KAAAR,MAAA,IAAAD,IAAA,KAAAQ,iBAAA,QAAAF,YAAA,CAAAG,OAAA,GAAAR,MAAA;IACd,IAAAS,SAAA,GAAAlB,YAAA,CAAAmB,OAAA,CAAAC,OAAA;MACA;QACAR,EAAA;QACqEJ,IAAA;QACrEC,MAAM;QAMFC,WAAA;QACAJ,YAAa;QAKjBU;MACE;IAAO,IACLJ,EACA,EAAAN,YACA,EAAAE,IACA,EAAAC,MACA,EAAAC,WACA,EACFM,iBAAA,EACA;IACF,0BAAAlB,kBAAA,CAAAuB,GAAA,EAAAlB,yBAAA,CAAAmB,sBAAA,CAAAC,QAAA;MAEA/B,KACE,EAAA0B,SAAA;MAIJb","ignoreList":[]}
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var SheetImplementationCustom_exports = {};
|
|
33
|
+
__export(SheetImplementationCustom_exports, {
|
|
34
|
+
SheetImplementationCustom: () => SheetImplementationCustom
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(SheetImplementationCustom_exports);
|
|
37
|
+
var import_gui_adapt = require("@hanzo/gui-adapt"),
|
|
38
|
+
import_gui_animate_presence = require("@hanzo/gui-animate-presence"),
|
|
39
|
+
import_gui_compose_refs = require("@hanzo/gui-compose-refs"),
|
|
40
|
+
import_gui_constants = require("@hanzo/gui-constants"),
|
|
41
|
+
import_gui_core = require("@hanzo/gui-core"),
|
|
42
|
+
import_gui_native = require("@hanzo/gui-native"),
|
|
43
|
+
import_gui_portal = require("@hanzo/gui-portal"),
|
|
44
|
+
import_react = __toESM(require("react"), 1),
|
|
45
|
+
import_react_native = require("react-native-web"),
|
|
46
|
+
import_contexts = require("./contexts.cjs"),
|
|
47
|
+
import_GestureDetectorWrapper = require("./GestureDetectorWrapper.cjs"),
|
|
48
|
+
import_GestureSheetContext = require("./GestureSheetContext.cjs"),
|
|
49
|
+
import_helpers = require("./helpers.cjs"),
|
|
50
|
+
import_SheetContext = require("./SheetContext.cjs"),
|
|
51
|
+
import_useGestureHandlerPan = require("./useGestureHandlerPan.cjs"),
|
|
52
|
+
import_useKeyboardControllerSheet = require("./useKeyboardControllerSheet.cjs"),
|
|
53
|
+
import_useSheetOpenState = require("./useSheetOpenState.cjs"),
|
|
54
|
+
import_useSheetProviderProps = require("./useSheetProviderProps.cjs"),
|
|
55
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
56
|
+
const hiddenSize = 10000.1;
|
|
57
|
+
let _cachedSafeAreaTop;
|
|
58
|
+
function getSafeAreaTopInset() {
|
|
59
|
+
return _cachedSafeAreaTop !== void 0 || (_cachedSafeAreaTop = (0, import_gui_native.getSafeArea)().getInsets().top), _cachedSafeAreaTop;
|
|
60
|
+
}
|
|
61
|
+
let sheetHiddenStyleSheet = null;
|
|
62
|
+
const relativeDimensionTo = import_gui_constants.isWeb ? "window" : "screen",
|
|
63
|
+
SheetImplementationCustom = import_react.default.forwardRef(function (props, forwardedRef) {
|
|
64
|
+
const parentSheet = import_react.default.useContext(import_contexts.ParentSheetContext),
|
|
65
|
+
{
|
|
66
|
+
transition,
|
|
67
|
+
transitionConfig: transitionConfigProp,
|
|
68
|
+
modal = !1,
|
|
69
|
+
zIndex = parentSheet.zIndex + 1,
|
|
70
|
+
moveOnKeyboardChange = !1,
|
|
71
|
+
unmountChildrenWhenHidden = !1,
|
|
72
|
+
portalProps,
|
|
73
|
+
containerComponent: ContainerComponent = import_react.default.Fragment,
|
|
74
|
+
onAnimationComplete
|
|
75
|
+
} = props,
|
|
76
|
+
state = (0, import_useSheetOpenState.useSheetOpenState)(props),
|
|
77
|
+
[overlayComponent, setOverlayComponent] = import_react.default.useState(null),
|
|
78
|
+
providerProps = (0, import_useSheetProviderProps.useSheetProviderProps)(props, state, {
|
|
79
|
+
onOverlayComponent: setOverlayComponent
|
|
80
|
+
}),
|
|
81
|
+
{
|
|
82
|
+
frameSize,
|
|
83
|
+
setFrameSize,
|
|
84
|
+
snapPoints,
|
|
85
|
+
snapPointsMode,
|
|
86
|
+
hasFit,
|
|
87
|
+
position,
|
|
88
|
+
setPosition,
|
|
89
|
+
scrollBridge,
|
|
90
|
+
screenSize,
|
|
91
|
+
setMaxContentSize,
|
|
92
|
+
maxSnapPoint
|
|
93
|
+
} = providerProps,
|
|
94
|
+
{
|
|
95
|
+
open,
|
|
96
|
+
controller,
|
|
97
|
+
isHidden
|
|
98
|
+
} = state,
|
|
99
|
+
openRef = import_react.default.useRef(open);
|
|
100
|
+
openRef.current = open;
|
|
101
|
+
const sheetRef = import_react.default.useRef(void 0),
|
|
102
|
+
ref = (0, import_gui_compose_refs.useComposedRefs)(forwardedRef, sheetRef, providerProps.contentRef),
|
|
103
|
+
{
|
|
104
|
+
animationDriver
|
|
105
|
+
} = (0, import_gui_core.useConfiguration)();
|
|
106
|
+
if (!animationDriver) throw new Error("Sheet requires an animation driver to be set");
|
|
107
|
+
const transitionConfig = (() => {
|
|
108
|
+
if (transitionConfigProp) return transitionConfigProp;
|
|
109
|
+
const [animationProp, animationPropConfig] = transition ? Array.isArray(transition) ? transition : [transition] : [];
|
|
110
|
+
return animationProp && animationDriver.animations?.[animationProp] ? {
|
|
111
|
+
...animationDriver.animations[animationProp],
|
|
112
|
+
...animationPropConfig
|
|
113
|
+
} : null;
|
|
114
|
+
})(),
|
|
115
|
+
[isShowingInnerSheet, setIsShowingInnerSheet] = import_react.default.useState(!1),
|
|
116
|
+
shouldHideParentSheet = !import_gui_constants.isWeb && modal && isShowingInnerSheet && (0, import_gui_portal.needsPortalRepropagation)(),
|
|
117
|
+
sheetInsideSheet = import_react.default.useContext(import_contexts.SheetInsideSheetContext),
|
|
118
|
+
onInnerSheet = import_react.default.useCallback(hasChild => {
|
|
119
|
+
setIsShowingInnerSheet(hasChild);
|
|
120
|
+
}, []),
|
|
121
|
+
stableFrameSize = import_react.default.useRef(frameSize);
|
|
122
|
+
import_react.default.useEffect(() => {
|
|
123
|
+
open && frameSize && (stableFrameSize.current = frameSize);
|
|
124
|
+
}, [open, frameSize]);
|
|
125
|
+
const effectiveFrameSize = open ? frameSize : stableFrameSize.current || frameSize,
|
|
126
|
+
positions = import_react.default.useMemo(() => snapPoints.map(point => getYPositions(snapPointsMode, point, screenSize, effectiveFrameSize)), [screenSize, effectiveFrameSize, snapPoints, snapPointsMode]),
|
|
127
|
+
{
|
|
128
|
+
keyboardHeight,
|
|
129
|
+
isKeyboardVisible,
|
|
130
|
+
dismissKeyboard,
|
|
131
|
+
pauseKeyboardHandler,
|
|
132
|
+
flushPendingHide
|
|
133
|
+
} = (0, import_useKeyboardControllerSheet.useKeyboardControllerSheet)({
|
|
134
|
+
enabled: !import_gui_constants.isWeb && !!moveOnKeyboardChange
|
|
135
|
+
}),
|
|
136
|
+
[isDragging, setIsDragging_] = import_react.default.useState(!1),
|
|
137
|
+
isDraggingRef = import_react.default.useRef(!1),
|
|
138
|
+
setIsDragging = import_react.default.useCallback(val => {
|
|
139
|
+
isDraggingRef.current = val, pauseKeyboardHandler.current = val, setIsDragging_(val), val || flushPendingHide();
|
|
140
|
+
}, [pauseKeyboardHandler, flushPendingHide]),
|
|
141
|
+
activePositionsRef = import_react.default.useRef(positions),
|
|
142
|
+
activePositions = import_react.default.useMemo(() => {
|
|
143
|
+
if (isDragging || isDraggingRef.current) return activePositionsRef.current;
|
|
144
|
+
let result;
|
|
145
|
+
if (!isKeyboardVisible || keyboardHeight <= 0) result = positions;else {
|
|
146
|
+
const safeAreaTop = import_gui_constants.isWeb ? 0 : getSafeAreaTopInset();
|
|
147
|
+
result = positions.map(p => screenSize && p >= screenSize ? p : Math.max(safeAreaTop, p - keyboardHeight));
|
|
148
|
+
}
|
|
149
|
+
return activePositionsRef.current = result, result;
|
|
150
|
+
}, [positions, isKeyboardVisible, keyboardHeight, screenSize, isDragging]),
|
|
151
|
+
{
|
|
152
|
+
useAnimatedNumber,
|
|
153
|
+
useAnimatedNumberStyle,
|
|
154
|
+
useAnimatedNumberReaction
|
|
155
|
+
} = animationDriver,
|
|
156
|
+
AnimatedView = animationDriver.View ?? import_gui_core.View;
|
|
157
|
+
(0, import_gui_constants.useIsomorphicLayoutEffect)(() => {
|
|
158
|
+
if (sheetInsideSheet && open) return sheetInsideSheet(!0), () => {
|
|
159
|
+
sheetInsideSheet(!1);
|
|
160
|
+
};
|
|
161
|
+
}, [sheetInsideSheet, open]);
|
|
162
|
+
const nextParentContext = import_react.default.useMemo(() => ({
|
|
163
|
+
zIndex
|
|
164
|
+
}), [zIndex]),
|
|
165
|
+
startPosition = (0, import_gui_core.useDidFinishSSR)() && screenSize ? screenSize : hiddenSize,
|
|
166
|
+
animatedNumber = useAnimatedNumber(startPosition),
|
|
167
|
+
at = import_react.default.useRef(startPosition),
|
|
168
|
+
hasntMeasured = at.current === hiddenSize,
|
|
169
|
+
[disableAnimation, setDisableAnimation] = (0, import_react.useState)(hasntMeasured),
|
|
170
|
+
skipAdaptAnimation = import_react.default.useRef(!1);
|
|
171
|
+
controller?.skipNextAnimation && (skipAdaptAnimation.current = !0);
|
|
172
|
+
const hasScrollView = import_react.default.useRef(!1),
|
|
173
|
+
opacityFallbackTimer = import_react.default.useRef(null);
|
|
174
|
+
useAnimatedNumberReaction({
|
|
175
|
+
value: animatedNumber,
|
|
176
|
+
hostRef: sheetRef
|
|
177
|
+
}, import_react.default.useCallback(value => {
|
|
178
|
+
at.current = value, scrollBridge.paneY = value;
|
|
179
|
+
const minY = activePositions[0],
|
|
180
|
+
wasAtTop = scrollBridge.isAtTop,
|
|
181
|
+
nowAtTop = value <= minY + 5;
|
|
182
|
+
wasAtTop !== nowAtTop && (scrollBridge.isAtTop = nowAtTop, nowAtTop ? (scrollBridge.y > 0 && (scrollBridge.forceScrollTo?.(0), scrollBridge.y = 0), scrollBridge.scrollLockY = void 0, scrollBridge.setScrollEnabled?.(!0)) : (scrollBridge.scrollLockY = 0, scrollBridge.setScrollEnabled?.(!1)));
|
|
183
|
+
}, [animationDriver, activePositions]));
|
|
184
|
+
function stopSpring() {
|
|
185
|
+
animatedNumber.stop(), scrollBridge.onFinishAnimate && (scrollBridge.onFinishAnimate(), scrollBridge.onFinishAnimate = void 0);
|
|
186
|
+
}
|
|
187
|
+
const animateTo = (0, import_gui_core.useEvent)((position2, animationOverride) => {
|
|
188
|
+
if (frameSize === 0) return;
|
|
189
|
+
let toValue = isHidden || position2 === -1 ? screenSize : activePositions[position2];
|
|
190
|
+
if (at.current === toValue) return;
|
|
191
|
+
at.current = toValue, stopSpring();
|
|
192
|
+
const isOpenAnimation = position2 !== -1 && !isHidden;
|
|
193
|
+
opacityFallbackTimer.current && (clearTimeout(opacityFallbackTimer.current), opacityFallbackTimer.current = null);
|
|
194
|
+
const animationCompleteCallback = () => {
|
|
195
|
+
opacityFallbackTimer.current && (clearTimeout(opacityFallbackTimer.current), opacityFallbackTimer.current = null), !isOpenAnimation && !open && setOpacity(0), onAnimationComplete?.({
|
|
196
|
+
open: isOpenAnimation
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
if (isOpenAnimation || (opacityFallbackTimer.current = setTimeout(() => {
|
|
200
|
+
opacityFallbackTimer.current = null, openRef.current || setOpacity(0);
|
|
201
|
+
}, 1e3)), skipAdaptAnimation.current) {
|
|
202
|
+
skipAdaptAnimation.current = !1, animatedNumber.setValue(toValue, {
|
|
203
|
+
type: "timing",
|
|
204
|
+
duration: 0
|
|
205
|
+
}, animationCompleteCallback);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
animatedNumber.setValue(toValue, animationOverride || {
|
|
209
|
+
type: "spring",
|
|
210
|
+
...transitionConfig
|
|
211
|
+
}, animationCompleteCallback);
|
|
212
|
+
});
|
|
213
|
+
(0, import_gui_constants.useIsomorphicLayoutEffect)(() => {
|
|
214
|
+
if (hasntMeasured && screenSize && frameSize) {
|
|
215
|
+
at.current = screenSize, animatedNumber.setValue(screenSize, {
|
|
216
|
+
type: "timing",
|
|
217
|
+
duration: 0
|
|
218
|
+
}, () => {
|
|
219
|
+
setTimeout(() => {
|
|
220
|
+
setDisableAnimation(!1);
|
|
221
|
+
}, 10);
|
|
222
|
+
});
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (!disableAnimation && !(!frameSize || !screenSize || isHidden || hasntMeasured && !open) && (animateTo(position), position === -1 && (scrollBridge.scrollLock = !1, scrollBridge.scrollStartY = -1), open && position >= 0)) {
|
|
226
|
+
const isTopPosition = position === 0;
|
|
227
|
+
scrollBridge.isAtTop = isTopPosition, isTopPosition ? (scrollBridge.scrollLockY = void 0, scrollBridge.setScrollEnabled?.(!0)) : (scrollBridge.scrollLockY = 0, scrollBridge.setScrollEnabled?.(!1));
|
|
228
|
+
}
|
|
229
|
+
}, [hasntMeasured, disableAnimation, isHidden, frameSize, screenSize, open, position]);
|
|
230
|
+
const disableDrag = props.disableDrag ?? controller?.disableDrag,
|
|
231
|
+
themeName = (0, import_gui_core.useThemeName)(),
|
|
232
|
+
[blockPan, setBlockPan] = import_react.default.useState(!1),
|
|
233
|
+
panResponder = import_react.default.useMemo(() => {
|
|
234
|
+
if (disableDrag || !frameSize || isShowingInnerSheet) return;
|
|
235
|
+
const minY = positions[0];
|
|
236
|
+
scrollBridge.paneMinY = minY;
|
|
237
|
+
let startY = at.current;
|
|
238
|
+
function setPanning(val) {
|
|
239
|
+
setIsDragging(val), sheetHiddenStyleSheet || (sheetHiddenStyleSheet = document.createElement("style"), typeof document.head < "u" && document.head.appendChild(sheetHiddenStyleSheet)), val ? sheetHiddenStyleSheet.innerText = ":root * { user-select: none !important; -webkit-user-select: none !important; }" : sheetHiddenStyleSheet.innerText = "";
|
|
240
|
+
}
|
|
241
|
+
const release = ({
|
|
242
|
+
vy
|
|
243
|
+
}) => {
|
|
244
|
+
if (scrollBridge.setParentDragging(!1), scrollBridge.scrollLock) return;
|
|
245
|
+
isExternalDrag = !1, previouslyScrolling = !1, setPanning(!1);
|
|
246
|
+
const end = at.current + frameSize * vy * 0.2;
|
|
247
|
+
let closestPoint = 0,
|
|
248
|
+
dist = Number.POSITIVE_INFINITY;
|
|
249
|
+
for (let i = 0; i < positions.length; i++) {
|
|
250
|
+
const position2 = positions[i],
|
|
251
|
+
curDist = end > position2 ? end - position2 : position2 - end;
|
|
252
|
+
curDist < dist && (dist = curDist, closestPoint = i);
|
|
253
|
+
}
|
|
254
|
+
setPosition(closestPoint), animateTo(closestPoint);
|
|
255
|
+
},
|
|
256
|
+
finish = (_e, state2) => {
|
|
257
|
+
release({
|
|
258
|
+
vy: state2.vy,
|
|
259
|
+
dragAt: state2.dy
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
let previouslyScrolling = !1;
|
|
263
|
+
const onMoveShouldSet = (e, {
|
|
264
|
+
dy
|
|
265
|
+
}) => {
|
|
266
|
+
function getShouldSet() {
|
|
267
|
+
if (e.target === providerProps.handleRef.current) return !0;
|
|
268
|
+
if (scrollBridge.hasScrollableContent === !0) {
|
|
269
|
+
if (scrollBridge.scrollLock) return !1;
|
|
270
|
+
const isScrolled = scrollBridge.y !== 0,
|
|
271
|
+
isDraggingUp = dy < 0,
|
|
272
|
+
isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
|
|
273
|
+
if (isScrolled) return previouslyScrolling = !0, !1;
|
|
274
|
+
if (isNearTop && hasScrollView.current && isDraggingUp) return !1;
|
|
275
|
+
}
|
|
276
|
+
return Math.abs(dy) > 10;
|
|
277
|
+
}
|
|
278
|
+
const granted = getShouldSet();
|
|
279
|
+
return granted && scrollBridge.setParentDragging(!0), granted;
|
|
280
|
+
},
|
|
281
|
+
grant = () => {
|
|
282
|
+
setPanning(!0), stopSpring(), startY = at.current;
|
|
283
|
+
};
|
|
284
|
+
let isExternalDrag = !1;
|
|
285
|
+
return scrollBridge.drag = dy => {
|
|
286
|
+
isExternalDrag || (isExternalDrag = !0, grant());
|
|
287
|
+
const to = dy + startY;
|
|
288
|
+
animatedNumber.setValue((0, import_helpers.resisted)(to, minY), {
|
|
289
|
+
type: "direct"
|
|
290
|
+
});
|
|
291
|
+
}, scrollBridge.release = release, scrollBridge.snapToPosition = positionIndex => {
|
|
292
|
+
isExternalDrag = !1, previouslyScrolling = !1, setPanning(!1), setPosition(positionIndex), animateTo(positionIndex);
|
|
293
|
+
}, import_react_native.PanResponder.create({
|
|
294
|
+
onMoveShouldSetPanResponder: onMoveShouldSet,
|
|
295
|
+
onPanResponderGrant: grant,
|
|
296
|
+
onPanResponderMove: (_e, {
|
|
297
|
+
dy
|
|
298
|
+
}) => {
|
|
299
|
+
const toFull = dy + startY,
|
|
300
|
+
to = (0, import_helpers.resisted)(toFull, minY);
|
|
301
|
+
to <= minY ? scrollBridge.setParentDragging(!1) : scrollBridge.setParentDragging(!0), animatedNumber.setValue(to, {
|
|
302
|
+
type: "direct"
|
|
303
|
+
});
|
|
304
|
+
},
|
|
305
|
+
onPanResponderEnd: finish,
|
|
306
|
+
onPanResponderTerminate: finish,
|
|
307
|
+
onPanResponderRelease: finish
|
|
308
|
+
});
|
|
309
|
+
}, [disableDrag, isShowingInnerSheet, animateTo, frameSize, positions, setPosition]);
|
|
310
|
+
import_react.default.useEffect(() => {
|
|
311
|
+
isDragging || isHidden || !open || disableAnimation || !frameSize || !screenSize || animateTo(position, {
|
|
312
|
+
type: "timing",
|
|
313
|
+
duration: 250
|
|
314
|
+
});
|
|
315
|
+
}, [isKeyboardVisible, keyboardHeight]);
|
|
316
|
+
const wasDragging = import_react.default.useRef(!1);
|
|
317
|
+
import_react.default.useEffect(() => {
|
|
318
|
+
if (isDragging) {
|
|
319
|
+
wasDragging.current = !0;
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
wasDragging.current && (wasDragging.current = !1, !(!frameSize || !screenSize || isHidden || !open) && animateTo(position));
|
|
323
|
+
}, [isDragging]), import_react.default.useEffect(() => {
|
|
324
|
+
!open && isKeyboardVisible && dismissKeyboard();
|
|
325
|
+
}, [open]);
|
|
326
|
+
const {
|
|
327
|
+
panGesture,
|
|
328
|
+
panGestureRef,
|
|
329
|
+
gestureHandlerEnabled
|
|
330
|
+
} = (0, import_useGestureHandlerPan.useGestureHandlerPan)({
|
|
331
|
+
positions: activePositions,
|
|
332
|
+
frameSize,
|
|
333
|
+
setPosition,
|
|
334
|
+
animateTo,
|
|
335
|
+
stopSpring,
|
|
336
|
+
scrollBridge,
|
|
337
|
+
setIsDragging,
|
|
338
|
+
getCurrentPosition: () => at.current,
|
|
339
|
+
resisted: import_helpers.resisted,
|
|
340
|
+
disableDrag,
|
|
341
|
+
isShowingInnerSheet,
|
|
342
|
+
setAnimatedPosition: val => {
|
|
343
|
+
at.current = val, animatedNumber.setValue(val, {
|
|
344
|
+
type: "direct"
|
|
345
|
+
});
|
|
346
|
+
},
|
|
347
|
+
pauseKeyboardHandler
|
|
348
|
+
}),
|
|
349
|
+
handleAnimationViewLayout = (0, import_gui_core.useEvent)(e => {
|
|
350
|
+
if (!open && stableFrameSize.current !== 0) return;
|
|
351
|
+
const layoutHeight = e.nativeEvent?.layout.height,
|
|
352
|
+
next = modal ? Math.min(layoutHeight, import_react_native.Dimensions.get(relativeDimensionTo).height) : layoutHeight;
|
|
353
|
+
next && setFrameSize(next);
|
|
354
|
+
}),
|
|
355
|
+
handleMaxContentViewLayout = import_react.default.useCallback(e => {
|
|
356
|
+
const next = Math.min(e.nativeEvent?.layout.height, import_react_native.Dimensions.get(relativeDimensionTo).height);
|
|
357
|
+
next && setMaxContentSize(next);
|
|
358
|
+
}, []),
|
|
359
|
+
animatedStyle = useAnimatedNumberStyle(animatedNumber, val => {
|
|
360
|
+
"worklet";
|
|
361
|
+
|
|
362
|
+
return {
|
|
363
|
+
transform: [{
|
|
364
|
+
translateY: frameSize === 0 ? hiddenSize : val
|
|
365
|
+
}]
|
|
366
|
+
};
|
|
367
|
+
}),
|
|
368
|
+
[opacity, setOpacity] = import_react.default.useState(open ? 1 : 0);
|
|
369
|
+
open && opacity === 0 && (setOpacity(1), opacityFallbackTimer.current && (clearTimeout(opacityFallbackTimer.current), opacityFallbackTimer.current = null));
|
|
370
|
+
const forcedContentHeight = hasFit ? void 0 : snapPointsMode === "percent" ?
|
|
371
|
+
// Use dvh for modal (viewport-relative), % for inline (container-relative)
|
|
372
|
+
`${maxSnapPoint}${import_gui_constants.isWeb && modal ? "dvh" : "%"}` : maxSnapPoint,
|
|
373
|
+
setHasScrollView = import_react.default.useCallback(val => {
|
|
374
|
+
hasScrollView.current = val;
|
|
375
|
+
}, []);
|
|
376
|
+
let contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_core.LayoutMeasurementController, {
|
|
377
|
+
disable: !open,
|
|
378
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_contexts.ParentSheetContext.Provider, {
|
|
379
|
+
value: nextParentContext,
|
|
380
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_SheetContext.SheetProvider, {
|
|
381
|
+
...providerProps,
|
|
382
|
+
setHasScrollView,
|
|
383
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_GestureSheetContext.GestureSheetProvider, {
|
|
384
|
+
isDragging,
|
|
385
|
+
blockPan,
|
|
386
|
+
setBlockPan,
|
|
387
|
+
panGesture,
|
|
388
|
+
panGestureRef,
|
|
389
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_animate_presence.AnimatePresence, {
|
|
390
|
+
custom: {
|
|
391
|
+
open
|
|
392
|
+
},
|
|
393
|
+
children: shouldHideParentSheet || !open ? null : overlayComponent
|
|
394
|
+
}), snapPointsMode !== "percent" && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
|
|
395
|
+
style: {
|
|
396
|
+
opacity: 0,
|
|
397
|
+
position: "absolute",
|
|
398
|
+
top: 0,
|
|
399
|
+
left: 0,
|
|
400
|
+
right: 0,
|
|
401
|
+
bottom: 0,
|
|
402
|
+
pointerEvents: "none"
|
|
403
|
+
},
|
|
404
|
+
onLayout: handleMaxContentViewLayout
|
|
405
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(AnimatedView, {
|
|
406
|
+
ref,
|
|
407
|
+
onLayout: handleAnimationViewLayout,
|
|
408
|
+
transition: isDragging || disableAnimation ? null : transition,
|
|
409
|
+
disableClassName: !0,
|
|
410
|
+
style: [{
|
|
411
|
+
position: "absolute",
|
|
412
|
+
zIndex,
|
|
413
|
+
width: "100%",
|
|
414
|
+
height: forcedContentHeight,
|
|
415
|
+
minHeight: forcedContentHeight,
|
|
416
|
+
opacity: shouldHideParentSheet ? 0 : opacity,
|
|
417
|
+
...((shouldHideParentSheet || !open) && {
|
|
418
|
+
pointerEvents: "none"
|
|
419
|
+
})
|
|
420
|
+
}, animatedStyle],
|
|
421
|
+
children: gestureHandlerEnabled && panGesture ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_GestureDetectorWrapper.GestureDetectorWrapper, {
|
|
422
|
+
gesture: panGesture,
|
|
423
|
+
style: {
|
|
424
|
+
flex: 1
|
|
425
|
+
},
|
|
426
|
+
children: props.children
|
|
427
|
+
}) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
|
|
428
|
+
...panResponder?.panHandlers,
|
|
429
|
+
style: {
|
|
430
|
+
flex: 1,
|
|
431
|
+
width: "100%",
|
|
432
|
+
height: "100%"
|
|
433
|
+
},
|
|
434
|
+
children: props.children
|
|
435
|
+
})
|
|
436
|
+
})]
|
|
437
|
+
})
|
|
438
|
+
})
|
|
439
|
+
})
|
|
440
|
+
});
|
|
441
|
+
const shouldMountChildren = unmountChildrenWhenHidden ? !!opacity : !0;
|
|
442
|
+
if (modal) {
|
|
443
|
+
const modalContents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_portal.Portal, {
|
|
444
|
+
stackZIndex: zIndex,
|
|
445
|
+
...portalProps,
|
|
446
|
+
children: shouldMountChildren && /* @__PURE__ */(0, import_jsx_runtime.jsx)(ContainerComponent, {
|
|
447
|
+
children: contents
|
|
448
|
+
})
|
|
449
|
+
});
|
|
450
|
+
return import_gui_constants.isWeb ? modalContents : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_contexts.SheetInsideSheetContext.Provider, {
|
|
451
|
+
value: onInnerSheet,
|
|
452
|
+
children: modalContents
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
return contents;
|
|
456
|
+
});
|
|
457
|
+
function getYPositions(mode, point, screenSize, frameSize) {
|
|
458
|
+
if (!screenSize || !frameSize) return 0;
|
|
459
|
+
if (mode === "mixed") {
|
|
460
|
+
if (typeof point == "number") return screenSize - Math.min(screenSize, Math.max(0, point));
|
|
461
|
+
if (point === "fit") return screenSize - Math.min(screenSize, frameSize);
|
|
462
|
+
if (point.endsWith("%")) {
|
|
463
|
+
const pct2 = Math.min(100, Math.max(0, Number(point.slice(0, -1)))) / 100;
|
|
464
|
+
return Number.isNaN(pct2) ? (console.warn("Invalid snapPoint percentage string"), 0) : Math.round(screenSize - pct2 * screenSize);
|
|
465
|
+
}
|
|
466
|
+
return console.warn("Invalid snapPoint unknown value"), 0;
|
|
467
|
+
}
|
|
468
|
+
if (mode === "fit") return point === 0 ? screenSize : screenSize - Math.min(screenSize, frameSize);
|
|
469
|
+
if (mode === "constant" && typeof point == "number") return screenSize - Math.min(screenSize, Math.max(0, point));
|
|
470
|
+
const pct = Math.min(100, Math.max(0, Number(point))) / 100;
|
|
471
|
+
return Number.isNaN(pct) ? (console.warn("Invalid snapPoint percentage"), 0) : Math.round(screenSize - pct * screenSize);
|
|
472
|
+
}
|