@vvedantb/native-ui 0.37.2 → 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/README.md +8 -7
- 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/app-root/AuthGroupGate.jsx +65 -0
- package/dist/app-root/SsoCallbackScreen.jsx +97 -0
- package/dist/app-root/fonts.js +88 -0
- package/dist/app-root/index.js +3 -0
- package/dist/auth/AuthScreen.jsx +250 -77
- package/dist/auth/GoogleSignInButton.jsx +0 -3
- package/dist/auth/SecondFactorScreen.jsx +18 -14
- package/dist/auth/SignInScreen.jsx +40 -34
- 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/LastCrashDialog.jsx +56 -0
- package/dist/crash/lastCrash.js +192 -0
- package/dist/entries/ai.js +0 -3
- package/dist/entries/ambient.js +0 -2
- package/dist/entries/app-root.js +1 -0
- 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 +2 -0
- 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 +4 -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 +4 -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 +158 -0
- package/dist/pagerSwipe.js +0 -16
- package/dist/palette.js +0 -10
- package/dist/primitives/button.jsx +0 -5
- package/dist/primitives/icon.jsx +0 -4
- 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 -10
- 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 +2 -9
- 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 +62 -0
- package/dist/themeModes.js +9 -0
- 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 +47 -19
- 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 +38 -0
- package/src/app-root/SsoCallbackScreen.tsx +52 -0
- package/src/app-root/fonts.ts +53 -0
- package/src/app-root/index.ts +6 -0
- package/src/auth/AccountScreens.tsx +0 -16
- package/src/auth/AuthProviders.tsx +0 -13
- package/src/auth/AuthScreen.tsx +95 -6
- package/src/auth/GoogleSignInButton.tsx +0 -12
- package/src/auth/SecondFactorScreen.tsx +17 -15
- package/src/auth/SignInScreen.tsx +103 -105
- 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 +36 -0
- package/src/crash/lastCrash.ts +218 -0
- package/src/entries/ai.ts +0 -3
- package/src/entries/ambient.ts +0 -2
- package/src/entries/app-root.ts +1 -0
- 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 +13 -0
- 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 +8 -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 +1 -21
- package/src/index.ts +7 -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 +127 -0
- 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/icon.tsx +0 -2
- 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 -18
- 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 +2 -16
- 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 +85 -0
- package/src/themeModes.ts +10 -0
- 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
- package/types/prism-react-renderer.d.ts +22 -0
package/src/ai/conversation.tsx
CHANGED
|
@@ -64,8 +64,6 @@ export function Conversation({ className, ...props }: ConversationProps) {
|
|
|
64
64
|
const reduceMotion = useReduceMotion();
|
|
65
65
|
const scrollRef = useRef<ConversationScroller | null>(null);
|
|
66
66
|
const atBottom = useRef(true);
|
|
67
|
-
// Set while our own animated scroll heads down, so its first frames (not
|
|
68
|
-
// yet at the bottom) do not count as the reader leaving.
|
|
69
67
|
const autoScrolling = useRef(false);
|
|
70
68
|
const [isAtBottom, setIsAtBottom] = useState(true);
|
|
71
69
|
const [dockHeight, setDockHeight] = useState(0);
|
|
@@ -93,7 +91,6 @@ export function Conversation({ className, ...props }: ConversationProps) {
|
|
|
93
91
|
onUserScroll: () => {
|
|
94
92
|
autoScrolling.current = false;
|
|
95
93
|
},
|
|
96
|
-
// A jump, not an animation: streamed text grows the content many times a second.
|
|
97
94
|
followContent: () => {
|
|
98
95
|
if (atBottom.current) scrollRef.current?.scrollToEnd({ animated: false });
|
|
99
96
|
},
|
|
@@ -112,7 +109,6 @@ export function Conversation({ className, ...props }: ConversationProps) {
|
|
|
112
109
|
);
|
|
113
110
|
}
|
|
114
111
|
|
|
115
|
-
/** The scroll handlers a thread's scroller passes on, as `ScrollView` and `FlatList` both take them. */
|
|
116
112
|
type ConversationScrollHandlers = {
|
|
117
113
|
onScroll?: ((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | null;
|
|
118
114
|
onScrollBeginDrag?: ((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | null;
|
|
@@ -120,27 +116,12 @@ type ConversationScrollHandlers = {
|
|
|
120
116
|
onLayout?: ((event: LayoutChangeEvent) => void) | null;
|
|
121
117
|
};
|
|
122
118
|
|
|
123
|
-
/**
|
|
124
|
-
* Taps reach rows while the keyboard is up; a drag lowers it (interactively
|
|
125
|
-
* on iOS, and on Android 11+ with `KeyboardControllerProvider`, in
|
|
126
|
-
* `ConversationList`); scroll events at 60 Hz.
|
|
127
|
-
*/
|
|
128
119
|
const SCROLL_DEFAULTS: Pick<ScrollViewProps, "keyboardShouldPersistTaps" | "keyboardDismissMode" | "scrollEventThrottle"> = {
|
|
129
120
|
keyboardShouldPersistTaps: "handled",
|
|
130
121
|
keyboardDismissMode: Platform.OS === "ios" ? "interactive" : "on-drag",
|
|
131
122
|
scrollEventThrottle: 16,
|
|
132
123
|
};
|
|
133
124
|
|
|
134
|
-
/**
|
|
135
|
-
* The wiring `ConversationContent` and `ConversationList` share: the ref the
|
|
136
|
-
* scroll button and the follow use, taps that reach rows while the keyboard is
|
|
137
|
-
* up, and the handlers that track the bottom and follow new content. The
|
|
138
|
-
* defaults come first so `props` can override them; the handlers come last
|
|
139
|
-
* and call the app's own after the thread's. An inverted list needs no
|
|
140
|
-
* follow: its newest message is at offset 0, so it stays in view as the
|
|
141
|
-
* content and the view change. While `paused` is true the bottom is not
|
|
142
|
-
* tracked: something other than the reader scrolls the list.
|
|
143
|
-
*/
|
|
144
125
|
function useConversationScroll<P extends ConversationScrollHandlers>(
|
|
145
126
|
{ onScroll, onScrollBeginDrag, onContentSizeChange, onLayout, ...props }: P,
|
|
146
127
|
{
|
|
@@ -148,7 +129,6 @@ function useConversationScroll<P extends ConversationScrollHandlers>(
|
|
|
148
129
|
inverted = false,
|
|
149
130
|
paused,
|
|
150
131
|
}: {
|
|
151
|
-
/** Space past the content that `onScroll` does not report, read at each event. */
|
|
152
132
|
bottomInset?: () => number;
|
|
153
133
|
inverted?: boolean;
|
|
154
134
|
paused?: () => boolean;
|
|
@@ -170,12 +150,10 @@ function useConversationScroll<P extends ConversationScrollHandlers>(
|
|
|
170
150
|
conversation.settleOverlay();
|
|
171
151
|
onScrollBeginDrag?.(event);
|
|
172
152
|
},
|
|
173
|
-
// The app's handler first, so a scroller that measures itself (`ConversationList`) has the new size to follow.
|
|
174
153
|
onContentSizeChange: (width: number, height: number) => {
|
|
175
154
|
onContentSizeChange?.(width, height);
|
|
176
155
|
if (!inverted) conversation.followContent();
|
|
177
156
|
},
|
|
178
|
-
// The keyboard or composer resizing the view keeps the end in view too.
|
|
179
157
|
onLayout: (event: LayoutChangeEvent) => {
|
|
180
158
|
onLayout?.(event);
|
|
181
159
|
if (!inverted) conversation.followContent();
|
|
@@ -250,16 +228,9 @@ export function ConversationList<T>({
|
|
|
250
228
|
const keyboard = useKeyboardParts();
|
|
251
229
|
const insets = useSafeAreaInsets();
|
|
252
230
|
const inverted = props.inverted === true;
|
|
253
|
-
// Sizes from the list's own events, for the scroll offset; no render reads
|
|
254
|
-
// them. `inset` is the keyboard's space past the content (before offset 0
|
|
255
|
-
// when inverted); `keyboardMoving` is true while the keyboard scrolls the
|
|
256
|
-
// list, which is not the reader leaving the bottom.
|
|
257
231
|
const size = useRef({ content: 0, view: 0, inset: 0, keyboardMoving: false });
|
|
258
|
-
// The list, and the row `scrollToIndex` last asked for, for its retry when that row was not drawn.
|
|
259
232
|
const listRef = useRef<FlatList<T> | null>(null);
|
|
260
233
|
const indexTarget = useRef<{ index: number; animated?: boolean; viewPosition?: number; tries: number } | null>(null);
|
|
261
|
-
// Not inverted: hidden until the first jump to the end (see above). An
|
|
262
|
-
// empty list (a spinner, an empty state) shows at once.
|
|
263
234
|
const hasRows = (props.data?.length ?? 0) > 0;
|
|
264
235
|
const [placed, setPlaced] = useState(false);
|
|
265
236
|
const placeOnce = () => {
|
|
@@ -283,13 +254,10 @@ export function ConversationList<T>({
|
|
|
283
254
|
},
|
|
284
255
|
{ bottomInset: () => size.current.inset, inverted, paused: () => size.current.keyboardMoving },
|
|
285
256
|
);
|
|
286
|
-
// An inverted list would draw its empty state at the bottom, flipped back
|
|
287
|
-
// only if the element takes a `style`: draw it the right way up instead.
|
|
288
257
|
if (inverted && !hasRows) {
|
|
289
258
|
const Empty = props.ListEmptyComponent;
|
|
290
259
|
return <View style={styles.fill}>{isValidElement(Empty) ? Empty : typeof Empty === "function" ? <Empty /> : null}</View>;
|
|
291
260
|
}
|
|
292
|
-
// The newest message's offset: inverted, 0 less the space before it.
|
|
293
261
|
const end = () =>
|
|
294
262
|
inverted
|
|
295
263
|
? size.current.inset > 0
|
|
@@ -299,11 +267,9 @@ export function ConversationList<T>({
|
|
|
299
267
|
const list = (
|
|
300
268
|
<FlatList
|
|
301
269
|
className={cn("flex-1", className)}
|
|
302
|
-
// Inverted, the column's end is the top: a short thread sits there.
|
|
303
270
|
contentContainerClassName={cn("px-3 py-3", inverted && "grow justify-end", contentContainerClassName)}
|
|
304
271
|
{...wired}
|
|
305
272
|
style={[wired.style, !inverted && hasRows && !placed ? styles.hidden : null]}
|
|
306
|
-
// At the bottom, a new message shows at offset 0; scrolled up, it must not move what the reader sees.
|
|
307
273
|
maintainVisibleContentPosition={
|
|
308
274
|
props.maintainVisibleContentPosition ?? (inverted && !conversation.isAtBottom ? KEEP_VISIBLE : undefined)
|
|
309
275
|
}
|
|
@@ -317,22 +283,18 @@ export function ConversationList<T>({
|
|
|
317
283
|
{...scrollProps}
|
|
318
284
|
inverted={inverted}
|
|
319
285
|
freeze={conversation.overlay !== "none"}
|
|
320
|
-
// The composer pads the bottom inset, which the keyboard covers: the content rises by the rest.
|
|
321
286
|
bottomOffset={insets.bottom}
|
|
322
287
|
onInsetChange={(inset) => {
|
|
323
288
|
size.current.inset = inset;
|
|
324
289
|
}}
|
|
325
290
|
onKeyboardMove={(moving) => {
|
|
326
291
|
size.current.keyboardMoving = moving;
|
|
327
|
-
// The closing menu's window hands the focus back with a keyboard event: frozen until it ends.
|
|
328
292
|
if (!moving) conversation.settleOverlay();
|
|
329
293
|
}}
|
|
330
294
|
/>
|
|
331
295
|
)
|
|
332
296
|
: props.renderScrollComponent
|
|
333
297
|
}
|
|
334
|
-
// A row the list has not drawn yet (it draws only those near the view):
|
|
335
|
-
// go to its estimated offset, which draws it, then to the row itself.
|
|
336
298
|
onScrollToIndexFailed={
|
|
337
299
|
props.onScrollToIndexFailed ??
|
|
338
300
|
((info) => {
|
|
@@ -357,7 +319,6 @@ export function ConversationList<T>({
|
|
|
357
319
|
/>
|
|
358
320
|
);
|
|
359
321
|
if (!keyboard) return list;
|
|
360
|
-
// The keyboard follows the finger from the composer's top: the dock less the inset it pads.
|
|
361
322
|
return (
|
|
362
323
|
<keyboard.GestureArea offset={Math.max(0, conversation.dockHeight - insets.bottom)} style={styles.fill}>
|
|
363
324
|
{list}
|
|
@@ -365,7 +326,6 @@ export function ConversationList<T>({
|
|
|
365
326
|
);
|
|
366
327
|
}
|
|
367
328
|
|
|
368
|
-
/** Scrolled up in an inverted list: the first drawn row in view keeps its place as rows are added or grow. */
|
|
369
329
|
const KEEP_VISIBLE = { minIndexForVisible: 0 };
|
|
370
330
|
|
|
371
331
|
export type ConversationEmptyStateProps = ViewProps & {
|
|
@@ -453,30 +413,16 @@ export function ConversationDock({ onLayout, ...props }: ConversationDockProps)
|
|
|
453
413
|
}
|
|
454
414
|
|
|
455
415
|
export type ConversationScrollButtonProps = {
|
|
456
|
-
/** The accessibility label, and the text with `showLabel`. Default "Scroll to bottom". */
|
|
457
416
|
label?: string;
|
|
458
|
-
/** Replaces the down arrow. */
|
|
459
417
|
icon?: ComponentType<IconProps>;
|
|
460
|
-
/**
|
|
461
|
-
* Draw `label` after the icon in a compact pill, as the web button with a
|
|
462
|
-
* `label` in Eva's chat ("Scroll to end": 28 high, `px-3`, muted, a 60%
|
|
463
|
-
* border on the surface), with a `text-sm` label, the phone floor for
|
|
464
|
-
* tappable text (the web is `text-xs`). Default `false`: the round arrow.
|
|
465
|
-
*/
|
|
466
418
|
showLabel?: boolean;
|
|
467
|
-
/**
|
|
468
|
-
* The row the button centres in, full width by default. Inset a side (for
|
|
469
|
-
* example `{ right: 10 }`) to centre it on a thread that sits off-centre.
|
|
470
|
-
*/
|
|
471
419
|
insets?: { left?: number; right?: number };
|
|
472
420
|
testID?: string;
|
|
473
421
|
};
|
|
474
422
|
|
|
475
|
-
/** The scroll button fades in and out on the strong ease-out. */
|
|
476
423
|
const SCROLL_BUTTON_ENTER = FadeIn.duration(150).easing(EASE_OUT);
|
|
477
424
|
const SCROLL_BUTTON_EXIT = FadeOut.duration(120).easing(EASE_OUT);
|
|
478
425
|
|
|
479
|
-
/** The labelled pill's height (web `h-7`). */
|
|
480
426
|
const SCROLL_PILL_HEIGHT = 28;
|
|
481
427
|
|
|
482
428
|
/**
|
|
@@ -520,10 +466,7 @@ export function ConversationScrollButton({
|
|
|
520
466
|
accessibilityLabel={label}
|
|
521
467
|
onPress={scrollToBottom}
|
|
522
468
|
testID={testID}
|
|
523
|
-
// Wider than 44 with its label; only the height needs slop.
|
|
524
469
|
hitSlop={touchSlop(MIN_TOUCH_TARGET, SCROLL_PILL_HEIGHT)}
|
|
525
|
-
// A plain style object: NativeWind drops a function `style` on a
|
|
526
|
-
// native `Pressable`, which lost the pill's row, border and fill.
|
|
527
470
|
style={{
|
|
528
471
|
minHeight: SCROLL_PILL_HEIGHT,
|
|
529
472
|
flexDirection: "row",
|
|
@@ -559,7 +502,6 @@ export function ConversationScrollButton({
|
|
|
559
502
|
</NativeOnlyAnimatedView>
|
|
560
503
|
);
|
|
561
504
|
if (!keyboard) return button;
|
|
562
|
-
// It rides with the dock: the same move with the keyboard.
|
|
563
505
|
return (
|
|
564
506
|
<keyboard.StickyView bottomOffset={safeArea.bottom} pointerEvents="box-none" style={StyleSheet.absoluteFill}>
|
|
565
507
|
{button}
|
package/src/ai/file-chip.tsx
CHANGED
|
@@ -9,7 +9,6 @@ import { tokens } from "../tokens";
|
|
|
9
9
|
import { useScheme } from "../useScheme";
|
|
10
10
|
import { MONO_FONT, chatTextSize } from "./chat-text";
|
|
11
11
|
|
|
12
|
-
/** A `text-xs` line with the web `py-0.5` and border: 22 high. The slop brings it to 44. */
|
|
13
12
|
const CHIP_HEIGHT = 22;
|
|
14
13
|
|
|
15
14
|
function FileChipLabel({ name }: { name: string }) {
|
package/src/ai/icon-button.tsx
CHANGED
|
@@ -10,13 +10,6 @@ import { useScheme } from "../useScheme";
|
|
|
10
10
|
/** The web `icon-sm` button: 32 square with a 16 icon. */
|
|
11
11
|
export const CHAT_ICON_BUTTON_SIZE = 32;
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Side and icon per size: `sm` is the web `icon-sm` (32, 16 icon), `xs` the
|
|
15
|
-
* web `icon-xs` (28, 14 icon) and `md` the web `size-9` (36, 16 icon), Eva's
|
|
16
|
-
* composer send button. `touch` has no web twin: a 44 square with a 16 icon,
|
|
17
|
-
* for a row of ghost buttons a thumb taps (the message actions), where the
|
|
18
|
-
* web 28 squares 2 apart are a mouse's density.
|
|
19
|
-
*/
|
|
20
13
|
const CHAT_ICON_BUTTON = {
|
|
21
14
|
xs: { side: 28, icon: 14, className: "h-7 w-7" },
|
|
22
15
|
sm: { side: CHAT_ICON_BUTTON_SIZE, icon: 16, className: "h-8 w-8" },
|
|
@@ -28,19 +21,9 @@ export type ChatIconButtonSize = keyof typeof CHAT_ICON_BUTTON;
|
|
|
28
21
|
|
|
29
22
|
export type ChatIconButtonProps = Omit<ButtonProps, "children" | "size" | "icon"> & {
|
|
30
23
|
icon: ComponentType<IconProps>;
|
|
31
|
-
/** Names the button for VoiceOver and TalkBack; it has no text. */
|
|
32
24
|
label: string;
|
|
33
|
-
/** Default: the variant's label colour. */
|
|
34
25
|
iconColor?: string;
|
|
35
|
-
/** Default `sm`. Larger text paints each 44 with a 20 icon. */
|
|
36
26
|
size?: ChatIconButtonSize;
|
|
37
|
-
/**
|
|
38
|
-
* `"square"` (default) slops to 44 on every side. `"vertical"` slops only
|
|
39
|
-
* the height to 44, for a dense row (the message actions sit 2 to 4 apart),
|
|
40
|
-
* where sideways slop would overlap the next button and steal its taps.
|
|
41
|
-
* `{ left, right }` is `"vertical"` plus that much on each side, for the
|
|
42
|
-
* outer side of a button at the end of such a row.
|
|
43
|
-
*/
|
|
44
27
|
slop?: "square" | "vertical" | { left: number; right: number };
|
|
45
28
|
};
|
|
46
29
|
|
package/src/ai/index.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// AI chat parts, ported from the `@vvedantb/ui` AI elements for touch. On the
|
|
2
|
-
// `@vvedantb/native-ui/ai` entry only, so apps without a chat do not bundle
|
|
3
|
-
// them. Generic: no model names and no app logic.
|
|
4
1
|
export { useStreamingDisclosure } from "./use-streaming-disclosure";
|
|
5
2
|
export { chatTextSize, formatElapsed, META_TEXT_STYLE, MONO_FONT } from "./chat-text";
|
|
6
3
|
export type { ChatTextKind } from "./chat-text";
|
|
@@ -110,8 +107,6 @@ export type {
|
|
|
110
107
|
} from "./chain-of-thought";
|
|
111
108
|
export { ActivityStep } from "./activity-step";
|
|
112
109
|
export type { ActivityStepProps, ActivityStepStatus } from "./activity-step";
|
|
113
|
-
// The web timeline's pure logic (byte-identical copies) and its folded rules.
|
|
114
|
-
// The step type is `ActivityTimelineStep` here: `ActivityStep` is the line above.
|
|
115
110
|
export { activityStepHasRichDetail } from "./activity-step-types";
|
|
116
111
|
export type {
|
|
117
112
|
ActivityStep as ActivityTimelineStep,
|
|
@@ -18,9 +18,7 @@ export type MessageSheetAction = {
|
|
|
18
18
|
key: string;
|
|
19
19
|
label: string;
|
|
20
20
|
icon?: ComponentType<IconProps>;
|
|
21
|
-
/** Draws the row in the danger colour, such as Delete. */
|
|
22
21
|
destructive?: boolean;
|
|
23
|
-
/** Dims the row and ignores presses (the context menu's rows; the sheet leaves a disabled action out). */
|
|
24
22
|
disabled?: boolean;
|
|
25
23
|
onPress: () => void;
|
|
26
24
|
};
|
|
@@ -30,12 +28,9 @@ export const MESSAGE_ACTIONS_TITLE = "Message actions";
|
|
|
30
28
|
|
|
31
29
|
export type MessageActionSheetProps = {
|
|
32
30
|
open: boolean;
|
|
33
|
-
/** Called on a backdrop tap, Cancel, Android back and after an action runs. */
|
|
34
31
|
onClose: () => void;
|
|
35
32
|
actions: MessageSheetAction[];
|
|
36
|
-
/** Shown above the rows, and names the sheet for VoiceOver and TalkBack. Default "Message actions". */
|
|
37
33
|
title?: string;
|
|
38
|
-
/** Default "Cancel". */
|
|
39
34
|
cancelLabel?: string;
|
|
40
35
|
testID?: string;
|
|
41
36
|
};
|
|
@@ -75,9 +70,6 @@ export function MessageActionSheet({
|
|
|
75
70
|
if (!next) onClose();
|
|
76
71
|
}}
|
|
77
72
|
>
|
|
78
|
-
{/* The kit's bottom-sheet overlay: it slides with `SHEET_SPRING`, the backdrop
|
|
79
|
-
follows its position and a drag down closes it. The part name keeps
|
|
80
|
-
the backdrop testID `{testID}-backdrop`. */}
|
|
81
73
|
<OverlayModal part={testID} placement="bottom" dismissible>
|
|
82
74
|
<SheetDragView enabled>
|
|
83
75
|
<View
|
|
@@ -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,
|