@tamagui/sheet 1.125.6 → 1.125.7

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