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