@vvedantb/native-ui 0.26.1 → 0.27.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.
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Text, View } from "react-native";
|
|
3
|
+
import { IconCheck, IconMessageQuestion, IconPencil } from "@tabler/icons-react-native";
|
|
4
|
+
import { sizeStyle, textStyle, typeStyle } 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
|
+
import { TopicBadge } from "./choice-question";
|
|
11
|
+
const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The offered labels the user picked. A whole-answer match wins first, so a
|
|
15
|
+
* single-select label holding ", " is not read as several picks; only a
|
|
16
|
+
* multi-select answer is split on the ", " the dock joins it with.
|
|
17
|
+
*/
|
|
18
|
+
export function selectedLabels(answer, question) {
|
|
19
|
+
if (answer === undefined) return [];
|
|
20
|
+
const offered = new Set(question.options.map(option => option.label));
|
|
21
|
+
if (offered.has(answer)) return [answer];
|
|
22
|
+
if (!question.multiSelect) return [];
|
|
23
|
+
return answer.split(", ").filter(label => offered.has(label));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Free text typed into "Other": an answer that matches no offered label. */
|
|
27
|
+
export function freeTextAnswer(answer, chosen) {
|
|
28
|
+
if (answer === undefined || answer.trim().length === 0) return null;
|
|
29
|
+
return chosen.length > 0 ? null : answer;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The read-only record of an AskUserQuestion prompt and the answer given, as
|
|
33
|
+
* the web `ActivityQuestionCard`: "Question(s)" over each question with its
|
|
34
|
+
* topic badge, its lettered options with the picked ones filled and checked,
|
|
35
|
+
* the free "Other" text with a pencil, and "Answered in the next message" when
|
|
36
|
+
* no structured answer was kept. The live prompt is `ChoiceQuestion`; this is
|
|
37
|
+
* what the transcript keeps once it is answered. Nothing here is pressable.
|
|
38
|
+
*/
|
|
39
|
+
export function ActivityQuestionCard(t0) {
|
|
40
|
+
const $ = _c(11);
|
|
41
|
+
const {
|
|
42
|
+
questions,
|
|
43
|
+
answers
|
|
44
|
+
} = t0;
|
|
45
|
+
const scheme = useScheme();
|
|
46
|
+
const largerText = useLargerText();
|
|
47
|
+
if (questions.length === 0) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
let t1;
|
|
51
|
+
if ($[0] !== answers || $[1] !== largerText || $[2] !== questions || $[3] !== scheme) {
|
|
52
|
+
const caption = chatTextSize("caption", largerText);
|
|
53
|
+
const small = chatTextSize("small", largerText);
|
|
54
|
+
const title = questions.length > 1 ? "Questions" : "Question";
|
|
55
|
+
const t2 = tokens.color.surface[scheme];
|
|
56
|
+
let t3;
|
|
57
|
+
if ($[5] !== t2) {
|
|
58
|
+
t3 = {
|
|
59
|
+
borderRadius: tokens.radius.lg,
|
|
60
|
+
backgroundColor: t2,
|
|
61
|
+
padding: 12,
|
|
62
|
+
gap: 12
|
|
63
|
+
};
|
|
64
|
+
$[5] = t2;
|
|
65
|
+
$[6] = t3;
|
|
66
|
+
} else {
|
|
67
|
+
t3 = $[6];
|
|
68
|
+
}
|
|
69
|
+
let t4;
|
|
70
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
71
|
+
t4 = {
|
|
72
|
+
gap: 6
|
|
73
|
+
};
|
|
74
|
+
$[7] = t4;
|
|
75
|
+
} else {
|
|
76
|
+
t4 = $[7];
|
|
77
|
+
}
|
|
78
|
+
const t5 = largerText ? 18 : 14;
|
|
79
|
+
const t6 = tokens.color.muted[scheme];
|
|
80
|
+
let t7;
|
|
81
|
+
if ($[8] !== t5 || $[9] !== t6) {
|
|
82
|
+
t7 = <IconMessageQuestion size={t5} color={t6} />;
|
|
83
|
+
$[8] = t5;
|
|
84
|
+
$[9] = t6;
|
|
85
|
+
$[10] = t7;
|
|
86
|
+
} else {
|
|
87
|
+
t7 = $[10];
|
|
88
|
+
}
|
|
89
|
+
t1 = <View accessibilityLabel={title} style={t3}><View className="flex-row items-center" style={t4}>{t7}<Text className="font-instrument-sans-medium" style={[sizeStyle(caption), textStyle("muted", scheme), typeStyle("medium")]}>{title}</Text></View>{questions.map((question, questionIndex) => {
|
|
90
|
+
const answer = answers?.[question.question];
|
|
91
|
+
const chosen = selectedLabels(answer, question);
|
|
92
|
+
const freeText = freeTextAnswer(answer, chosen);
|
|
93
|
+
const answered = answer !== undefined && answer.trim().length > 0;
|
|
94
|
+
return <View key={`${question.question}-${questionIndex}`} style={{
|
|
95
|
+
gap: 6
|
|
96
|
+
}}><View className="flex-row items-start justify-between" style={{
|
|
97
|
+
gap: 8
|
|
98
|
+
}}><Text className="min-w-0 flex-1 font-instrument-sans-medium" style={[sizeStyle(small), textStyle("foreground", scheme), typeStyle("medium")]}>{question.question}</Text>{question.header ? <TopicBadge>{question.header}</TopicBadge> : null}</View><View style={{
|
|
99
|
+
gap: 2
|
|
100
|
+
}}>{question.options.map((option, optionIndex) => <RecordRow key={`${option.label}-${optionIndex}`} mark={chosen.includes(option.label) ? "check" : LETTERS[optionIndex] ?? String(optionIndex + 1)} label={option.label} description={option.description} selected={chosen.includes(option.label)} />)}{freeText ? <RecordRow mark="other" label="Other" description={freeText} selected={true} /> : null}</View>{answered ? null : <Text className="font-instrument-sans" style={[sizeStyle(caption), textStyle("muted", scheme)]}>Answered in the next message</Text>}</View>;
|
|
101
|
+
})}</View>;
|
|
102
|
+
$[0] = answers;
|
|
103
|
+
$[1] = largerText;
|
|
104
|
+
$[2] = questions;
|
|
105
|
+
$[3] = scheme;
|
|
106
|
+
$[4] = t1;
|
|
107
|
+
} else {
|
|
108
|
+
t1 = $[4];
|
|
109
|
+
}
|
|
110
|
+
return t1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* One option as recorded (web `OptionRow`): a 20 rounded mark (the letter, a
|
|
115
|
+
* check when picked, a pencil for "Other"), the label and its description.
|
|
116
|
+
* Picked: the row on the tertiary fill, the mark on primary, the label medium.
|
|
117
|
+
*/
|
|
118
|
+
function RecordRow(t0) {
|
|
119
|
+
const $ = _c(56);
|
|
120
|
+
const {
|
|
121
|
+
mark,
|
|
122
|
+
label,
|
|
123
|
+
description,
|
|
124
|
+
selected
|
|
125
|
+
} = t0;
|
|
126
|
+
const scheme = useScheme();
|
|
127
|
+
const largerText = useLargerText();
|
|
128
|
+
let T0;
|
|
129
|
+
let T1;
|
|
130
|
+
let t1;
|
|
131
|
+
let t2;
|
|
132
|
+
let t3;
|
|
133
|
+
let t4;
|
|
134
|
+
let t5;
|
|
135
|
+
let t6;
|
|
136
|
+
let t7;
|
|
137
|
+
let t8;
|
|
138
|
+
if ($[0] !== description || $[1] !== label || $[2] !== largerText || $[3] !== mark || $[4] !== scheme || $[5] !== selected) {
|
|
139
|
+
const caption = chatTextSize("caption", largerText);
|
|
140
|
+
const small = chatTextSize("small", largerText);
|
|
141
|
+
const markSize = largerText ? 26 : 20;
|
|
142
|
+
const markColor = selected ? palette.primaryForeground[scheme] : tokens.color.muted[scheme];
|
|
143
|
+
const glyph = largerText ? 15 : 12;
|
|
144
|
+
T1 = View;
|
|
145
|
+
t4 = selected ? `${label}, chosen` : label;
|
|
146
|
+
t5 = description || undefined;
|
|
147
|
+
t6 = "flex-row items-start";
|
|
148
|
+
const t9 = selected ? palette.surfaceTertiary[scheme] : "transparent";
|
|
149
|
+
if ($[16] !== t9) {
|
|
150
|
+
t7 = {
|
|
151
|
+
gap: 8,
|
|
152
|
+
borderRadius: tokens.radius.md,
|
|
153
|
+
paddingHorizontal: 8,
|
|
154
|
+
paddingVertical: 6,
|
|
155
|
+
backgroundColor: t9
|
|
156
|
+
};
|
|
157
|
+
$[16] = t9;
|
|
158
|
+
$[17] = t7;
|
|
159
|
+
} else {
|
|
160
|
+
t7 = $[17];
|
|
161
|
+
}
|
|
162
|
+
const t10 = selected ? palette.primary[scheme] : palette.default[scheme];
|
|
163
|
+
let t11;
|
|
164
|
+
if ($[18] !== markSize || $[19] !== t10) {
|
|
165
|
+
t11 = {
|
|
166
|
+
width: markSize,
|
|
167
|
+
height: markSize,
|
|
168
|
+
marginTop: 2,
|
|
169
|
+
borderRadius: 6,
|
|
170
|
+
alignItems: "center",
|
|
171
|
+
justifyContent: "center",
|
|
172
|
+
backgroundColor: t10
|
|
173
|
+
};
|
|
174
|
+
$[18] = markSize;
|
|
175
|
+
$[19] = t10;
|
|
176
|
+
$[20] = t11;
|
|
177
|
+
} else {
|
|
178
|
+
t11 = $[20];
|
|
179
|
+
}
|
|
180
|
+
let t12;
|
|
181
|
+
if ($[21] !== glyph || $[22] !== largerText || $[23] !== mark || $[24] !== markColor) {
|
|
182
|
+
t12 = mark === "check" ? <IconCheck size={glyph} strokeWidth={3} color={markColor} /> : mark === "other" ? <IconPencil size={glyph} strokeWidth={3} color={markColor} /> : <Text className="font-instrument-sans-semibold" style={[{
|
|
183
|
+
fontSize: largerText ? 13 : 10,
|
|
184
|
+
color: markColor
|
|
185
|
+
}, typeStyle("semibold")]}>{mark}</Text>;
|
|
186
|
+
$[21] = glyph;
|
|
187
|
+
$[22] = largerText;
|
|
188
|
+
$[23] = mark;
|
|
189
|
+
$[24] = markColor;
|
|
190
|
+
$[25] = t12;
|
|
191
|
+
} else {
|
|
192
|
+
t12 = $[25];
|
|
193
|
+
}
|
|
194
|
+
if ($[26] !== t11 || $[27] !== t12) {
|
|
195
|
+
t8 = <View style={t11}>{t12}</View>;
|
|
196
|
+
$[26] = t11;
|
|
197
|
+
$[27] = t12;
|
|
198
|
+
$[28] = t8;
|
|
199
|
+
} else {
|
|
200
|
+
t8 = $[28];
|
|
201
|
+
}
|
|
202
|
+
T0 = View;
|
|
203
|
+
t1 = "min-w-0 flex-1";
|
|
204
|
+
const T2 = Text;
|
|
205
|
+
const t13 = selected ? "font-instrument-sans-medium" : "font-instrument-sans";
|
|
206
|
+
const t14 = sizeStyle(small, "snug");
|
|
207
|
+
const t15 = selected ? "foreground" : "muted";
|
|
208
|
+
let t16;
|
|
209
|
+
if ($[29] !== scheme || $[30] !== t15) {
|
|
210
|
+
t16 = textStyle(t15, scheme);
|
|
211
|
+
$[29] = scheme;
|
|
212
|
+
$[30] = t15;
|
|
213
|
+
$[31] = t16;
|
|
214
|
+
} else {
|
|
215
|
+
t16 = $[31];
|
|
216
|
+
}
|
|
217
|
+
let t17;
|
|
218
|
+
if ($[32] !== selected) {
|
|
219
|
+
t17 = selected ? typeStyle("medium") : null;
|
|
220
|
+
$[32] = selected;
|
|
221
|
+
$[33] = t17;
|
|
222
|
+
} else {
|
|
223
|
+
t17 = $[33];
|
|
224
|
+
}
|
|
225
|
+
let t18;
|
|
226
|
+
if ($[34] !== t14 || $[35] !== t16 || $[36] !== t17) {
|
|
227
|
+
t18 = [t14, t16, t17];
|
|
228
|
+
$[34] = t14;
|
|
229
|
+
$[35] = t16;
|
|
230
|
+
$[36] = t17;
|
|
231
|
+
$[37] = t18;
|
|
232
|
+
} else {
|
|
233
|
+
t18 = $[37];
|
|
234
|
+
}
|
|
235
|
+
if ($[38] !== T2 || $[39] !== label || $[40] !== t13 || $[41] !== t18) {
|
|
236
|
+
t2 = <T2 className={t13} style={t18}>{label}</T2>;
|
|
237
|
+
$[38] = T2;
|
|
238
|
+
$[39] = label;
|
|
239
|
+
$[40] = t13;
|
|
240
|
+
$[41] = t18;
|
|
241
|
+
$[42] = t2;
|
|
242
|
+
} else {
|
|
243
|
+
t2 = $[42];
|
|
244
|
+
}
|
|
245
|
+
t3 = description ? <Text className="font-instrument-sans" style={[sizeStyle(caption), textStyle("muted", scheme), {
|
|
246
|
+
marginTop: 2
|
|
247
|
+
}]}>{description}</Text> : null;
|
|
248
|
+
$[0] = description;
|
|
249
|
+
$[1] = label;
|
|
250
|
+
$[2] = largerText;
|
|
251
|
+
$[3] = mark;
|
|
252
|
+
$[4] = scheme;
|
|
253
|
+
$[5] = selected;
|
|
254
|
+
$[6] = T0;
|
|
255
|
+
$[7] = T1;
|
|
256
|
+
$[8] = t1;
|
|
257
|
+
$[9] = t2;
|
|
258
|
+
$[10] = t3;
|
|
259
|
+
$[11] = t4;
|
|
260
|
+
$[12] = t5;
|
|
261
|
+
$[13] = t6;
|
|
262
|
+
$[14] = t7;
|
|
263
|
+
$[15] = t8;
|
|
264
|
+
} else {
|
|
265
|
+
T0 = $[6];
|
|
266
|
+
T1 = $[7];
|
|
267
|
+
t1 = $[8];
|
|
268
|
+
t2 = $[9];
|
|
269
|
+
t3 = $[10];
|
|
270
|
+
t4 = $[11];
|
|
271
|
+
t5 = $[12];
|
|
272
|
+
t6 = $[13];
|
|
273
|
+
t7 = $[14];
|
|
274
|
+
t8 = $[15];
|
|
275
|
+
}
|
|
276
|
+
let t9;
|
|
277
|
+
if ($[43] !== T0 || $[44] !== t1 || $[45] !== t2 || $[46] !== t3) {
|
|
278
|
+
t9 = <T0 className={t1}>{t2}{t3}</T0>;
|
|
279
|
+
$[43] = T0;
|
|
280
|
+
$[44] = t1;
|
|
281
|
+
$[45] = t2;
|
|
282
|
+
$[46] = t3;
|
|
283
|
+
$[47] = t9;
|
|
284
|
+
} else {
|
|
285
|
+
t9 = $[47];
|
|
286
|
+
}
|
|
287
|
+
let t10;
|
|
288
|
+
if ($[48] !== T1 || $[49] !== t4 || $[50] !== t5 || $[51] !== t6 || $[52] !== t7 || $[53] !== t8 || $[54] !== t9) {
|
|
289
|
+
t10 = <T1 accessibilityLabel={t4} accessibilityHint={t5} className={t6} style={t7}>{t8}{t9}</T1>;
|
|
290
|
+
$[48] = T1;
|
|
291
|
+
$[49] = t4;
|
|
292
|
+
$[50] = t5;
|
|
293
|
+
$[51] = t6;
|
|
294
|
+
$[52] = t7;
|
|
295
|
+
$[53] = t8;
|
|
296
|
+
$[54] = t9;
|
|
297
|
+
$[55] = t10;
|
|
298
|
+
} else {
|
|
299
|
+
t10 = $[55];
|
|
300
|
+
}
|
|
301
|
+
return t10;
|
|
302
|
+
}
|
|
@@ -515,7 +515,7 @@ export function ChoiceQuestion(t0) {
|
|
|
515
515
|
* `text-3xs font-semibold` (10 / 14, 600) in a `px-2.5 py-0.5` pill. Drawn here
|
|
516
516
|
* because `Badge` sets its own size and weight.
|
|
517
517
|
*/
|
|
518
|
-
function TopicBadge(t0) {
|
|
518
|
+
export function TopicBadge(t0) {
|
|
519
519
|
const $ = _c(15);
|
|
520
520
|
const {
|
|
521
521
|
children
|
package/dist/ai/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export { ChatJumpRail } from "./chat-jump-rail";
|
|
|
33
33
|
export { CodeBlock, CodeBlockCopyButton } from "./code-block";
|
|
34
34
|
export { ResponseText, ChatTextColorContext } from "./response-text";
|
|
35
35
|
export { ChoiceQuestion, choiceAnswers } from "./choice-question";
|
|
36
|
+
export { ActivityQuestionCard, freeTextAnswer, selectedLabels } from "./activity-question";
|
|
36
37
|
export { ActivityStepDetail } from "./activity-step-detail";
|
|
37
38
|
export { UnifiedDiff, DiffStat, UNIFIED_DIFF } from "./unified-diff";
|
|
38
39
|
export { ToolApprovalCard, ToolDraftCard, summarizeArgs, ARGS_MAX_CHARS, changedDraftEdits, DRAFT_ROLE_LABELS } from "./tool-approval-card";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React Native / Expo UI primitives. Floating surfaces, forms, overlays, toasts, settings chrome, tab bar, AI chat parts, the family app marks, a NativeWind preset, the Expo web root and Clerk + Convex auth screens.",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Text, View } from "react-native";
|
|
2
|
+
import { IconCheck, IconMessageQuestion, IconPencil } from "@tabler/icons-react-native";
|
|
3
|
+
import { sizeStyle, textStyle, typeStyle } from "../controlStyles";
|
|
4
|
+
import { palette } from "../palette";
|
|
5
|
+
import { useLargerText } from "../theme";
|
|
6
|
+
import { tokens } from "../tokens";
|
|
7
|
+
import { useScheme } from "../useScheme";
|
|
8
|
+
import type { ActivityQuestion } from "./activity-step-types";
|
|
9
|
+
import { chatTextSize } from "./chat-text";
|
|
10
|
+
import { TopicBadge } from "./choice-question";
|
|
11
|
+
|
|
12
|
+
const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The offered labels the user picked. A whole-answer match wins first, so a
|
|
16
|
+
* single-select label holding ", " is not read as several picks; only a
|
|
17
|
+
* multi-select answer is split on the ", " the dock joins it with.
|
|
18
|
+
*/
|
|
19
|
+
export function selectedLabels(answer: string | undefined, question: ActivityQuestion): string[] {
|
|
20
|
+
if (answer === undefined) return [];
|
|
21
|
+
const offered = new Set(question.options.map((option) => option.label));
|
|
22
|
+
if (offered.has(answer)) return [answer];
|
|
23
|
+
if (!question.multiSelect) return [];
|
|
24
|
+
return answer.split(", ").filter((label) => offered.has(label));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Free text typed into "Other": an answer that matches no offered label. */
|
|
28
|
+
export function freeTextAnswer(answer: string | undefined, chosen: readonly string[]): string | null {
|
|
29
|
+
if (answer === undefined || answer.trim().length === 0) return null;
|
|
30
|
+
return chosen.length > 0 ? null : answer;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type ActivityQuestionCardProps = {
|
|
34
|
+
/** The prompt's questions, as the agent asked them. */
|
|
35
|
+
questions: ActivityQuestion[];
|
|
36
|
+
/** The answers, keyed by question text (`ChoiceQuestion`'s `onSubmit` shape). */
|
|
37
|
+
answers?: Record<string, string>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The read-only record of an AskUserQuestion prompt and the answer given, as
|
|
42
|
+
* the web `ActivityQuestionCard`: "Question(s)" over each question with its
|
|
43
|
+
* topic badge, its lettered options with the picked ones filled and checked,
|
|
44
|
+
* the free "Other" text with a pencil, and "Answered in the next message" when
|
|
45
|
+
* no structured answer was kept. The live prompt is `ChoiceQuestion`; this is
|
|
46
|
+
* what the transcript keeps once it is answered. Nothing here is pressable.
|
|
47
|
+
*/
|
|
48
|
+
export function ActivityQuestionCard({ questions, answers }: ActivityQuestionCardProps) {
|
|
49
|
+
const scheme = useScheme();
|
|
50
|
+
const largerText = useLargerText();
|
|
51
|
+
if (questions.length === 0) return null;
|
|
52
|
+
const caption = chatTextSize("caption", largerText);
|
|
53
|
+
const small = chatTextSize("small", largerText);
|
|
54
|
+
const title = questions.length > 1 ? "Questions" : "Question";
|
|
55
|
+
return (
|
|
56
|
+
<View
|
|
57
|
+
accessibilityLabel={title}
|
|
58
|
+
style={{ borderRadius: tokens.radius.lg, backgroundColor: tokens.color.surface[scheme], padding: 12, gap: 12 }}
|
|
59
|
+
>
|
|
60
|
+
<View className="flex-row items-center" style={{ gap: 6 }}>
|
|
61
|
+
<IconMessageQuestion size={largerText ? 18 : 14} color={tokens.color.muted[scheme]} />
|
|
62
|
+
<Text className="font-instrument-sans-medium" style={[sizeStyle(caption), textStyle("muted", scheme), typeStyle("medium")]}>
|
|
63
|
+
{title}
|
|
64
|
+
</Text>
|
|
65
|
+
</View>
|
|
66
|
+
{questions.map((question, questionIndex) => {
|
|
67
|
+
const answer = answers?.[question.question];
|
|
68
|
+
const chosen = selectedLabels(answer, question);
|
|
69
|
+
const freeText = freeTextAnswer(answer, chosen);
|
|
70
|
+
const answered = answer !== undefined && answer.trim().length > 0;
|
|
71
|
+
return (
|
|
72
|
+
<View key={`${question.question}-${questionIndex}`} style={{ gap: 6 }}>
|
|
73
|
+
<View className="flex-row items-start justify-between" style={{ gap: 8 }}>
|
|
74
|
+
<Text
|
|
75
|
+
className="min-w-0 flex-1 font-instrument-sans-medium"
|
|
76
|
+
style={[sizeStyle(small), textStyle("foreground", scheme), typeStyle("medium")]}
|
|
77
|
+
>
|
|
78
|
+
{question.question}
|
|
79
|
+
</Text>
|
|
80
|
+
{question.header ? <TopicBadge>{question.header}</TopicBadge> : null}
|
|
81
|
+
</View>
|
|
82
|
+
<View style={{ gap: 2 }}>
|
|
83
|
+
{question.options.map((option, optionIndex) => (
|
|
84
|
+
<RecordRow
|
|
85
|
+
key={`${option.label}-${optionIndex}`}
|
|
86
|
+
mark={chosen.includes(option.label) ? "check" : (LETTERS[optionIndex] ?? String(optionIndex + 1))}
|
|
87
|
+
label={option.label}
|
|
88
|
+
description={option.description}
|
|
89
|
+
selected={chosen.includes(option.label)}
|
|
90
|
+
/>
|
|
91
|
+
))}
|
|
92
|
+
{freeText ? <RecordRow mark="other" label="Other" description={freeText} selected /> : null}
|
|
93
|
+
</View>
|
|
94
|
+
{answered ? null : (
|
|
95
|
+
<Text className="font-instrument-sans" style={[sizeStyle(caption), textStyle("muted", scheme)]}>
|
|
96
|
+
Answered in the next message
|
|
97
|
+
</Text>
|
|
98
|
+
)}
|
|
99
|
+
</View>
|
|
100
|
+
);
|
|
101
|
+
})}
|
|
102
|
+
</View>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* One option as recorded (web `OptionRow`): a 20 rounded mark (the letter, a
|
|
108
|
+
* check when picked, a pencil for "Other"), the label and its description.
|
|
109
|
+
* Picked: the row on the tertiary fill, the mark on primary, the label medium.
|
|
110
|
+
*/
|
|
111
|
+
function RecordRow({
|
|
112
|
+
mark,
|
|
113
|
+
label,
|
|
114
|
+
description,
|
|
115
|
+
selected,
|
|
116
|
+
}: {
|
|
117
|
+
mark: string;
|
|
118
|
+
label: string;
|
|
119
|
+
description?: string;
|
|
120
|
+
selected: boolean;
|
|
121
|
+
}) {
|
|
122
|
+
const scheme = useScheme();
|
|
123
|
+
const largerText = useLargerText();
|
|
124
|
+
const caption = chatTextSize("caption", largerText);
|
|
125
|
+
const small = chatTextSize("small", largerText);
|
|
126
|
+
const markSize = largerText ? 26 : 20;
|
|
127
|
+
const markColor = selected ? palette.primaryForeground[scheme] : tokens.color.muted[scheme];
|
|
128
|
+
const glyph = largerText ? 15 : 12;
|
|
129
|
+
return (
|
|
130
|
+
<View
|
|
131
|
+
accessibilityLabel={selected ? `${label}, chosen` : label}
|
|
132
|
+
accessibilityHint={description || undefined}
|
|
133
|
+
className="flex-row items-start"
|
|
134
|
+
style={{
|
|
135
|
+
gap: 8,
|
|
136
|
+
borderRadius: tokens.radius.md,
|
|
137
|
+
paddingHorizontal: 8,
|
|
138
|
+
paddingVertical: 6,
|
|
139
|
+
backgroundColor: selected ? palette.surfaceTertiary[scheme] : "transparent",
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<View
|
|
143
|
+
style={{
|
|
144
|
+
width: markSize,
|
|
145
|
+
height: markSize,
|
|
146
|
+
marginTop: 2,
|
|
147
|
+
// A small rounded square, as the web `rounded-md` mark.
|
|
148
|
+
borderRadius: 6,
|
|
149
|
+
alignItems: "center",
|
|
150
|
+
justifyContent: "center",
|
|
151
|
+
backgroundColor: selected ? palette.primary[scheme] : palette.default[scheme],
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
{mark === "check" ? (
|
|
155
|
+
<IconCheck size={glyph} strokeWidth={3} color={markColor} />
|
|
156
|
+
) : mark === "other" ? (
|
|
157
|
+
<IconPencil size={glyph} strokeWidth={3} color={markColor} />
|
|
158
|
+
) : (
|
|
159
|
+
<Text className="font-instrument-sans-semibold" style={[{ fontSize: largerText ? 13 : 10, color: markColor }, typeStyle("semibold")]}>
|
|
160
|
+
{mark}
|
|
161
|
+
</Text>
|
|
162
|
+
)}
|
|
163
|
+
</View>
|
|
164
|
+
<View className="min-w-0 flex-1">
|
|
165
|
+
<Text
|
|
166
|
+
className={selected ? "font-instrument-sans-medium" : "font-instrument-sans"}
|
|
167
|
+
style={[sizeStyle(small, "snug"), textStyle(selected ? "foreground" : "muted", scheme), selected ? typeStyle("medium") : null]}
|
|
168
|
+
>
|
|
169
|
+
{label}
|
|
170
|
+
</Text>
|
|
171
|
+
{description ? (
|
|
172
|
+
<Text className="font-instrument-sans" style={[sizeStyle(caption), textStyle("muted", scheme), { marginTop: 2 }]}>
|
|
173
|
+
{description}
|
|
174
|
+
</Text>
|
|
175
|
+
) : null}
|
|
176
|
+
</View>
|
|
177
|
+
</View>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
@@ -232,7 +232,7 @@ export function ChoiceQuestion({
|
|
|
232
232
|
* `text-3xs font-semibold` (10 / 14, 600) in a `px-2.5 py-0.5` pill. Drawn here
|
|
233
233
|
* because `Badge` sets its own size and weight.
|
|
234
234
|
*/
|
|
235
|
-
function TopicBadge({ children }: { children: string }) {
|
|
235
|
+
export function TopicBadge({ children }: { children: string }) {
|
|
236
236
|
const scheme = useScheme();
|
|
237
237
|
const largerText = useLargerText();
|
|
238
238
|
const fontSize = largerText ? 14 : 10;
|
package/src/ai/index.ts
CHANGED
|
@@ -181,6 +181,8 @@ export type { CodeBlockProps, CodeBlockCopyButtonProps } from "./code-block";
|
|
|
181
181
|
export { ResponseText, ChatTextColorContext } from "./response-text";
|
|
182
182
|
export type { ResponseTextProps } from "./response-text";
|
|
183
183
|
export { ChoiceQuestion, choiceAnswers } from "./choice-question";
|
|
184
|
+
export { ActivityQuestionCard, freeTextAnswer, selectedLabels } from "./activity-question";
|
|
185
|
+
export type { ActivityQuestionCardProps } from "./activity-question";
|
|
184
186
|
export type { ChoiceQuestionProps, ChoiceQuestionItem } from "./choice-question";
|
|
185
187
|
export { ActivityStepDetail } from "./activity-step-detail";
|
|
186
188
|
export type { ActivityStepDetailProps, ActivityStepDetailStep } from "./activity-step-detail";
|