@vvedantb/native-ui 0.26.0 → 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.
- package/dist/ai/activity-question.jsx +302 -0
- package/dist/ai/choice-question.jsx +1 -1
- package/dist/ai/index.js +1 -0
- package/dist/ai/message-context-menu.jsx +234 -175
- package/package.json +1 -1
- package/src/ai/activity-question.tsx +179 -0
- package/src/ai/choice-question.tsx +1 -1
- package/src/ai/index.ts +2 -0
- package/src/ai/message-context-menu.tsx +39 -15
|
@@ -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";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { Modal, Pressable, StyleSheet, Text, View, useWindowDimensions } from "react-native";
|
|
3
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
3
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
5
|
import { cn } from "../cn";
|
|
6
|
+
import { PANEL_SCALE_FROM, POPOVER_ENTER } from "../motion";
|
|
5
7
|
import { sizeStyle, typeStyle } from "../controlStyles";
|
|
6
8
|
import { palette, withAlpha } from "../palette";
|
|
7
9
|
import { useLargerText } from "../theme";
|
|
@@ -12,17 +14,23 @@ import { chatTextSize } from "./chat-text";
|
|
|
12
14
|
import { MESSAGE_MENU, messageContextMenuLayout } from "./message-menu-layout";
|
|
13
15
|
import { usePressed } from "../usePressed";
|
|
14
16
|
|
|
17
|
+
/** How far the held message lifts as the menu opens: a little, so a tall one stays in its room. */
|
|
18
|
+
const LIFT_SCALE = 1.02;
|
|
19
|
+
|
|
15
20
|
/**
|
|
16
21
|
* The iMessage hold menu for a chat message: the chat fades under a frosted
|
|
17
22
|
* wash of the screen colour, the held message stays in place,
|
|
18
23
|
* lifted, with the quick reactions in a pill above it and the actions in a
|
|
19
24
|
* card below it, label first and icon last. It fades in and out as one (the
|
|
20
|
-
* Modal's own fade; with Reduce Motion on, it appears at once).
|
|
25
|
+
* Modal's own fade; with Reduce Motion on, it appears at once). As it fades
|
|
26
|
+
* in, the pill and the card grow into place from the message's side (0.96 to
|
|
27
|
+
* 1) and the held message lifts a little (to 1.02), in 150 ms; with Reduce
|
|
28
|
+
* Motion they are in place at once. A tap outside, Android back
|
|
21
29
|
* or the VoiceOver escape closes it; an action or a reaction closes it, then
|
|
22
30
|
* runs. `Message` opens it with `menu`.
|
|
23
31
|
*/
|
|
24
32
|
export function MessageContextMenu(t0) {
|
|
25
|
-
const $ = _c(
|
|
33
|
+
const $ = _c(90);
|
|
26
34
|
const {
|
|
27
35
|
open,
|
|
28
36
|
onClose,
|
|
@@ -49,62 +57,85 @@ export function MessageContextMenu(t0) {
|
|
|
49
57
|
t2 = $[1];
|
|
50
58
|
}
|
|
51
59
|
const body = t2;
|
|
60
|
+
const shown = useSharedValue(0);
|
|
61
|
+
const popStyle = useAnimatedStyle(() => ({
|
|
62
|
+
transform: [{
|
|
63
|
+
scale: PANEL_SCALE_FROM + (1 - PANEL_SCALE_FROM) * shown.get()
|
|
64
|
+
}]
|
|
65
|
+
}));
|
|
66
|
+
const liftStyle = useAnimatedStyle(() => ({
|
|
67
|
+
transform: [{
|
|
68
|
+
scale: 1 + (LIFT_SCALE - 1) * shown.get()
|
|
69
|
+
}]
|
|
70
|
+
}));
|
|
71
|
+
let t3;
|
|
72
|
+
if ($[2] !== shown) {
|
|
73
|
+
t3 = () => {
|
|
74
|
+
shown.set(0);
|
|
75
|
+
shown.set(withTiming(1, POPOVER_ENTER));
|
|
76
|
+
};
|
|
77
|
+
$[2] = shown;
|
|
78
|
+
$[3] = t3;
|
|
79
|
+
} else {
|
|
80
|
+
t3 = $[3];
|
|
81
|
+
}
|
|
82
|
+
const appear = t3;
|
|
52
83
|
if (!open || anchor === null) {
|
|
53
84
|
return null;
|
|
54
85
|
}
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
let
|
|
58
|
-
if ($[
|
|
59
|
-
|
|
86
|
+
const t4 = menu.actions.length * rowHeight;
|
|
87
|
+
const t5 = menu.reactions !== undefined;
|
|
88
|
+
let t6;
|
|
89
|
+
if ($[4] !== anchor || $[5] !== insets || $[6] !== t4 || $[7] !== t5 || $[8] !== window) {
|
|
90
|
+
t6 = messageContextMenuLayout({
|
|
60
91
|
anchor,
|
|
61
92
|
window,
|
|
62
93
|
insets,
|
|
63
|
-
menuHeight:
|
|
64
|
-
hasReactions:
|
|
94
|
+
menuHeight: t4,
|
|
95
|
+
hasReactions: t5
|
|
65
96
|
});
|
|
66
|
-
$[
|
|
67
|
-
$[
|
|
68
|
-
$[
|
|
69
|
-
$[5] = t4;
|
|
70
|
-
$[6] = window;
|
|
97
|
+
$[4] = anchor;
|
|
98
|
+
$[5] = insets;
|
|
99
|
+
$[6] = t4;
|
|
71
100
|
$[7] = t5;
|
|
101
|
+
$[8] = window;
|
|
102
|
+
$[9] = t6;
|
|
72
103
|
} else {
|
|
73
|
-
|
|
104
|
+
t6 = $[9];
|
|
74
105
|
}
|
|
75
|
-
const layout =
|
|
76
|
-
let
|
|
77
|
-
if ($[
|
|
78
|
-
|
|
106
|
+
const layout = t6;
|
|
107
|
+
let t7;
|
|
108
|
+
if ($[10] !== onClose) {
|
|
109
|
+
t7 = action => {
|
|
79
110
|
onClose();
|
|
80
111
|
action();
|
|
81
112
|
};
|
|
82
|
-
$[
|
|
83
|
-
$[
|
|
113
|
+
$[10] = onClose;
|
|
114
|
+
$[11] = t7;
|
|
84
115
|
} else {
|
|
85
|
-
|
|
116
|
+
t7 = $[11];
|
|
86
117
|
}
|
|
87
|
-
const run =
|
|
88
|
-
let
|
|
89
|
-
if ($[
|
|
90
|
-
|
|
118
|
+
const run = t7;
|
|
119
|
+
let t8;
|
|
120
|
+
if ($[12] !== align || $[13] !== anchor.width || $[14] !== anchor.x || $[15] !== window.width) {
|
|
121
|
+
t8 = width => align === "end" ? {
|
|
91
122
|
left: Math.max(MESSAGE_MENU.edge, Math.min(anchor.x + anchor.width, window.width - MESSAGE_MENU.edge) - width)
|
|
92
123
|
} : {
|
|
93
124
|
left: Math.max(MESSAGE_MENU.edge, Math.min(anchor.x, window.width - MESSAGE_MENU.edge - width))
|
|
94
125
|
};
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
$[
|
|
126
|
+
$[12] = align;
|
|
127
|
+
$[13] = anchor.width;
|
|
128
|
+
$[14] = anchor.x;
|
|
129
|
+
$[15] = window.width;
|
|
130
|
+
$[16] = t8;
|
|
100
131
|
} else {
|
|
101
|
-
|
|
132
|
+
t8 = $[16];
|
|
102
133
|
}
|
|
103
|
-
const side =
|
|
134
|
+
const side = t8;
|
|
104
135
|
const surface = tokens.color.surface[scheme];
|
|
105
|
-
let
|
|
106
|
-
if ($[
|
|
107
|
-
|
|
136
|
+
let t9;
|
|
137
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
138
|
+
t9 = {
|
|
108
139
|
shadowColor: "#000",
|
|
109
140
|
shadowOpacity: 0.18,
|
|
110
141
|
shadowRadius: 16,
|
|
@@ -114,95 +145,108 @@ export function MessageContextMenu(t0) {
|
|
|
114
145
|
},
|
|
115
146
|
elevation: 8
|
|
116
147
|
};
|
|
117
|
-
$[
|
|
148
|
+
$[17] = t9;
|
|
118
149
|
} else {
|
|
119
|
-
|
|
150
|
+
t9 = $[17];
|
|
120
151
|
}
|
|
121
|
-
const shadow =
|
|
152
|
+
const shadow = t9;
|
|
122
153
|
const pillWidth = Math.min(window.width - 2 * MESSAGE_MENU.edge, (menu.reactions?.items.length ?? 0) * 48 + 16);
|
|
123
|
-
const
|
|
124
|
-
let
|
|
125
|
-
if ($[
|
|
126
|
-
|
|
154
|
+
const t10 = reduceMotion ? "none" : "fade";
|
|
155
|
+
let t11;
|
|
156
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
157
|
+
t11 = {
|
|
127
158
|
flex: 1
|
|
128
159
|
};
|
|
129
|
-
$[
|
|
160
|
+
$[18] = t11;
|
|
130
161
|
} else {
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
const t11 = `${testID}-backdrop`;
|
|
134
|
-
const t12 = tokens.color.background[scheme];
|
|
135
|
-
let t13;
|
|
136
|
-
if ($[17] !== t12) {
|
|
137
|
-
t13 = withAlpha(t12, 0.85);
|
|
138
|
-
$[17] = t12;
|
|
139
|
-
$[18] = t13;
|
|
140
|
-
} else {
|
|
141
|
-
t13 = $[18];
|
|
162
|
+
t11 = $[18];
|
|
142
163
|
}
|
|
164
|
+
const t12 = `${testID}-backdrop`;
|
|
165
|
+
const t13 = tokens.color.background[scheme];
|
|
143
166
|
let t14;
|
|
144
167
|
if ($[19] !== t13) {
|
|
145
|
-
t14 =
|
|
146
|
-
backgroundColor: t13
|
|
147
|
-
}];
|
|
168
|
+
t14 = withAlpha(t13, 0.85);
|
|
148
169
|
$[19] = t13;
|
|
149
170
|
$[20] = t14;
|
|
150
171
|
} else {
|
|
151
172
|
t14 = $[20];
|
|
152
173
|
}
|
|
153
174
|
let t15;
|
|
154
|
-
if ($[21] !==
|
|
155
|
-
t15 =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
175
|
+
if ($[21] !== t14) {
|
|
176
|
+
t15 = [StyleSheet.absoluteFill, {
|
|
177
|
+
backgroundColor: t14
|
|
178
|
+
}];
|
|
179
|
+
$[21] = t14;
|
|
180
|
+
$[22] = t15;
|
|
160
181
|
} else {
|
|
161
|
-
t15 = $[
|
|
182
|
+
t15 = $[22];
|
|
162
183
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
184
|
+
let t16;
|
|
185
|
+
if ($[23] !== onClose || $[24] !== t12 || $[25] !== t15) {
|
|
186
|
+
t16 = <View style={StyleSheet.absoluteFill}><Pressable testID={t12} accessibilityRole="button" accessibilityLabel="Close menu" onPress={onClose} style={t15} /></View>;
|
|
187
|
+
$[23] = onClose;
|
|
188
|
+
$[24] = t12;
|
|
189
|
+
$[25] = t15;
|
|
190
|
+
$[26] = t16;
|
|
191
|
+
} else {
|
|
192
|
+
t16 = $[26];
|
|
193
|
+
}
|
|
194
|
+
const t17 = tokens.color.background[scheme];
|
|
195
|
+
let t18;
|
|
196
|
+
if ($[27] !== anchor.width || $[28] !== anchor.x || $[29] !== layout.previewHeight || $[30] !== layout.previewTop || $[31] !== t17) {
|
|
197
|
+
t18 = {
|
|
167
198
|
position: "absolute",
|
|
168
199
|
top: layout.previewTop,
|
|
169
200
|
left: anchor.x,
|
|
170
201
|
width: anchor.width,
|
|
171
202
|
height: layout.previewHeight,
|
|
172
203
|
overflow: "hidden",
|
|
173
|
-
backgroundColor:
|
|
204
|
+
backgroundColor: t17,
|
|
174
205
|
borderRadius: tokens.radius.card,
|
|
175
206
|
...shadow
|
|
176
207
|
};
|
|
177
|
-
$[
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
208
|
+
$[27] = anchor.width;
|
|
209
|
+
$[28] = anchor.x;
|
|
210
|
+
$[29] = layout.previewHeight;
|
|
211
|
+
$[30] = layout.previewTop;
|
|
212
|
+
$[31] = t17;
|
|
213
|
+
$[32] = t18;
|
|
183
214
|
} else {
|
|
184
|
-
|
|
215
|
+
t18 = $[32];
|
|
185
216
|
}
|
|
186
|
-
let
|
|
187
|
-
if ($[
|
|
188
|
-
|
|
189
|
-
$[
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
217
|
+
let t19;
|
|
218
|
+
if ($[33] !== liftStyle || $[34] !== t18) {
|
|
219
|
+
t19 = [t18, liftStyle];
|
|
220
|
+
$[33] = liftStyle;
|
|
221
|
+
$[34] = t18;
|
|
222
|
+
$[35] = t19;
|
|
192
223
|
} else {
|
|
193
|
-
|
|
224
|
+
t19 = $[35];
|
|
194
225
|
}
|
|
195
|
-
let
|
|
196
|
-
if ($[
|
|
197
|
-
|
|
226
|
+
let t20;
|
|
227
|
+
if ($[36] !== preview || $[37] !== t19) {
|
|
228
|
+
t20 = <Animated.View pointerEvents="none" style={t19}>{preview}</Animated.View>;
|
|
229
|
+
$[36] = preview;
|
|
230
|
+
$[37] = t19;
|
|
231
|
+
$[38] = t20;
|
|
232
|
+
} else {
|
|
233
|
+
t20 = $[38];
|
|
234
|
+
}
|
|
235
|
+
let t21;
|
|
236
|
+
if ($[39] !== align || $[40] !== layout.pillTop || $[41] !== menu.reactions || $[42] !== pillWidth || $[43] !== popStyle || $[44] !== run || $[45] !== scheme || $[46] !== side || $[47] !== surface || $[48] !== testID) {
|
|
237
|
+
t21 = menu.reactions ? <Animated.View accessibilityRole="toolbar" style={[{
|
|
198
238
|
position: "absolute",
|
|
199
239
|
top: layout.pillTop,
|
|
200
240
|
...side(pillWidth),
|
|
201
241
|
height: MESSAGE_MENU.pillHeight,
|
|
202
242
|
borderRadius: MESSAGE_MENU.pillHeight / 2,
|
|
203
243
|
backgroundColor: surface,
|
|
244
|
+
flexDirection: "row",
|
|
245
|
+
alignItems: "center",
|
|
246
|
+
paddingHorizontal: 8,
|
|
247
|
+
transformOrigin: align === "end" ? "right bottom" : "left bottom",
|
|
204
248
|
...shadow
|
|
205
|
-
}}
|
|
249
|
+
}, popStyle]}>{menu.reactions.items.map(item => {
|
|
206
250
|
const selected = item.selected === true;
|
|
207
251
|
return <Pressable key={item.key} testID={`${testID}-reaction-${item.key}`} accessibilityRole="button" accessibilityLabel={item.label} accessibilityState={{
|
|
208
252
|
selected
|
|
@@ -210,109 +254,124 @@ export function MessageContextMenu(t0) {
|
|
|
210
254
|
marginHorizontal: 2,
|
|
211
255
|
backgroundColor: selected ? withAlpha(palette.primary[scheme], 0.12) : "transparent"
|
|
212
256
|
}}>{item.render(selected)}</Pressable>;
|
|
213
|
-
})}</View> : null;
|
|
214
|
-
$[
|
|
215
|
-
$[
|
|
216
|
-
$[
|
|
217
|
-
$[
|
|
218
|
-
$[
|
|
219
|
-
$[
|
|
220
|
-
$[
|
|
221
|
-
$[
|
|
222
|
-
$[
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
const t20 = layout.menuTop;
|
|
227
|
-
let t21;
|
|
228
|
-
if ($[43] !== side) {
|
|
229
|
-
t21 = side(MESSAGE_MENU.menuWidth);
|
|
230
|
-
$[43] = side;
|
|
231
|
-
$[44] = t21;
|
|
257
|
+
})}</Animated.View> : null;
|
|
258
|
+
$[39] = align;
|
|
259
|
+
$[40] = layout.pillTop;
|
|
260
|
+
$[41] = menu.reactions;
|
|
261
|
+
$[42] = pillWidth;
|
|
262
|
+
$[43] = popStyle;
|
|
263
|
+
$[44] = run;
|
|
264
|
+
$[45] = scheme;
|
|
265
|
+
$[46] = side;
|
|
266
|
+
$[47] = surface;
|
|
267
|
+
$[48] = testID;
|
|
268
|
+
$[49] = t21;
|
|
232
269
|
} else {
|
|
233
|
-
t21 = $[
|
|
270
|
+
t21 = $[49];
|
|
234
271
|
}
|
|
235
|
-
const t22 =
|
|
272
|
+
const t22 = layout.menuTop;
|
|
236
273
|
let t23;
|
|
237
|
-
if ($[
|
|
238
|
-
t23 =
|
|
274
|
+
if ($[50] !== side) {
|
|
275
|
+
t23 = side(MESSAGE_MENU.menuWidth);
|
|
276
|
+
$[50] = side;
|
|
277
|
+
$[51] = t23;
|
|
278
|
+
} else {
|
|
279
|
+
t23 = $[51];
|
|
280
|
+
}
|
|
281
|
+
const t24 = window.width - 2 * MESSAGE_MENU.edge;
|
|
282
|
+
const t25 = align === "end" ? "right top" : "left top";
|
|
283
|
+
let t26;
|
|
284
|
+
if ($[52] !== layout.menuTop || $[53] !== surface || $[54] !== t23 || $[55] !== t24 || $[56] !== t25) {
|
|
285
|
+
t26 = {
|
|
239
286
|
position: "absolute",
|
|
240
|
-
top:
|
|
241
|
-
...
|
|
287
|
+
top: t22,
|
|
288
|
+
...t23,
|
|
242
289
|
width: MESSAGE_MENU.menuWidth,
|
|
243
|
-
maxWidth:
|
|
290
|
+
maxWidth: t24,
|
|
244
291
|
borderRadius: tokens.radius.card,
|
|
245
292
|
backgroundColor: surface,
|
|
246
293
|
overflow: "hidden",
|
|
294
|
+
transformOrigin: t25,
|
|
247
295
|
...shadow
|
|
248
296
|
};
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
251
|
-
$[
|
|
252
|
-
$[
|
|
253
|
-
$[
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
297
|
+
$[52] = layout.menuTop;
|
|
298
|
+
$[53] = surface;
|
|
299
|
+
$[54] = t23;
|
|
300
|
+
$[55] = t24;
|
|
301
|
+
$[56] = t25;
|
|
302
|
+
$[57] = t26;
|
|
303
|
+
} else {
|
|
304
|
+
t26 = $[57];
|
|
305
|
+
}
|
|
306
|
+
let t27;
|
|
307
|
+
if ($[58] !== popStyle || $[59] !== t26) {
|
|
308
|
+
t27 = [t26, popStyle];
|
|
309
|
+
$[58] = popStyle;
|
|
310
|
+
$[59] = t26;
|
|
311
|
+
$[60] = t27;
|
|
312
|
+
} else {
|
|
313
|
+
t27 = $[60];
|
|
314
|
+
}
|
|
315
|
+
let t28;
|
|
316
|
+
if ($[61] !== body || $[62] !== largerText || $[63] !== menu.actions || $[64] !== rowHeight || $[65] !== run || $[66] !== testID) {
|
|
317
|
+
let t29;
|
|
318
|
+
if ($[68] !== body || $[69] !== largerText || $[70] !== rowHeight || $[71] !== run || $[72] !== testID) {
|
|
319
|
+
t29 = (action_0, index) => <MenuCardRow key={action_0.key} testID={`${testID}-action-${action_0.key}`} action={action_0} first={index === 0} rowHeight={rowHeight} body={body} iconSize={largerText ? 22 : 20} onPress={() => run(action_0.onPress)} />;
|
|
320
|
+
$[68] = body;
|
|
321
|
+
$[69] = largerText;
|
|
322
|
+
$[70] = rowHeight;
|
|
323
|
+
$[71] = run;
|
|
324
|
+
$[72] = testID;
|
|
325
|
+
$[73] = t29;
|
|
268
326
|
} else {
|
|
269
|
-
|
|
327
|
+
t29 = $[73];
|
|
270
328
|
}
|
|
271
|
-
|
|
272
|
-
$[
|
|
273
|
-
$[
|
|
274
|
-
$[
|
|
275
|
-
$[
|
|
276
|
-
$[
|
|
277
|
-
$[
|
|
278
|
-
$[
|
|
279
|
-
} else {
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
let t25;
|
|
283
|
-
if ($[63] !== t23 || $[64] !== t24) {
|
|
284
|
-
t25 = <View accessibilityRole="menu" style={t23}>{t24}</View>;
|
|
285
|
-
$[63] = t23;
|
|
286
|
-
$[64] = t24;
|
|
287
|
-
$[65] = t25;
|
|
288
|
-
} else {
|
|
289
|
-
t25 = $[65];
|
|
329
|
+
t28 = menu.actions.map(t29);
|
|
330
|
+
$[61] = body;
|
|
331
|
+
$[62] = largerText;
|
|
332
|
+
$[63] = menu.actions;
|
|
333
|
+
$[64] = rowHeight;
|
|
334
|
+
$[65] = run;
|
|
335
|
+
$[66] = testID;
|
|
336
|
+
$[67] = t28;
|
|
337
|
+
} else {
|
|
338
|
+
t28 = $[67];
|
|
290
339
|
}
|
|
291
|
-
let
|
|
292
|
-
if ($[
|
|
293
|
-
|
|
294
|
-
$[
|
|
295
|
-
$[
|
|
296
|
-
$[
|
|
297
|
-
|
|
298
|
-
$[
|
|
299
|
-
$[71] = testID;
|
|
300
|
-
$[72] = t26;
|
|
301
|
-
} else {
|
|
302
|
-
t26 = $[72];
|
|
340
|
+
let t29;
|
|
341
|
+
if ($[74] !== t27 || $[75] !== t28) {
|
|
342
|
+
t29 = <Animated.View accessibilityRole="menu" style={t27}>{t28}</Animated.View>;
|
|
343
|
+
$[74] = t27;
|
|
344
|
+
$[75] = t28;
|
|
345
|
+
$[76] = t29;
|
|
346
|
+
} else {
|
|
347
|
+
t29 = $[76];
|
|
303
348
|
}
|
|
304
|
-
let
|
|
305
|
-
if ($[
|
|
306
|
-
|
|
307
|
-
$[
|
|
308
|
-
$[
|
|
309
|
-
$[
|
|
310
|
-
$[
|
|
311
|
-
$[
|
|
349
|
+
let t30;
|
|
350
|
+
if ($[77] !== appear || $[78] !== onClose || $[79] !== t16 || $[80] !== t20 || $[81] !== t21 || $[82] !== t29 || $[83] !== testID) {
|
|
351
|
+
t30 = <View style={t11} testID={testID} accessibilityViewIsModal={true} onAccessibilityEscape={onClose} onLayout={appear}>{t16}{t20}{t21}{t29}</View>;
|
|
352
|
+
$[77] = appear;
|
|
353
|
+
$[78] = onClose;
|
|
354
|
+
$[79] = t16;
|
|
355
|
+
$[80] = t20;
|
|
356
|
+
$[81] = t21;
|
|
357
|
+
$[82] = t29;
|
|
358
|
+
$[83] = testID;
|
|
359
|
+
$[84] = t30;
|
|
360
|
+
} else {
|
|
361
|
+
t30 = $[84];
|
|
362
|
+
}
|
|
363
|
+
let t31;
|
|
364
|
+
if ($[85] !== onClose || $[86] !== onDismissed || $[87] !== t10 || $[88] !== t30) {
|
|
365
|
+
t31 = <Modal visible={true} transparent={true} animationType={t10} statusBarTranslucent={true} onRequestClose={onClose} onDismiss={onDismissed}>{t30}</Modal>;
|
|
366
|
+
$[85] = onClose;
|
|
367
|
+
$[86] = onDismissed;
|
|
368
|
+
$[87] = t10;
|
|
369
|
+
$[88] = t30;
|
|
370
|
+
$[89] = t31;
|
|
312
371
|
} else {
|
|
313
|
-
|
|
372
|
+
t31 = $[89];
|
|
314
373
|
}
|
|
315
|
-
return
|
|
374
|
+
return t31;
|
|
316
375
|
}
|
|
317
376
|
|
|
318
377
|
/**
|
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";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { Modal, Pressable, StyleSheet, Text, View, useWindowDimensions } from "react-native";
|
|
3
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
3
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
5
|
import { cn } from "../cn";
|
|
6
|
+
import { PANEL_SCALE_FROM, POPOVER_ENTER } from "../motion";
|
|
5
7
|
import { sizeStyle, typeStyle } from "../controlStyles";
|
|
6
8
|
import { palette, withAlpha } from "../palette";
|
|
7
9
|
import { useLargerText } from "../theme";
|
|
@@ -12,12 +14,18 @@ import { chatTextSize } from "./chat-text";
|
|
|
12
14
|
import { MESSAGE_MENU, messageContextMenuLayout, type MessageMenu, type MessageMenuRect } from "./message-menu-layout";
|
|
13
15
|
import { usePressed } from "../usePressed";
|
|
14
16
|
|
|
17
|
+
/** How far the held message lifts as the menu opens: a little, so a tall one stays in its room. */
|
|
18
|
+
const LIFT_SCALE = 1.02;
|
|
19
|
+
|
|
15
20
|
/**
|
|
16
21
|
* The iMessage hold menu for a chat message: the chat fades under a frosted
|
|
17
22
|
* wash of the screen colour, the held message stays in place,
|
|
18
23
|
* lifted, with the quick reactions in a pill above it and the actions in a
|
|
19
24
|
* card below it, label first and icon last. It fades in and out as one (the
|
|
20
|
-
* Modal's own fade; with Reduce Motion on, it appears at once).
|
|
25
|
+
* Modal's own fade; with Reduce Motion on, it appears at once). As it fades
|
|
26
|
+
* in, the pill and the card grow into place from the message's side (0.96 to
|
|
27
|
+
* 1) and the held message lifts a little (to 1.02), in 150 ms; with Reduce
|
|
28
|
+
* Motion they are in place at once. A tap outside, Android back
|
|
21
29
|
* or the VoiceOver escape closes it; an action or a reaction closes it, then
|
|
22
30
|
* runs. `Message` opens it with `menu`.
|
|
23
31
|
*/
|
|
@@ -51,6 +59,16 @@ export function MessageContextMenu({
|
|
|
51
59
|
const reduceMotion = useReduceMotion();
|
|
52
60
|
const rowHeight = largerText ? 56 : 48;
|
|
53
61
|
const body = chatTextSize("body", largerText);
|
|
62
|
+
// 0 to 1 as the menu opens. Started from the menu's first layout: Reanimated's
|
|
63
|
+
// entering animations do not run inside a Modal on Android, a shared value does.
|
|
64
|
+
const shown = useSharedValue(0);
|
|
65
|
+
const popStyle = useAnimatedStyle(() => ({ transform: [{ scale: PANEL_SCALE_FROM + (1 - PANEL_SCALE_FROM) * shown.get() }] }));
|
|
66
|
+
const liftStyle = useAnimatedStyle(() => ({ transform: [{ scale: 1 + (LIFT_SCALE - 1) * shown.get() }] }));
|
|
67
|
+
// `POPOVER_ENTER` reduces with the system setting: with Reduce Motion the menu is in place at once.
|
|
68
|
+
const appear = () => {
|
|
69
|
+
shown.set(0);
|
|
70
|
+
shown.set(withTiming(1, POPOVER_ENTER));
|
|
71
|
+
};
|
|
54
72
|
if (!open || anchor === null) return null;
|
|
55
73
|
|
|
56
74
|
const layout = messageContextMenuLayout({
|
|
@@ -76,7 +94,7 @@ export function MessageContextMenu({
|
|
|
76
94
|
return (
|
|
77
95
|
// The Modal's own fade: Reanimated entering animations do not run inside a Modal on Android.
|
|
78
96
|
<Modal visible transparent animationType={reduceMotion ? "none" : "fade"} statusBarTranslucent onRequestClose={onClose} onDismiss={onDismissed}>
|
|
79
|
-
<View style={{ flex: 1 }} testID={testID} accessibilityViewIsModal onAccessibilityEscape={onClose}>
|
|
97
|
+
<View style={{ flex: 1 }} testID={testID} accessibilityViewIsModal onAccessibilityEscape={onClose} onLayout={appear}>
|
|
80
98
|
<View style={StyleSheet.absoluteFill}>
|
|
81
99
|
<Pressable
|
|
82
100
|
testID={`${testID}-backdrop`}
|
|
@@ -89,9 +107,9 @@ export function MessageContextMenu({
|
|
|
89
107
|
/>
|
|
90
108
|
</View>
|
|
91
109
|
{/* The held message, lifted: in place, on the screen colour with a shadow, clipped when it is taller than the room. */}
|
|
92
|
-
<View
|
|
110
|
+
<Animated.View
|
|
93
111
|
pointerEvents="none"
|
|
94
|
-
style={{
|
|
112
|
+
style={[{
|
|
95
113
|
position: "absolute",
|
|
96
114
|
top: layout.previewTop,
|
|
97
115
|
left: anchor.x,
|
|
@@ -102,23 +120,28 @@ export function MessageContextMenu({
|
|
|
102
120
|
backgroundColor: tokens.color.background[scheme],
|
|
103
121
|
borderRadius: tokens.radius.card,
|
|
104
122
|
...shadow,
|
|
105
|
-
}}
|
|
123
|
+
}, liftStyle]}
|
|
106
124
|
>
|
|
107
125
|
{preview}
|
|
108
|
-
</View>
|
|
126
|
+
</Animated.View>
|
|
109
127
|
{menu.reactions ? (
|
|
110
|
-
<View
|
|
128
|
+
<Animated.View
|
|
111
129
|
accessibilityRole="toolbar"
|
|
112
|
-
style={{
|
|
130
|
+
style={[{
|
|
113
131
|
position: "absolute",
|
|
114
132
|
top: layout.pillTop,
|
|
115
133
|
...side(pillWidth),
|
|
116
134
|
height: MESSAGE_MENU.pillHeight,
|
|
117
135
|
borderRadius: MESSAGE_MENU.pillHeight / 2,
|
|
118
136
|
backgroundColor: surface,
|
|
137
|
+
// Styles, not classes: this is a Reanimated view.
|
|
138
|
+
flexDirection: "row",
|
|
139
|
+
alignItems: "center",
|
|
140
|
+
paddingHorizontal: 8,
|
|
141
|
+
// Grows from the corner next to the message.
|
|
142
|
+
transformOrigin: align === "end" ? "right bottom" : "left bottom",
|
|
119
143
|
...shadow,
|
|
120
|
-
}}
|
|
121
|
-
className="flex-row items-center px-2"
|
|
144
|
+
}, popStyle]}
|
|
122
145
|
>
|
|
123
146
|
{menu.reactions.items.map((item) => {
|
|
124
147
|
const selected = item.selected === true;
|
|
@@ -137,11 +160,11 @@ export function MessageContextMenu({
|
|
|
137
160
|
</Pressable>
|
|
138
161
|
);
|
|
139
162
|
})}
|
|
140
|
-
</View>
|
|
163
|
+
</Animated.View>
|
|
141
164
|
) : null}
|
|
142
|
-
<View
|
|
165
|
+
<Animated.View
|
|
143
166
|
accessibilityRole="menu"
|
|
144
|
-
style={{
|
|
167
|
+
style={[{
|
|
145
168
|
position: "absolute",
|
|
146
169
|
top: layout.menuTop,
|
|
147
170
|
...side(MESSAGE_MENU.menuWidth),
|
|
@@ -150,8 +173,9 @@ export function MessageContextMenu({
|
|
|
150
173
|
borderRadius: tokens.radius.card,
|
|
151
174
|
backgroundColor: surface,
|
|
152
175
|
overflow: "hidden",
|
|
176
|
+
transformOrigin: align === "end" ? "right top" : "left top",
|
|
153
177
|
...shadow,
|
|
154
|
-
}}
|
|
178
|
+
}, popStyle]}
|
|
155
179
|
>
|
|
156
180
|
{menu.actions.map((action, index) => (
|
|
157
181
|
<MenuCardRow
|
|
@@ -165,7 +189,7 @@ export function MessageContextMenu({
|
|
|
165
189
|
onPress={() => run(action.onPress)}
|
|
166
190
|
/>
|
|
167
191
|
))}
|
|
168
|
-
</View>
|
|
192
|
+
</Animated.View>
|
|
169
193
|
</View>
|
|
170
194
|
</Modal>
|
|
171
195
|
);
|