@vvedantb/native-ui 0.17.2 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlertDialog.jsx +123 -0
- package/dist/AmbientBackground.jsx +73 -0
- package/dist/ArtifactList.jsx +59 -0
- package/dist/Avatar.jsx +285 -0
- package/dist/Badge.jsx +154 -0
- package/dist/BottomSheetContainer.jsx +208 -0
- package/dist/BulkActionBar.jsx +717 -0
- package/dist/Button.jsx +344 -0
- package/dist/CaptureButton.jsx +104 -0
- package/dist/Card.jsx +371 -0
- package/dist/Checkbox.jsx +177 -0
- package/dist/Chip.jsx +79 -0
- package/dist/ColorSwatches.jsx +159 -0
- package/dist/ConfirmDialog.jsx +157 -0
- package/dist/DateTimeField.jsx +204 -0
- package/dist/Dialog.jsx +614 -0
- package/dist/DividedList.jsx +120 -0
- package/dist/DropdownMenu.jsx +849 -0
- package/dist/EmptyState.jsx +434 -0
- package/dist/ExpoWebRoot.jsx +134 -0
- package/dist/FloatingFAB.jsx +95 -0
- package/dist/FloatingSurface.jsx +226 -0
- package/dist/FloatingTabBar.jsx +403 -0
- package/dist/HeaderIconButton.jsx +53 -0
- package/dist/IconButton.jsx +157 -0
- package/dist/Input.jsx +96 -0
- package/dist/Label.jsx +96 -0
- package/dist/LabeledSwitchRow.jsx +170 -0
- package/dist/LiquidGlass.jsx +2 -0
- package/dist/ListRow.jsx +281 -0
- package/dist/LoadingState.jsx +205 -0
- package/dist/PageIndicator.jsx +128 -0
- package/dist/PageTitle.jsx +205 -0
- package/dist/Pager.jsx +105 -0
- package/dist/PasswordInput.jsx +120 -0
- package/dist/PillTabs.jsx +300 -0
- package/dist/PinnedBotTile.jsx +212 -0
- package/dist/Progress.jsx +147 -0
- package/dist/SafeAreaContainer.jsx +38 -0
- package/dist/ScreenContainer.jsx +117 -0
- package/dist/SearchInput.jsx +150 -0
- package/dist/SectionLabel.jsx +128 -0
- package/dist/Select.jsx +223 -0
- package/dist/Separator.jsx +95 -0
- package/dist/Sheet.jsx +343 -0
- package/dist/SheetRow.jsx +198 -0
- package/dist/Skeleton.jsx +311 -0
- package/dist/Spinner.jsx +195 -0
- package/dist/StackPageHeader.jsx +160 -0
- package/dist/StatGrid.jsx +74 -0
- package/dist/StatusDot.jsx +129 -0
- package/dist/SurfaceRow.jsx +143 -0
- package/dist/SwipeableRow.jsx +50 -0
- package/dist/Switch.jsx +130 -0
- package/dist/Tabs.jsx +385 -0
- package/dist/Textarea.jsx +103 -0
- package/dist/ThemeToggle.jsx +78 -0
- package/dist/Toast.jsx +396 -0
- package/dist/ai/activity-step-detail.jsx +179 -0
- package/dist/ai/activity-step-label.js +816 -0
- package/dist/ai/activity-step-types.js +14 -0
- package/dist/ai/activity-step.jsx +98 -0
- package/dist/ai/activity-tasks-utils.js +172 -0
- package/dist/ai/activity-timeline.js +47 -0
- package/dist/ai/attachments.jsx +258 -0
- package/dist/ai/card-button.jsx +188 -0
- package/dist/ai/chain-of-thought.jsx +459 -0
- package/dist/ai/chat-jump-rail.jsx +57 -0
- package/dist/ai/chat-text.js +44 -0
- package/dist/ai/chat-thread.jsx +135 -0
- package/dist/ai/choice-question.jsx +925 -0
- package/dist/ai/code-block.jsx +574 -0
- package/dist/ai/collapsible.jsx +275 -0
- package/dist/ai/conversation.jsx +723 -0
- package/dist/ai/file-chip.jsx +198 -0
- package/dist/ai/icon-button.jsx +179 -0
- package/dist/ai/index.js +37 -0
- package/dist/ai/message-action-sheet.jsx +408 -0
- package/dist/ai/message-quote.jsx +241 -0
- package/dist/ai/message.jsx +739 -0
- package/dist/ai/prompt-input-menu.jsx +365 -0
- package/dist/ai/prompt-input.jsx +626 -0
- package/dist/ai/reasoning.jsx +446 -0
- package/dist/ai/reply-quote-chip.jsx +278 -0
- package/dist/ai/response-text.jsx +130 -0
- package/dist/ai/shimmer.jsx +149 -0
- package/dist/ai/sources.jsx +260 -0
- package/dist/ai/subagent-cards.jsx +645 -0
- package/dist/ai/suggestion.jsx +186 -0
- package/dist/ai/tool-approval-card.jsx +359 -0
- package/dist/ai/trace.jsx +728 -0
- package/dist/ai/unified-diff.jsx +280 -0
- package/dist/ai/use-streaming-disclosure.js +70 -0
- package/dist/auth/AuthProviders.jsx +27 -0
- package/dist/auth/AuthScreen.jsx +292 -0
- package/dist/auth/GoogleSignInButton.jsx +188 -0
- package/dist/auth/SecondFactorScreen.jsx +133 -0
- package/dist/auth/SignInScreen.jsx +482 -0
- package/dist/auth/authErrors.js +131 -0
- package/dist/auth/index.js +11 -0
- package/dist/auth/totp.js +378 -0
- package/dist/blur.js +36 -0
- package/dist/brand/AppIcons.jsx +118 -0
- package/dist/brand/AppMark.jsx +128 -0
- package/dist/brand/AppWordmark.jsx +138 -0
- package/dist/brand/GoogleMark.jsx +71 -0
- package/dist/brand/ProviderIcon.jsx +192 -0
- package/dist/brand/familyApps.js +33 -0
- package/dist/brand/index.js +11 -0
- package/dist/brand/svg.js +252 -0
- package/dist/brand/vProAppBenefits.js +19 -0
- package/dist/cn.js +5 -0
- package/dist/colors.js +15 -0
- package/dist/configureTheme.js +72 -0
- package/dist/controlStyles.js +520 -0
- package/dist/definiteSize.js +12 -0
- package/dist/dialogLayout.js +18 -0
- package/dist/entries/ai.js +4 -0
- package/dist/entries/ambient.js +3 -0
- package/dist/entries/auth.js +5 -0
- package/dist/entries/bottom-sheet.js +2 -0
- package/dist/entries/brand.js +2 -0
- package/dist/entries/button.js +2 -0
- package/dist/entries/date-time.js +3 -0
- package/dist/entries/expo-router.js +4 -0
- package/dist/entries/expo-web-root.js +3 -0
- package/dist/entries/floating.js +7 -0
- package/dist/entries/gesture-handler.js +4 -0
- package/dist/entries/keyboard-controller.js +4 -0
- package/dist/entries/layout.js +16 -0
- package/dist/entries/markdown.js +4 -0
- package/dist/entries/marketing.js +3 -0
- package/dist/entries/page-title.js +7 -0
- package/dist/entries/password-input.js +3 -0
- package/dist/entries/primitives.js +57 -0
- package/dist/entries/search-input.js +3 -0
- package/dist/entries/tab-bar.js +4 -0
- package/dist/entries/theme.js +7 -0
- package/dist/entries/toast.js +5 -0
- package/dist/entries/video.js +3 -0
- package/dist/entries/webview.js +4 -0
- package/dist/examples/AiChatGallery.jsx +509 -0
- package/dist/examples/ParityGallery.jsx +1307 -0
- package/dist/floating.js +62 -0
- package/dist/glassBlur.jsx +145 -0
- package/dist/gradient.js +17 -0
- package/dist/haptics.js +44 -0
- package/dist/highlight.js +382 -0
- package/dist/index.js +85 -0
- package/dist/initials.js +4 -0
- package/dist/loadingGrid.js +81 -0
- package/dist/markdown/Markdown.jsx +515 -0
- package/dist/markdown/MarkdownTable.jsx +443 -0
- package/dist/markdown/tableText.js +68 -0
- package/dist/marketing/PricingModal.jsx +608 -0
- package/dist/marketing/UpgradeToProCard.jsx +164 -0
- package/dist/marketing/pricing.js +34 -0
- package/dist/media/ImageGallery.jsx +580 -0
- package/dist/media/MediaCard.jsx +162 -0
- package/dist/media/imageGrid.js +54 -0
- package/dist/motion.js +33 -0
- package/dist/pagerSwipe.js +104 -0
- package/dist/palette.js +104 -0
- package/dist/primitives/button.jsx +127 -0
- package/dist/primitives/card.jsx +249 -0
- package/dist/primitives/icon.jsx +37 -0
- package/dist/primitives/input.jsx +56 -0
- package/dist/primitives/keyboard-controller.jsx +207 -0
- package/dist/primitives/keyboard-parts.jsx +75 -0
- package/dist/primitives/native-only-animated-view.jsx +68 -0
- package/dist/primitives/overlay.jsx +391 -0
- package/dist/primitives/pager-gesture.jsx +131 -0
- package/dist/primitives/select-host.jsx +103 -0
- package/dist/primitives/select.jsx +555 -0
- package/dist/primitives/sheet-drag.jsx +420 -0
- package/dist/primitives/sheet-gesture.jsx +219 -0
- package/dist/primitives/swipe-row-gesture.jsx +341 -0
- package/dist/primitives/switch.jsx +105 -0
- package/dist/primitives/text.jsx +145 -0
- package/dist/primitives/toast-drag-gesture.jsx +94 -0
- package/dist/primitives/use-controllable-state.js +40 -0
- package/dist/primitives/web-click-guard.js +69 -0
- package/dist/push.js +166 -0
- package/dist/relativeTime.js +70 -0
- package/dist/router/RouterStackPageHeader.jsx +53 -0
- package/dist/selectA11y.js +32 -0
- package/dist/settings/MoreFromProjectV.jsx +168 -0
- package/dist/settings/SettingsEmptyState.jsx +102 -0
- package/dist/settings/SettingsField.jsx +49 -0
- package/dist/settings/SettingsSection.jsx +101 -0
- package/dist/settings/SettingsStack.jsx +17 -0
- package/dist/settings/SettingsToggleRow.jsx +163 -0
- package/dist/settings/projectVMobileApps.js +126 -0
- package/dist/settings/relaxedSizeStyle.js +11 -0
- package/dist/sheetDrag.js +76 -0
- package/dist/svgA11y.js +46 -0
- package/dist/swipeRow.js +161 -0
- package/dist/tabBarRoutes.js +41 -0
- package/dist/tabIndicator.js +139 -0
- package/dist/tailwind-preset.cjs +255 -0
- package/dist/tailwind-preset.d.cts +55 -0
- package/dist/theme.jsx +62 -0
- package/dist/toastChrome.js +110 -0
- package/dist/toastDrag.js +51 -0
- package/dist/toastStore.js +54 -0
- package/dist/tokens.js +70 -0
- package/dist/typography.js +40 -0
- package/dist/useReduceMotion.js +32 -0
- package/dist/useReduceTransparency.js +27 -0
- package/dist/useScheme.js +15 -0
- package/dist/video/InlineVideo.jsx +115 -0
- package/dist/webview/HtmlView.jsx +169 -0
- package/dist/webview/HtmlView.web.jsx +63 -0
- package/dist/webview/htmlView.js +43 -0
- package/package.json +70 -33
- package/src/DropdownMenu.tsx +28 -16
- package/src/FloatingTabBar.tsx +78 -41
- package/src/ai/conversation.tsx +12 -8
- package/src/glassBlur.tsx +47 -22
- package/src/primitives/swipe-row-gesture.tsx +11 -2
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Pressable, ScrollView, Text, View } from "react-native";
|
|
3
|
+
import { cn } from "../cn";
|
|
4
|
+
import { MIN_TOUCH_TARGET, sizeStyle, textStyle, touchSlop } from "../controlStyles";
|
|
5
|
+
import { palette } from "../palette";
|
|
6
|
+
import { useLargerText } from "../theme";
|
|
7
|
+
import { tokens } from "../tokens";
|
|
8
|
+
import { useScheme } from "../useScheme";
|
|
9
|
+
import { chatTextSize } from "./chat-text";
|
|
10
|
+
/**
|
|
11
|
+
* Prompt suggestions. Horizontal is a `ScrollView` with no scroll bar (the web
|
|
12
|
+
* row with its scroll arrows; a phone swipes instead).
|
|
13
|
+
*/
|
|
14
|
+
export function Suggestions(t0) {
|
|
15
|
+
const $ = _c(13);
|
|
16
|
+
const {
|
|
17
|
+
orientation: t1,
|
|
18
|
+
className,
|
|
19
|
+
contentContainerClassName,
|
|
20
|
+
children
|
|
21
|
+
} = t0;
|
|
22
|
+
const orientation = t1 === undefined ? "horizontal" : t1;
|
|
23
|
+
if (orientation === "vertical") {
|
|
24
|
+
let t2;
|
|
25
|
+
if ($[0] !== className) {
|
|
26
|
+
t2 = cn("w-full gap-2", className);
|
|
27
|
+
$[0] = className;
|
|
28
|
+
$[1] = t2;
|
|
29
|
+
} else {
|
|
30
|
+
t2 = $[1];
|
|
31
|
+
}
|
|
32
|
+
let t3;
|
|
33
|
+
if ($[2] !== children || $[3] !== t2) {
|
|
34
|
+
t3 = <View className={t2}>{children}</View>;
|
|
35
|
+
$[2] = children;
|
|
36
|
+
$[3] = t2;
|
|
37
|
+
$[4] = t3;
|
|
38
|
+
} else {
|
|
39
|
+
t3 = $[4];
|
|
40
|
+
}
|
|
41
|
+
return t3;
|
|
42
|
+
}
|
|
43
|
+
let t2;
|
|
44
|
+
if ($[5] !== className) {
|
|
45
|
+
t2 = cn("w-full grow-0", className);
|
|
46
|
+
$[5] = className;
|
|
47
|
+
$[6] = t2;
|
|
48
|
+
} else {
|
|
49
|
+
t2 = $[6];
|
|
50
|
+
}
|
|
51
|
+
let t3;
|
|
52
|
+
if ($[7] !== contentContainerClassName) {
|
|
53
|
+
t3 = cn("items-center gap-2 px-1", contentContainerClassName);
|
|
54
|
+
$[7] = contentContainerClassName;
|
|
55
|
+
$[8] = t3;
|
|
56
|
+
} else {
|
|
57
|
+
t3 = $[8];
|
|
58
|
+
}
|
|
59
|
+
let t4;
|
|
60
|
+
if ($[9] !== children || $[10] !== t2 || $[11] !== t3) {
|
|
61
|
+
t4 = <ScrollView horizontal={true} showsHorizontalScrollIndicator={false} keyboardShouldPersistTaps="handled" className={t2} contentContainerClassName={t3}>{children}</ScrollView>;
|
|
62
|
+
$[9] = children;
|
|
63
|
+
$[10] = t2;
|
|
64
|
+
$[11] = t3;
|
|
65
|
+
$[12] = t4;
|
|
66
|
+
} else {
|
|
67
|
+
t4 = $[12];
|
|
68
|
+
}
|
|
69
|
+
return t4;
|
|
70
|
+
}
|
|
71
|
+
/** A `text-sm` line with the web `py-1.5`: 32 high. The slop brings it to 44. */
|
|
72
|
+
const CHIP_HEIGHT = 32;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A round chip with the web suggestion look: `rounded-full border
|
|
76
|
+
* bg-surface-secondary px-3 py-1.5 text-sm text-muted-foreground`. Pressed,
|
|
77
|
+
* it takes the web hover (`bg-surface-tertiary text-foreground`).
|
|
78
|
+
*/
|
|
79
|
+
export function Suggestion(t0) {
|
|
80
|
+
const $ = _c(27);
|
|
81
|
+
const {
|
|
82
|
+
suggestion,
|
|
83
|
+
onPress,
|
|
84
|
+
children,
|
|
85
|
+
disabled,
|
|
86
|
+
testID
|
|
87
|
+
} = t0;
|
|
88
|
+
const scheme = useScheme();
|
|
89
|
+
const largerText = useLargerText();
|
|
90
|
+
let t1;
|
|
91
|
+
if ($[0] !== largerText) {
|
|
92
|
+
t1 = chatTextSize("small", largerText);
|
|
93
|
+
$[0] = largerText;
|
|
94
|
+
$[1] = t1;
|
|
95
|
+
} else {
|
|
96
|
+
t1 = $[1];
|
|
97
|
+
}
|
|
98
|
+
const size = t1;
|
|
99
|
+
const t2 = Boolean(disabled);
|
|
100
|
+
let t3;
|
|
101
|
+
if ($[2] !== t2) {
|
|
102
|
+
t3 = {
|
|
103
|
+
disabled: t2
|
|
104
|
+
};
|
|
105
|
+
$[2] = t2;
|
|
106
|
+
$[3] = t3;
|
|
107
|
+
} else {
|
|
108
|
+
t3 = $[3];
|
|
109
|
+
}
|
|
110
|
+
let t4;
|
|
111
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
112
|
+
t4 = touchSlop(MIN_TOUCH_TARGET, CHIP_HEIGHT);
|
|
113
|
+
$[4] = t4;
|
|
114
|
+
} else {
|
|
115
|
+
t4 = $[4];
|
|
116
|
+
}
|
|
117
|
+
let t5;
|
|
118
|
+
if ($[5] !== onPress || $[6] !== suggestion) {
|
|
119
|
+
t5 = () => onPress?.(suggestion);
|
|
120
|
+
$[5] = onPress;
|
|
121
|
+
$[6] = suggestion;
|
|
122
|
+
$[7] = t5;
|
|
123
|
+
} else {
|
|
124
|
+
t5 = $[7];
|
|
125
|
+
}
|
|
126
|
+
const t6 = largerText ? "min-h-12 px-4 py-2" : "min-h-8 px-3 py-1.5";
|
|
127
|
+
const t7 = disabled && "opacity-45";
|
|
128
|
+
let t8;
|
|
129
|
+
if ($[8] !== t6 || $[9] !== t7) {
|
|
130
|
+
t8 = cn("justify-center border", t6, t7);
|
|
131
|
+
$[8] = t6;
|
|
132
|
+
$[9] = t7;
|
|
133
|
+
$[10] = t8;
|
|
134
|
+
} else {
|
|
135
|
+
t8 = $[10];
|
|
136
|
+
}
|
|
137
|
+
let t9;
|
|
138
|
+
if ($[11] !== scheme) {
|
|
139
|
+
t9 = t10 => {
|
|
140
|
+
const {
|
|
141
|
+
pressed
|
|
142
|
+
} = t10;
|
|
143
|
+
return {
|
|
144
|
+
borderRadius: tokens.radius.pill,
|
|
145
|
+
borderColor: tokens.color.border[scheme],
|
|
146
|
+
backgroundColor: pressed ? palette.surfaceTertiary[scheme] : tokens.color.surfaceSecondary[scheme]
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
$[11] = scheme;
|
|
150
|
+
$[12] = t9;
|
|
151
|
+
} else {
|
|
152
|
+
t9 = $[12];
|
|
153
|
+
}
|
|
154
|
+
let t10;
|
|
155
|
+
if ($[13] !== children || $[14] !== scheme || $[15] !== size || $[16] !== suggestion) {
|
|
156
|
+
t10 = t11 => {
|
|
157
|
+
const {
|
|
158
|
+
pressed: pressed_0
|
|
159
|
+
} = t11;
|
|
160
|
+
return <Text className={cn(size, "font-instrument-sans")} style={[sizeStyle(size), textStyle(pressed_0 ? "foreground" : "muted", scheme)]}>{children ?? suggestion}</Text>;
|
|
161
|
+
};
|
|
162
|
+
$[13] = children;
|
|
163
|
+
$[14] = scheme;
|
|
164
|
+
$[15] = size;
|
|
165
|
+
$[16] = suggestion;
|
|
166
|
+
$[17] = t10;
|
|
167
|
+
} else {
|
|
168
|
+
t10 = $[17];
|
|
169
|
+
}
|
|
170
|
+
let t11;
|
|
171
|
+
if ($[18] !== disabled || $[19] !== suggestion || $[20] !== t10 || $[21] !== t3 || $[22] !== t5 || $[23] !== t8 || $[24] !== t9 || $[25] !== testID) {
|
|
172
|
+
t11 = <Pressable testID={testID} accessibilityRole="button" accessibilityLabel={suggestion} accessibilityState={t3} disabled={disabled} hitSlop={t4} onPress={t5} className={t8} style={t9}>{t10}</Pressable>;
|
|
173
|
+
$[18] = disabled;
|
|
174
|
+
$[19] = suggestion;
|
|
175
|
+
$[20] = t10;
|
|
176
|
+
$[21] = t3;
|
|
177
|
+
$[22] = t5;
|
|
178
|
+
$[23] = t8;
|
|
179
|
+
$[24] = t9;
|
|
180
|
+
$[25] = testID;
|
|
181
|
+
$[26] = t11;
|
|
182
|
+
} else {
|
|
183
|
+
t11 = $[26];
|
|
184
|
+
}
|
|
185
|
+
return t11;
|
|
186
|
+
}
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Text, View } from "react-native";
|
|
4
|
+
import { IconTool } from "@tabler/icons-react-native";
|
|
5
|
+
import { cn } from "../cn";
|
|
6
|
+
import { cardStyle, sizeStyle, textStyle, typeStyle } from "../controlStyles";
|
|
7
|
+
import { withAlpha, palette } from "../palette";
|
|
8
|
+
import { useLargerText } from "../theme";
|
|
9
|
+
import { tokens } from "../tokens";
|
|
10
|
+
import { useScheme } from "../useScheme";
|
|
11
|
+
import { Input } from "../Input";
|
|
12
|
+
import { Textarea } from "../Textarea";
|
|
13
|
+
import { CardButton } from "./card-button";
|
|
14
|
+
import { chatTextSize, MONO_FONT } from "./chat-text";
|
|
15
|
+
export const DRAFT_ROLE_LABELS = {
|
|
16
|
+
to: "To",
|
|
17
|
+
cc: "Cc",
|
|
18
|
+
bcc: "Bcc",
|
|
19
|
+
subject: "Subject",
|
|
20
|
+
body: "Message"
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** The fields whose value differs from the original. `read` returns the edited value, or undefined for no edit. */
|
|
24
|
+
export function changedDraftEdits(fields, read) {
|
|
25
|
+
return fields.flatMap(field => {
|
|
26
|
+
const value = read(field.key);
|
|
27
|
+
return value === undefined || value === field.value ? [] : [{
|
|
28
|
+
key: field.key,
|
|
29
|
+
value
|
|
30
|
+
}];
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** What the reader chose. `edit` is offered by `ToolDraftCard` only. */
|
|
35
|
+
|
|
36
|
+
/** Characters of the args summary before it is cut with an ellipsis. */
|
|
37
|
+
export const ARGS_MAX_CHARS = 160;
|
|
38
|
+
|
|
39
|
+
/** One line summary of tool arguments, cut at `max` characters. */
|
|
40
|
+
export function summarizeArgs(args, max = ARGS_MAX_CHARS) {
|
|
41
|
+
if (args == null) return "";
|
|
42
|
+
let text;
|
|
43
|
+
if (typeof args === "string") {
|
|
44
|
+
text = args;
|
|
45
|
+
} else {
|
|
46
|
+
try {
|
|
47
|
+
text = JSON.stringify(args) ?? "";
|
|
48
|
+
} catch {
|
|
49
|
+
text = "[unserialisable arguments]";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
text = text.replace(/\s+/g, " ").trim();
|
|
53
|
+
return text.length > max ? `${text.slice(0, Math.max(0, max - 1))}…` : text;
|
|
54
|
+
}
|
|
55
|
+
function ToolCardBase(t0) {
|
|
56
|
+
const $ = _c(60);
|
|
57
|
+
const {
|
|
58
|
+
toolName,
|
|
59
|
+
args,
|
|
60
|
+
onDecide,
|
|
61
|
+
pending: t1,
|
|
62
|
+
disabled: t2,
|
|
63
|
+
approveLabel: t3,
|
|
64
|
+
denyLabel: t4,
|
|
65
|
+
editLabel: t5,
|
|
66
|
+
allowEdit: t6,
|
|
67
|
+
heading,
|
|
68
|
+
metaNote,
|
|
69
|
+
fields,
|
|
70
|
+
server,
|
|
71
|
+
routineMode: t7,
|
|
72
|
+
expiresLabel,
|
|
73
|
+
target,
|
|
74
|
+
meta,
|
|
75
|
+
chrome,
|
|
76
|
+
className,
|
|
77
|
+
testID: t8
|
|
78
|
+
} = t0;
|
|
79
|
+
const pending = t1 === undefined ? false : t1;
|
|
80
|
+
const disabled = t2 === undefined ? false : t2;
|
|
81
|
+
const approveLabel = t3 === undefined ? "Approve" : t3;
|
|
82
|
+
const denyLabel = t4 === undefined ? "Deny" : t4;
|
|
83
|
+
const editLabel = t5 === undefined ? "Edit" : t5;
|
|
84
|
+
const allowEdit = t6 === undefined ? false : t6;
|
|
85
|
+
const routineMode = t7 === undefined ? false : t7;
|
|
86
|
+
const testID = t8 === undefined ? "tool-approval-card" : t8;
|
|
87
|
+
const scheme = useScheme();
|
|
88
|
+
const largerText = useLargerText();
|
|
89
|
+
const body = chatTextSize("body", largerText);
|
|
90
|
+
const small = chatTextSize("small", largerText);
|
|
91
|
+
const caption = chatTextSize("caption", largerText);
|
|
92
|
+
const off = pending || disabled;
|
|
93
|
+
let t9;
|
|
94
|
+
if ($[0] !== args) {
|
|
95
|
+
t9 = summarizeArgs(args);
|
|
96
|
+
$[0] = args;
|
|
97
|
+
$[1] = t9;
|
|
98
|
+
} else {
|
|
99
|
+
t9 = $[1];
|
|
100
|
+
}
|
|
101
|
+
const summary = t9;
|
|
102
|
+
const [edits, setEdits] = useState(null);
|
|
103
|
+
const hasFields = fields !== undefined;
|
|
104
|
+
const headerFields = fields?.filter(_temp) ?? [];
|
|
105
|
+
let t10;
|
|
106
|
+
if ($[2] !== fields) {
|
|
107
|
+
t10 = fields?.find(_temp2);
|
|
108
|
+
$[2] = fields;
|
|
109
|
+
$[3] = t10;
|
|
110
|
+
} else {
|
|
111
|
+
t10 = $[3];
|
|
112
|
+
}
|
|
113
|
+
const bodyField = t10;
|
|
114
|
+
const t11 = server ? `via ${server}` : "built-in tool";
|
|
115
|
+
let t12;
|
|
116
|
+
if ($[4] !== metaNote) {
|
|
117
|
+
t12 = metaNote ? [metaNote] : [];
|
|
118
|
+
$[4] = metaNote;
|
|
119
|
+
$[5] = t12;
|
|
120
|
+
} else {
|
|
121
|
+
t12 = $[5];
|
|
122
|
+
}
|
|
123
|
+
let t13;
|
|
124
|
+
if ($[6] !== t11 || $[7] !== t12) {
|
|
125
|
+
t13 = [t11, ...t12];
|
|
126
|
+
$[6] = t11;
|
|
127
|
+
$[7] = t12;
|
|
128
|
+
$[8] = t13;
|
|
129
|
+
} else {
|
|
130
|
+
t13 = $[8];
|
|
131
|
+
}
|
|
132
|
+
const metaText = t13.join(" \xB7 ") + (routineMode ? " \xB7 queued while you were away" : "") + (expiresLabel ? ` · Expires ${expiresLabel}` : "");
|
|
133
|
+
const showMeta = meta !== undefined || server !== undefined || routineMode || expiresLabel !== undefined || metaNote !== undefined;
|
|
134
|
+
let t14;
|
|
135
|
+
if ($[9] !== edits || $[10] !== fields || $[11] !== onDecide) {
|
|
136
|
+
t14 = () => {
|
|
137
|
+
if (!fields) {
|
|
138
|
+
return onDecide?.("edit");
|
|
139
|
+
}
|
|
140
|
+
setEdits(edits ? null : Object.fromEntries(fields.map(_temp3)));
|
|
141
|
+
};
|
|
142
|
+
$[9] = edits;
|
|
143
|
+
$[10] = fields;
|
|
144
|
+
$[11] = onDecide;
|
|
145
|
+
$[12] = t14;
|
|
146
|
+
} else {
|
|
147
|
+
t14 = $[12];
|
|
148
|
+
}
|
|
149
|
+
const onEdit = t14;
|
|
150
|
+
let t15;
|
|
151
|
+
if ($[13] !== edits || $[14] !== fields || $[15] !== onDecide) {
|
|
152
|
+
t15 = () => {
|
|
153
|
+
if (fields && edits) {
|
|
154
|
+
onDecide?.("approve", changedDraftEdits(fields, key => edits[key]));
|
|
155
|
+
} else {
|
|
156
|
+
onDecide?.("approve");
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
$[13] = edits;
|
|
160
|
+
$[14] = fields;
|
|
161
|
+
$[15] = onDecide;
|
|
162
|
+
$[16] = t15;
|
|
163
|
+
} else {
|
|
164
|
+
t15 = $[16];
|
|
165
|
+
}
|
|
166
|
+
const onApprove = t15;
|
|
167
|
+
let t16;
|
|
168
|
+
if ($[17] !== className) {
|
|
169
|
+
t16 = cn("w-full gap-3 p-4", className);
|
|
170
|
+
$[17] = className;
|
|
171
|
+
$[18] = t16;
|
|
172
|
+
} else {
|
|
173
|
+
t16 = $[18];
|
|
174
|
+
}
|
|
175
|
+
let t17;
|
|
176
|
+
if ($[19] !== scheme) {
|
|
177
|
+
t17 = cardStyle(scheme);
|
|
178
|
+
$[19] = scheme;
|
|
179
|
+
$[20] = t17;
|
|
180
|
+
} else {
|
|
181
|
+
t17 = $[20];
|
|
182
|
+
}
|
|
183
|
+
const t18 = palette.primary[scheme];
|
|
184
|
+
let t19;
|
|
185
|
+
if ($[21] !== t18) {
|
|
186
|
+
t19 = withAlpha(t18, 0.25);
|
|
187
|
+
$[21] = t18;
|
|
188
|
+
$[22] = t19;
|
|
189
|
+
} else {
|
|
190
|
+
t19 = $[22];
|
|
191
|
+
}
|
|
192
|
+
let t20;
|
|
193
|
+
if ($[23] !== t19) {
|
|
194
|
+
t20 = {
|
|
195
|
+
borderWidth: 1,
|
|
196
|
+
borderColor: t19
|
|
197
|
+
};
|
|
198
|
+
$[23] = t19;
|
|
199
|
+
$[24] = t20;
|
|
200
|
+
} else {
|
|
201
|
+
t20 = $[24];
|
|
202
|
+
}
|
|
203
|
+
let t21;
|
|
204
|
+
if ($[25] !== t17 || $[26] !== t20) {
|
|
205
|
+
t21 = [t17, t20];
|
|
206
|
+
$[25] = t17;
|
|
207
|
+
$[26] = t20;
|
|
208
|
+
$[27] = t21;
|
|
209
|
+
} else {
|
|
210
|
+
t21 = $[27];
|
|
211
|
+
}
|
|
212
|
+
const t22 = largerText ? 20 : 16;
|
|
213
|
+
const t23 = tokens.color.muted[scheme];
|
|
214
|
+
let t24;
|
|
215
|
+
if ($[28] !== t22 || $[29] !== t23) {
|
|
216
|
+
t24 = <IconTool size={t22} color={t23} />;
|
|
217
|
+
$[28] = t22;
|
|
218
|
+
$[29] = t23;
|
|
219
|
+
$[30] = t24;
|
|
220
|
+
} else {
|
|
221
|
+
t24 = $[30];
|
|
222
|
+
}
|
|
223
|
+
let t25;
|
|
224
|
+
if ($[31] !== pending) {
|
|
225
|
+
t25 = {
|
|
226
|
+
busy: pending
|
|
227
|
+
};
|
|
228
|
+
$[31] = pending;
|
|
229
|
+
$[32] = t25;
|
|
230
|
+
} else {
|
|
231
|
+
t25 = $[32];
|
|
232
|
+
}
|
|
233
|
+
const t26 = `${testID}-deny`;
|
|
234
|
+
const t27 = `${denyLabel} ${toolName}`;
|
|
235
|
+
let t28;
|
|
236
|
+
if ($[33] !== onDecide) {
|
|
237
|
+
t28 = () => onDecide?.("deny");
|
|
238
|
+
$[33] = onDecide;
|
|
239
|
+
$[34] = t28;
|
|
240
|
+
} else {
|
|
241
|
+
t28 = $[34];
|
|
242
|
+
}
|
|
243
|
+
let t29;
|
|
244
|
+
if ($[35] !== denyLabel || $[36] !== off || $[37] !== t26 || $[38] !== t27 || $[39] !== t28) {
|
|
245
|
+
t29 = <CardButton testID={t26} label={denyLabel} accessibilityLabel={t27} variant="outline" disabled={off} onPress={t28} />;
|
|
246
|
+
$[35] = denyLabel;
|
|
247
|
+
$[36] = off;
|
|
248
|
+
$[37] = t26;
|
|
249
|
+
$[38] = t27;
|
|
250
|
+
$[39] = t28;
|
|
251
|
+
$[40] = t29;
|
|
252
|
+
} else {
|
|
253
|
+
t29 = $[40];
|
|
254
|
+
}
|
|
255
|
+
let t30;
|
|
256
|
+
if ($[41] !== allowEdit || $[42] !== editLabel || $[43] !== edits || $[44] !== off || $[45] !== onEdit || $[46] !== testID || $[47] !== toolName) {
|
|
257
|
+
t30 = allowEdit ? <CardButton testID={`${testID}-edit`} label={edits ? "Cancel edit" : editLabel} accessibilityLabel={`${edits ? "Cancel edit" : editLabel} ${toolName}`} variant="secondary" disabled={off} onPress={onEdit} /> : null;
|
|
258
|
+
$[41] = allowEdit;
|
|
259
|
+
$[42] = editLabel;
|
|
260
|
+
$[43] = edits;
|
|
261
|
+
$[44] = off;
|
|
262
|
+
$[45] = onEdit;
|
|
263
|
+
$[46] = testID;
|
|
264
|
+
$[47] = toolName;
|
|
265
|
+
$[48] = t30;
|
|
266
|
+
} else {
|
|
267
|
+
t30 = $[48];
|
|
268
|
+
}
|
|
269
|
+
const t31 = `${testID}-approve`;
|
|
270
|
+
const t32 = `${approveLabel} ${toolName}`;
|
|
271
|
+
let t33;
|
|
272
|
+
if ($[49] !== approveLabel || $[50] !== off || $[51] !== onApprove || $[52] !== t31 || $[53] !== t32) {
|
|
273
|
+
t33 = <CardButton testID={t31} label={approveLabel} accessibilityLabel={t32} variant="primary" disabled={off} onPress={onApprove} />;
|
|
274
|
+
$[49] = approveLabel;
|
|
275
|
+
$[50] = off;
|
|
276
|
+
$[51] = onApprove;
|
|
277
|
+
$[52] = t31;
|
|
278
|
+
$[53] = t32;
|
|
279
|
+
$[54] = t33;
|
|
280
|
+
} else {
|
|
281
|
+
t33 = $[54];
|
|
282
|
+
}
|
|
283
|
+
let t34;
|
|
284
|
+
if ($[55] !== t25 || $[56] !== t29 || $[57] !== t30 || $[58] !== t33) {
|
|
285
|
+
t34 = <View className="flex-row flex-wrap items-center justify-end gap-2" accessibilityState={t25}>{t29}{t30}{t33}</View>;
|
|
286
|
+
$[55] = t25;
|
|
287
|
+
$[56] = t29;
|
|
288
|
+
$[57] = t30;
|
|
289
|
+
$[58] = t33;
|
|
290
|
+
$[59] = t34;
|
|
291
|
+
} else {
|
|
292
|
+
t34 = $[59];
|
|
293
|
+
}
|
|
294
|
+
return <View testID={testID} accessible={false} accessibilityLabel={`${heading}: ${toolName}`} className={t16} style={t21}><View className="flex-row items-center gap-2">{t24}<Text className={cn(caption, "font-instrument-sans-semibold")} style={[sizeStyle(caption), typeStyle("semibold"), textStyle("muted", scheme)]}>{pending ? "Sending decision\u2026" : heading}</Text></View>{showMeta ? meta ?? <Text testID={`${testID}-meta`} className={caption} style={[sizeStyle(caption), textStyle("muted", scheme)]}>{metaText}</Text> : null}{chrome}<Text testID={`${testID}-name`} numberOfLines={2} className={cn(body, "font-instrument-sans-semibold")} style={[sizeStyle(body), typeStyle("semibold"), textStyle("foreground", scheme)]}>{toolName}</Text>{target ? <Text testID={`${testID}-target`} className={small} style={[sizeStyle(small), textStyle("muted", scheme)]}>{`Target: ${target}`}</Text> : null}{hasFields ? edits ? <View testID={`${testID}-editor`} className="gap-2">{fields.map(field_2 => <View key={field_2.key} className="gap-1"><Text className={caption} style={[sizeStyle(caption), textStyle("muted", scheme)]}>{DRAFT_ROLE_LABELS[field_2.role]}</Text>{field_2.role === "body" ? <Textarea testID={`${testID}-field-${field_2.key}`} value={edits[field_2.key] ?? ""} onChangeText={value => setEdits({
|
|
295
|
+
...edits,
|
|
296
|
+
[field_2.key]: value
|
|
297
|
+
})} numberOfLines={8} accessibilityLabel={DRAFT_ROLE_LABELS[field_2.role]} /> : <Input testID={`${testID}-field-${field_2.key}`} value={edits[field_2.key] ?? ""} onChangeText={value_0 => setEdits({
|
|
298
|
+
...edits,
|
|
299
|
+
[field_2.key]: value_0
|
|
300
|
+
})} accessibilityLabel={DRAFT_ROLE_LABELS[field_2.role]} />}</View>)}</View> : <View testID={`${testID}-preview`} className="gap-2">{headerFields.map(field_3 => <View key={field_3.key} className="flex-row gap-2"><Text className={cn(caption, "w-16")} style={[sizeStyle(caption), textStyle("muted", scheme)]}>{DRAFT_ROLE_LABELS[field_3.role]}</Text><Text className={cn(small, "min-w-0 flex-1")} style={[sizeStyle(small), textStyle("foreground", scheme)]}>{field_3.value}</Text></View>)}{bodyField ? <Text numberOfLines={12} className={body} style={[sizeStyle(body), textStyle("foreground", scheme)]}>{bodyField.value}</Text> : null}</View> : summary ? <Text testID={`${testID}-args`} numberOfLines={3} className={small} style={[sizeStyle(small), textStyle("muted", scheme), {
|
|
301
|
+
fontFamily: MONO_FONT
|
|
302
|
+
}]}>{summary}</Text> : null}{t34}</View>;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* A pending tool call that needs a yes or no: the tool name, a cut summary of
|
|
307
|
+
* the arguments, and Deny and Approve buttons (44 point targets). With
|
|
308
|
+
* `pending` or `disabled` both buttons are off.
|
|
309
|
+
*/
|
|
310
|
+
function _temp3(field_1) {
|
|
311
|
+
return [field_1.key, field_1.value];
|
|
312
|
+
}
|
|
313
|
+
function _temp2(field_0) {
|
|
314
|
+
return field_0.role === "body";
|
|
315
|
+
}
|
|
316
|
+
function _temp(field) {
|
|
317
|
+
return field.role !== "body";
|
|
318
|
+
}
|
|
319
|
+
export function ToolApprovalCard(props) {
|
|
320
|
+
const $ = _c(2);
|
|
321
|
+
let t0;
|
|
322
|
+
if ($[0] !== props) {
|
|
323
|
+
t0 = <ToolCardBase {...props} heading="Approval needed" />;
|
|
324
|
+
$[0] = props;
|
|
325
|
+
$[1] = t0;
|
|
326
|
+
} else {
|
|
327
|
+
t0 = $[1];
|
|
328
|
+
}
|
|
329
|
+
return t0;
|
|
330
|
+
}
|
|
331
|
+
/** As `ToolApprovalCard`, plus an Edit button that reports `"edit"`, for a draft the reader may change first. */
|
|
332
|
+
export function ToolDraftCard(t0) {
|
|
333
|
+
const $ = _c(6);
|
|
334
|
+
let props;
|
|
335
|
+
let t1;
|
|
336
|
+
if ($[0] !== t0) {
|
|
337
|
+
({
|
|
338
|
+
testID: t1,
|
|
339
|
+
...props
|
|
340
|
+
} = t0);
|
|
341
|
+
$[0] = t0;
|
|
342
|
+
$[1] = props;
|
|
343
|
+
$[2] = t1;
|
|
344
|
+
} else {
|
|
345
|
+
props = $[1];
|
|
346
|
+
t1 = $[2];
|
|
347
|
+
}
|
|
348
|
+
const testID = t1 === undefined ? "tool-draft-card" : t1;
|
|
349
|
+
let t2;
|
|
350
|
+
if ($[3] !== props || $[4] !== testID) {
|
|
351
|
+
t2 = <ToolCardBase {...props} testID={testID} allowEdit={true} heading="Draft for review" metaNote="Nothing is sent until you press Send" />;
|
|
352
|
+
$[3] = props;
|
|
353
|
+
$[4] = testID;
|
|
354
|
+
$[5] = t2;
|
|
355
|
+
} else {
|
|
356
|
+
t2 = $[5];
|
|
357
|
+
}
|
|
358
|
+
return t2;
|
|
359
|
+
}
|