@tamagui/sheet 1.113.0 → 1.113.2
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/esm/Sheet.native.js +82 -79
- package/dist/esm/Sheet.native.js.map +6 -1
- package/dist/esm/SheetContext.native.js +9 -5
- package/dist/esm/SheetContext.native.js.map +6 -1
- package/dist/esm/SheetController.native.js +20 -19
- package/dist/esm/SheetController.native.js.map +6 -1
- package/dist/esm/SheetImplementationCustom.native.js +271 -303
- package/dist/esm/SheetImplementationCustom.native.js.map +6 -1
- package/dist/esm/SheetScrollView.native.js +89 -102
- package/dist/esm/SheetScrollView.native.js.map +6 -1
- package/dist/esm/constants.native.js +8 -6
- package/dist/esm/constants.native.js.map +6 -1
- package/dist/esm/contexts.native.js +7 -5
- package/dist/esm/contexts.native.js.map +6 -1
- package/dist/esm/createSheet.native.js +96 -120
- package/dist/esm/createSheet.native.js.map +6 -1
- package/dist/esm/helpers.native.js +5 -6
- package/dist/esm/helpers.native.js.map +6 -1
- package/dist/esm/index.native.js +12 -12
- package/dist/esm/index.native.js.map +6 -1
- package/dist/esm/nativeSheet.native.js +36 -34
- package/dist/esm/nativeSheet.native.js.map +6 -1
- package/dist/esm/types.native.js +1 -2
- package/dist/esm/types.native.js.map +6 -1
- package/dist/esm/useSheet.native.js +6 -4
- package/dist/esm/useSheet.native.js.map +6 -1
- package/dist/esm/useSheetController.native.js +14 -14
- package/dist/esm/useSheetController.native.js.map +6 -1
- package/dist/esm/useSheetOffscreenSize.native.js +13 -26
- package/dist/esm/useSheetOffscreenSize.native.js.map +6 -1
- package/dist/esm/useSheetOpenState.native.js +16 -21
- package/dist/esm/useSheetOpenState.native.js.map +6 -1
- package/dist/esm/useSheetProviderProps.native.js +83 -82
- package/dist/esm/useSheetProviderProps.native.js.map +6 -1
- package/package.json +16 -16
|
@@ -7,340 +7,308 @@ import { getConfig, Stack, Theme, useConfiguration, useEvent, useThemeName } fro
|
|
|
7
7
|
import { Portal } from "@tamagui/portal";
|
|
8
8
|
import React from "react";
|
|
9
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,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
position,
|
|
42
|
-
setPosition,
|
|
43
|
-
scrollBridge,
|
|
44
|
-
screenSize,
|
|
45
|
-
setMaxContentSize,
|
|
46
|
-
maxSnapPoint
|
|
47
|
-
} = providerProps,
|
|
48
|
-
{
|
|
49
|
-
open,
|
|
50
|
-
controller,
|
|
51
|
-
isHidden
|
|
52
|
-
} = state,
|
|
53
|
-
sheetRef = React.useRef(null),
|
|
54
|
-
ref = useComposedRefs(forwardedRef, sheetRef),
|
|
55
|
-
animationConfig = function () {
|
|
56
|
-
var [animationProp, animationPropConfig] = animation ? Array.isArray(animation) ? animation : [animation] : [];
|
|
57
|
-
return animationConfigProp ?? (animationProp ? {
|
|
58
|
-
...getConfig().animations.animations[animationProp],
|
|
59
|
-
...animationPropConfig
|
|
60
|
-
} : null);
|
|
61
|
-
}(),
|
|
62
|
-
[isShowingInnerSheet, setIsShowingInnerSheet] = React.useState(!1),
|
|
63
|
-
shouldHideParentSheet = !isWeb && modal && isShowingInnerSheet,
|
|
64
|
-
parentSheetContext = React.useContext(SheetInsideSheetContext),
|
|
65
|
-
onInnerSheet = React.useCallback(function (hasChild) {
|
|
66
|
-
setIsShowingInnerSheet(hasChild);
|
|
67
|
-
}, []),
|
|
68
|
-
positions = React.useMemo(function () {
|
|
69
|
-
return snapPoints.map(function (point) {
|
|
70
|
-
return getYPositions(snapPointsMode, point, screenSize, frameSize);
|
|
71
|
-
});
|
|
72
|
-
}, [screenSize, frameSize, snapPoints, snapPointsMode]),
|
|
73
|
-
{
|
|
74
|
-
animationDriver
|
|
75
|
-
} = useConfiguration(),
|
|
76
|
-
{
|
|
77
|
-
useAnimatedNumber,
|
|
78
|
-
useAnimatedNumberStyle,
|
|
79
|
-
useAnimatedNumberReaction
|
|
80
|
-
} = animationDriver,
|
|
81
|
-
_animationDriver_View,
|
|
82
|
-
AnimatedView = (_animationDriver_View = animationDriver.View) !== null && _animationDriver_View !== void 0 ? _animationDriver_View : Stack;
|
|
83
|
-
useIsomorphicLayoutEffect(function () {
|
|
84
|
-
if (parentSheetContext && open) return parentSheetContext(!0), function () {
|
|
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(null), ref = useComposedRefs(forwardedRef, sheetRef), animationConfig = function() {
|
|
19
|
+
var [animationProp, animationPropConfig] = animation ? Array.isArray(animation) ? animation : [
|
|
20
|
+
animation
|
|
21
|
+
] : [];
|
|
22
|
+
return animationConfigProp ?? (animationProp ? {
|
|
23
|
+
...getConfig().animations.animations[animationProp],
|
|
24
|
+
...animationPropConfig
|
|
25
|
+
} : null);
|
|
26
|
+
}(), [isShowingInnerSheet, setIsShowingInnerSheet] = React.useState(!1), shouldHideParentSheet = !isWeb && modal && isShowingInnerSheet, parentSheetContext = React.useContext(SheetInsideSheetContext), onInnerSheet = React.useCallback(function(hasChild) {
|
|
27
|
+
setIsShowingInnerSheet(hasChild);
|
|
28
|
+
}, []), positions = React.useMemo(function() {
|
|
29
|
+
return snapPoints.map(function(point) {
|
|
30
|
+
return getYPositions(snapPointsMode, point, screenSize, frameSize);
|
|
31
|
+
});
|
|
32
|
+
}, [
|
|
33
|
+
screenSize,
|
|
34
|
+
frameSize,
|
|
35
|
+
snapPoints,
|
|
36
|
+
snapPointsMode
|
|
37
|
+
]), { animationDriver } = useConfiguration(), { useAnimatedNumber, useAnimatedNumberStyle, useAnimatedNumberReaction } = animationDriver, _animationDriver_View, AnimatedView = (_animationDriver_View = animationDriver.View) !== null && _animationDriver_View !== void 0 ? _animationDriver_View : Stack;
|
|
38
|
+
useIsomorphicLayoutEffect(function() {
|
|
39
|
+
if (parentSheetContext && open)
|
|
40
|
+
return parentSheetContext(!0), function() {
|
|
85
41
|
parentSheetContext(!1);
|
|
86
42
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
animatedNumber.setValue(toValue, {
|
|
43
|
+
}, [
|
|
44
|
+
parentSheetContext,
|
|
45
|
+
open
|
|
46
|
+
]);
|
|
47
|
+
var nextParentContext = React.useMemo(function() {
|
|
48
|
+
return {
|
|
49
|
+
zIndex
|
|
50
|
+
};
|
|
51
|
+
}, [
|
|
52
|
+
zIndex
|
|
53
|
+
]), animatedNumber = useAnimatedNumber(hiddenSize), at = React.useRef(hiddenSize);
|
|
54
|
+
useAnimatedNumberReaction({
|
|
55
|
+
value: animatedNumber,
|
|
56
|
+
hostRef: sheetRef
|
|
57
|
+
}, React.useCallback(function(value) {
|
|
58
|
+
at.current = value, scrollBridge.paneY = value;
|
|
59
|
+
}, [
|
|
60
|
+
animationDriver
|
|
61
|
+
]));
|
|
62
|
+
function stopSpring() {
|
|
63
|
+
animatedNumber.stop(), scrollBridge.onFinishAnimate && (scrollBridge.onFinishAnimate(), scrollBridge.onFinishAnimate = void 0);
|
|
64
|
+
}
|
|
65
|
+
var hasntMeasured = at.current === hiddenSize, animateTo = useEvent(function(position2) {
|
|
66
|
+
if (frameSize !== 0) {
|
|
67
|
+
var toValue = isHidden || position2 === -1 ? screenSize : positions[position2];
|
|
68
|
+
if (at.current !== toValue) {
|
|
69
|
+
if (at.current = toValue, stopSpring(), hasntMeasured || isHidden) {
|
|
70
|
+
animatedNumber.setValue(screenSize, {
|
|
71
|
+
type: "timing",
|
|
72
|
+
duration: 0
|
|
73
|
+
}, function() {
|
|
74
|
+
isHidden || (toValue = positions[position2], at.current = toValue, animatedNumber.setValue(toValue, {
|
|
122
75
|
type: "spring",
|
|
123
76
|
...animationConfig
|
|
124
|
-
});
|
|
125
|
-
}
|
|
77
|
+
}));
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
126
80
|
}
|
|
81
|
+
animatedNumber.setValue(toValue, {
|
|
82
|
+
type: "spring",
|
|
83
|
+
...animationConfig
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
useIsomorphicLayoutEffect(function() {
|
|
89
|
+
screenSize && hasntMeasured && animatedNumber.setValue(screenSize, {
|
|
90
|
+
type: "timing",
|
|
91
|
+
duration: 0
|
|
92
|
+
});
|
|
93
|
+
}, [
|
|
94
|
+
hasntMeasured,
|
|
95
|
+
screenSize
|
|
96
|
+
]), useIsomorphicLayoutEffect(function() {
|
|
97
|
+
!frameSize || !screenSize || isHidden || hasntMeasured && !open || animateTo(position);
|
|
98
|
+
}, [
|
|
99
|
+
isHidden,
|
|
100
|
+
frameSize,
|
|
101
|
+
screenSize,
|
|
102
|
+
open,
|
|
103
|
+
position
|
|
104
|
+
]);
|
|
105
|
+
var _props_disableDrag, disableDrag = (_props_disableDrag = props.disableDrag) !== null && _props_disableDrag !== void 0 ? _props_disableDrag : controller?.disableDrag, themeName = useThemeName(), [isDragging, setIsDragging] = React.useState(!1), panResponder = React.useMemo(function() {
|
|
106
|
+
if (disableDrag || !frameSize || isShowingInnerSheet) return;
|
|
107
|
+
var minY = positions[0];
|
|
108
|
+
scrollBridge.paneMinY = minY;
|
|
109
|
+
var startY = at.current;
|
|
110
|
+
function setPanning(val) {
|
|
111
|
+
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 = "");
|
|
112
|
+
}
|
|
113
|
+
var release = function(param) {
|
|
114
|
+
var { vy, dragAt } = param;
|
|
115
|
+
isExternalDrag = !1, previouslyScrolling = !1, setPanning(!1);
|
|
116
|
+
for (var at2 = dragAt + startY, end = at2 + frameSize * vy * 0.2, closestPoint = 0, dist = Number.POSITIVE_INFINITY, i = 0; i < positions.length; i++) {
|
|
117
|
+
var position2 = positions[i], curDist = end > position2 ? end - position2 : position2 - end;
|
|
118
|
+
curDist < dist && (dist = curDist, closestPoint = i);
|
|
119
|
+
}
|
|
120
|
+
setPosition(closestPoint), animateTo(closestPoint);
|
|
121
|
+
}, finish = function(_e, state2) {
|
|
122
|
+
release({
|
|
123
|
+
vy: state2.vy,
|
|
124
|
+
dragAt: state2.dy
|
|
127
125
|
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
}, previouslyScrolling = !1, onMoveShouldSet = function(e, param) {
|
|
127
|
+
var { dy } = param;
|
|
128
|
+
if (e.target === providerProps.handleRef.current)
|
|
129
|
+
return !0;
|
|
130
|
+
var isScrolled = scrollBridge.y !== 0, isDraggingUp = dy < 0, isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
|
|
131
|
+
return isScrolled ? (previouslyScrolling = !0, !1) : isNearTop && !isScrolled && isDraggingUp && !isWeb ? !1 : Math.abs(dy) > 5;
|
|
132
|
+
}, grant = function() {
|
|
133
|
+
setPanning(!0), stopSpring(), startY = at.current;
|
|
134
|
+
}, isExternalDrag = !1;
|
|
135
|
+
return scrollBridge.drag = function(dy) {
|
|
136
|
+
isExternalDrag || (isExternalDrag = !0, grant());
|
|
137
|
+
var to = dy + startY;
|
|
138
|
+
animatedNumber.setValue(resisted(to, minY), {
|
|
139
|
+
type: "direct"
|
|
132
140
|
});
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
}, scrollBridge.release = release, PanResponder.create({
|
|
142
|
+
onMoveShouldSetPanResponder: onMoveShouldSet,
|
|
143
|
+
onPanResponderGrant: grant,
|
|
144
|
+
onPanResponderMove: function(_e, param) {
|
|
145
|
+
var { dy } = param, toFull = dy + startY, to = resisted(toFull, minY);
|
|
146
|
+
animatedNumber.setValue(to, {
|
|
147
|
+
type: "direct"
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
onPanResponderEnd: finish,
|
|
151
|
+
onPanResponderTerminate: finish,
|
|
152
|
+
onPanResponderRelease: finish
|
|
153
|
+
});
|
|
154
|
+
}, [
|
|
155
|
+
disableDrag,
|
|
156
|
+
isShowingInnerSheet,
|
|
157
|
+
animateTo,
|
|
158
|
+
frameSize,
|
|
159
|
+
positions,
|
|
160
|
+
setPosition
|
|
161
|
+
]), handleAnimationViewLayout = React.useCallback(function(e) {
|
|
162
|
+
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);
|
|
163
|
+
next && setFrameSize(next);
|
|
164
|
+
}, []), handleMaxContentViewLayout = React.useCallback(function(e) {
|
|
165
|
+
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);
|
|
166
|
+
next && setMaxContentSize(next);
|
|
167
|
+
}, []), animatedStyle = useAnimatedNumberStyle(animatedNumber, function(val) {
|
|
168
|
+
"worklet";
|
|
169
|
+
var translateY = frameSize === 0 ? hiddenSize : val;
|
|
170
|
+
return {
|
|
171
|
+
transform: [
|
|
172
|
+
{
|
|
173
|
+
translateY
|
|
147
174
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
]
|
|
176
|
+
};
|
|
177
|
+
}), sizeBeforeKeyboard = React.useRef(null);
|
|
178
|
+
React.useEffect(function() {
|
|
179
|
+
if (!(isWeb || !moveOnKeyboardChange)) {
|
|
180
|
+
var keyboardShowListener = Keyboard.addListener(currentPlatform === "ios" ? "keyboardWillShow" : "keyboardDidShow", function(e) {
|
|
181
|
+
sizeBeforeKeyboard.current === null && (sizeBeforeKeyboard.current = isHidden || position === -1 ? screenSize : positions[position], animatedNumber.setValue(Math.max(sizeBeforeKeyboard.current - e.endCoordinates.height, 0), {
|
|
182
|
+
type: "timing",
|
|
183
|
+
duration: 250
|
|
184
|
+
}));
|
|
185
|
+
}), keyboardDidHideListener = Keyboard.addListener("keyboardDidHide", function() {
|
|
186
|
+
sizeBeforeKeyboard.current !== null && (animatedNumber.setValue(sizeBeforeKeyboard.current, {
|
|
187
|
+
type: "timing",
|
|
188
|
+
duration: 250
|
|
189
|
+
}), sizeBeforeKeyboard.current = null);
|
|
190
|
+
});
|
|
191
|
+
return function() {
|
|
192
|
+
keyboardDidHideListener.remove(), keyboardShowListener.remove();
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}, [
|
|
196
|
+
moveOnKeyboardChange,
|
|
197
|
+
positions,
|
|
198
|
+
position,
|
|
199
|
+
isHidden
|
|
200
|
+
]);
|
|
201
|
+
var [opacity, setOpacity] = React.useState(open ? 1 : 0);
|
|
202
|
+
open && opacity === 0 && setOpacity(1), React.useEffect(function() {
|
|
203
|
+
if (!open) {
|
|
204
|
+
var tm = setTimeout(function() {
|
|
205
|
+
setOpacity(0);
|
|
206
|
+
}, 400);
|
|
207
|
+
return function() {
|
|
208
|
+
clearTimeout(tm);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}, [
|
|
212
|
+
open
|
|
213
|
+
]);
|
|
214
|
+
var forcedContentHeight = hasFit ? void 0 : snapPointsMode === "percent" ? `${maxSnapPoint}${isWeb ? "dvh" : "%"}` : maxSnapPoint, contents = /* @__PURE__ */ _jsx(ParentSheetContext.Provider, {
|
|
215
|
+
value: nextParentContext,
|
|
216
|
+
children: /* @__PURE__ */ _jsxs(SheetProvider, {
|
|
217
|
+
...providerProps,
|
|
218
|
+
children: [
|
|
219
|
+
/* @__PURE__ */ _jsx(AnimatePresence, {
|
|
220
|
+
custom: {
|
|
221
|
+
open
|
|
177
222
|
},
|
|
178
|
-
|
|
179
|
-
|
|
223
|
+
children: shouldHideParentSheet || !open ? null : overlayComponent
|
|
224
|
+
}),
|
|
225
|
+
snapPointsMode !== "percent" && /* @__PURE__ */ _jsx(View, {
|
|
226
|
+
style: {
|
|
227
|
+
opacity: 0,
|
|
228
|
+
position: "absolute",
|
|
229
|
+
top: 0,
|
|
230
|
+
left: 0,
|
|
231
|
+
right: 0,
|
|
232
|
+
bottom: 0,
|
|
233
|
+
pointerEvents: "none"
|
|
180
234
|
},
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
onPanResponderGrant: grant,
|
|
191
|
-
onPanResponderMove: function (_e, param) {
|
|
192
|
-
var {
|
|
193
|
-
dy
|
|
194
|
-
} = param,
|
|
195
|
-
toFull = dy + startY,
|
|
196
|
-
to = resisted(toFull, minY);
|
|
197
|
-
animatedNumber.setValue(to, {
|
|
198
|
-
type: "direct"
|
|
199
|
-
});
|
|
235
|
+
onLayout: handleMaxContentViewLayout
|
|
236
|
+
}),
|
|
237
|
+
/* @__PURE__ */ _jsx(AnimatedView, {
|
|
238
|
+
ref,
|
|
239
|
+
...panResponder?.panHandlers,
|
|
240
|
+
onLayout: handleAnimationViewLayout,
|
|
241
|
+
...!isDragging && {
|
|
242
|
+
// @ts-ignore for CSS driver this is necessary to attach the transition
|
|
243
|
+
animation
|
|
200
244
|
},
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}, [disableDrag, isShowingInnerSheet, animateTo, frameSize, positions, setPosition]),
|
|
206
|
-
handleAnimationViewLayout = React.useCallback(function (e) {
|
|
207
|
-
var _e_nativeEvent,
|
|
208
|
-
next = Math.min((_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.layout.height, Dimensions.get(relativeDimensionTo).height);
|
|
209
|
-
next && setFrameSize(next);
|
|
210
|
-
}, []),
|
|
211
|
-
handleMaxContentViewLayout = React.useCallback(function (e) {
|
|
212
|
-
var _e_nativeEvent,
|
|
213
|
-
next = Math.min((_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.layout.height, Dimensions.get(relativeDimensionTo).height);
|
|
214
|
-
next && setMaxContentSize(next);
|
|
215
|
-
}, []),
|
|
216
|
-
animatedStyle = useAnimatedNumberStyle(animatedNumber, function (val) {
|
|
217
|
-
"worklet";
|
|
218
|
-
|
|
219
|
-
var translateY = frameSize === 0 ? hiddenSize : val;
|
|
220
|
-
return {
|
|
221
|
-
transform: [{
|
|
222
|
-
translateY
|
|
223
|
-
}]
|
|
224
|
-
};
|
|
225
|
-
}),
|
|
226
|
-
sizeBeforeKeyboard = React.useRef(null);
|
|
227
|
-
React.useEffect(function () {
|
|
228
|
-
if (!(isWeb || !moveOnKeyboardChange)) {
|
|
229
|
-
var keyboardShowListener = Keyboard.addListener(currentPlatform === "ios" ? "keyboardWillShow" : "keyboardDidShow", function (e) {
|
|
230
|
-
sizeBeforeKeyboard.current === null && (sizeBeforeKeyboard.current = isHidden || position === -1 ? screenSize : positions[position], animatedNumber.setValue(Math.max(sizeBeforeKeyboard.current - e.endCoordinates.height, 0), {
|
|
231
|
-
type: "timing",
|
|
232
|
-
duration: 250
|
|
233
|
-
}));
|
|
234
|
-
}),
|
|
235
|
-
keyboardDidHideListener = Keyboard.addListener("keyboardDidHide", function () {
|
|
236
|
-
sizeBeforeKeyboard.current !== null && (animatedNumber.setValue(sizeBeforeKeyboard.current, {
|
|
237
|
-
type: "timing",
|
|
238
|
-
duration: 250
|
|
239
|
-
}), sizeBeforeKeyboard.current = null);
|
|
240
|
-
});
|
|
241
|
-
return function () {
|
|
242
|
-
keyboardDidHideListener.remove(), keyboardShowListener.remove();
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
}, [moveOnKeyboardChange, positions, position, isHidden]);
|
|
246
|
-
var [opacity, setOpacity] = React.useState(open ? 1 : 0);
|
|
247
|
-
open && opacity === 0 && setOpacity(1), React.useEffect(function () {
|
|
248
|
-
if (!open) {
|
|
249
|
-
var tm = setTimeout(function () {
|
|
250
|
-
setOpacity(0);
|
|
251
|
-
}, 400);
|
|
252
|
-
return function () {
|
|
253
|
-
clearTimeout(tm);
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
}, [open]);
|
|
257
|
-
var forcedContentHeight = hasFit ? void 0 : snapPointsMode === "percent" ? `${maxSnapPoint}${isWeb ? "dvh" : "%"}` : maxSnapPoint,
|
|
258
|
-
contents = /* @__PURE__ */_jsx(ParentSheetContext.Provider, {
|
|
259
|
-
value: nextParentContext,
|
|
260
|
-
children: /* @__PURE__ */_jsxs(SheetProvider, {
|
|
261
|
-
...providerProps,
|
|
262
|
-
children: [/* @__PURE__ */_jsx(AnimatePresence, {
|
|
263
|
-
custom: {
|
|
264
|
-
open
|
|
265
|
-
},
|
|
266
|
-
children: shouldHideParentSheet || !open ? null : overlayComponent
|
|
267
|
-
}), snapPointsMode !== "percent" && /* @__PURE__ */_jsx(View, {
|
|
268
|
-
style: {
|
|
269
|
-
opacity: 0,
|
|
270
|
-
position: "absolute",
|
|
271
|
-
top: 0,
|
|
272
|
-
left: 0,
|
|
273
|
-
right: 0,
|
|
274
|
-
bottom: 0,
|
|
275
|
-
pointerEvents: "none"
|
|
276
|
-
},
|
|
277
|
-
onLayout: handleMaxContentViewLayout
|
|
278
|
-
}), /* @__PURE__ */_jsx(AnimatedView, {
|
|
279
|
-
ref,
|
|
280
|
-
...panResponder?.panHandlers,
|
|
281
|
-
onLayout: handleAnimationViewLayout,
|
|
282
|
-
...(!isDragging && {
|
|
283
|
-
// @ts-ignore for CSS driver this is necessary to attach the transition
|
|
284
|
-
animation
|
|
285
|
-
}),
|
|
286
|
-
// @ts-ignore
|
|
287
|
-
disableClassName: !0,
|
|
288
|
-
style: [{
|
|
245
|
+
// @ts-ignore
|
|
246
|
+
disableClassName: !0,
|
|
247
|
+
style: [
|
|
248
|
+
{
|
|
289
249
|
position: "absolute",
|
|
290
250
|
zIndex,
|
|
291
251
|
width: "100%",
|
|
292
252
|
height: forcedContentHeight,
|
|
293
253
|
minHeight: forcedContentHeight,
|
|
294
254
|
opacity,
|
|
295
|
-
...(
|
|
255
|
+
...(shouldHideParentSheet || !open) && {
|
|
296
256
|
pointerEvents: "none"
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
animatedStyle
|
|
260
|
+
],
|
|
261
|
+
children: props.children
|
|
301
262
|
})
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
})
|
|
263
|
+
]
|
|
264
|
+
})
|
|
265
|
+
}), adaptContext = React.useContext(AdaptParentContext), shouldMountChildren = !!(opacity || !unmountChildrenWhenHidden);
|
|
266
|
+
if (modal) {
|
|
267
|
+
var modalContents = /* @__PURE__ */ _jsx(Portal, {
|
|
268
|
+
zIndex,
|
|
269
|
+
...portalProps,
|
|
270
|
+
children: shouldMountChildren && /* @__PURE__ */ _jsx(ContainerComponent, {
|
|
271
|
+
children: /* @__PURE__ */ _jsx(Theme, {
|
|
272
|
+
forceClassName: !0,
|
|
273
|
+
name: themeName,
|
|
274
|
+
children: /* @__PURE__ */ _jsx(AdaptParentContext.Provider, {
|
|
275
|
+
value: adaptContext,
|
|
276
|
+
children: contents
|
|
317
277
|
})
|
|
318
278
|
})
|
|
319
|
-
})
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
279
|
+
})
|
|
280
|
+
});
|
|
281
|
+
return isWeb ? modalContents : /* @__PURE__ */ _jsx(SheetInsideSheetContext.Provider, {
|
|
282
|
+
value: onInnerSheet,
|
|
283
|
+
children: modalContents
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
return contents;
|
|
287
|
+
});
|
|
327
288
|
function getYPositions(mode, point, screenSize, frameSize) {
|
|
328
289
|
if (!screenSize || !frameSize) return 0;
|
|
329
290
|
if (mode === "mixed") {
|
|
330
|
-
if (typeof point == "number")
|
|
331
|
-
|
|
291
|
+
if (typeof point == "number")
|
|
292
|
+
return screenSize - Math.min(screenSize, Math.max(0, point));
|
|
293
|
+
if (point === "fit")
|
|
294
|
+
return screenSize - Math.min(screenSize, frameSize);
|
|
332
295
|
if (point.endsWith("%")) {
|
|
333
296
|
var pct = Math.min(100, Math.max(0, Number(point.slice(0, -1)))) / 100;
|
|
334
|
-
if (Number.isNaN(pct))
|
|
297
|
+
if (Number.isNaN(pct))
|
|
298
|
+
return console.warn("Invalid snapPoint percentage string"), 0;
|
|
335
299
|
var next = Math.round(screenSize - pct * screenSize);
|
|
336
300
|
return next;
|
|
337
301
|
}
|
|
338
302
|
return console.warn("Invalid snapPoint unknown value"), 0;
|
|
339
303
|
}
|
|
340
|
-
if (mode === "fit")
|
|
341
|
-
|
|
304
|
+
if (mode === "fit")
|
|
305
|
+
return point === 0 ? screenSize : screenSize - Math.min(screenSize, frameSize);
|
|
306
|
+
if (mode === "constant" && typeof point == "number")
|
|
307
|
+
return screenSize - Math.min(screenSize, Math.max(0, point));
|
|
342
308
|
var pct1 = Math.min(100, Math.max(0, Number(point))) / 100;
|
|
343
309
|
return Number.isNaN(pct1) ? (console.warn("Invalid snapPoint percentage"), 0) : Math.round(screenSize - pct1 * screenSize);
|
|
344
310
|
}
|
|
345
|
-
export {
|
|
346
|
-
|
|
311
|
+
export {
|
|
312
|
+
SheetImplementationCustom
|
|
313
|
+
};
|
|
314
|
+
//# sourceMappingURL=SheetImplementationCustom.js.map
|