@tamagui/sheet 1.113.1 → 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.
Files changed (35) hide show
  1. package/dist/esm/Sheet.native.js +82 -79
  2. package/dist/esm/Sheet.native.js.map +6 -1
  3. package/dist/esm/SheetContext.native.js +9 -5
  4. package/dist/esm/SheetContext.native.js.map +6 -1
  5. package/dist/esm/SheetController.native.js +20 -19
  6. package/dist/esm/SheetController.native.js.map +6 -1
  7. package/dist/esm/SheetImplementationCustom.native.js +271 -303
  8. package/dist/esm/SheetImplementationCustom.native.js.map +6 -1
  9. package/dist/esm/SheetScrollView.native.js +89 -102
  10. package/dist/esm/SheetScrollView.native.js.map +6 -1
  11. package/dist/esm/constants.native.js +8 -6
  12. package/dist/esm/constants.native.js.map +6 -1
  13. package/dist/esm/contexts.native.js +7 -5
  14. package/dist/esm/contexts.native.js.map +6 -1
  15. package/dist/esm/createSheet.native.js +96 -120
  16. package/dist/esm/createSheet.native.js.map +6 -1
  17. package/dist/esm/helpers.native.js +5 -6
  18. package/dist/esm/helpers.native.js.map +6 -1
  19. package/dist/esm/index.native.js +12 -12
  20. package/dist/esm/index.native.js.map +6 -1
  21. package/dist/esm/nativeSheet.native.js +36 -34
  22. package/dist/esm/nativeSheet.native.js.map +6 -1
  23. package/dist/esm/types.native.js +1 -2
  24. package/dist/esm/types.native.js.map +6 -1
  25. package/dist/esm/useSheet.native.js +6 -4
  26. package/dist/esm/useSheet.native.js.map +6 -1
  27. package/dist/esm/useSheetController.native.js +14 -14
  28. package/dist/esm/useSheetController.native.js.map +6 -1
  29. package/dist/esm/useSheetOffscreenSize.native.js +13 -26
  30. package/dist/esm/useSheetOffscreenSize.native.js.map +6 -1
  31. package/dist/esm/useSheetOpenState.native.js +16 -21
  32. package/dist/esm/useSheetOpenState.native.js.map +6 -1
  33. package/dist/esm/useSheetProviderProps.native.js +83 -82
  34. package/dist/esm/useSheetProviderProps.native.js.map +6 -1
  35. 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.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),
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
- }, [parentSheetContext, open]);
88
- var nextParentContext = React.useMemo(function () {
89
- return {
90
- zIndex
91
- };
92
- }, [zIndex]),
93
- animatedNumber = useAnimatedNumber(hiddenSize),
94
- at = React.useRef(hiddenSize);
95
- useAnimatedNumberReaction({
96
- value: animatedNumber,
97
- hostRef: sheetRef
98
- }, React.useCallback(function (value) {
99
- at.current = value, scrollBridge.paneY = value;
100
- }, [animationDriver]));
101
- function stopSpring() {
102
- animatedNumber.stop(), scrollBridge.onFinishAnimate && (scrollBridge.onFinishAnimate(), scrollBridge.onFinishAnimate = void 0);
103
- }
104
- var hasntMeasured = at.current === hiddenSize,
105
- animateTo = useEvent(function (position2) {
106
- if (frameSize !== 0) {
107
- var toValue = isHidden || position2 === -1 ? screenSize : positions[position2];
108
- if (at.current !== toValue) {
109
- if (at.current = toValue, stopSpring(), hasntMeasured || isHidden) {
110
- animatedNumber.setValue(screenSize, {
111
- type: "timing",
112
- duration: 0
113
- }, function () {
114
- isHidden || (toValue = positions[position2], at.current = toValue, animatedNumber.setValue(toValue, {
115
- type: "spring",
116
- ...animationConfig
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
- useIsomorphicLayoutEffect(function () {
129
- screenSize && hasntMeasured && animatedNumber.setValue(screenSize, {
130
- type: "timing",
131
- duration: 0
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
- }, [hasntMeasured, screenSize]), useIsomorphicLayoutEffect(function () {
134
- !frameSize || !screenSize || isHidden || hasntMeasured && !open || animateTo(position);
135
- }, [isHidden, frameSize, screenSize, open, position]);
136
- var _props_disableDrag,
137
- disableDrag = (_props_disableDrag = props.disableDrag) !== null && _props_disableDrag !== void 0 ? _props_disableDrag : controller?.disableDrag,
138
- themeName = useThemeName(),
139
- [isDragging, setIsDragging] = React.useState(!1),
140
- panResponder = React.useMemo(function () {
141
- if (disableDrag || !frameSize || isShowingInnerSheet) return;
142
- var minY = positions[0];
143
- scrollBridge.paneMinY = minY;
144
- var startY = at.current;
145
- function setPanning(val) {
146
- 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 = "");
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
- var release = function (param) {
149
- var {
150
- vy,
151
- dragAt
152
- } = param;
153
- isExternalDrag = !1, previouslyScrolling = !1, setPanning(!1);
154
- for (var at2 = dragAt + startY, end = at2 + frameSize * vy * 0.2, closestPoint = 0, dist = Number.POSITIVE_INFINITY, i = 0; i < positions.length; i++) {
155
- var position2 = positions[i],
156
- curDist = end > position2 ? end - position2 : position2 - end;
157
- curDist < dist && (dist = curDist, closestPoint = i);
158
- }
159
- setPosition(closestPoint), animateTo(closestPoint);
160
- },
161
- finish = function (_e, state2) {
162
- release({
163
- vy: state2.vy,
164
- dragAt: state2.dy
165
- });
166
- },
167
- previouslyScrolling = !1,
168
- onMoveShouldSet = function (e, param) {
169
- var {
170
- dy
171
- } = param;
172
- if (e.target === providerProps.handleRef.current) return !0;
173
- var isScrolled = scrollBridge.y !== 0,
174
- isDraggingUp = dy < 0,
175
- isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
176
- return isScrolled ? (previouslyScrolling = !0, !1) : isNearTop && !isScrolled && isDraggingUp && !isWeb ? !1 : Math.abs(dy) > 5;
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
- grant = function () {
179
- setPanning(!0), stopSpring(), startY = at.current;
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
- isExternalDrag = !1;
182
- return scrollBridge.drag = function (dy) {
183
- isExternalDrag || (isExternalDrag = !0, grant());
184
- var to = dy + startY;
185
- animatedNumber.setValue(resisted(to, minY), {
186
- type: "direct"
187
- });
188
- }, scrollBridge.release = release, PanResponder.create({
189
- onMoveShouldSetPanResponder: onMoveShouldSet,
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
- onPanResponderEnd: finish,
202
- onPanResponderTerminate: finish,
203
- onPanResponderRelease: finish
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
- ...((shouldHideParentSheet || !open) && {
255
+ ...(shouldHideParentSheet || !open) && {
296
256
  pointerEvents: "none"
297
- })
298
- }, animatedStyle],
299
- children: props.children
300
- })]
257
+ }
258
+ },
259
+ animatedStyle
260
+ ],
261
+ children: props.children
301
262
  })
302
- }),
303
- adaptContext = React.useContext(AdaptParentContext),
304
- shouldMountChildren = !!(opacity || !unmountChildrenWhenHidden);
305
- if (modal) {
306
- var modalContents = /* @__PURE__ */_jsx(Portal, {
307
- zIndex,
308
- ...portalProps,
309
- children: shouldMountChildren && /* @__PURE__ */_jsx(ContainerComponent, {
310
- children: /* @__PURE__ */_jsx(Theme, {
311
- forceClassName: !0,
312
- name: themeName,
313
- children: /* @__PURE__ */_jsx(AdaptParentContext.Provider, {
314
- value: adaptContext,
315
- children: contents
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
- return isWeb ? modalContents : /* @__PURE__ */_jsx(SheetInsideSheetContext.Provider, {
321
- value: onInnerSheet,
322
- children: modalContents
323
- });
324
- }
325
- return contents;
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") return screenSize - Math.min(screenSize, Math.max(0, point));
331
- if (point === "fit") return screenSize - Math.min(screenSize, frameSize);
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)) return console.warn("Invalid snapPoint percentage string"), 0;
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") return point === 0 ? screenSize : screenSize - Math.min(screenSize, frameSize);
341
- if (mode === "constant" && typeof point == "number") return screenSize - Math.min(screenSize, Math.max(0, point));
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 { SheetImplementationCustom };
346
- //# sourceMappingURL=SheetImplementationCustom.native.js.map
311
+ export {
312
+ SheetImplementationCustom
313
+ };
314
+ //# sourceMappingURL=SheetImplementationCustom.js.map