@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
package/src/ai/chat-thread.tsx
CHANGED
|
@@ -19,25 +19,17 @@ export type UIMessage = {
|
|
|
19
19
|
|
|
20
20
|
export type ChatThreadProps<M extends UIMessage = UIMessage> = {
|
|
21
21
|
messages: M[];
|
|
22
|
-
/** True while a reply is on its way. Marks the last assistant message as streaming and shows `thinking`. */
|
|
23
22
|
working: boolean;
|
|
24
|
-
/** Draws one message. `isStreaming` is true for the last assistant message while `working`. */
|
|
25
23
|
renderMessage: (message: M, isStreaming: boolean) => ReactNode;
|
|
26
|
-
/** A row after the last user message while `working`, such as a `Shimmer` "Thinking". */
|
|
27
24
|
thinking?: ReactNode;
|
|
28
|
-
/** Shown in place of the list when there are no messages. */
|
|
29
25
|
emptyState?: ReactNode;
|
|
30
|
-
/** Last in the column, lifted over the keyboard. A `PromptInput`. */
|
|
31
26
|
footer: ReactNode;
|
|
32
|
-
/** Merged into the `ConversationContent` column classes (`gap-4 px-3 py-3`), such as `px-4 py-4`. */
|
|
33
27
|
contentContainerClassName?: string;
|
|
34
|
-
/** Height of anything above the thread, such as a navigation header, for the keyboard lift. Default 0. */
|
|
35
28
|
keyboardVerticalOffset?: number;
|
|
36
29
|
className?: string;
|
|
37
30
|
testID?: string;
|
|
38
31
|
};
|
|
39
32
|
|
|
40
|
-
/** Index of the last message with `role`, or -1. A loop, not `findLastIndex` (Hermes). */
|
|
41
33
|
function lastIndexOfRole(messages: UIMessage[], role: UIMessage["role"]) {
|
|
42
34
|
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
43
35
|
if (messages[index]!.role === role) return index;
|
|
@@ -71,7 +63,6 @@ export function ChatThread<M extends UIMessage = UIMessage>({
|
|
|
71
63
|
|
|
72
64
|
return (
|
|
73
65
|
<KeyboardAvoidingView testID={testID} keyboardVerticalOffset={keyboardVerticalOffset} style={styles.fill}>
|
|
74
|
-
{/* The column lifts as a whole: the parts in it add no lift of their own. */}
|
|
75
66
|
<KeyboardLiftContext.Provider value>
|
|
76
67
|
<View className={cn("flex-1", className)}>
|
|
77
68
|
<Conversation>
|
|
@@ -14,7 +14,6 @@ import { chatTextSize } from "./chat-text";
|
|
|
14
14
|
/** One question, as an agent's AskUserQuestion sends it. */
|
|
15
15
|
export type ChoiceQuestionItem = {
|
|
16
16
|
question: string;
|
|
17
|
-
/** Short tag shown as a badge beside the question. */
|
|
18
17
|
header: string;
|
|
19
18
|
multiSelect: boolean;
|
|
20
19
|
options: ReadonlyArray<{ label: string; description: string }>;
|
|
@@ -22,23 +21,11 @@ export type ChoiceQuestionItem = {
|
|
|
22
21
|
|
|
23
22
|
export type ChoiceQuestionProps = {
|
|
24
23
|
questions: ReadonlyArray<ChoiceQuestionItem>;
|
|
25
|
-
/**
|
|
26
|
-
* Question text to the picked label, or the typed "Other" answer.
|
|
27
|
-
* Multi-select joins labels with ", " (the shape AskUserQuestion reads).
|
|
28
|
-
*/
|
|
29
24
|
onSubmit: (answers: Record<string, string>) => void | Promise<void>;
|
|
30
|
-
/** Shows a spinner on the submit button and blocks input. */
|
|
31
25
|
loading?: boolean;
|
|
32
|
-
/** Default "Other...". */
|
|
33
26
|
otherLabel?: string;
|
|
34
|
-
/** Default "Type your answer...". */
|
|
35
27
|
otherPlaceholder?: string;
|
|
36
|
-
/** Inside the web dock card (`rounded-surface bg-card p-3`, scrolling past 60% of the screen). Default `true`. */
|
|
37
28
|
framed?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Back, Next and Submit label weight. Default `medium`, the `Button` label
|
|
40
|
-
* (web `font-medium`). `semibold` for apps whose web buttons are semibold, as Eva.
|
|
41
|
-
*/
|
|
42
29
|
buttonWeight?: "medium" | "semibold";
|
|
43
30
|
};
|
|
44
31
|
|
|
@@ -83,7 +70,6 @@ export function ChoiceQuestion({
|
|
|
83
70
|
const largerText = useLargerText();
|
|
84
71
|
const icon = largerText ? 18 : 15;
|
|
85
72
|
const buttonText = largerText ? "text-xl" : "text-sm";
|
|
86
|
-
// A string child draws the `Button` medium label; a semibold one is drawn here, in the variant's label colour.
|
|
87
73
|
const buttonLabel = (text: string, variant: "primary" | "ghost") =>
|
|
88
74
|
buttonWeight === "medium" ? (
|
|
89
75
|
text
|
|
@@ -128,7 +114,6 @@ export function ChoiceQuestion({
|
|
|
128
114
|
<View className="flex-row items-center justify-between" style={{ gap: 8 }}>
|
|
129
115
|
<Text
|
|
130
116
|
className="flex-1 font-instrument-sans-medium"
|
|
131
|
-
// Web `text-[15px] leading-snug` (15 / 20.625); larger text steps up to 18.
|
|
132
117
|
style={[{ fontSize: largerText ? 18 : 15, lineHeight: largerText ? 24 : 15 * 1.375 }, textStyle("foreground", scheme), typeStyle("medium")]}
|
|
133
118
|
>
|
|
134
119
|
{question.question}
|
|
@@ -175,8 +160,6 @@ export function ChoiceQuestion({
|
|
|
175
160
|
placeholder={otherPlaceholder}
|
|
176
161
|
editable={!loading}
|
|
177
162
|
autoFocus
|
|
178
|
-
// Return is the Next or Submit button. Until there is an
|
|
179
|
-
// answer it keeps the keyboard up, as the button does nothing.
|
|
180
163
|
returnKeyType={isLast ? "send" : "next"}
|
|
181
164
|
submitBehavior={isLast && hasAnswer ? "blurAndSubmit" : "submit"}
|
|
182
165
|
onSubmitEditing={next}
|
|
@@ -255,10 +238,8 @@ export function TopicBadge({ children }: { children: string }) {
|
|
|
255
238
|
);
|
|
256
239
|
}
|
|
257
240
|
|
|
258
|
-
/** The option card's `py-2 px-2.5`, which is also the slop of its press target. */
|
|
259
241
|
const CARD_PADDING = { top: 8, bottom: 8, left: 10, right: 10 };
|
|
260
242
|
|
|
261
|
-
/** A whole card is at least a 44 target: the press target inside is this much less its slop. */
|
|
262
243
|
const CARD_MIN_HEIGHT = 44;
|
|
263
244
|
|
|
264
245
|
/** The card while pressed: the kit 3% press scale, or a dim with Reduce Motion. */
|
|
@@ -267,11 +248,6 @@ export function choicePressStyle(pressed: boolean, reduceMotion: boolean) {
|
|
|
267
248
|
return reduceMotion ? { opacity: 0.8 } : { transform: [{ scale: 0.97 }] };
|
|
268
249
|
}
|
|
269
250
|
|
|
270
|
-
/**
|
|
271
|
-
* One option row (web `Card` with `bg-secondary`, `py-2 px-2.5`, radius 16): a round 24 mark
|
|
272
|
-
* (30 with larger text; letter, or a pencil for "Other"; a check on the primary fill when picked),
|
|
273
|
-
* the label and the description. Picked: a 1-wide primary ring outside, on the accent.
|
|
274
|
-
*/
|
|
275
251
|
function ChoiceRow({
|
|
276
252
|
selected,
|
|
277
253
|
disabled,
|
|
@@ -284,7 +260,6 @@ function ChoiceRow({
|
|
|
284
260
|
}: {
|
|
285
261
|
selected: boolean;
|
|
286
262
|
disabled: boolean;
|
|
287
|
-
/** A multi-select question: each row is a `checkbox`, not a `radio`. */
|
|
288
263
|
multiple: boolean;
|
|
289
264
|
mark: string;
|
|
290
265
|
label: string;
|
|
@@ -295,24 +270,18 @@ function ChoiceRow({
|
|
|
295
270
|
const scheme = useScheme();
|
|
296
271
|
const largerText = useLargerText();
|
|
297
272
|
const reduceMotion = useReduceMotion();
|
|
298
|
-
// The scale moves the whole card, which is not the Pressable (the "Other" field sits in it too).
|
|
299
273
|
const [pressed, setPressed] = useState(false);
|
|
300
274
|
const muted = tokens.color.muted[scheme];
|
|
301
275
|
const markSize = largerText ? 30 : 24;
|
|
302
276
|
const markText = largerText ? 14 : 11;
|
|
303
277
|
const glyph = largerText ? 16 : 13;
|
|
304
278
|
const small = chatTextSize("small", largerText);
|
|
305
|
-
// Web: an option label is `text-sm leading-snug font-medium`; "Other..." is
|
|
306
|
-
// plain `text-sm`, medium only once picked.
|
|
307
279
|
const plain = mark === "other" && !selected;
|
|
308
|
-
// The web label is an inline `leading-snug` span in a 16 / 24 block, so each
|
|
309
|
-
// line box is the block's 24, not 19.25: rows are 24 a line, as on the web.
|
|
310
280
|
const labelLine = largerText ? sizeStyle(small, "snug") : { ...sizeStyle(small, "snug"), lineHeight: 24 };
|
|
311
281
|
return (
|
|
312
282
|
<View
|
|
313
283
|
style={[
|
|
314
284
|
{
|
|
315
|
-
// Web `Card` (rounded-surface, 16) with `py-2 px-2.5` and no border width.
|
|
316
285
|
borderRadius: tokens.radius.lg,
|
|
317
286
|
backgroundColor: selected ? tokens.color.background[scheme] : palette.default[scheme],
|
|
318
287
|
opacity: disabled ? 0.5 : 1,
|
|
@@ -323,7 +292,6 @@ function ChoiceRow({
|
|
|
323
292
|
]}
|
|
324
293
|
>
|
|
325
294
|
{selected ? (
|
|
326
|
-
// Web `ring-1 ring-primary`: a 1 line just outside the card, so picking a row moves nothing.
|
|
327
295
|
<View
|
|
328
296
|
pointerEvents="none"
|
|
329
297
|
style={{
|
|
@@ -344,7 +312,6 @@ function ChoiceRow({
|
|
|
344
312
|
accessibilityHint={description || undefined}
|
|
345
313
|
accessibilityState={{ checked: selected, disabled }}
|
|
346
314
|
disabled={disabled}
|
|
347
|
-
// The card's own padding: a tap anywhere on the card picks it, and stops at its edge.
|
|
348
315
|
hitSlop={CARD_PADDING}
|
|
349
316
|
onPress={onPress}
|
|
350
317
|
onPressIn={() => setPressed(true)}
|
|
@@ -360,7 +327,6 @@ function ChoiceRow({
|
|
|
360
327
|
style={{
|
|
361
328
|
width: markSize,
|
|
362
329
|
height: markSize,
|
|
363
|
-
// Web `rounded-md` (radius - 2 = 14 at the default 1rem) on a 24 box: round.
|
|
364
330
|
borderRadius: markSize / 2,
|
|
365
331
|
marginTop: description ? 2 : 0,
|
|
366
332
|
alignItems: "center",
|
|
@@ -373,7 +339,6 @@ function ChoiceRow({
|
|
|
373
339
|
) : mark === "other" ? (
|
|
374
340
|
<IconPencil size={glyph} color={muted} />
|
|
375
341
|
) : (
|
|
376
|
-
// Web `text-2xs font-medium tracking-wide`, at semibold: native-ui draws no bold face.
|
|
377
342
|
<Text
|
|
378
343
|
className="font-instrument-sans-medium"
|
|
379
344
|
style={[
|
|
@@ -400,7 +365,6 @@ function ChoiceRow({
|
|
|
400
365
|
</Text>
|
|
401
366
|
)}
|
|
402
367
|
{description ? (
|
|
403
|
-
// Web `text-xs mt-0.5 leading-relaxed` (12 / 19.5).
|
|
404
368
|
<Text
|
|
405
369
|
className="font-instrument-sans"
|
|
406
370
|
style={[sizeStyle(chatTextSize("caption", largerText), "relaxed"), { color: muted, marginTop: 2 }]}
|
package/src/ai/code-block.tsx
CHANGED
|
@@ -32,20 +32,10 @@ export const CODE_BLOCK_METRICS = {
|
|
|
32
32
|
|
|
33
33
|
export type CodeBlockCopyButtonProps = {
|
|
34
34
|
code: string;
|
|
35
|
-
/**
|
|
36
|
-
* Puts `code` on the clipboard. React Native's own `Clipboard` is
|
|
37
|
-
* deprecated, and native-ui adds no clipboard package, so the app passes its
|
|
38
|
-
* own (for example `expo-clipboard`'s `setStringAsync`). A rejected promise
|
|
39
|
-
* leaves the copy icon.
|
|
40
|
-
*/
|
|
41
35
|
onCopy: (code: string) => void | Promise<void>;
|
|
42
|
-
/** Milliseconds the check shows after a copy. Default 2000, as on the web. */
|
|
43
36
|
timeout?: number;
|
|
44
|
-
/** Default "Copy code"; "Copied" while the check shows. */
|
|
45
37
|
label?: string;
|
|
46
|
-
/** Default `sm` (the web `CodeBlock` copy button); the markdown code block uses `xs`. */
|
|
47
38
|
size?: ChatIconButtonSize;
|
|
48
|
-
/** Default `"square"`. See `ChatIconButton`. */
|
|
49
39
|
slop?: ChatIconButtonProps["slop"];
|
|
50
40
|
};
|
|
51
41
|
|
|
@@ -57,7 +47,6 @@ export function CodeBlockCopyButton({ code, onCopy, timeout = 2000, label = "Cop
|
|
|
57
47
|
useEffect(() => () => clearTimeout(timer.current), []);
|
|
58
48
|
|
|
59
49
|
const copy = async () => {
|
|
60
|
-
// As the web: presses while the check shows do nothing.
|
|
61
50
|
if (copied) return;
|
|
62
51
|
try {
|
|
63
52
|
await onCopy(code);
|
|
@@ -81,39 +70,13 @@ export function CodeBlockCopyButton({ code, onCopy, timeout = 2000, label = "Cop
|
|
|
81
70
|
|
|
82
71
|
export type CodeBlockProps = {
|
|
83
72
|
code: string;
|
|
84
|
-
/**
|
|
85
|
-
* Shown in the header, and the Prism language for highlighting (`tsx`,
|
|
86
|
-
* `python`, `json`…). An unknown language draws plain text.
|
|
87
|
-
*/
|
|
88
73
|
language?: string;
|
|
89
|
-
/**
|
|
90
|
-
* Colour the code in the GitHub light and dark colours, as the web shiki
|
|
91
|
-
* block. Default `true`. Needs the optional peer `prism-react-renderer` and a
|
|
92
|
-
* `language`; without either the code is plain.
|
|
93
|
-
*/
|
|
94
74
|
highlight?: boolean;
|
|
95
|
-
/** With it, the header has a copy button. See `CodeBlockCopyButton`. */
|
|
96
75
|
onCopy?: (code: string) => void | Promise<void>;
|
|
97
|
-
/** Default `default`, the web `CodeBlock`. `markdown` is the web `MarkdownCodeBlock` (see `CodeBlock`). */
|
|
98
76
|
variant?: "default" | "markdown";
|
|
99
77
|
className?: string;
|
|
100
78
|
};
|
|
101
79
|
|
|
102
|
-
/**
|
|
103
|
-
* Code on the flat panel at radius 16, selectable, long lines scrolling
|
|
104
|
-
* sideways. With `prism-react-renderer` installed and a `language`, tokens
|
|
105
|
-
* take the GitHub colours of the scheme.
|
|
106
|
-
*
|
|
107
|
-
* `default` is the web `CodeBlock` (`ai-elements/code-block.tsx`): `text-sm`
|
|
108
|
-
* code in `p-4`, and a `px-3` header with the language and a copy button when
|
|
109
|
-
* either is given. `markdown` is the web `MarkdownCodeBlock`, which `Markdown`
|
|
110
|
-
* draws for fenced code: 13 / 20.15 code, a 32 header with `icon-xs` actions,
|
|
111
|
-
* a wrap toggle ("Wrap long lines", foreground while on) and then copy.
|
|
112
|
-
*/
|
|
113
|
-
/**
|
|
114
|
-
* Android fades the code at a side with more to scroll (there is no scroll
|
|
115
|
-
* bar), so a cut line reads as "scroll sideways". iOS ignores it.
|
|
116
|
-
*/
|
|
117
80
|
const CODE_FADING_EDGE = 24;
|
|
118
81
|
|
|
119
82
|
export function CodeBlock({ code, language, highlight = true, onCopy, variant = "default", className }: CodeBlockProps) {
|
|
@@ -142,7 +105,6 @@ export function CodeBlock({ code, language, highlight = true, onCopy, variant =
|
|
|
142
105
|
);
|
|
143
106
|
}
|
|
144
107
|
|
|
145
|
-
/** The web `MarkdownCodeBlock`: `CodeBlock` with `variant="markdown"`. A component of its own for the wrap state. */
|
|
146
108
|
function MarkdownCodeBlock({
|
|
147
109
|
code,
|
|
148
110
|
language,
|
|
@@ -164,8 +126,6 @@ function MarkdownCodeBlock({
|
|
|
164
126
|
style={largerText ? { paddingLeft: headerBox.paddingLeft, paddingRight: headerBox.paddingRight } : headerBox}
|
|
165
127
|
>
|
|
166
128
|
{parts.label}
|
|
167
|
-
{/* Web `.markdown-code-actions`: `gap-0.5`. The two sit 2 apart, so
|
|
168
|
-
each slops only above and below and on its outer side. */}
|
|
169
129
|
<View className="flex-row items-center gap-0.5">
|
|
170
130
|
<ChatIconButton
|
|
171
131
|
icon={IconTextWrap}
|
|
@@ -196,7 +156,6 @@ function MarkdownCodeBlock({
|
|
|
196
156
|
);
|
|
197
157
|
}
|
|
198
158
|
|
|
199
|
-
/** The panel style, the language label and the code text both code blocks draw. */
|
|
200
159
|
function useCodeParts(code: string, language: string | undefined, highlight: boolean, markdown: boolean) {
|
|
201
160
|
const scheme = useScheme();
|
|
202
161
|
const largerText = useLargerText();
|
|
@@ -226,10 +185,6 @@ function useCodeParts(code: string, language: string | undefined, highlight: boo
|
|
|
226
185
|
};
|
|
227
186
|
}
|
|
228
187
|
|
|
229
|
-
/**
|
|
230
|
-
* Coloured runs as nested `Text` spans, lines joined by newlines. They
|
|
231
|
-
* inherit the size and font of the code `Text` around them.
|
|
232
|
-
*/
|
|
233
188
|
function CodeRuns({ lines, scheme }: { lines: CodeToken[][]; scheme: "light" | "dark" }) {
|
|
234
189
|
return (
|
|
235
190
|
<>
|
|
@@ -247,12 +202,6 @@ function CodeRuns({ lines, scheme }: { lines: CodeToken[][]; scheme: "light" | "
|
|
|
247
202
|
);
|
|
248
203
|
}
|
|
249
204
|
|
|
250
|
-
/**
|
|
251
|
-
* The code in the web's Shiki colours: shell blocks through `shellTokens`
|
|
252
|
-
* (no peer needed), other languages through Prism, the JavaScript family
|
|
253
|
-
* recoloured where Prism and Shiki disagree (`scriptTokens`). Without
|
|
254
|
-
* `prism-react-renderer` a non-shell block is the plain code.
|
|
255
|
-
*/
|
|
256
205
|
function HighlightedCode({ code, language, scheme }: { code: string; language: string; scheme: "light" | "dark" }) {
|
|
257
206
|
const lang = language.toLowerCase();
|
|
258
207
|
const source = code.replace(/\n$/, "");
|
|
@@ -269,7 +218,6 @@ function HighlightedCode({ code, language, scheme }: { code: string; language: s
|
|
|
269
218
|
{tokens.map((line, lineIndex) => (
|
|
270
219
|
<Fragment key={lineIndex}>
|
|
271
220
|
{lineIndex > 0 ? "\n" : null}
|
|
272
|
-
{/* An empty line is one `empty` token whose content is "\n": the join above already breaks it. */}
|
|
273
221
|
{line.map((token, tokenIndex) =>
|
|
274
222
|
token.empty ? null : (
|
|
275
223
|
<Text key={tokenIndex} style={{ color: codeTokenColor(token.types, scheme) }}>
|
package/src/ai/collapsible.tsx
CHANGED
|
@@ -7,17 +7,6 @@ import { MIN_TOUCH_TARGET, touchSlop } from "../controlStyles";
|
|
|
7
7
|
import { useControllableState } from "../primitives/use-controllable-state";
|
|
8
8
|
import { useReduceMotion } from "../useReduceMotion";
|
|
9
9
|
|
|
10
|
-
// A small fold for the AI parts: native-ui has no `Collapsible`. A `Pressable`
|
|
11
|
-
// trigger and content that mounts only while open. The content appears at
|
|
12
|
-
// once: a fade would also run each time a list mounts an open fold (a chat
|
|
13
|
-
// opening, a virtualised row scrolled back). The chevron turns in 150 ms; with
|
|
14
|
-
// Reduce Motion it changes in place.
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The web chevron: `transition-transform duration-150`. The curve is the
|
|
18
|
-
* predefined `ease-out`: a `cubicBezier(...)` value in an `Animated.View`
|
|
19
|
-
* style does not typecheck against `react-native-reanimated` 4.3.
|
|
20
|
-
*/
|
|
21
10
|
const CHEVRON_TURN = {
|
|
22
11
|
transitionProperty: "transform",
|
|
23
12
|
transitionDuration: 150,
|
|
@@ -56,7 +45,6 @@ export function Collapsible({ open, defaultOpen = false, onOpenChange, ...props
|
|
|
56
45
|
);
|
|
57
46
|
}
|
|
58
47
|
|
|
59
|
-
/** A `text-sm` line with the web `py-1`: 28 high. The slop brings it to 44. */
|
|
60
48
|
const TRIGGER_ROW_HEIGHT = 28;
|
|
61
49
|
|
|
62
50
|
export type CollapsibleTriggerProps = Omit<PressableProps, "children"> & {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext, type RefObject } from "react";
|
|
2
2
|
import type { NativeScrollEvent } from "react-native";
|
|
3
3
|
|
|
4
|
-
// The `Conversation` context on its own, so a message can reach it without the
|
|
5
|
-
// thread's components (`message.tsx` sets `overlay`).
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* What the thread scrolls with: the `ScrollView` of `ConversationContent` or
|
|
9
6
|
* the `FlatList` of `ConversationList`. `scrollToEnd` goes to the newest
|
|
@@ -22,22 +19,11 @@ export type ConversationContextValue = {
|
|
|
22
19
|
isAtBottom: boolean;
|
|
23
20
|
scrollToBottom: () => void;
|
|
24
21
|
scrollRef: RefObject<ConversationScroller | null>;
|
|
25
|
-
/** `bottomInset` and `inverted`, as `isScrolledToBottom`. */
|
|
26
22
|
onScroll: (event: NativeScrollEvent, bottomInset?: number, inverted?: boolean) => void;
|
|
27
23
|
onUserScroll: () => void;
|
|
28
24
|
followContent: () => void;
|
|
29
|
-
/** The height of the `ConversationDock` under the thread, 0 without one. */
|
|
30
25
|
dockHeight: number;
|
|
31
26
|
setDockHeight: (height: number) => void;
|
|
32
|
-
/**
|
|
33
|
-
* A message's hold menu over the thread. Its window takes the focus on
|
|
34
|
-
* Android, as it opens and again as it closes, and the keyboard handler of
|
|
35
|
-
* `ConversationList` would scroll the thread to its end each time. The list
|
|
36
|
-
* ignores the keyboard from `openOverlay` until the close has settled:
|
|
37
|
-
* `closeOverlay` marks it `closing`, and `settleOverlay` ends that on the
|
|
38
|
-
* close's last keyboard event (Android), the menu's dismiss (iOS) or the
|
|
39
|
-
* reader's next drag. Android gives no dismiss callback for a `Modal`.
|
|
40
|
-
*/
|
|
41
27
|
overlay: "none" | "open" | "closing";
|
|
42
28
|
openOverlay: () => void;
|
|
43
29
|
closeOverlay: () => void;
|
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
|