@vvedantb/native-ui 0.24.2 → 0.25.1

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,164 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Pressable, View } from "react-native";
3
+ import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react-native";
4
+ import { Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle } from "./Sheet";
5
+ import { SheetRow } from "./SheetRow";
6
+ import { tokens } from "./tokens";
7
+ import { useScheme } from "./useScheme";
8
+ /**
9
+ * A dropdown or context menu as one bottom sheet: a title, then `SheetRow`s
10
+ * with no gap between them, `MenuDivider`s between groups. With submenus, the
11
+ * root page lists the items, a `SubmenuRow` swaps the sheet to its page, and
12
+ * that page's header has a back button (`onBack`) to the root.
13
+ */
14
+ export function MenuSheet(t0) {
15
+ const $ = _c(18);
16
+ const {
17
+ open,
18
+ onOpenChange,
19
+ title,
20
+ onBack,
21
+ children,
22
+ testID
23
+ } = t0;
24
+ const muted = tokens.color.muted[useScheme()];
25
+ let t1;
26
+ if ($[0] !== muted || $[1] !== onBack) {
27
+ t1 = onBack ? <Pressable accessibilityRole="button" accessibilityLabel="Back" onPress={onBack} className="-ml-2 h-11 w-11 items-center justify-center rounded-lg active:opacity-70"><IconChevronLeft size={20} color={muted} /></Pressable> : null;
28
+ $[0] = muted;
29
+ $[1] = onBack;
30
+ $[2] = t1;
31
+ } else {
32
+ t1 = $[2];
33
+ }
34
+ let t2;
35
+ if ($[3] !== title) {
36
+ t2 = <SheetTitle numberOfLines={1} className="min-w-0 flex-1">{title}</SheetTitle>;
37
+ $[3] = title;
38
+ $[4] = t2;
39
+ } else {
40
+ t2 = $[4];
41
+ }
42
+ let t3;
43
+ if ($[5] !== t1 || $[6] !== t2) {
44
+ t3 = <SheetHeader className="min-h-11 flex-row items-center gap-1 px-2">{t1}{t2}</SheetHeader>;
45
+ $[5] = t1;
46
+ $[6] = t2;
47
+ $[7] = t3;
48
+ } else {
49
+ t3 = $[7];
50
+ }
51
+ let t4;
52
+ if ($[8] !== children) {
53
+ t4 = <SheetBody>{children}</SheetBody>;
54
+ $[8] = children;
55
+ $[9] = t4;
56
+ } else {
57
+ t4 = $[9];
58
+ }
59
+ let t5;
60
+ if ($[10] !== t3 || $[11] !== t4 || $[12] !== testID) {
61
+ t5 = <SheetContent className="gap-3 px-3" testID={testID}>{t3}{t4}</SheetContent>;
62
+ $[10] = t3;
63
+ $[11] = t4;
64
+ $[12] = testID;
65
+ $[13] = t5;
66
+ } else {
67
+ t5 = $[13];
68
+ }
69
+ let t6;
70
+ if ($[14] !== onOpenChange || $[15] !== open || $[16] !== t5) {
71
+ t6 = <Sheet open={open} onOpenChange={onOpenChange}>{t5}</Sheet>;
72
+ $[14] = onOpenChange;
73
+ $[15] = open;
74
+ $[16] = t5;
75
+ $[17] = t6;
76
+ } else {
77
+ t6 = $[17];
78
+ }
79
+ return t6;
80
+ }
81
+ /** A root-page item that opens a submenu: a `SheetRow` with a chevron at the end. */
82
+ export function SubmenuRow(t0) {
83
+ const $ = _c(18);
84
+ const {
85
+ icon,
86
+ leading,
87
+ title,
88
+ detail,
89
+ disabled,
90
+ onPress,
91
+ testID
92
+ } = t0;
93
+ const muted = tokens.color.muted[useScheme()];
94
+ let t1;
95
+ if ($[0] !== detail || $[1] !== disabled || $[2] !== icon || $[3] !== leading || $[4] !== onPress || $[5] !== testID || $[6] !== title) {
96
+ t1 = <View className="min-w-0 flex-1"><SheetRow icon={icon} leading={leading} title={title} detail={detail} disabled={disabled} onPress={onPress} testID={testID} /></View>;
97
+ $[0] = detail;
98
+ $[1] = disabled;
99
+ $[2] = icon;
100
+ $[3] = leading;
101
+ $[4] = onPress;
102
+ $[5] = testID;
103
+ $[6] = title;
104
+ $[7] = t1;
105
+ } else {
106
+ t1 = $[7];
107
+ }
108
+ const t2 = disabled ? 0.5 : 1;
109
+ let t3;
110
+ if ($[8] !== t2) {
111
+ t3 = {
112
+ pointerEvents: "none",
113
+ opacity: t2
114
+ };
115
+ $[8] = t2;
116
+ $[9] = t3;
117
+ } else {
118
+ t3 = $[9];
119
+ }
120
+ let t4;
121
+ if ($[10] !== muted) {
122
+ t4 = <IconChevronRight size={16} color={muted} />;
123
+ $[10] = muted;
124
+ $[11] = t4;
125
+ } else {
126
+ t4 = $[11];
127
+ }
128
+ let t5;
129
+ if ($[12] !== t3 || $[13] !== t4) {
130
+ t5 = <View className="absolute right-4" style={t3}>{t4}</View>;
131
+ $[12] = t3;
132
+ $[13] = t4;
133
+ $[14] = t5;
134
+ } else {
135
+ t5 = $[14];
136
+ }
137
+ let t6;
138
+ if ($[15] !== t1 || $[16] !== t5) {
139
+ t6 = <View className="flex-row items-center">{t1}{t5}</View>;
140
+ $[15] = t1;
141
+ $[16] = t5;
142
+ $[17] = t6;
143
+ } else {
144
+ t6 = $[17];
145
+ }
146
+ return t6;
147
+ }
148
+
149
+ /** The web `DropdownMenuSeparator` between groups of menu rows. */
150
+ export function MenuDivider() {
151
+ const $ = _c(2);
152
+ const t0 = tokens.color.border[useScheme()];
153
+ let t1;
154
+ if ($[0] !== t0) {
155
+ t1 = <View className="mx-4 my-1 h-px" style={{
156
+ backgroundColor: t0
157
+ }} />;
158
+ $[0] = t0;
159
+ $[1] = t1;
160
+ } else {
161
+ t1 = $[1];
162
+ }
163
+ return t1;
164
+ }
@@ -0,0 +1,84 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Pressable, View } from "react-native";
3
+ import { palette, withAlpha } from "./palette";
4
+ import { useScheme } from "./useScheme";
5
+
6
+ /** One round toggle: its key, its screen-reader label, its content (an emoji `Text` or an icon) and whether it is on. */
7
+
8
+ /**
9
+ * The quick reactions at the top of a hold menu (`MenuSheet`): round 44
10
+ * toggles, each one on or off. Emoji reactions use the tint, a reply's
11
+ * thumbs the solid fill.
12
+ */
13
+ export function ReactionRow(t0) {
14
+ const $ = _c(17);
15
+ const {
16
+ items,
17
+ onPress,
18
+ selectedStyle: t1,
19
+ layout: t2,
20
+ trailing
21
+ } = t0;
22
+ const selectedStyle = t1 === undefined ? "tint" : t1;
23
+ const layout = t2 === undefined ? "spread" : t2;
24
+ const scheme = useScheme();
25
+ let t3;
26
+ if ($[0] !== scheme || $[1] !== selectedStyle) {
27
+ t3 = selected => !selected ? palette.default[scheme] : selectedStyle === "solid" ? palette.primary[scheme] : withAlpha(palette.primary[scheme], 0.12);
28
+ $[0] = scheme;
29
+ $[1] = selectedStyle;
30
+ $[2] = t3;
31
+ } else {
32
+ t3 = $[2];
33
+ }
34
+ const fill = t3;
35
+ const t4 = layout === "spread" ? "flex-row justify-between px-2 pb-2" : "flex-row gap-3 px-4 py-2";
36
+ let t5;
37
+ if ($[3] !== fill || $[4] !== items || $[5] !== onPress) {
38
+ let t6;
39
+ if ($[7] !== fill || $[8] !== onPress) {
40
+ t6 = item => {
41
+ const selected_0 = item.selected === true;
42
+ return <Pressable key={item.key} accessibilityRole="button" accessibilityLabel={item.label} accessibilityState={{
43
+ selected: selected_0
44
+ }} onPress={() => onPress(item.key)} className="size-11 items-center justify-center rounded-full active:opacity-70" style={{
45
+ backgroundColor: fill(selected_0)
46
+ }}>{item.render(selected_0)}</Pressable>;
47
+ };
48
+ $[7] = fill;
49
+ $[8] = onPress;
50
+ $[9] = t6;
51
+ } else {
52
+ t6 = $[9];
53
+ }
54
+ t5 = items.map(t6);
55
+ $[3] = fill;
56
+ $[4] = items;
57
+ $[5] = onPress;
58
+ $[6] = t5;
59
+ } else {
60
+ t5 = $[6];
61
+ }
62
+ let t6;
63
+ if ($[10] !== fill || $[11] !== trailing) {
64
+ t6 = trailing ? <Pressable accessibilityRole="button" accessibilityLabel={trailing.label} onPress={trailing.onPress} className="size-11 items-center justify-center rounded-full active:opacity-70" style={{
65
+ backgroundColor: fill(false)
66
+ }}>{trailing.icon}</Pressable> : null;
67
+ $[10] = fill;
68
+ $[11] = trailing;
69
+ $[12] = t6;
70
+ } else {
71
+ t6 = $[12];
72
+ }
73
+ let t7;
74
+ if ($[13] !== t4 || $[14] !== t5 || $[15] !== t6) {
75
+ t7 = <View className={t4}>{t5}{t6}</View>;
76
+ $[13] = t4;
77
+ $[14] = t5;
78
+ $[15] = t6;
79
+ $[16] = t7;
80
+ } else {
81
+ t7 = $[16];
82
+ }
83
+ return t7;
84
+ }
package/dist/ai/index.js CHANGED
@@ -8,6 +8,8 @@ export { Collapsible, CollapsibleTrigger, CollapsibleContent, CollapsibleChevron
8
8
  export { Conversation, ConversationContent, ConversationList, ConversationEmptyState, ConversationScrollButton, ConversationDock, useConversation, isScrolledToBottom, AT_BOTTOM_THRESHOLD } from "./conversation";
9
9
  export { Message, MessageContent, MessageActionsBar, MessageAction, MessageMeta, MessageBotLabel, MESSAGE_ACTIONS, MESSAGE_HIGHLIGHT_MS, userBubbleStyle, tintBubbleStyle } from "./message";
10
10
  export { MessageActionSheet } from "./message-action-sheet";
11
+ export { MessageContextMenu } from "./message-context-menu";
12
+ export { messageContextMenuLayout, MESSAGE_MENU } from "./message-menu-layout";
11
13
  export { ReplyQuoteChip } from "./reply-quote-chip";
12
14
  export { MessageQuote, QUOTE_MAX_LINES } from "./message-quote";
13
15
  export { Reasoning, ReasoningTrigger, ReasoningContent, useReasoning, reasoningMessage } from "./reasoning";
@@ -0,0 +1,390 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Modal, Pressable, StyleSheet, Text, View, useWindowDimensions } from "react-native";
3
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
4
+ import { cn } from "../cn";
5
+ import { sizeStyle, typeStyle } from "../controlStyles";
6
+ import { palette, withAlpha } from "../palette";
7
+ import { useLargerText } from "../theme";
8
+ import { tokens } from "../tokens";
9
+ import { useReduceMotion } from "../useReduceMotion";
10
+ import { useScheme } from "../useScheme";
11
+ import { chatTextSize } from "./chat-text";
12
+ import { MESSAGE_MENU, messageContextMenuLayout } from "./message-menu-layout";
13
+
14
+ /**
15
+ * The iMessage hold menu for a chat message: the chat fades under a frosted
16
+ * wash of the screen colour, the held message stays in place,
17
+ * lifted, with the quick reactions in a pill above it and the actions in a
18
+ * card below it, label first and icon last. It fades in and out as one (the
19
+ * Modal's own fade; with Reduce Motion on, it appears at once). A tap outside, Android back
20
+ * or the VoiceOver escape closes it; an action or a reaction closes it, then
21
+ * runs. `Message` opens it with `menu`.
22
+ */
23
+ export function MessageContextMenu(t0) {
24
+ const $ = _c(103);
25
+ const {
26
+ open,
27
+ onClose,
28
+ anchor,
29
+ align,
30
+ preview,
31
+ menu,
32
+ testID: t1
33
+ } = t0;
34
+ const testID = t1 === undefined ? "message-context-menu" : t1;
35
+ const scheme = useScheme();
36
+ const window = useWindowDimensions();
37
+ const insets = useSafeAreaInsets();
38
+ const largerText = useLargerText();
39
+ const reduceMotion = useReduceMotion();
40
+ const rowHeight = largerText ? 56 : 48;
41
+ let T0;
42
+ let T1;
43
+ let T2;
44
+ let t10;
45
+ let t11;
46
+ let t12;
47
+ let t13;
48
+ let t14;
49
+ let t15;
50
+ let t16;
51
+ let t17;
52
+ let t2;
53
+ let t3;
54
+ let t4;
55
+ let t5;
56
+ let t6;
57
+ let t7;
58
+ let t8;
59
+ let t9;
60
+ if ($[0] !== align || $[1] !== anchor || $[2] !== insets || $[3] !== largerText || $[4] !== menu || $[5] !== onClose || $[6] !== open || $[7] !== preview || $[8] !== reduceMotion || $[9] !== rowHeight || $[10] !== scheme || $[11] !== testID || $[12] !== window) {
61
+ t17 = Symbol.for("react.early_return_sentinel");
62
+ bb0: {
63
+ const body = chatTextSize("body", largerText);
64
+ if (!open || anchor === null) {
65
+ t17 = null;
66
+ break bb0;
67
+ }
68
+ const t18 = menu.actions.length * rowHeight;
69
+ const t19 = menu.reactions !== undefined;
70
+ let t20;
71
+ if ($[32] !== anchor || $[33] !== insets || $[34] !== t18 || $[35] !== t19 || $[36] !== window) {
72
+ t20 = messageContextMenuLayout({
73
+ anchor,
74
+ window,
75
+ insets,
76
+ menuHeight: t18,
77
+ hasReactions: t19
78
+ });
79
+ $[32] = anchor;
80
+ $[33] = insets;
81
+ $[34] = t18;
82
+ $[35] = t19;
83
+ $[36] = window;
84
+ $[37] = t20;
85
+ } else {
86
+ t20 = $[37];
87
+ }
88
+ const layout = t20;
89
+ let t21;
90
+ if ($[38] !== onClose) {
91
+ t21 = action => {
92
+ onClose();
93
+ action();
94
+ };
95
+ $[38] = onClose;
96
+ $[39] = t21;
97
+ } else {
98
+ t21 = $[39];
99
+ }
100
+ const run = t21;
101
+ let t22;
102
+ if ($[40] !== align || $[41] !== anchor.width || $[42] !== anchor.x || $[43] !== window.width) {
103
+ t22 = width => align === "end" ? {
104
+ left: Math.max(MESSAGE_MENU.edge, Math.min(anchor.x + anchor.width, window.width - MESSAGE_MENU.edge) - width)
105
+ } : {
106
+ left: Math.max(MESSAGE_MENU.edge, Math.min(anchor.x, window.width - MESSAGE_MENU.edge - width))
107
+ };
108
+ $[40] = align;
109
+ $[41] = anchor.width;
110
+ $[42] = anchor.x;
111
+ $[43] = window.width;
112
+ $[44] = t22;
113
+ } else {
114
+ t22 = $[44];
115
+ }
116
+ const side = t22;
117
+ const surface = tokens.color.surface[scheme];
118
+ let t23;
119
+ if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
120
+ t23 = {
121
+ shadowColor: "#000",
122
+ shadowOpacity: 0.18,
123
+ shadowRadius: 16,
124
+ shadowOffset: {
125
+ width: 0,
126
+ height: 6
127
+ },
128
+ elevation: 8
129
+ };
130
+ $[45] = t23;
131
+ } else {
132
+ t23 = $[45];
133
+ }
134
+ const shadow = t23;
135
+ const pillWidth = Math.min(window.width - 2 * MESSAGE_MENU.edge, (menu.reactions?.items.length ?? 0) * 48 + 16);
136
+ T2 = Modal;
137
+ t12 = true;
138
+ t13 = true;
139
+ t14 = reduceMotion ? "none" : "fade";
140
+ t15 = true;
141
+ t16 = onClose;
142
+ T1 = View;
143
+ if ($[46] === Symbol.for("react.memo_cache_sentinel")) {
144
+ t5 = {
145
+ flex: 1
146
+ };
147
+ $[46] = t5;
148
+ } else {
149
+ t5 = $[46];
150
+ }
151
+ t6 = testID;
152
+ t7 = true;
153
+ t8 = onClose;
154
+ const t24 = `${testID}-backdrop`;
155
+ const t25 = tokens.color.background[scheme];
156
+ let t26;
157
+ if ($[47] !== t25) {
158
+ t26 = withAlpha(t25, 0.85);
159
+ $[47] = t25;
160
+ $[48] = t26;
161
+ } else {
162
+ t26 = $[48];
163
+ }
164
+ let t27;
165
+ if ($[49] !== t26) {
166
+ t27 = [StyleSheet.absoluteFill, {
167
+ backgroundColor: t26
168
+ }];
169
+ $[49] = t26;
170
+ $[50] = t27;
171
+ } else {
172
+ t27 = $[50];
173
+ }
174
+ if ($[51] !== onClose || $[52] !== t24 || $[53] !== t27) {
175
+ t9 = <View style={StyleSheet.absoluteFill}><Pressable testID={t24} accessibilityRole="button" accessibilityLabel="Close menu" onPress={onClose} style={t27} /></View>;
176
+ $[51] = onClose;
177
+ $[52] = t24;
178
+ $[53] = t27;
179
+ $[54] = t9;
180
+ } else {
181
+ t9 = $[54];
182
+ }
183
+ const t28 = tokens.color.background[scheme];
184
+ let t29;
185
+ if ($[55] !== anchor.width || $[56] !== anchor.x || $[57] !== layout.previewHeight || $[58] !== layout.previewTop || $[59] !== t28) {
186
+ t29 = {
187
+ position: "absolute",
188
+ top: layout.previewTop,
189
+ left: anchor.x,
190
+ width: anchor.width,
191
+ height: layout.previewHeight,
192
+ overflow: "hidden",
193
+ backgroundColor: t28,
194
+ borderRadius: tokens.radius.card,
195
+ ...shadow
196
+ };
197
+ $[55] = anchor.width;
198
+ $[56] = anchor.x;
199
+ $[57] = layout.previewHeight;
200
+ $[58] = layout.previewTop;
201
+ $[59] = t28;
202
+ $[60] = t29;
203
+ } else {
204
+ t29 = $[60];
205
+ }
206
+ if ($[61] !== preview || $[62] !== t29) {
207
+ t10 = <View pointerEvents="none" style={t29}>{preview}</View>;
208
+ $[61] = preview;
209
+ $[62] = t29;
210
+ $[63] = t10;
211
+ } else {
212
+ t10 = $[63];
213
+ }
214
+ if ($[64] !== layout.pillTop || $[65] !== menu.reactions || $[66] !== pillWidth || $[67] !== run || $[68] !== scheme || $[69] !== side || $[70] !== surface || $[71] !== testID) {
215
+ t11 = menu.reactions ? <View accessibilityRole="toolbar" style={{
216
+ position: "absolute",
217
+ top: layout.pillTop,
218
+ ...side(pillWidth),
219
+ height: MESSAGE_MENU.pillHeight,
220
+ borderRadius: MESSAGE_MENU.pillHeight / 2,
221
+ backgroundColor: surface,
222
+ ...shadow
223
+ }} className="flex-row items-center px-2">{menu.reactions.items.map(item => {
224
+ const selected = item.selected === true;
225
+ return <Pressable key={item.key} testID={`${testID}-reaction-${item.key}`} accessibilityRole="button" accessibilityLabel={item.label} accessibilityState={{
226
+ selected
227
+ }} onPress={() => run(() => menu.reactions?.onPress(item.key))} className="size-11 items-center justify-center rounded-full active:opacity-70" style={{
228
+ marginHorizontal: 2,
229
+ backgroundColor: selected ? withAlpha(palette.primary[scheme], 0.12) : "transparent"
230
+ }}>{item.render(selected)}</Pressable>;
231
+ })}</View> : null;
232
+ $[64] = layout.pillTop;
233
+ $[65] = menu.reactions;
234
+ $[66] = pillWidth;
235
+ $[67] = run;
236
+ $[68] = scheme;
237
+ $[69] = side;
238
+ $[70] = surface;
239
+ $[71] = testID;
240
+ $[72] = t11;
241
+ } else {
242
+ t11 = $[72];
243
+ }
244
+ T0 = View;
245
+ t2 = "menu";
246
+ const t30 = layout.menuTop;
247
+ let t31;
248
+ if ($[73] !== side) {
249
+ t31 = side(MESSAGE_MENU.menuWidth);
250
+ $[73] = side;
251
+ $[74] = t31;
252
+ } else {
253
+ t31 = $[74];
254
+ }
255
+ const t32 = window.width - 2 * MESSAGE_MENU.edge;
256
+ if ($[75] !== layout.menuTop || $[76] !== surface || $[77] !== t31 || $[78] !== t32) {
257
+ t3 = {
258
+ position: "absolute",
259
+ top: t30,
260
+ ...t31,
261
+ width: MESSAGE_MENU.menuWidth,
262
+ maxWidth: t32,
263
+ borderRadius: tokens.radius.card,
264
+ backgroundColor: surface,
265
+ overflow: "hidden",
266
+ ...shadow
267
+ };
268
+ $[75] = layout.menuTop;
269
+ $[76] = surface;
270
+ $[77] = t31;
271
+ $[78] = t32;
272
+ $[79] = t3;
273
+ } else {
274
+ t3 = $[79];
275
+ }
276
+ t4 = menu.actions.map((action_0, index) => {
277
+ const Icon = action_0.icon;
278
+ const color = action_0.destructive ? palette.danger[scheme] : tokens.color.foreground[scheme];
279
+ return <Pressable key={action_0.key} testID={`${testID}-action-${action_0.key}`} accessibilityRole="menuitem" accessibilityLabel={action_0.label} accessibilityState={{
280
+ disabled: action_0.disabled === true
281
+ }} disabled={action_0.disabled === true} onPress={() => run(action_0.onPress)} className="flex-row items-center gap-3 px-4 active:opacity-70" style={[{
282
+ minHeight: rowHeight,
283
+ opacity: action_0.disabled ? 0.5 : 1
284
+ }, index > 0 && {
285
+ borderTopWidth: StyleSheet.hairlineWidth,
286
+ borderTopColor: tokens.color.separator[scheme]
287
+ }]}><Text numberOfLines={1} className={cn(body, "min-w-0 flex-1 font-instrument-sans")} style={[sizeStyle(body), typeStyle("medium"), {
288
+ color
289
+ }]}>{action_0.label}</Text>{Icon ? <Icon size={largerText ? 22 : 20} color={color} /> : null}</Pressable>;
290
+ });
291
+ }
292
+ $[0] = align;
293
+ $[1] = anchor;
294
+ $[2] = insets;
295
+ $[3] = largerText;
296
+ $[4] = menu;
297
+ $[5] = onClose;
298
+ $[6] = open;
299
+ $[7] = preview;
300
+ $[8] = reduceMotion;
301
+ $[9] = rowHeight;
302
+ $[10] = scheme;
303
+ $[11] = testID;
304
+ $[12] = window;
305
+ $[13] = T0;
306
+ $[14] = T1;
307
+ $[15] = T2;
308
+ $[16] = t10;
309
+ $[17] = t11;
310
+ $[18] = t12;
311
+ $[19] = t13;
312
+ $[20] = t14;
313
+ $[21] = t15;
314
+ $[22] = t16;
315
+ $[23] = t17;
316
+ $[24] = t2;
317
+ $[25] = t3;
318
+ $[26] = t4;
319
+ $[27] = t5;
320
+ $[28] = t6;
321
+ $[29] = t7;
322
+ $[30] = t8;
323
+ $[31] = t9;
324
+ } else {
325
+ T0 = $[13];
326
+ T1 = $[14];
327
+ T2 = $[15];
328
+ t10 = $[16];
329
+ t11 = $[17];
330
+ t12 = $[18];
331
+ t13 = $[19];
332
+ t14 = $[20];
333
+ t15 = $[21];
334
+ t16 = $[22];
335
+ t17 = $[23];
336
+ t2 = $[24];
337
+ t3 = $[25];
338
+ t4 = $[26];
339
+ t5 = $[27];
340
+ t6 = $[28];
341
+ t7 = $[29];
342
+ t8 = $[30];
343
+ t9 = $[31];
344
+ }
345
+ if (t17 !== Symbol.for("react.early_return_sentinel")) {
346
+ return t17;
347
+ }
348
+ let t18;
349
+ if ($[80] !== T0 || $[81] !== t2 || $[82] !== t3 || $[83] !== t4) {
350
+ t18 = <T0 accessibilityRole={t2} style={t3}>{t4}</T0>;
351
+ $[80] = T0;
352
+ $[81] = t2;
353
+ $[82] = t3;
354
+ $[83] = t4;
355
+ $[84] = t18;
356
+ } else {
357
+ t18 = $[84];
358
+ }
359
+ let t19;
360
+ if ($[85] !== T1 || $[86] !== t10 || $[87] !== t11 || $[88] !== t18 || $[89] !== t5 || $[90] !== t6 || $[91] !== t7 || $[92] !== t8 || $[93] !== t9) {
361
+ t19 = <T1 style={t5} testID={t6} accessibilityViewIsModal={t7} onAccessibilityEscape={t8}>{t9}{t10}{t11}{t18}</T1>;
362
+ $[85] = T1;
363
+ $[86] = t10;
364
+ $[87] = t11;
365
+ $[88] = t18;
366
+ $[89] = t5;
367
+ $[90] = t6;
368
+ $[91] = t7;
369
+ $[92] = t8;
370
+ $[93] = t9;
371
+ $[94] = t19;
372
+ } else {
373
+ t19 = $[94];
374
+ }
375
+ let t20;
376
+ if ($[95] !== T2 || $[96] !== t12 || $[97] !== t13 || $[98] !== t14 || $[99] !== t15 || $[100] !== t16 || $[101] !== t19) {
377
+ t20 = <T2 visible={t12} transparent={t13} animationType={t14} statusBarTranslucent={t15} onRequestClose={t16}>{t19}</T2>;
378
+ $[95] = T2;
379
+ $[96] = t12;
380
+ $[97] = t13;
381
+ $[98] = t14;
382
+ $[99] = t15;
383
+ $[100] = t16;
384
+ $[101] = t19;
385
+ $[102] = t20;
386
+ } else {
387
+ t20 = $[102];
388
+ }
389
+ return t20;
390
+ }
@@ -0,0 +1,46 @@
1
+ /** A view's box in window coordinates, from `measureInWindow`. */
2
+
3
+ /** What a held message offers: quick reactions above it, actions below it. */
4
+
5
+ /** The pill's height, the gap between the parts, the menu's width and the margin from the screen edges. */
6
+ export const MESSAGE_MENU = {
7
+ pillHeight: 52,
8
+ gap: 8,
9
+ menuWidth: 250,
10
+ edge: 12,
11
+ maxPreviewRatio: 0.4
12
+ };
13
+
14
+ /**
15
+ * Where the parts go: the message stays where it was held when the pill fits
16
+ * above it and the menu below it; else it moves just enough, and a message
17
+ * taller than `maxPreviewRatio` of the screen shows its top part only.
18
+ */
19
+ export function messageContextMenuLayout({
20
+ anchor,
21
+ window,
22
+ insets,
23
+ menuHeight,
24
+ hasReactions
25
+ }) {
26
+ const {
27
+ pillHeight,
28
+ gap,
29
+ edge,
30
+ maxPreviewRatio
31
+ } = MESSAGE_MENU;
32
+ const above = hasReactions ? pillHeight + gap : 0;
33
+ const below = gap + menuHeight;
34
+ const top = insets.top + edge;
35
+ const bottom = window.height - insets.bottom - edge;
36
+ const previewHeight = Math.max(0, Math.min(anchor.height, window.height * maxPreviewRatio, bottom - top - above - below));
37
+ const minTop = top + above;
38
+ const maxTop = bottom - below - previewHeight;
39
+ const previewTop = Math.min(Math.max(anchor.y, minTop), Math.max(minTop, maxTop));
40
+ return {
41
+ previewTop,
42
+ previewHeight,
43
+ pillTop: previewTop - above,
44
+ menuTop: previewTop + previewHeight + gap
45
+ };
46
+ }