@tamagui/sheet 1.135.4-1761749240853 → 1.135.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Sheet.native.js +90 -96
- package/dist/cjs/Sheet.native.js.map +6 -1
- package/dist/cjs/SheetContext.native.js +18 -21
- package/dist/cjs/SheetContext.native.js.map +6 -1
- package/dist/cjs/SheetController.cjs +1 -1
- package/dist/cjs/SheetController.js +1 -1
- package/dist/cjs/SheetController.js.map +1 -1
- package/dist/cjs/SheetController.native.js +38 -51
- package/dist/cjs/SheetController.native.js.map +6 -1
- package/dist/cjs/SheetImplementationCustom.cjs +1 -1
- package/dist/cjs/SheetImplementationCustom.js +1 -1
- package/dist/cjs/SheetImplementationCustom.js.map +1 -1
- package/dist/cjs/SheetImplementationCustom.native.js +312 -362
- package/dist/cjs/SheetImplementationCustom.native.js.map +6 -1
- package/dist/cjs/SheetScrollView.cjs +1 -1
- package/dist/cjs/SheetScrollView.js +1 -1
- package/dist/cjs/SheetScrollView.js.map +1 -1
- package/dist/cjs/SheetScrollView.native.js +107 -137
- package/dist/cjs/SheetScrollView.native.js.map +6 -1
- package/dist/cjs/constants.native.js +18 -21
- package/dist/cjs/constants.native.js.map +6 -1
- package/dist/cjs/contexts.cjs +1 -1
- package/dist/cjs/contexts.js +1 -1
- package/dist/cjs/contexts.native.js +21 -28
- package/dist/cjs/contexts.native.js.map +6 -1
- package/dist/cjs/createSheet.native.js +101 -148
- package/dist/cjs/createSheet.native.js.map +6 -1
- package/dist/cjs/helpers.native.js +17 -20
- package/dist/cjs/helpers.native.js.map +6 -1
- package/dist/cjs/index.native.js +32 -23
- package/dist/cjs/index.native.js.map +6 -1
- package/dist/cjs/nativeSheet.native.js +53 -65
- package/dist/cjs/nativeSheet.native.js.map +6 -1
- package/dist/cjs/types.native.js +5 -9
- package/dist/cjs/types.native.js.map +6 -1
- package/dist/cjs/useSheet.native.js +17 -21
- package/dist/cjs/useSheet.native.js.map +6 -1
- package/dist/cjs/useSheetController.cjs +1 -1
- package/dist/cjs/useSheetController.js +1 -1
- package/dist/cjs/useSheetController.native.js +27 -36
- package/dist/cjs/useSheetController.native.js.map +6 -1
- package/dist/cjs/useSheetOffscreenSize.native.js +23 -41
- package/dist/cjs/useSheetOffscreenSize.native.js.map +6 -1
- package/dist/cjs/useSheetOpenState.native.js +30 -44
- package/dist/cjs/useSheetOpenState.native.js.map +6 -1
- package/dist/cjs/useSheetProviderProps.cjs +1 -1
- package/dist/cjs/useSheetProviderProps.js +1 -1
- package/dist/cjs/useSheetProviderProps.js.map +1 -1
- package/dist/cjs/useSheetProviderProps.native.js +108 -119
- package/dist/cjs/useSheetProviderProps.native.js.map +6 -1
- package/dist/jsx/Sheet.native.js +84 -114
- package/dist/jsx/Sheet.native.js.map +6 -1
- package/dist/jsx/SheetContext.native.js +10 -35
- package/dist/jsx/SheetContext.native.js.map +6 -1
- package/dist/jsx/SheetController.native.js +29 -67
- package/dist/jsx/SheetController.native.js.map +6 -1
- package/dist/jsx/SheetImplementationCustom.native.js +312 -377
- package/dist/jsx/SheetImplementationCustom.native.js.map +6 -1
- package/dist/jsx/SheetScrollView.native.js +104 -156
- package/dist/jsx/SheetScrollView.native.js.map +6 -1
- package/dist/jsx/constants.native.js +8 -35
- package/dist/jsx/constants.native.js.map +6 -1
- package/dist/jsx/contexts.native.js +9 -45
- package/dist/jsx/contexts.native.js.map +6 -1
- package/dist/jsx/createSheet.native.js +109 -160
- package/dist/jsx/createSheet.native.js.map +6 -1
- package/dist/jsx/helpers.native.js +7 -31
- package/dist/jsx/helpers.native.js.map +6 -1
- package/dist/jsx/index.native.js +12 -31
- package/dist/jsx/index.native.js.map +6 -1
- package/dist/jsx/nativeSheet.native.js +50 -77
- package/dist/jsx/nativeSheet.native.js.map +6 -1
- package/dist/jsx/types.native.js +1 -19
- package/dist/jsx/types.native.js.map +6 -1
- package/dist/jsx/useSheet.native.js +8 -32
- package/dist/jsx/useSheet.native.js.map +6 -1
- package/dist/jsx/useSheetController.native.js +14 -52
- package/dist/jsx/useSheetController.native.js.map +6 -1
- package/dist/jsx/useSheetOffscreenSize.native.js +13 -52
- package/dist/jsx/useSheetOffscreenSize.native.js.map +6 -1
- package/dist/jsx/useSheetOpenState.native.js +22 -55
- package/dist/jsx/useSheetOpenState.native.js.map +6 -1
- package/dist/jsx/useSheetProviderProps.native.js +98 -135
- package/dist/jsx/useSheetProviderProps.native.js.map +6 -1
- package/package.json +19 -20
- package/types/SheetContext.d.ts.map +1 -1
|
@@ -1,407 +1,342 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ProvideAdaptContext, useAdaptContext } from "@tamagui/adapt";
|
|
3
|
+
import { AnimatePresence } from "@tamagui/animate-presence";
|
|
4
|
+
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
5
|
+
import { currentPlatform, isClient, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
6
|
+
import { LayoutMeasurementController, Stack, Theme, useConfiguration, useDidFinishSSR, useEvent, useThemeName } from "@tamagui/core";
|
|
7
|
+
import { Portal, USE_NATIVE_PORTAL } from "@tamagui/portal";
|
|
8
|
+
import React, { useState } from "react";
|
|
9
|
+
import { Dimensions, Keyboard, PanResponder, View } from "react-native";
|
|
10
|
+
import { ParentSheetContext, SheetInsideSheetContext } from "./contexts";
|
|
11
|
+
import { resisted } from "./helpers";
|
|
12
|
+
import { SheetProvider } from "./SheetContext";
|
|
13
|
+
import { useSheetOpenState } from "./useSheetOpenState";
|
|
14
|
+
import { useSheetProviderProps } from "./useSheetProviderProps";
|
|
15
|
+
var hiddenSize = 10000.1, sheetHiddenStyleSheet = null, relativeDimensionTo = isWeb ? "window" : "screen", SheetImplementationCustom = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
16
|
+
var parentSheet = React.useContext(ParentSheetContext), { animation, animationConfig: animationConfigProp, modal = !1, zIndex = parentSheet.zIndex + 1, moveOnKeyboardChange = !1, unmountChildrenWhenHidden = !1, portalProps, containerComponent: ContainerComponent = React.Fragment } = props, state = useSheetOpenState(props), [overlayComponent, setOverlayComponent] = React.useState(null), providerProps = useSheetProviderProps(props, state, {
|
|
17
|
+
onOverlayComponent: setOverlayComponent
|
|
18
|
+
}), { frameSize, setFrameSize, snapPoints, snapPointsMode, hasFit, position, setPosition, scrollBridge, screenSize, setMaxContentSize, maxSnapPoint } = providerProps, { open, controller, isHidden } = state, sheetRef = React.useRef(void 0), ref = useComposedRefs(forwardedRef, sheetRef, providerProps.contentRef), { animationDriver } = useConfiguration();
|
|
19
|
+
if (!animationDriver)
|
|
20
|
+
throw new Error("Sheet reqiures an animation driver to be set");
|
|
21
|
+
var animationConfig = function() {
|
|
22
|
+
if (animationDriver.supportsCSS)
|
|
23
|
+
return {};
|
|
24
|
+
var [animationProp, animationPropConfig] = animation ? Array.isArray(animation) ? animation : [
|
|
25
|
+
animation
|
|
26
|
+
] : [];
|
|
27
|
+
return animationConfigProp ?? (animationProp ? {
|
|
28
|
+
...animationDriver.animations[animationProp],
|
|
29
|
+
...animationPropConfig
|
|
30
|
+
} : null);
|
|
31
|
+
}(), [isShowingInnerSheet, setIsShowingInnerSheet] = React.useState(!1), shouldHideParentSheet = !isWeb && modal && isShowingInnerSheet && // if not using weird portal limitation we dont need to hide parent sheet
|
|
32
|
+
USE_NATIVE_PORTAL, sheetInsideSheet = React.useContext(SheetInsideSheetContext), onInnerSheet = React.useCallback(function(hasChild) {
|
|
33
|
+
setIsShowingInnerSheet(hasChild);
|
|
34
|
+
}, []), positions = React.useMemo(function() {
|
|
35
|
+
return snapPoints.map(function(point) {
|
|
36
|
+
return getYPositions(snapPointsMode, point, screenSize, frameSize);
|
|
13
37
|
});
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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 SheetImplementationCustom_exports = {};
|
|
35
|
-
__export(SheetImplementationCustom_exports, {
|
|
36
|
-
SheetImplementationCustom: () => SheetImplementationCustom
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(SheetImplementationCustom_exports);
|
|
39
|
-
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
40
|
-
import_adapt = require("@tamagui/adapt"),
|
|
41
|
-
import_animate_presence = require("@tamagui/animate-presence"),
|
|
42
|
-
import_compose_refs = require("@tamagui/compose-refs"),
|
|
43
|
-
import_constants = require("@tamagui/constants"),
|
|
44
|
-
import_core = require("@tamagui/core"),
|
|
45
|
-
import_portal = require("@tamagui/portal"),
|
|
46
|
-
import_react = __toESM(require("react"), 1),
|
|
47
|
-
import_react_native = require("react-native"),
|
|
48
|
-
import_contexts = require("./contexts.native.js"),
|
|
49
|
-
import_helpers = require("./helpers.native.js"),
|
|
50
|
-
import_SheetContext = require("./SheetContext.native.js"),
|
|
51
|
-
import_useSheetOpenState = require("./useSheetOpenState.native.js"),
|
|
52
|
-
import_useSheetProviderProps = require("./useSheetProviderProps.native.js"),
|
|
53
|
-
hiddenSize = 10000.1,
|
|
54
|
-
sheetHiddenStyleSheet = null,
|
|
55
|
-
relativeDimensionTo = import_constants.isWeb ? "window" : "screen",
|
|
56
|
-
SheetImplementationCustom = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
|
|
57
|
-
var parentSheet = import_react.default.useContext(import_contexts.ParentSheetContext),
|
|
58
|
-
{
|
|
59
|
-
animation,
|
|
60
|
-
animationConfig: animationConfigProp,
|
|
61
|
-
modal = !1,
|
|
62
|
-
zIndex = parentSheet.zIndex + 1,
|
|
63
|
-
moveOnKeyboardChange = !1,
|
|
64
|
-
unmountChildrenWhenHidden = !1,
|
|
65
|
-
portalProps,
|
|
66
|
-
containerComponent: ContainerComponent = import_react.default.Fragment
|
|
67
|
-
} = props,
|
|
68
|
-
state = (0, import_useSheetOpenState.useSheetOpenState)(props),
|
|
69
|
-
[overlayComponent, setOverlayComponent] = import_react.default.useState(null),
|
|
70
|
-
providerProps = (0, import_useSheetProviderProps.useSheetProviderProps)(props, state, {
|
|
71
|
-
onOverlayComponent: setOverlayComponent
|
|
72
|
-
}),
|
|
73
|
-
{
|
|
74
|
-
frameSize,
|
|
75
|
-
setFrameSize,
|
|
76
|
-
snapPoints,
|
|
77
|
-
snapPointsMode,
|
|
78
|
-
hasFit,
|
|
79
|
-
position,
|
|
80
|
-
setPosition,
|
|
81
|
-
scrollBridge,
|
|
82
|
-
screenSize,
|
|
83
|
-
setMaxContentSize,
|
|
84
|
-
maxSnapPoint
|
|
85
|
-
} = providerProps,
|
|
86
|
-
{
|
|
87
|
-
open,
|
|
88
|
-
controller,
|
|
89
|
-
isHidden
|
|
90
|
-
} = state,
|
|
91
|
-
sheetRef = import_react.default.useRef(void 0),
|
|
92
|
-
ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, sheetRef, providerProps.contentRef),
|
|
93
|
-
{
|
|
94
|
-
animationDriver
|
|
95
|
-
} = (0, import_core.useConfiguration)();
|
|
96
|
-
if (!animationDriver) throw new Error("Sheet reqiures an animation driver to be set");
|
|
97
|
-
var animationConfig = function () {
|
|
98
|
-
if (animationDriver.supportsCSS) return {};
|
|
99
|
-
var [animationProp, animationPropConfig] = animation ? Array.isArray(animation) ? animation : [animation] : [];
|
|
100
|
-
return animationConfigProp ?? (animationProp ? {
|
|
101
|
-
...animationDriver.animations[animationProp],
|
|
102
|
-
...animationPropConfig
|
|
103
|
-
} : null);
|
|
104
|
-
}(),
|
|
105
|
-
[isShowingInnerSheet, setIsShowingInnerSheet] = import_react.default.useState(!1),
|
|
106
|
-
shouldHideParentSheet = !import_constants.isWeb && modal && isShowingInnerSheet &&
|
|
107
|
-
// if not using weird portal limitation we dont need to hide parent sheet
|
|
108
|
-
import_portal.USE_NATIVE_PORTAL,
|
|
109
|
-
sheetInsideSheet = import_react.default.useContext(import_contexts.SheetInsideSheetContext),
|
|
110
|
-
onInnerSheet = import_react.default.useCallback(function (hasChild) {
|
|
111
|
-
setIsShowingInnerSheet(hasChild);
|
|
112
|
-
}, []),
|
|
113
|
-
positions = import_react.default.useMemo(function () {
|
|
114
|
-
return snapPoints.map(function (point) {
|
|
115
|
-
return getYPositions(snapPointsMode, point, screenSize, frameSize);
|
|
116
|
-
});
|
|
117
|
-
}, [screenSize, frameSize, snapPoints, snapPointsMode]),
|
|
118
|
-
{
|
|
119
|
-
useAnimatedNumber,
|
|
120
|
-
useAnimatedNumberStyle,
|
|
121
|
-
useAnimatedNumberReaction
|
|
122
|
-
} = animationDriver,
|
|
123
|
-
_animationDriver_View,
|
|
124
|
-
AnimatedView = (_animationDriver_View = animationDriver.View) !== null && _animationDriver_View !== void 0 ? _animationDriver_View : import_core.Stack;
|
|
125
|
-
(0, import_constants.useIsomorphicLayoutEffect)(function () {
|
|
126
|
-
if (sheetInsideSheet && open) return sheetInsideSheet(!0), function () {
|
|
38
|
+
}, [
|
|
39
|
+
screenSize,
|
|
40
|
+
frameSize,
|
|
41
|
+
snapPoints,
|
|
42
|
+
snapPointsMode
|
|
43
|
+
]), { useAnimatedNumber, useAnimatedNumberStyle, useAnimatedNumberReaction } = animationDriver, _animationDriver_View, AnimatedView = (_animationDriver_View = animationDriver.View) !== null && _animationDriver_View !== void 0 ? _animationDriver_View : Stack;
|
|
44
|
+
useIsomorphicLayoutEffect(function() {
|
|
45
|
+
if (sheetInsideSheet && open)
|
|
46
|
+
return sheetInsideSheet(!0), function() {
|
|
127
47
|
sheetInsideSheet(!1);
|
|
128
48
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
49
|
+
}, [
|
|
50
|
+
sheetInsideSheet,
|
|
51
|
+
open
|
|
52
|
+
]);
|
|
53
|
+
var nextParentContext = React.useMemo(function() {
|
|
54
|
+
return {
|
|
55
|
+
zIndex
|
|
56
|
+
};
|
|
57
|
+
}, [
|
|
58
|
+
zIndex
|
|
59
|
+
]), isMounted = useDidFinishSSR(), startPosition = isMounted && screenSize ? screenSize : hiddenSize, animatedNumber = useAnimatedNumber(startPosition), at = React.useRef(startPosition), hasntMeasured = at.current === hiddenSize, [disableAnimation, setDisableAnimation] = useState(hasntMeasured), hasScrollView = React.useRef(!1);
|
|
60
|
+
useAnimatedNumberReaction({
|
|
61
|
+
value: animatedNumber,
|
|
62
|
+
hostRef: sheetRef
|
|
63
|
+
}, React.useCallback(function(value) {
|
|
64
|
+
at.current = value, scrollBridge.paneY = value;
|
|
65
|
+
}, [
|
|
66
|
+
animationDriver
|
|
67
|
+
]));
|
|
68
|
+
function stopSpring() {
|
|
69
|
+
animatedNumber.stop(), scrollBridge.onFinishAnimate && (scrollBridge.onFinishAnimate(), scrollBridge.onFinishAnimate = void 0);
|
|
70
|
+
}
|
|
71
|
+
var animateTo = useEvent(function(position2) {
|
|
72
|
+
if (frameSize !== 0) {
|
|
73
|
+
var toValue = isHidden || position2 === -1 ? screenSize : positions[position2];
|
|
74
|
+
at.current !== toValue && (at.current = toValue, stopSpring(), animatedNumber.setValue(toValue, {
|
|
75
|
+
type: "spring",
|
|
76
|
+
...animationConfig
|
|
77
|
+
}));
|
|
150
78
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
79
|
+
});
|
|
80
|
+
useIsomorphicLayoutEffect(function() {
|
|
81
|
+
if (hasntMeasured && screenSize && frameSize) {
|
|
82
|
+
at.current = screenSize, animatedNumber.setValue(screenSize, {
|
|
83
|
+
type: "timing",
|
|
84
|
+
duration: 0
|
|
85
|
+
}, function() {
|
|
86
|
+
setTimeout(function() {
|
|
87
|
+
setDisableAnimation(!1);
|
|
88
|
+
}, 10);
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
disableAnimation || !frameSize || !screenSize || isHidden || hasntMeasured && !open || (animateTo(position), position === -1 && (scrollBridge.scrollLock = !1, scrollBridge.scrollStartY = -1));
|
|
93
|
+
}, [
|
|
94
|
+
hasntMeasured,
|
|
95
|
+
disableAnimation,
|
|
96
|
+
isHidden,
|
|
97
|
+
frameSize,
|
|
98
|
+
screenSize,
|
|
99
|
+
open,
|
|
100
|
+
position
|
|
101
|
+
]);
|
|
102
|
+
var _props_disableDrag, disableDrag = (_props_disableDrag = props.disableDrag) !== null && _props_disableDrag !== void 0 ? _props_disableDrag : controller == null ? void 0 : controller.disableDrag, themeName = useThemeName(), [isDragging, setIsDragging] = React.useState(!1), panResponder = React.useMemo(function() {
|
|
103
|
+
if (disableDrag || !frameSize || isShowingInnerSheet) return;
|
|
104
|
+
var minY = positions[0];
|
|
105
|
+
scrollBridge.paneMinY = minY;
|
|
106
|
+
var startY = at.current;
|
|
107
|
+
function setPanning(val) {
|
|
108
|
+
setIsDragging(val), isClient && (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 = "");
|
|
109
|
+
}
|
|
110
|
+
var release = function(param) {
|
|
111
|
+
var { vy, dragAt } = param;
|
|
112
|
+
if (scrollBridge.setParentDragging(!1), !scrollBridge.scrollLock) {
|
|
113
|
+
isExternalDrag = !1, previouslyScrolling = !1, setPanning(!1);
|
|
114
|
+
for (var at2 = dragAt + startY, end = at2 + frameSize * vy * 0.2, closestPoint = 0, dist = Number.POSITIVE_INFINITY, i = 0; i < positions.length; i++) {
|
|
115
|
+
var position2 = positions[i], curDist = end > position2 ? end - position2 : position2 - end;
|
|
116
|
+
curDist < dist && (dist = curDist, closestPoint = i);
|
|
117
|
+
}
|
|
118
|
+
setPosition(closestPoint), animateTo(closestPoint);
|
|
171
119
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
120
|
+
}, finish = function(_e, state2) {
|
|
121
|
+
release({
|
|
122
|
+
vy: state2.vy,
|
|
123
|
+
dragAt: state2.dy
|
|
124
|
+
});
|
|
125
|
+
}, previouslyScrolling = !1, onMoveShouldSet = function(e, param) {
|
|
126
|
+
var { dy } = param;
|
|
127
|
+
function getShouldSet() {
|
|
128
|
+
if (e.target === providerProps.handleRef.current)
|
|
129
|
+
return !0;
|
|
130
|
+
if (scrollBridge.hasScrollableContent === !0) {
|
|
131
|
+
if (scrollBridge.scrollLock)
|
|
132
|
+
return !1;
|
|
133
|
+
var isScrolled = scrollBridge.y !== 0, isDraggingUp = dy < 0, isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
|
|
134
|
+
if (isScrolled)
|
|
135
|
+
return previouslyScrolling = !0, !1;
|
|
136
|
+
if (isNearTop && hasScrollView.current && isDraggingUp)
|
|
137
|
+
return !1;
|
|
185
138
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
},
|
|
207
|
-
previouslyScrolling = !1,
|
|
208
|
-
onMoveShouldSet = function (e, param) {
|
|
209
|
-
var {
|
|
210
|
-
dy
|
|
211
|
-
} = param;
|
|
212
|
-
function getShouldSet() {
|
|
213
|
-
if (e.target === providerProps.handleRef.current) return !0;
|
|
214
|
-
if (scrollBridge.hasScrollableContent === !0) {
|
|
215
|
-
if (scrollBridge.scrollLock) return !1;
|
|
216
|
-
var isScrolled = scrollBridge.y !== 0,
|
|
217
|
-
isDraggingUp = dy < 0,
|
|
218
|
-
isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
|
|
219
|
-
if (isScrolled) return previouslyScrolling = !0, !1;
|
|
220
|
-
if (isNearTop && hasScrollView.current && isDraggingUp) return !1;
|
|
221
|
-
}
|
|
222
|
-
return Math.abs(dy) > 10;
|
|
223
|
-
}
|
|
224
|
-
var granted = getShouldSet();
|
|
225
|
-
return granted && scrollBridge.setParentDragging(!0), granted;
|
|
226
|
-
},
|
|
227
|
-
grant = function () {
|
|
228
|
-
setPanning(!0), stopSpring(), startY = at.current;
|
|
229
|
-
},
|
|
230
|
-
isExternalDrag = !1;
|
|
231
|
-
return scrollBridge.drag = function (dy) {
|
|
232
|
-
isExternalDrag || (isExternalDrag = !0, grant());
|
|
233
|
-
var to = dy + startY;
|
|
234
|
-
animatedNumber.setValue((0, import_helpers.resisted)(to, minY), {
|
|
235
|
-
type: "direct"
|
|
236
|
-
});
|
|
237
|
-
}, scrollBridge.release = release, import_react_native.PanResponder.create({
|
|
238
|
-
onMoveShouldSetPanResponder: onMoveShouldSet,
|
|
239
|
-
onPanResponderGrant: grant,
|
|
240
|
-
onPanResponderMove: function (_e, param) {
|
|
241
|
-
var {
|
|
242
|
-
dy
|
|
243
|
-
} = param,
|
|
244
|
-
toFull = dy + startY,
|
|
245
|
-
to = (0, import_helpers.resisted)(toFull, minY),
|
|
246
|
-
isAtTop = to <= minY;
|
|
247
|
-
isAtTop ? scrollBridge.setParentDragging(!1) : scrollBridge.setParentDragging(!0), animatedNumber.setValue(to, {
|
|
248
|
-
type: "direct"
|
|
249
|
-
});
|
|
250
|
-
},
|
|
251
|
-
onPanResponderEnd: finish,
|
|
252
|
-
onPanResponderTerminate: finish,
|
|
253
|
-
onPanResponderRelease: finish
|
|
139
|
+
return Math.abs(dy) > 10;
|
|
140
|
+
}
|
|
141
|
+
var granted = getShouldSet();
|
|
142
|
+
return granted && scrollBridge.setParentDragging(!0), granted;
|
|
143
|
+
}, grant = function() {
|
|
144
|
+
setPanning(!0), stopSpring(), startY = at.current;
|
|
145
|
+
}, isExternalDrag = !1;
|
|
146
|
+
return scrollBridge.drag = function(dy) {
|
|
147
|
+
isExternalDrag || (isExternalDrag = !0, grant());
|
|
148
|
+
var to = dy + startY;
|
|
149
|
+
animatedNumber.setValue(resisted(to, minY), {
|
|
150
|
+
type: "direct"
|
|
151
|
+
});
|
|
152
|
+
}, scrollBridge.release = release, PanResponder.create({
|
|
153
|
+
onMoveShouldSetPanResponder: onMoveShouldSet,
|
|
154
|
+
onPanResponderGrant: grant,
|
|
155
|
+
onPanResponderMove: function(_e, param) {
|
|
156
|
+
var { dy } = param, toFull = dy + startY, to = resisted(toFull, minY), isAtTop = to <= minY;
|
|
157
|
+
isAtTop ? scrollBridge.setParentDragging(!1) : scrollBridge.setParentDragging(!0), animatedNumber.setValue(to, {
|
|
158
|
+
type: "direct"
|
|
254
159
|
});
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
160
|
+
},
|
|
161
|
+
onPanResponderEnd: finish,
|
|
162
|
+
onPanResponderTerminate: finish,
|
|
163
|
+
onPanResponderRelease: finish
|
|
164
|
+
});
|
|
165
|
+
}, [
|
|
166
|
+
disableDrag,
|
|
167
|
+
isShowingInnerSheet,
|
|
168
|
+
animateTo,
|
|
169
|
+
frameSize,
|
|
170
|
+
positions,
|
|
171
|
+
setPosition
|
|
172
|
+
]), handleAnimationViewLayout = React.useCallback(function(e) {
|
|
173
|
+
var _e_nativeEvent, next = Math.min((_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.layout.height, Dimensions.get(relativeDimensionTo).height);
|
|
174
|
+
next && setFrameSize(next);
|
|
175
|
+
}, []), handleMaxContentViewLayout = React.useCallback(function(e) {
|
|
176
|
+
var _e_nativeEvent, next = Math.min((_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.layout.height, Dimensions.get(relativeDimensionTo).height);
|
|
177
|
+
next && setMaxContentSize(next);
|
|
178
|
+
}, []), animatedStyle = useAnimatedNumberStyle(animatedNumber, function(val) {
|
|
179
|
+
"worklet";
|
|
180
|
+
var translateY = frameSize === 0 ? hiddenSize : val;
|
|
181
|
+
return {
|
|
182
|
+
transform: [
|
|
183
|
+
{
|
|
184
|
+
translateY
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
};
|
|
188
|
+
}), sizeBeforeKeyboard = React.useRef(null);
|
|
189
|
+
React.useEffect(function() {
|
|
190
|
+
if (!(isWeb || !moveOnKeyboardChange)) {
|
|
191
|
+
var keyboardShowListener = Keyboard.addListener(currentPlatform === "ios" ? "keyboardWillShow" : "keyboardDidShow", function(e) {
|
|
192
|
+
sizeBeforeKeyboard.current === null && (sizeBeforeKeyboard.current = isHidden || position === -1 ? screenSize : positions[position], animatedNumber.setValue(Math.max(sizeBeforeKeyboard.current - e.endCoordinates.height, 0), {
|
|
193
|
+
type: "timing",
|
|
194
|
+
duration: 250
|
|
195
|
+
}));
|
|
196
|
+
}), keyboardDidHideListener = Keyboard.addListener("keyboardDidHide", function() {
|
|
197
|
+
sizeBeforeKeyboard.current !== null && (animatedNumber.setValue(sizeBeforeKeyboard.current, {
|
|
198
|
+
type: "timing",
|
|
199
|
+
duration: 250
|
|
200
|
+
}), sizeBeforeKeyboard.current = null);
|
|
201
|
+
});
|
|
202
|
+
return function() {
|
|
203
|
+
keyboardDidHideListener.remove(), keyboardShowListener.remove();
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}, [
|
|
207
|
+
moveOnKeyboardChange,
|
|
208
|
+
positions,
|
|
209
|
+
position,
|
|
210
|
+
isHidden
|
|
211
|
+
]);
|
|
212
|
+
var [opacity, setOpacity] = React.useState(open ? 1 : 0);
|
|
213
|
+
open && opacity === 0 && setOpacity(1), React.useEffect(function() {
|
|
214
|
+
if (!open) {
|
|
215
|
+
var tm = setTimeout(function() {
|
|
216
|
+
setOpacity(0);
|
|
217
|
+
}, 400);
|
|
218
|
+
return function() {
|
|
219
|
+
clearTimeout(tm);
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}, [
|
|
223
|
+
open
|
|
224
|
+
]);
|
|
225
|
+
var forcedContentHeight = hasFit ? void 0 : snapPointsMode === "percent" ? `${maxSnapPoint}${isWeb ? "dvh" : "%"}` : maxSnapPoint, setHasScrollView = React.useCallback(function(val) {
|
|
226
|
+
hasScrollView.current = val;
|
|
227
|
+
}, []), contents = /* @__PURE__ */ _jsx(LayoutMeasurementController, {
|
|
228
|
+
disable: !open,
|
|
229
|
+
children: /* @__PURE__ */ _jsx(ParentSheetContext.Provider, {
|
|
230
|
+
value: nextParentContext,
|
|
231
|
+
children: /* @__PURE__ */ _jsxs(SheetProvider, {
|
|
232
|
+
...providerProps,
|
|
233
|
+
setHasScrollView,
|
|
234
|
+
children: [
|
|
235
|
+
/* @__PURE__ */ _jsx(AnimatePresence, {
|
|
236
|
+
custom: {
|
|
237
|
+
open
|
|
238
|
+
},
|
|
239
|
+
children: shouldHideParentSheet || !open ? null : overlayComponent
|
|
284
240
|
}),
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
setHasScrollView = import_react.default.useCallback(function (val) {
|
|
309
|
-
hasScrollView.current = val;
|
|
310
|
-
}, []),
|
|
311
|
-
contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.LayoutMeasurementController, {
|
|
312
|
-
disable: !open,
|
|
313
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_contexts.ParentSheetContext.Provider, {
|
|
314
|
-
value: nextParentContext,
|
|
315
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_SheetContext.SheetProvider, {
|
|
316
|
-
...providerProps,
|
|
317
|
-
setHasScrollView,
|
|
318
|
-
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
|
|
319
|
-
custom: {
|
|
320
|
-
open
|
|
321
|
-
},
|
|
322
|
-
children: shouldHideParentSheet || !open ? null : overlayComponent
|
|
323
|
-
}), snapPointsMode !== "percent" && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
|
|
324
|
-
style: {
|
|
325
|
-
opacity: 0,
|
|
326
|
-
position: "absolute",
|
|
327
|
-
top: 0,
|
|
328
|
-
left: 0,
|
|
329
|
-
right: 0,
|
|
330
|
-
bottom: 0,
|
|
331
|
-
pointerEvents: "none"
|
|
332
|
-
},
|
|
333
|
-
onLayout: handleMaxContentViewLayout
|
|
334
|
-
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(AnimatedView, {
|
|
335
|
-
ref,
|
|
336
|
-
...panResponder?.panHandlers,
|
|
337
|
-
onLayout: handleAnimationViewLayout,
|
|
338
|
-
// @ts-ignore for CSS driver this is necessary to attach the transition
|
|
339
|
-
// also motion driver at least though i suspect all drivers?
|
|
340
|
-
animation: isDragging || disableAnimation ? null : animation,
|
|
341
|
-
// @ts-ignore
|
|
342
|
-
disableClassName: !0,
|
|
343
|
-
style: [{
|
|
241
|
+
snapPointsMode !== "percent" && /* @__PURE__ */ _jsx(View, {
|
|
242
|
+
style: {
|
|
243
|
+
opacity: 0,
|
|
244
|
+
position: "absolute",
|
|
245
|
+
top: 0,
|
|
246
|
+
left: 0,
|
|
247
|
+
right: 0,
|
|
248
|
+
bottom: 0,
|
|
249
|
+
pointerEvents: "none"
|
|
250
|
+
},
|
|
251
|
+
onLayout: handleMaxContentViewLayout
|
|
252
|
+
}),
|
|
253
|
+
/* @__PURE__ */ _jsx(AnimatedView, {
|
|
254
|
+
ref,
|
|
255
|
+
...panResponder == null ? void 0 : panResponder.panHandlers,
|
|
256
|
+
onLayout: handleAnimationViewLayout,
|
|
257
|
+
// @ts-ignore for CSS driver this is necessary to attach the transition
|
|
258
|
+
// also motion driver at least though i suspect all drivers?
|
|
259
|
+
animation: isDragging || disableAnimation ? null : animation,
|
|
260
|
+
// @ts-ignore
|
|
261
|
+
disableClassName: !0,
|
|
262
|
+
style: [
|
|
263
|
+
{
|
|
344
264
|
position: "absolute",
|
|
345
265
|
zIndex,
|
|
346
266
|
width: "100%",
|
|
347
267
|
height: forcedContentHeight,
|
|
348
268
|
minHeight: forcedContentHeight,
|
|
349
269
|
opacity: shouldHideParentSheet ? 0 : opacity,
|
|
350
|
-
...(
|
|
270
|
+
...(shouldHideParentSheet || !open) && {
|
|
351
271
|
pointerEvents: "none"
|
|
352
|
-
}
|
|
353
|
-
},
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (!import_portal.USE_NATIVE_PORTAL) {
|
|
361
|
-
var adaptContext = (0, import_adapt.useAdaptContext)();
|
|
362
|
-
contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.ProvideAdaptContext, {
|
|
363
|
-
...adaptContext,
|
|
364
|
-
children: (/* @ts-ignore */
|
|
365
|
-
contents)
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
var shouldMountChildren = unmountChildrenWhenHidden ? !!opacity : !0;
|
|
369
|
-
if (modal) {
|
|
370
|
-
var modalContents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.Portal, {
|
|
371
|
-
stackZIndex: zIndex,
|
|
372
|
-
...portalProps,
|
|
373
|
-
children: shouldMountChildren && /* @__PURE__ */(0, import_jsx_runtime.jsx)(ContainerComponent, {
|
|
374
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Theme, {
|
|
375
|
-
contain: !0,
|
|
376
|
-
forceClassName: !0,
|
|
377
|
-
name: themeName,
|
|
378
|
-
children: contents
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
animatedStyle
|
|
275
|
+
],
|
|
276
|
+
children: (
|
|
277
|
+
/* <AdaptProvider>{props.children}</AdaptProvider> */
|
|
278
|
+
props.children
|
|
279
|
+
)
|
|
379
280
|
})
|
|
380
|
-
|
|
381
|
-
})
|
|
382
|
-
|
|
383
|
-
value: onInnerSheet,
|
|
384
|
-
children: modalContents
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
return contents;
|
|
281
|
+
]
|
|
282
|
+
})
|
|
283
|
+
})
|
|
388
284
|
});
|
|
285
|
+
if (!USE_NATIVE_PORTAL) {
|
|
286
|
+
var adaptContext = useAdaptContext();
|
|
287
|
+
contents = /* @__PURE__ */ _jsx(ProvideAdaptContext, {
|
|
288
|
+
...adaptContext,
|
|
289
|
+
children: (
|
|
290
|
+
/* @ts-ignore */
|
|
291
|
+
contents
|
|
292
|
+
)
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
var shouldMountChildren = unmountChildrenWhenHidden ? !!opacity : !0;
|
|
296
|
+
if (modal) {
|
|
297
|
+
var modalContents = /* @__PURE__ */ _jsx(Portal, {
|
|
298
|
+
stackZIndex: zIndex,
|
|
299
|
+
...portalProps,
|
|
300
|
+
children: shouldMountChildren && /* @__PURE__ */ _jsx(ContainerComponent, {
|
|
301
|
+
children: /* @__PURE__ */ _jsx(Theme, {
|
|
302
|
+
contain: !0,
|
|
303
|
+
forceClassName: !0,
|
|
304
|
+
name: themeName,
|
|
305
|
+
children: contents
|
|
306
|
+
})
|
|
307
|
+
})
|
|
308
|
+
});
|
|
309
|
+
return isWeb ? modalContents : /* @__PURE__ */ _jsx(SheetInsideSheetContext.Provider, {
|
|
310
|
+
value: onInnerSheet,
|
|
311
|
+
children: modalContents
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
return contents;
|
|
315
|
+
});
|
|
389
316
|
function getYPositions(mode, point, screenSize, frameSize) {
|
|
390
317
|
if (!screenSize || !frameSize) return 0;
|
|
391
318
|
if (mode === "mixed") {
|
|
392
|
-
if (typeof point == "number")
|
|
393
|
-
|
|
319
|
+
if (typeof point == "number")
|
|
320
|
+
return screenSize - Math.min(screenSize, Math.max(0, point));
|
|
321
|
+
if (point === "fit")
|
|
322
|
+
return screenSize - Math.min(screenSize, frameSize);
|
|
394
323
|
if (point.endsWith("%")) {
|
|
395
324
|
var pct = Math.min(100, Math.max(0, Number(point.slice(0, -1)))) / 100;
|
|
396
|
-
if (Number.isNaN(pct))
|
|
325
|
+
if (Number.isNaN(pct))
|
|
326
|
+
return console.warn("Invalid snapPoint percentage string"), 0;
|
|
397
327
|
var next = Math.round(screenSize - pct * screenSize);
|
|
398
328
|
return next;
|
|
399
329
|
}
|
|
400
330
|
return console.warn("Invalid snapPoint unknown value"), 0;
|
|
401
331
|
}
|
|
402
|
-
if (mode === "fit")
|
|
403
|
-
|
|
332
|
+
if (mode === "fit")
|
|
333
|
+
return point === 0 ? screenSize : screenSize - Math.min(screenSize, frameSize);
|
|
334
|
+
if (mode === "constant" && typeof point == "number")
|
|
335
|
+
return screenSize - Math.min(screenSize, Math.max(0, point));
|
|
404
336
|
var pct1 = Math.min(100, Math.max(0, Number(point))) / 100;
|
|
405
337
|
return Number.isNaN(pct1) ? (console.warn("Invalid snapPoint percentage"), 0) : Math.round(screenSize - pct1 * screenSize);
|
|
406
338
|
}
|
|
407
|
-
|
|
339
|
+
export {
|
|
340
|
+
SheetImplementationCustom
|
|
341
|
+
};
|
|
342
|
+
//# sourceMappingURL=SheetImplementationCustom.js.map
|