@tamagui/sheet 1.135.4-1761748186554 → 1.135.4
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/Sheet.native.js +90 -96
- package/dist/cjs/Sheet.native.js.map +6 -1
- package/dist/cjs/SheetContext.native.js +18 -21
- package/dist/cjs/SheetContext.native.js.map +6 -1
- package/dist/cjs/SheetController.cjs +1 -1
- package/dist/cjs/SheetController.js +1 -1
- package/dist/cjs/SheetController.js.map +1 -1
- package/dist/cjs/SheetController.native.js +38 -51
- package/dist/cjs/SheetController.native.js.map +6 -1
- package/dist/cjs/SheetImplementationCustom.cjs +1 -1
- package/dist/cjs/SheetImplementationCustom.js +1 -1
- package/dist/cjs/SheetImplementationCustom.js.map +1 -1
- package/dist/cjs/SheetImplementationCustom.native.js +312 -362
- package/dist/cjs/SheetImplementationCustom.native.js.map +6 -1
- package/dist/cjs/SheetScrollView.cjs +1 -1
- package/dist/cjs/SheetScrollView.js +1 -1
- package/dist/cjs/SheetScrollView.js.map +1 -1
- package/dist/cjs/SheetScrollView.native.js +107 -137
- package/dist/cjs/SheetScrollView.native.js.map +6 -1
- package/dist/cjs/constants.native.js +18 -21
- package/dist/cjs/constants.native.js.map +6 -1
- package/dist/cjs/contexts.cjs +1 -1
- package/dist/cjs/contexts.js +1 -1
- package/dist/cjs/contexts.native.js +21 -28
- package/dist/cjs/contexts.native.js.map +6 -1
- package/dist/cjs/createSheet.native.js +101 -148
- package/dist/cjs/createSheet.native.js.map +6 -1
- package/dist/cjs/helpers.native.js +17 -20
- package/dist/cjs/helpers.native.js.map +6 -1
- package/dist/cjs/index.native.js +32 -23
- package/dist/cjs/index.native.js.map +6 -1
- package/dist/cjs/nativeSheet.native.js +53 -65
- package/dist/cjs/nativeSheet.native.js.map +6 -1
- package/dist/cjs/types.native.js +5 -9
- package/dist/cjs/types.native.js.map +6 -1
- package/dist/cjs/useSheet.native.js +17 -21
- package/dist/cjs/useSheet.native.js.map +6 -1
- package/dist/cjs/useSheetController.cjs +1 -1
- package/dist/cjs/useSheetController.js +1 -1
- package/dist/cjs/useSheetController.native.js +27 -36
- package/dist/cjs/useSheetController.native.js.map +6 -1
- package/dist/cjs/useSheetOffscreenSize.native.js +23 -41
- package/dist/cjs/useSheetOffscreenSize.native.js.map +6 -1
- package/dist/cjs/useSheetOpenState.native.js +30 -44
- package/dist/cjs/useSheetOpenState.native.js.map +6 -1
- package/dist/cjs/useSheetProviderProps.cjs +1 -1
- package/dist/cjs/useSheetProviderProps.js +1 -1
- package/dist/cjs/useSheetProviderProps.js.map +1 -1
- package/dist/cjs/useSheetProviderProps.native.js +108 -119
- package/dist/cjs/useSheetProviderProps.native.js.map +6 -1
- package/dist/jsx/Sheet.native.js +84 -114
- package/dist/jsx/Sheet.native.js.map +6 -1
- package/dist/jsx/SheetContext.native.js +10 -35
- package/dist/jsx/SheetContext.native.js.map +6 -1
- package/dist/jsx/SheetController.native.js +29 -67
- package/dist/jsx/SheetController.native.js.map +6 -1
- package/dist/jsx/SheetImplementationCustom.native.js +312 -377
- package/dist/jsx/SheetImplementationCustom.native.js.map +6 -1
- package/dist/jsx/SheetScrollView.native.js +104 -156
- package/dist/jsx/SheetScrollView.native.js.map +6 -1
- package/dist/jsx/constants.native.js +8 -35
- package/dist/jsx/constants.native.js.map +6 -1
- package/dist/jsx/contexts.native.js +9 -45
- package/dist/jsx/contexts.native.js.map +6 -1
- package/dist/jsx/createSheet.native.js +109 -160
- package/dist/jsx/createSheet.native.js.map +6 -1
- package/dist/jsx/helpers.native.js +7 -31
- package/dist/jsx/helpers.native.js.map +6 -1
- package/dist/jsx/index.native.js +12 -31
- package/dist/jsx/index.native.js.map +6 -1
- package/dist/jsx/nativeSheet.native.js +50 -77
- package/dist/jsx/nativeSheet.native.js.map +6 -1
- package/dist/jsx/types.native.js +1 -19
- package/dist/jsx/types.native.js.map +6 -1
- package/dist/jsx/useSheet.native.js +8 -32
- package/dist/jsx/useSheet.native.js.map +6 -1
- package/dist/jsx/useSheetController.native.js +14 -52
- package/dist/jsx/useSheetController.native.js.map +6 -1
- package/dist/jsx/useSheetOffscreenSize.native.js +13 -52
- package/dist/jsx/useSheetOffscreenSize.native.js.map +6 -1
- package/dist/jsx/useSheetOpenState.native.js +22 -55
- package/dist/jsx/useSheetOpenState.native.js.map +6 -1
- package/dist/jsx/useSheetProviderProps.native.js +98 -135
- package/dist/jsx/useSheetProviderProps.native.js.map +6 -1
- package/package.json +19 -20
- package/types/SheetContext.d.ts.map +1 -1
|
@@ -1,407 +1,357 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
7
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
-
});
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
22
16
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
17
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
18
|
// file that has been converted to a CommonJS file using a Babel-
|
|
25
19
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
20
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}) : target, mod)),
|
|
31
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: !0
|
|
33
|
-
}), mod);
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
+
mod
|
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
34
24
|
var SheetImplementationCustom_exports = {};
|
|
35
25
|
__export(SheetImplementationCustom_exports, {
|
|
36
26
|
SheetImplementationCustom: () => SheetImplementationCustom
|
|
37
27
|
});
|
|
38
28
|
module.exports = __toCommonJS(SheetImplementationCustom_exports);
|
|
39
|
-
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
import_compose_refs =
|
|
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
|
-
onOverlayComponent: setOverlayComponent
|
|
72
|
-
}),
|
|
73
|
-
{
|
|
74
|
-
frameSize,
|
|
75
|
-
setFrameSize,
|
|
76
|
-
snapPoints,
|
|
77
|
-
snapPointsMode,
|
|
78
|
-
hasFit,
|
|
79
|
-
position,
|
|
80
|
-
setPosition,
|
|
81
|
-
scrollBridge,
|
|
82
|
-
screenSize,
|
|
83
|
-
setMaxContentSize,
|
|
84
|
-
maxSnapPoint
|
|
85
|
-
} = providerProps,
|
|
86
|
-
{
|
|
87
|
-
open,
|
|
88
|
-
controller,
|
|
89
|
-
isHidden
|
|
90
|
-
} = state,
|
|
91
|
-
sheetRef = import_react.default.useRef(void 0),
|
|
92
|
-
ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, sheetRef, providerProps.contentRef),
|
|
93
|
-
{
|
|
94
|
-
animationDriver
|
|
95
|
-
} = (0, import_core.useConfiguration)();
|
|
96
|
-
if (!animationDriver) throw new Error("Sheet reqiures an animation driver to be set");
|
|
97
|
-
var animationConfig = function () {
|
|
98
|
-
if (animationDriver.supportsCSS) return {};
|
|
99
|
-
var [animationProp, animationPropConfig] = animation ? Array.isArray(animation) ? animation : [animation] : [];
|
|
100
|
-
return animationConfigProp ?? (animationProp ? {
|
|
101
|
-
...animationDriver.animations[animationProp],
|
|
102
|
-
...animationPropConfig
|
|
103
|
-
} : null);
|
|
104
|
-
}(),
|
|
105
|
-
[isShowingInnerSheet, setIsShowingInnerSheet] = import_react.default.useState(!1),
|
|
106
|
-
shouldHideParentSheet = !import_constants.isWeb && modal && isShowingInnerSheet &&
|
|
107
|
-
// if not using weird portal limitation we dont need to hide parent sheet
|
|
108
|
-
import_portal.USE_NATIVE_PORTAL,
|
|
109
|
-
sheetInsideSheet = import_react.default.useContext(import_contexts.SheetInsideSheetContext),
|
|
110
|
-
onInnerSheet = import_react.default.useCallback(function (hasChild) {
|
|
111
|
-
setIsShowingInnerSheet(hasChild);
|
|
112
|
-
}, []),
|
|
113
|
-
positions = import_react.default.useMemo(function () {
|
|
114
|
-
return snapPoints.map(function (point) {
|
|
115
|
-
return getYPositions(snapPointsMode, point, screenSize, frameSize);
|
|
116
|
-
});
|
|
117
|
-
}, [screenSize, frameSize, snapPoints, snapPointsMode]),
|
|
118
|
-
{
|
|
119
|
-
useAnimatedNumber,
|
|
120
|
-
useAnimatedNumberStyle,
|
|
121
|
-
useAnimatedNumberReaction
|
|
122
|
-
} = animationDriver,
|
|
123
|
-
_animationDriver_View,
|
|
124
|
-
AnimatedView = (_animationDriver_View = animationDriver.View) !== null && _animationDriver_View !== void 0 ? _animationDriver_View : import_core.Stack;
|
|
125
|
-
(0, import_constants.useIsomorphicLayoutEffect)(function () {
|
|
126
|
-
if (sheetInsideSheet && open) return sheetInsideSheet(!0), function () {
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime"), import_adapt = require("@tamagui/adapt"), import_animate_presence = require("@tamagui/animate-presence"), import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_portal = require("@tamagui/portal"), import_react = __toESM(require("react")), import_react_native = require("react-native"), import_contexts = require("./contexts"), import_helpers = require("./helpers"), import_SheetContext = require("./SheetContext"), import_useSheetOpenState = require("./useSheetOpenState"), import_useSheetProviderProps = require("./useSheetProviderProps"), hiddenSize = 10000.1, sheetHiddenStyleSheet = null, relativeDimensionTo = import_constants.isWeb ? "window" : "screen", SheetImplementationCustom = /* @__PURE__ */ import_react.default.forwardRef(function(props, forwardedRef) {
|
|
30
|
+
var parentSheet = import_react.default.useContext(import_contexts.ParentSheetContext), { animation, animationConfig: animationConfigProp, modal = !1, zIndex = parentSheet.zIndex + 1, moveOnKeyboardChange = !1, unmountChildrenWhenHidden = !1, portalProps, containerComponent: ContainerComponent = import_react.default.Fragment } = props, state = (0, import_useSheetOpenState.useSheetOpenState)(props), [overlayComponent, setOverlayComponent] = import_react.default.useState(null), providerProps = (0, import_useSheetProviderProps.useSheetProviderProps)(props, state, {
|
|
31
|
+
onOverlayComponent: setOverlayComponent
|
|
32
|
+
}), { frameSize, setFrameSize, snapPoints, snapPointsMode, hasFit, position, setPosition, scrollBridge, screenSize, setMaxContentSize, maxSnapPoint } = providerProps, { open, controller, isHidden } = state, sheetRef = import_react.default.useRef(void 0), ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, sheetRef, providerProps.contentRef), { animationDriver } = (0, import_core.useConfiguration)();
|
|
33
|
+
if (!animationDriver)
|
|
34
|
+
throw new Error("Sheet reqiures an animation driver to be set");
|
|
35
|
+
var animationConfig = function() {
|
|
36
|
+
if (animationDriver.supportsCSS)
|
|
37
|
+
return {};
|
|
38
|
+
var [animationProp, animationPropConfig] = animation ? Array.isArray(animation) ? animation : [
|
|
39
|
+
animation
|
|
40
|
+
] : [];
|
|
41
|
+
return animationConfigProp ?? (animationProp ? {
|
|
42
|
+
...animationDriver.animations[animationProp],
|
|
43
|
+
...animationPropConfig
|
|
44
|
+
} : null);
|
|
45
|
+
}(), [isShowingInnerSheet, setIsShowingInnerSheet] = import_react.default.useState(!1), shouldHideParentSheet = !import_constants.isWeb && modal && isShowingInnerSheet && // if not using weird portal limitation we dont need to hide parent sheet
|
|
46
|
+
import_portal.USE_NATIVE_PORTAL, sheetInsideSheet = import_react.default.useContext(import_contexts.SheetInsideSheetContext), onInnerSheet = import_react.default.useCallback(function(hasChild) {
|
|
47
|
+
setIsShowingInnerSheet(hasChild);
|
|
48
|
+
}, []), positions = import_react.default.useMemo(function() {
|
|
49
|
+
return snapPoints.map(function(point) {
|
|
50
|
+
return getYPositions(snapPointsMode, point, screenSize, frameSize);
|
|
51
|
+
});
|
|
52
|
+
}, [
|
|
53
|
+
screenSize,
|
|
54
|
+
frameSize,
|
|
55
|
+
snapPoints,
|
|
56
|
+
snapPointsMode
|
|
57
|
+
]), { useAnimatedNumber, useAnimatedNumberStyle, useAnimatedNumberReaction } = animationDriver, _animationDriver_View, AnimatedView = (_animationDriver_View = animationDriver.View) !== null && _animationDriver_View !== void 0 ? _animationDriver_View : import_core.Stack;
|
|
58
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
59
|
+
if (sheetInsideSheet && open)
|
|
60
|
+
return sheetInsideSheet(!0), function() {
|
|
127
61
|
sheetInsideSheet(!1);
|
|
128
62
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
63
|
+
}, [
|
|
64
|
+
sheetInsideSheet,
|
|
65
|
+
open
|
|
66
|
+
]);
|
|
67
|
+
var nextParentContext = import_react.default.useMemo(function() {
|
|
68
|
+
return {
|
|
69
|
+
zIndex
|
|
70
|
+
};
|
|
71
|
+
}, [
|
|
72
|
+
zIndex
|
|
73
|
+
]), isMounted = (0, import_core.useDidFinishSSR)(), startPosition = isMounted && screenSize ? screenSize : hiddenSize, animatedNumber = useAnimatedNumber(startPosition), at = import_react.default.useRef(startPosition), hasntMeasured = at.current === hiddenSize, [disableAnimation, setDisableAnimation] = (0, import_react.useState)(hasntMeasured), hasScrollView = import_react.default.useRef(!1);
|
|
74
|
+
useAnimatedNumberReaction({
|
|
75
|
+
value: animatedNumber,
|
|
76
|
+
hostRef: sheetRef
|
|
77
|
+
}, import_react.default.useCallback(function(value) {
|
|
78
|
+
at.current = value, scrollBridge.paneY = value;
|
|
79
|
+
}, [
|
|
80
|
+
animationDriver
|
|
81
|
+
]));
|
|
82
|
+
function stopSpring() {
|
|
83
|
+
animatedNumber.stop(), scrollBridge.onFinishAnimate && (scrollBridge.onFinishAnimate(), scrollBridge.onFinishAnimate = void 0);
|
|
84
|
+
}
|
|
85
|
+
var animateTo = (0, import_core.useEvent)(function(position2) {
|
|
86
|
+
if (frameSize !== 0) {
|
|
87
|
+
var toValue = isHidden || position2 === -1 ? screenSize : positions[position2];
|
|
88
|
+
at.current !== toValue && (at.current = toValue, stopSpring(), animatedNumber.setValue(toValue, {
|
|
89
|
+
type: "spring",
|
|
90
|
+
...animationConfig
|
|
91
|
+
}));
|
|
150
92
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
93
|
+
});
|
|
94
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
95
|
+
if (hasntMeasured && screenSize && frameSize) {
|
|
96
|
+
at.current = screenSize, animatedNumber.setValue(screenSize, {
|
|
97
|
+
type: "timing",
|
|
98
|
+
duration: 0
|
|
99
|
+
}, function() {
|
|
100
|
+
setTimeout(function() {
|
|
101
|
+
setDisableAnimation(!1);
|
|
102
|
+
}, 10);
|
|
103
|
+
});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
disableAnimation || !frameSize || !screenSize || isHidden || hasntMeasured && !open || (animateTo(position), position === -1 && (scrollBridge.scrollLock = !1, scrollBridge.scrollStartY = -1));
|
|
107
|
+
}, [
|
|
108
|
+
hasntMeasured,
|
|
109
|
+
disableAnimation,
|
|
110
|
+
isHidden,
|
|
111
|
+
frameSize,
|
|
112
|
+
screenSize,
|
|
113
|
+
open,
|
|
114
|
+
position
|
|
115
|
+
]);
|
|
116
|
+
var _props_disableDrag, disableDrag = (_props_disableDrag = props.disableDrag) !== null && _props_disableDrag !== void 0 ? _props_disableDrag : controller == null ? void 0 : controller.disableDrag, themeName = (0, import_core.useThemeName)(), [isDragging, setIsDragging] = import_react.default.useState(!1), panResponder = import_react.default.useMemo(function() {
|
|
117
|
+
if (disableDrag || !frameSize || isShowingInnerSheet) return;
|
|
118
|
+
var minY = positions[0];
|
|
119
|
+
scrollBridge.paneMinY = minY;
|
|
120
|
+
var startY = at.current;
|
|
121
|
+
function setPanning(val) {
|
|
122
|
+
setIsDragging(val), import_constants.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 = "");
|
|
123
|
+
}
|
|
124
|
+
var release = function(param) {
|
|
125
|
+
var { vy, dragAt } = param;
|
|
126
|
+
if (scrollBridge.setParentDragging(!1), !scrollBridge.scrollLock) {
|
|
127
|
+
isExternalDrag = !1, previouslyScrolling = !1, setPanning(!1);
|
|
128
|
+
for (var at2 = dragAt + startY, end = at2 + frameSize * vy * 0.2, closestPoint = 0, dist = Number.POSITIVE_INFINITY, i = 0; i < positions.length; i++) {
|
|
129
|
+
var position2 = positions[i], curDist = end > position2 ? end - position2 : position2 - end;
|
|
130
|
+
curDist < dist && (dist = curDist, closestPoint = i);
|
|
131
|
+
}
|
|
132
|
+
setPosition(closestPoint), animateTo(closestPoint);
|
|
171
133
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
134
|
+
}, finish = function(_e, state2) {
|
|
135
|
+
release({
|
|
136
|
+
vy: state2.vy,
|
|
137
|
+
dragAt: state2.dy
|
|
138
|
+
});
|
|
139
|
+
}, previouslyScrolling = !1, onMoveShouldSet = function(e, param) {
|
|
140
|
+
var { dy } = param;
|
|
141
|
+
function getShouldSet() {
|
|
142
|
+
if (e.target === providerProps.handleRef.current)
|
|
143
|
+
return !0;
|
|
144
|
+
if (scrollBridge.hasScrollableContent === !0) {
|
|
145
|
+
if (scrollBridge.scrollLock)
|
|
146
|
+
return !1;
|
|
147
|
+
var isScrolled = scrollBridge.y !== 0, isDraggingUp = dy < 0, isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
|
|
148
|
+
if (isScrolled)
|
|
149
|
+
return previouslyScrolling = !0, !1;
|
|
150
|
+
if (isNearTop && hasScrollView.current && isDraggingUp)
|
|
151
|
+
return !1;
|
|
185
152
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
},
|
|
207
|
-
previouslyScrolling = !1,
|
|
208
|
-
onMoveShouldSet = function (e, param) {
|
|
209
|
-
var {
|
|
210
|
-
dy
|
|
211
|
-
} = param;
|
|
212
|
-
function getShouldSet() {
|
|
213
|
-
if (e.target === providerProps.handleRef.current) return !0;
|
|
214
|
-
if (scrollBridge.hasScrollableContent === !0) {
|
|
215
|
-
if (scrollBridge.scrollLock) return !1;
|
|
216
|
-
var isScrolled = scrollBridge.y !== 0,
|
|
217
|
-
isDraggingUp = dy < 0,
|
|
218
|
-
isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
|
|
219
|
-
if (isScrolled) return previouslyScrolling = !0, !1;
|
|
220
|
-
if (isNearTop && hasScrollView.current && isDraggingUp) return !1;
|
|
221
|
-
}
|
|
222
|
-
return Math.abs(dy) > 10;
|
|
223
|
-
}
|
|
224
|
-
var granted = getShouldSet();
|
|
225
|
-
return granted && scrollBridge.setParentDragging(!0), granted;
|
|
226
|
-
},
|
|
227
|
-
grant = function () {
|
|
228
|
-
setPanning(!0), stopSpring(), startY = at.current;
|
|
229
|
-
},
|
|
230
|
-
isExternalDrag = !1;
|
|
231
|
-
return scrollBridge.drag = function (dy) {
|
|
232
|
-
isExternalDrag || (isExternalDrag = !0, grant());
|
|
233
|
-
var to = dy + startY;
|
|
234
|
-
animatedNumber.setValue((0, import_helpers.resisted)(to, minY), {
|
|
235
|
-
type: "direct"
|
|
236
|
-
});
|
|
237
|
-
}, scrollBridge.release = release, import_react_native.PanResponder.create({
|
|
238
|
-
onMoveShouldSetPanResponder: onMoveShouldSet,
|
|
239
|
-
onPanResponderGrant: grant,
|
|
240
|
-
onPanResponderMove: function (_e, param) {
|
|
241
|
-
var {
|
|
242
|
-
dy
|
|
243
|
-
} = param,
|
|
244
|
-
toFull = dy + startY,
|
|
245
|
-
to = (0, import_helpers.resisted)(toFull, minY),
|
|
246
|
-
isAtTop = to <= minY;
|
|
247
|
-
isAtTop ? scrollBridge.setParentDragging(!1) : scrollBridge.setParentDragging(!0), animatedNumber.setValue(to, {
|
|
248
|
-
type: "direct"
|
|
249
|
-
});
|
|
250
|
-
},
|
|
251
|
-
onPanResponderEnd: finish,
|
|
252
|
-
onPanResponderTerminate: finish,
|
|
253
|
-
onPanResponderRelease: finish
|
|
153
|
+
return Math.abs(dy) > 10;
|
|
154
|
+
}
|
|
155
|
+
var granted = getShouldSet();
|
|
156
|
+
return granted && scrollBridge.setParentDragging(!0), granted;
|
|
157
|
+
}, grant = function() {
|
|
158
|
+
setPanning(!0), stopSpring(), startY = at.current;
|
|
159
|
+
}, isExternalDrag = !1;
|
|
160
|
+
return scrollBridge.drag = function(dy) {
|
|
161
|
+
isExternalDrag || (isExternalDrag = !0, grant());
|
|
162
|
+
var to = dy + startY;
|
|
163
|
+
animatedNumber.setValue((0, import_helpers.resisted)(to, minY), {
|
|
164
|
+
type: "direct"
|
|
165
|
+
});
|
|
166
|
+
}, scrollBridge.release = release, import_react_native.PanResponder.create({
|
|
167
|
+
onMoveShouldSetPanResponder: onMoveShouldSet,
|
|
168
|
+
onPanResponderGrant: grant,
|
|
169
|
+
onPanResponderMove: function(_e, param) {
|
|
170
|
+
var { dy } = param, toFull = dy + startY, to = (0, import_helpers.resisted)(toFull, minY), isAtTop = to <= minY;
|
|
171
|
+
isAtTop ? scrollBridge.setParentDragging(!1) : scrollBridge.setParentDragging(!0), animatedNumber.setValue(to, {
|
|
172
|
+
type: "direct"
|
|
254
173
|
});
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
174
|
+
},
|
|
175
|
+
onPanResponderEnd: finish,
|
|
176
|
+
onPanResponderTerminate: finish,
|
|
177
|
+
onPanResponderRelease: finish
|
|
178
|
+
});
|
|
179
|
+
}, [
|
|
180
|
+
disableDrag,
|
|
181
|
+
isShowingInnerSheet,
|
|
182
|
+
animateTo,
|
|
183
|
+
frameSize,
|
|
184
|
+
positions,
|
|
185
|
+
setPosition
|
|
186
|
+
]), handleAnimationViewLayout = import_react.default.useCallback(function(e) {
|
|
187
|
+
var _e_nativeEvent, next = Math.min((_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.layout.height, import_react_native.Dimensions.get(relativeDimensionTo).height);
|
|
188
|
+
next && setFrameSize(next);
|
|
189
|
+
}, []), handleMaxContentViewLayout = import_react.default.useCallback(function(e) {
|
|
190
|
+
var _e_nativeEvent, next = Math.min((_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.layout.height, import_react_native.Dimensions.get(relativeDimensionTo).height);
|
|
191
|
+
next && setMaxContentSize(next);
|
|
192
|
+
}, []), animatedStyle = useAnimatedNumberStyle(animatedNumber, function(val) {
|
|
193
|
+
"worklet";
|
|
194
|
+
var translateY = frameSize === 0 ? hiddenSize : val;
|
|
195
|
+
return {
|
|
196
|
+
transform: [
|
|
197
|
+
{
|
|
198
|
+
translateY
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
};
|
|
202
|
+
}), sizeBeforeKeyboard = import_react.default.useRef(null);
|
|
203
|
+
import_react.default.useEffect(function() {
|
|
204
|
+
if (!(import_constants.isWeb || !moveOnKeyboardChange)) {
|
|
205
|
+
var keyboardShowListener = import_react_native.Keyboard.addListener(import_constants.currentPlatform === "ios" ? "keyboardWillShow" : "keyboardDidShow", function(e) {
|
|
206
|
+
sizeBeforeKeyboard.current === null && (sizeBeforeKeyboard.current = isHidden || position === -1 ? screenSize : positions[position], animatedNumber.setValue(Math.max(sizeBeforeKeyboard.current - e.endCoordinates.height, 0), {
|
|
207
|
+
type: "timing",
|
|
208
|
+
duration: 250
|
|
209
|
+
}));
|
|
210
|
+
}), keyboardDidHideListener = import_react_native.Keyboard.addListener("keyboardDidHide", function() {
|
|
211
|
+
sizeBeforeKeyboard.current !== null && (animatedNumber.setValue(sizeBeforeKeyboard.current, {
|
|
212
|
+
type: "timing",
|
|
213
|
+
duration: 250
|
|
214
|
+
}), sizeBeforeKeyboard.current = null);
|
|
215
|
+
});
|
|
216
|
+
return function() {
|
|
217
|
+
keyboardDidHideListener.remove(), keyboardShowListener.remove();
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}, [
|
|
221
|
+
moveOnKeyboardChange,
|
|
222
|
+
positions,
|
|
223
|
+
position,
|
|
224
|
+
isHidden
|
|
225
|
+
]);
|
|
226
|
+
var [opacity, setOpacity] = import_react.default.useState(open ? 1 : 0);
|
|
227
|
+
open && opacity === 0 && setOpacity(1), import_react.default.useEffect(function() {
|
|
228
|
+
if (!open) {
|
|
229
|
+
var tm = setTimeout(function() {
|
|
230
|
+
setOpacity(0);
|
|
231
|
+
}, 400);
|
|
232
|
+
return function() {
|
|
233
|
+
clearTimeout(tm);
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}, [
|
|
237
|
+
open
|
|
238
|
+
]);
|
|
239
|
+
var forcedContentHeight = hasFit ? void 0 : snapPointsMode === "percent" ? `${maxSnapPoint}${import_constants.isWeb ? "dvh" : "%"}` : maxSnapPoint, setHasScrollView = import_react.default.useCallback(function(val) {
|
|
240
|
+
hasScrollView.current = val;
|
|
241
|
+
}, []), contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.LayoutMeasurementController, {
|
|
242
|
+
disable: !open,
|
|
243
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_contexts.ParentSheetContext.Provider, {
|
|
244
|
+
value: nextParentContext,
|
|
245
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_SheetContext.SheetProvider, {
|
|
246
|
+
...providerProps,
|
|
247
|
+
setHasScrollView,
|
|
248
|
+
children: [
|
|
249
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
|
|
250
|
+
custom: {
|
|
251
|
+
open
|
|
252
|
+
},
|
|
253
|
+
children: shouldHideParentSheet || !open ? null : overlayComponent
|
|
284
254
|
}),
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
setHasScrollView = import_react.default.useCallback(function (val) {
|
|
309
|
-
hasScrollView.current = val;
|
|
310
|
-
}, []),
|
|
311
|
-
contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.LayoutMeasurementController, {
|
|
312
|
-
disable: !open,
|
|
313
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_contexts.ParentSheetContext.Provider, {
|
|
314
|
-
value: nextParentContext,
|
|
315
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_SheetContext.SheetProvider, {
|
|
316
|
-
...providerProps,
|
|
317
|
-
setHasScrollView,
|
|
318
|
-
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
|
|
319
|
-
custom: {
|
|
320
|
-
open
|
|
321
|
-
},
|
|
322
|
-
children: shouldHideParentSheet || !open ? null : overlayComponent
|
|
323
|
-
}), snapPointsMode !== "percent" && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
|
|
324
|
-
style: {
|
|
325
|
-
opacity: 0,
|
|
326
|
-
position: "absolute",
|
|
327
|
-
top: 0,
|
|
328
|
-
left: 0,
|
|
329
|
-
right: 0,
|
|
330
|
-
bottom: 0,
|
|
331
|
-
pointerEvents: "none"
|
|
332
|
-
},
|
|
333
|
-
onLayout: handleMaxContentViewLayout
|
|
334
|
-
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(AnimatedView, {
|
|
335
|
-
ref,
|
|
336
|
-
...panResponder?.panHandlers,
|
|
337
|
-
onLayout: handleAnimationViewLayout,
|
|
338
|
-
// @ts-ignore for CSS driver this is necessary to attach the transition
|
|
339
|
-
// also motion driver at least though i suspect all drivers?
|
|
340
|
-
animation: isDragging || disableAnimation ? null : animation,
|
|
341
|
-
// @ts-ignore
|
|
342
|
-
disableClassName: !0,
|
|
343
|
-
style: [{
|
|
255
|
+
snapPointsMode !== "percent" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, {
|
|
256
|
+
style: {
|
|
257
|
+
opacity: 0,
|
|
258
|
+
position: "absolute",
|
|
259
|
+
top: 0,
|
|
260
|
+
left: 0,
|
|
261
|
+
right: 0,
|
|
262
|
+
bottom: 0,
|
|
263
|
+
pointerEvents: "none"
|
|
264
|
+
},
|
|
265
|
+
onLayout: handleMaxContentViewLayout
|
|
266
|
+
}),
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnimatedView, {
|
|
268
|
+
ref,
|
|
269
|
+
...panResponder == null ? void 0 : panResponder.panHandlers,
|
|
270
|
+
onLayout: handleAnimationViewLayout,
|
|
271
|
+
// @ts-ignore for CSS driver this is necessary to attach the transition
|
|
272
|
+
// also motion driver at least though i suspect all drivers?
|
|
273
|
+
animation: isDragging || disableAnimation ? null : animation,
|
|
274
|
+
// @ts-ignore
|
|
275
|
+
disableClassName: !0,
|
|
276
|
+
style: [
|
|
277
|
+
{
|
|
344
278
|
position: "absolute",
|
|
345
279
|
zIndex,
|
|
346
280
|
width: "100%",
|
|
347
281
|
height: forcedContentHeight,
|
|
348
282
|
minHeight: forcedContentHeight,
|
|
349
283
|
opacity: shouldHideParentSheet ? 0 : opacity,
|
|
350
|
-
...(
|
|
284
|
+
...(shouldHideParentSheet || !open) && {
|
|
351
285
|
pointerEvents: "none"
|
|
352
|
-
}
|
|
353
|
-
},
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (!import_portal.USE_NATIVE_PORTAL) {
|
|
361
|
-
var adaptContext = (0, import_adapt.useAdaptContext)();
|
|
362
|
-
contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.ProvideAdaptContext, {
|
|
363
|
-
...adaptContext,
|
|
364
|
-
children: (/* @ts-ignore */
|
|
365
|
-
contents)
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
var shouldMountChildren = unmountChildrenWhenHidden ? !!opacity : !0;
|
|
369
|
-
if (modal) {
|
|
370
|
-
var modalContents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.Portal, {
|
|
371
|
-
stackZIndex: zIndex,
|
|
372
|
-
...portalProps,
|
|
373
|
-
children: shouldMountChildren && /* @__PURE__ */(0, import_jsx_runtime.jsx)(ContainerComponent, {
|
|
374
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Theme, {
|
|
375
|
-
contain: !0,
|
|
376
|
-
forceClassName: !0,
|
|
377
|
-
name: themeName,
|
|
378
|
-
children: contents
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
animatedStyle
|
|
289
|
+
],
|
|
290
|
+
children: (
|
|
291
|
+
/* <AdaptProvider>{props.children}</AdaptProvider> */
|
|
292
|
+
props.children
|
|
293
|
+
)
|
|
379
294
|
})
|
|
380
|
-
|
|
381
|
-
})
|
|
382
|
-
|
|
383
|
-
value: onInnerSheet,
|
|
384
|
-
children: modalContents
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
return contents;
|
|
295
|
+
]
|
|
296
|
+
})
|
|
297
|
+
})
|
|
388
298
|
});
|
|
299
|
+
if (!import_portal.USE_NATIVE_PORTAL) {
|
|
300
|
+
var adaptContext = (0, import_adapt.useAdaptContext)();
|
|
301
|
+
contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.ProvideAdaptContext, {
|
|
302
|
+
...adaptContext,
|
|
303
|
+
children: (
|
|
304
|
+
/* @ts-ignore */
|
|
305
|
+
contents
|
|
306
|
+
)
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
var shouldMountChildren = unmountChildrenWhenHidden ? !!opacity : !0;
|
|
310
|
+
if (modal) {
|
|
311
|
+
var modalContents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, {
|
|
312
|
+
stackZIndex: zIndex,
|
|
313
|
+
...portalProps,
|
|
314
|
+
children: shouldMountChildren && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContainerComponent, {
|
|
315
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, {
|
|
316
|
+
contain: !0,
|
|
317
|
+
forceClassName: !0,
|
|
318
|
+
name: themeName,
|
|
319
|
+
children: contents
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
});
|
|
323
|
+
return import_constants.isWeb ? modalContents : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_contexts.SheetInsideSheetContext.Provider, {
|
|
324
|
+
value: onInnerSheet,
|
|
325
|
+
children: modalContents
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return contents;
|
|
329
|
+
});
|
|
389
330
|
function getYPositions(mode, point, screenSize, frameSize) {
|
|
390
331
|
if (!screenSize || !frameSize) return 0;
|
|
391
332
|
if (mode === "mixed") {
|
|
392
|
-
if (typeof point == "number")
|
|
393
|
-
|
|
333
|
+
if (typeof point == "number")
|
|
334
|
+
return screenSize - Math.min(screenSize, Math.max(0, point));
|
|
335
|
+
if (point === "fit")
|
|
336
|
+
return screenSize - Math.min(screenSize, frameSize);
|
|
394
337
|
if (point.endsWith("%")) {
|
|
395
338
|
var pct = Math.min(100, Math.max(0, Number(point.slice(0, -1)))) / 100;
|
|
396
|
-
if (Number.isNaN(pct))
|
|
339
|
+
if (Number.isNaN(pct))
|
|
340
|
+
return console.warn("Invalid snapPoint percentage string"), 0;
|
|
397
341
|
var next = Math.round(screenSize - pct * screenSize);
|
|
398
342
|
return next;
|
|
399
343
|
}
|
|
400
344
|
return console.warn("Invalid snapPoint unknown value"), 0;
|
|
401
345
|
}
|
|
402
|
-
if (mode === "fit")
|
|
403
|
-
|
|
346
|
+
if (mode === "fit")
|
|
347
|
+
return point === 0 ? screenSize : screenSize - Math.min(screenSize, frameSize);
|
|
348
|
+
if (mode === "constant" && typeof point == "number")
|
|
349
|
+
return screenSize - Math.min(screenSize, Math.max(0, point));
|
|
404
350
|
var pct1 = Math.min(100, Math.max(0, Number(point))) / 100;
|
|
405
351
|
return Number.isNaN(pct1) ? (console.warn("Invalid snapPoint percentage"), 0) : Math.round(screenSize - pct1 * screenSize);
|
|
406
352
|
}
|
|
407
|
-
|
|
353
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
354
|
+
0 && (module.exports = {
|
|
355
|
+
SheetImplementationCustom
|
|
356
|
+
});
|
|
357
|
+
//# sourceMappingURL=SheetImplementationCustom.js.map
|