@vvedantb/native-ui 0.25.1 → 0.25.3
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/FloatingTabBar.jsx +66 -56
- package/dist/SheetRow.jsx +102 -101
- package/dist/ai/conversation-context.js +27 -0
- package/dist/ai/conversation.jsx +62 -52
- package/dist/ai/message-context-menu.jsx +408 -330
- package/dist/ai/message.jsx +94 -75
- package/dist/ai/sources.jsx +37 -37
- package/dist/ai/suggestion.jsx +42 -40
- package/dist/primitives/keyboard-controller.jsx +32 -26
- package/dist/usePressed.js +38 -0
- package/package.json +3 -3
- package/src/FloatingTabBar.tsx +5 -1
- package/src/SheetRow.tsx +7 -3
- package/src/ai/conversation-context.ts +56 -0
- package/src/ai/conversation.tsx +12 -42
- package/src/ai/message-context-menu.tsx +76 -31
- package/src/ai/message.tsx +15 -5
- package/src/ai/sources.tsx +7 -3
- package/src/ai/suggestion.tsx +7 -3
- package/src/primitives/keyboard-controller.tsx +3 -0
- package/src/primitives/keyboard-parts.tsx +3 -1
- package/src/usePressed.ts +13 -0
package/dist/FloatingTabBar.jsx
CHANGED
|
@@ -11,6 +11,7 @@ import { useLargerText } from "./theme";
|
|
|
11
11
|
import { useReduceMotion } from "./useReduceMotion";
|
|
12
12
|
import { useScheme } from "./useScheme";
|
|
13
13
|
import { FLOATING_PILL_RADIUS, tabBarHeight, tabBarSlotStyle } from "./floating";
|
|
14
|
+
import { usePressed } from "./usePressed";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Space between the bar edge and the tabs, on every side of the active pill,
|
|
@@ -192,7 +193,7 @@ export function FloatingTabBar(t0) {
|
|
|
192
193
|
* the caller's function.
|
|
193
194
|
*/
|
|
194
195
|
function TabBarItem(t0) {
|
|
195
|
-
const $ = _c(
|
|
196
|
+
const $ = _c(34);
|
|
196
197
|
const {
|
|
197
198
|
route,
|
|
198
199
|
navigation,
|
|
@@ -204,6 +205,7 @@ function TabBarItem(t0) {
|
|
|
204
205
|
testID,
|
|
205
206
|
accessibilityLabel
|
|
206
207
|
} = t0;
|
|
208
|
+
const press = usePressed();
|
|
207
209
|
let t1;
|
|
208
210
|
if ($[0] !== focused || $[1] !== navigation || $[2] !== route.key || $[3] !== route.name || $[4] !== route.params) {
|
|
209
211
|
t1 = () => {
|
|
@@ -237,71 +239,87 @@ function TabBarItem(t0) {
|
|
|
237
239
|
} else {
|
|
238
240
|
t2 = $[7];
|
|
239
241
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
const t3 = press.onPressIn;
|
|
243
|
+
const t4 = press.onPressOut;
|
|
244
|
+
const t5 = press.pressed ? 0.7 : 1;
|
|
245
|
+
let t6;
|
|
246
|
+
if ($[8] !== t5) {
|
|
247
|
+
t6 = {
|
|
248
|
+
opacity: t5
|
|
249
|
+
};
|
|
250
|
+
$[8] = t5;
|
|
251
|
+
$[9] = t6;
|
|
252
|
+
} else {
|
|
253
|
+
t6 = $[9];
|
|
254
|
+
}
|
|
255
|
+
let t7;
|
|
256
|
+
if ($[10] !== color || $[11] !== focused || $[12] !== largerText || $[13] !== renderIcon) {
|
|
257
|
+
t7 = renderIcon ? renderIcon({
|
|
243
258
|
focused,
|
|
244
259
|
color,
|
|
245
260
|
size: largerText ? 28 : 24
|
|
246
261
|
}) : null;
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
251
|
-
$[
|
|
262
|
+
$[10] = color;
|
|
263
|
+
$[11] = focused;
|
|
264
|
+
$[12] = largerText;
|
|
265
|
+
$[13] = renderIcon;
|
|
266
|
+
$[14] = t7;
|
|
252
267
|
} else {
|
|
253
|
-
|
|
268
|
+
t7 = $[14];
|
|
254
269
|
}
|
|
255
|
-
const
|
|
256
|
-
let
|
|
257
|
-
if ($[
|
|
258
|
-
|
|
270
|
+
const t8 = `font-instrument-sans-semibold ${largerText ? "text-base" : "text-sm"}`;
|
|
271
|
+
let t9;
|
|
272
|
+
if ($[15] !== color) {
|
|
273
|
+
t9 = {
|
|
259
274
|
color
|
|
260
275
|
};
|
|
261
|
-
$[
|
|
262
|
-
$[
|
|
276
|
+
$[15] = color;
|
|
277
|
+
$[16] = t9;
|
|
263
278
|
} else {
|
|
264
|
-
|
|
279
|
+
t9 = $[16];
|
|
265
280
|
}
|
|
266
|
-
let
|
|
267
|
-
if ($[
|
|
268
|
-
|
|
269
|
-
$[
|
|
281
|
+
let t10;
|
|
282
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
283
|
+
t10 = typeStyle("semibold");
|
|
284
|
+
$[17] = t10;
|
|
270
285
|
} else {
|
|
271
|
-
|
|
286
|
+
t10 = $[17];
|
|
272
287
|
}
|
|
273
|
-
let
|
|
274
|
-
if ($[
|
|
275
|
-
|
|
276
|
-
$[
|
|
277
|
-
$[
|
|
288
|
+
let t11;
|
|
289
|
+
if ($[18] !== t9) {
|
|
290
|
+
t11 = [t9, t10];
|
|
291
|
+
$[18] = t9;
|
|
292
|
+
$[19] = t11;
|
|
278
293
|
} else {
|
|
279
|
-
|
|
294
|
+
t11 = $[19];
|
|
280
295
|
}
|
|
281
|
-
let
|
|
282
|
-
if ($[
|
|
283
|
-
|
|
284
|
-
$[
|
|
285
|
-
$[
|
|
286
|
-
$[
|
|
287
|
-
$[
|
|
296
|
+
let t12;
|
|
297
|
+
if ($[20] !== label || $[21] !== t11 || $[22] !== t8) {
|
|
298
|
+
t12 = <Text numberOfLines={1} maxFontSizeMultiplier={1.5} className={t8} style={t11}>{label}</Text>;
|
|
299
|
+
$[20] = label;
|
|
300
|
+
$[21] = t11;
|
|
301
|
+
$[22] = t8;
|
|
302
|
+
$[23] = t12;
|
|
288
303
|
} else {
|
|
289
|
-
|
|
304
|
+
t12 = $[23];
|
|
290
305
|
}
|
|
291
|
-
let
|
|
292
|
-
if ($[
|
|
293
|
-
|
|
294
|
-
$[
|
|
295
|
-
$[
|
|
296
|
-
$[
|
|
297
|
-
$[
|
|
298
|
-
$[
|
|
299
|
-
$[
|
|
300
|
-
$[
|
|
306
|
+
let t13;
|
|
307
|
+
if ($[24] !== accessibilityLabel || $[25] !== onPress || $[26] !== press.onPressIn || $[27] !== press.onPressOut || $[28] !== t12 || $[29] !== t2 || $[30] !== t6 || $[31] !== t7 || $[32] !== testID) {
|
|
308
|
+
t13 = <Pressable testID={testID} accessibilityRole="tab" accessibilityState={t2} accessibilityLabel={accessibilityLabel} onPress={onPress} onPressIn={t3} onPressOut={t4} className="min-h-12 min-w-12 flex-1 items-center justify-center gap-1" style={t6}>{t7}{t12}</Pressable>;
|
|
309
|
+
$[24] = accessibilityLabel;
|
|
310
|
+
$[25] = onPress;
|
|
311
|
+
$[26] = press.onPressIn;
|
|
312
|
+
$[27] = press.onPressOut;
|
|
313
|
+
$[28] = t12;
|
|
314
|
+
$[29] = t2;
|
|
315
|
+
$[30] = t6;
|
|
316
|
+
$[31] = t7;
|
|
317
|
+
$[32] = testID;
|
|
318
|
+
$[33] = t13;
|
|
301
319
|
} else {
|
|
302
|
-
|
|
320
|
+
t13 = $[33];
|
|
303
321
|
}
|
|
304
|
-
return
|
|
322
|
+
return t13;
|
|
305
323
|
}
|
|
306
324
|
|
|
307
325
|
/**
|
|
@@ -313,14 +331,6 @@ function TabBarItem(t0) {
|
|
|
313
331
|
* and moves at once with Reduce Motion. Behind the tablist, so assistive tech
|
|
314
332
|
* reads only the tabs.
|
|
315
333
|
*/
|
|
316
|
-
function _temp(t0) {
|
|
317
|
-
const {
|
|
318
|
-
pressed
|
|
319
|
-
} = t0;
|
|
320
|
-
return {
|
|
321
|
-
opacity: pressed ? 0.7 : 1
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
334
|
function ActiveTabPill(t0) {
|
|
325
335
|
const $ = _c(14);
|
|
326
336
|
const {
|
package/dist/SheetRow.jsx
CHANGED
|
@@ -7,6 +7,7 @@ import { palette } from "./palette";
|
|
|
7
7
|
import { useLargerText } from "./theme";
|
|
8
8
|
import { tokens } from "./tokens";
|
|
9
9
|
import { useScheme } from "./useScheme";
|
|
10
|
+
import { usePressed } from "./usePressed";
|
|
10
11
|
/**
|
|
11
12
|
* One action in a `Sheet` or bottom sheet, a touch size of the web menu item:
|
|
12
13
|
* icon (or another `leading` mark), title and optional detail, at least 56 high (64 with larger text) with
|
|
@@ -16,7 +17,7 @@ import { useScheme } from "./useScheme";
|
|
|
16
17
|
* item, and ignores presses.
|
|
17
18
|
*/
|
|
18
19
|
export function SheetRow(t0) {
|
|
19
|
-
const $ = _c(
|
|
20
|
+
const $ = _c(53);
|
|
20
21
|
const {
|
|
21
22
|
icon: Icon,
|
|
22
23
|
leading,
|
|
@@ -34,6 +35,7 @@ export function SheetRow(t0) {
|
|
|
34
35
|
const danger = t2 === undefined ? false : t2;
|
|
35
36
|
const warning = t3 === undefined ? false : t3;
|
|
36
37
|
const disabled = t4 === undefined ? false : t4;
|
|
38
|
+
const press = usePressed();
|
|
37
39
|
const scheme = useScheme();
|
|
38
40
|
const largerText = useLargerText();
|
|
39
41
|
const color = danger ? palette.danger[scheme] : warning ? palette.warning[scheme] : tokens.color.foreground[scheme];
|
|
@@ -66,133 +68,132 @@ export function SheetRow(t0) {
|
|
|
66
68
|
} else {
|
|
67
69
|
t9 = $[5];
|
|
68
70
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const {
|
|
73
|
-
pressed
|
|
74
|
-
} = t11;
|
|
75
|
-
return {
|
|
76
|
-
borderRadius: tokens.radius.sm,
|
|
77
|
-
backgroundColor: pressed && !disabled ? palette.default[scheme] : "transparent"
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
$[6] = disabled;
|
|
81
|
-
$[7] = scheme;
|
|
82
|
-
$[8] = t10;
|
|
83
|
-
} else {
|
|
84
|
-
t10 = $[8];
|
|
85
|
-
}
|
|
86
|
-
let t11;
|
|
87
|
-
if ($[9] !== Icon || $[10] !== color || $[11] !== iconSize || $[12] !== leading) {
|
|
88
|
-
t11 = leading ?? (Icon ? <Icon size={iconSize} color={color} /> : null);
|
|
89
|
-
$[9] = Icon;
|
|
90
|
-
$[10] = color;
|
|
91
|
-
$[11] = iconSize;
|
|
92
|
-
$[12] = leading;
|
|
93
|
-
$[13] = t11;
|
|
94
|
-
} else {
|
|
95
|
-
t11 = $[13];
|
|
96
|
-
}
|
|
97
|
-
let t12;
|
|
98
|
-
if ($[14] !== titleSize) {
|
|
99
|
-
t12 = cn("font-instrument-sans-medium", titleSize);
|
|
100
|
-
$[14] = titleSize;
|
|
101
|
-
$[15] = t12;
|
|
102
|
-
} else {
|
|
103
|
-
t12 = $[15];
|
|
104
|
-
}
|
|
71
|
+
const t10 = press.onPressIn;
|
|
72
|
+
const t11 = press.onPressOut;
|
|
73
|
+
const t12 = press.pressed && !disabled ? palette.default[scheme] : "transparent";
|
|
105
74
|
let t13;
|
|
106
|
-
if ($[
|
|
75
|
+
if ($[6] !== t12) {
|
|
107
76
|
t13 = {
|
|
108
|
-
|
|
77
|
+
borderRadius: tokens.radius.sm,
|
|
78
|
+
backgroundColor: t12
|
|
109
79
|
};
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
80
|
+
$[6] = t12;
|
|
81
|
+
$[7] = t13;
|
|
112
82
|
} else {
|
|
113
|
-
t13 = $[
|
|
83
|
+
t13 = $[7];
|
|
114
84
|
}
|
|
115
85
|
let t14;
|
|
116
|
-
if ($[
|
|
117
|
-
t14 =
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
86
|
+
if ($[8] !== Icon || $[9] !== color || $[10] !== iconSize || $[11] !== leading) {
|
|
87
|
+
t14 = leading ?? (Icon ? <Icon size={iconSize} color={color} /> : null);
|
|
88
|
+
$[8] = Icon;
|
|
89
|
+
$[9] = color;
|
|
90
|
+
$[10] = iconSize;
|
|
91
|
+
$[11] = leading;
|
|
92
|
+
$[12] = t14;
|
|
120
93
|
} else {
|
|
121
|
-
t14 = $[
|
|
94
|
+
t14 = $[12];
|
|
122
95
|
}
|
|
123
96
|
let t15;
|
|
124
|
-
if ($[
|
|
125
|
-
t15 =
|
|
126
|
-
$[
|
|
97
|
+
if ($[13] !== titleSize) {
|
|
98
|
+
t15 = cn("font-instrument-sans-medium", titleSize);
|
|
99
|
+
$[13] = titleSize;
|
|
100
|
+
$[14] = t15;
|
|
127
101
|
} else {
|
|
128
|
-
t15 = $[
|
|
102
|
+
t15 = $[14];
|
|
129
103
|
}
|
|
130
104
|
let t16;
|
|
131
|
-
if ($[
|
|
132
|
-
t16 =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
$[
|
|
105
|
+
if ($[15] !== color) {
|
|
106
|
+
t16 = {
|
|
107
|
+
color
|
|
108
|
+
};
|
|
109
|
+
$[15] = color;
|
|
110
|
+
$[16] = t16;
|
|
136
111
|
} else {
|
|
137
|
-
t16 = $[
|
|
112
|
+
t16 = $[16];
|
|
138
113
|
}
|
|
139
114
|
let t17;
|
|
140
|
-
if ($[
|
|
141
|
-
t17 =
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
144
|
-
$[26] = title;
|
|
145
|
-
$[27] = t17;
|
|
115
|
+
if ($[17] !== titleSize) {
|
|
116
|
+
t17 = sizeStyle(titleSize);
|
|
117
|
+
$[17] = titleSize;
|
|
118
|
+
$[18] = t17;
|
|
146
119
|
} else {
|
|
147
|
-
t17 = $[
|
|
120
|
+
t17 = $[18];
|
|
148
121
|
}
|
|
149
122
|
let t18;
|
|
150
|
-
if ($[
|
|
151
|
-
t18 =
|
|
152
|
-
$[
|
|
153
|
-
$[29] = detailSize;
|
|
154
|
-
$[30] = scheme;
|
|
155
|
-
$[31] = t18;
|
|
123
|
+
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
|
|
124
|
+
t18 = typeStyle("medium");
|
|
125
|
+
$[19] = t18;
|
|
156
126
|
} else {
|
|
157
|
-
t18 = $[
|
|
127
|
+
t18 = $[19];
|
|
158
128
|
}
|
|
159
129
|
let t19;
|
|
160
|
-
if ($[
|
|
161
|
-
t19 =
|
|
162
|
-
$[
|
|
163
|
-
$[
|
|
164
|
-
$[
|
|
130
|
+
if ($[20] !== t16 || $[21] !== t17) {
|
|
131
|
+
t19 = [t16, t17, t18];
|
|
132
|
+
$[20] = t16;
|
|
133
|
+
$[21] = t17;
|
|
134
|
+
$[22] = t19;
|
|
165
135
|
} else {
|
|
166
|
-
t19 = $[
|
|
136
|
+
t19 = $[22];
|
|
167
137
|
}
|
|
168
138
|
let t20;
|
|
169
|
-
if ($[
|
|
170
|
-
t20 =
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
139
|
+
if ($[23] !== t15 || $[24] !== t19 || $[25] !== title) {
|
|
140
|
+
t20 = <Text className={t15} style={t19}>{title}</Text>;
|
|
141
|
+
$[23] = t15;
|
|
142
|
+
$[24] = t19;
|
|
143
|
+
$[25] = title;
|
|
144
|
+
$[26] = t20;
|
|
175
145
|
} else {
|
|
176
|
-
t20 = $[
|
|
146
|
+
t20 = $[26];
|
|
177
147
|
}
|
|
178
148
|
let t21;
|
|
179
|
-
if ($[
|
|
180
|
-
t21 =
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
184
|
-
$[
|
|
185
|
-
|
|
186
|
-
$[
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
149
|
+
if ($[27] !== detail || $[28] !== detailSize || $[29] !== scheme) {
|
|
150
|
+
t21 = detail ? <Text className={cn("font-instrument-sans", detailSize)} style={[textStyle("muted", scheme), sizeStyle(detailSize)]}>{detail}</Text> : null;
|
|
151
|
+
$[27] = detail;
|
|
152
|
+
$[28] = detailSize;
|
|
153
|
+
$[29] = scheme;
|
|
154
|
+
$[30] = t21;
|
|
155
|
+
} else {
|
|
156
|
+
t21 = $[30];
|
|
157
|
+
}
|
|
158
|
+
let t22;
|
|
159
|
+
if ($[31] !== t20 || $[32] !== t21) {
|
|
160
|
+
t22 = <View className="min-w-0 flex-1">{t20}{t21}</View>;
|
|
161
|
+
$[31] = t20;
|
|
162
|
+
$[32] = t21;
|
|
163
|
+
$[33] = t22;
|
|
164
|
+
} else {
|
|
165
|
+
t22 = $[33];
|
|
166
|
+
}
|
|
167
|
+
let t23;
|
|
168
|
+
if ($[34] !== active || $[35] !== color || $[36] !== iconSize) {
|
|
169
|
+
t23 = active ? <IconCheck size={iconSize} color={color} strokeWidth={2} /> : null;
|
|
170
|
+
$[34] = active;
|
|
171
|
+
$[35] = color;
|
|
172
|
+
$[36] = iconSize;
|
|
173
|
+
$[37] = t23;
|
|
174
|
+
} else {
|
|
175
|
+
t23 = $[37];
|
|
176
|
+
}
|
|
177
|
+
let t24;
|
|
178
|
+
if ($[38] !== detail || $[39] !== disabled || $[40] !== onPress || $[41] !== press.onPressIn || $[42] !== press.onPressOut || $[43] !== t13 || $[44] !== t14 || $[45] !== t22 || $[46] !== t23 || $[47] !== t5 || $[48] !== t6 || $[49] !== t9 || $[50] !== testID || $[51] !== title) {
|
|
179
|
+
t24 = <Pressable testID={testID} accessibilityRole={t5} accessibilityLabel={title} accessibilityHint={detail} accessibilityState={t6} disabled={disabled} onPress={onPress} className={t9} onPressIn={t10} onPressOut={t11} style={t13}>{t14}{t22}{t23}</Pressable>;
|
|
180
|
+
$[38] = detail;
|
|
181
|
+
$[39] = disabled;
|
|
182
|
+
$[40] = onPress;
|
|
183
|
+
$[41] = press.onPressIn;
|
|
184
|
+
$[42] = press.onPressOut;
|
|
185
|
+
$[43] = t13;
|
|
186
|
+
$[44] = t14;
|
|
187
|
+
$[45] = t22;
|
|
188
|
+
$[46] = t23;
|
|
189
|
+
$[47] = t5;
|
|
190
|
+
$[48] = t6;
|
|
191
|
+
$[49] = t9;
|
|
192
|
+
$[50] = testID;
|
|
193
|
+
$[51] = title;
|
|
194
|
+
$[52] = t24;
|
|
194
195
|
} else {
|
|
195
|
-
|
|
196
|
+
t24 = $[52];
|
|
196
197
|
}
|
|
197
|
-
return
|
|
198
|
+
return t24;
|
|
198
199
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
|
|
3
|
+
// The `Conversation` context on its own, so a message can reach it without the
|
|
4
|
+
// thread's components (`message.tsx` sets `overlay`).
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the thread scrolls with: the `ScrollView` of `ConversationContent` or
|
|
8
|
+
* the `FlatList` of `ConversationList`. `scrollToEnd` goes to the newest
|
|
9
|
+
* message, which is offset 0 in an inverted list. `scrollTo` goes to an
|
|
10
|
+
* offset; only the `ScrollView` has it, so call it as `scrollTo?.(...)`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const ConversationContext = createContext(null);
|
|
14
|
+
|
|
15
|
+
/** `isAtBottom` and `scrollToBottom` of the enclosing `Conversation`, for a custom scroll button. */
|
|
16
|
+
export function useConversation() {
|
|
17
|
+
const context = useContext(ConversationContext);
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error("Conversation parts must be used within Conversation");
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The enclosing `Conversation`, or null for a message drawn outside one. */
|
|
25
|
+
export function useOptionalConversation() {
|
|
26
|
+
return useContext(ConversationContext);
|
|
27
|
+
}
|
package/dist/ai/conversation.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { isValidElement, useRef, useState } from "react";
|
|
3
3
|
import { FlatList, Platform, Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
|
|
4
4
|
import { IconArrowDown } from "@tabler/icons-react-native";
|
|
5
5
|
import { FadeIn, FadeOut } from "react-native-reanimated";
|
|
@@ -16,6 +16,7 @@ import { tokens } from "../tokens";
|
|
|
16
16
|
import { useReduceMotion } from "../useReduceMotion";
|
|
17
17
|
import { useScheme } from "../useScheme";
|
|
18
18
|
import { chatTextSize } from "./chat-text";
|
|
19
|
+
import { ConversationContext, useConversation } from "./conversation-context";
|
|
19
20
|
|
|
20
21
|
/** Within this many points of the end, the thread counts as at the bottom and keeps following new content. */
|
|
21
22
|
export const AT_BOTTOM_THRESHOLD = 70;
|
|
@@ -36,31 +37,14 @@ export function isScrolledToBottom({
|
|
|
36
37
|
if (inverted) return contentOffset.y + bottomInset <= AT_BOTTOM_THRESHOLD;
|
|
37
38
|
return contentSize.height + bottomInset - layoutMeasurement.height - contentOffset.y <= AT_BOTTOM_THRESHOLD;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* What the thread scrolls with: the `ScrollView` of `ConversationContent` or
|
|
42
|
-
* the `FlatList` of `ConversationList`. `scrollToEnd` goes to the newest
|
|
43
|
-
* message, which is offset 0 in an inverted list. `scrollTo` goes to an
|
|
44
|
-
* offset; only the `ScrollView` has it, so call it as `scrollTo?.(...)`.
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
const ConversationContext = createContext(null);
|
|
48
|
-
|
|
49
|
-
/** `isAtBottom` and `scrollToBottom` of the enclosing `Conversation`, for a custom scroll button. */
|
|
50
|
-
export function useConversation() {
|
|
51
|
-
const context = useContext(ConversationContext);
|
|
52
|
-
if (!context) {
|
|
53
|
-
throw new Error("Conversation parts must be used within Conversation");
|
|
54
|
-
}
|
|
55
|
-
return context;
|
|
56
|
-
}
|
|
40
|
+
export { useConversation, useOptionalConversation } from "./conversation-context";
|
|
57
41
|
/**
|
|
58
42
|
* The thread frame (web `relative flex-1`). It sticks to the bottom: while the
|
|
59
43
|
* reader is at the end, new and growing messages stay in view; once they
|
|
60
44
|
* scroll up, it stops following and `ConversationScrollButton` shows.
|
|
61
45
|
*/
|
|
62
46
|
export function Conversation(t0) {
|
|
63
|
-
const $ = _c(
|
|
47
|
+
const $ = _c(25);
|
|
64
48
|
let className;
|
|
65
49
|
let props;
|
|
66
50
|
if ($[0] !== t0) {
|
|
@@ -81,6 +65,7 @@ export function Conversation(t0) {
|
|
|
81
65
|
const autoScrolling = useRef(false);
|
|
82
66
|
const [isAtBottom, setIsAtBottom] = useState(true);
|
|
83
67
|
const [dockHeight, setDockHeight] = useState(0);
|
|
68
|
+
const [overlay, setOverlay] = useState("none");
|
|
84
69
|
let t1;
|
|
85
70
|
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
86
71
|
t1 = next => {
|
|
@@ -140,8 +125,23 @@ export function Conversation(t0) {
|
|
|
140
125
|
t5 = $[8];
|
|
141
126
|
}
|
|
142
127
|
let t6;
|
|
143
|
-
|
|
144
|
-
|
|
128
|
+
let t7;
|
|
129
|
+
let t8;
|
|
130
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
131
|
+
t6 = () => setOverlay("open");
|
|
132
|
+
t7 = () => setOverlay("closing");
|
|
133
|
+
t8 = () => setOverlay(_temp);
|
|
134
|
+
$[9] = t6;
|
|
135
|
+
$[10] = t7;
|
|
136
|
+
$[11] = t8;
|
|
137
|
+
} else {
|
|
138
|
+
t6 = $[9];
|
|
139
|
+
t7 = $[10];
|
|
140
|
+
t8 = $[11];
|
|
141
|
+
}
|
|
142
|
+
let t9;
|
|
143
|
+
if ($[12] !== dockHeight || $[13] !== isAtBottom || $[14] !== overlay || $[15] !== t2) {
|
|
144
|
+
t9 = {
|
|
145
145
|
isAtBottom,
|
|
146
146
|
scrollRef,
|
|
147
147
|
scrollToBottom: t2,
|
|
@@ -149,47 +149,54 @@ export function Conversation(t0) {
|
|
|
149
149
|
onUserScroll: t4,
|
|
150
150
|
followContent: t5,
|
|
151
151
|
dockHeight,
|
|
152
|
-
setDockHeight
|
|
152
|
+
setDockHeight,
|
|
153
|
+
overlay,
|
|
154
|
+
openOverlay: t6,
|
|
155
|
+
closeOverlay: t7,
|
|
156
|
+
settleOverlay: t8
|
|
153
157
|
};
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
+
$[12] = dockHeight;
|
|
159
|
+
$[13] = isAtBottom;
|
|
160
|
+
$[14] = overlay;
|
|
161
|
+
$[15] = t2;
|
|
162
|
+
$[16] = t9;
|
|
158
163
|
} else {
|
|
159
|
-
|
|
164
|
+
t9 = $[16];
|
|
160
165
|
}
|
|
161
|
-
const value =
|
|
162
|
-
let
|
|
163
|
-
if ($[
|
|
164
|
-
|
|
165
|
-
$[
|
|
166
|
-
$[
|
|
166
|
+
const value = t9;
|
|
167
|
+
let t10;
|
|
168
|
+
if ($[17] !== className) {
|
|
169
|
+
t10 = cn("relative flex-1", className);
|
|
170
|
+
$[17] = className;
|
|
171
|
+
$[18] = t10;
|
|
167
172
|
} else {
|
|
168
|
-
|
|
173
|
+
t10 = $[18];
|
|
169
174
|
}
|
|
170
|
-
let
|
|
171
|
-
if ($[
|
|
172
|
-
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
175
|
-
$[
|
|
175
|
+
let t11;
|
|
176
|
+
if ($[19] !== props || $[20] !== t10) {
|
|
177
|
+
t11 = <View className={t10} {...props} />;
|
|
178
|
+
$[19] = props;
|
|
179
|
+
$[20] = t10;
|
|
180
|
+
$[21] = t11;
|
|
176
181
|
} else {
|
|
177
|
-
|
|
182
|
+
t11 = $[21];
|
|
178
183
|
}
|
|
179
|
-
let
|
|
180
|
-
if ($[
|
|
181
|
-
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
184
|
-
$[
|
|
184
|
+
let t12;
|
|
185
|
+
if ($[22] !== t11 || $[23] !== value) {
|
|
186
|
+
t12 = <ConversationContext.Provider value={value}>{t11}</ConversationContext.Provider>;
|
|
187
|
+
$[22] = t11;
|
|
188
|
+
$[23] = value;
|
|
189
|
+
$[24] = t12;
|
|
185
190
|
} else {
|
|
186
|
-
|
|
191
|
+
t12 = $[24];
|
|
187
192
|
}
|
|
188
|
-
return
|
|
193
|
+
return t12;
|
|
189
194
|
}
|
|
190
195
|
|
|
191
196
|
/** The scroll handlers a thread's scroller passes on, as `ScrollView` and `FlatList` both take them. */
|
|
192
|
-
|
|
197
|
+
function _temp(current) {
|
|
198
|
+
return current === "closing" ? "none" : current;
|
|
199
|
+
}
|
|
193
200
|
/**
|
|
194
201
|
* Taps reach rows while the keyboard is up; a drag lowers it (interactively
|
|
195
202
|
* on iOS, and on Android 11+ with `KeyboardControllerProvider`, in
|
|
@@ -235,6 +242,7 @@ function useConversationScroll({
|
|
|
235
242
|
},
|
|
236
243
|
onScrollBeginDrag: event_0 => {
|
|
237
244
|
conversation.onUserScroll();
|
|
245
|
+
conversation.settleOverlay();
|
|
238
246
|
onScrollBeginDrag?.(event_0);
|
|
239
247
|
},
|
|
240
248
|
// The app's handler first, so a scroller that measures itself (`ConversationList`) has the new size to follow.
|
|
@@ -396,12 +404,14 @@ export function ConversationList({
|
|
|
396
404
|
// Inverted, the column's end is the top: a short thread sits there.
|
|
397
405
|
contentContainerClassName={cn("px-3 py-3", inverted && "grow justify-end", contentContainerClassName)} {...wired} style={[wired.style, !inverted && hasRows && !placed ? styles.hidden : null]}
|
|
398
406
|
// At the bottom, a new message shows at offset 0; scrolled up, it must not move what the reader sees.
|
|
399
|
-
maintainVisibleContentPosition={props.maintainVisibleContentPosition ?? (inverted && !conversation.isAtBottom ? KEEP_VISIBLE : undefined)} keyboardDismissMode={props.keyboardDismissMode ?? (keyboard?.interactive ? "interactive" : SCROLL_DEFAULTS.keyboardDismissMode)} renderScrollComponent={keyboard ? scrollProps => <keyboard.ChatScrollView {...scrollProps} inverted={inverted}
|
|
407
|
+
maintainVisibleContentPosition={props.maintainVisibleContentPosition ?? (inverted && !conversation.isAtBottom ? KEEP_VISIBLE : undefined)} keyboardDismissMode={props.keyboardDismissMode ?? (keyboard?.interactive ? "interactive" : SCROLL_DEFAULTS.keyboardDismissMode)} renderScrollComponent={keyboard ? scrollProps => <keyboard.ChatScrollView {...scrollProps} inverted={inverted} freeze={conversation.overlay !== "none"}
|
|
400
408
|
// The composer pads the bottom inset, which the keyboard covers: the content rises by the rest.
|
|
401
409
|
bottomOffset={insets.bottom} onInsetChange={inset => {
|
|
402
410
|
size.current.inset = inset;
|
|
403
411
|
}} onKeyboardMove={moving => {
|
|
404
412
|
size.current.keyboardMoving = moving;
|
|
413
|
+
// The closing menu's window hands the focus back with a keyboard event: frozen until it ends.
|
|
414
|
+
if (!moving) conversation.settleOverlay();
|
|
405
415
|
}} /> : props.renderScrollComponent} ref={list => {
|
|
406
416
|
conversation.scrollRef.current = list && {
|
|
407
417
|
scrollToEnd: options => list.scrollToOffset({
|