@vvedantb/native-ui 0.17.2 → 0.18.0
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/AlertDialog.jsx +123 -0
- package/dist/AmbientBackground.jsx +73 -0
- package/dist/ArtifactList.jsx +59 -0
- package/dist/Avatar.jsx +285 -0
- package/dist/Badge.jsx +154 -0
- package/dist/BottomSheetContainer.jsx +208 -0
- package/dist/BulkActionBar.jsx +717 -0
- package/dist/Button.jsx +344 -0
- package/dist/CaptureButton.jsx +104 -0
- package/dist/Card.jsx +371 -0
- package/dist/Checkbox.jsx +177 -0
- package/dist/Chip.jsx +79 -0
- package/dist/ColorSwatches.jsx +159 -0
- package/dist/ConfirmDialog.jsx +157 -0
- package/dist/DateTimeField.jsx +204 -0
- package/dist/Dialog.jsx +614 -0
- package/dist/DividedList.jsx +120 -0
- package/dist/DropdownMenu.jsx +849 -0
- package/dist/EmptyState.jsx +434 -0
- package/dist/ExpoWebRoot.jsx +134 -0
- package/dist/FloatingFAB.jsx +95 -0
- package/dist/FloatingSurface.jsx +226 -0
- package/dist/FloatingTabBar.jsx +403 -0
- package/dist/HeaderIconButton.jsx +53 -0
- package/dist/IconButton.jsx +157 -0
- package/dist/Input.jsx +96 -0
- package/dist/Label.jsx +96 -0
- package/dist/LabeledSwitchRow.jsx +170 -0
- package/dist/LiquidGlass.jsx +2 -0
- package/dist/ListRow.jsx +281 -0
- package/dist/LoadingState.jsx +205 -0
- package/dist/PageIndicator.jsx +128 -0
- package/dist/PageTitle.jsx +205 -0
- package/dist/Pager.jsx +105 -0
- package/dist/PasswordInput.jsx +120 -0
- package/dist/PillTabs.jsx +300 -0
- package/dist/PinnedBotTile.jsx +212 -0
- package/dist/Progress.jsx +147 -0
- package/dist/SafeAreaContainer.jsx +38 -0
- package/dist/ScreenContainer.jsx +117 -0
- package/dist/SearchInput.jsx +150 -0
- package/dist/SectionLabel.jsx +128 -0
- package/dist/Select.jsx +223 -0
- package/dist/Separator.jsx +95 -0
- package/dist/Sheet.jsx +343 -0
- package/dist/SheetRow.jsx +198 -0
- package/dist/Skeleton.jsx +311 -0
- package/dist/Spinner.jsx +195 -0
- package/dist/StackPageHeader.jsx +160 -0
- package/dist/StatGrid.jsx +74 -0
- package/dist/StatusDot.jsx +129 -0
- package/dist/SurfaceRow.jsx +143 -0
- package/dist/SwipeableRow.jsx +50 -0
- package/dist/Switch.jsx +130 -0
- package/dist/Tabs.jsx +385 -0
- package/dist/Textarea.jsx +103 -0
- package/dist/ThemeToggle.jsx +78 -0
- package/dist/Toast.jsx +396 -0
- package/dist/ai/activity-step-detail.jsx +179 -0
- package/dist/ai/activity-step-label.js +816 -0
- package/dist/ai/activity-step-types.js +14 -0
- package/dist/ai/activity-step.jsx +98 -0
- package/dist/ai/activity-tasks-utils.js +172 -0
- package/dist/ai/activity-timeline.js +47 -0
- package/dist/ai/attachments.jsx +258 -0
- package/dist/ai/card-button.jsx +188 -0
- package/dist/ai/chain-of-thought.jsx +459 -0
- package/dist/ai/chat-jump-rail.jsx +57 -0
- package/dist/ai/chat-text.js +44 -0
- package/dist/ai/chat-thread.jsx +135 -0
- package/dist/ai/choice-question.jsx +925 -0
- package/dist/ai/code-block.jsx +574 -0
- package/dist/ai/collapsible.jsx +275 -0
- package/dist/ai/conversation.jsx +723 -0
- package/dist/ai/file-chip.jsx +198 -0
- package/dist/ai/icon-button.jsx +179 -0
- package/dist/ai/index.js +37 -0
- package/dist/ai/message-action-sheet.jsx +408 -0
- package/dist/ai/message-quote.jsx +241 -0
- package/dist/ai/message.jsx +739 -0
- package/dist/ai/prompt-input-menu.jsx +365 -0
- package/dist/ai/prompt-input.jsx +626 -0
- package/dist/ai/reasoning.jsx +446 -0
- package/dist/ai/reply-quote-chip.jsx +278 -0
- package/dist/ai/response-text.jsx +130 -0
- package/dist/ai/shimmer.jsx +149 -0
- package/dist/ai/sources.jsx +260 -0
- package/dist/ai/subagent-cards.jsx +645 -0
- package/dist/ai/suggestion.jsx +186 -0
- package/dist/ai/tool-approval-card.jsx +359 -0
- package/dist/ai/trace.jsx +728 -0
- package/dist/ai/unified-diff.jsx +280 -0
- package/dist/ai/use-streaming-disclosure.js +70 -0
- package/dist/auth/AuthProviders.jsx +27 -0
- package/dist/auth/AuthScreen.jsx +292 -0
- package/dist/auth/GoogleSignInButton.jsx +188 -0
- package/dist/auth/SecondFactorScreen.jsx +133 -0
- package/dist/auth/SignInScreen.jsx +482 -0
- package/dist/auth/authErrors.js +131 -0
- package/dist/auth/index.js +11 -0
- package/dist/auth/totp.js +378 -0
- package/dist/blur.js +36 -0
- package/dist/brand/AppIcons.jsx +118 -0
- package/dist/brand/AppMark.jsx +128 -0
- package/dist/brand/AppWordmark.jsx +138 -0
- package/dist/brand/GoogleMark.jsx +71 -0
- package/dist/brand/ProviderIcon.jsx +192 -0
- package/dist/brand/familyApps.js +33 -0
- package/dist/brand/index.js +11 -0
- package/dist/brand/svg.js +252 -0
- package/dist/brand/vProAppBenefits.js +19 -0
- package/dist/cn.js +5 -0
- package/dist/colors.js +15 -0
- package/dist/configureTheme.js +72 -0
- package/dist/controlStyles.js +520 -0
- package/dist/definiteSize.js +12 -0
- package/dist/dialogLayout.js +18 -0
- package/dist/entries/ai.js +4 -0
- package/dist/entries/ambient.js +3 -0
- package/dist/entries/auth.js +5 -0
- package/dist/entries/bottom-sheet.js +2 -0
- package/dist/entries/brand.js +2 -0
- package/dist/entries/button.js +2 -0
- package/dist/entries/date-time.js +3 -0
- package/dist/entries/expo-router.js +4 -0
- package/dist/entries/expo-web-root.js +3 -0
- package/dist/entries/floating.js +7 -0
- package/dist/entries/gesture-handler.js +4 -0
- package/dist/entries/keyboard-controller.js +4 -0
- package/dist/entries/layout.js +16 -0
- package/dist/entries/markdown.js +4 -0
- package/dist/entries/marketing.js +3 -0
- package/dist/entries/page-title.js +7 -0
- package/dist/entries/password-input.js +3 -0
- package/dist/entries/primitives.js +57 -0
- package/dist/entries/search-input.js +3 -0
- package/dist/entries/tab-bar.js +4 -0
- package/dist/entries/theme.js +7 -0
- package/dist/entries/toast.js +5 -0
- package/dist/entries/video.js +3 -0
- package/dist/entries/webview.js +4 -0
- package/dist/examples/AiChatGallery.jsx +509 -0
- package/dist/examples/ParityGallery.jsx +1307 -0
- package/dist/floating.js +62 -0
- package/dist/glassBlur.jsx +145 -0
- package/dist/gradient.js +17 -0
- package/dist/haptics.js +44 -0
- package/dist/highlight.js +382 -0
- package/dist/index.js +85 -0
- package/dist/initials.js +4 -0
- package/dist/loadingGrid.js +81 -0
- package/dist/markdown/Markdown.jsx +515 -0
- package/dist/markdown/MarkdownTable.jsx +443 -0
- package/dist/markdown/tableText.js +68 -0
- package/dist/marketing/PricingModal.jsx +608 -0
- package/dist/marketing/UpgradeToProCard.jsx +164 -0
- package/dist/marketing/pricing.js +34 -0
- package/dist/media/ImageGallery.jsx +580 -0
- package/dist/media/MediaCard.jsx +162 -0
- package/dist/media/imageGrid.js +54 -0
- package/dist/motion.js +33 -0
- package/dist/pagerSwipe.js +104 -0
- package/dist/palette.js +104 -0
- package/dist/primitives/button.jsx +127 -0
- package/dist/primitives/card.jsx +249 -0
- package/dist/primitives/icon.jsx +37 -0
- package/dist/primitives/input.jsx +56 -0
- package/dist/primitives/keyboard-controller.jsx +207 -0
- package/dist/primitives/keyboard-parts.jsx +75 -0
- package/dist/primitives/native-only-animated-view.jsx +68 -0
- package/dist/primitives/overlay.jsx +391 -0
- package/dist/primitives/pager-gesture.jsx +131 -0
- package/dist/primitives/select-host.jsx +103 -0
- package/dist/primitives/select.jsx +555 -0
- package/dist/primitives/sheet-drag.jsx +420 -0
- package/dist/primitives/sheet-gesture.jsx +219 -0
- package/dist/primitives/swipe-row-gesture.jsx +341 -0
- package/dist/primitives/switch.jsx +105 -0
- package/dist/primitives/text.jsx +145 -0
- package/dist/primitives/toast-drag-gesture.jsx +94 -0
- package/dist/primitives/use-controllable-state.js +40 -0
- package/dist/primitives/web-click-guard.js +69 -0
- package/dist/push.js +166 -0
- package/dist/relativeTime.js +70 -0
- package/dist/router/RouterStackPageHeader.jsx +53 -0
- package/dist/selectA11y.js +32 -0
- package/dist/settings/MoreFromProjectV.jsx +168 -0
- package/dist/settings/SettingsEmptyState.jsx +102 -0
- package/dist/settings/SettingsField.jsx +49 -0
- package/dist/settings/SettingsSection.jsx +101 -0
- package/dist/settings/SettingsStack.jsx +17 -0
- package/dist/settings/SettingsToggleRow.jsx +163 -0
- package/dist/settings/projectVMobileApps.js +126 -0
- package/dist/settings/relaxedSizeStyle.js +11 -0
- package/dist/sheetDrag.js +76 -0
- package/dist/svgA11y.js +46 -0
- package/dist/swipeRow.js +161 -0
- package/dist/tabBarRoutes.js +41 -0
- package/dist/tabIndicator.js +139 -0
- package/dist/tailwind-preset.cjs +255 -0
- package/dist/tailwind-preset.d.cts +55 -0
- package/dist/theme.jsx +62 -0
- package/dist/toastChrome.js +110 -0
- package/dist/toastDrag.js +51 -0
- package/dist/toastStore.js +54 -0
- package/dist/tokens.js +70 -0
- package/dist/typography.js +40 -0
- package/dist/useReduceMotion.js +32 -0
- package/dist/useReduceTransparency.js +27 -0
- package/dist/useScheme.js +15 -0
- package/dist/video/InlineVideo.jsx +115 -0
- package/dist/webview/HtmlView.jsx +169 -0
- package/dist/webview/HtmlView.web.jsx +63 -0
- package/dist/webview/htmlView.js +43 -0
- package/package.json +70 -33
- package/src/DropdownMenu.tsx +28 -16
- package/src/FloatingTabBar.tsx +78 -41
- package/src/ai/conversation.tsx +12 -8
- package/src/glassBlur.tsx +47 -22
- package/src/primitives/swipe-row-gesture.tsx +11 -2
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { createContext, useContext, useState } from "react";
|
|
3
|
+
import { PanResponder, ScrollView, View, useWindowDimensions } from "react-native";
|
|
4
|
+
import Animated, { cancelAnimation, interpolate, runOnJS, useAnimatedReaction, useAnimatedStyle, useSharedValue, withSpring } from "react-native-reanimated";
|
|
5
|
+
import { impactHaptic } from "../haptics";
|
|
6
|
+
import { SHEET_SNAP_SPRING, SHEET_SPRING } from "../motion";
|
|
7
|
+
import { isSheetDragDown, SHEET_OVERPULL, sheetDragDismisses, sheetDragOffset, sheetSnapVelocity } from "../sheetDrag";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The live state of one open overlay's motion, shared by the sheet (which
|
|
11
|
+
* moves), the backdrop (which fades with it) and a `DialogBody` / `SheetBody`
|
|
12
|
+
* inside (which reports its scroll, so a drag only takes over at the top).
|
|
13
|
+
* One `offset` drives the slide in, the drag, the release and the slide out,
|
|
14
|
+
* so each can take over from the others mid-flight. Shared values, so the
|
|
15
|
+
* motion runs on the UI thread and a drag re-renders nothing per move.
|
|
16
|
+
* `dragging` is for the `PanResponder` drag only; the Gesture Handler drag
|
|
17
|
+
* (`SheetGestureParts`) holds the body still on the UI thread instead.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const SheetDragContext = createContext(null);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Makes the motion state for one open overlay and closes it once a drag
|
|
24
|
+
* flung the sheet out. Call it inside the `Modal`, so each opening starts
|
|
25
|
+
* fresh: below the screen when `slides`, else at rest.
|
|
26
|
+
*/
|
|
27
|
+
export function useSheetDragState(close, slides) {
|
|
28
|
+
const $ = _c(8);
|
|
29
|
+
const window = useWindowDimensions();
|
|
30
|
+
const offset = useSharedValue(slides ? window.height : 0);
|
|
31
|
+
const height = useSharedValue(0);
|
|
32
|
+
const scrollTop = useSharedValue(0);
|
|
33
|
+
const dismissed = useSharedValue(false);
|
|
34
|
+
const closing = useSharedValue(false);
|
|
35
|
+
const [dragging, setDragging] = useState(false);
|
|
36
|
+
useAnimatedReaction(() => dismissed.get(), (done, previous) => {
|
|
37
|
+
if (done && !previous) {
|
|
38
|
+
runOnJS(close)();
|
|
39
|
+
}
|
|
40
|
+
}, [close]);
|
|
41
|
+
let t0;
|
|
42
|
+
if ($[0] !== closing || $[1] !== dismissed || $[2] !== dragging || $[3] !== height || $[4] !== offset || $[5] !== scrollTop || $[6] !== slides) {
|
|
43
|
+
t0 = {
|
|
44
|
+
offset,
|
|
45
|
+
height,
|
|
46
|
+
scrollTop,
|
|
47
|
+
dismissed,
|
|
48
|
+
closing,
|
|
49
|
+
slides,
|
|
50
|
+
dragging,
|
|
51
|
+
setDragging
|
|
52
|
+
};
|
|
53
|
+
$[0] = closing;
|
|
54
|
+
$[1] = dismissed;
|
|
55
|
+
$[2] = dragging;
|
|
56
|
+
$[3] = height;
|
|
57
|
+
$[4] = offset;
|
|
58
|
+
$[5] = scrollTop;
|
|
59
|
+
$[6] = slides;
|
|
60
|
+
$[7] = t0;
|
|
61
|
+
} else {
|
|
62
|
+
t0 = $[7];
|
|
63
|
+
}
|
|
64
|
+
return t0;
|
|
65
|
+
}
|
|
66
|
+
export const SheetDragProvider = SheetDragContext.Provider;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The Gesture Handler build of the sheet parts, from
|
|
70
|
+
* `@vvedantb/native-ui/gesture-handler`. Without it (the peer is optional)
|
|
71
|
+
* the sheets drag with `PanResponder`. A context, so only that entry imports
|
|
72
|
+
* `react-native-gesture-handler` and an app without it bundles as before.
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
export const SheetGestureContext = createContext(null);
|
|
76
|
+
|
|
77
|
+
/** The backdrop's opacity, from the sheet's offset: 1 at rest, 0 with the sheet out of sight. */
|
|
78
|
+
export function useSheetBackdropStyle(drag) {
|
|
79
|
+
return useAnimatedStyle(() => {
|
|
80
|
+
const height = drag.height.get();
|
|
81
|
+
if (height === 0) {
|
|
82
|
+
return {
|
|
83
|
+
opacity: drag.offset.get() > 0 ? 0 : 1
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
opacity: interpolate(drag.offset.get(), [0, height], [1, 0], "clamp")
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Springs a sheet that is sliding out back to rest: the overlay opened again. */
|
|
93
|
+
export function slideSheetIn(drag) {
|
|
94
|
+
drag.closing.set(false);
|
|
95
|
+
if (drag.height.get() > 0) drag.offset.set(withSpring(0, SHEET_SPRING));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Slides the sheet down out of sight, then calls `done` (which hides the `Modal`). */
|
|
99
|
+
export function slideSheetOut(drag, done) {
|
|
100
|
+
drag.closing.set(true);
|
|
101
|
+
drag.offset.set(withSpring(drag.height.get(), SHEET_SPRING, finished => {
|
|
102
|
+
"worklet";
|
|
103
|
+
|
|
104
|
+
if (finished) runOnJS(done)();
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A scroll view that hands a downward drag to the sheet around it: the drag
|
|
110
|
+
* moves the sheet only once the content is scrolled to its top, and the
|
|
111
|
+
* content holds still while the sheet follows the finger. With
|
|
112
|
+
* `react-native-gesture-handler` (`SheetGestureParts`) both run on the UI
|
|
113
|
+
* thread; with `PanResponder`, `onScroll` reports the offset and
|
|
114
|
+
* `scrollEnabled` is off during a drag, so the native scroll does not take
|
|
115
|
+
* the touch over (Android and iOS would cancel the drag). Outside a sheet, a
|
|
116
|
+
* plain `ScrollView`.
|
|
117
|
+
*/
|
|
118
|
+
export function SheetScrollView(props) {
|
|
119
|
+
const $ = _c(13);
|
|
120
|
+
const drag = useContext(SheetDragContext);
|
|
121
|
+
const gestures = useContext(SheetGestureContext);
|
|
122
|
+
if (!drag) {
|
|
123
|
+
let t0;
|
|
124
|
+
if ($[0] !== props) {
|
|
125
|
+
t0 = <ScrollView {...props} />;
|
|
126
|
+
$[0] = props;
|
|
127
|
+
$[1] = t0;
|
|
128
|
+
} else {
|
|
129
|
+
t0 = $[1];
|
|
130
|
+
}
|
|
131
|
+
return t0;
|
|
132
|
+
}
|
|
133
|
+
if (gestures) {
|
|
134
|
+
let t0;
|
|
135
|
+
if ($[2] !== drag || $[3] !== gestures.ScrollView || $[4] !== props) {
|
|
136
|
+
t0 = <gestures.ScrollView {...props} drag={drag} />;
|
|
137
|
+
$[2] = drag;
|
|
138
|
+
$[3] = gestures.ScrollView;
|
|
139
|
+
$[4] = props;
|
|
140
|
+
$[5] = t0;
|
|
141
|
+
} else {
|
|
142
|
+
t0 = $[5];
|
|
143
|
+
}
|
|
144
|
+
return t0;
|
|
145
|
+
}
|
|
146
|
+
const {
|
|
147
|
+
onScroll,
|
|
148
|
+
scrollEnabled: t0
|
|
149
|
+
} = props;
|
|
150
|
+
const scrollEnabled = t0 === undefined ? true : t0;
|
|
151
|
+
const t1 = scrollEnabled && !drag.dragging;
|
|
152
|
+
let t2;
|
|
153
|
+
if ($[6] !== drag.scrollTop || $[7] !== onScroll) {
|
|
154
|
+
t2 = event => {
|
|
155
|
+
drag.scrollTop.set(event.nativeEvent.contentOffset.y);
|
|
156
|
+
onScroll?.(event);
|
|
157
|
+
};
|
|
158
|
+
$[6] = drag.scrollTop;
|
|
159
|
+
$[7] = onScroll;
|
|
160
|
+
$[8] = t2;
|
|
161
|
+
} else {
|
|
162
|
+
t2 = $[8];
|
|
163
|
+
}
|
|
164
|
+
let t3;
|
|
165
|
+
if ($[9] !== props || $[10] !== t1 || $[11] !== t2) {
|
|
166
|
+
t3 = <ScrollView {...props} scrollEnabled={t1} onScroll={t2} />;
|
|
167
|
+
$[9] = props;
|
|
168
|
+
$[10] = t1;
|
|
169
|
+
$[11] = t2;
|
|
170
|
+
$[12] = t3;
|
|
171
|
+
} else {
|
|
172
|
+
t3 = $[12];
|
|
173
|
+
}
|
|
174
|
+
return t3;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The part of a bottom sheet that follows the finger. A drag down from
|
|
179
|
+
* anywhere on it (rows included; a body only when scrolled to its top) moves
|
|
180
|
+
* the sheet 1:1 and fades the backdrop. A touch on a sheet still sliding in,
|
|
181
|
+
* springing home or flung out catches it where it is. On release the sheet
|
|
182
|
+
* springs on at the finger's speed: a quick flick or a drag past half the
|
|
183
|
+
* sheet carries it out and closes the overlay; a slow, short drag springs it
|
|
184
|
+
* home, with a light haptic. Pulled up past rest, it gives a little, with
|
|
185
|
+
* resistance. On its first layout it slides in from below when `slides`.
|
|
186
|
+
* With Reduce Motion on it still follows the finger, and the release settles
|
|
187
|
+
* at once. `enabled={false}` (a sheet that may not be dismissed) leaves it
|
|
188
|
+
* still under the finger. The drag runs on Gesture Handler when the app
|
|
189
|
+
* provides it (`SheetGestureParts`), else on `PanResponder`.
|
|
190
|
+
*/
|
|
191
|
+
export function SheetDragView(t0) {
|
|
192
|
+
const $ = _c(14);
|
|
193
|
+
const {
|
|
194
|
+
enabled,
|
|
195
|
+
style,
|
|
196
|
+
children
|
|
197
|
+
} = t0;
|
|
198
|
+
const drag = useContext(SheetDragContext);
|
|
199
|
+
const gestures = useContext(SheetGestureContext);
|
|
200
|
+
if (!drag) {
|
|
201
|
+
let t1;
|
|
202
|
+
if ($[0] !== children || $[1] !== style) {
|
|
203
|
+
t1 = <View style={style}>{children}</View>;
|
|
204
|
+
$[0] = children;
|
|
205
|
+
$[1] = style;
|
|
206
|
+
$[2] = t1;
|
|
207
|
+
} else {
|
|
208
|
+
t1 = $[2];
|
|
209
|
+
}
|
|
210
|
+
return t1;
|
|
211
|
+
}
|
|
212
|
+
if (gestures) {
|
|
213
|
+
let t1;
|
|
214
|
+
if ($[3] !== children || $[4] !== drag || $[5] !== enabled || $[6] !== gestures.DragView || $[7] !== style) {
|
|
215
|
+
t1 = <gestures.DragView drag={drag} enabled={enabled} style={style}>{children}</gestures.DragView>;
|
|
216
|
+
$[3] = children;
|
|
217
|
+
$[4] = drag;
|
|
218
|
+
$[5] = enabled;
|
|
219
|
+
$[6] = gestures.DragView;
|
|
220
|
+
$[7] = style;
|
|
221
|
+
$[8] = t1;
|
|
222
|
+
} else {
|
|
223
|
+
t1 = $[8];
|
|
224
|
+
}
|
|
225
|
+
return t1;
|
|
226
|
+
}
|
|
227
|
+
let t1;
|
|
228
|
+
if ($[9] !== children || $[10] !== drag || $[11] !== enabled || $[12] !== style) {
|
|
229
|
+
t1 = <PanResponderDragView drag={drag} enabled={enabled} style={style}>{children}</PanResponderDragView>;
|
|
230
|
+
$[9] = children;
|
|
231
|
+
$[10] = drag;
|
|
232
|
+
$[11] = enabled;
|
|
233
|
+
$[12] = style;
|
|
234
|
+
$[13] = t1;
|
|
235
|
+
} else {
|
|
236
|
+
t1 = $[13];
|
|
237
|
+
}
|
|
238
|
+
return t1;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* The view that moves: `translateY` from the sheet's offset, and the slide in
|
|
243
|
+
* from below on its first layout. Both drags wrap it.
|
|
244
|
+
*/
|
|
245
|
+
export function SheetMotionView(t0) {
|
|
246
|
+
const $ = _c(15);
|
|
247
|
+
let drag;
|
|
248
|
+
let props;
|
|
249
|
+
let style;
|
|
250
|
+
if ($[0] !== t0) {
|
|
251
|
+
({
|
|
252
|
+
drag,
|
|
253
|
+
style,
|
|
254
|
+
...props
|
|
255
|
+
} = t0);
|
|
256
|
+
$[0] = t0;
|
|
257
|
+
$[1] = drag;
|
|
258
|
+
$[2] = props;
|
|
259
|
+
$[3] = style;
|
|
260
|
+
} else {
|
|
261
|
+
drag = $[1];
|
|
262
|
+
props = $[2];
|
|
263
|
+
style = $[3];
|
|
264
|
+
}
|
|
265
|
+
const dragStyle = useAnimatedStyle(() => ({
|
|
266
|
+
transform: [{
|
|
267
|
+
translateY: drag.offset.get()
|
|
268
|
+
}]
|
|
269
|
+
}));
|
|
270
|
+
let t1;
|
|
271
|
+
if ($[4] !== drag.height || $[5] !== drag.offset || $[6] !== drag.slides) {
|
|
272
|
+
t1 = event => {
|
|
273
|
+
const height = event.nativeEvent.layout.height;
|
|
274
|
+
const first = drag.height.get() === 0;
|
|
275
|
+
drag.height.set(height);
|
|
276
|
+
if (first && drag.slides) {
|
|
277
|
+
drag.offset.set(height);
|
|
278
|
+
drag.offset.set(withSpring(0, SHEET_SPRING));
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
$[4] = drag.height;
|
|
282
|
+
$[5] = drag.offset;
|
|
283
|
+
$[6] = drag.slides;
|
|
284
|
+
$[7] = t1;
|
|
285
|
+
} else {
|
|
286
|
+
t1 = $[7];
|
|
287
|
+
}
|
|
288
|
+
let t2;
|
|
289
|
+
if ($[8] !== dragStyle || $[9] !== style) {
|
|
290
|
+
t2 = [style, dragStyle];
|
|
291
|
+
$[8] = dragStyle;
|
|
292
|
+
$[9] = style;
|
|
293
|
+
$[10] = t2;
|
|
294
|
+
} else {
|
|
295
|
+
t2 = $[10];
|
|
296
|
+
}
|
|
297
|
+
let t3;
|
|
298
|
+
if ($[11] !== props || $[12] !== t1 || $[13] !== t2) {
|
|
299
|
+
t3 = <Animated.View {...props} onLayout={t1} style={t2} />;
|
|
300
|
+
$[11] = props;
|
|
301
|
+
$[12] = t1;
|
|
302
|
+
$[13] = t2;
|
|
303
|
+
$[14] = t3;
|
|
304
|
+
} else {
|
|
305
|
+
t3 = $[14];
|
|
306
|
+
}
|
|
307
|
+
return t3;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** The drag on the JavaScript thread, for an app without `react-native-gesture-handler`. */
|
|
311
|
+
function PanResponderDragView(t0) {
|
|
312
|
+
const $ = _c(7);
|
|
313
|
+
const {
|
|
314
|
+
drag,
|
|
315
|
+
enabled,
|
|
316
|
+
style,
|
|
317
|
+
children
|
|
318
|
+
} = t0;
|
|
319
|
+
let t1;
|
|
320
|
+
if ($[0] !== drag) {
|
|
321
|
+
t1 = () => {
|
|
322
|
+
let start = 0;
|
|
323
|
+
const release = (position, vy, mayDismiss) => {
|
|
324
|
+
drag.setDragging(false);
|
|
325
|
+
if (settleSheet(drag, position, vy, mayDismiss)) {
|
|
326
|
+
impactHaptic("light");
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
return PanResponder.create({
|
|
330
|
+
onStartShouldSetPanResponderCapture: () => sheetCatches(drag),
|
|
331
|
+
onMoveShouldSetPanResponderCapture: (_event, gesture) => sheetTakesDrag(drag, gesture.dx, gesture.dy),
|
|
332
|
+
onPanResponderTerminationRequest: _temp,
|
|
333
|
+
onPanResponderGrant: () => {
|
|
334
|
+
cancelAnimation(drag.offset);
|
|
335
|
+
start = drag.offset.get();
|
|
336
|
+
drag.setDragging(true);
|
|
337
|
+
},
|
|
338
|
+
onPanResponderMove: (_event_0, gesture_0) => {
|
|
339
|
+
drag.offset.set(sheetDragOffset(start + gesture_0.dy));
|
|
340
|
+
},
|
|
341
|
+
onPanResponderRelease: (_event_1, gesture_1) => release(start + gesture_1.dy, gesture_1.vy, true),
|
|
342
|
+
onPanResponderTerminate: (_event_2, gesture_2) => release(start + gesture_2.dy, gesture_2.vy, false)
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
$[0] = drag;
|
|
346
|
+
$[1] = t1;
|
|
347
|
+
} else {
|
|
348
|
+
t1 = $[1];
|
|
349
|
+
}
|
|
350
|
+
const [responder] = useState(t1);
|
|
351
|
+
const t2 = enabled ? responder.panHandlers : null;
|
|
352
|
+
let t3;
|
|
353
|
+
if ($[2] !== children || $[3] !== drag || $[4] !== style || $[5] !== t2) {
|
|
354
|
+
t3 = <SheetMotionView drag={drag} {...t2} style={style}>{children}</SheetMotionView>;
|
|
355
|
+
$[2] = children;
|
|
356
|
+
$[3] = drag;
|
|
357
|
+
$[4] = style;
|
|
358
|
+
$[5] = t2;
|
|
359
|
+
$[6] = t3;
|
|
360
|
+
} else {
|
|
361
|
+
t3 = $[6];
|
|
362
|
+
}
|
|
363
|
+
return t3;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** The parts of the motion state a worklet may capture (no React setter). */
|
|
367
|
+
function _temp() {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
/** A touch on a sheet in motion (sliding in, springing home, flung out) catches it; one sliding out after a close does not. */
|
|
371
|
+
export function sheetCatches(drag) {
|
|
372
|
+
"worklet";
|
|
373
|
+
|
|
374
|
+
return !drag.closing.get() && drag.offset.get() > 1;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** A downward drag takes the sheet once the body inside is at its top. */
|
|
378
|
+
export function sheetTakesDrag(drag, dx, dy) {
|
|
379
|
+
"worklet";
|
|
380
|
+
|
|
381
|
+
return !drag.closing.get() && isSheetDragDown(dx, dy) && drag.scrollTop.get() <= 0;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Release phase, at `position` below rest with velocity `vy` (pt/ms): the
|
|
386
|
+
* sheet springs on at the finger's speed, out (then the overlay closes) or
|
|
387
|
+
* home. `mayDismiss` is false when the system took the touch away. Returns
|
|
388
|
+
* true when it springs home from below rest: the caller fires the light
|
|
389
|
+
* haptic, in the same frame.
|
|
390
|
+
*/
|
|
391
|
+
export function settleSheet(drag, position, vy, mayDismiss) {
|
|
392
|
+
"worklet";
|
|
393
|
+
|
|
394
|
+
const height = drag.height.get();
|
|
395
|
+
const velocity = vy * 1000;
|
|
396
|
+
if (mayDismiss && sheetDragDismisses({
|
|
397
|
+
dy: position,
|
|
398
|
+
vy,
|
|
399
|
+
height
|
|
400
|
+
})) {
|
|
401
|
+
drag.offset.set(withSpring(height, {
|
|
402
|
+
...SHEET_SPRING,
|
|
403
|
+
velocity
|
|
404
|
+
}, finished => {
|
|
405
|
+
"worklet";
|
|
406
|
+
|
|
407
|
+
if (finished) drag.dismissed.set(true);
|
|
408
|
+
}));
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
drag.offset.set(withSpring(0, {
|
|
412
|
+
...SHEET_SNAP_SPRING,
|
|
413
|
+
velocity: sheetSnapVelocity(position, velocity),
|
|
414
|
+
// Bounce, but never so far up that the bottom edge lifts off the screen.
|
|
415
|
+
clamp: {
|
|
416
|
+
min: -SHEET_OVERPULL
|
|
417
|
+
}
|
|
418
|
+
}));
|
|
419
|
+
return position > 1;
|
|
420
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { createContext, useContext, useState } from "react";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
import { Gesture, GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler";
|
|
5
|
+
import Animated, { cancelAnimation, runOnJS, scrollTo, useAnimatedReaction, useAnimatedRef, useScrollOffset, useSharedValue } from "react-native-reanimated";
|
|
6
|
+
import { impactHaptic } from "../haptics";
|
|
7
|
+
import { SwipeRowGestureContext } from "../SwipeableRow";
|
|
8
|
+
import { sheetDragAnchor, sheetDragOffset } from "../sheetDrag";
|
|
9
|
+
import { settleSheet, sheetCatches, sheetTakesDrag, SheetMotionView, SheetGestureContext } from "./sheet-drag";
|
|
10
|
+
import { PagerGestureContext } from "../Pager";
|
|
11
|
+
import { ToastDragContext } from "../toastDrag";
|
|
12
|
+
import { GesturePager } from "./pager-gesture";
|
|
13
|
+
import { GestureSwipeableRow } from "./swipe-row-gesture";
|
|
14
|
+
import { GestureToastDrag } from "./toast-drag-gesture";
|
|
15
|
+
|
|
16
|
+
// The sheet drag on Gesture Handler: the touch, the track phase and the
|
|
17
|
+
// release all run as worklets on the UI thread, so a busy JavaScript thread
|
|
18
|
+
// (a reply streaming in behind the sheet) cannot make the sheet lag the
|
|
19
|
+
// finger. The rules are the same as the `PanResponder` drag's (`sheet-drag`).
|
|
20
|
+
|
|
21
|
+
/** What a body inside the sheet needs from the drag around it. */
|
|
22
|
+
|
|
23
|
+
const SheetScrollLinkContext = createContext(null);
|
|
24
|
+
function motionOf(drag) {
|
|
25
|
+
return {
|
|
26
|
+
offset: drag.offset,
|
|
27
|
+
height: drag.height,
|
|
28
|
+
scrollTop: drag.scrollTop,
|
|
29
|
+
dismissed: drag.dismissed,
|
|
30
|
+
closing: drag.closing
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function GestureSheetDragView(t0) {
|
|
34
|
+
const $ = _c(13);
|
|
35
|
+
const {
|
|
36
|
+
drag,
|
|
37
|
+
enabled,
|
|
38
|
+
style,
|
|
39
|
+
children
|
|
40
|
+
} = t0;
|
|
41
|
+
const motion = motionOf(drag);
|
|
42
|
+
const [native] = useState(_temp);
|
|
43
|
+
const heldTop = useSharedValue(null);
|
|
44
|
+
const downX = useSharedValue(0);
|
|
45
|
+
const downY = useSharedValue(0);
|
|
46
|
+
const downTop = useSharedValue(0);
|
|
47
|
+
const start = useSharedValue(0);
|
|
48
|
+
const anchorY = useSharedValue(0);
|
|
49
|
+
const pan = Gesture.Pan().enabled(enabled).manualActivation(true).simultaneousWithExternalGesture(native).onTouchesDown((event, manager) => {
|
|
50
|
+
const touch = event.allTouches[0];
|
|
51
|
+
if (!touch) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
downX.set(touch.absoluteX);
|
|
55
|
+
downY.set(touch.absoluteY);
|
|
56
|
+
downTop.set(motion.scrollTop.get());
|
|
57
|
+
if (sheetCatches(motion)) {
|
|
58
|
+
manager.activate();
|
|
59
|
+
}
|
|
60
|
+
}).onTouchesMove((event_0, manager_0) => {
|
|
61
|
+
const touch_0 = event_0.allTouches[0];
|
|
62
|
+
if (touch_0 && sheetTakesDrag(motion, touch_0.absoluteX - downX.get(), touch_0.absoluteY - downY.get())) {
|
|
63
|
+
manager_0.activate();
|
|
64
|
+
}
|
|
65
|
+
}).onStart(() => {
|
|
66
|
+
cancelAnimation(motion.offset);
|
|
67
|
+
start.set(motion.offset.get());
|
|
68
|
+
anchorY.set(sheetDragAnchor(downY.get(), downTop.get(), motion.scrollTop.get()));
|
|
69
|
+
heldTop.set(motion.scrollTop.get());
|
|
70
|
+
}).onUpdate(event_1 => {
|
|
71
|
+
motion.offset.set(sheetDragOffset(start.get() + event_1.absoluteY - anchorY.get()));
|
|
72
|
+
}).onEnd((event_2, success) => {
|
|
73
|
+
const position = start.get() + event_2.absoluteY - anchorY.get();
|
|
74
|
+
if (settleSheet(motion, position, event_2.velocityY / 1000, success)) {
|
|
75
|
+
runOnJS(impactHaptic)("light");
|
|
76
|
+
}
|
|
77
|
+
}).onFinalize(() => {
|
|
78
|
+
heldTop.set(null);
|
|
79
|
+
});
|
|
80
|
+
let t1;
|
|
81
|
+
if ($[0] !== heldTop || $[1] !== native) {
|
|
82
|
+
t1 = {
|
|
83
|
+
native,
|
|
84
|
+
heldTop
|
|
85
|
+
};
|
|
86
|
+
$[0] = heldTop;
|
|
87
|
+
$[1] = native;
|
|
88
|
+
$[2] = t1;
|
|
89
|
+
} else {
|
|
90
|
+
t1 = $[2];
|
|
91
|
+
}
|
|
92
|
+
let t2;
|
|
93
|
+
if ($[3] !== children || $[4] !== drag || $[5] !== style) {
|
|
94
|
+
t2 = <SheetMotionView drag={drag} style={style}>{children}</SheetMotionView>;
|
|
95
|
+
$[3] = children;
|
|
96
|
+
$[4] = drag;
|
|
97
|
+
$[5] = style;
|
|
98
|
+
$[6] = t2;
|
|
99
|
+
} else {
|
|
100
|
+
t2 = $[6];
|
|
101
|
+
}
|
|
102
|
+
let t3;
|
|
103
|
+
if ($[7] !== pan || $[8] !== t2) {
|
|
104
|
+
t3 = <GestureDetector gesture={pan}>{t2}</GestureDetector>;
|
|
105
|
+
$[7] = pan;
|
|
106
|
+
$[8] = t2;
|
|
107
|
+
$[9] = t3;
|
|
108
|
+
} else {
|
|
109
|
+
t3 = $[9];
|
|
110
|
+
}
|
|
111
|
+
let t4;
|
|
112
|
+
if ($[10] !== t1 || $[11] !== t3) {
|
|
113
|
+
t4 = <SheetScrollLinkContext.Provider value={t1}>{t3}</SheetScrollLinkContext.Provider>;
|
|
114
|
+
$[10] = t1;
|
|
115
|
+
$[11] = t3;
|
|
116
|
+
$[12] = t4;
|
|
117
|
+
} else {
|
|
118
|
+
t4 = $[12];
|
|
119
|
+
}
|
|
120
|
+
return t4;
|
|
121
|
+
}
|
|
122
|
+
function _temp() {
|
|
123
|
+
return Gesture.Native();
|
|
124
|
+
}
|
|
125
|
+
function GestureSheetScrollView(t0) {
|
|
126
|
+
const $ = _c(9);
|
|
127
|
+
let drag;
|
|
128
|
+
let props;
|
|
129
|
+
if ($[0] !== t0) {
|
|
130
|
+
({
|
|
131
|
+
drag,
|
|
132
|
+
...props
|
|
133
|
+
} = t0);
|
|
134
|
+
$[0] = t0;
|
|
135
|
+
$[1] = drag;
|
|
136
|
+
$[2] = props;
|
|
137
|
+
} else {
|
|
138
|
+
drag = $[1];
|
|
139
|
+
props = $[2];
|
|
140
|
+
}
|
|
141
|
+
const link = useContext(SheetScrollLinkContext);
|
|
142
|
+
const heldTop = link?.heldTop;
|
|
143
|
+
const ref = useAnimatedRef();
|
|
144
|
+
useScrollOffset(ref, drag.scrollTop);
|
|
145
|
+
useAnimatedReaction(() => drag.scrollTop.get(), top => {
|
|
146
|
+
const held = heldTop?.get();
|
|
147
|
+
if (typeof held === "number" && top !== held) {
|
|
148
|
+
scrollTo(ref, 0, held, false);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
let t1;
|
|
152
|
+
if ($[3] !== props || $[4] !== ref) {
|
|
153
|
+
t1 = <Animated.ScrollView ref={ref} {...props} />;
|
|
154
|
+
$[3] = props;
|
|
155
|
+
$[4] = ref;
|
|
156
|
+
$[5] = t1;
|
|
157
|
+
} else {
|
|
158
|
+
t1 = $[5];
|
|
159
|
+
}
|
|
160
|
+
const scroll = t1;
|
|
161
|
+
let t2;
|
|
162
|
+
if ($[6] !== link || $[7] !== scroll) {
|
|
163
|
+
t2 = link ? <GestureDetector gesture={link.native}>{scroll}</GestureDetector> : scroll;
|
|
164
|
+
$[6] = link;
|
|
165
|
+
$[7] = scroll;
|
|
166
|
+
$[8] = t2;
|
|
167
|
+
} else {
|
|
168
|
+
t2 = $[8];
|
|
169
|
+
}
|
|
170
|
+
return t2;
|
|
171
|
+
}
|
|
172
|
+
function GestureModalRoot(t0) {
|
|
173
|
+
const $ = _c(2);
|
|
174
|
+
const {
|
|
175
|
+
children
|
|
176
|
+
} = t0;
|
|
177
|
+
let t1;
|
|
178
|
+
if ($[0] !== children) {
|
|
179
|
+
t1 = <GestureHandlerRootView style={styles.fill}>{children}</GestureHandlerRootView>;
|
|
180
|
+
$[0] = children;
|
|
181
|
+
$[1] = t1;
|
|
182
|
+
} else {
|
|
183
|
+
t1 = $[1];
|
|
184
|
+
}
|
|
185
|
+
return t1;
|
|
186
|
+
}
|
|
187
|
+
const PARTS = {
|
|
188
|
+
ModalRoot: GestureModalRoot,
|
|
189
|
+
DragView: GestureSheetDragView,
|
|
190
|
+
ScrollView: GestureSheetScrollView
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Runs the kit's sheet drags (`SheetContent`, the compact `DialogContent`)
|
|
195
|
+
* on Gesture Handler instead of `PanResponder`, and turns on the swipes of
|
|
196
|
+
* `SwipeableRow`, `Pager` and the `Toaster` toasts (up to dismiss). Put it
|
|
197
|
+
* inside the app's `GestureHandlerRootView`; each overlay adds its own root
|
|
198
|
+
* view inside its `Modal`.
|
|
199
|
+
*/
|
|
200
|
+
export function GestureHandlerProvider(t0) {
|
|
201
|
+
const $ = _c(2);
|
|
202
|
+
const {
|
|
203
|
+
children
|
|
204
|
+
} = t0;
|
|
205
|
+
let t1;
|
|
206
|
+
if ($[0] !== children) {
|
|
207
|
+
t1 = <SheetGestureContext.Provider value={PARTS}><SwipeRowGestureContext.Provider value={GestureSwipeableRow}><PagerGestureContext.Provider value={GesturePager}><ToastDragContext.Provider value={GestureToastDrag}>{children}</ToastDragContext.Provider></PagerGestureContext.Provider></SwipeRowGestureContext.Provider></SheetGestureContext.Provider>;
|
|
208
|
+
$[0] = children;
|
|
209
|
+
$[1] = t1;
|
|
210
|
+
} else {
|
|
211
|
+
t1 = $[1];
|
|
212
|
+
}
|
|
213
|
+
return t1;
|
|
214
|
+
}
|
|
215
|
+
const styles = StyleSheet.create({
|
|
216
|
+
fill: {
|
|
217
|
+
flex: 1
|
|
218
|
+
}
|
|
219
|
+
});
|