@tamagui/sheet 1.26.1 → 1.27.1
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.js +23 -425
- package/dist/cjs/Sheet.js.map +2 -2
- package/dist/cjs/StyledSheet.js +132 -0
- package/dist/cjs/StyledSheet.js.map +6 -0
- package/dist/cjs/constants.js +3 -0
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/createSheet.js +446 -0
- package/dist/cjs/createSheet.js.map +6 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/useSheet.js +30 -0
- package/dist/cjs/useSheet.js.map +6 -0
- package/dist/cjs/useSheetChildren.js +4 -2
- package/dist/cjs/useSheetChildren.js.map +1 -1
- package/dist/esm/Sheet.js +20 -447
- package/dist/esm/Sheet.js.map +2 -2
- package/dist/esm/StyledSheet.js +100 -0
- package/dist/esm/StyledSheet.js.map +6 -0
- package/dist/esm/constants.js +2 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/createSheet.js +448 -0
- package/dist/esm/createSheet.js.map +6 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/useSheet.js +6 -0
- package/dist/esm/useSheet.js.map +6 -0
- package/dist/esm/useSheetChildren.js +4 -2
- package/dist/esm/useSheetChildren.js.map +1 -1
- package/dist/jsx/Sheet.js +20 -434
- package/dist/jsx/Sheet.js.map +2 -2
- package/dist/jsx/Sheet.mjs +20 -434
- package/dist/jsx/Sheet.mjs.map +2 -2
- package/dist/jsx/StyledSheet.js +100 -0
- package/dist/jsx/StyledSheet.js.map +6 -0
- package/dist/jsx/StyledSheet.mjs +100 -0
- package/dist/jsx/StyledSheet.mjs.map +6 -0
- package/dist/jsx/constants.js +2 -0
- package/dist/jsx/constants.js.map +1 -1
- package/dist/jsx/constants.mjs +2 -0
- package/dist/jsx/constants.mjs.map +1 -1
- package/dist/jsx/createSheet.js +438 -0
- package/dist/jsx/createSheet.js.map +6 -0
- package/dist/jsx/createSheet.mjs +438 -0
- package/dist/jsx/createSheet.mjs.map +6 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +2 -0
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/useSheet.js +6 -0
- package/dist/jsx/useSheet.js.map +6 -0
- package/dist/jsx/useSheet.mjs +6 -0
- package/dist/jsx/useSheet.mjs.map +6 -0
- package/dist/jsx/useSheetChildren.js +4 -2
- package/dist/jsx/useSheetChildren.js.map +1 -1
- package/dist/jsx/useSheetChildren.mjs +4 -2
- package/dist/jsx/useSheetChildren.mjs.map +1 -1
- package/package.json +13 -13
- package/src/Sheet.tsx +20 -543
- package/src/constants.tsx +1 -0
- package/src/createSheet.tsx +573 -0
- package/src/index.ts +2 -0
- package/src/useSheet.tsx +3 -0
- package/src/useSheetChildren.tsx +3 -1
- package/types/Sheet.d.ts +159 -80
- package/types/Sheet.d.ts.map +1 -1
- package/types/constants.d.ts +1 -0
- package/types/constants.d.ts.map +1 -1
- package/types/createSheet.d.ts +66 -0
- package/types/createSheet.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -1
- package/types/useSheet.d.ts +12 -0
- package/types/useSheet.d.ts.map +1 -0
- package/types/useSheetChildren.d.ts +1 -0
- package/types/useSheetChildren.d.ts.map +1 -1
package/dist/jsx/Sheet.js
CHANGED
|
@@ -1,51 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
3
|
-
import {
|
|
4
|
-
Theme,
|
|
5
|
-
isClient,
|
|
6
|
-
isTouchable,
|
|
7
|
-
isWeb,
|
|
8
|
-
mergeEvent,
|
|
9
|
-
styled,
|
|
10
|
-
themeable,
|
|
11
|
-
useAnimationDriver,
|
|
12
|
-
useDidFinishSSR,
|
|
13
|
-
useEvent,
|
|
14
|
-
useIsomorphicLayoutEffect,
|
|
15
|
-
useThemeName,
|
|
16
|
-
withStaticProperties
|
|
17
|
-
} from "@tamagui/core";
|
|
18
|
-
import { Portal } from "@tamagui/portal";
|
|
19
|
-
import { RemoveScroll } from "@tamagui/remove-scroll";
|
|
1
|
+
import { styled } from "@tamagui/core";
|
|
20
2
|
import { ThemeableStack, XStack, YStack } from "@tamagui/stacks";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
createContext,
|
|
24
|
-
forwardRef,
|
|
25
|
-
useCallback,
|
|
26
|
-
useContext,
|
|
27
|
-
useEffect,
|
|
28
|
-
useMemo,
|
|
29
|
-
useRef,
|
|
30
|
-
useState
|
|
31
|
-
} from "react";
|
|
32
|
-
import {
|
|
33
|
-
Keyboard,
|
|
34
|
-
PanResponder,
|
|
35
|
-
Platform
|
|
36
|
-
} from "react-native";
|
|
37
|
-
import { SHEET_HANDLE_NAME, SHEET_NAME } from "./constants";
|
|
38
|
-
import { getNativeSheet } from "./nativeSheet";
|
|
39
|
-
import { SheetProvider, useSheetContext } from "./SheetContext";
|
|
40
|
-
import { SheetScrollView } from "./SheetScrollView";
|
|
41
|
-
import { useSheetChildren } from "./useSheetChildren";
|
|
42
|
-
import { useSheetController } from "./useSheetController";
|
|
43
|
-
import { useSheetOpenState } from "./useSheetOpenState";
|
|
44
|
-
import { useSheetProviderProps } from "./useSheetProviderProps";
|
|
45
|
-
import { useSheetSnapPoints } from "./useSheetSnapPoints";
|
|
3
|
+
import { SHEET_HANDLE_NAME, SHEET_NAME, SHEET_OVERLAY_NAME } from "./constants";
|
|
4
|
+
import { createSheet } from "./createSheet";
|
|
46
5
|
import { createSheetScope } from "./SheetContext";
|
|
47
6
|
export * from "./types";
|
|
48
|
-
const
|
|
7
|
+
const Handle = styled(XStack, {
|
|
49
8
|
name: SHEET_HANDLE_NAME,
|
|
50
9
|
variants: {
|
|
51
10
|
open: {
|
|
@@ -76,31 +35,17 @@ const SheetHandleFrame = styled(XStack, {
|
|
|
76
35
|
unstyled: false
|
|
77
36
|
}
|
|
78
37
|
});
|
|
79
|
-
const
|
|
80
|
-
({ __scopeSheet, ...props }) => {
|
|
81
|
-
const context = useSheetContext(SHEET_HANDLE_NAME, __scopeSheet);
|
|
82
|
-
return <SheetHandleFrame
|
|
83
|
-
onPress={() => {
|
|
84
|
-
const max = context.snapPoints.length + (context.dismissOnSnapToBottom ? -1 : 0);
|
|
85
|
-
const nextPos = (context.position + 1) % max;
|
|
86
|
-
context.setPosition(nextPos);
|
|
87
|
-
}}
|
|
88
|
-
open={context.open}
|
|
89
|
-
{...props}
|
|
90
|
-
/>;
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
const SHEET_OVERLAY_NAME = "SheetOverlay";
|
|
94
|
-
const SheetOverlayFrame = styled(ThemeableStack, {
|
|
38
|
+
const Overlay = styled(ThemeableStack, {
|
|
95
39
|
name: SHEET_OVERLAY_NAME,
|
|
96
40
|
variants: {
|
|
97
|
-
|
|
41
|
+
open: {
|
|
98
42
|
true: {
|
|
99
|
-
opacity:
|
|
100
|
-
pointerEvents: "
|
|
43
|
+
opacity: 1,
|
|
44
|
+
pointerEvents: "auto"
|
|
101
45
|
},
|
|
102
46
|
false: {
|
|
103
|
-
|
|
47
|
+
opacity: 0,
|
|
48
|
+
pointerEvents: "none"
|
|
104
49
|
}
|
|
105
50
|
},
|
|
106
51
|
unstyled: {
|
|
@@ -116,26 +61,7 @@ const SheetOverlayFrame = styled(ThemeableStack, {
|
|
|
116
61
|
unstyled: false
|
|
117
62
|
}
|
|
118
63
|
});
|
|
119
|
-
const
|
|
120
|
-
({ __scopeSheet, ...props }) => {
|
|
121
|
-
const context = useSheetContext(SHEET_OVERLAY_NAME, __scopeSheet);
|
|
122
|
-
return <SheetOverlayFrame
|
|
123
|
-
closed={!context.open || context.hidden}
|
|
124
|
-
{...props}
|
|
125
|
-
onPress={mergeEvent(
|
|
126
|
-
props.onPress,
|
|
127
|
-
context.dismissOnOverlayPress ? () => {
|
|
128
|
-
context.setOpen(false);
|
|
129
|
-
} : void 0
|
|
130
|
-
)}
|
|
131
|
-
/>;
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
const selectionStyleSheet = isClient ? document.createElement("style") : null;
|
|
135
|
-
if (selectionStyleSheet) {
|
|
136
|
-
document.head.appendChild(selectionStyleSheet);
|
|
137
|
-
}
|
|
138
|
-
const SheetFrameFrame = styled(YStack, {
|
|
64
|
+
const Frame = styled(YStack, {
|
|
139
65
|
name: SHEET_NAME,
|
|
140
66
|
variants: {
|
|
141
67
|
unstyled: {
|
|
@@ -155,359 +81,19 @@ const SheetFrameFrame = styled(YStack, {
|
|
|
155
81
|
unstyled: false
|
|
156
82
|
}
|
|
157
83
|
});
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const composedContentRef = useComposedRefs(forwardedRef, context.contentRef);
|
|
163
|
-
return <SheetFrameFrame ref={composedContentRef} {...props} />;
|
|
164
|
-
}
|
|
165
|
-
)
|
|
166
|
-
);
|
|
167
|
-
const HIDDEN_SIZE = 1e4;
|
|
168
|
-
const sheetComponents = {
|
|
169
|
-
Handle: SheetHandle,
|
|
170
|
-
Frame: SheetFrame,
|
|
171
|
-
Overlay: SheetOverlay,
|
|
172
|
-
ScrollView: SheetScrollView
|
|
173
|
-
};
|
|
174
|
-
const ParentSheetContext = createContext({
|
|
175
|
-
zIndex: 1e5
|
|
84
|
+
const Sheet = createSheet({
|
|
85
|
+
Frame,
|
|
86
|
+
Handle,
|
|
87
|
+
Overlay
|
|
176
88
|
});
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
const hydrated = useDidFinishSSR();
|
|
180
|
-
const { isShowingNonSheet } = useSheetController();
|
|
181
|
-
let SheetImplementation = SheetImplementationCustom;
|
|
182
|
-
if (props.native && Platform.OS === "ios") {
|
|
183
|
-
if (process.env.TAMAGUI_TARGET === "native") {
|
|
184
|
-
const impl = getNativeSheet("ios");
|
|
185
|
-
if (impl) {
|
|
186
|
-
SheetImplementation = impl;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (isShowingNonSheet || !hydrated) {
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
return <SheetImplementation ref={ref} {...props} />;
|
|
194
|
-
}),
|
|
195
|
-
sheetComponents
|
|
196
|
-
);
|
|
197
|
-
const SheetImplementationCustom = themeable(
|
|
198
|
-
forwardRef(function SheetImplementationCustom2(props, forwardedRef) {
|
|
199
|
-
const parentSheet = useContext(ParentSheetContext);
|
|
200
|
-
const {
|
|
201
|
-
animationConfig,
|
|
202
|
-
forceRemoveScrollEnabled = null,
|
|
203
|
-
disableDrag: disableDragProp,
|
|
204
|
-
modal = false,
|
|
205
|
-
zIndex = parentSheet.zIndex + 1,
|
|
206
|
-
moveOnKeyboardChange = false,
|
|
207
|
-
portalProps
|
|
208
|
-
} = props;
|
|
209
|
-
const state = useSheetOpenState(props);
|
|
210
|
-
const providerProps = useSheetProviderProps(props, state);
|
|
211
|
-
const { positions, maxSnapPoint, screenSize } = useSheetSnapPoints(providerProps);
|
|
212
|
-
const { position, contentRef, setPosition, scrollBridge, frameSize, setFrameSize } = providerProps;
|
|
213
|
-
const { open, isHidden, controller } = state;
|
|
214
|
-
const { frameComponent, handleComponent, bottomCoverComponent, overlayComponent } = useSheetChildren(props.children);
|
|
215
|
-
const sheetRef = useRef(null);
|
|
216
|
-
const ref = useComposedRefs(forwardedRef, sheetRef);
|
|
217
|
-
const driver = useAnimationDriver();
|
|
218
|
-
if (!driver) {
|
|
219
|
-
throw new Error("Must set animations in tamagui.config.ts");
|
|
220
|
-
}
|
|
221
|
-
const disableDrag = disableDragProp ?? controller?.disableDrag;
|
|
222
|
-
const keyboardIsVisible = useKeyboardVisible();
|
|
223
|
-
const themeName = useThemeName();
|
|
224
|
-
const { useAnimatedNumber, useAnimatedNumberReaction, useAnimatedNumberStyle } = driver;
|
|
225
|
-
const animatedNumber = useAnimatedNumber(HIDDEN_SIZE);
|
|
226
|
-
const at = useRef(0);
|
|
227
|
-
useAnimatedNumberReaction(
|
|
228
|
-
{
|
|
229
|
-
value: animatedNumber,
|
|
230
|
-
hostRef: sheetRef
|
|
231
|
-
},
|
|
232
|
-
(value) => {
|
|
233
|
-
if (!driver.isReactNative)
|
|
234
|
-
return;
|
|
235
|
-
at.current = value;
|
|
236
|
-
scrollBridge.paneY = value;
|
|
237
|
-
}
|
|
238
|
-
);
|
|
239
|
-
function stopSpring() {
|
|
240
|
-
animatedNumber.stop();
|
|
241
|
-
if (scrollBridge.onFinishAnimate) {
|
|
242
|
-
scrollBridge.onFinishAnimate();
|
|
243
|
-
scrollBridge.onFinishAnimate = void 0;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
const [opacity, setOpacity] = useState(open ? 1 : 0);
|
|
247
|
-
if (open && opacity === 0) {
|
|
248
|
-
setOpacity(1);
|
|
249
|
-
}
|
|
250
|
-
useEffect(() => {
|
|
251
|
-
if (!open) {
|
|
252
|
-
const tm = setTimeout(() => {
|
|
253
|
-
setOpacity(0);
|
|
254
|
-
}, 400);
|
|
255
|
-
return () => {
|
|
256
|
-
clearTimeout(tm);
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
}, [open]);
|
|
260
|
-
const animateTo = useEvent((position2) => {
|
|
261
|
-
const current = animatedNumber.getValue();
|
|
262
|
-
if (isHidden && open)
|
|
263
|
-
return;
|
|
264
|
-
if (!current)
|
|
265
|
-
return;
|
|
266
|
-
if (frameSize === 0)
|
|
267
|
-
return;
|
|
268
|
-
const hiddenValue = frameSize === 0 ? HIDDEN_SIZE : screenSize;
|
|
269
|
-
const toValue = isHidden || position2 === -1 ? hiddenValue : positions[position2];
|
|
270
|
-
if (at.current === toValue)
|
|
271
|
-
return;
|
|
272
|
-
stopSpring();
|
|
273
|
-
if (isHidden) {
|
|
274
|
-
animatedNumber.setValue(toValue, {
|
|
275
|
-
type: "timing",
|
|
276
|
-
duration: 0
|
|
277
|
-
});
|
|
278
|
-
at.current = toValue;
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
const overshootClamping = at.current === HIDDEN_SIZE;
|
|
282
|
-
animatedNumber.setValue(toValue, {
|
|
283
|
-
...animationConfig,
|
|
284
|
-
type: "spring",
|
|
285
|
-
overshootClamping
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
useIsomorphicLayoutEffect(() => {
|
|
289
|
-
animateTo(position);
|
|
290
|
-
}, [isHidden, frameSize, position, animateTo]);
|
|
291
|
-
const [isShowingInnerSheet, setIsShowingInnerSheet] = useState(false);
|
|
292
|
-
const shouldHideParentSheet = !isWeb && modal && isShowingInnerSheet;
|
|
293
|
-
const parentSheetContext = useContext(SheetInsideSheetContext);
|
|
294
|
-
const onInnerSheet = useCallback((hasChild) => {
|
|
295
|
-
setIsShowingInnerSheet(hasChild);
|
|
296
|
-
}, []);
|
|
297
|
-
const panResponder = useMemo(
|
|
298
|
-
() => {
|
|
299
|
-
if (disableDrag)
|
|
300
|
-
return;
|
|
301
|
-
if (!frameSize)
|
|
302
|
-
return;
|
|
303
|
-
if (isShowingInnerSheet)
|
|
304
|
-
return;
|
|
305
|
-
const minY = positions[0];
|
|
306
|
-
scrollBridge.paneMinY = minY;
|
|
307
|
-
let startY = at.current;
|
|
308
|
-
function makeUnselectable(val) {
|
|
309
|
-
if (!selectionStyleSheet)
|
|
310
|
-
return;
|
|
311
|
-
if (!val) {
|
|
312
|
-
selectionStyleSheet.innerText = "";
|
|
313
|
-
} else {
|
|
314
|
-
selectionStyleSheet.innerText = ":root * { user-select: none !important; -webkit-user-select: none !important; }";
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
const release = ({ vy, dragAt }) => {
|
|
318
|
-
isExternalDrag = false;
|
|
319
|
-
previouslyScrolling = false;
|
|
320
|
-
makeUnselectable(false);
|
|
321
|
-
const at2 = dragAt + startY;
|
|
322
|
-
const end = at2 + frameSize * vy * 0.2;
|
|
323
|
-
let closestPoint = 0;
|
|
324
|
-
let dist = Infinity;
|
|
325
|
-
for (let i = 0; i < positions.length; i++) {
|
|
326
|
-
const position2 = positions[i];
|
|
327
|
-
const curDist = end > position2 ? end - position2 : position2 - end;
|
|
328
|
-
if (curDist < dist) {
|
|
329
|
-
dist = curDist;
|
|
330
|
-
closestPoint = i;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
setPosition(closestPoint);
|
|
334
|
-
animateTo(closestPoint);
|
|
335
|
-
};
|
|
336
|
-
const finish = (_e, state2) => {
|
|
337
|
-
release({
|
|
338
|
-
vy: state2.vy,
|
|
339
|
-
dragAt: state2.dy
|
|
340
|
-
});
|
|
341
|
-
};
|
|
342
|
-
let previouslyScrolling = false;
|
|
343
|
-
const onMoveShouldSet = (_e, { dy }) => {
|
|
344
|
-
const isScrolled = scrollBridge.y !== 0;
|
|
345
|
-
const isDraggingUp = dy < 0;
|
|
346
|
-
const isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
|
|
347
|
-
if (isScrolled) {
|
|
348
|
-
previouslyScrolling = true;
|
|
349
|
-
return false;
|
|
350
|
-
}
|
|
351
|
-
if (isNearTop) {
|
|
352
|
-
if (!isScrolled && isDraggingUp) {
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return Math.abs(dy) > 5;
|
|
357
|
-
};
|
|
358
|
-
const grant = () => {
|
|
359
|
-
makeUnselectable(true);
|
|
360
|
-
stopSpring();
|
|
361
|
-
startY = at.current;
|
|
362
|
-
};
|
|
363
|
-
let isExternalDrag = false;
|
|
364
|
-
scrollBridge.drag = (dy) => {
|
|
365
|
-
if (!isExternalDrag) {
|
|
366
|
-
isExternalDrag = true;
|
|
367
|
-
grant();
|
|
368
|
-
}
|
|
369
|
-
const to = dy + startY;
|
|
370
|
-
animatedNumber.setValue(resisted(to, minY), { type: "direct" });
|
|
371
|
-
};
|
|
372
|
-
scrollBridge.release = release;
|
|
373
|
-
return PanResponder.create({
|
|
374
|
-
onMoveShouldSetPanResponder: onMoveShouldSet,
|
|
375
|
-
onPanResponderGrant: grant,
|
|
376
|
-
onPanResponderMove: (_e, { dy }) => {
|
|
377
|
-
const toFull = dy + startY;
|
|
378
|
-
const to = resisted(toFull, minY);
|
|
379
|
-
animatedNumber.setValue(to, { type: "direct" });
|
|
380
|
-
},
|
|
381
|
-
onPanResponderEnd: finish,
|
|
382
|
-
onPanResponderTerminate: finish,
|
|
383
|
-
onPanResponderRelease: finish
|
|
384
|
-
});
|
|
385
|
-
},
|
|
386
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
387
|
-
[disableDrag, isShowingInnerSheet, animateTo, frameSize, positions, setPosition]
|
|
388
|
-
);
|
|
389
|
-
const animatedStyle = useAnimatedNumberStyle(animatedNumber, (val) => {
|
|
390
|
-
"worklet";
|
|
391
|
-
const translateY = frameSize === 0 ? HIDDEN_SIZE : val;
|
|
392
|
-
return {
|
|
393
|
-
transform: [{ translateY }]
|
|
394
|
-
};
|
|
395
|
-
});
|
|
396
|
-
const sizeBeforeKeyboard = useRef(null);
|
|
397
|
-
useEffect(() => {
|
|
398
|
-
if (isWeb || !moveOnKeyboardChange)
|
|
399
|
-
return;
|
|
400
|
-
const keyboardDidShowListener = Keyboard.addListener("keyboardDidShow", (e) => {
|
|
401
|
-
if (sizeBeforeKeyboard.current !== null)
|
|
402
|
-
return;
|
|
403
|
-
sizeBeforeKeyboard.current = animatedNumber.getValue();
|
|
404
|
-
animatedNumber.setValue(
|
|
405
|
-
Math.max(animatedNumber.getValue() - e.endCoordinates.height, 0)
|
|
406
|
-
);
|
|
407
|
-
});
|
|
408
|
-
const keyboardDidHideListener = Keyboard.addListener("keyboardDidHide", () => {
|
|
409
|
-
if (sizeBeforeKeyboard.current === null)
|
|
410
|
-
return;
|
|
411
|
-
animatedNumber.setValue(sizeBeforeKeyboard.current);
|
|
412
|
-
sizeBeforeKeyboard.current = null;
|
|
413
|
-
});
|
|
414
|
-
return () => {
|
|
415
|
-
keyboardDidHideListener.remove();
|
|
416
|
-
keyboardDidShowListener.remove();
|
|
417
|
-
};
|
|
418
|
-
}, []);
|
|
419
|
-
const AnimatedView = driver["NumberView"] ?? driver.View;
|
|
420
|
-
useIsomorphicLayoutEffect(() => {
|
|
421
|
-
if (!(parentSheetContext && open))
|
|
422
|
-
return;
|
|
423
|
-
parentSheetContext(true);
|
|
424
|
-
return () => {
|
|
425
|
-
parentSheetContext(false);
|
|
426
|
-
};
|
|
427
|
-
}, [parentSheetContext, open]);
|
|
428
|
-
const nextParentContext = useMemo(
|
|
429
|
-
() => ({
|
|
430
|
-
zIndex
|
|
431
|
-
}),
|
|
432
|
-
[zIndex]
|
|
433
|
-
);
|
|
434
|
-
const handleLayout = useCallback(
|
|
435
|
-
(e) => {
|
|
436
|
-
let next = e.nativeEvent?.layout.height;
|
|
437
|
-
if (isWeb && isTouchable && !open) {
|
|
438
|
-
next += 100;
|
|
439
|
-
}
|
|
440
|
-
if (!next)
|
|
441
|
-
return;
|
|
442
|
-
setFrameSize(() => next);
|
|
443
|
-
},
|
|
444
|
-
[keyboardIsVisible]
|
|
445
|
-
);
|
|
446
|
-
const removeScrollEnabled = forceRemoveScrollEnabled ?? (open && modal);
|
|
447
|
-
const contents = <ParentSheetContext.Provider value={nextParentContext}><SheetProvider {...providerProps}>
|
|
448
|
-
{shouldHideParentSheet ? null : overlayComponent}
|
|
449
|
-
<AnimatedView
|
|
450
|
-
ref={ref}
|
|
451
|
-
{...panResponder?.panHandlers}
|
|
452
|
-
onLayout={handleLayout}
|
|
453
|
-
pointerEvents={open && !shouldHideParentSheet ? "auto" : "none"}
|
|
454
|
-
animation={props.animation}
|
|
455
|
-
style={[
|
|
456
|
-
{
|
|
457
|
-
position: "absolute",
|
|
458
|
-
zIndex,
|
|
459
|
-
width: "100%",
|
|
460
|
-
height: `${maxSnapPoint}%`,
|
|
461
|
-
opacity
|
|
462
|
-
},
|
|
463
|
-
animatedStyle
|
|
464
|
-
]}
|
|
465
|
-
>
|
|
466
|
-
{handleComponent}
|
|
467
|
-
{bottomCoverComponent}
|
|
468
|
-
{
|
|
469
|
-
/* @ts-ignore */
|
|
470
|
-
}
|
|
471
|
-
<RemoveScroll
|
|
472
|
-
forwardProps
|
|
473
|
-
enabled={removeScrollEnabled}
|
|
474
|
-
allowPinchZoom
|
|
475
|
-
shards={[contentRef]}
|
|
476
|
-
removeScrollBar={false}
|
|
477
|
-
>{frameComponent}</RemoveScroll>
|
|
478
|
-
</AnimatedView>
|
|
479
|
-
</SheetProvider></ParentSheetContext.Provider>;
|
|
480
|
-
const adaptContext = useContext(AdaptParentContext);
|
|
481
|
-
if (modal) {
|
|
482
|
-
const modalContents = <Portal zIndex={zIndex} {...portalProps}><Theme forceClassName name={themeName}><AdaptParentContext.Provider value={adaptContext}>{contents}</AdaptParentContext.Provider></Theme></Portal>;
|
|
483
|
-
if (isWeb) {
|
|
484
|
-
return modalContents;
|
|
485
|
-
}
|
|
486
|
-
return <SheetInsideSheetContext.Provider value={onInnerSheet}>{modalContents}</SheetInsideSheetContext.Provider>;
|
|
487
|
-
}
|
|
488
|
-
return contents;
|
|
489
|
-
})
|
|
490
|
-
);
|
|
491
|
-
const SheetInsideSheetContext = createContext(null);
|
|
492
|
-
const ControlledSheet = Sheet;
|
|
493
|
-
function resisted(y, minY, maxOverflow = 25) {
|
|
494
|
-
if (y < minY) {
|
|
495
|
-
const past = minY - y;
|
|
496
|
-
const pctPast = Math.min(maxOverflow, past) / maxOverflow;
|
|
497
|
-
const diminishBy = 1.1 - Math.pow(0.1, pctPast);
|
|
498
|
-
const extra = -diminishBy * maxOverflow;
|
|
499
|
-
return minY + extra;
|
|
500
|
-
}
|
|
501
|
-
return y;
|
|
502
|
-
}
|
|
89
|
+
const SheetOverlayFrame = Overlay;
|
|
90
|
+
const SheetHandleFrame = Handle;
|
|
503
91
|
export {
|
|
504
|
-
|
|
92
|
+
Frame,
|
|
93
|
+
Handle,
|
|
94
|
+
Overlay,
|
|
505
95
|
Sheet,
|
|
506
|
-
SheetFrame,
|
|
507
|
-
SheetFrameFrame,
|
|
508
|
-
SheetHandle,
|
|
509
96
|
SheetHandleFrame,
|
|
510
|
-
SheetOverlay,
|
|
511
97
|
SheetOverlayFrame,
|
|
512
98
|
createSheetScope
|
|
513
99
|
};
|
package/dist/jsx/Sheet.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Sheet.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,gBAAgB,QAAQ,cAAc;AAE/C,SAAS,mBAAmB,YAAY,0BAA0B;AAClE,SAAS,mBAAmB;AAE5B,SAAS,wBAAwB;AACjC,cAAc;AAMP,MAAM,SAAS,OAAO,QAAQ;AAAA,EACnC,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,MAAM;AAAA,QACJ,eAAe;AAAA,MACjB;AAAA,MACA,OAAO;AAAA,QACL,SAAS;AAAA,QACT,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,OAAO;AAAA,QACL,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,QAAQ;AAAA,QACR,kBAAkB;AAAA,QAClB,cAAc;AAAA,QACd,SAAS;AAAA,QAET,YAAY;AAAA,UACV,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAMM,MAAM,UAAU,OAAO,gBAAgB;AAAA,EAC5C,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,eAAe;AAAA,MACjB;AAAA,MACA,OAAO;AAAA,QACL,SAAS;AAAA,QACT,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,OAAO;AAAA,QACL,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,cAAc;AAAA,QACd,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAMM,MAAM,QAAQ,OAAO,QAAQ;AAAA,EAClC,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,QACN,iBAAiB;AAAA,QACjB,qBAAqB;AAAA,QACrB,sBAAsB;AAAA,QACtB,OAAO;AAAA,QACP,WAAW;AAAA,QACX,UAAU;AAAA,QACV,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAEM,MAAM,QAAQ,YAAY;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,MAAM,oBAAoB;AAG1B,MAAM,mBAAmB;",
|
|
5
|
+
"names": []
|
|
6
6
|
}
|