@marktiderman/genesis-ui-native 3.6.0 → 3.7.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/README.md +44 -0
- package/dist/{chunk-AGTBABAH.js → chunk-3KFUS7O6.js} +4 -4
- package/dist/{chunk-AGTBABAH.js.map → chunk-3KFUS7O6.js.map} +1 -1
- package/dist/{chunk-2Z72MYHB.js → chunk-7NDKIIOT.js} +5 -5
- package/dist/{chunk-2Z72MYHB.js.map → chunk-7NDKIIOT.js.map} +1 -1
- package/dist/chunk-CAI7LGN6.js +39 -0
- package/dist/chunk-CAI7LGN6.js.map +1 -0
- package/dist/{chunk-FUMSL7VZ.js → chunk-GBNIBHSU.js} +6 -6
- package/dist/{chunk-FUMSL7VZ.js.map → chunk-GBNIBHSU.js.map} +1 -1
- package/dist/{chunk-SEJ6RBP7.js → chunk-IXC3LO2K.js} +100 -51
- package/dist/chunk-IXC3LO2K.js.map +1 -0
- package/dist/{chunk-NDXNSSM6.js → chunk-KH2RVAI5.js} +3 -4
- package/dist/chunk-KH2RVAI5.js.map +1 -0
- package/dist/{chunk-6PGLX6ET.js → chunk-O4BMDV7I.js} +14 -16
- package/dist/chunk-O4BMDV7I.js.map +1 -0
- package/dist/{chunk-4OQOJ2OC.js → chunk-RTYO24SC.js} +30 -5
- package/dist/chunk-RTYO24SC.js.map +1 -0
- package/dist/{chunk-ZRQAFFTN.js → chunk-YWDDDYDI.js} +2 -2
- package/dist/{chunk-ZRQAFFTN.js.map → chunk-YWDDDYDI.js.map} +1 -1
- package/dist/components/index.d.ts +55 -10
- package/dist/components/index.js +6 -5
- package/dist/data/index.js +4 -4
- package/dist/hooks/index.d.ts +32 -3
- package/dist/hooks/index.js +3 -2
- package/dist/icons/lucide.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -8
- package/dist/layouts/index.js +6 -5
- package/dist/{native-modules-Cl3zw3kh.d.ts → native-modules-DEJJQhDx.d.ts} +29 -1
- package/package.json +25 -2
- package/src/__tests__/doctor-rules.test.ts +27 -0
- package/src/components/__tests__/button-haptic.test.tsx +52 -0
- package/src/components/__tests__/composer-bar.test.tsx +24 -0
- package/src/components/__tests__/thread-list.test.tsx +63 -0
- package/src/components/button.tsx +18 -1
- package/src/components/composer-bar.tsx +101 -23
- package/src/components/index.ts +1 -1
- package/src/components/thread-list.tsx +43 -13
- package/src/hooks/__tests__/use-haptics.test.tsx +146 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-haptics.ts +64 -0
- package/src/hooks/use-press-feedback.ts +87 -0
- package/src/native-modules.tsx +4 -0
- package/dist/chunk-4OQOJ2OC.js.map +0 -1
- package/dist/chunk-6PGLX6ET.js.map +0 -1
- package/dist/chunk-NDXNSSM6.js.map +0 -1
- package/dist/chunk-SEJ6RBP7.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { NativeSkeleton, NativeText, NativeIcon } from './chunk-O4BMDV7I.js';
|
|
2
|
+
import { usePressFeedback } from './chunk-CAI7LGN6.js';
|
|
3
|
+
import { useGenesisModules, useReducedMotion, useThemeRoles } from './chunk-RTYO24SC.js';
|
|
3
4
|
import { forwardRef, useState, useRef, useEffect, useCallback, useImperativeHandle, useMemo } from 'react';
|
|
4
|
-
import { FlatList, View, Platform, AccessibilityInfo, Pressable, Dimensions, TextInput, ActivityIndicator } from 'react-native';
|
|
5
|
+
import { FlatList, View, Platform, AccessibilityInfo, Pressable, Dimensions, TextInput, ActivityIndicator, Animated, Alert } from 'react-native';
|
|
5
6
|
import { useThreadJump } from '@marktiderman/genesis-core/conversation';
|
|
6
7
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
7
8
|
|
|
@@ -35,6 +36,7 @@ function NativeThreadListInner(props, ref) {
|
|
|
35
36
|
earlierLabel = "Load earlier messages",
|
|
36
37
|
renderEarlier,
|
|
37
38
|
jumpTo,
|
|
39
|
+
jumpId,
|
|
38
40
|
onLoadUntil,
|
|
39
41
|
jumpAnnouncement,
|
|
40
42
|
onJumpFailed,
|
|
@@ -70,9 +72,10 @@ function NativeThreadListInner(props, ref) {
|
|
|
70
72
|
const pending = timers.current;
|
|
71
73
|
return () => pending.forEach(clearTimeout);
|
|
72
74
|
}, []);
|
|
73
|
-
const
|
|
74
|
-
latest
|
|
75
|
-
|
|
75
|
+
const idOf = jumpId ?? keyExtractor;
|
|
76
|
+
const latest = useRef({ data, idOf, jumpAnnouncement, onJumpFailed, onAtBottomChange });
|
|
77
|
+
latest.current = { data, idOf, jumpAnnouncement, onJumpFailed, onAtBottomChange };
|
|
78
|
+
const indexOf = useCallback((id) => latest.current.data.findIndex((row) => latest.current.idOf(row) === id), []);
|
|
76
79
|
const setAtBottom = useCallback((v) => {
|
|
77
80
|
if (atBottom.current === v) return;
|
|
78
81
|
atBottom.current = v;
|
|
@@ -105,7 +108,9 @@ function NativeThreadListInner(props, ref) {
|
|
|
105
108
|
(id) => {
|
|
106
109
|
const scroll = () => {
|
|
107
110
|
const at = indexOf(id);
|
|
108
|
-
if (at
|
|
111
|
+
if (at < 0) return;
|
|
112
|
+
settlingUntil.current = Date.now() + SETTLING_MS;
|
|
113
|
+
listRef.current?.scrollToIndex?.({ index: at, animated: !reducedMotion, viewPosition: 0.5 });
|
|
109
114
|
};
|
|
110
115
|
jumpTries.current = { id, tries: 0 };
|
|
111
116
|
settlingUntil.current = Date.now() + SETTLING_MS;
|
|
@@ -128,9 +133,15 @@ function NativeThreadListInner(props, ref) {
|
|
|
128
133
|
},
|
|
129
134
|
onLanded: (id) => {
|
|
130
135
|
if (recheck.current) clearTimeout(recheck.current);
|
|
131
|
-
|
|
136
|
+
const look = () => {
|
|
137
|
+
const wait = settlingUntil.current - Date.now();
|
|
138
|
+
if (wait > 0) {
|
|
139
|
+
recheck.current = setTimeout(look, wait + 50);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
132
142
|
if (metrics.current && threadNearBottom(metrics.current)) setAtBottom(true);
|
|
133
|
-
}
|
|
143
|
+
};
|
|
144
|
+
recheck.current = setTimeout(look, SETTLING_MS + 50);
|
|
134
145
|
const at = indexOf(id);
|
|
135
146
|
const said = at >= 0 ? latest.current.jumpAnnouncement?.(latest.current.data[at]) : void 0;
|
|
136
147
|
if (said) announce(said);
|
|
@@ -150,8 +161,8 @@ function NativeThreadListInner(props, ref) {
|
|
|
150
161
|
hasEarlier && onLoadEarlier ? renderEarlier ? renderEarlier(earlierProps) : /* @__PURE__ */ jsx(DefaultEarlier, { ...earlierProps }) : null
|
|
151
162
|
] });
|
|
152
163
|
const renderListItem = useCallback(
|
|
153
|
-
({ item, index }) => renderItem(item, { index, highlighted: highlightedId !== null &&
|
|
154
|
-
[highlightedId,
|
|
164
|
+
({ item, index }) => renderItem(item, { index, highlighted: highlightedId !== null && idOf(item) === highlightedId }),
|
|
165
|
+
[highlightedId, idOf, renderItem]
|
|
155
166
|
);
|
|
156
167
|
const listKey = useCallback((row) => keyExtractor(row), [keyExtractor]);
|
|
157
168
|
const listItemType = useMemo(() => getItemType ? (row) => getItemType(row) : void 0, [getItemType]);
|
|
@@ -160,12 +171,14 @@ function NativeThreadListInner(props, ref) {
|
|
|
160
171
|
metrics.current = { contentOffset: { y: e.nativeEvent.contentOffset.y }, contentSize: { height: e.nativeEvent.contentSize.height }, layoutMeasurement: { height: e.nativeEvent.layoutMeasurement.height } };
|
|
161
172
|
const height = e.nativeEvent.layoutMeasurement.height;
|
|
162
173
|
setViewport((v) => Math.abs(v - height) < 1 ? v : height);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
setAtBottom(near);
|
|
174
|
+
if (Date.now() < settlingUntil.current) return;
|
|
175
|
+
setAtBottom(threadNearBottom(e.nativeEvent));
|
|
166
176
|
},
|
|
167
177
|
[setAtBottom]
|
|
168
178
|
);
|
|
179
|
+
const onScrollBeginDrag = useCallback(() => {
|
|
180
|
+
settlingUntil.current = 0;
|
|
181
|
+
}, []);
|
|
169
182
|
const onScrollToIndexFailed = useCallback(
|
|
170
183
|
({ index, averageItemLength }) => {
|
|
171
184
|
listRef.current?.scrollToOffset?.({ offset: Math.max(0, index * averageItemLength - 200), animated: false });
|
|
@@ -174,7 +187,9 @@ function NativeThreadListInner(props, ref) {
|
|
|
174
187
|
target.tries += 1;
|
|
175
188
|
later(() => {
|
|
176
189
|
const at = indexOf(target.id);
|
|
177
|
-
if (at
|
|
190
|
+
if (at < 0) return;
|
|
191
|
+
settlingUntil.current = Date.now() + SETTLING_MS;
|
|
192
|
+
listRef.current?.scrollToIndex?.({ index: at, animated: !reducedMotion, viewPosition: 0.5 });
|
|
178
193
|
}, 250);
|
|
179
194
|
},
|
|
180
195
|
[indexOf, later, reducedMotion]
|
|
@@ -211,6 +226,7 @@ function NativeThreadListInner(props, ref) {
|
|
|
211
226
|
maintainVisibleContentPosition: mode.maintainVisibleContentPosition,
|
|
212
227
|
scrollEventThrottle: 32,
|
|
213
228
|
onScroll,
|
|
229
|
+
onScrollBeginDrag,
|
|
214
230
|
onScrollToIndexFailed,
|
|
215
231
|
...mode.followsByHand ? { onContentSizeChange: follow, onLayout: follow } : {},
|
|
216
232
|
ListHeaderComponent: listHeader,
|
|
@@ -233,6 +249,13 @@ function DefaultLoading() {
|
|
|
233
249
|
/* @__PURE__ */ jsx(NativeSkeleton, { width: 240, height: 36, className: "rounded-2xl" })
|
|
234
250
|
] });
|
|
235
251
|
}
|
|
252
|
+
function openSendActions(actions, title) {
|
|
253
|
+
if (actions.length === 1) return actions[0].onPress();
|
|
254
|
+
Alert.alert(title ?? "", void 0, [
|
|
255
|
+
...actions.map((a) => ({ text: a.label, style: a.destructive ? "destructive" : "default", onPress: a.onPress })),
|
|
256
|
+
{ text: "Cancel", style: "cancel" }
|
|
257
|
+
]);
|
|
258
|
+
}
|
|
236
259
|
var LINE = 22;
|
|
237
260
|
var PAD_Y = 8;
|
|
238
261
|
function NativeComposerBar({
|
|
@@ -252,6 +275,14 @@ function NativeComposerBar({
|
|
|
252
275
|
leading,
|
|
253
276
|
trailing,
|
|
254
277
|
above,
|
|
278
|
+
empty,
|
|
279
|
+
idleAction,
|
|
280
|
+
replaceInput,
|
|
281
|
+
sendActions,
|
|
282
|
+
sendActionsTitle,
|
|
283
|
+
sendActionsHint = "Touch and hold for more options",
|
|
284
|
+
onSelectionChange,
|
|
285
|
+
editable = true,
|
|
255
286
|
testID = "composer"
|
|
256
287
|
}) {
|
|
257
288
|
const colors = useThemeRoles();
|
|
@@ -259,8 +290,11 @@ function NativeComposerBar({
|
|
|
259
290
|
const hasIcon = Boolean(symbol || icons?.["arrow-up"]);
|
|
260
291
|
const current = modes?.find((m) => m.id === mode) ?? modes?.[0];
|
|
261
292
|
const internal = current?.tone === "internal";
|
|
262
|
-
const blank = !value.trim();
|
|
263
|
-
const canSend = !blank && !disabled && !sending;
|
|
293
|
+
const blank = empty ?? !value.trim();
|
|
294
|
+
const canSend = !blank && !disabled && !sending && editable;
|
|
295
|
+
const actions = sendActions?.length ? sendActions : null;
|
|
296
|
+
const idle = idleAction != null && blank && !sending;
|
|
297
|
+
const sendPress = usePressFeedback({ haptic: "light", scale: 0.9, disabled: !canSend });
|
|
264
298
|
const fontScale = Dimensions.get("window").fontScale || 1;
|
|
265
299
|
const maxHeight = Math.ceil(LINE * fontScale) * maxLines + PAD_Y * 2;
|
|
266
300
|
useEffect(() => {
|
|
@@ -306,50 +340,65 @@ function NativeComposerBar({
|
|
|
306
340
|
}) }) : null,
|
|
307
341
|
above,
|
|
308
342
|
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "flex-end", gap: 8 }, children: [
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
343
|
+
replaceInput != null ? /* @__PURE__ */ jsx(View, { style: { flex: 1, minHeight: 44, justifyContent: "center" }, children: replaceInput }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
344
|
+
leading,
|
|
345
|
+
/* @__PURE__ */ jsx(
|
|
346
|
+
TextInput,
|
|
347
|
+
{
|
|
348
|
+
testID: `${testID}-input`,
|
|
349
|
+
value,
|
|
350
|
+
onChangeText,
|
|
351
|
+
placeholder: internal ? current.label : placeholder,
|
|
352
|
+
placeholderTextColor: colors.tertiaryLabel,
|
|
353
|
+
accessibilityLabel: internal ? current.label : placeholder,
|
|
354
|
+
accessibilityState: editable ? void 0 : { disabled: true },
|
|
355
|
+
editable,
|
|
356
|
+
onSelectionChange,
|
|
357
|
+
multiline: true,
|
|
358
|
+
maxLength,
|
|
359
|
+
style: {
|
|
360
|
+
flex: 1,
|
|
361
|
+
minHeight: 44,
|
|
362
|
+
maxHeight,
|
|
363
|
+
textAlignVertical: "center",
|
|
364
|
+
paddingHorizontal: 14,
|
|
365
|
+
paddingTop: PAD_Y,
|
|
366
|
+
paddingBottom: PAD_Y,
|
|
367
|
+
borderRadius: 22,
|
|
368
|
+
fontSize: 17,
|
|
369
|
+
lineHeight: LINE,
|
|
370
|
+
color: colors.label,
|
|
371
|
+
backgroundColor: colors.surface,
|
|
372
|
+
borderWidth: internal ? 1 : 0,
|
|
373
|
+
borderColor: colors.warning,
|
|
374
|
+
opacity: editable ? 1 : 0.6
|
|
375
|
+
}
|
|
336
376
|
}
|
|
337
|
-
|
|
338
|
-
),
|
|
377
|
+
)
|
|
378
|
+
] }),
|
|
339
379
|
trailing,
|
|
340
|
-
sending ? /* @__PURE__ */ jsx(View, { testID: `${testID}-sending`, accessible: true, accessibilityLabel: sendingLabel, accessibilityLiveRegion: "polite", style: { width: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(ActivityIndicator, {}) }) : /* @__PURE__ */ jsx(
|
|
380
|
+
idle ? /* @__PURE__ */ jsx(View, { testID: `${testID}-idle`, style: { minWidth: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: idleAction }) : sending ? /* @__PURE__ */ jsx(View, { testID: `${testID}-sending`, accessible: true, accessibilityLabel: sendingLabel, accessibilityLiveRegion: "polite", style: { width: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(ActivityIndicator, {}) }) : /* @__PURE__ */ jsx(Animated.View, { style: sendPress.style, children: /* @__PURE__ */ jsx(
|
|
341
381
|
Pressable,
|
|
342
382
|
{
|
|
343
383
|
testID: `${testID}-send`,
|
|
344
384
|
accessibilityRole: "button",
|
|
345
385
|
accessibilityLabel: sendLabel,
|
|
346
386
|
accessibilityState: { disabled: !canSend },
|
|
387
|
+
accessibilityHint: actions ? sendActionsHint : void 0,
|
|
388
|
+
accessibilityActions: actions && canSend ? actions.map((a) => ({ name: a.id, label: a.label })) : void 0,
|
|
389
|
+
onAccessibilityAction: actions ? (e) => actions.find((a) => a.id === e.nativeEvent.actionName)?.onPress() : void 0,
|
|
390
|
+
onLongPress: actions ? () => openSendActions(actions, sendActionsTitle) : void 0,
|
|
347
391
|
disabled: !canSend,
|
|
348
|
-
|
|
392
|
+
onPressIn: sendPress.onPressIn,
|
|
393
|
+
onPressOut: sendPress.onPressOut,
|
|
394
|
+
onPress: () => {
|
|
395
|
+
sendPress.confirm();
|
|
396
|
+
onSend();
|
|
397
|
+
},
|
|
349
398
|
style: { minWidth: 44, height: 44, paddingHorizontal: hasIcon ? 0 : 14, borderRadius: 22, alignItems: "center", justifyContent: "center", backgroundColor: canSend ? colors.tint : colors.fill },
|
|
350
399
|
children: hasIcon ? /* @__PURE__ */ jsx(NativeIcon, { name: "arrow-up", size: 20, color: canSend ? colors.background : colors.tertiaryLabel }) : /* @__PURE__ */ jsx(NativeText, { preset: "label", className: canSend ? "text-primary-foreground" : void 0, style: canSend ? void 0 : { color: colors.tertiaryLabel }, children: sendLabel })
|
|
351
400
|
}
|
|
352
|
-
)
|
|
401
|
+
) })
|
|
353
402
|
] })
|
|
354
403
|
]
|
|
355
404
|
}
|
|
@@ -357,5 +406,5 @@ function NativeComposerBar({
|
|
|
357
406
|
}
|
|
358
407
|
|
|
359
408
|
export { NativeComposerBar, NativeThreadList, THREAD_AT_BOTTOM_POINTS, threadListMode, threadNearBottom };
|
|
360
|
-
//# sourceMappingURL=chunk-
|
|
361
|
-
//# sourceMappingURL=chunk-
|
|
409
|
+
//# sourceMappingURL=chunk-IXC3LO2K.js.map
|
|
410
|
+
//# sourceMappingURL=chunk-IXC3LO2K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/thread-list.tsx","../src/components/composer-bar.tsx"],"names":["useEffect","Platform","AccessibilityInfo","jsxs","View","jsx","Pressable","Fragment"],"mappings":";;;;;;;;AA+CA,IAAM,QAAA,GAAW,CAAC,IAAA,KAAkB,iBAAA,CAAyE,2BAA2B,IAAI,CAAA;AAGrI,IAAM,uBAAA,GAA0B;AAGvC,IAAM,WAAA,GAAc,GAAA;AAGb,SAAS,gBAAA,CAAiB,CAAA,EAAkB,KAAA,GAAQ,uBAAA,EAAkC;AAC3F,EAAA,OAAO,CAAA,CAAE,cAAc,CAAA,GAAI,CAAA,CAAE,kBAAkB,MAAA,IAAU,CAAA,CAAE,YAAY,MAAA,GAAS,KAAA;AAClF;AASO,SAAS,cAAA,CACd,KAAA,EACA,aAAA,EACA,cAAA,GAAiB,CAAA,EACoE;AACrF,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,MAAM,SAAA,GAAY,iBAAiB,CAAA,GAAI,IAAA,CAAK,IAAI,CAAA,EAAG,uBAAA,GAA0B,cAAc,CAAA,GAAI,GAAA;AAC/F,IAAA,OAAO;AAAA,MACL,aAAA,EAAe,KAAA;AAAA,MACf,8BAA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AAA,EAAW,MAAK,UAAA,EAAW,IAAA,EAAM,EAAA,EAAI,KAAA,EAAO,OAAA,GAAU,MAAA,CAAO,UAAA,GAAa,MAAA,CAAO,eAAe,CAAA,mBAEjGA,GAAAA,CAAC,UAAA,EAAA,EAAW,MAAA,EAAO,OAAA,EAAQ,SAAA,EAAW,OAAA,GAAU,4BAA4B,MAAA,EAAW,KAAA,EAAO,OAAA,GAAU,MAAA,GAAY,EAAE,KAAA,EAAO,MAAA,CAAO,aAAA,IACjI,QAAA,EAAA,SAAA,EACH;AAAA;AAAA,WAEJ,EACF;AAAA,SAAA,EAEJ;AAAA;AAAA;AAAA,GACF;AAEJ","file":"chunk-IXC3LO2K.js","sourcesContent":["/**\n * NativeThreadList — a conversation's list: oldest first, top to bottom (the\n * order VoiceOver reads), that opens at the newest row, follows new rows only\n * while you're at the bottom, keeps your place while earlier rows load at the\n * top, and can go to one row (a search result, the first unread).\n *\n * The atom under ThreadPage, and the one any app builds its own thread from:\n * it renders the rows it's given and never fetches. Earlier pages come from\n * `onLoadEarlier`, a row out of reach from `onLoadUntil(id)`.\n *\n * FlashList v2 (`GenesisModules.list`) when the app passed it: its chat mode\n * (`startRenderingFromBottom`, `autoscrollToBottomThreshold`, the first\n * visible row held when rows prepend). Without it, FlatList, which keeps its\n * place with `maintainVisibleContentPosition` (anchored past the header) and\n * follows the bottom by hand.\n *\n * Not inverted: in an inverted FlashList a new row at index 0 lands under the\n * composer, and VoiceOver reads each day's heading after its messages.\n *\n * Earlier rows load by themselves near the top, and the explicit \"Load\n * earlier\" button stays: VoiceOver can't reach rows a virtualized list hasn't\n * rendered. Going to a row waits for `loading`, loads until it's held,\n * scrolls to it (again after FlashList's own placement on open), highlights\n * it for two seconds and announces it. Reduce Motion scrolls without\n * animating.\n *\n * Promoted from genesis-chat's thread and its `useJumpToMessage` (G4); chat\n * moves onto it later.\n *\n * @stability Beta\n */\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState, type ComponentType, type ReactElement, type ReactNode } from \"react\";\nimport { AccessibilityInfo, FlatList, Platform, Pressable, View } from \"react-native\";\nimport { useGenesisModules } from \"../native-modules\";\nimport { useReducedMotion } from \"../hooks/use-reduced-motion\";\nimport { useThemeRoles } from \"../hooks/use-theme-roles\";\nimport { useThreadJump } from \"@marktiderman/genesis-core/conversation\";\nimport { NativeSkeleton } from \"./skeleton\";\nimport { NativeText } from \"./text\";\n\n/** The scroll event fields the list reads. */\ninterface ScrollMetrics {\n contentOffset: { y: number };\n contentSize: { height: number };\n layoutMeasurement: { height: number };\n}\n\nconst announce = (text: string) => (AccessibilityInfo as { announceForAccessibility?: (t: string) => void }).announceForAccessibility?.(text);\n\n/** Points from the bottom that still count as \"at the bottom\". */\nexport const THREAD_AT_BOTTOM_POINTS = 120;\n\n/** After the list scrolls itself (to the newest, to a row), how long its own scroll events don't count. */\nconst SETTLING_MS = 400;\n\n/** Whether a scroll position is at (or near) the bottom of its content. */\nexport function threadNearBottom(m: ScrollMetrics, slack = THREAD_AT_BOTTOM_POINTS): boolean {\n return m.contentOffset.y + m.layoutMeasurement.height >= m.contentSize.height - slack;\n}\n\n/**\n * How the list is set up. FlashList follows by itself, within\n * `THREAD_AT_BOTTOM_POINTS` of the bottom (its threshold is a fraction of the\n * viewport: a fifth until the viewport's height is known); FlatList keeps its\n * place on prepend, anchored on the first row past the header (index 1: the\n * header is child 0), and the list follows the bottom by hand.\n */\nexport function threadListMode(\n flash: boolean,\n reducedMotion: boolean,\n viewportHeight = 0,\n): { followsByHand: boolean; maintainVisibleContentPosition: Record<string, unknown> } {\n if (flash) {\n const threshold = viewportHeight > 0 ? Math.min(1, THREAD_AT_BOTTOM_POINTS / viewportHeight) : 0.2;\n return {\n followsByHand: false,\n maintainVisibleContentPosition: { startRenderingFromBottom: true, autoscrollToBottomThreshold: threshold, animateAutoScrollToBottom: !reducedMotion },\n };\n }\n return { followsByHand: true, maintainVisibleContentPosition: { minIndexForVisible: 1 } };\n}\n\nexport interface NativeThreadListHandle {\n /** Go to the newest row (after a send: what you send is what you look at next). */\n scrollToEnd: (options?: { animated?: boolean }) => void;\n}\n\n/** What `renderItem` is told about a row besides the row itself. */\nexport interface ThreadRowInfo {\n index: number;\n /** The row a jump just landed on, for two seconds. */\n highlighted: boolean;\n}\n\nexport interface NativeThreadListProps<T> {\n /** Oldest first. */\n data: readonly T[];\n /** A row's id. It must stay the same across refreshes (from a cache to the server), or rows jump. */\n keyExtractor: (row: T) => string;\n renderItem: (row: T, info: ThreadRowInfo) => ReactElement | null;\n /** Rows of different shapes recycle apart (FlashList): \"mine\", \"theirs\", \"event\". */\n getItemType?: (row: T) => string;\n /** The first page is loading: shows `loadingView` (a skeleton by default), and a jump waits. */\n loading?: boolean;\n loadingView?: ReactNode;\n /** There are earlier rows: loads them near the top, and shows the \"Load earlier\" button. */\n hasEarlier?: boolean;\n onLoadEarlier?: () => void;\n loadingEarlier?: boolean;\n earlierLabel?: string;\n /** Replaces the default \"Load earlier\" button. */\n renderEarlier?: (props: { loading: boolean; onPress: () => void; label: string; testID: string }) => ReactNode;\n /** Go to this row, loading earlier pages with `onLoadUntil` until it's here. A new id, or the same one after `null`, goes again. */\n jumpTo?: string | null;\n /**\n * The id `jumpTo` names a row by, when it isn't the row's key: a message keyed by the id the\n * phone gave it (so it keeps its row when the server's copy lands) and gone to by the server's\n * id. `null` for a row that can't be gone to (a day heading). `keyExtractor` by default.\n * Pass a stable function (module scope, or `useCallback`): a new one each render re-renders every row.\n */\n jumpId?: (row: T) => string | null | undefined;\n /** Load earlier pages until the row is held; resolve false when it can't be found. */\n onLoadUntil?: (id: string) => Promise<boolean>;\n /** What VoiceOver says on arriving at `jumpTo`. */\n jumpAnnouncement?: (row: T) => string;\n /** The row couldn't be found (deleted, out of reach). The list goes back to the newest row first. */\n onJumpFailed?: (id: string) => void;\n /** Whether the reader is at the bottom, as it changes (to show a \"new messages\" pill, say). */\n onAtBottomChange?: (atBottom: boolean) => void;\n /** Above the first row, before the \"Load earlier\" button: what the thread is about. */\n header?: ReactNode;\n /** Under the last row: who is typing, a \"Sending…\" line. */\n footer?: ReactNode;\n /** Shown instead of the rows when there are none. */\n empty?: ReactNode;\n testID?: string;\n}\n\n/** The FlatList and FlashList v2 props the thread passes. */\ninterface ThreadListComponentProps {\n ref?: unknown;\n data: readonly unknown[];\n renderItem: (info: { item: unknown; index: number }) => ReactElement | null;\n keyExtractor: (row: unknown) => string;\n getItemType?: (row: unknown) => string;\n extraData?: unknown;\n onStartReached?: () => void;\n onStartReachedThreshold?: number;\n ListHeaderComponent?: ReactElement | null;\n ListFooterComponent?: ReactElement | null;\n keyboardShouldPersistTaps?: \"handled\";\n keyboardDismissMode?: \"interactive\" | \"on-drag\";\n contentInsetAdjustmentBehavior?: \"automatic\";\n contentContainerStyle?: Record<string, unknown>;\n maintainVisibleContentPosition?: Record<string, unknown>;\n onScroll?: (e: { nativeEvent: ScrollMetrics }) => void;\n onScrollBeginDrag?: () => void;\n scrollEventThrottle?: number;\n onContentSizeChange?: () => void;\n onLayout?: () => void;\n onScrollToIndexFailed?: (info: { index: number; averageItemLength: number }) => void;\n accessibilityRole?: \"list\";\n testID?: string;\n}\n\ninterface ListRef {\n scrollToEnd?: (o?: { animated?: boolean }) => void;\n scrollToIndex?: (o: { index: number; animated?: boolean; viewPosition?: number }) => void;\n scrollToOffset?: (o: { offset: number; animated?: boolean }) => void;\n}\n\nfunction NativeThreadListInner<T>(props: NativeThreadListProps<T>, ref: React.ForwardedRef<NativeThreadListHandle>) {\n const {\n data,\n keyExtractor,\n renderItem,\n getItemType,\n loading = false,\n loadingView,\n hasEarlier = false,\n onLoadEarlier,\n loadingEarlier = false,\n earlierLabel = \"Load earlier messages\",\n renderEarlier,\n jumpTo,\n jumpId,\n onLoadUntil,\n jumpAnnouncement,\n onJumpFailed,\n onAtBottomChange,\n footer,\n header,\n empty,\n testID = \"thread-list\",\n } = props;\n const genesis = useGenesisModules();\n const reducedMotion = useReducedMotion();\n const List = (genesis.list ?? FlatList) as unknown as ComponentType<ThreadListComponentProps>;\n const [viewport, setViewport] = useState(0);\n const mode = threadListMode(Boolean(genesis.list), reducedMotion, viewport);\n // The last position the list reported, to re-check \"at the bottom\" after it moves itself.\n const metrics = useRef<ScrollMetrics | null>(null);\n const recheck = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(() => () => {\n if (recheck.current) clearTimeout(recheck.current);\n }, []);\n const listRef = useRef<ListRef | null>(null);\n // At the bottom (or not yet scrolled): new rows and a shorter list keep it there.\n const atBottom = useRef(true);\n // FlatList opens at the top and is moved down a frame later: until then the top isn't \"reached\".\n const placed = useRef(!mode.followsByHand);\n // While the list scrolls itself, its own scroll events don't move \"at the bottom\".\n const settlingUntil = useRef(0);\n const timers = useRef(new Set<ReturnType<typeof setTimeout>>());\n const later = useCallback((fn: () => void, ms: number) => {\n const t = setTimeout(() => {\n timers.current.delete(t);\n fn();\n }, ms);\n timers.current.add(t);\n }, []);\n useEffect(() => {\n const pending = timers.current;\n return () => pending.forEach(clearTimeout);\n }, []);\n const idOf = jumpId ?? keyExtractor;\n const latest = useRef({ data, idOf, jumpAnnouncement, onJumpFailed, onAtBottomChange });\n latest.current = { data, idOf, jumpAnnouncement, onJumpFailed, onAtBottomChange };\n // The row a jump names, by `jumpId` (the key by default).\n const indexOf = useCallback((id: string) => latest.current.data.findIndex((row) => latest.current.idOf(row) === id), []);\n\n const setAtBottom = useCallback((v: boolean) => {\n if (atBottom.current === v) return;\n atBottom.current = v;\n latest.current.onAtBottomChange?.(v);\n }, []);\n\n const toBottom = useCallback(\n (animated: boolean) => {\n settlingUntil.current = Date.now() + SETTLING_MS;\n const go = (a: boolean) => listRef.current?.scrollToEnd?.({ animated: a && !reducedMotion });\n requestAnimationFrame(() => {\n go(animated);\n placed.current = true;\n });\n // Once more after a new row has its size (FlashList measures it after the first pass).\n if (animated) later(() => go(true), 180);\n },\n [later, reducedMotion],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n scrollToEnd: (options) => {\n setAtBottom(true);\n toBottom(options?.animated ?? true);\n },\n }),\n [setAtBottom, toBottom],\n );\n\n // Going to a row: by id, so a page loading in between can't send it to the wrong row.\n const jumpTries = useRef<{ id: string; tries: number } | null>(null);\n const scrollToRow = useCallback(\n (id: string) => {\n const scroll = () => {\n const at = indexOf(id);\n if (at < 0) return;\n // Each try moves the list again: its events don't count until this one settles.\n settlingUntil.current = Date.now() + SETTLING_MS;\n listRef.current?.scrollToIndex?.({ index: at, animated: !reducedMotion, viewPosition: 0.5 });\n };\n jumpTries.current = { id, tries: 0 };\n settlingUntil.current = Date.now() + SETTLING_MS;\n requestAnimationFrame(scroll);\n // Once more after the first layout: on open, FlashList's start-at-the-bottom placement comes after\n // the first frame and would win, leaving the thread at the bottom.\n later(scroll, 250);\n },\n [indexOf, later, reducedMotion],\n );\n const has = useCallback((id: string) => indexOf(id) >= 0, [indexOf]);\n // `has` must change when the rows do, so the jump looks again.\n const hasNow = useMemo(() => (id: string) => has(id), [has, data]); // eslint-disable-line react-hooks/exhaustive-deps\n const { highlightedId, jumping } = useThreadJump({\n target: jumpTo,\n has: hasNow,\n loading,\n loadUntil: onLoadUntil,\n scrollTo: scrollToRow,\n onStart: () => {\n setAtBottom(false);\n placed.current = true;\n },\n onLanded: (id) => {\n // A jump to a row already at the bottom moves nothing, so no scroll event says so: look once it settles.\n // Not before the list's own scrolling has settled (a second try extends it): mid-way, it can still read as the bottom.\n if (recheck.current) clearTimeout(recheck.current);\n const look = () => {\n const wait = settlingUntil.current - Date.now();\n if (wait > 0) {\n recheck.current = setTimeout(look, wait + 50);\n return;\n }\n if (metrics.current && threadNearBottom(metrics.current)) setAtBottom(true);\n };\n recheck.current = setTimeout(look, SETTLING_MS + 50);\n const at = indexOf(id);\n const said = at >= 0 ? latest.current.jumpAnnouncement?.(latest.current.data[at]!) : undefined;\n if (said) announce(said);\n },\n onGone: (id) => {\n // Back to where the thread opens: the newest rows.\n setAtBottom(true);\n toBottom(false);\n latest.current.onJumpFailed?.(id);\n },\n });\n\n const loadEarlier = useCallback(() => {\n if (placed.current && !jumping && hasEarlier && !loadingEarlier) onLoadEarlier?.();\n }, [hasEarlier, jumping, loadingEarlier, onLoadEarlier]);\n\n const earlierProps = { loading: loadingEarlier, onPress: () => onLoadEarlier?.(), label: earlierLabel, testID: `${testID}-earlier` };\n const listHeader = (\n <View>\n {header}\n {hasEarlier && onLoadEarlier ? (renderEarlier ? renderEarlier(earlierProps) : <DefaultEarlier {...earlierProps} />) : null}\n </View>\n );\n\n const renderListItem = useCallback(\n ({ item, index }: { item: unknown; index: number }) => renderItem(item as T, { index, highlighted: highlightedId !== null && idOf(item as T) === highlightedId }),\n [highlightedId, idOf, renderItem],\n );\n const listKey = useCallback((row: unknown) => keyExtractor(row as T), [keyExtractor]);\n const listItemType = useMemo(() => (getItemType ? (row: unknown) => getItemType(row as T) : undefined), [getItemType]);\n const onScroll = useCallback(\n (e: { nativeEvent: ScrollMetrics }) => {\n metrics.current = { contentOffset: { y: e.nativeEvent.contentOffset.y }, contentSize: { height: e.nativeEvent.contentSize.height }, layoutMeasurement: { height: e.nativeEvent.layoutMeasurement.height } };\n const height = e.nativeEvent.layoutMeasurement.height;\n setViewport((v) => (Math.abs(v - height) < 1 ? v : height));\n // The list's own scroll (to the newest, to a row) isn't the reader moving. Going to a row starts\n // at the bottom, so its first events say \"at the bottom\": taken, that turned following back on,\n // and FlatList's next layout scrolled to the end, away from the row. After a jump, onLanded\n // looks again once it has settled.\n if (Date.now() < settlingUntil.current) return;\n setAtBottom(threadNearBottom(e.nativeEvent));\n },\n [setAtBottom],\n );\n // The reader's touch ends the list's own scroll: from here their scrolling counts, even mid-jump.\n const onScrollBeginDrag = useCallback(() => {\n settlingUntil.current = 0;\n }, []);\n const onScrollToIndexFailed = useCallback(\n ({ index, averageItemLength }: { index: number; averageItemLength: number }) => {\n // FlatList hasn't measured that far up yet: get near it, then try again by id (three times at most).\n listRef.current?.scrollToOffset?.({ offset: Math.max(0, index * averageItemLength - 200), animated: false });\n const target = jumpTries.current;\n if (!target || target.tries >= 3) return;\n target.tries += 1;\n later(() => {\n const at = indexOf(target.id);\n if (at < 0) return;\n settlingUntil.current = Date.now() + SETTLING_MS;\n listRef.current?.scrollToIndex?.({ index: at, animated: !reducedMotion, viewPosition: 0.5 });\n }, 250);\n },\n [indexOf, later, reducedMotion],\n );\n const follow = useCallback(() => {\n if (atBottom.current && !jumping) toBottom(false);\n }, [jumping, toBottom]);\n\n if (loading && data.length === 0) {\n return (\n <View testID={`${testID}-loading`} accessible accessibilityLabel=\"Loading\" style={{ flex: 1, justifyContent: \"flex-end\", padding: 16, gap: 10 }}>\n {loadingView ?? <DefaultLoading />}\n </View>\n );\n }\n\n if (data.length === 0 && empty) {\n return (\n <View testID={testID} style={{ flex: 1, justifyContent: \"center\" }}>\n {listHeader}\n {empty}\n </View>\n );\n }\n\n return (\n <List\n ref={listRef}\n testID={testID}\n accessibilityRole=\"list\"\n data={data as readonly unknown[]}\n renderItem={renderListItem}\n keyExtractor={listKey}\n getItemType={listItemType}\n extraData={highlightedId}\n onStartReached={loadEarlier}\n onStartReachedThreshold={0.5}\n keyboardShouldPersistTaps=\"handled\"\n keyboardDismissMode={Platform.select({ ios: \"interactive\" as const, default: \"on-drag\" as const })}\n contentInsetAdjustmentBehavior=\"automatic\"\n contentContainerStyle={{ paddingVertical: 8, paddingHorizontal: 12 }}\n maintainVisibleContentPosition={mode.maintainVisibleContentPosition}\n scrollEventThrottle={32}\n onScroll={onScroll}\n onScrollBeginDrag={onScrollBeginDrag}\n onScrollToIndexFailed={onScrollToIndexFailed}\n {...(mode.followsByHand ? { onContentSizeChange: follow, onLayout: follow } : {})}\n ListHeaderComponent={listHeader}\n ListFooterComponent={footer ? <View>{footer}</View> : null}\n />\n );\n}\n\n/** A conversation's list. See the module docs. */\nexport const NativeThreadList = forwardRef(NativeThreadListInner) as <T>(\n props: NativeThreadListProps<T> & { ref?: React.Ref<NativeThreadListHandle> },\n) => ReactElement | null;\n\nfunction DefaultEarlier({ loading, label, onPress, testID }: { loading: boolean; label: string; onPress: () => void; testID: string }) {\n const colors = useThemeRoles();\n return (\n <View style={{ alignItems: \"center\", paddingVertical: 12 }}>\n {loading ? (\n <View testID={`${testID}-loading`} accessible accessibilityLabel={label} accessibilityState={{ busy: true }} style={{ gap: 8, alignItems: \"center\" }}>\n <NativeSkeleton width={180} height={14} />\n <NativeSkeleton width={120} height={14} />\n </View>\n ) : (\n <Pressable testID={testID} accessibilityRole=\"button\" accessibilityLabel={label} onPress={onPress} style={{ minHeight: 44, justifyContent: \"center\", paddingHorizontal: 16 }}>\n <NativeText preset=\"label\" style={{ color: colors.tint }}>\n {label}\n </NativeText>\n </Pressable>\n )}\n </View>\n );\n}\n\nfunction DefaultLoading() {\n return (\n <>\n <NativeSkeleton width={200} height={36} className=\"rounded-2xl\" />\n <View style={{ alignItems: \"flex-end\" }}>\n <NativeSkeleton width={160} height={36} className=\"rounded-2xl\" />\n </View>\n <NativeSkeleton width={240} height={36} className=\"rounded-2xl\" />\n </>\n );\n}\n","/**\n * NativeComposerBar — the bar you write a message in: an input that grows\n * with what you type (up to `maxLines`, then scrolls), a send button, and\n * slots beside and above it. ThreadPage's composer; chat, comments and AI\n * prompts build on it too.\n *\n * - **Modes:** `modes` with a `tone` each (\"Reply\" / \"Internal note\"). The\n * picker sits above the input, and an `internal` tone edges the bar and\n * the input in the theme's `warning` role, so a staff-only note never\n * reads like a reply (the send button keeps the tint: text on `warning`\n * would fail contrast). The row it sends carries the same tone (ThreadPage).\n * - **Slots:** `leading` (attach), `trailing` (beside send: an emoji button),\n * `above` (a reply preview, attachments waiting to send), `idleAction` (in\n * Send's place while there's nothing to send: a hold-to-record mic) and\n * `replaceInput` (instead of `leading` and the input: a recording's\n * waveform). Attachments with no text: pass `empty={false}`.\n * - **More ways to send:** `sendActions` (\"Schedule\"). Touch and hold Send:\n * one action runs, several open a menu. Each is also an accessibility\n * action on Send.\n * - **Keyboard:** the bar doesn't move itself. Put it under a keyboard-aware\n * container (ThreadPage does, with `GenesisModules.keyboardAvoidingView`);\n * the list above it dismisses the keyboard interactively on a drag.\n * - **Accessibility:** send and the mode picker are 44pt targets, the input\n * is labelled by its placeholder (and says when it writes an internal\n * note), Sending is announced, and the input stays editable while a\n * message sends (the keyboard stays up).\n *\n * @stability Beta\n */\nimport { useEffect, type ReactNode } from \"react\";\nimport { AccessibilityInfo, ActivityIndicator, Alert, Animated, Dimensions, Platform, Pressable, TextInput, View } from \"react-native\";\nimport type { ComposerMode } from \"@marktiderman/genesis-core/conversation\";\nimport { useThemeRoles } from \"../hooks/use-theme-roles\";\nimport { useGenesisModules } from \"../native-modules\";\nimport { usePressFeedback } from \"../hooks/use-press-feedback\";\nimport { NativeIcon } from \"./icon\";\nimport { NativeText } from \"./text\";\n\nexport type { ComposerMode, ComposerTone } from \"@marktiderman/genesis-core/conversation\";\n\nexport interface NativeComposerBarProps {\n value: string;\n onChangeText: (text: string) => void;\n onSend: () => void;\n /** A send is in flight: the button spins and won't send twice. */\n sending?: boolean;\n /** Turns sending off (besides a blank value). */\n disabled?: boolean;\n placeholder?: string;\n /** Send's label, to VoiceOver. Default \"Send\". */\n sendLabel?: string;\n sendingLabel?: string;\n maxLength?: number;\n /** The input grows to this many lines, then scrolls. Default 6. */\n maxLines?: number;\n /** Ways to send (\"Reply\", \"Internal note\"). Two or more show the picker. */\n modes?: readonly ComposerMode[];\n /** The chosen mode's id. Default the first. */\n mode?: string;\n onModeChange?: (id: string) => void;\n leading?: ReactNode;\n trailing?: ReactNode;\n above?: ReactNode;\n /**\n * Whether there's nothing to send. By default, a blank `value`; pass `false` when attachments\n * are waiting and no text is needed.\n */\n empty?: boolean;\n /** Takes Send's place (the same 44pt spot) while there's nothing to send and nothing sending: a hold-to-record mic. */\n idleAction?: ReactNode;\n /** Shown instead of `leading` and the input (a recording in progress). Label it yourself: it's one region to VoiceOver. */\n replaceInput?: ReactNode;\n /** Touch and hold Send for these (one runs straight away; several open a menu). Each is also an accessibility action on Send. */\n sendActions?: readonly ComposerSendAction[];\n /** Title of the menu when there are several `sendActions`. */\n sendActionsTitle?: string;\n /** The hint on Send when it has `sendActions`. Default \"Touch and hold for more options\". */\n sendActionsHint?: string;\n /** Passed to the input (to insert at the cursor, say). */\n onSelectionChange?: (e: { nativeEvent: { selection: { start: number; end: number } } }) => void;\n /** The input takes text (default). When false, nothing sends and the input reads as disabled. */\n editable?: boolean;\n testID?: string;\n}\n\n/** Another way to send (touch and hold Send). */\nexport interface ComposerSendAction {\n id: string;\n label: string;\n onPress: () => void;\n destructive?: boolean;\n}\n\nfunction openSendActions(actions: readonly ComposerSendAction[], title: string | undefined) {\n if (actions.length === 1) return actions[0]!.onPress();\n Alert.alert(title ?? \"\", undefined, [\n ...actions.map((a) => ({ text: a.label, style: a.destructive ? (\"destructive\" as const) : (\"default\" as const), onPress: a.onPress })),\n { text: \"Cancel\", style: \"cancel\" as const },\n ]);\n}\n\nconst LINE = 22;\nconst PAD_Y = 8;\n\nexport function NativeComposerBar({\n value,\n onChangeText,\n onSend,\n sending = false,\n disabled = false,\n placeholder = \"Message\",\n sendLabel = \"Send\",\n sendingLabel = \"Sending\",\n maxLength,\n maxLines = 6,\n modes,\n mode,\n onModeChange,\n leading,\n trailing,\n above,\n empty,\n idleAction,\n replaceInput,\n sendActions,\n sendActionsTitle,\n sendActionsHint = \"Touch and hold for more options\",\n onSelectionChange,\n editable = true,\n testID = \"composer\",\n}: NativeComposerBarProps) {\n const colors = useThemeRoles();\n const { symbol, icons } = useGenesisModules();\n // No icon module: the arrow would draw nothing, so the button says its label.\n const hasIcon = Boolean(symbol || icons?.[\"arrow-up\"]);\n const current = modes?.find((m) => m.id === mode) ?? modes?.[0];\n const internal = current?.tone === \"internal\";\n const blank = empty ?? !value.trim();\n const canSend = !blank && !disabled && !sending && editable;\n const actions = sendActions?.length ? sendActions : null;\n const idle = idleAction != null && blank && !sending;\n const sendPress = usePressFeedback({ haptic: \"light\", scale: 0.9, disabled: !canSend });\n // A multiline input grows with its text by itself; this caps it, after which it scrolls.\n // Lines grow with the person's text size (Dynamic Type, Android font scale).\n const fontScale = Dimensions.get(\"window\").fontScale || 1;\n const maxHeight = Math.ceil(LINE * fontScale) * maxLines + PAD_Y * 2;\n // Say \"Sending\" on iOS too (a live region is Android-only).\n useEffect(() => {\n if (sending && Platform.OS === \"ios\") (AccessibilityInfo as { announceForAccessibility?: (t: string) => void }).announceForAccessibility?.(sendingLabel);\n }, [sending, sendingLabel]);\n\n return (\n <View\n testID={testID}\n style={{\n paddingHorizontal: 12,\n paddingTop: 8,\n paddingBottom: 8,\n gap: 6,\n backgroundColor: colors.groupedBackground,\n borderTopWidth: internal ? 2 : 0,\n borderTopColor: colors.warning,\n }}\n >\n {modes && modes.length > 1 ? (\n <View testID={`${testID}-modes`} accessibilityRole=\"tablist\" style={{ flexDirection: \"row\", gap: 4 }}>\n {modes.map((m) => {\n const on = m.id === current?.id;\n return (\n <Pressable\n key={m.id}\n testID={`${testID}-mode-${m.id}`}\n accessibilityRole=\"tab\"\n accessibilityState={{ selected: on }}\n accessibilityLabel={m.label}\n onPress={() => onModeChange?.(m.id)}\n style={{\n minHeight: 44,\n justifyContent: \"center\",\n paddingHorizontal: 12,\n borderRadius: 22,\n backgroundColor: on ? colors.fill : \"transparent\",\n borderWidth: m.tone === \"internal\" ? 1 : 0,\n borderColor: colors.warning,\n }}\n >\n <NativeText preset=\"label\" style={{ color: on ? colors.label : colors.secondaryLabel }}>\n {m.label}\n </NativeText>\n </Pressable>\n );\n })}\n </View>\n ) : null}\n {above}\n <View style={{ flexDirection: \"row\", alignItems: \"flex-end\", gap: 8 }}>\n {replaceInput != null ? (\n <View style={{ flex: 1, minHeight: 44, justifyContent: \"center\" }}>{replaceInput}</View>\n ) : (\n <>\n {leading}\n <TextInput\n testID={`${testID}-input`}\n value={value}\n onChangeText={onChangeText}\n placeholder={internal ? current!.label : placeholder}\n placeholderTextColor={colors.tertiaryLabel as string}\n accessibilityLabel={internal ? current!.label : placeholder}\n accessibilityState={editable ? undefined : { disabled: true }}\n editable={editable}\n onSelectionChange={onSelectionChange}\n multiline\n maxLength={maxLength}\n style={{\n flex: 1,\n minHeight: 44,\n maxHeight,\n textAlignVertical: \"center\",\n paddingHorizontal: 14,\n paddingTop: PAD_Y,\n paddingBottom: PAD_Y,\n borderRadius: 22,\n fontSize: 17,\n lineHeight: LINE,\n color: colors.label as string,\n backgroundColor: colors.surface,\n borderWidth: internal ? 1 : 0,\n borderColor: colors.warning,\n opacity: editable ? 1 : 0.6,\n }}\n />\n </>\n )}\n {trailing}\n {idle ? (\n <View testID={`${testID}-idle`} style={{ minWidth: 44, height: 44, alignItems: \"center\", justifyContent: \"center\" }}>\n {idleAction}\n </View>\n ) : sending ? (\n <View testID={`${testID}-sending`} accessible accessibilityLabel={sendingLabel} accessibilityLiveRegion=\"polite\" style={{ width: 44, height: 44, alignItems: \"center\", justifyContent: \"center\" }}>\n <ActivityIndicator />\n </View>\n ) : (\n <Animated.View style={sendPress.style}>\n <Pressable\n testID={`${testID}-send`}\n accessibilityRole=\"button\"\n accessibilityLabel={sendLabel}\n accessibilityState={{ disabled: !canSend }}\n accessibilityHint={actions ? sendActionsHint : undefined}\n accessibilityActions={actions && canSend ? actions.map((a) => ({ name: a.id, label: a.label })) : undefined}\n onAccessibilityAction={actions ? (e) => actions.find((a) => a.id === e.nativeEvent.actionName)?.onPress() : undefined}\n onLongPress={actions ? () => openSendActions(actions, sendActionsTitle) : undefined}\n disabled={!canSend}\n onPressIn={sendPress.onPressIn}\n onPressOut={sendPress.onPressOut}\n onPress={() => {\n sendPress.confirm();\n onSend();\n }}\n style={{ minWidth: 44, height: 44, paddingHorizontal: hasIcon ? 0 : 14, borderRadius: 22, alignItems: \"center\", justifyContent: \"center\", backgroundColor: canSend ? colors.tint : colors.fill }}\n >\n {hasIcon ? (\n <NativeIcon name=\"arrow-up\" size={20} color={canSend ? colors.background : colors.tertiaryLabel} />\n ) : (\n <NativeText preset=\"label\" className={canSend ? \"text-primary-foreground\" : undefined} style={canSend ? undefined : { color: colors.tertiaryLabel }}>\n {sendLabel}\n </NativeText>\n )}\n </Pressable>\n </Animated.View>\n )}\n </View>\n </View>\n );\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { useGenesisModules } from './chunk-
|
|
2
|
-
import { useThemeRoles, useReducedMotion } from './chunk-4OQOJ2OC.js';
|
|
1
|
+
import { useThemeRoles, useGenesisModules, useReducedMotion } from './chunk-RTYO24SC.js';
|
|
3
2
|
import { cn } from './chunk-OHZD7KRO.js';
|
|
4
3
|
import { __require } from './chunk-DGUM43GV.js';
|
|
5
4
|
import { View, Text, ScrollView, Dimensions, Platform, Modal, Pressable, KeyboardAvoidingView, TextInput, Image, Switch, FlatList, AccessibilityInfo } from 'react-native';
|
|
@@ -1309,5 +1308,5 @@ function NativeGalleryGrid({
|
|
|
1309
1308
|
}
|
|
1310
1309
|
|
|
1311
1310
|
export { NativeAlert, NativeAlertDescription, NativeAlertTitle, NativeAvatar, NativeBanner, NativeCard, NativeCardContent, NativeCardDescription, NativeCardFooter, NativeCardHeader, NativeCardTitle, NativeCheckbox, NativeDatePicker, NativeGalleryGrid, NativeImage, NativeInlineAlert, NativeLabel, NativeSearchBar, NativeSegmentedControl, NativeSelect, NativeSelectContent, NativeSelectItem, NativeSelectTrigger, NativeSeparator, NativeSheet, NativeSheetProvider, NativeSheetScrollView, NativeSwitch, NativeTextarea, NativeTimePicker, alertVariants };
|
|
1312
|
-
//# sourceMappingURL=chunk-
|
|
1313
|
-
//# sourceMappingURL=chunk-
|
|
1311
|
+
//# sourceMappingURL=chunk-KH2RVAI5.js.map
|
|
1312
|
+
//# sourceMappingURL=chunk-KH2RVAI5.js.map
|