@vvedantb/native-ui 0.38.0 → 0.39.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 +0 -1
- 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 +0 -8
- 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 +0 -27
- 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 +0 -1
- 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 +0 -17
- 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 +0 -97
- 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
|
@@ -14,7 +14,6 @@ import { chatTextSize } from "./chat-text";
|
|
|
14
14
|
import { MESSAGE_MENU, messageContextMenuLayout, type MessageMenu, type MessageMenuRect } from "./message-menu-layout";
|
|
15
15
|
import { usePressed } from "../usePressed";
|
|
16
16
|
|
|
17
|
-
/** How far the held message lifts as the menu opens: a little, so a tall one stays in its room. */
|
|
18
17
|
const LIFT_SCALE = 1.02;
|
|
19
18
|
|
|
20
19
|
/**
|
|
@@ -42,13 +41,9 @@ export function MessageContextMenu({
|
|
|
42
41
|
}: {
|
|
43
42
|
open: boolean;
|
|
44
43
|
onClose: () => void;
|
|
45
|
-
/** After the menu has gone from the screen (iOS; Android gives no such callback for a `Modal`). */
|
|
46
44
|
onDismissed?: () => void;
|
|
47
|
-
/** The held message's box; the menu stays shut without one. */
|
|
48
45
|
anchor: MessageMenuRect | null;
|
|
49
|
-
/** Which side the pill and the card line up with: the message's (`end` for the user's). */
|
|
50
46
|
align: "start" | "end";
|
|
51
|
-
/** The message, drawn again over the blur. */
|
|
52
47
|
preview: ReactNode;
|
|
53
48
|
menu: MessageMenu;
|
|
54
49
|
testID?: string;
|
|
@@ -59,12 +54,9 @@ export function MessageContextMenu({
|
|
|
59
54
|
const largerText = useLargerText();
|
|
60
55
|
const rowHeight = largerText ? 56 : 48;
|
|
61
56
|
const body = chatTextSize("body", largerText);
|
|
62
|
-
// 0 to 1 as the menu opens, started from the menu's first layout: a shared value runs in a
|
|
63
|
-
// layer and in the fallback Modal alike (Reanimated's entering does not run inside a Modal on Android).
|
|
64
57
|
const shown = useSharedValue(0);
|
|
65
58
|
const popStyle = useAnimatedStyle(() => ({ transform: [{ scale: PANEL_SCALE_FROM + (1 - PANEL_SCALE_FROM) * shown.get() }] }));
|
|
66
59
|
const liftStyle = useAnimatedStyle(() => ({ transform: [{ scale: 1 + (LIFT_SCALE - 1) * shown.get() }] }));
|
|
67
|
-
// `POPOVER_ENTER` reduces with the system setting: with Reduce Motion the menu is in place at once.
|
|
68
60
|
const appear = () => {
|
|
69
61
|
shown.set(0);
|
|
70
62
|
shown.set(withTiming(1, POPOVER_ENTER));
|
|
@@ -82,7 +74,6 @@ export function MessageContextMenu({
|
|
|
82
74
|
onClose();
|
|
83
75
|
action();
|
|
84
76
|
};
|
|
85
|
-
// The pill and the card line up with the message's side, kept on screen.
|
|
86
77
|
const side = (width: number) =>
|
|
87
78
|
align === "end"
|
|
88
79
|
? { left: Math.max(MESSAGE_MENU.edge, Math.min(anchor.x + anchor.width, window.width - MESSAGE_MENU.edge) - width) }
|
|
@@ -92,8 +83,6 @@ export function MessageContextMenu({
|
|
|
92
83
|
const pillWidth = Math.min(window.width - 2 * MESSAGE_MENU.edge, (menu.reactions?.items.length ?? 0) * 48 + 16);
|
|
93
84
|
|
|
94
85
|
return (
|
|
95
|
-
// In the app's window (`WindowLayer`): a Modal's own window moved the focus on Android, and the chat
|
|
96
|
-
// list's keyboard handling scrolled to the newest message as it opened and closed.
|
|
97
86
|
<WindowLayer onRequestClose={onClose} onDismiss={onDismissed}>
|
|
98
87
|
<View style={{ flex: 1 }} testID={testID} accessibilityViewIsModal onAccessibilityEscape={onClose} onLayout={appear}>
|
|
99
88
|
<View style={StyleSheet.absoluteFill}>
|
|
@@ -102,12 +91,9 @@ export function MessageContextMenu({
|
|
|
102
91
|
accessibilityRole="button"
|
|
103
92
|
accessibilityLabel="Close menu"
|
|
104
93
|
onPress={onClose}
|
|
105
|
-
// A frosted wash of the screen colour over the chat, as iMessage's blur reads: the `ai`
|
|
106
|
-
// entry reaches no optional peer, so it draws no `expo-blur`.
|
|
107
94
|
style={[StyleSheet.absoluteFill, { backgroundColor: withAlpha(tokens.color.background[scheme], 0.85) }]}
|
|
108
95
|
/>
|
|
109
96
|
</View>
|
|
110
|
-
{/* The held message, lifted: in place, on the screen colour with a shadow, clipped when it is taller than the room. */}
|
|
111
97
|
<Animated.View
|
|
112
98
|
pointerEvents="none"
|
|
113
99
|
style={[{
|
|
@@ -117,7 +103,6 @@ export function MessageContextMenu({
|
|
|
117
103
|
width: anchor.width,
|
|
118
104
|
height: layout.previewHeight,
|
|
119
105
|
overflow: "hidden",
|
|
120
|
-
// The screen colour behind the copy: a reply without a bubble would show the dimmed original through it.
|
|
121
106
|
backgroundColor: tokens.color.background[scheme],
|
|
122
107
|
borderRadius: tokens.radius.card,
|
|
123
108
|
...shadow,
|
|
@@ -135,11 +120,9 @@ export function MessageContextMenu({
|
|
|
135
120
|
height: MESSAGE_MENU.pillHeight,
|
|
136
121
|
borderRadius: MESSAGE_MENU.pillHeight / 2,
|
|
137
122
|
backgroundColor: surface,
|
|
138
|
-
// Styles, not classes: this is a Reanimated view.
|
|
139
123
|
flexDirection: "row",
|
|
140
124
|
alignItems: "center",
|
|
141
125
|
paddingHorizontal: 8,
|
|
142
|
-
// Grows from the corner next to the message.
|
|
143
126
|
transformOrigin: align === "end" ? "right bottom" : "left bottom",
|
|
144
127
|
...shadow,
|
|
145
128
|
}, popStyle]}
|
|
@@ -196,10 +179,6 @@ export function MessageContextMenu({
|
|
|
196
179
|
);
|
|
197
180
|
}
|
|
198
181
|
|
|
199
|
-
/**
|
|
200
|
-
* One card row: label first, icon last. While pressed it takes the
|
|
201
|
-
* `SheetRow` pressed fill, so the finger sees which row it is on.
|
|
202
|
-
*/
|
|
203
182
|
function MenuCardRow({
|
|
204
183
|
testID,
|
|
205
184
|
action,
|
|
@@ -218,7 +197,6 @@ function MenuCardRow({
|
|
|
218
197
|
onPress: () => void;
|
|
219
198
|
}) {
|
|
220
199
|
const scheme = useScheme();
|
|
221
|
-
// A state, not a style function: with a `className`, NativeWind drops a style function.
|
|
222
200
|
const press = usePressed();
|
|
223
201
|
const disabled = action.disabled === true;
|
|
224
202
|
const Icon = action.icon;
|
package/src/ai/message-quote.tsx
CHANGED
|
@@ -9,13 +9,9 @@ import { chatTextSize } from "./chat-text";
|
|
|
9
9
|
import { ChatTextColorContext } from "./response-text";
|
|
10
10
|
|
|
11
11
|
export type MessageQuoteProps = {
|
|
12
|
-
/** Who wrote the quoted message, such as "You" or the bot name. */
|
|
13
12
|
author: string;
|
|
14
|
-
/** The quoted text. Shown on up to two lines. */
|
|
15
13
|
text: string;
|
|
16
|
-
/** Makes the quote a button, so the app can scroll to and highlight the original. */
|
|
17
14
|
onPress?: () => void;
|
|
18
|
-
/** Names the button. Default "Go to quoted message from {author}". Used with `onPress` only. */
|
|
19
15
|
accessibilityLabel?: string;
|
|
20
16
|
className?: string;
|
|
21
17
|
testID?: string;
|
package/src/ai/message.tsx
CHANGED
|
@@ -33,33 +33,11 @@ const MessageContext = createContext<MessageRole>("assistant");
|
|
|
33
33
|
export type MessageProps = ViewProps & {
|
|
34
34
|
from: MessageRole;
|
|
35
35
|
className?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Called on a long press of the message. Without it (and without `actions`)
|
|
38
|
-
* the message is a plain `View`, as before.
|
|
39
|
-
*/
|
|
40
36
|
onLongPress?: () => void;
|
|
41
|
-
/**
|
|
42
|
-
* The iMessage hold menu (`MessageContextMenu`): built when the message is
|
|
43
|
-
* held, so a long list builds none up front. Takes over from `actions`.
|
|
44
|
-
*/
|
|
45
37
|
menu?: () => MessageMenu;
|
|
46
|
-
/**
|
|
47
|
-
* Actions for a `MessageActionSheet` that opens on a long press, such as
|
|
48
|
-
* Reply and Copy. `onLongPress` also runs, before the sheet opens.
|
|
49
|
-
*/
|
|
50
38
|
actions?: MessageSheetAction[];
|
|
51
|
-
/** Title of the action sheet. Default "Message actions". */
|
|
52
39
|
actionSheetTitle?: string;
|
|
53
|
-
/**
|
|
54
|
-
* True while the message is the target of a quote tap: a primary wash that
|
|
55
|
-
* fades over about 1.4 seconds, and a ring while it stays true. Set it back
|
|
56
|
-
* to `false` after the scroll, about 1.5 seconds later.
|
|
57
|
-
*/
|
|
58
40
|
highlighted?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* For group chats: which bot sent this message. Draws a `MessageBotLabel`
|
|
61
|
-
* (avatar and name) above the content. Only when set; assistant messages only.
|
|
62
|
-
*/
|
|
63
41
|
bot?: MessageBot;
|
|
64
42
|
};
|
|
65
43
|
|
|
@@ -69,7 +47,6 @@ export type MessageBot = { name: string; avatar?: ReactNode };
|
|
|
69
47
|
/** How long the highlight wash takes to fade, in milliseconds. */
|
|
70
48
|
export const MESSAGE_HIGHLIGHT_MS = 1400;
|
|
71
49
|
|
|
72
|
-
/** Peak opacity of the highlight wash (the primary colour). */
|
|
73
50
|
const HIGHLIGHT_WASH = 0.18;
|
|
74
51
|
|
|
75
52
|
function MessageHighlight() {
|
|
@@ -103,25 +80,7 @@ function MessageHighlight() {
|
|
|
103
80
|
);
|
|
104
81
|
}
|
|
105
82
|
|
|
106
|
-
/**
|
|
107
|
-
* One message: the web `w-full max-w-[95%] flex-col gap-2`. A user message
|
|
108
|
-
* sits at the end of the row with its parts at the end; an assistant message
|
|
109
|
-
* at the start, its parts full width.
|
|
110
|
-
*
|
|
111
|
-
* With `onLongPress` or `actions` the message is a `Pressable` (same layout,
|
|
112
|
-
* `className`, `style` and view props): a 350 ms hold dims it a little,
|
|
113
|
-
* fires a medium haptic, runs `onLongPress` and opens the
|
|
114
|
-
* `MessageActionSheet`; TalkBack reaches it as the `longpress` action. It stays
|
|
115
|
-
* a non-accessible container so its buttons and links keep their own focus:
|
|
116
|
-
* also offer the actions in a `MessageActionsBar` for screen reader users. `highlighted` draws the quote-jump highlight.
|
|
117
|
-
*/
|
|
118
|
-
/** How long a hold takes, in ms: shorter than React Native's 500, as iMessage. */
|
|
119
83
|
const HOLD_DELAY_MS = 350;
|
|
120
|
-
/**
|
|
121
|
-
* A held message dims a little. It does not shrink: the hold menu measures the
|
|
122
|
-
* message while it is held, and a scaled box would draw the lifted copy smaller
|
|
123
|
-
* (and could wrap its text differently).
|
|
124
|
-
*/
|
|
125
84
|
const HELD_STYLE = { opacity: 0.9 };
|
|
126
85
|
|
|
127
86
|
export function Message({
|
|
@@ -140,16 +99,12 @@ export function Message({
|
|
|
140
99
|
const user = from === "user";
|
|
141
100
|
const [sheetOpen, setSheetOpen] = useState(false);
|
|
142
101
|
const press = usePressed();
|
|
143
|
-
// The open context menu: where the message was and what it offers, read at the hold.
|
|
144
102
|
const [held, setHeld] = useState<{ anchor: MessageMenuRect; menu: MessageMenu } | null>(null);
|
|
145
|
-
// Measured at the hold: the menu draws the message again where it is on screen.
|
|
146
103
|
const pressable = useRef<ComponentRef<typeof View>>(null);
|
|
147
104
|
const hasActions = actions != null && actions.length > 0;
|
|
148
105
|
const longPressable = onLongPress != null || hasActions || menu != null;
|
|
149
|
-
// In a thread, the menu freezes the list's keyboard handling until its close settles (see `overlay`).
|
|
150
106
|
const conversation = useOptionalConversation();
|
|
151
107
|
const longPress = () => {
|
|
152
|
-
// A medium tap on a hold, as iMessage; the sheet adds its own selection tick.
|
|
153
108
|
impactHaptic("medium");
|
|
154
109
|
onLongPress?.();
|
|
155
110
|
if (menu) {
|
|
@@ -182,14 +137,11 @@ export function Message({
|
|
|
182
137
|
ref={pressable}
|
|
183
138
|
accessible={false}
|
|
184
139
|
className={merged}
|
|
185
|
-
// While held it dims a little: the feedback before the menu opens. A state, not a
|
|
186
|
-
// style function: with a `className`, NativeWind drops a style function, layout and all.
|
|
187
140
|
style={[layout, press.pressed ? HELD_STYLE : null]}
|
|
188
141
|
onPressIn={press.onPressIn}
|
|
189
142
|
onPressOut={press.onPressOut}
|
|
190
143
|
onLongPress={longPress}
|
|
191
144
|
delayLongPress={HOLD_DELAY_MS}
|
|
192
|
-
// TalkBack's actions menu reaches the same sheet as a long press.
|
|
193
145
|
accessibilityActions={[{ name: "longpress", label: actionSheetTitle ?? MESSAGE_ACTIONS_TITLE }]}
|
|
194
146
|
onAccessibilityAction={(event) => {
|
|
195
147
|
if (event.nativeEvent.actionName === "longpress") longPress();
|
|
@@ -262,7 +214,6 @@ export function tintBubbleStyle(scheme: "light" | "dark") {
|
|
|
262
214
|
|
|
263
215
|
export type MessageBotLabelProps = {
|
|
264
216
|
name: string;
|
|
265
|
-
/** An avatar node, such as `<Avatar size="xs" />`. Drawn before the name. */
|
|
266
217
|
avatar?: ReactNode;
|
|
267
218
|
className?: string;
|
|
268
219
|
testID?: string;
|
|
@@ -297,9 +248,7 @@ export function MessageBotLabel({ name, avatar, className, testID = "message-bot
|
|
|
297
248
|
}
|
|
298
249
|
|
|
299
250
|
export type MessageContentProps = ViewProps & {
|
|
300
|
-
/** User messages only. Default `"primary"`. */
|
|
301
251
|
bubble?: MessageBubble;
|
|
302
|
-
/** A `MessageQuote` drawn above the content, inside the bubble. */
|
|
303
252
|
quote?: ReactNode;
|
|
304
253
|
className?: string;
|
|
305
254
|
};
|
|
@@ -341,10 +290,6 @@ export function MessageContent({ children, bubble = "primary", quote, className,
|
|
|
341
290
|
|
|
342
291
|
export type MessageMetaProps = {
|
|
343
292
|
children: ReactNode;
|
|
344
|
-
/**
|
|
345
|
-
* Default `caption` (`text-xs`, 12 / 16). `2xs` is the web `text-2xs` token
|
|
346
|
-
* (11 / 16), as Eva's web chat. Larger text draws both at the caption step.
|
|
347
|
-
*/
|
|
348
293
|
size?: "caption" | "2xs";
|
|
349
294
|
className?: string;
|
|
350
295
|
};
|
|
@@ -391,23 +336,12 @@ export const MESSAGE_ACTIONS = {
|
|
|
391
336
|
export type MessageActionKind = keyof typeof MESSAGE_ACTIONS;
|
|
392
337
|
|
|
393
338
|
export type MessageActionProps = {
|
|
394
|
-
/** A preset icon and label from `MESSAGE_ACTIONS`. `icon` and `label` override it. */
|
|
395
339
|
kind?: MessageActionKind;
|
|
396
340
|
icon?: ComponentType<IconProps>;
|
|
397
|
-
/** The accessibility label (the web `label` / `tooltip`). Required without `kind`. */
|
|
398
341
|
label?: string;
|
|
399
342
|
onPress?: () => void;
|
|
400
|
-
/**
|
|
401
|
-
* For feedback: the chosen action draws its icon in the foreground and
|
|
402
|
-
* reports `selected` to VoiceOver and TalkBack.
|
|
403
|
-
*/
|
|
404
343
|
selected?: boolean;
|
|
405
344
|
disabled?: boolean;
|
|
406
|
-
/**
|
|
407
|
-
* Default `sm`, the web `icon-sm` (32, 16 icon). `xs` is the web `icon-xs`
|
|
408
|
-
* (28, 14 icon), as Eva's web chat; `touch` is a whole 44 square (16 icon)
|
|
409
|
-
* for a phone, so the row needs no slop.
|
|
410
|
-
*/
|
|
411
345
|
size?: ChatIconButtonSize;
|
|
412
346
|
testID?: string;
|
|
413
347
|
};
|
|
@@ -21,16 +21,9 @@ export function promptInputMenuHeight(windowHeight: number): number {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export type PromptInputMenuProps = {
|
|
24
|
-
/** Names the list for VoiceOver and TalkBack, as the web listbox `aria-label` (such as "Mentions" or "Skills"). */
|
|
25
24
|
title: string;
|
|
26
|
-
/** `PromptInputMenuItem`s. With none, `empty` shows instead. */
|
|
27
25
|
children?: ReactNode;
|
|
28
|
-
/** Shown when there are no rows. Default "No matches.", as the web. */
|
|
29
26
|
empty?: ReactNode;
|
|
30
|
-
/**
|
|
31
|
-
* Closes the picker, as Escape does on the web. Android back calls it while
|
|
32
|
-
* the picker is mounted, before the screen behind gets the press.
|
|
33
|
-
*/
|
|
34
27
|
onDismiss?: () => void;
|
|
35
28
|
testID?: string;
|
|
36
29
|
};
|
|
@@ -46,7 +39,6 @@ export type PromptInputMenuProps = {
|
|
|
46
39
|
*/
|
|
47
40
|
export function PromptInputMenu({ title, children, empty = "No matches.", onDismiss, testID }: PromptInputMenuProps) {
|
|
48
41
|
const scheme = useScheme();
|
|
49
|
-
// Back closes the picker first. An effect: the subscription is a native one.
|
|
50
42
|
useEffect(() => {
|
|
51
43
|
if (!onDismiss) return;
|
|
52
44
|
const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
@@ -78,7 +70,6 @@ export function PromptInputMenu({ title, children, empty = "No matches.", onDism
|
|
|
78
70
|
{children}
|
|
79
71
|
</ScrollView>
|
|
80
72
|
) : (
|
|
81
|
-
// Web: `px-3 py-2.5 text-xs leading-relaxed text-muted-foreground`.
|
|
82
73
|
<Text
|
|
83
74
|
className="px-3 py-2.5 font-instrument-sans text-xs"
|
|
84
75
|
style={[sizeStyle("text-xs", "relaxed"), textStyle("muted", scheme)]}
|
|
@@ -90,29 +81,21 @@ export function PromptInputMenu({ title, children, empty = "No matches.", onDism
|
|
|
90
81
|
);
|
|
91
82
|
}
|
|
92
83
|
|
|
93
|
-
/** Web badge chip: `rounded-md bg-muted px-1.5 py-0.5 text-3xs font-medium` (10). */
|
|
94
84
|
const BADGE_TEXT = { fontSize: 10, lineHeight: 12 } as const;
|
|
95
85
|
|
|
96
86
|
export type PromptInputMenuItemProps = {
|
|
97
|
-
/** The character that inserts this row, muted before the label: `@` or `/`. Left out when `leading` names a person. */
|
|
98
87
|
prefix?: string;
|
|
99
88
|
label: string;
|
|
100
|
-
/** One muted line under the label, such as a skill's description. */
|
|
101
89
|
description?: string;
|
|
102
|
-
/** Before the text, such as a teammate's `Avatar` (24). */
|
|
103
90
|
leading?: ReactNode;
|
|
104
|
-
/** At the end in place of `badge`, such as a 16 kind icon. */
|
|
105
91
|
trailing?: ReactNode;
|
|
106
|
-
/** A small source chip at the end (such as "Eva" or "Claude"), with an optional 11 `badgeIcon`. */
|
|
107
92
|
badge?: string;
|
|
108
93
|
badgeIcon?: ReactNode;
|
|
109
|
-
/** The row Return picks, tinted as the web's keyboard-selected row. */
|
|
110
94
|
selected?: boolean;
|
|
111
95
|
onPress?: () => void;
|
|
112
96
|
testID?: string;
|
|
113
97
|
};
|
|
114
98
|
|
|
115
|
-
/** A description longer than this is cut with "…", as the web `previewOneLine`. */
|
|
116
99
|
const DESCRIPTION_MAX = 72;
|
|
117
100
|
|
|
118
101
|
function oneLine(text: string): string {
|
|
@@ -163,9 +146,7 @@ export function PromptInputMenuItem({
|
|
|
163
146
|
accessibilityState={{ selected }}
|
|
164
147
|
accessibilityLabel={[`${prefix ?? ""}${label}`, detail, badge].filter(Boolean).join(", ")}
|
|
165
148
|
onPress={onPress}
|
|
166
|
-
// Already 44 high and the list's width: no slop past the row.
|
|
167
149
|
hitSlop={touchSlop(MIN_TOUCH_TARGET)}
|
|
168
|
-
// A plain style: NativeWind drops a function `style` beside `className`.
|
|
169
150
|
className={cn("mx-1 flex-row items-center gap-2 px-2 py-1.5 active:opacity-70", largerText && "py-2")}
|
|
170
151
|
style={{
|
|
171
152
|
minHeight: MIN_TOUCH_TARGET,
|
package/src/ai/prompt-input.tsx
CHANGED
|
@@ -27,18 +27,11 @@ export type PromptInputSubmitProps = {
|
|
|
27
27
|
status?: ChatStatus;
|
|
28
28
|
onSubmit?: () => void;
|
|
29
29
|
onStop?: () => void;
|
|
30
|
-
/** Whether there is something to send. Default `true`. */
|
|
31
30
|
canSubmit?: boolean;
|
|
32
|
-
/** Default `sm` (32). `md` is 36, the `pill` composer's send button. */
|
|
33
31
|
size?: ChatIconButtonSize;
|
|
34
32
|
testID?: string;
|
|
35
33
|
};
|
|
36
34
|
|
|
37
|
-
// The web `PromptInputSubmit` and `PromptInputButton` keep `shape="rounded"`
|
|
38
|
-
// (`rounded-lg`, 16) as field addons. At the 32 `icon-sm` size 16 is half the
|
|
39
|
-
// side, so the web draws a circle. These stay pills: the same circle at 32, and
|
|
40
|
-
// still a circle at 44 with larger text, where 16 would draw a rounded square.
|
|
41
|
-
|
|
42
35
|
/**
|
|
43
36
|
* Send, or stop while the AI answers: the web `default` `icon-sm` button
|
|
44
37
|
* (32, round, slop to 44). Send is an up arrow on the primary fill, faded by
|
|
@@ -104,36 +97,21 @@ export const PROMPT_INPUT_CHIP = {
|
|
|
104
97
|
chevronSize: 12,
|
|
105
98
|
chevronOpacity: 0.6,
|
|
106
99
|
suffixOpacity: 0.7,
|
|
107
|
-
/** The narrowest label worth drawing: about two characters and the ellipsis at `text-sm` (2em). */
|
|
108
100
|
labelMinWidth: 28,
|
|
109
|
-
/** `size="touch"`: 36 on screen, 4 slop above and below, so a 44 bar holds its whole target. */
|
|
110
101
|
touchHeight: 36,
|
|
111
102
|
} as const;
|
|
112
103
|
|
|
113
104
|
export type PromptInputChipProps = {
|
|
114
|
-
/** Before the label: a `PROMPT_INPUT_CHIP.iconSize` (14) mark, such as `ProviderIcon` or a Tabler icon. */
|
|
115
105
|
icon?: ReactNode;
|
|
116
106
|
label: string;
|
|
117
|
-
/** After the label, " · " between, at 70% of `color`: the web trigger suffix (the reasoning level). */
|
|
118
107
|
suffix?: string;
|
|
119
|
-
/** After the label in medium weight with tabular figures, such as a saved count. */
|
|
120
108
|
count?: number;
|
|
121
|
-
/** The chevron after the label. Default `true`. */
|
|
122
109
|
chevron?: boolean;
|
|
123
|
-
/** Label weight. Default `medium`, the web trigger; a quieter footer passes `normal`. */
|
|
124
110
|
weight?: "normal" | "medium";
|
|
125
|
-
/** Text, chevron and Tabler icon colour. Default `tokens.color.muted`, the web `text-muted-foreground`. */
|
|
126
111
|
color?: string;
|
|
127
|
-
/** Default: the label, then the suffix and count. */
|
|
128
112
|
accessibilityLabel?: string;
|
|
129
|
-
/** Whether the menu it opens is open, for VoiceOver and TalkBack. */
|
|
130
113
|
expanded?: boolean;
|
|
131
114
|
disabled?: boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Default `sm`, the web trigger: 28 high, slop to 44. `touch` has no web
|
|
134
|
-
* twin: 36 high, for a phone bar that is 44 itself, so the slop stays
|
|
135
|
-
* inside the bar and never reaches the field above.
|
|
136
|
-
*/
|
|
137
115
|
size?: "sm" | "touch";
|
|
138
116
|
onPress?: () => void;
|
|
139
117
|
testID?: string;
|
|
@@ -167,10 +145,6 @@ export function PromptInputChip({
|
|
|
167
145
|
const scheme = useScheme();
|
|
168
146
|
const pressed = usePressFeedback();
|
|
169
147
|
const { fontScale } = useWindowDimensions();
|
|
170
|
-
// Whether the label slot is wide enough to read. Hiding it only sets the
|
|
171
|
-
// opacity, so the layout and the next `onLayout` width stay the same: the
|
|
172
|
-
// state changes once per threshold crossing, never in a layout loop, and a
|
|
173
|
-
// wider slot later shows the label again.
|
|
174
148
|
const [readable, setReadable] = useState(true);
|
|
175
149
|
const tint = color ?? tokens.color.muted[scheme];
|
|
176
150
|
const text = [sizeStyle("text-sm"), { color: tint }];
|
|
@@ -183,10 +157,8 @@ export function PromptInputChip({
|
|
|
183
157
|
accessibilityState={{ disabled, expanded }}
|
|
184
158
|
disabled={disabled}
|
|
185
159
|
onPress={onPress}
|
|
186
|
-
// Slop only above and below: chips sit side by side, so the width stays theirs.
|
|
187
160
|
hitSlop={touchSlop(MIN_TOUCH_TARGET, height)}
|
|
188
161
|
className={cn("min-w-0 shrink flex-row items-center", pressed, disabled && "opacity-50")}
|
|
189
|
-
// `minHeight`, so a larger system font size can still grow it.
|
|
190
162
|
style={{
|
|
191
163
|
minHeight: height,
|
|
192
164
|
paddingHorizontal: PROMPT_INPUT_CHIP.paddingX,
|
|
@@ -194,7 +166,6 @@ export function PromptInputChip({
|
|
|
194
166
|
borderRadius: PROMPT_INPUT_CHIP.radius,
|
|
195
167
|
}}
|
|
196
168
|
>
|
|
197
|
-
{/* Held whole: in a squeezed chip only the label gives up width. */}
|
|
198
169
|
{icon ? <View className="shrink-0">{icon}</View> : null}
|
|
199
170
|
<Text
|
|
200
171
|
numberOfLines={1}
|
|
@@ -228,85 +199,33 @@ export type PromptInputProps = {
|
|
|
228
199
|
value?: string;
|
|
229
200
|
defaultValue?: string;
|
|
230
201
|
onChangeText?: (text: string) => void;
|
|
231
|
-
/** Called with the trimmed text when Send is pressed. The field then clears. */
|
|
232
202
|
onSubmit: (text: string) => void;
|
|
233
203
|
status?: ChatStatus;
|
|
234
204
|
onStop?: () => void;
|
|
235
|
-
/** Default "What would you like to know?", as on the web. */
|
|
236
205
|
placeholder?: string;
|
|
237
|
-
/** Names the field for VoiceOver and TalkBack. Default "Message". */
|
|
238
206
|
accessibilityLabel?: string;
|
|
239
|
-
/**
|
|
240
|
-
* A pending reply above the field and above `header`: a `ReplyQuoteChip`.
|
|
241
|
-
* Clear it in the app with the chip's `onDismiss`. A `ReplyQuoteChip` as
|
|
242
|
-
* `header` works as well, beside any attachments.
|
|
243
|
-
*/
|
|
244
207
|
replyTo?: ReactNode;
|
|
245
|
-
/** Above the field, such as `Attachments`. */
|
|
246
208
|
header?: ReactNode;
|
|
247
|
-
/** Before the send button, such as `PromptInputButton`s. */
|
|
248
209
|
toolbar?: ReactNode;
|
|
249
|
-
/**
|
|
250
|
-
* Under the field, inside the keyboard lift and above the bottom inset: a
|
|
251
|
-
* row of `PromptInputChip`s, as the bar under Eva's web composer.
|
|
252
|
-
*/
|
|
253
210
|
footer?: ReactNode;
|
|
254
|
-
/**
|
|
255
|
-
* Right above the field, the field's width and 6 clear of it, inside the
|
|
256
|
-
* keyboard lift: a `PromptInputMenu`, the web `@` / `/` picker. Pass it only
|
|
257
|
-
* while the picker is open.
|
|
258
|
-
*/
|
|
259
211
|
menu?: ReactNode;
|
|
260
|
-
/**
|
|
261
|
-
* Images pasted into the field (long-press Paste, or the keyboard's image
|
|
262
|
-
* insert), as `file://` URIs. Needs `PasteInputProvider` from
|
|
263
|
-
* `@vvedantb/native-ui/paste-input`; without it a field takes text only.
|
|
264
|
-
*/
|
|
265
212
|
onPasteImages?: (uris: string[]) => void;
|
|
266
|
-
/**
|
|
267
|
-
* `stacked` (default): the field over a footer of tools and send, the web
|
|
268
|
-
* `PromptInput`. `inline`: one row, as the web `Composer layout="inline"`
|
|
269
|
-
* (Eva's chat): `leading`, the field, `toolbar`, then send, in a 20-radius
|
|
270
|
-
* field with `p-1.5`, 44 high on one line.
|
|
271
|
-
*/
|
|
272
213
|
layout?: "stacked" | "inline";
|
|
273
|
-
/**
|
|
274
|
-
* `inline` only. `rounded` (default): the web `Composer` field, radius 20.
|
|
275
|
-
* `pill`: Eva's web chat composer (`h-12 rounded-full py-1`): 48 high on one
|
|
276
|
-
* line, a 36 send button and a `text-sm` (14 / 20) field 36 high; it keeps
|
|
277
|
-
* radius 24 as it grows. Give the + a filled `variant="secondary"`, as Eva.
|
|
278
|
-
*/
|
|
279
214
|
shape?: "rounded" | "pill";
|
|
280
|
-
/** `inline` only: before the field, such as a + (attach) `PromptInputButton`. */
|
|
281
215
|
leading?: ReactNode;
|
|
282
216
|
disabled?: boolean;
|
|
283
|
-
/** Pad the bottom safe-area inset (home indicator). Default `true`; turn it off when a tab bar below already does. */
|
|
284
217
|
safeBottom?: boolean;
|
|
285
|
-
/** Height of anything above the screen's own top, such as a navigation header, for the keyboard lift. Default 0. */
|
|
286
218
|
keyboardVerticalOffset?: number;
|
|
287
219
|
className?: string;
|
|
288
220
|
testID?: string;
|
|
289
221
|
};
|
|
290
222
|
|
|
291
|
-
/** The web `Composer` inline radius, `rounded-[1.25rem]`. */
|
|
292
223
|
const INLINE_RADIUS = 20;
|
|
293
224
|
|
|
294
|
-
/**
|
|
295
|
-
* Eva's `pill` composer: 48 high on one line (border 1, then 5 around a 36
|
|
296
|
-
* field: the web `h-12 py-1` centres the 36 field and send button in 38),
|
|
297
|
-
* `pl-1.5` / `pr-1.5`, and radius 24 (`rounded-full` at 48). Its placeholder
|
|
298
|
-
* is the muted colour at 90% (`data-empty:before:text-muted-foreground/90`).
|
|
299
|
-
*/
|
|
300
225
|
const PILL = { radius: 24, paddingY: 5, paddingX: 6, lineHeight: 36, placeholderAlpha: 0.9 } as const;
|
|
301
226
|
|
|
302
|
-
/** The field grows to this height, then scrolls: about 6 lines of 24 (with `py-2.5`), and about 8 of `text-xl` with larger text. */
|
|
303
227
|
const MAX_FIELD_HEIGHT = { regular: 160, larger: 240 } as const;
|
|
304
228
|
|
|
305
|
-
/**
|
|
306
|
-
* React Native Web draws a multiline field as a `textarea` with the HTML
|
|
307
|
-
* default of 2 rows, and the auto-grow keeps that height. One row there; on
|
|
308
|
-
* native, `numberOfLines` would lock the line count on Android, so none.
|
|
309
|
-
*/
|
|
310
229
|
const ONE_ROW = Platform.OS === "web" ? 1 : undefined;
|
|
311
230
|
|
|
312
231
|
/**
|
|
@@ -348,29 +267,22 @@ export function PromptInput({
|
|
|
348
267
|
const insets = useSafeAreaInsets();
|
|
349
268
|
const lifted = useContext(KeyboardLiftContext);
|
|
350
269
|
const paste = usePasteParts();
|
|
351
|
-
// The field inside the paste target when an app takes pasted images; it then fills the target.
|
|
352
270
|
const pasteTarget = paste && onPasteImages ? paste.Target : null;
|
|
353
271
|
const [text, setText] = useControllableState({ value, defaultValue, onChange: onChangeText });
|
|
354
272
|
const message = text.trim();
|
|
355
273
|
const canSubmit = message.length > 0 && !disabled && !isGenerating(status);
|
|
356
274
|
const bottom = safeBottom ? insets.bottom : 0;
|
|
357
|
-
// The field grows with its content up to `maxHeight`, then scrolls. A fixed
|
|
358
|
-
// `numberOfLines` would lock the line count on Android, so neither layout sets it.
|
|
359
275
|
const [contentHeight, setContentHeight] = useState(0);
|
|
360
276
|
const maxHeight = largerText ? MAX_FIELD_HEIGHT.larger : MAX_FIELD_HEIGHT.regular;
|
|
361
277
|
const growStyle = contentHeight > 0 ? { height: Math.min(contentHeight, maxHeight) } : null;
|
|
362
278
|
const scrollEnabled = contentHeight > maxHeight;
|
|
363
279
|
const pill = layout === "inline" && shape === "pill";
|
|
364
|
-
// Inline: the web `Composer` `text-sm leading-6` (Eva's pill: `leading-5`).
|
|
365
|
-
// Stacked: the web `PromptInput` `Textarea`, `text-base` below `sm`. Larger text is `text-xl`.
|
|
366
280
|
const fieldText = largerText
|
|
367
281
|
? sizeStyle("text-xl")
|
|
368
282
|
: layout === "inline"
|
|
369
283
|
? { fontSize: 14, lineHeight: pill ? 20 : 24 }
|
|
370
284
|
: sizeStyle("text-base");
|
|
371
285
|
|
|
372
|
-
// An empty field drops its measured height and is one line again: on the web
|
|
373
|
-
// a `textarea` only reports a taller height, never a shorter one.
|
|
374
286
|
const changeText = (next: string) => {
|
|
375
287
|
setText(next);
|
|
376
288
|
if (next === "") setContentHeight(0);
|
|
@@ -389,10 +301,8 @@ export function PromptInput({
|
|
|
389
301
|
className={cn("pt-2", className)}
|
|
390
302
|
style={{ paddingBottom: bottom + 8, paddingLeft: insets.left + 12, paddingRight: insets.right + 12 }}
|
|
391
303
|
>
|
|
392
|
-
{/* The web panel picker's 6 gap (`POPUP_GAP`) above the field. */}
|
|
393
304
|
{menu ? <View className="mb-1.5">{menu}</View> : null}
|
|
394
305
|
{layout === "inline" ? (
|
|
395
|
-
// Web `Composer` inline: `rounded-[1.25rem]` and a `p-1.5` row, items at the bottom as the field grows.
|
|
396
306
|
<View className="border" style={[fieldStyle(scheme), { borderRadius: pill ? PILL.radius : INLINE_RADIUS }]}>
|
|
397
307
|
{replyTo ? <View className="px-1.5 pt-1.5">{replyTo}</View> : null}
|
|
398
308
|
{header ? <View className="flex-row flex-wrap gap-1 px-1.5 pt-1.5">{header}</View> : null}
|
|
@@ -401,7 +311,6 @@ export function PromptInput({
|
|
|
401
311
|
style={pill ? { paddingVertical: PILL.paddingY, paddingHorizontal: PILL.paddingX } : null}
|
|
402
312
|
>
|
|
403
313
|
{leading ? (
|
|
404
|
-
// In the pill, centred on the 36 line, as the web `items-center` row.
|
|
405
314
|
<View className="shrink-0 flex-row items-center gap-1" style={pill ? { minHeight: PILL.lineHeight } : null}>
|
|
406
315
|
{leading}
|
|
407
316
|
</View>
|
|
@@ -422,7 +331,6 @@ export function PromptInput({
|
|
|
422
331
|
scrollEnabled={scrollEnabled}
|
|
423
332
|
onContentSizeChange={(e) => setContentHeight(e.nativeEvent.contentSize.height)}
|
|
424
333
|
className={cn(
|
|
425
|
-
// In the row the field grows across; in a paste target, the target does and the field fills it.
|
|
426
334
|
pasteTarget ? "border-0 text-sm font-instrument-sans" : "flex-1 border-0 text-sm font-instrument-sans",
|
|
427
335
|
pill ? "min-h-9 px-1 py-2" : "min-h-8 px-2 py-1",
|
|
428
336
|
largerText && "min-h-11 py-2 text-xl font-instrument-sans-medium",
|
|
@@ -455,7 +363,6 @@ export function PromptInput({
|
|
|
455
363
|
<View className="border" style={fieldStyle(scheme)}>
|
|
456
364
|
{replyTo ? <View className="px-2 pt-2">{replyTo}</View> : null}
|
|
457
365
|
{header ? <View className="flex-row flex-wrap gap-1 px-2 pt-2">{header}</View> : null}
|
|
458
|
-
{/* The `Textarea` field without its `numberOfLines` (default 4), which on Android sets the line count: this one starts at one line and grows. */}
|
|
459
366
|
<PasteTarget target={pasteTarget} onPasteImages={onPasteImages}>
|
|
460
367
|
<FieldInput
|
|
461
368
|
testID={testID ? `${testID}-input` : undefined}
|
|
@@ -498,8 +405,6 @@ export function PromptInput({
|
|
|
498
405
|
if (lifted) return composer;
|
|
499
406
|
return (
|
|
500
407
|
<KeyboardAvoidingView
|
|
501
|
-
// The keyboard covers the home indicator, so the inset padded below is
|
|
502
|
-
// taken off the lift: the composer sits right on the keyboard.
|
|
503
408
|
keyboardVerticalOffset={keyboardVerticalOffset - bottom}
|
|
504
409
|
>
|
|
505
410
|
{composer}
|
|
@@ -507,10 +412,8 @@ export function PromptInput({
|
|
|
507
412
|
);
|
|
508
413
|
}
|
|
509
414
|
|
|
510
|
-
/** In the inline row the paste target takes the field's place: it grows across, and the field fills it. */
|
|
511
415
|
const PASTE_TARGET_INLINE = { flex: 1, minWidth: 0 };
|
|
512
416
|
|
|
513
|
-
/** The field inside the app's paste target (`PasteInputProvider`), or the field alone. */
|
|
514
417
|
function PasteTarget({
|
|
515
418
|
target: Target,
|
|
516
419
|
onPasteImages,
|
package/src/ai/reasoning.tsx
CHANGED
|
@@ -24,7 +24,6 @@ type ReasoningContextValue = {
|
|
|
24
24
|
isStreaming: boolean;
|
|
25
25
|
isOpen: boolean;
|
|
26
26
|
setIsOpen: (open: boolean) => void;
|
|
27
|
-
/** Whole seconds the reasoning streamed for, or `undefined` before it is known. */
|
|
28
27
|
duration: number | undefined;
|
|
29
28
|
};
|
|
30
29
|
|
|
@@ -41,10 +40,8 @@ const AUTO_CLOSE_DELAY_MS = 1000;
|
|
|
41
40
|
export type ReasoningProps = Omit<CollapsibleProps, "open" | "defaultOpen" | "onOpenChange"> & {
|
|
42
41
|
isStreaming?: boolean;
|
|
43
42
|
open?: boolean;
|
|
44
|
-
/** Default: open while streaming. `false` keeps it shut when streaming starts, as on the web. */
|
|
45
43
|
defaultOpen?: boolean;
|
|
46
44
|
onOpenChange?: (open: boolean) => void;
|
|
47
|
-
/** Seconds, when the app knows them (a reloaded thread). Default: timed from `isStreaming`. */
|
|
48
45
|
duration?: number;
|
|
49
46
|
};
|
|
50
47
|
|
|
@@ -72,8 +69,6 @@ export function Reasoning({
|
|
|
72
69
|
const [closeDue, setCloseDue] = useState(false);
|
|
73
70
|
const startedAt = useRef<number | null>(isStreaming ? Date.now() : null);
|
|
74
71
|
|
|
75
|
-
// Runs when the stream starts or stops, not on every open change, so a
|
|
76
|
-
// reader's own close mid-stream holds.
|
|
77
72
|
useEffect(() => {
|
|
78
73
|
if (isStreaming) {
|
|
79
74
|
if (startedAt.current === null) startedAt.current = Date.now();
|
|
@@ -122,7 +117,6 @@ export function reasoningMessage(isStreaming: boolean, duration?: number): strin
|
|
|
122
117
|
}
|
|
123
118
|
|
|
124
119
|
export type ReasoningTriggerProps = CollapsibleTriggerProps & {
|
|
125
|
-
/** Replaces `reasoningMessage`. A string, as it is also the accessibility label. */
|
|
126
120
|
getThinkingMessage?: (isStreaming: boolean, duration?: number) => string;
|
|
127
121
|
};
|
|
128
122
|
|
|
@@ -9,15 +9,10 @@ import { useScheme } from "../useScheme";
|
|
|
9
9
|
import { chatTextSize } from "./chat-text";
|
|
10
10
|
|
|
11
11
|
export type ReplyQuoteChipProps = {
|
|
12
|
-
/** Who wrote the message being replied to. */
|
|
13
12
|
author: string;
|
|
14
|
-
/** Its text. Shown on up to two lines. */
|
|
15
13
|
text: string;
|
|
16
|
-
/** Called when the X is pressed. Clear the reply in the app. */
|
|
17
14
|
onDismiss?: () => void;
|
|
18
|
-
/** Default "Replying to {author}". */
|
|
19
15
|
accessibilityLabel?: string;
|
|
20
|
-
/** Names the X button. Default "Dismiss reply quote". */
|
|
21
16
|
dismissLabel?: string;
|
|
22
17
|
className?: string;
|
|
23
18
|
testID?: string;
|
package/src/ai/response-text.tsx
CHANGED
|
@@ -6,12 +6,6 @@ import { useLargerText } from "../theme";
|
|
|
6
6
|
import { useScheme } from "../useScheme";
|
|
7
7
|
import { chatTextSize, type ChatTextKind } from "./chat-text";
|
|
8
8
|
|
|
9
|
-
// Markdown stub. The web renders replies with Streamdown; native-ui has no
|
|
10
|
-
// markdown peer, so `ResponseText` draws the text as it is, newlines kept.
|
|
11
|
-
// An app that wants markdown can render one of these in its place:
|
|
12
|
-
// `react-native-markdown-display`, `@ronradtke/react-native-markdown-display`
|
|
13
|
-
// (a maintained fork) or `react-native-marked`.
|
|
14
|
-
|
|
15
9
|
/**
|
|
16
10
|
* The text colour `MessageContent` hands down: React Native text does not
|
|
17
11
|
* inherit a colour from its parent view, as web text does from `color`.
|
|
@@ -20,9 +14,7 @@ export const ChatTextColorContext = createContext<string | undefined>(undefined)
|
|
|
20
14
|
|
|
21
15
|
export type ResponseTextProps = Omit<TextProps, "children"> & {
|
|
22
16
|
children: string;
|
|
23
|
-
/** Default: the enclosing `MessageContent` colour, else the foreground. */
|
|
24
17
|
tone?: "foreground" | "muted";
|
|
25
|
-
/** Default `"body"` (16, `text-xl` with larger text). See `chatTextSize`. */
|
|
26
18
|
size?: ChatTextKind;
|
|
27
19
|
className?: string;
|
|
28
20
|
};
|