@tamagui/sheet 1.89.26 → 1.89.27-1708113113238
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 +1 -1
- package/dist/cjs/Sheet.native.js.map +3 -3
- package/dist/cjs/SheetContext.native.js +48 -4
- package/dist/cjs/SheetContext.native.js.map +3 -3
- package/dist/cjs/SheetController.native.js +46 -14
- package/dist/cjs/SheetController.native.js.map +3 -3
- package/dist/cjs/SheetImplementationCustom.js.map +1 -1
- package/dist/cjs/SheetImplementationCustom.native.js +290 -211
- package/dist/cjs/SheetImplementationCustom.native.js.map +3 -3
- package/dist/cjs/SheetScrollView.native.js +112 -37
- package/dist/cjs/SheetScrollView.native.js.map +3 -3
- package/dist/cjs/constants.native.js +1 -2
- package/dist/cjs/constants.native.js.map +3 -3
- package/dist/cjs/contexts.native.js +1 -2
- package/dist/cjs/contexts.native.js.map +3 -3
- package/dist/cjs/createSheet.native.js +147 -110
- package/dist/cjs/createSheet.native.js.map +3 -3
- package/dist/cjs/helpers.native.js +3 -2
- package/dist/cjs/helpers.native.js.map +3 -3
- package/dist/cjs/index.native.js.map +2 -2
- package/dist/cjs/nativeSheet.native.js +61 -21
- package/dist/cjs/nativeSheet.native.js.map +3 -3
- package/dist/cjs/types.native.js.map +2 -2
- package/dist/cjs/useSheet.native.js +3 -2
- package/dist/cjs/useSheet.native.js.map +3 -3
- package/dist/cjs/useSheetController.native.js +3 -6
- package/dist/cjs/useSheetController.native.js.map +3 -3
- package/dist/cjs/useSheetOffscreenSize.native.js +9 -14
- package/dist/cjs/useSheetOffscreenSize.native.js.map +3 -3
- package/dist/cjs/useSheetOpenState.native.js +55 -8
- package/dist/cjs/useSheetOpenState.native.js.map +3 -3
- package/dist/cjs/useSheetProviderProps.native.js +116 -44
- package/dist/cjs/useSheetProviderProps.native.js.map +3 -3
- package/dist/esm/Sheet.native.js +1 -1
- package/dist/esm/Sheet.native.js.map +3 -3
- package/dist/esm/SheetContext.native.js +48 -4
- package/dist/esm/SheetContext.native.js.map +3 -3
- package/dist/esm/SheetController.native.js +36 -13
- package/dist/esm/SheetController.native.js.map +3 -3
- package/dist/esm/SheetImplementationCustom.js.map +1 -1
- package/dist/esm/SheetImplementationCustom.native.js +291 -229
- package/dist/esm/SheetImplementationCustom.native.js.map +3 -3
- package/dist/esm/SheetScrollView.native.js +111 -37
- package/dist/esm/SheetScrollView.native.js.map +3 -3
- package/dist/esm/constants.native.js +1 -1
- package/dist/esm/constants.native.js.map +3 -3
- package/dist/esm/contexts.native.js +1 -1
- package/dist/esm/contexts.native.js.map +3 -3
- package/dist/esm/createSheet.native.js +145 -109
- package/dist/esm/createSheet.native.js.map +3 -3
- package/dist/esm/helpers.native.js +3 -2
- package/dist/esm/helpers.native.js.map +3 -3
- package/dist/esm/index.native.js.map +3 -3
- package/dist/esm/nativeSheet.native.js +60 -21
- package/dist/esm/nativeSheet.native.js.map +3 -3
- package/dist/esm/useSheet.native.js +3 -1
- package/dist/esm/useSheet.native.js.map +3 -3
- package/dist/esm/useSheetController.native.js +3 -5
- package/dist/esm/useSheetController.native.js.map +3 -3
- package/dist/esm/useSheetOffscreenSize.native.js +9 -14
- package/dist/esm/useSheetOffscreenSize.native.js.map +3 -3
- package/dist/esm/useSheetOpenState.native.js +55 -8
- package/dist/esm/useSheetOpenState.native.js.map +3 -3
- package/dist/esm/useSheetProviderProps.native.js +116 -44
- package/dist/esm/useSheetProviderProps.native.js.map +3 -3
- package/dist/jsx/Sheet.native.js +1 -1
- package/dist/jsx/Sheet.native.js.map +3 -3
- package/dist/jsx/SheetContext.native.js +48 -4
- package/dist/jsx/SheetContext.native.js.map +3 -3
- package/dist/jsx/SheetController.native.js +36 -13
- package/dist/jsx/SheetController.native.js.map +3 -3
- package/dist/jsx/SheetImplementationCustom.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.native.js +291 -229
- package/dist/jsx/SheetImplementationCustom.native.js.map +3 -3
- package/dist/jsx/SheetScrollView.native.js +111 -37
- package/dist/jsx/SheetScrollView.native.js.map +3 -3
- package/dist/jsx/constants.native.js +1 -1
- package/dist/jsx/constants.native.js.map +3 -3
- package/dist/jsx/contexts.native.js +1 -1
- package/dist/jsx/contexts.native.js.map +3 -3
- package/dist/jsx/createSheet.native.js +145 -109
- package/dist/jsx/createSheet.native.js.map +3 -3
- package/dist/jsx/helpers.native.js +3 -2
- package/dist/jsx/helpers.native.js.map +3 -3
- package/dist/jsx/index.native.js.map +3 -3
- package/dist/jsx/nativeSheet.native.js +60 -21
- package/dist/jsx/nativeSheet.native.js.map +3 -3
- package/dist/jsx/useSheet.native.js +3 -1
- package/dist/jsx/useSheet.native.js.map +3 -3
- package/dist/jsx/useSheetController.native.js +3 -5
- package/dist/jsx/useSheetController.native.js.map +3 -3
- package/dist/jsx/useSheetOffscreenSize.native.js +9 -14
- package/dist/jsx/useSheetOffscreenSize.native.js.map +3 -3
- package/dist/jsx/useSheetOpenState.native.js +55 -8
- package/dist/jsx/useSheetOpenState.native.js.map +3 -3
- package/dist/jsx/useSheetProviderProps.native.js +116 -44
- package/dist/jsx/useSheetProviderProps.native.js.map +3 -3
- package/package.json +17 -17
- package/src/SheetImplementationCustom.tsx +0 -1
- package/types/SheetImplementationCustom.d.ts.map +1 -1
|
@@ -18,77 +18,138 @@ __export(SheetImplementationCustom_exports, {
|
|
|
18
18
|
SheetImplementationCustom: () => SheetImplementationCustom
|
|
19
19
|
});
|
|
20
20
|
module.exports = __toCommonJS(SheetImplementationCustom_exports);
|
|
21
|
-
var 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_use_keyboard_visible = require("@tamagui/use-keyboard-visible"), import_react = require("react"), import_react_native = require("react-native"), import_constants2 = require("./constants"), import_contexts = require("./contexts"), import_helpers = require("./helpers"), import_SheetContext = require("./SheetContext"), import_useSheetOpenState = require("./useSheetOpenState"), import_useSheetProviderProps = require("./useSheetProviderProps")
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
(0,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
() => snapPoints.map(
|
|
57
|
-
(point) => getYPositions(snapPointsMode, point, screenSize, frameSize)
|
|
58
|
-
),
|
|
59
|
-
[screenSize, frameSize, snapPoints, snapPointsMode]
|
|
60
|
-
), { animationDriver } = (0, import_core.useConfiguration)(), { useAnimatedNumber, useAnimatedNumberStyle, useAnimatedNumberReaction } = animationDriver, AnimatedView = animationDriver.View ?? import_core.Stack;
|
|
61
|
-
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
62
|
-
if (parentSheetContext && open)
|
|
63
|
-
return parentSheetContext(!0), () => {
|
|
64
|
-
parentSheetContext(!1);
|
|
65
|
-
};
|
|
66
|
-
}, [parentSheetContext, open]);
|
|
67
|
-
const nextParentContext = (0, import_react.useMemo)(
|
|
68
|
-
() => ({
|
|
69
|
-
zIndex
|
|
70
|
-
}),
|
|
71
|
-
[zIndex]
|
|
72
|
-
), animatedNumber = useAnimatedNumber(hiddenSize), at = (0, import_react.useRef)(hiddenSize);
|
|
73
|
-
useAnimatedNumberReaction(
|
|
74
|
-
{
|
|
75
|
-
value: animatedNumber,
|
|
76
|
-
hostRef: sheetRef
|
|
77
|
-
},
|
|
78
|
-
(0, import_react.useCallback)(
|
|
79
|
-
(value) => {
|
|
80
|
-
at.current = value, scrollBridge.paneY = value;
|
|
81
|
-
},
|
|
82
|
-
[animationDriver]
|
|
83
|
-
)
|
|
84
|
-
);
|
|
85
|
-
function stopSpring() {
|
|
86
|
-
animatedNumber.stop(), scrollBridge.onFinishAnimate && (scrollBridge.onFinishAnimate(), scrollBridge.onFinishAnimate = void 0);
|
|
21
|
+
var 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_use_keyboard_visible = require("@tamagui/use-keyboard-visible"), import_react = require("react"), import_react_native = require("react-native"), import_constants2 = require("./constants"), import_contexts = require("./contexts"), import_helpers = require("./helpers"), import_SheetContext = require("./SheetContext"), import_useSheetOpenState = require("./useSheetOpenState"), import_useSheetProviderProps = require("./useSheetProviderProps");
|
|
22
|
+
function _array_like_to_array(arr, len) {
|
|
23
|
+
(len == null || len > arr.length) && (len = arr.length);
|
|
24
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
25
|
+
arr2[i] = arr[i];
|
|
26
|
+
return arr2;
|
|
27
|
+
}
|
|
28
|
+
function _array_with_holes(arr) {
|
|
29
|
+
if (Array.isArray(arr))
|
|
30
|
+
return arr;
|
|
31
|
+
}
|
|
32
|
+
function _define_property(obj, key, value) {
|
|
33
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
34
|
+
value,
|
|
35
|
+
enumerable: !0,
|
|
36
|
+
configurable: !0,
|
|
37
|
+
writable: !0
|
|
38
|
+
}) : obj[key] = value, obj;
|
|
39
|
+
}
|
|
40
|
+
function _iterable_to_array_limit(arr, i) {
|
|
41
|
+
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
42
|
+
if (_i != null) {
|
|
43
|
+
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
44
|
+
try {
|
|
45
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
46
|
+
;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
_d = !0, _e = err;
|
|
49
|
+
} finally {
|
|
50
|
+
try {
|
|
51
|
+
!_n && _i.return != null && _i.return();
|
|
52
|
+
} finally {
|
|
53
|
+
if (_d)
|
|
54
|
+
throw _e;
|
|
55
|
+
}
|
|
87
56
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
57
|
+
return _arr;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function _non_iterable_rest() {
|
|
61
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
62
|
+
}
|
|
63
|
+
function _object_spread(target) {
|
|
64
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
65
|
+
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
66
|
+
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
67
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
68
|
+
}))), ownKeys2.forEach(function(key) {
|
|
69
|
+
_define_property(target, key, source[key]);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
74
|
+
function ownKeys(object, enumerableOnly) {
|
|
75
|
+
var keys = Object.keys(object);
|
|
76
|
+
if (Object.getOwnPropertySymbols) {
|
|
77
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
78
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
79
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
80
|
+
})), keys.push.apply(keys, symbols);
|
|
81
|
+
}
|
|
82
|
+
return keys;
|
|
83
|
+
}
|
|
84
|
+
function _object_spread_props(target, source) {
|
|
85
|
+
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
86
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
87
|
+
}), target;
|
|
88
|
+
}
|
|
89
|
+
function _sliced_to_array(arr, i) {
|
|
90
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
91
|
+
}
|
|
92
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
93
|
+
if (o) {
|
|
94
|
+
if (typeof o == "string")
|
|
95
|
+
return _array_like_to_array(o, minLen);
|
|
96
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
97
|
+
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set")
|
|
98
|
+
return Array.from(n);
|
|
99
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
100
|
+
return _array_like_to_array(o, minLen);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
var hiddenSize = 10000.1, SheetImplementationCustom = (0, import_core.themeable)(/* @__PURE__ */ (0, import_react.forwardRef)(function(props, forwardedRef) {
|
|
104
|
+
var parentSheet = (0, import_react.useContext)(import_contexts.ParentSheetContext), animation = props.animation, animationConfigProp = props.animationConfig, _props_modal = props.modal, modal = _props_modal === void 0 ? !1 : _props_modal, _props_zIndex = props.zIndex, zIndex = _props_zIndex === void 0 ? parentSheet.zIndex + 1 : _props_zIndex, _props_moveOnKeyboardChange = props.moveOnKeyboardChange, moveOnKeyboardChange = _props_moveOnKeyboardChange === void 0 ? !1 : _props_moveOnKeyboardChange, _props_unmountChildrenWhenHidden = props.unmountChildrenWhenHidden, unmountChildrenWhenHidden = _props_unmountChildrenWhenHidden === void 0 ? !1 : _props_unmountChildrenWhenHidden, portalProps = props.portalProps, keyboardIsVisible = (0, import_use_keyboard_visible.useKeyboardVisible)(), state = (0, import_useSheetOpenState.useSheetOpenState)(props), _useState = _sliced_to_array((0, import_react.useState)(null), 2), overlayComponent = _useState[0], setOverlayComponent = _useState[1], providerProps = (0, import_useSheetProviderProps.useSheetProviderProps)(props, state, {
|
|
105
|
+
onOverlayComponent: setOverlayComponent
|
|
106
|
+
}), frameSize = providerProps.frameSize, setFrameSize = providerProps.setFrameSize, snapPoints = providerProps.snapPoints, snapPointsMode = providerProps.snapPointsMode, hasFit = providerProps.hasFit, position = providerProps.position, setPosition = providerProps.setPosition, scrollBridge = providerProps.scrollBridge, screenSize = providerProps.screenSize, setMaxContentSize = providerProps.setMaxContentSize, maxSnapPoint = providerProps.maxSnapPoint, open = state.open, controller = state.controller, isHidden = state.isHidden, sheetRef = (0, import_react.useRef)(null), ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, sheetRef), animationConfig = function() {
|
|
107
|
+
var _ref = _sliced_to_array(animation ? Array.isArray(animation) ? animation : [
|
|
108
|
+
animation
|
|
109
|
+
] : [], 2), animationProp = _ref[0], animationPropConfig = _ref[1];
|
|
110
|
+
return animationConfigProp ?? (animationProp ? _object_spread({}, (0, import_core.getConfig)().animations.animations[animationProp], animationPropConfig) : null);
|
|
111
|
+
}(), _useState1 = _sliced_to_array((0, import_react.useState)(!1), 2), isShowingInnerSheet = _useState1[0], setIsShowingInnerSheet = _useState1[1], shouldHideParentSheet = !import_constants.isWeb && modal && isShowingInnerSheet, parentSheetContext = (0, import_react.useContext)(import_contexts.SheetInsideSheetContext), onInnerSheet = (0, import_react.useCallback)(function(hasChild) {
|
|
112
|
+
setIsShowingInnerSheet(hasChild);
|
|
113
|
+
}, []), positions = (0, import_react.useMemo)(function() {
|
|
114
|
+
return snapPoints.map(function(point) {
|
|
115
|
+
return getYPositions(snapPointsMode, point, screenSize, frameSize);
|
|
116
|
+
});
|
|
117
|
+
}, [
|
|
118
|
+
screenSize,
|
|
119
|
+
frameSize,
|
|
120
|
+
snapPoints,
|
|
121
|
+
snapPointsMode
|
|
122
|
+
]), animationDriver = (0, import_core.useConfiguration)().animationDriver, useAnimatedNumber = animationDriver.useAnimatedNumber, useAnimatedNumberStyle = animationDriver.useAnimatedNumberStyle, useAnimatedNumberReaction = animationDriver.useAnimatedNumberReaction, _animationDriver_View, AnimatedView = (_animationDriver_View = animationDriver.View) !== null && _animationDriver_View !== void 0 ? _animationDriver_View : import_core.Stack;
|
|
123
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
124
|
+
if (parentSheetContext && open)
|
|
125
|
+
return parentSheetContext(!0), function() {
|
|
126
|
+
parentSheetContext(!1);
|
|
127
|
+
};
|
|
128
|
+
}, [
|
|
129
|
+
parentSheetContext,
|
|
130
|
+
open
|
|
131
|
+
]);
|
|
132
|
+
var nextParentContext = (0, import_react.useMemo)(function() {
|
|
133
|
+
return {
|
|
134
|
+
zIndex
|
|
135
|
+
};
|
|
136
|
+
}, [
|
|
137
|
+
zIndex
|
|
138
|
+
]), animatedNumber = useAnimatedNumber(hiddenSize), at = (0, import_react.useRef)(hiddenSize);
|
|
139
|
+
useAnimatedNumberReaction({
|
|
140
|
+
value: animatedNumber,
|
|
141
|
+
hostRef: sheetRef
|
|
142
|
+
}, (0, import_react.useCallback)(function(value) {
|
|
143
|
+
at.current = value, scrollBridge.paneY = value;
|
|
144
|
+
}, [
|
|
145
|
+
animationDriver
|
|
146
|
+
]));
|
|
147
|
+
function stopSpring() {
|
|
148
|
+
animatedNumber.stop(), scrollBridge.onFinishAnimate && (scrollBridge.onFinishAnimate(), scrollBridge.onFinishAnimate = void 0);
|
|
149
|
+
}
|
|
150
|
+
var hasntMeasured = at.current === hiddenSize, animateTo = (0, import_core.useEvent)(function(position2) {
|
|
151
|
+
if (frameSize !== 0) {
|
|
152
|
+
var toValue = isHidden || position2 === -1 ? screenSize : positions[position2];
|
|
92
153
|
if (at.current !== toValue) {
|
|
93
154
|
if (at.current = toValue, stopSpring(), hasntMeasured || isHidden) {
|
|
94
155
|
if (animatedNumber.setValue(screenSize, {
|
|
@@ -98,172 +159,187 @@ const SheetImplementationCustom = (0, import_core.themeable)(
|
|
|
98
159
|
return;
|
|
99
160
|
toValue = positions[position2], at.current = toValue;
|
|
100
161
|
}
|
|
101
|
-
animatedNumber.setValue(toValue, {
|
|
102
|
-
type: "spring"
|
|
103
|
-
|
|
104
|
-
});
|
|
162
|
+
animatedNumber.setValue(toValue, _object_spread({
|
|
163
|
+
type: "spring"
|
|
164
|
+
}, animationConfig));
|
|
105
165
|
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
169
|
+
screenSize && hasntMeasured && animatedNumber.setValue(screenSize, {
|
|
170
|
+
type: "timing",
|
|
171
|
+
duration: 0
|
|
106
172
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
173
|
+
}, [
|
|
174
|
+
hasntMeasured,
|
|
175
|
+
screenSize
|
|
176
|
+
]), (0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
177
|
+
!frameSize || !screenSize || isHidden || hasntMeasured && !open || animateTo(position);
|
|
178
|
+
}, [
|
|
179
|
+
isHidden,
|
|
180
|
+
frameSize,
|
|
181
|
+
screenSize,
|
|
182
|
+
open,
|
|
183
|
+
position
|
|
184
|
+
]);
|
|
185
|
+
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)(), _useState2 = _sliced_to_array((0, import_react.useState)(!1), 2), isDragging = _useState2[0], setIsDragging = _useState2[1], panResponder = (0, import_react.useMemo)(function() {
|
|
186
|
+
var setPanning = function(val) {
|
|
187
|
+
setIsDragging(val), import_constants2.SHEET_HIDDEN_STYLESHEET && (val ? import_constants2.SHEET_HIDDEN_STYLESHEET.innerText = ":root * { user-select: none !important; -webkit-user-select: none !important; }" : import_constants2.SHEET_HIDDEN_STYLESHEET.innerText = "");
|
|
188
|
+
};
|
|
189
|
+
if (!disableDrag && frameSize && !isShowingInnerSheet) {
|
|
190
|
+
var minY = positions[0];
|
|
119
191
|
scrollBridge.paneMinY = minY;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
setIsDragging(val), import_constants2.SHEET_HIDDEN_STYLESHEET && (val ? import_constants2.SHEET_HIDDEN_STYLESHEET.innerText = ":root * { user-select: none !important; -webkit-user-select: none !important; }" : import_constants2.SHEET_HIDDEN_STYLESHEET.innerText = "");
|
|
123
|
-
}
|
|
124
|
-
const release = ({ vy, dragAt }) => {
|
|
192
|
+
var startY = at.current, release = function(param) {
|
|
193
|
+
var vy = param.vy, dragAt = param.dragAt;
|
|
125
194
|
isExternalDrag = !1, previouslyScrolling = !1, setPanning(!1);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
for (let i = 0; i < positions.length; i++) {
|
|
129
|
-
const position2 = positions[i], curDist = end > position2 ? end - position2 : position2 - end;
|
|
195
|
+
for (var at2 = dragAt + startY, end = at2 + frameSize * vy * 0.2, closestPoint = 0, dist = 1 / 0, i = 0; i < positions.length; i++) {
|
|
196
|
+
var position2 = positions[i], curDist = end > position2 ? end - position2 : position2 - end;
|
|
130
197
|
curDist < dist && (dist = curDist, closestPoint = i);
|
|
131
198
|
}
|
|
132
199
|
setPosition(closestPoint), animateTo(closestPoint);
|
|
133
|
-
}, finish = (_e, state2)
|
|
200
|
+
}, finish = function(_e, state2) {
|
|
134
201
|
release({
|
|
135
202
|
vy: state2.vy,
|
|
136
203
|
dragAt: state2.dy
|
|
137
204
|
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const onMoveShouldSet = (e, { dy }) => {
|
|
205
|
+
}, previouslyScrolling = !1, onMoveShouldSet = function(e, param) {
|
|
206
|
+
var dy = param.dy;
|
|
141
207
|
if (e.target === providerProps.handleRef.current)
|
|
142
208
|
return !0;
|
|
143
|
-
|
|
209
|
+
var isScrolled = scrollBridge.y !== 0, isDraggingUp = dy < 0, isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
|
|
144
210
|
return isScrolled ? (previouslyScrolling = !0, !1) : isNearTop && !isScrolled && isDraggingUp && !import_constants.isWeb ? !1 : Math.abs(dy) > 5;
|
|
145
|
-
}, grant = ()
|
|
211
|
+
}, grant = function() {
|
|
146
212
|
setPanning(!0), stopSpring(), startY = at.current;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
return scrollBridge.drag = (dy) => {
|
|
213
|
+
}, isExternalDrag = !1;
|
|
214
|
+
return scrollBridge.drag = function(dy) {
|
|
150
215
|
isExternalDrag || (isExternalDrag = !0, grant());
|
|
151
|
-
|
|
152
|
-
animatedNumber.setValue((0, import_helpers.resisted)(to, minY), {
|
|
216
|
+
var to = dy + startY;
|
|
217
|
+
animatedNumber.setValue((0, import_helpers.resisted)(to, minY), {
|
|
218
|
+
type: "direct"
|
|
219
|
+
});
|
|
153
220
|
}, scrollBridge.release = release, import_react_native.PanResponder.create({
|
|
154
221
|
onMoveShouldSetPanResponder: onMoveShouldSet,
|
|
155
222
|
onPanResponderGrant: grant,
|
|
156
|
-
onPanResponderMove: (_e,
|
|
157
|
-
|
|
158
|
-
animatedNumber.setValue(to, {
|
|
223
|
+
onPanResponderMove: function(_e, param) {
|
|
224
|
+
var dy = param.dy, toFull = dy + startY, to = (0, import_helpers.resisted)(toFull, minY);
|
|
225
|
+
animatedNumber.setValue(to, {
|
|
226
|
+
type: "direct"
|
|
227
|
+
});
|
|
159
228
|
},
|
|
160
229
|
onPanResponderEnd: finish,
|
|
161
230
|
onPanResponderTerminate: finish,
|
|
162
231
|
onPanResponderRelease: finish
|
|
163
232
|
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
));
|
|
197
|
-
}), keyboardDidHideListener = import_react_native.Keyboard.addListener("keyboardDidHide", ()
|
|
233
|
+
}
|
|
234
|
+
}, [
|
|
235
|
+
disableDrag,
|
|
236
|
+
isShowingInnerSheet,
|
|
237
|
+
animateTo,
|
|
238
|
+
frameSize,
|
|
239
|
+
positions,
|
|
240
|
+
setPosition
|
|
241
|
+
]), handleAnimationViewLayout = (0, import_react.useCallback)(function(e) {
|
|
242
|
+
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("window").height);
|
|
243
|
+
next && setFrameSize(next);
|
|
244
|
+
}, [
|
|
245
|
+
keyboardIsVisible
|
|
246
|
+
]), handleMaxContentViewLayout = (0, import_react.useCallback)(function(e) {
|
|
247
|
+
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("window").height);
|
|
248
|
+
next && setMaxContentSize(next);
|
|
249
|
+
}, [
|
|
250
|
+
keyboardIsVisible
|
|
251
|
+
]), animatedStyle = useAnimatedNumberStyle(animatedNumber, function(val) {
|
|
252
|
+
"worklet";
|
|
253
|
+
var translateY = frameSize === 0 ? hiddenSize : val;
|
|
254
|
+
return {
|
|
255
|
+
transform: [
|
|
256
|
+
{
|
|
257
|
+
translateY
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
};
|
|
261
|
+
}), sizeBeforeKeyboard = (0, import_react.useRef)(null);
|
|
262
|
+
(0, import_react.useEffect)(function() {
|
|
263
|
+
if (!(import_constants.isWeb || !moveOnKeyboardChange)) {
|
|
264
|
+
var keyboardDidShowListener = import_react_native.Keyboard.addListener("keyboardDidShow", function(e) {
|
|
265
|
+
sizeBeforeKeyboard.current === null && (sizeBeforeKeyboard.current = animatedNumber.getValue(), animatedNumber.setValue(Math.max(animatedNumber.getValue() - e.endCoordinates.height, 0)));
|
|
266
|
+
}), keyboardDidHideListener = import_react_native.Keyboard.addListener("keyboardDidHide", function() {
|
|
198
267
|
sizeBeforeKeyboard.current !== null && (animatedNumber.setValue(sizeBeforeKeyboard.current), sizeBeforeKeyboard.current = null);
|
|
199
268
|
});
|
|
200
|
-
return ()
|
|
269
|
+
return function() {
|
|
201
270
|
keyboardDidHideListener.remove(), keyboardDidShowListener.remove();
|
|
202
271
|
};
|
|
203
|
-
}, [moveOnKeyboardChange]);
|
|
204
|
-
const [opacity, setOpacity] = (0, import_react.useState)(open ? 1 : 0);
|
|
205
|
-
open && opacity === 0 && setOpacity(1), (0, import_react.useEffect)(() => {
|
|
206
|
-
if (!open) {
|
|
207
|
-
const tm = setTimeout(() => {
|
|
208
|
-
setOpacity(0);
|
|
209
|
-
}, 400);
|
|
210
|
-
return () => {
|
|
211
|
-
clearTimeout(tm);
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
}, [open]);
|
|
215
|
-
const forcedContentHeight = hasFit ? void 0 : snapPointsMode === "percent" ? `${maxSnapPoint}%` : maxSnapPoint, contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_contexts.ParentSheetContext.Provider, { value: nextParentContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_SheetContext.SheetProvider, { ...providerProps, children: [
|
|
216
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { enterExitVariant: "open", children: shouldHideParentSheet || !open ? null : overlayComponent }),
|
|
217
|
-
snapPointsMode !== "percent" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
218
|
-
import_react_native.View,
|
|
219
|
-
{
|
|
220
|
-
style: {
|
|
221
|
-
opacity: 0,
|
|
222
|
-
position: "absolute",
|
|
223
|
-
top: 0,
|
|
224
|
-
left: 0,
|
|
225
|
-
right: 0,
|
|
226
|
-
bottom: 0,
|
|
227
|
-
pointerEvents: "none"
|
|
228
|
-
},
|
|
229
|
-
pointerEvents: "none",
|
|
230
|
-
onLayout: handleMaxContentViewLayout
|
|
231
|
-
}
|
|
232
|
-
),
|
|
233
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
234
|
-
AnimatedView,
|
|
235
|
-
{
|
|
236
|
-
ref,
|
|
237
|
-
...panResponder == null ? void 0 : panResponder.panHandlers,
|
|
238
|
-
onLayout: handleAnimationViewLayout,
|
|
239
|
-
pointerEvents: open && !shouldHideParentSheet ? "auto" : "none",
|
|
240
|
-
...!isDragging && {
|
|
241
|
-
// @ts-ignore for CSS driver this is necessary to attach the transition
|
|
242
|
-
animation
|
|
243
|
-
},
|
|
244
|
-
disableClassName: !0,
|
|
245
|
-
style: [
|
|
246
|
-
{
|
|
247
|
-
position: "absolute",
|
|
248
|
-
zIndex,
|
|
249
|
-
width: "100%",
|
|
250
|
-
height: forcedContentHeight,
|
|
251
|
-
minHeight: forcedContentHeight,
|
|
252
|
-
opacity
|
|
253
|
-
},
|
|
254
|
-
animatedStyle
|
|
255
|
-
],
|
|
256
|
-
children: props.children
|
|
257
|
-
}
|
|
258
|
-
)
|
|
259
|
-
] }) }), adaptContext = (0, import_react.useContext)(import_adapt.AdaptParentContext), shouldMountChildren = !!(opacity || !unmountChildrenWhenHidden);
|
|
260
|
-
if (modal) {
|
|
261
|
-
const modalContents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, { zIndex, ...portalProps, children: shouldMountChildren && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, { forceClassName: !0, name: themeName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.AdaptParentContext.Provider, { value: adaptContext, children: contents }) }) });
|
|
262
|
-
return import_constants.isWeb ? modalContents : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_contexts.SheetInsideSheetContext.Provider, { value: onInnerSheet, children: modalContents });
|
|
263
272
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
);
|
|
273
|
+
}, [
|
|
274
|
+
moveOnKeyboardChange
|
|
275
|
+
]);
|
|
276
|
+
var _useState3 = _sliced_to_array((0, import_react.useState)(open ? 1 : 0), 2), opacity = _useState3[0], setOpacity = _useState3[1];
|
|
277
|
+
open && opacity === 0 && setOpacity(1), (0, import_react.useEffect)(function() {
|
|
278
|
+
if (!open) {
|
|
279
|
+
var tm = setTimeout(function() {
|
|
280
|
+
setOpacity(0);
|
|
281
|
+
}, 400);
|
|
282
|
+
return function() {
|
|
283
|
+
clearTimeout(tm);
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
}, [
|
|
287
|
+
open
|
|
288
|
+
]);
|
|
289
|
+
var forcedContentHeight = hasFit ? void 0 : snapPointsMode === "percent" ? "".concat(maxSnapPoint, "%") : maxSnapPoint, contents = /* @__PURE__ */ React.createElement(import_contexts.ParentSheetContext.Provider, {
|
|
290
|
+
value: nextParentContext
|
|
291
|
+
}, /* @__PURE__ */ React.createElement(import_SheetContext.SheetProvider, providerProps, /* @__PURE__ */ React.createElement(import_animate_presence.AnimatePresence, {
|
|
292
|
+
enterExitVariant: "open"
|
|
293
|
+
}, shouldHideParentSheet || !open ? null : overlayComponent), snapPointsMode !== "percent" && /* @__PURE__ */ React.createElement(import_react_native.View, {
|
|
294
|
+
style: {
|
|
295
|
+
opacity: 0,
|
|
296
|
+
position: "absolute",
|
|
297
|
+
top: 0,
|
|
298
|
+
left: 0,
|
|
299
|
+
right: 0,
|
|
300
|
+
bottom: 0,
|
|
301
|
+
pointerEvents: "none"
|
|
302
|
+
},
|
|
303
|
+
pointerEvents: "none",
|
|
304
|
+
onLayout: handleMaxContentViewLayout
|
|
305
|
+
}), /* @__PURE__ */ React.createElement(AnimatedView, _object_spread_props(_object_spread(_object_spread_props(_object_spread({
|
|
306
|
+
ref
|
|
307
|
+
}, panResponder == null ? void 0 : panResponder.panHandlers), {
|
|
308
|
+
onLayout: handleAnimationViewLayout,
|
|
309
|
+
pointerEvents: open && !shouldHideParentSheet ? "auto" : "none"
|
|
310
|
+
}), !isDragging && {
|
|
311
|
+
// @ts-ignore for CSS driver this is necessary to attach the transition
|
|
312
|
+
animation
|
|
313
|
+
}), {
|
|
314
|
+
// @ts-ignore
|
|
315
|
+
disableClassName: !0,
|
|
316
|
+
style: [
|
|
317
|
+
{
|
|
318
|
+
position: "absolute",
|
|
319
|
+
zIndex,
|
|
320
|
+
width: "100%",
|
|
321
|
+
height: forcedContentHeight,
|
|
322
|
+
minHeight: forcedContentHeight,
|
|
323
|
+
opacity
|
|
324
|
+
},
|
|
325
|
+
animatedStyle
|
|
326
|
+
]
|
|
327
|
+
}), props.children))), adaptContext = (0, import_react.useContext)(import_adapt.AdaptParentContext), shouldMountChildren = !!(opacity || !unmountChildrenWhenHidden);
|
|
328
|
+
if (modal) {
|
|
329
|
+
var modalContents = /* @__PURE__ */ React.createElement(import_portal.Portal, _object_spread({
|
|
330
|
+
zIndex
|
|
331
|
+
}, portalProps), shouldMountChildren && /* @__PURE__ */ React.createElement(import_core.Theme, {
|
|
332
|
+
forceClassName: !0,
|
|
333
|
+
name: themeName
|
|
334
|
+
}, /* @__PURE__ */ React.createElement(import_adapt.AdaptParentContext.Provider, {
|
|
335
|
+
value: adaptContext
|
|
336
|
+
}, contents)));
|
|
337
|
+
return import_constants.isWeb ? modalContents : /* @__PURE__ */ React.createElement(import_contexts.SheetInsideSheetContext.Provider, {
|
|
338
|
+
value: onInnerSheet
|
|
339
|
+
}, modalContents);
|
|
340
|
+
}
|
|
341
|
+
return contents;
|
|
342
|
+
}));
|
|
267
343
|
function getYPositions(mode, point, screenSize, frameSize) {
|
|
268
344
|
if (!screenSize || !frameSize)
|
|
269
345
|
return 0;
|
|
@@ -273,8 +349,11 @@ function getYPositions(mode, point, screenSize, frameSize) {
|
|
|
273
349
|
if (point === "fit")
|
|
274
350
|
return screenSize - Math.min(screenSize, frameSize);
|
|
275
351
|
if (point.endsWith("%")) {
|
|
276
|
-
|
|
277
|
-
|
|
352
|
+
var pct = Math.min(100, Math.max(0, Number(point.slice(0, -1)))) / 100;
|
|
353
|
+
if (Number.isNaN(pct))
|
|
354
|
+
return console.warn("Invalid snapPoint percentage string"), 0;
|
|
355
|
+
var next = Math.round(screenSize - pct * screenSize);
|
|
356
|
+
return next;
|
|
278
357
|
}
|
|
279
358
|
return console.warn("Invalid snapPoint unknown value"), 0;
|
|
280
359
|
}
|
|
@@ -282,8 +361,8 @@ function getYPositions(mode, point, screenSize, frameSize) {
|
|
|
282
361
|
return point === 0 ? screenSize : screenSize - Math.min(screenSize, frameSize);
|
|
283
362
|
if (mode === "constant" && typeof point == "number")
|
|
284
363
|
return screenSize - Math.min(screenSize, Math.max(0, point));
|
|
285
|
-
|
|
286
|
-
return Number.isNaN(
|
|
364
|
+
var pct1 = Math.min(100, Math.max(0, Number(point))) / 100;
|
|
365
|
+
return Number.isNaN(pct1) ? (console.warn("Invalid snapPoint percentage"), 0) : Math.round(screenSize - pct1 * screenSize);
|
|
287
366
|
}
|
|
288
367
|
// Annotate the CommonJS export names for ESM import in node:
|
|
289
368
|
0 && (module.exports = {
|