@vvedantb/native-ui 0.38.0 → 0.40.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/Avatar.jsx +22 -19
- package/dist/BottomSheetContainer.jsx +0 -6
- package/dist/BulkActionBar.jsx +0 -24
- package/dist/Button.jsx +92 -116
- package/dist/Card.jsx +56 -50
- package/dist/ColorSwatches.jsx +0 -6
- package/dist/Dialog.jsx +0 -12
- package/dist/DropdownMenu.jsx +0 -10
- package/dist/EmptyState.jsx +0 -3
- package/dist/ExpoWebRoot.jsx +0 -6
- package/dist/Field.jsx +0 -17
- package/dist/FloatingSurface.jsx +95 -80
- package/dist/FloatingTabBar.jsx +0 -23
- package/dist/IconButton.jsx +0 -1
- package/dist/LoadingState.jsx +0 -6
- package/dist/PasswordInput.jsx +0 -15
- package/dist/PillTabs.jsx +39 -36
- package/dist/SearchInput.jsx +0 -13
- package/dist/SectionLabel.jsx +0 -1
- package/dist/SharedTransition.jsx +0 -3
- package/dist/Skeleton.jsx +0 -2
- package/dist/Spinner.jsx +0 -2
- package/dist/StatusDot.jsx +0 -5
- package/dist/Switch.jsx +32 -22
- package/dist/Tabs.jsx +27 -26
- package/dist/Textarea.jsx +0 -1
- package/dist/ThemeToggle.jsx +0 -1
- package/dist/Toast.jsx +80 -91
- package/dist/UpdateChecker.jsx +0 -1
- package/dist/ai/activity-question.jsx +0 -6
- package/dist/ai/activity-step-label.js +0 -6
- package/dist/ai/activity-step-types.js +0 -4
- package/dist/ai/activity-tasks-utils.js +0 -17
- package/dist/ai/activity-timeline.js +0 -8
- package/dist/ai/attachments.jsx +0 -2
- package/dist/ai/chain-of-thought.jsx +0 -3
- package/dist/ai/chat-text.js +2 -3
- package/dist/ai/chat-thread.jsx +0 -1
- package/dist/ai/choice-question.jsx +0 -10
- package/dist/ai/code-block.jsx +0 -31
- package/dist/ai/collapsible.jsx +0 -14
- package/dist/ai/conversation-context.js +0 -3
- package/dist/ai/conversation.jsx +2 -48
- package/dist/ai/file-chip.jsx +0 -2
- package/dist/ai/icon-button.jsx +10 -18
- package/dist/ai/index.js +0 -5
- package/dist/ai/message-context-menu.jsx +0 -7
- package/dist/ai/message.jsx +0 -21
- package/dist/ai/prompt-input-menu.jsx +0 -3
- package/dist/ai/prompt-input.jsx +2 -29
- package/dist/ai/response-text.jsx +0 -6
- package/dist/ai/sources.jsx +0 -1
- package/dist/ai/suggestion.jsx +0 -1
- package/dist/ai/trace.jsx +0 -11
- package/dist/ai/unified-diff.jsx +0 -4
- package/dist/auth/AuthScreen.jsx +0 -5
- package/dist/auth/GoogleSignInButton.jsx +0 -3
- package/dist/auth/SecondFactorScreen.jsx +0 -2
- package/dist/auth/SignInScreen.jsx +0 -17
- package/dist/auth/authErrors.js +0 -4
- package/dist/auth/clerkCore3.js +0 -7
- package/dist/auth/index.js +0 -4
- package/dist/auth/totp.js +0 -2
- package/dist/brand/GoogleMark.jsx +0 -1
- package/dist/brand/ProviderIcon.jsx +0 -2
- package/dist/brand/index.js +0 -3
- package/dist/brand/svg.js +0 -6
- package/dist/configureTheme.js +0 -9
- package/dist/controlStyles.js +0 -14
- package/dist/crash/lastCrash.js +3 -24
- package/dist/entries/ai.js +0 -3
- package/dist/entries/ambient.js +0 -2
- package/dist/entries/app-root.js +0 -5
- package/dist/entries/auth.js +0 -4
- package/dist/entries/bottom-sheet.js +0 -2
- package/dist/entries/brand.js +0 -1
- package/dist/entries/button.js +0 -1
- package/dist/entries/crash.js +0 -3
- package/dist/entries/date-time.js +0 -2
- package/dist/entries/expo-router.js +0 -3
- package/dist/entries/expo-web-root.js +0 -2
- package/dist/entries/floating.js +0 -2
- package/dist/entries/generative-ui.js +0 -4
- package/dist/entries/gesture-handler.js +0 -3
- package/dist/entries/keyboard-controller.js +0 -3
- package/dist/entries/layout.js +0 -2
- package/dist/entries/markdown.js +0 -3
- package/dist/entries/marketing.js +0 -1
- package/dist/entries/page-title.js +0 -5
- package/dist/entries/password-input.js +0 -2
- package/dist/entries/paste-input.js +0 -3
- package/dist/entries/primitives.js +0 -6
- package/dist/entries/search-input.js +0 -2
- package/dist/entries/tab-bar.js +0 -2
- package/dist/entries/theme.js +1 -2
- package/dist/entries/toast.js +0 -3
- package/dist/entries/video.js +0 -2
- package/dist/entries/webview.js +0 -2
- package/dist/examples/AiChatGallery.jsx +0 -11
- package/dist/examples/ParityGallery.jsx +0 -12
- package/dist/floating.js +0 -8
- package/dist/generative-ui/GenerativeUiPanel.jsx +0 -2
- package/dist/generative-ui/components.jsx +0 -8
- package/dist/glass.js +55 -0
- package/dist/glassBlur.jsx +0 -12
- package/dist/highlight.js +0 -26
- package/dist/index.js +1 -2
- package/dist/loadingGrid.js +0 -13
- package/dist/markdown/Markdown.jsx +0 -59
- package/dist/markdown/MarkdownTable.jsx +0 -18
- package/dist/markdown/tableText.js +0 -5
- package/dist/marketing/UpgradeToProCard.jsx +0 -5
- package/dist/marketing/pricing.js +0 -3
- package/dist/media/ImageGallery.jsx +0 -16
- package/dist/media/imageZoom.js +0 -4
- package/dist/media/zoom-image-gesture.jsx +0 -8
- package/dist/media/zoomImage.js +0 -3
- package/dist/motion.js +0 -3
- package/dist/neutralTheme.js +0 -5
- package/dist/pagerSwipe.js +0 -16
- package/dist/palette.js +0 -10
- package/dist/primitives/button.jsx +0 -5
- package/dist/primitives/keyboard-controller.jsx +0 -27
- package/dist/primitives/native-only-animated-view.jsx +0 -5
- package/dist/primitives/overlay.jsx +0 -2
- package/dist/primitives/pager-gesture.jsx +3 -29
- package/dist/primitives/paste-input.jsx +0 -5
- package/dist/primitives/select.jsx +0 -8
- package/dist/primitives/sheet-drag.jsx +0 -3
- package/dist/primitives/sheet-gesture.jsx +0 -8
- package/dist/primitives/swipe-row-gesture.jsx +3 -45
- package/dist/primitives/text.jsx +0 -5
- package/dist/primitives/toast-drag-gesture.jsx +4 -24
- package/dist/primitives/web-click-guard.js +0 -3
- package/dist/primitives/window-layer.jsx +0 -14
- package/dist/push.js +0 -6
- package/dist/relativeTime.js +0 -13
- package/dist/settings/MoreFromProjectV.jsx +0 -5
- package/dist/settings/ThemeModePicker.jsx +0 -4
- package/dist/settings/projectVMobileApps.js +1 -6
- package/dist/sheetDrag.js +0 -10
- package/dist/swipeRow.js +0 -15
- package/dist/tabBarRoutes.js +0 -4
- package/dist/tabIndicator.js +0 -4
- package/dist/tailwind-preset.cjs +0 -54
- package/dist/tailwind-preset.d.cts +0 -8
- package/dist/theme.jsx +29 -21
- package/dist/themeModeStore.js +0 -5
- package/dist/toastChrome.js +0 -6
- package/dist/toastDrag.js +0 -14
- package/dist/toastStore.js +0 -4
- package/dist/updateCheck.js +0 -7
- package/dist/video/InlineVideo.jsx +0 -2
- package/dist/webview/htmlView.js +0 -5
- package/package.json +3 -3
- package/src/ArtifactList.tsx +0 -2
- package/src/Avatar.tsx +3 -3
- package/src/Badge.tsx +0 -1
- package/src/BottomSheetContainer.tsx +0 -11
- package/src/BulkActionBar.tsx +0 -66
- package/src/Button.tsx +4 -40
- package/src/CaptureButton.tsx +0 -1
- package/src/Card.tsx +3 -15
- package/src/Checkbox.tsx +0 -2
- package/src/ColorSwatches.tsx +0 -9
- package/src/ConfirmDialog.tsx +0 -7
- package/src/DateTimeField.tsx +0 -5
- package/src/Dialog.tsx +0 -27
- package/src/DividedList.tsx +0 -1
- package/src/DropdownMenu.tsx +0 -51
- package/src/EmptyState.tsx +0 -5
- package/src/ExpoWebRoot.tsx +0 -10
- package/src/Field.tsx +0 -14
- package/src/FloatingFAB.tsx +0 -3
- package/src/FloatingSurface.tsx +11 -8
- package/src/FloatingTabBar.tsx +0 -25
- package/src/IconButton.tsx +0 -5
- package/src/Input.tsx +0 -1
- package/src/Label.tsx +0 -1
- package/src/LabeledSwitchRow.tsx +0 -2
- package/src/ListRow.tsx +0 -12
- package/src/LoadingState.tsx +0 -12
- package/src/MenuSheet.tsx +0 -2
- package/src/PageIndicator.tsx +0 -2
- package/src/PageTitle.tsx +0 -15
- package/src/Pager.tsx +0 -9
- package/src/PasswordInput.tsx +0 -24
- package/src/PillTabs.tsx +3 -11
- package/src/PinnedBotTile.tsx +0 -6
- package/src/Progress.tsx +0 -3
- package/src/ReactionRow.tsx +0 -8
- package/src/ScreenContainer.tsx +0 -4
- package/src/SearchInput.tsx +0 -25
- package/src/SectionLabel.tsx +0 -2
- package/src/Select.tsx +0 -6
- package/src/Separator.tsx +0 -2
- package/src/SharedTransition.tsx +0 -7
- package/src/Sheet.tsx +0 -3
- package/src/SheetRow.tsx +0 -12
- package/src/Skeleton.tsx +0 -10
- package/src/Spinner.tsx +0 -6
- package/src/StackPageHeader.tsx +0 -16
- package/src/StatGrid.tsx +0 -1
- package/src/StatusDot.tsx +0 -6
- package/src/SurfaceRow.tsx +0 -12
- package/src/SwipeableRow.tsx +0 -4
- package/src/Switch.tsx +3 -4
- package/src/Tabs.tsx +3 -27
- package/src/Textarea.tsx +0 -2
- package/src/ThemeToggle.tsx +0 -1
- package/src/Toast.tsx +3 -19
- package/src/UpdateChecker.tsx +0 -46
- package/src/ai/activity-question.tsx +0 -8
- package/src/ai/activity-step-detail.tsx +0 -5
- package/src/ai/activity-step-label.ts +0 -5
- package/src/ai/activity-step-types.ts +0 -24
- package/src/ai/activity-step.tsx +0 -4
- package/src/ai/activity-tasks-utils.ts +0 -13
- package/src/ai/activity-timeline.ts +0 -6
- package/src/ai/attachments.tsx +0 -13
- package/src/ai/chain-of-thought.tsx +0 -5
- package/src/ai/chat-jump-rail.tsx +0 -2
- package/src/ai/chat-text.ts +2 -3
- package/src/ai/chat-thread.tsx +0 -9
- package/src/ai/choice-question.tsx +0 -36
- package/src/ai/code-block.tsx +0 -52
- package/src/ai/collapsible.tsx +0 -12
- package/src/ai/conversation-context.ts +0 -14
- package/src/ai/conversation.tsx +0 -58
- package/src/ai/file-chip.tsx +0 -1
- package/src/ai/icon-button.tsx +5 -22
- package/src/ai/index.ts +0 -5
- package/src/ai/message-action-sheet.tsx +0 -8
- package/src/ai/message-context-menu.tsx +0 -22
- package/src/ai/message-quote.tsx +0 -4
- package/src/ai/message.tsx +0 -66
- package/src/ai/prompt-input-menu.tsx +0 -19
- package/src/ai/prompt-input.tsx +1 -98
- package/src/ai/reasoning.tsx +0 -6
- package/src/ai/reply-quote-chip.tsx +0 -5
- package/src/ai/response-text.tsx +0 -8
- package/src/ai/shimmer.tsx +0 -2
- package/src/ai/sources.tsx +0 -3
- package/src/ai/subagent-cards.tsx +0 -13
- package/src/ai/suggestion.tsx +0 -4
- package/src/ai/tool-approval-card.tsx +0 -14
- package/src/ai/trace.tsx +0 -23
- package/src/ai/unified-diff.tsx +0 -16
- package/src/ai/use-streaming-disclosure.ts +0 -4
- package/src/app-root/AuthGroupGate.tsx +0 -8
- package/src/app-root/SsoCallbackScreen.tsx +0 -10
- package/src/app-root/fonts.ts +0 -2
- package/src/auth/AccountScreens.tsx +0 -16
- package/src/auth/AuthProviders.tsx +0 -13
- package/src/auth/AuthScreen.tsx +0 -12
- package/src/auth/GoogleSignInButton.tsx +0 -12
- package/src/auth/SecondFactorScreen.tsx +0 -16
- package/src/auth/SignInScreen.tsx +0 -68
- package/src/auth/authErrors.ts +0 -6
- package/src/auth/clerkCore3.ts +0 -6
- package/src/auth/index.ts +0 -4
- package/src/auth/totp.ts +0 -13
- package/src/brand/AppIcons.tsx +0 -6
- package/src/brand/AppMark.tsx +0 -5
- package/src/brand/AppWordmark.tsx +0 -7
- package/src/brand/GoogleMark.tsx +0 -4
- package/src/brand/ProviderIcon.tsx +0 -6
- package/src/brand/familyApps.ts +0 -2
- package/src/brand/index.ts +0 -3
- package/src/brand/svg.ts +0 -9
- package/src/configureTheme.ts +0 -10
- package/src/controlStyles.ts +0 -12
- package/src/crash/LastCrashDialog.tsx +0 -6
- package/src/crash/lastCrash.ts +0 -21
- package/src/entries/ai.ts +0 -3
- package/src/entries/ambient.ts +0 -2
- package/src/entries/app-root.ts +0 -5
- package/src/entries/auth.ts +0 -4
- package/src/entries/bottom-sheet.ts +0 -2
- package/src/entries/brand.ts +0 -1
- package/src/entries/button.ts +0 -1
- package/src/entries/crash.ts +0 -3
- package/src/entries/date-time.ts +0 -2
- package/src/entries/expo-router.ts +0 -3
- package/src/entries/expo-web-root.ts +0 -2
- package/src/entries/floating.ts +0 -2
- package/src/entries/generative-ui.ts +0 -4
- package/src/entries/gesture-handler.ts +0 -3
- package/src/entries/keyboard-controller.ts +0 -3
- package/src/entries/layout.ts +0 -2
- package/src/entries/markdown.ts +0 -3
- package/src/entries/marketing.ts +0 -1
- package/src/entries/page-title.ts +0 -5
- package/src/entries/password-input.ts +0 -2
- package/src/entries/paste-input.ts +0 -3
- package/src/entries/primitives.ts +0 -6
- package/src/entries/search-input.ts +0 -2
- package/src/entries/tab-bar.ts +0 -2
- package/src/entries/theme.ts +2 -2
- package/src/entries/toast.ts +0 -3
- package/src/entries/video.ts +0 -2
- package/src/entries/webview.ts +0 -2
- package/src/examples/AiChatGallery.tsx +0 -11
- package/src/examples/ParityGallery.tsx +0 -25
- package/src/floating.ts +0 -6
- package/src/generative-ui/GenerativeUiPanel.tsx +0 -15
- package/src/generative-ui/components.tsx +0 -9
- package/src/generative-ui/context.ts +0 -2
- package/src/glass.ts +31 -0
- package/src/glassBlur.tsx +0 -15
- package/src/highlight.ts +0 -20
- package/src/index.ts +2 -2
- package/src/loadingGrid.ts +0 -12
- package/src/markdown/Markdown.tsx +0 -71
- package/src/markdown/MarkdownTable.tsx +0 -23
- package/src/markdown/tableText.ts +0 -3
- package/src/marketing/PricingModal.tsx +0 -13
- package/src/marketing/UpgradeToProCard.tsx +0 -14
- package/src/marketing/pricing.ts +0 -12
- package/src/media/ImageGallery.tsx +0 -18
- package/src/media/MediaCard.tsx +0 -8
- package/src/media/imageZoom.ts +0 -4
- package/src/media/zoom-image-gesture.tsx +0 -9
- package/src/media/zoomImage.ts +0 -5
- package/src/motion.ts +0 -3
- package/src/neutralTheme.ts +0 -3
- package/src/pagerSwipe.ts +0 -13
- package/src/palette.ts +0 -10
- package/src/pressScale.ts +0 -7
- package/src/primitives/button.tsx +0 -4
- package/src/primitives/card.tsx +0 -1
- package/src/primitives/input.tsx +0 -4
- package/src/primitives/keyboard-controller.tsx +0 -25
- package/src/primitives/keyboard-parts.tsx +0 -27
- package/src/primitives/native-only-animated-view.tsx +0 -5
- package/src/primitives/overlay.tsx +0 -25
- package/src/primitives/pager-gesture.tsx +0 -20
- package/src/primitives/paste-input.tsx +0 -4
- package/src/primitives/paste-parts.tsx +0 -1
- package/src/primitives/select.tsx +0 -16
- package/src/primitives/sheet-drag.tsx +0 -19
- package/src/primitives/sheet-gesture.tsx +0 -22
- package/src/primitives/swipe-row-gesture.tsx +0 -33
- package/src/primitives/switch.tsx +0 -4
- package/src/primitives/text.tsx +0 -4
- package/src/primitives/toast-drag-gesture.tsx +0 -13
- package/src/primitives/web-click-guard.ts +0 -2
- package/src/primitives/window-layer.tsx +0 -18
- package/src/push.ts +0 -15
- package/src/relativeTime.ts +0 -21
- package/src/router/RouterStackPageHeader.tsx +0 -1
- package/src/settings/MoreFromProjectV.tsx +0 -8
- package/src/settings/SettingsEmptyState.tsx +0 -2
- package/src/settings/SettingsSection.tsx +0 -3
- package/src/settings/SettingsToggleRow.tsx +0 -4
- package/src/settings/ThemeModePicker.tsx +0 -11
- package/src/settings/projectVMobileApps.ts +0 -8
- package/src/sheetDrag.ts +0 -9
- package/src/swipeRow.ts +0 -23
- package/src/tabBarRoutes.ts +0 -13
- package/src/tabIndicator.ts +0 -5
- package/src/tailwind-preset.cjs +0 -54
- package/src/tailwind-preset.d.cts +0 -8
- package/src/theme.tsx +11 -2
- package/src/themeModeStore.ts +0 -9
- package/src/toastChrome.ts +0 -6
- package/src/toastDrag.ts +0 -13
- package/src/toastStore.ts +0 -7
- package/src/updateCheck.ts +0 -15
- package/src/video/InlineVideo.tsx +0 -5
- package/src/webview/HtmlView.tsx +0 -23
- package/src/webview/HtmlView.web.tsx +0 -1
- package/src/webview/htmlView.ts +0 -5
|
@@ -31,8 +31,6 @@ const SelectValue = React.forwardRef<
|
|
|
31
31
|
>(({ className, style, ...props }, ref) => {
|
|
32
32
|
const classes = cn("line-clamp-1 text-sm text-foreground", className);
|
|
33
33
|
if (Platform.OS === "web") {
|
|
34
|
-
// Radix `Select.Value` drops `className` and `style`, so the placeholder
|
|
35
|
-
// took the page colour. Its span inherits them from this Text instead.
|
|
36
34
|
return (
|
|
37
35
|
<Text className={classes} style={style}>
|
|
38
36
|
<SelectPrimitive.Value ref={ref} {...props} />
|
|
@@ -79,7 +77,6 @@ type SelectContentProps = React.ComponentPropsWithoutRef<
|
|
|
79
77
|
portalHost?: string;
|
|
80
78
|
};
|
|
81
79
|
|
|
82
|
-
/** The popover fades in and out on the strong ease-out. */
|
|
83
80
|
const SELECT_ENTER = FadeIn.duration(150).easing(EASE_OUT);
|
|
84
81
|
const SELECT_EXIT = FadeOut.duration(100).easing(EASE_OUT);
|
|
85
82
|
|
|
@@ -95,9 +92,6 @@ const SelectContent = React.forwardRef<
|
|
|
95
92
|
entering={SELECT_ENTER}
|
|
96
93
|
exiting={SELECT_EXIT}
|
|
97
94
|
className="z-50"
|
|
98
|
-
// Content is absolutely positioned, so a bare wrapper has zero height
|
|
99
|
-
// and UI tests drop its children as invisible. Fill the overlay and
|
|
100
|
-
// let touches fall through to it.
|
|
101
95
|
style={overlayFill}
|
|
102
96
|
pointerEvents={Platform.select({ native: "box-none" })}
|
|
103
97
|
>
|
|
@@ -132,9 +126,6 @@ const SelectContent = React.forwardRef<
|
|
|
132
126
|
</SelectPrimitive.Overlay>
|
|
133
127
|
);
|
|
134
128
|
|
|
135
|
-
// Android: no Portal. A Modal inside a portal mounts empty, so `SelectHost`
|
|
136
|
-
// renders the Modal directly and gates it on `open`. iOS and web keep the
|
|
137
|
-
// Portal; `SelectHost` adds the full-window layer on iOS.
|
|
138
129
|
if (Platform.OS === "android") {
|
|
139
130
|
return <SelectHost>{content}</SelectHost>;
|
|
140
131
|
}
|
|
@@ -164,11 +155,6 @@ const SelectLabel = React.forwardRef<
|
|
|
164
155
|
);
|
|
165
156
|
});
|
|
166
157
|
|
|
167
|
-
/**
|
|
168
|
-
* On web `SelectPrimitive.Item` passes these props to a Radix DOM node, not a
|
|
169
|
-
* React Native view, so give it `aria-label` and `data-testid` there, not
|
|
170
|
-
* `accessibilityLabel` or `testID` (`selectItemA11yProps`).
|
|
171
|
-
*/
|
|
172
158
|
type SelectItemProps = React.ComponentPropsWithoutRef<
|
|
173
159
|
typeof SelectPrimitive.Item
|
|
174
160
|
> & {
|
|
@@ -186,7 +172,6 @@ const SelectItem = React.forwardRef<
|
|
|
186
172
|
ref={ref}
|
|
187
173
|
disabled={disabled}
|
|
188
174
|
className={cn(
|
|
189
|
-
// 44 high (56 with larger text) so a row is a full touch target.
|
|
190
175
|
"relative min-h-[44px] flex-row items-center gap-2 rounded-sm py-3 pl-2 pr-8 active:opacity-70",
|
|
191
176
|
largerText && "min-h-[56px]",
|
|
192
177
|
disabled && "opacity-50",
|
|
@@ -201,7 +186,6 @@ const SelectItem = React.forwardRef<
|
|
|
201
186
|
</View>
|
|
202
187
|
<SelectPrimitive.ItemText
|
|
203
188
|
className="select-none text-sm font-instrument-sans-medium"
|
|
204
|
-
// One object: on web the item text is a Radix slot, which drops arrays.
|
|
205
189
|
style={{ ...textStyle("foreground", scheme), ...typeStyle("medium") }}
|
|
206
190
|
/>
|
|
207
191
|
</SelectPrimitive.Item>
|
|
@@ -35,19 +35,12 @@ import { isSheetDragDown, SHEET_OVERPULL, sheetDragDismisses, sheetDragOffset, s
|
|
|
35
35
|
* (`SheetGestureParts`) holds the body still on the UI thread instead.
|
|
36
36
|
*/
|
|
37
37
|
export type SheetDragState = {
|
|
38
|
-
/** How far down the sheet sits from rest. */
|
|
39
38
|
offset: SharedValue<number>;
|
|
40
|
-
/** The sheet's height, from its layout; 0 until it is laid out. */
|
|
41
39
|
height: SharedValue<number>;
|
|
42
|
-
/** The scroll offset of the body inside, 0 at the top. */
|
|
43
40
|
scrollTop: SharedValue<number>;
|
|
44
|
-
/** Set once a release flung the sheet out: the overlay then closes. */
|
|
45
41
|
dismissed: SharedValue<boolean>;
|
|
46
|
-
/** Set while the sheet slides out after the overlay closed: a touch no longer catches it. */
|
|
47
42
|
closing: SharedValue<boolean>;
|
|
48
|
-
/** The sheet slides in from below on its first layout (a bottom sheet, Reduce Motion off). */
|
|
49
43
|
slides: boolean;
|
|
50
|
-
/** While the sheet follows a `PanResponder` finger: the body inside stops scrolling, so the native scroll does not take the touch. */
|
|
51
44
|
dragging: boolean;
|
|
52
45
|
setDragging: (dragging: boolean) => void;
|
|
53
46
|
};
|
|
@@ -92,7 +85,6 @@ export type SheetDragViewProps = {
|
|
|
92
85
|
* `react-native-gesture-handler` and an app without it bundles as before.
|
|
93
86
|
*/
|
|
94
87
|
export type SheetGestureParts = {
|
|
95
|
-
/** Wraps each overlay's `Modal` content: on Android a `Modal` is its own root, and gestures need a root view there. */
|
|
96
88
|
ModalRoot: ComponentType<{ children: ReactNode }>;
|
|
97
89
|
DragView: ComponentType<SheetDragViewProps & { drag: SheetDragState }>;
|
|
98
90
|
ScrollView: ComponentType<ScrollViewProps & { drag: SheetDragState }>;
|
|
@@ -104,7 +96,6 @@ export const SheetGestureContext = createContext<SheetGestureParts | null>(null)
|
|
|
104
96
|
export function useSheetBackdropStyle(drag: SheetDragState) {
|
|
105
97
|
return useAnimatedStyle(() => {
|
|
106
98
|
const height = drag.height.get();
|
|
107
|
-
// Not laid out yet: hidden while a sliding sheet waits below the screen.
|
|
108
99
|
if (height === 0) return { opacity: drag.offset.get() > 0 ? 0 : 1 };
|
|
109
100
|
return { opacity: interpolate(drag.offset.get(), [0, height], [1, 0], "clamp") };
|
|
110
101
|
});
|
|
@@ -204,7 +195,6 @@ export function SheetMotionView({
|
|
|
204
195
|
const height = event.nativeEvent.layout.height;
|
|
205
196
|
const first = drag.height.get() === 0;
|
|
206
197
|
drag.height.set(height);
|
|
207
|
-
// Slide in: from just below the screen edge, whatever the sheet's height.
|
|
208
198
|
if (first && drag.slides) {
|
|
209
199
|
drag.offset.set(height);
|
|
210
200
|
drag.offset.set(withSpring(0, SHEET_SPRING));
|
|
@@ -215,27 +205,20 @@ export function SheetMotionView({
|
|
|
215
205
|
);
|
|
216
206
|
}
|
|
217
207
|
|
|
218
|
-
/** The drag on the JavaScript thread, for an app without `react-native-gesture-handler`. */
|
|
219
208
|
function PanResponderDragView({
|
|
220
209
|
drag,
|
|
221
210
|
enabled,
|
|
222
211
|
style,
|
|
223
212
|
children,
|
|
224
213
|
}: SheetDragViewProps & { drag: SheetDragState }) {
|
|
225
|
-
// Created once: its handlers only touch shared values and `start`, so they never go stale.
|
|
226
214
|
const [responder] = useState(() => {
|
|
227
|
-
// Where the sheet was when the finger caught it.
|
|
228
215
|
let start = 0;
|
|
229
216
|
const release = (position: number, vy: number, mayDismiss: boolean) => {
|
|
230
217
|
drag.setDragging(false);
|
|
231
218
|
if (settleSheet(drag, position, vy, mayDismiss)) impactHaptic("light");
|
|
232
219
|
};
|
|
233
220
|
return PanResponder.create({
|
|
234
|
-
// A touch on a sheet in motion catches it: it stops under the finger.
|
|
235
221
|
onStartShouldSetPanResponderCapture: () => sheetCatches(drag),
|
|
236
|
-
// Capture, so a downward drag wins over the rows and over a body
|
|
237
|
-
// scrolled to its top. Only then: a body scrolled down keeps its
|
|
238
|
-
// scroll both ways, and an upward drag always scrolls it.
|
|
239
222
|
onMoveShouldSetPanResponderCapture: (_event, gesture) => sheetTakesDrag(drag, gesture.dx, gesture.dy),
|
|
240
223
|
onPanResponderTerminationRequest: () => false,
|
|
241
224
|
onPanResponderGrant: () => {
|
|
@@ -243,7 +226,6 @@ function PanResponderDragView({
|
|
|
243
226
|
start = drag.offset.get();
|
|
244
227
|
drag.setDragging(true);
|
|
245
228
|
},
|
|
246
|
-
// Track phase: one shared value write per move, no React render.
|
|
247
229
|
onPanResponderMove: (_event, gesture) => {
|
|
248
230
|
drag.offset.set(sheetDragOffset(start + gesture.dy));
|
|
249
231
|
},
|
|
@@ -297,7 +279,6 @@ export function settleSheet(drag: SheetMotion, position: number, vy: number, may
|
|
|
297
279
|
withSpring(0, {
|
|
298
280
|
...SHEET_SNAP_SPRING,
|
|
299
281
|
velocity: sheetSnapVelocity(position, velocity),
|
|
300
|
-
// Bounce, but never so far up that the bottom edge lifts off the screen.
|
|
301
282
|
clamp: { min: -SHEET_OVERPULL },
|
|
302
283
|
}),
|
|
303
284
|
);
|
|
@@ -37,16 +37,8 @@ import { ZOOM_IMAGE_PARTS } from "../media/zoom-image-gesture";
|
|
|
37
37
|
import { GestureSwipeableRow } from "./swipe-row-gesture";
|
|
38
38
|
import { GestureToastDrag } from "./toast-drag-gesture";
|
|
39
39
|
|
|
40
|
-
// The sheet drag on Gesture Handler: the touch, the track phase and the
|
|
41
|
-
// release all run as worklets on the UI thread, so a busy JavaScript thread
|
|
42
|
-
// (a reply streaming in behind the sheet) cannot make the sheet lag the
|
|
43
|
-
// finger. The rules are the same as the `PanResponder` drag's (`sheet-drag`).
|
|
44
|
-
|
|
45
|
-
/** What a body inside the sheet needs from the drag around it. */
|
|
46
40
|
type SheetScrollLink = {
|
|
47
|
-
/** The body's native scroll, run together with the sheet's pan. */
|
|
48
41
|
native: ReturnType<typeof Gesture.Native>;
|
|
49
|
-
/** While the sheet follows the finger: the scroll offset the body holds; else `null`. */
|
|
50
42
|
heldTop: SharedValue<number | null>;
|
|
51
43
|
};
|
|
52
44
|
|
|
@@ -63,25 +55,16 @@ function motionOf(drag: SheetDragState): SheetMotion {
|
|
|
63
55
|
}
|
|
64
56
|
|
|
65
57
|
function GestureSheetDragView({ drag, enabled, style, children }: SheetDragViewProps & { drag: SheetDragState }) {
|
|
66
|
-
// Shared values only: the worklets must not capture the React setter in `drag`.
|
|
67
58
|
const motion = motionOf(drag);
|
|
68
59
|
const [native] = useState(() => Gesture.Native());
|
|
69
60
|
const heldTop = useSharedValue<number | null>(null);
|
|
70
|
-
// Where the finger touched down, and the body's scroll then.
|
|
71
61
|
const downX = useSharedValue(0);
|
|
72
62
|
const downY = useSharedValue(0);
|
|
73
63
|
const downTop = useSharedValue(0);
|
|
74
|
-
// Where the sheet was when the finger caught it, and the finger position
|
|
75
|
-
// its travel counts from (`sheetDragAnchor`). Window positions, as the
|
|
76
|
-
// sheet moves under the finger.
|
|
77
64
|
const start = useSharedValue(0);
|
|
78
65
|
const anchorY = useSharedValue(0);
|
|
79
|
-
// Built on each render (for `enabled`): the detector keeps the same handler,
|
|
80
|
-
// and a drag in flight, and only takes the new config.
|
|
81
66
|
const pan = Gesture.Pan()
|
|
82
67
|
.enabled(enabled)
|
|
83
|
-
// The same rules as the `PanResponder` capture: a touch on a sheet in
|
|
84
|
-
// motion catches it; a drag down takes it once the body is at its top.
|
|
85
68
|
.manualActivation(true)
|
|
86
69
|
.simultaneousWithExternalGesture(native)
|
|
87
70
|
.onTouchesDown((event, manager) => {
|
|
@@ -104,13 +87,11 @@ function GestureSheetDragView({ drag, enabled, style, children }: SheetDragViewP
|
|
|
104
87
|
anchorY.set(sheetDragAnchor(downY.get(), downTop.get(), motion.scrollTop.get()));
|
|
105
88
|
heldTop.set(motion.scrollTop.get());
|
|
106
89
|
})
|
|
107
|
-
// Track phase: one shared value write per frame, on the UI thread.
|
|
108
90
|
.onUpdate((event) => {
|
|
109
91
|
motion.offset.set(sheetDragOffset(start.get() + event.absoluteY - anchorY.get()));
|
|
110
92
|
})
|
|
111
93
|
.onEnd((event, success) => {
|
|
112
94
|
const position = start.get() + event.absoluteY - anchorY.get();
|
|
113
|
-
// `velocityY` is pt/s; the rules take pt/ms, as `PanResponder`'s `vy`.
|
|
114
95
|
if (settleSheet(motion, position, event.velocityY / 1000, success)) runOnJS(impactHaptic)("light");
|
|
115
96
|
})
|
|
116
97
|
.onFinalize(() => {
|
|
@@ -131,10 +112,7 @@ function GestureSheetScrollView({ drag, ...props }: ScrollViewProps & { drag: Sh
|
|
|
131
112
|
const link = useContext(SheetScrollLinkContext);
|
|
132
113
|
const heldTop = link?.heldTop;
|
|
133
114
|
const ref = useAnimatedRef<Animated.ScrollView>();
|
|
134
|
-
// The offset on the UI thread, where the pan reads it: no `onScroll` to JavaScript.
|
|
135
115
|
useScrollOffset(ref, drag.scrollTop);
|
|
136
|
-
// While the sheet follows the finger, the content stays where it was, so
|
|
137
|
-
// the scroll (which runs together with the pan) does not move it too.
|
|
138
116
|
useAnimatedReaction(
|
|
139
117
|
() => drag.scrollTop.get(),
|
|
140
118
|
(top) => {
|
|
@@ -36,20 +36,13 @@ import { tokens } from "../tokens";
|
|
|
36
36
|
import { useScheme } from "../useScheme";
|
|
37
37
|
import { useWebClickGuard } from "./web-click-guard";
|
|
38
38
|
|
|
39
|
-
// The swipeable row on Gesture Handler: the track phase and the release run
|
|
40
|
-
// as worklets on the UI thread, so the row never lags the finger. The rules
|
|
41
|
-
// are plain worklets in `swipeRow`.
|
|
42
|
-
|
|
43
|
-
/** The release: springs on at the finger's speed, no bounce (a row overshooting rest would flash the other side). */
|
|
44
39
|
const ROW_SPRING = { duration: 250, dampingRatio: 1, reduceMotion: ReduceMotion.System } as const;
|
|
45
40
|
|
|
46
|
-
/** The armed full swipe: the first action's icon grows a little, with the haptic, so the commit shows without it. */
|
|
47
41
|
const ARMED_SCALE = 1.15;
|
|
48
42
|
const ARMED_TIMING = { duration: 150, easing: EASE_OUT, reduceMotion: ReduceMotion.System } as const;
|
|
49
43
|
|
|
50
44
|
const ICON_SIZE = 20;
|
|
51
45
|
|
|
52
|
-
/** Each tone's fill and the icon colour on it. */
|
|
53
46
|
const TONES = {
|
|
54
47
|
default: { fill: palette.primary, icon: palette.primaryForeground },
|
|
55
48
|
warning: { fill: palette.warning, icon: palette.warningForeground },
|
|
@@ -66,24 +59,17 @@ export function GestureSwipeableRow({
|
|
|
66
59
|
const scheme = useScheme();
|
|
67
60
|
const x = useSharedValue(0);
|
|
68
61
|
const width = useSharedValue(0);
|
|
69
|
-
// Where the row was when the finger caught it.
|
|
70
62
|
const start = useSharedValue(0);
|
|
71
63
|
const dragging = useSharedValue(false);
|
|
72
64
|
const armed = useSharedValue<SwipeSide | null>(null);
|
|
73
65
|
const armedScale = useSharedValue(1);
|
|
74
|
-
// Plain values for the worklets: they must not capture the actions' functions.
|
|
75
66
|
const leading = leadingActions.length * SWIPE_ACTION_WIDTH;
|
|
76
67
|
const trailing = trailingActions.length * SWIPE_ACTION_WIDTH;
|
|
77
68
|
const leadingExits = leadingActions[0]?.exits === true;
|
|
78
69
|
const trailingExits = trailingActions[0]?.exits === true;
|
|
79
70
|
const [handle] = useState<SwipeRowHandle>(() => ({ close: () => x.set(withSpring(0, ROW_SPRING)) }));
|
|
80
71
|
|
|
81
|
-
// Whether this touch began while a row was open, so its release only closes that row. Nothing renders from it.
|
|
82
72
|
const closesOnRelease = useRef(false);
|
|
83
|
-
// The action strips mount on the row's first touch, not with the row: a
|
|
84
|
-
// list of a hundred rows then mounts no hidden buttons and icons up front.
|
|
85
|
-
// A touch lands a few frames before a swipe can move the row, so the strip
|
|
86
|
-
// is there before any of it shows.
|
|
87
73
|
const [revealed, setRevealed] = useState(false);
|
|
88
74
|
const reveal = () => setRevealed(true);
|
|
89
75
|
const webClicks = useWebClickGuard(isSwipeRowOpen);
|
|
@@ -95,15 +81,12 @@ export function GestureSwipeableRow({
|
|
|
95
81
|
};
|
|
96
82
|
const closed = () => markSwipeRowClosed(handle);
|
|
97
83
|
const firstOf = (side: SwipeSide) => (side === "leading" ? leadingActions[0] : trailingActions[0]);
|
|
98
|
-
/** Runs an action once the row slid out: if it fails, the row comes back. */
|
|
99
84
|
const runExited = (action: SwipeAction | undefined) => {
|
|
100
85
|
const result = action?.onPress();
|
|
101
86
|
if (result instanceof Promise) result.catch(() => x.set(withSpring(0, ROW_SPRING)));
|
|
102
87
|
};
|
|
103
|
-
// The worklets take sides, never the actions (their functions stay on the JavaScript thread).
|
|
104
88
|
const runFirstExited = (side: SwipeSide) => runExited(firstOf(side));
|
|
105
89
|
const runFirstInPlace = (side: SwipeSide) => void firstOf(side)?.onPress();
|
|
106
|
-
/** A tapped button: the row closes, or slides out for an action that exits, then the action runs. */
|
|
107
90
|
const press = (action: SwipeAction, side: SwipeSide) => {
|
|
108
91
|
closed();
|
|
109
92
|
if (!action.exits) {
|
|
@@ -120,8 +103,6 @@ export function GestureSwipeableRow({
|
|
|
120
103
|
);
|
|
121
104
|
};
|
|
122
105
|
|
|
123
|
-
// The full swipe arms and disarms as the row crosses the point: the icon
|
|
124
|
-
// grows, and a light haptic fires as it arms under the finger.
|
|
125
106
|
useAnimatedReaction(
|
|
126
107
|
() => swipeRowArmed(x.get(), { leading, trailing, width: width.get() }),
|
|
127
108
|
(side, previous) => {
|
|
@@ -133,12 +114,9 @@ export function GestureSwipeableRow({
|
|
|
133
114
|
[leading, trailing],
|
|
134
115
|
);
|
|
135
116
|
|
|
136
|
-
// Built on each render (for `enabled` and the actions): the detector keeps
|
|
137
|
-
// the same handler, and a drag in flight, and only takes the new config.
|
|
138
117
|
const activation = swipeRowActivation({ leading, trailing }, insidePager);
|
|
139
118
|
const pan = Gesture.Pan()
|
|
140
119
|
.enabled(enabled && leading + trailing > 0)
|
|
141
|
-
// Sideways intent first; a drag that goes vertical first is the list's scroll.
|
|
142
120
|
.activeOffsetX(activation.activeOffsetX)
|
|
143
121
|
.failOffsetY([-SWIPE_FAIL_OFFSET_Y, SWIPE_FAIL_OFFSET_Y]);
|
|
144
122
|
if (activation.failOffsetX !== undefined) pan.failOffsetX(activation.failOffsetX);
|
|
@@ -152,7 +130,6 @@ export function GestureSwipeableRow({
|
|
|
152
130
|
dragging.set(true);
|
|
153
131
|
runOnJS(opened)();
|
|
154
132
|
})
|
|
155
|
-
// Track phase: one shared value write per frame, on the UI thread.
|
|
156
133
|
.onUpdate((event) => {
|
|
157
134
|
x.set(swipeRowOffset(start.get() + event.translationX, { leading, trailing, width: width.get() }));
|
|
158
135
|
})
|
|
@@ -162,7 +139,6 @@ export function GestureSwipeableRow({
|
|
|
162
139
|
const settle = swipeRowSettle(x.get(), event.velocityX, { leading, trailing, width: rowWidth });
|
|
163
140
|
const velocity = event.velocityX;
|
|
164
141
|
if (success && settle.kind === "commit") {
|
|
165
|
-
// Armed by the fling rather than the position: the haptic fires now, with the commit.
|
|
166
142
|
if (armed.get() === null) runOnJS(impactHaptic)("light");
|
|
167
143
|
runOnJS(closed)();
|
|
168
144
|
const side = settle.side;
|
|
@@ -203,8 +179,6 @@ export function GestureSwipeableRow({
|
|
|
203
179
|
<Animated.View style={[{ backgroundColor: backgroundColor ?? tokens.color.background[scheme] }, rowStyle]}>
|
|
204
180
|
<View
|
|
205
181
|
ref={webClicks.ref}
|
|
206
|
-
// While a row is open, a tap on any row only closes it: the row
|
|
207
|
-
// takes the touch from the pressables inside.
|
|
208
182
|
onStartShouldSetResponderCapture={() => {
|
|
209
183
|
closesOnRelease.current = isSwipeRowOpen();
|
|
210
184
|
return closesOnRelease.current;
|
|
@@ -221,12 +195,6 @@ export function GestureSwipeableRow({
|
|
|
221
195
|
);
|
|
222
196
|
}
|
|
223
197
|
|
|
224
|
-
/**
|
|
225
|
-
* One side's actions behind the row, the first at the screen edge, on the
|
|
226
|
-
* first action's fill (which stretches with a full swipe). Shown only while
|
|
227
|
-
* the row moves toward that side. Hidden from screen readers: they reach the
|
|
228
|
-
* actions on the row itself (`swipeActionsAccessibility`).
|
|
229
|
-
*/
|
|
230
198
|
function ActionStrip({
|
|
231
199
|
side,
|
|
232
200
|
actions,
|
|
@@ -244,7 +212,6 @@ function ActionStrip({
|
|
|
244
212
|
const reveal = actions.length * SWIPE_ACTION_WIDTH;
|
|
245
213
|
const direction = side === "leading" ? 1 : -1;
|
|
246
214
|
const stripStyle = useAnimatedStyle(() => ({ opacity: x.get() * direction > 0 ? 1 : 0 }));
|
|
247
|
-
// Past its slot the first icon keeps beside the row's edge, so it stays in view.
|
|
248
215
|
const firstIconStyle = useAnimatedStyle(() => ({
|
|
249
216
|
transform: [
|
|
250
217
|
{ translateX: direction * Math.max(0, Math.abs(x.get()) - reveal) },
|
|
@@ -8,10 +8,6 @@ type SwitchProps = React.ComponentPropsWithoutRef<
|
|
|
8
8
|
> & {
|
|
9
9
|
className?: string;
|
|
10
10
|
thumbClassName?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Track and thumb colours. Flat objects: on web each part is a Radix slot,
|
|
13
|
-
* which spreads `style`, so these are the only styles applied there.
|
|
14
|
-
*/
|
|
15
11
|
trackStyle?: ViewStyle;
|
|
16
12
|
thumbStyle?: ViewProps["style"];
|
|
17
13
|
};
|
package/src/primitives/text.tsx
CHANGED
|
@@ -66,10 +66,6 @@ const ARIA_LEVEL: Partial<Record<TextVariant, string>> = {
|
|
|
66
66
|
h4: "4",
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
// The weight of each variant's `font-instrument-sans-*` class, set as a style
|
|
70
|
-
// beside it (`typeStyle`): where an app maps every one of those classes to one
|
|
71
|
-
// family, the class alone draws Regular. Headings are semibold, as the web
|
|
72
|
-
// titles; `h1` was `font-medium` before 0.3.13.
|
|
73
69
|
const WEIGHT: Partial<Record<TextVariant, ReturnType<typeof typeStyle>>> = {
|
|
74
70
|
h1: typeStyle("medium"),
|
|
75
71
|
h2: typeStyle("medium"),
|
|
@@ -18,18 +18,12 @@ import {
|
|
|
18
18
|
} from "../toastDrag";
|
|
19
19
|
import { useWebClickGuard } from "./web-click-guard";
|
|
20
20
|
|
|
21
|
-
// The toast drag on Gesture Handler: the track phase and the release run as
|
|
22
|
-
// worklets on the UI thread. The rules are plain worklets in `toastDrag`.
|
|
23
|
-
|
|
24
|
-
/** Back home after a short drag: critically damped, no bounce. */
|
|
25
21
|
const HOME_SPRING = { duration: 250, dampingRatio: 1, overshootClamping: true, reduceMotion: ReduceMotion.System } as const;
|
|
26
|
-
/** Away up the screen: no overshoot back into view. */
|
|
27
22
|
const AWAY_SPRING = { duration: 250, dampingRatio: 1, overshootClamping: true, reduceMotion: ReduceMotion.System } as const;
|
|
28
23
|
|
|
29
24
|
export function GestureToastDrag({ onDismiss, onHoldChange, children }: ToastDragProps) {
|
|
30
25
|
const y = useSharedValue(0);
|
|
31
26
|
const height = useSharedValue(0);
|
|
32
|
-
// Where the toast was when the finger caught it, and the finger's travel then.
|
|
33
27
|
const start = useSharedValue(0);
|
|
34
28
|
const startY = useSharedValue(0);
|
|
35
29
|
const webClicks = useWebClickGuard();
|
|
@@ -38,28 +32,23 @@ export function GestureToastDrag({ onDismiss, onHoldChange, children }: ToastDra
|
|
|
38
32
|
onDismiss();
|
|
39
33
|
};
|
|
40
34
|
|
|
41
|
-
// Built on each render: the detector keeps the same handler, and a drag in flight.
|
|
42
35
|
const pan = Gesture.Pan()
|
|
43
36
|
.activeOffsetY([-TOAST_DRAG_ACTIVE_OFFSET_Y, TOAST_DRAG_ACTIVE_OFFSET_Y])
|
|
44
|
-
// The timer holds from the touch, a tap included (a tap closes the toast anyway).
|
|
45
37
|
.onBegin(() => {
|
|
46
38
|
runOnJS(onHoldChange)(true);
|
|
47
39
|
})
|
|
48
40
|
.onStart((event) => {
|
|
49
41
|
cancelAnimation(y);
|
|
50
42
|
start.set(y.get());
|
|
51
|
-
// Count from here, so the toast does not jump by the slop the drag needed to start.
|
|
52
43
|
startY.set(event.translationY);
|
|
53
44
|
runOnJS(webClicks.swallowNext)();
|
|
54
45
|
})
|
|
55
|
-
// Track phase: one shared value write per frame, on the UI thread.
|
|
56
46
|
.onUpdate((event) => {
|
|
57
47
|
y.set(toastDragOffset(start.get() + event.translationY - startY.get()));
|
|
58
48
|
})
|
|
59
49
|
.onEnd((event) => {
|
|
60
50
|
const position = y.get();
|
|
61
51
|
if (toastDragDismisses(position, event.velocityY, height.get())) {
|
|
62
|
-
// Up past its own height, fading on the way (`toastStyle`), at the finger's speed.
|
|
63
52
|
y.set(
|
|
64
53
|
withSpring(-height.get() * 1.5, { ...AWAY_SPRING, velocity: event.velocityY }, (finished) => {
|
|
65
54
|
"worklet";
|
|
@@ -74,13 +63,11 @@ export function GestureToastDrag({ onDismiss, onHoldChange, children }: ToastDra
|
|
|
74
63
|
runOnJS(onHoldChange)(false);
|
|
75
64
|
});
|
|
76
65
|
|
|
77
|
-
// Linked to the same value: the toast fades as it rises, gone one height up.
|
|
78
66
|
const toastStyle = useAnimatedStyle(() => ({
|
|
79
67
|
opacity: height.get() > 0 ? interpolate(y.get(), [-height.get(), 0], [0, 1], "clamp") : 1,
|
|
80
68
|
transform: [{ translateY: y.get() }],
|
|
81
69
|
}));
|
|
82
70
|
return (
|
|
83
|
-
// Its own root: on iOS the toasts draw in a separate window (`FullWindowOverlay`).
|
|
84
71
|
<GestureHandlerRootView>
|
|
85
72
|
<GestureDetector gesture={pan}>
|
|
86
73
|
<Animated.View style={toastStyle} onLayout={(event) => height.set(event.nativeEvent.layout.height)}>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useRef, type ComponentRef } from "react";
|
|
2
2
|
import { Platform, View } from "react-native";
|
|
3
3
|
|
|
4
|
-
/** The part of a DOM element the web click guard uses: on the web a `View` is a DOM element. */
|
|
5
4
|
type DomNode = {
|
|
6
5
|
addEventListener: (type: string, listener: (event: DomEvent) => void, capture: boolean) => void;
|
|
7
6
|
removeEventListener: (type: string, listener: (event: DomEvent) => void, capture: boolean) => void;
|
|
@@ -35,7 +34,6 @@ export function useWebClickGuard(swallowOnDown: () => boolean = () => false) {
|
|
|
35
34
|
event.stopPropagation();
|
|
36
35
|
event.preventDefault();
|
|
37
36
|
};
|
|
38
|
-
// Each touch starts afresh (a touch drag clicks nothing, so its flag must not outlive it).
|
|
39
37
|
const onPointerDown = () => {
|
|
40
38
|
swallow.current = swallowOnDown();
|
|
41
39
|
};
|
|
@@ -3,13 +3,6 @@ import { BackHandler, Modal, StyleSheet, View } from "react-native";
|
|
|
3
3
|
import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
|
|
4
4
|
import { useReduceMotion } from "../useReduceMotion";
|
|
5
5
|
|
|
6
|
-
// Overlays drawn in the app's own window. A React Native `Modal` is a window
|
|
7
|
-
// of its own on Android: it takes the focus as it opens and hands it back as
|
|
8
|
-
// it closes, and each time `react-native-keyboard-controller`'s chat list
|
|
9
|
-
// scrolls to its newest message. A layer in `WindowLayerHost` is a view over
|
|
10
|
-
// the app instead, so the focus never moves. Without a host, `WindowLayer`
|
|
11
|
-
// falls back to a `Modal`, so an app that mounts none keeps working.
|
|
12
|
-
|
|
13
6
|
type Layer = { id: string; node: ReactNode; onRequestClose: () => void; onShow?: () => void; fade: boolean };
|
|
14
7
|
|
|
15
8
|
const EMPTY: readonly Layer[] = [];
|
|
@@ -34,7 +27,6 @@ const upsert = (layer: Layer) => {
|
|
|
34
27
|
emit();
|
|
35
28
|
};
|
|
36
29
|
|
|
37
|
-
// Layers that have called `onShow` once, as a Modal does once per opening.
|
|
38
30
|
const announced = new Set<string>();
|
|
39
31
|
|
|
40
32
|
const showOnce = (layer: Layer) => {
|
|
@@ -50,7 +42,6 @@ const remove = (id: string) => {
|
|
|
50
42
|
emit();
|
|
51
43
|
};
|
|
52
44
|
|
|
53
|
-
// Android back closes the newest layer, as a Modal's `onRequestClose`.
|
|
54
45
|
const onBack = () => {
|
|
55
46
|
const top = layers[layers.length - 1];
|
|
56
47
|
if (!top) return false;
|
|
@@ -58,7 +49,6 @@ const onBack = () => {
|
|
|
58
49
|
return true;
|
|
59
50
|
};
|
|
60
51
|
|
|
61
|
-
/** Mounted: the host is there, and it answers Android back for its layers. */
|
|
62
52
|
const hostRef = (view: ComponentRef<typeof View> | null) => {
|
|
63
53
|
if (view === null) return undefined;
|
|
64
54
|
hosts += 1;
|
|
@@ -78,9 +68,6 @@ const hostRef = (view: ComponentRef<typeof View> | null) => {
|
|
|
78
68
|
*/
|
|
79
69
|
export function WindowLayerHost({ children }: { children: ReactNode }) {
|
|
80
70
|
const shown = useSyncExternalStore(subscribe, () => layers, () => EMPTY);
|
|
81
|
-
// The layers fade in and out as a Modal's `fade`, unless they move on their
|
|
82
|
-
// own (`fade={false}`). With Reduce Motion they get no layout animation at
|
|
83
|
-
// all, as the fallback Modal gets `animationType="none"`.
|
|
84
71
|
const reduceMotion = useReduceMotion();
|
|
85
72
|
const enter = reduceMotion ? undefined : FadeIn.duration(200);
|
|
86
73
|
const exit = reduceMotion ? undefined : FadeOut.duration(150);
|
|
@@ -125,19 +112,14 @@ export function WindowLayer({
|
|
|
125
112
|
children,
|
|
126
113
|
}: {
|
|
127
114
|
onRequestClose: () => void;
|
|
128
|
-
/** The fallback Modal's dismiss (iOS); a layer is gone as it unmounts. */
|
|
129
115
|
onDismiss?: () => void;
|
|
130
|
-
/** Once the layer is on screen, as a Modal's `onShow`. */
|
|
131
116
|
onShow?: () => void;
|
|
132
|
-
/** Fade in and out. `false` for an overlay that runs its own motion. Default `true`. */
|
|
133
117
|
fade?: boolean;
|
|
134
118
|
children: ReactNode;
|
|
135
119
|
}) {
|
|
136
120
|
const id = useId();
|
|
137
121
|
const reduceMotion = useReduceMotion();
|
|
138
122
|
const hosted = useSyncExternalStore(subscribe, () => hosts > 0, () => false);
|
|
139
|
-
// A portal has to hand the host its children after each render: an external
|
|
140
|
-
// store fed from an effect, the one sync React offers for it.
|
|
141
123
|
useLayoutEffect(() => {
|
|
142
124
|
if (hosted) upsert({ id, node: children, onRequestClose, onShow, fade });
|
|
143
125
|
}, [hosted, id, children, onRequestClose, onShow, fade]);
|
package/src/push.ts
CHANGED
|
@@ -4,10 +4,6 @@ import type * as ExpoConstants from "expo-constants";
|
|
|
4
4
|
import type * as ExpoDevice from "expo-device";
|
|
5
5
|
import type * as ExpoNotifications from "expo-notifications";
|
|
6
6
|
|
|
7
|
-
// `expo-notifications`, `expo-constants` and `expo-device` are optional peers.
|
|
8
|
-
// Metro bundles a `require` placed directly in a `try` block as an optional
|
|
9
|
-
// dependency, so a missing peer does not break the bundle.
|
|
10
|
-
|
|
11
7
|
export type ExpoNotificationsModule = typeof ExpoNotifications;
|
|
12
8
|
export type ExpoConstantsModule = typeof ExpoConstants;
|
|
13
9
|
export type ExpoDeviceModule = typeof ExpoDevice;
|
|
@@ -63,9 +59,7 @@ export type ExpoPushTap = {
|
|
|
63
59
|
};
|
|
64
60
|
|
|
65
61
|
export type GetExpoPushTokenOptions = {
|
|
66
|
-
/** Show the permission prompt when it was never answered. */
|
|
67
62
|
ask: boolean;
|
|
68
|
-
/** Android channel id, also used as its name. Default `"default"`. */
|
|
69
63
|
channelName?: string;
|
|
70
64
|
};
|
|
71
65
|
|
|
@@ -94,7 +88,6 @@ export async function getExpoPushToken({ ask, channelName = "default" }: GetExpo
|
|
|
94
88
|
try {
|
|
95
89
|
return (await Notifications.getExpoPushTokenAsync({ projectId })).data;
|
|
96
90
|
} catch {
|
|
97
|
-
// No google-services.json in this build: FCM cannot issue a token.
|
|
98
91
|
return null;
|
|
99
92
|
}
|
|
100
93
|
}
|
|
@@ -117,18 +110,10 @@ export function showPushesInForeground(): void {
|
|
|
117
110
|
}
|
|
118
111
|
|
|
119
112
|
export type UseExpoPushRegistrationOptions = {
|
|
120
|
-
/**
|
|
121
|
-
* Saves the token on your backend, for example `useMutation(api.push.register)`.
|
|
122
|
-
* Called once on mount, with the latest function.
|
|
123
|
-
*/
|
|
124
113
|
register: (args: ExpoPushRegisterArgs) => Promise<unknown>;
|
|
125
|
-
/** Called when the user taps a push, including the tap that cold-started the app. Once per push. */
|
|
126
114
|
onNotificationTap?: (tap: ExpoPushTap) => void;
|
|
127
|
-
/** Android channel id, also used as its name. Default `"default"`. */
|
|
128
115
|
channelName?: string;
|
|
129
|
-
/** Show the permission prompt when it was never answered. Default `true`. */
|
|
130
116
|
ask?: boolean;
|
|
131
|
-
/** Show pushes as banners while the app is open. Default `true`. */
|
|
132
117
|
showInForeground?: boolean;
|
|
133
118
|
};
|
|
134
119
|
|
package/src/relativeTime.ts
CHANGED
|
@@ -1,40 +1,20 @@
|
|
|
1
|
-
// The twin of `@vvedantb/ui`'s `formatCompactRelativeTime`
|
|
2
|
-
// (`ui/app/src/time/compactRelativeTime.ts`), which `RelativeDateTime` shows.
|
|
3
|
-
// The web file pulls no DOM, but the web package does, so this is a copy;
|
|
4
|
-
// tests/relativeTime.test.ts checks both give the same strings.
|
|
5
|
-
|
|
6
1
|
export type CompactRelativeTimeOptions = {
|
|
7
|
-
/** Clock in ms. Defaults to `Date.now()`. */
|
|
8
2
|
now?: number;
|
|
9
|
-
/**
|
|
10
|
-
* Returned for anything under a minute old, including future times. When
|
|
11
|
-
* unset the result is whole seconds (`"42s"`), and a future time gives zero
|
|
12
|
-
* or a negative count (`"0s"`, `"-300s"`).
|
|
13
|
-
*/
|
|
14
3
|
justNow?: string;
|
|
15
|
-
/**
|
|
16
|
-
* `false` (default): elapsed time only. A day is 24 hours, a month 30 days,
|
|
17
|
-
* a year 12 of those months.
|
|
18
|
-
* `true`: days count local calendar days across a DST change, and months and
|
|
19
|
-
* years are calendar months, as `dayjs().diff(date, unit)` counts them.
|
|
20
|
-
*/
|
|
21
4
|
calendar?: boolean;
|
|
22
5
|
};
|
|
23
6
|
|
|
24
7
|
const MS_PER_MINUTE = 60_000;
|
|
25
8
|
const MS_PER_DAY = 86_400_000;
|
|
26
9
|
|
|
27
|
-
/** Rounds toward zero; `-0` becomes `0`. */
|
|
28
10
|
function truncate(n: number): number {
|
|
29
11
|
return n < 0 ? Math.ceil(n) || 0 : Math.floor(n);
|
|
30
12
|
}
|
|
31
13
|
|
|
32
|
-
/** Local UTC offset in minutes, rounded to 15 minutes. */
|
|
33
14
|
function utcOffset(ms: number): number {
|
|
34
15
|
return -Math.round(new Date(ms).getTimezoneOffset() / 15) * 15;
|
|
35
16
|
}
|
|
36
17
|
|
|
37
|
-
/** Adds calendar months in local time and clamps the day to the target month. */
|
|
38
18
|
function addMonths(ms: number, months: number): number {
|
|
39
19
|
const date = new Date(ms);
|
|
40
20
|
const day = date.getDate();
|
|
@@ -45,7 +25,6 @@ function addMonths(ms: number, months: number): number {
|
|
|
45
25
|
return date.getTime();
|
|
46
26
|
}
|
|
47
27
|
|
|
48
|
-
/** Fractional calendar months from `a` to `b`, negated (the moment.js formula). */
|
|
49
28
|
function monthDiff(a: number, b: number): number {
|
|
50
29
|
if (new Date(a).getDate() < new Date(b).getDate()) return -monthDiff(b, a);
|
|
51
30
|
const from = new Date(a);
|
|
@@ -2,7 +2,6 @@ import { useRouter, type Href } from "expo-router";
|
|
|
2
2
|
import { StackPageHeader, type StackPageHeaderProps } from "../StackPageHeader";
|
|
3
3
|
|
|
4
4
|
export type RouterStackPageHeaderProps = Omit<StackPageHeaderProps, "onBack"> & {
|
|
5
|
-
/** Where the back button goes when there is nothing to go back to, such as after a deep link. Default `"/"`. */
|
|
6
5
|
fallbackHref?: Href;
|
|
7
6
|
};
|
|
8
7
|
|
|
@@ -15,10 +15,6 @@ import {
|
|
|
15
15
|
type ProjectVOpenTarget,
|
|
16
16
|
} from "./projectVMobileApps";
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* The mark for each phone app. V Store has no mark of its own (it was left out
|
|
20
|
-
* of the brand marks in 0.3.9), so it shows the Project V mark.
|
|
21
|
-
*/
|
|
22
18
|
const MARK: Record<ProjectVMobileAppId, AppName> = {
|
|
23
19
|
vibot: "vibot",
|
|
24
20
|
verve: "verve",
|
|
@@ -59,13 +55,9 @@ export function FromProjectV({ className, testID }: FromProjectVProps) {
|
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
export type MoreFromProjectVProps = {
|
|
62
|
-
/** The app showing the section. It is left out of the list. */
|
|
63
58
|
current: ProjectVMobileAppId;
|
|
64
|
-
/** `"section"` (default): a settings section listing the other apps. `"footer"`: only the small "from Project V" line. */
|
|
65
59
|
variant?: "section" | "footer";
|
|
66
|
-
/** Section title. Default "More from Project V". */
|
|
67
60
|
title?: string;
|
|
68
|
-
/** Called after a row opens something: the app, V Store or its website (`null` if nothing opened). */
|
|
69
61
|
onOpen?: (id: ProjectVMobileAppId, target: ProjectVOpenTarget | null) => void;
|
|
70
62
|
className?: string;
|
|
71
63
|
};
|
|
@@ -10,9 +10,7 @@ import { relaxedSizeStyle } from "./relaxedSizeStyle";
|
|
|
10
10
|
export type SettingsEmptyStateProps = {
|
|
11
11
|
title: string;
|
|
12
12
|
description?: string;
|
|
13
|
-
/** Optional icon above the title, as on the web. */
|
|
14
13
|
icon?: ComponentType<IconProps>;
|
|
15
|
-
/** Below the text, such as a `Button`. */
|
|
16
14
|
action?: ReactNode;
|
|
17
15
|
testID?: string;
|
|
18
16
|
};
|