@tamagui/sheet 1.111.8 → 1.111.9

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