@marktiderman/genesis-ui-native 3.5.1 → 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 +115 -7
- package/dist/{chunk-ONH2PCGH.js → chunk-3KFUS7O6.js} +9 -15
- package/dist/chunk-3KFUS7O6.js.map +1 -0
- package/dist/{chunk-LBVD7XXL.js → chunk-7NDKIIOT.js} +627 -20
- package/dist/chunk-7NDKIIOT.js.map +1 -0
- package/dist/chunk-CAI7LGN6.js +39 -0
- package/dist/chunk-CAI7LGN6.js.map +1 -0
- package/dist/{chunk-ABVSSJNT.js → chunk-GBNIBHSU.js} +198 -168
- package/dist/chunk-GBNIBHSU.js.map +1 -0
- package/dist/chunk-IXC3LO2K.js +410 -0
- package/dist/chunk-IXC3LO2K.js.map +1 -0
- package/dist/{chunk-GHYUNNNU.js → chunk-KH2RVAI5.js} +174 -93
- package/dist/chunk-KH2RVAI5.js.map +1 -0
- package/dist/{chunk-6KWEAGRD.js → chunk-O4BMDV7I.js} +110 -17
- package/dist/chunk-O4BMDV7I.js.map +1 -0
- package/dist/chunk-RTYO24SC.js +105 -0
- package/dist/chunk-RTYO24SC.js.map +1 -0
- package/dist/{chunk-D5RKSPMH.js → chunk-YWDDDYDI.js} +4 -3
- package/dist/chunk-YWDDDYDI.js.map +1 -0
- package/dist/components/index.d.ts +382 -10
- package/dist/components/index.js +6 -5
- package/dist/data/index.d.ts +68 -4
- package/dist/data/index.js +231 -30
- package/dist/data/index.js.map +1 -1
- package/dist/hooks/index.d.ts +90 -2
- package/dist/hooks/index.js +3 -3
- package/dist/icons/lucide.d.ts +1 -1
- package/dist/icons/lucide.js +7 -1
- package/dist/icons/lucide.js.map +1 -1
- package/dist/{inbox-page-BEarNEIP.d.ts → inbox-page-B7_Oi2fS.d.ts} +2 -44
- package/dist/index.d.ts +8 -5
- package/dist/index.js +9 -8
- package/dist/layouts/index.d.ts +40 -51
- package/dist/layouts/index.js +6 -4
- package/dist/{native-modules-PwnGltOU.d.ts → native-modules-DEJJQhDx.d.ts} +55 -1
- package/package.json +101 -4
- package/src/__tests__/doctor-rules.test.ts +87 -0
- package/src/__tests__/native-modules-lists.test.tsx +1 -0
- package/src/components/__tests__/button-haptic.test.tsx +52 -0
- package/src/components/__tests__/composer-bar.test.tsx +79 -0
- package/src/components/__tests__/gallery-card.test.tsx +59 -0
- package/src/components/__tests__/gallery-grid.test.tsx +160 -0
- package/src/components/__tests__/lightbox-resnap.test.tsx +50 -0
- package/src/components/__tests__/lightbox-zoom.test.ts +33 -0
- package/src/components/__tests__/lightbox.test.tsx +141 -0
- package/src/components/__tests__/live-indicator.test.tsx +72 -0
- package/src/components/__tests__/rating.test.tsx +82 -0
- package/src/components/__tests__/thread-list.test.tsx +219 -0
- package/src/components/button.tsx +18 -1
- package/src/components/composer-bar.tsx +276 -0
- package/src/components/drawer.tsx +15 -9
- package/src/components/gallery-card.tsx +109 -0
- package/src/components/gallery-grid.tsx +285 -0
- package/src/components/gallery-layout.ts +2 -0
- package/src/components/gallery-types.ts +2 -0
- package/src/components/index.ts +44 -0
- package/src/components/lightbox-zoom.tsx +282 -0
- package/src/components/lightbox.tsx +342 -0
- package/src/components/live-indicator.tsx +139 -0
- package/src/components/rating.tsx +128 -0
- package/src/components/skeleton.tsx +9 -4
- package/src/components/thread-list.tsx +457 -0
- package/src/components/toast.tsx +7 -4
- package/src/data/NativeConflictSheet.tsx +181 -0
- package/src/data/NativeResourceForm.tsx +15 -1
- package/src/data/index.ts +2 -0
- package/src/data/resource-view/NativeRecordView.tsx +85 -8
- package/src/data/resource-view/NativeResourceView.tsx +79 -32
- package/src/data/resource-view/__tests__/native-record-view.test.tsx +95 -1
- package/src/data/resource-view/__tests__/native-resource-gallery.test.tsx +125 -0
- package/src/hooks/__tests__/use-haptics.test.tsx +146 -0
- package/src/hooks/__tests__/use-motion.test.tsx +106 -0
- package/src/hooks/__tests__/use-thread-jump.test.tsx +88 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/use-haptics.ts +64 -0
- package/src/hooks/use-motion.ts +128 -0
- package/src/hooks/use-press-feedback.ts +87 -0
- package/src/hooks/use-thread-jump.ts +110 -0
- package/src/icon-names.ts +6 -0
- package/src/icons/lucide.ts +12 -0
- package/src/layouts/__tests__/inbox-page.test.tsx +6 -0
- package/src/layouts/__tests__/thread-page.test.tsx +114 -14
- package/src/layouts/inbox-page.tsx +6 -55
- package/src/layouts/index.ts +2 -0
- package/src/layouts/thread-page.tsx +326 -262
- package/src/native-modules.tsx +20 -2
- package/dist/chunk-6KWEAGRD.js.map +0 -1
- package/dist/chunk-7PCWEY6R.js +0 -27
- package/dist/chunk-7PCWEY6R.js.map +0 -1
- package/dist/chunk-ABVSSJNT.js.map +0 -1
- package/dist/chunk-D5RKSPMH.js.map +0 -1
- package/dist/chunk-GHYUNNNU.js.map +0 -1
- package/dist/chunk-LBVD7XXL.js.map +0 -1
- package/dist/chunk-ONH2PCGH.js.map +0 -1
- package/dist/chunk-Z3AQYVUA.js +0 -36
- package/dist/chunk-Z3AQYVUA.js.map +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useMotion, useHaptics } from './chunk-RTYO24SC.js';
|
|
2
|
+
import { useRef, useCallback, useEffect, useMemo } from 'react';
|
|
3
|
+
import { Animated } from 'react-native';
|
|
4
|
+
|
|
5
|
+
function usePressFeedback({ haptic = false, scale = 0.97, dimTo = 0.6, disabled = false, level } = {}) {
|
|
6
|
+
const motion = useMotion(level ? { level } : {});
|
|
7
|
+
const play = useHaptics();
|
|
8
|
+
const value = useRef(new Animated.Value(1)).current;
|
|
9
|
+
const reduced = motion.reduced;
|
|
10
|
+
const to = useCallback(
|
|
11
|
+
(target, held) => {
|
|
12
|
+
if (held || reduced) {
|
|
13
|
+
Animated.timing(value, { toValue: target, duration: motion.duration.press, useNativeDriver: true }).start();
|
|
14
|
+
} else {
|
|
15
|
+
const s = motion.spring.snappy;
|
|
16
|
+
Animated.spring(value, { toValue: target, damping: s.damping, stiffness: s.stiffness, mass: s.mass, useNativeDriver: true }).start();
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
[value, motion, reduced]
|
|
20
|
+
);
|
|
21
|
+
const onPressIn = useCallback(() => {
|
|
22
|
+
if (disabled) return;
|
|
23
|
+
to(reduced ? dimTo : scale, true);
|
|
24
|
+
if (haptic === "select") play("select");
|
|
25
|
+
}, [disabled, reduced, dimTo, scale, to, haptic, play]);
|
|
26
|
+
const onPressOut = useCallback(() => to(1, false), [to]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (disabled) value.setValue(1);
|
|
29
|
+
}, [disabled, value]);
|
|
30
|
+
const confirm = useCallback(() => {
|
|
31
|
+
if (!disabled && haptic && haptic !== "select") play(haptic);
|
|
32
|
+
}, [disabled, haptic, play]);
|
|
33
|
+
const style = useMemo(() => disabled ? {} : reduced ? { opacity: value } : { transform: [{ scale: value }] }, [disabled, reduced, value]);
|
|
34
|
+
return { onPressIn, onPressOut, confirm, style };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { usePressFeedback };
|
|
38
|
+
//# sourceMappingURL=chunk-CAI7LGN6.js.map
|
|
39
|
+
//# sourceMappingURL=chunk-CAI7LGN6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-press-feedback.ts"],"names":[],"mappings":";;;;AAgDO,SAAS,gBAAA,CAAiB,EAAE,MAAA,GAAS,KAAA,EAAO,KAAA,GAAQ,IAAA,EAAM,KAAA,GAAQ,GAAA,EAAK,QAAA,GAAW,KAAA,EAAO,KAAA,EAAM,GAA0B,EAAC,EAAkB;AACjJ,EAAA,MAAM,SAAS,SAAA,CAAU,KAAA,GAAQ,EAAE,KAAA,EAAM,GAAI,EAAE,CAAA;AAC/C,EAAA,MAAM,OAAO,UAAA,EAAW;AACxB,EAAA,MAAM,QAAQ,MAAA,CAAO,IAAI,SAAS,KAAA,CAAM,CAAC,CAAC,CAAA,CAAE,OAAA;AAC5C,EAAA,MAAM,UAAU,MAAA,CAAO,OAAA;AAEvB,EAAA,MAAM,EAAA,GAAK,WAAA;AAAA,IACT,CAAC,QAAgB,IAAA,KAAkB;AACjC,MAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,QAAA,QAAA,CAAS,MAAA,CAAO,KAAA,EAAO,EAAE,OAAA,EAAS,MAAA,EAAQ,QAAA,EAAU,MAAA,CAAO,QAAA,CAAS,KAAA,EAAO,eAAA,EAAiB,IAAA,EAAM,EAAE,KAAA,EAAM;AAAA,MAC5G,CAAA,MAAO;AACL,QAAA,MAAM,CAAA,GAAI,OAAO,MAAA,CAAO,MAAA;AACxB,QAAA,QAAA,CAAS,OAAO,KAAA,EAAO,EAAE,SAAS,MAAA,EAAQ,OAAA,EAAS,EAAE,OAAA,EAAS,SAAA,EAAW,CAAA,CAAE,SAAA,EAAW,MAAM,CAAA,CAAE,IAAA,EAAM,iBAAiB,IAAA,EAAM,EAAE,KAAA,EAAM;AAAA,MACrI;AAAA,IACF,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,MAAA,EAAQ,OAAO;AAAA,GACzB;AAEA,EAAA,MAAM,SAAA,GAAY,YAAY,MAAM;AAClC,IAAA,IAAI,QAAA,EAAU;AACd,IAAA,EAAA,CAAG,OAAA,GAAU,KAAA,GAAQ,KAAA,EAAO,IAAI,CAAA;AAChC,IAAA,IAAI,MAAA,KAAW,QAAA,EAAU,IAAA,CAAK,QAAQ,CAAA;AAAA,EACxC,CAAA,EAAG,CAAC,QAAA,EAAU,OAAA,EAAS,OAAO,KAAA,EAAO,EAAA,EAAI,MAAA,EAAQ,IAAI,CAAC,CAAA;AAItD,EAAA,MAAM,UAAA,GAAa,YAAY,MAAM,EAAA,CAAG,GAAG,KAAK,CAAA,EAAG,CAAC,EAAE,CAAC,CAAA;AACvD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,QAAA,EAAU,KAAA,CAAM,QAAA,CAAS,CAAC,CAAA;AAAA,EAChC,CAAA,EAAG,CAAC,QAAA,EAAU,KAAK,CAAC,CAAA;AAEpB,EAAA,MAAM,OAAA,GAAU,YAAY,MAAM;AAChC,IAAA,IAAI,CAAC,QAAA,IAAY,MAAA,IAAU,MAAA,KAAW,QAAA,OAAe,MAAM,CAAA;AAAA,EAC7D,CAAA,EAAG,CAAC,QAAA,EAAU,MAAA,EAAQ,IAAI,CAAC,CAAA;AAE3B,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,MAAO,QAAA,GAAW,KAAK,OAAA,GAAU,EAAE,OAAA,EAAS,KAAA,EAAM,GAAI,EAAE,WAAW,CAAC,EAAE,KAAA,EAAO,KAAA,EAAO,CAAA,IAAM,CAAC,QAAA,EAAU,OAAA,EAAS,KAAK,CAAC,CAAA;AAE1I,EAAA,OAAO,EAAE,SAAA,EAAW,UAAA,EAAY,OAAA,EAAS,KAAA,EAAM;AACjD","file":"chunk-CAI7LGN6.js","sourcesContent":["/**\n * usePressFeedback: how a pressable answers a touch, the same for buttons, rows and cards. It\n * shrinks a little while held (on the motion tokens' `press` duration) and springs back on release\n * (`snappy`), and can play a haptic when the press lands. Under Reduce Motion (or brand motion\n * `none`) it dims instead of moving.\n *\n * const press = usePressFeedback({ haptic: \"light\" });\n * <Pressable onPress={save} onPressIn={press.onPressIn} onPressOut={press.onPressOut}>\n * <Animated.View style={press.style}>…</Animated.View>\n * </Pressable>\n *\n * The haptic plays on `onPressIn` for `select` (a tick under the finger, as iOS does). Any other\n * kind plays when you call `press.confirm()` from `onPress`, so a press cancelled by scrolling\n * stays quiet.\n *\n * Built on React Native's `Animated`, so it works without Reanimated.\n *\n * @stability Beta\n */\nimport { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { Animated } from \"react-native\";\nimport { useMotion, type UseMotionOptions } from \"./use-motion\";\nimport { useHaptics, type HapticKind } from \"./use-haptics\";\n\ntype AnimatedValue = InstanceType<typeof Animated.Value>;\n\nexport interface PressFeedbackOptions {\n /** A haptic when the press counts (`confirm()`), or `select` as a tick on press-in. Default none. */\n haptic?: HapticKind | false;\n /** How far it shrinks while held. Default 0.97. */\n scale?: number;\n /** Under Reduce Motion: how far it dims while held. Default 0.6. */\n dimTo?: number;\n /** No feedback (a disabled button). */\n disabled?: boolean;\n /** The brand's motion level, as `useMotion` takes it. */\n level?: UseMotionOptions[\"level\"];\n}\n\nexport interface PressFeedback {\n onPressIn: () => void;\n onPressOut: () => void;\n /** Call from `onPress`: plays the haptic for a press that counted. */\n confirm: () => void;\n /** For an `Animated.View` around the pressable's content. */\n style: { transform?: { scale: AnimatedValue }[]; opacity?: AnimatedValue };\n}\n\nexport function usePressFeedback({ haptic = false, scale = 0.97, dimTo = 0.6, disabled = false, level }: PressFeedbackOptions = {}): PressFeedback {\n const motion = useMotion(level ? { level } : {});\n const play = useHaptics();\n const value = useRef(new Animated.Value(1)).current;\n const reduced = motion.reduced;\n\n const to = useCallback(\n (target: number, held: boolean) => {\n if (held || reduced) {\n Animated.timing(value, { toValue: target, duration: motion.duration.press, useNativeDriver: true }).start();\n } else {\n const s = motion.spring.snappy;\n Animated.spring(value, { toValue: target, damping: s.damping, stiffness: s.stiffness, mass: s.mass, useNativeDriver: true }).start();\n }\n },\n [value, motion, reduced],\n );\n\n const onPressIn = useCallback(() => {\n if (disabled) return;\n to(reduced ? dimTo : scale, true);\n if (haptic === \"select\") play(\"select\");\n }, [disabled, reduced, dimTo, scale, to, haptic, play]);\n\n // Always let go, even if the pressable was disabled mid-press (a send that started), and start\n // from rest whenever it's disabled, so it never comes back still shrunk.\n const onPressOut = useCallback(() => to(1, false), [to]);\n useEffect(() => {\n if (disabled) value.setValue(1);\n }, [disabled, value]);\n\n const confirm = useCallback(() => {\n if (!disabled && haptic && haptic !== \"select\") play(haptic);\n }, [disabled, haptic, play]);\n\n const style = useMemo(() => (disabled ? {} : reduced ? { opacity: value } : { transform: [{ scale: value }] }), [disabled, reduced, value]);\n\n return { onPressIn, onPressOut, confirm, style };\n}\n"]}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { NativeThreadList, NativeComposerBar } from './chunk-IXC3LO2K.js';
|
|
2
|
+
import { composeHeaderOptions, ScreenContainer, NavBarSaveButton } from './chunk-3KFUS7O6.js';
|
|
3
|
+
import { NativeText, NativeListItem, NativeButton, NativeSectionListHeader, NativeEmptyState, NativeInput } from './chunk-O4BMDV7I.js';
|
|
4
|
+
import { useThemeRoles, useGenesisModules, useThemeMode } from './chunk-RTYO24SC.js';
|
|
4
5
|
import { cn } from './chunk-OHZD7KRO.js';
|
|
5
|
-
import { createContext, Fragment, useState, useMemo, createElement, useContext, useCallback, useRef, useEffect } from 'react';
|
|
6
|
+
import { createContext, memo, Fragment, useState, useMemo, createElement, useContext, useCallback, useRef, useEffect } from 'react';
|
|
6
7
|
import { renderSlot } from '@marktiderman/genesis-core/slots';
|
|
7
|
-
import {
|
|
8
|
+
import { View, Pressable, Platform, StyleSheet, Alert, KeyboardAvoidingView, ScrollView, RefreshControl, SectionList, Image, Text, AccessibilityInfo } from 'react-native';
|
|
8
9
|
import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
9
10
|
import { SafeAreaInsetsContext, SafeAreaView } from 'react-native-safe-area-context';
|
|
11
|
+
import { readReceiptFor, DEFAULT_THREAD_LABELS, formatMessageTime } from '@marktiderman/genesis-core/conversation';
|
|
12
|
+
export { readReceiptFor } from '@marktiderman/genesis-core/conversation';
|
|
10
13
|
|
|
11
14
|
function getSettingsPageStackOptions(props) {
|
|
12
15
|
return composeHeaderOptions({
|
|
@@ -542,7 +545,7 @@ function UnreadDot({
|
|
|
542
545
|
}
|
|
543
546
|
);
|
|
544
547
|
}
|
|
545
|
-
var
|
|
548
|
+
var announce = (text) => AccessibilityInfo.announceForAccessibility?.(text);
|
|
546
549
|
function getThreadPageStackOptions(props) {
|
|
547
550
|
return composeHeaderOptions({
|
|
548
551
|
headerTitle: props.headerTitle ?? "Conversation",
|
|
@@ -554,17 +557,18 @@ function getThreadPageStackOptions(props) {
|
|
|
554
557
|
});
|
|
555
558
|
}
|
|
556
559
|
var toDate = (value) => typeof value === "string" ? new Date(value) : value;
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
560
|
+
var NO_SLOTS2 = {};
|
|
561
|
+
var NO_SLOT_PROPS = {};
|
|
562
|
+
var messageKey = (m) => m.id;
|
|
563
|
+
var messageType = (m) => m.kind === "event" ? "event" : m.mine ? "mine" : "theirs";
|
|
564
|
+
var warnedNoKeyboardModule = false;
|
|
565
|
+
function warnNoKeyboardModule() {
|
|
566
|
+
const dev = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process !== "undefined" && process.env.NODE_ENV !== "production";
|
|
567
|
+
if (!dev || warnedNoKeyboardModule) return;
|
|
568
|
+
warnedNoKeyboardModule = true;
|
|
569
|
+
console.warn(
|
|
570
|
+
"[genesis] ThreadPage: react-native-keyboard-controller is set up (keyboardScroll) but GenesisModules.keyboardAvoidingView isn't, so the composer falls back to React Native's KeyboardAvoidingView. Pass keyboard-controller's KeyboardAvoidingView as `keyboardAvoidingView` in your Genesis modules."
|
|
571
|
+
);
|
|
568
572
|
}
|
|
569
573
|
function ThreadPage({
|
|
570
574
|
messages,
|
|
@@ -577,117 +581,186 @@ function ThreadPage({
|
|
|
577
581
|
onLoadEarlier,
|
|
578
582
|
loadingEarlier = false,
|
|
579
583
|
earlierLabel = "Load earlier messages",
|
|
584
|
+
firstUnreadId,
|
|
585
|
+
jumpTo,
|
|
586
|
+
onLoadUntil,
|
|
587
|
+
onJumpFailed,
|
|
588
|
+
loading = false,
|
|
589
|
+
updating = false,
|
|
590
|
+
keyboardVerticalOffset,
|
|
580
591
|
emptyTitle,
|
|
581
592
|
emptyBody,
|
|
582
|
-
formatTime =
|
|
593
|
+
formatTime = formatMessageTime,
|
|
583
594
|
labels: labelOverrides,
|
|
584
|
-
slots =
|
|
585
|
-
slotProps =
|
|
595
|
+
slots = NO_SLOTS2,
|
|
596
|
+
slotProps = NO_SLOT_PROPS,
|
|
586
597
|
testID = "thread-page"
|
|
587
598
|
}) {
|
|
588
599
|
const colors = useThemeRoles();
|
|
589
|
-
const
|
|
590
|
-
const
|
|
600
|
+
const genesis = useGenesisModules();
|
|
601
|
+
const listRef = useRef(null);
|
|
602
|
+
const [atBottom, setAtBottom] = useState(true);
|
|
591
603
|
const receiptFor = readReceiptFor(messages, readAt);
|
|
592
|
-
const
|
|
593
|
-
const
|
|
604
|
+
const labelsKey = labelOverrides ? JSON.stringify(labelOverrides) : "";
|
|
605
|
+
const labels = useMemo(() => ({ ...DEFAULT_THREAD_LABELS, ...labelOverrides }), [labelsKey]);
|
|
606
|
+
const keyboardScroll = useKeyboardScroll();
|
|
594
607
|
useEffect(() => {
|
|
595
|
-
|
|
596
|
-
}, [
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
slotProps.
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
...message,
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
608
|
+
if (keyboardScroll && !genesis.keyboardAvoidingView) warnNoKeyboardModule();
|
|
609
|
+
}, [keyboardScroll, genesis.keyboardAvoidingView]);
|
|
610
|
+
useEffect(() => {
|
|
611
|
+
if (updating && Platform.OS === "ios") announce(labels.updating);
|
|
612
|
+
}, [updating]);
|
|
613
|
+
const renderRow = useCallback(
|
|
614
|
+
(message, { highlighted }) => {
|
|
615
|
+
const timeLabel = formatTime(toDate(message.timestamp));
|
|
616
|
+
const divider = message.id === firstUnreadId ? renderSlot(DefaultUnreadDivider, slots.unreadDivider, { label: labels.newMessages, testID: `${testID}-unread` }, slotProps.unreadDivider) : null;
|
|
617
|
+
if (message.kind === "event") {
|
|
618
|
+
return /* @__PURE__ */ jsxs(View, { style: { paddingVertical: 3 }, children: [
|
|
619
|
+
divider,
|
|
620
|
+
renderSlot(DefaultEvent, slots.event, { ...message, testID: `${testID}-event-${message.id}`, timeLabel }, slotProps.event)
|
|
621
|
+
] });
|
|
622
|
+
}
|
|
623
|
+
return /* @__PURE__ */ jsxs(View, { style: { paddingVertical: 3 }, children: [
|
|
624
|
+
divider,
|
|
625
|
+
renderSlot(
|
|
626
|
+
DefaultMessage,
|
|
627
|
+
slots.message,
|
|
628
|
+
{ ...message, testID: `${testID}-message-${message.id}`, timeLabel, showReadReceipt: message.id === receiptFor, labels, highlighted },
|
|
629
|
+
slotProps.message
|
|
630
|
+
),
|
|
631
|
+
message.attachments?.length ? /* @__PURE__ */ jsx(View, { style: { flexDirection: "row", flexWrap: "wrap", gap: 6, justifyContent: message.mine ? "flex-end" : "flex-start", marginTop: 4 }, children: message.attachments.map((attachment) => /* @__PURE__ */ jsx(View, { children: renderSlot(
|
|
632
|
+
DefaultAttachment,
|
|
633
|
+
slots.attachment,
|
|
634
|
+
{ ...attachment, mine: message.mine, testID: `${testID}-attachment-${attachment.id}` },
|
|
635
|
+
slotProps.attachment
|
|
636
|
+
) }, attachment.id)) }) : null,
|
|
637
|
+
message.id === receiptFor ? renderSlot(DefaultReadReceipt, slots.readReceipt, { label: readLabel, testID: `${testID}-read-receipt` }, slotProps.readReceipt) : null
|
|
638
|
+
] });
|
|
639
|
+
},
|
|
640
|
+
[firstUnreadId, formatTime, receiptFor, readLabel, slots, slotProps, testID, labels]
|
|
641
|
+
);
|
|
642
|
+
const send = composer ? () => {
|
|
643
|
+
composer.onSend();
|
|
644
|
+
listRef.current?.scrollToEnd({ animated: true });
|
|
645
|
+
} : void 0;
|
|
632
646
|
const footer = composer ? renderSlot(
|
|
633
647
|
DefaultComposer,
|
|
634
648
|
slots.composer,
|
|
635
649
|
{
|
|
636
650
|
...composer,
|
|
651
|
+
sendingLabel: composer.sendingLabel ?? labels.sending,
|
|
652
|
+
onSend: send,
|
|
637
653
|
testID: `${testID}-composer`,
|
|
638
654
|
accessory: renderSlot(Nothing, slots.composerAccessory, { testID: `${testID}-composer-accessory` }, slotProps.composerAccessory)
|
|
639
655
|
},
|
|
640
656
|
slotProps.composer
|
|
641
657
|
) : closedNotice ? /* @__PURE__ */ jsx(NativeText, { testID: `${testID}-closed`, style: { textAlign: "center", padding: 16, color: colors.secondaryLabel, fontSize: 13, lineHeight: 18 }, children: closedNotice }) : null;
|
|
642
|
-
const
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
658
|
+
const listHeader = header ?? renderSlot(Nothing, slots.header, { testID: `${testID}-header` }, slotProps.header);
|
|
659
|
+
const KeyboardAvoiding = genesis.keyboardAvoidingView ?? KeyboardAvoidingView;
|
|
660
|
+
const keyboardProps = genesis.keyboardAvoidingView ? { behavior: "translate-with-padding", automaticOffset: true, keyboardVerticalOffset: keyboardVerticalOffset ?? 0 } : { behavior: Platform.OS === "ios" ? "padding" : "height", keyboardVerticalOffset: keyboardVerticalOffset ?? (Platform.OS === "ios" ? 100 : 0) };
|
|
661
|
+
return /* @__PURE__ */ jsxs(SafeAreaView, { testID, edges: ["left", "right", "bottom"], style: { flex: 1, backgroundColor: colors.groupedBackground }, children: [
|
|
662
|
+
renderSlot(Nothing, slots.headerRegion, { testID: `${testID}-header-region` }, slotProps.headerRegion),
|
|
663
|
+
updating ? /* @__PURE__ */ jsx(View, { testID: `${testID}-updating`, accessibilityLiveRegion: "polite", accessible: true, accessibilityLabel: labels.updating, children: /* @__PURE__ */ jsx(NativeText, { style: { textAlign: "center", paddingVertical: 4, color: colors.tertiaryLabel, fontSize: 12, lineHeight: 16 }, children: labels.updating }) }) : null,
|
|
664
|
+
/* @__PURE__ */ jsxs(KeyboardAvoiding, { testID: `${testID}-keyboard`, style: { flex: 1 }, ...keyboardProps, children: [
|
|
665
|
+
/* @__PURE__ */ jsxs(View, { style: { flex: 1 }, children: [
|
|
666
|
+
/* @__PURE__ */ jsx(
|
|
667
|
+
NativeThreadList,
|
|
668
|
+
{
|
|
669
|
+
ref: listRef,
|
|
670
|
+
testID: `${testID}-messages`,
|
|
671
|
+
data: messages,
|
|
672
|
+
keyExtractor: messageKey,
|
|
673
|
+
getItemType: messageType,
|
|
674
|
+
renderItem: renderRow,
|
|
675
|
+
loading,
|
|
676
|
+
hasEarlier,
|
|
677
|
+
onLoadEarlier,
|
|
678
|
+
loadingEarlier,
|
|
679
|
+
earlierLabel,
|
|
680
|
+
renderEarlier: (p) => renderSlot(DefaultEarlierButton, slots.earlier, { ...p, testID: `${testID}-earlier` }, slotProps.earlier),
|
|
681
|
+
jumpTo,
|
|
682
|
+
onLoadUntil,
|
|
683
|
+
jumpAnnouncement: (m) => [m.mine ? labels.you : m.authorName, m.body].filter(Boolean).join(", "),
|
|
684
|
+
onJumpFailed: onJumpFailed ?? (() => announce(labels.messageGone)),
|
|
685
|
+
onAtBottomChange: setAtBottom,
|
|
686
|
+
header: listHeader,
|
|
687
|
+
empty: renderSlot(
|
|
688
|
+
DefaultEmpty2,
|
|
689
|
+
slots.empty,
|
|
690
|
+
{ title: emptyTitle ?? "No messages yet", body: emptyBody ?? "Write the first one below.", testID: `${testID}-empty` },
|
|
691
|
+
slotProps.empty
|
|
692
|
+
)
|
|
693
|
+
}
|
|
694
|
+
),
|
|
695
|
+
!atBottom && messages.length > 0 ? /* @__PURE__ */ jsx(
|
|
696
|
+
Pressable,
|
|
697
|
+
{
|
|
698
|
+
testID: `${testID}-jump-latest`,
|
|
699
|
+
accessibilityRole: "button",
|
|
700
|
+
accessibilityLabel: labels.jumpToLatest,
|
|
701
|
+
onPress: () => listRef.current?.scrollToEnd({ animated: true }),
|
|
702
|
+
style: { position: "absolute", bottom: 8, alignSelf: "center", minHeight: 44, justifyContent: "center", paddingHorizontal: 16, borderRadius: 22, backgroundColor: colors.surface },
|
|
703
|
+
children: /* @__PURE__ */ jsx(NativeText, { preset: "label", style: { color: colors.tint }, children: labels.jumpToLatest })
|
|
704
|
+
}
|
|
705
|
+
) : null
|
|
706
|
+
] }),
|
|
657
707
|
footer
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
return /* @__PURE__ */ jsx(SafeAreaView, { testID, edges: ["left", "right", "bottom"], style: page, children: /* @__PURE__ */ jsxs(KeyboardAvoidingView, { testID: `${testID}-kav`, style: { flex: 1 }, behavior: Platform.OS === "ios" ? "padding" : void 0, keyboardVerticalOffset: Platform.OS === "ios" ? 100 : 0, children: [
|
|
661
|
-
/* @__PURE__ */ jsx(
|
|
662
|
-
ScrollView,
|
|
663
|
-
{
|
|
664
|
-
ref: scrollRef,
|
|
665
|
-
testID: `${testID}-scroll`,
|
|
666
|
-
keyboardShouldPersistTaps: "handled",
|
|
667
|
-
contentInsetAdjustmentBehavior: "automatic",
|
|
668
|
-
contentContainerStyle: { flexGrow: 1 },
|
|
669
|
-
onContentSizeChange,
|
|
670
|
-
children: body
|
|
671
|
-
}
|
|
672
|
-
),
|
|
673
|
-
footer
|
|
674
|
-
] }) });
|
|
708
|
+
] })
|
|
709
|
+
] });
|
|
675
710
|
}
|
|
676
711
|
function Nothing(_props) {
|
|
677
712
|
return null;
|
|
678
713
|
}
|
|
679
|
-
function
|
|
680
|
-
|
|
714
|
+
function DefaultEarlierButton({ loading, onPress, label, testID }) {
|
|
715
|
+
const colors = useThemeRoles();
|
|
716
|
+
return /* @__PURE__ */ jsx(Pressable, { testID, accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { busy: loading }, onPress, disabled: loading, style: { minHeight: 44, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(NativeText, { preset: "label", style: { color: colors.tint }, children: label }) });
|
|
681
717
|
}
|
|
682
718
|
function DefaultEmpty2({ title, body, testID }) {
|
|
683
719
|
return /* @__PURE__ */ jsx(NativeEmptyState, { variant: "first-run", title, body, testID });
|
|
684
720
|
}
|
|
721
|
+
function DefaultUnreadDivider({ label, testID }) {
|
|
722
|
+
const colors = useThemeRoles();
|
|
723
|
+
return /* @__PURE__ */ jsxs(View, { testID, accessible: true, accessibilityRole: "header", accessibilityLabel: label, style: { flexDirection: "row", alignItems: "center", gap: 8, paddingVertical: 8 }, children: [
|
|
724
|
+
/* @__PURE__ */ jsx(View, { style: { flex: 1, height: 1, backgroundColor: colors.tint } }),
|
|
725
|
+
/* @__PURE__ */ jsx(NativeText, { style: { color: colors.tint, fontSize: 12, lineHeight: 16 }, children: label }),
|
|
726
|
+
/* @__PURE__ */ jsx(View, { style: { flex: 1, height: 1, backgroundColor: colors.tint } })
|
|
727
|
+
] });
|
|
728
|
+
}
|
|
729
|
+
function DefaultEvent({ body, timeLabel, testID }) {
|
|
730
|
+
const colors = useThemeRoles();
|
|
731
|
+
return /* @__PURE__ */ jsx(View, { testID, accessible: true, accessibilityLabel: `${body}, ${timeLabel}`, style: { alignSelf: "center", paddingHorizontal: 12, paddingVertical: 4, borderRadius: 12, backgroundColor: colors.fill }, children: /* @__PURE__ */ jsx(NativeText, { style: { color: colors.secondaryLabel, fontSize: 12, lineHeight: 16, textAlign: "center" }, children: body }) });
|
|
732
|
+
}
|
|
685
733
|
var MINE_TEXT = { fontSize: 17, lineHeight: 22 };
|
|
686
|
-
function
|
|
734
|
+
function stateLabel(message) {
|
|
735
|
+
const { labels } = message;
|
|
736
|
+
switch (message.status) {
|
|
737
|
+
case "sending":
|
|
738
|
+
return labels.sending;
|
|
739
|
+
case "pending":
|
|
740
|
+
return labels.pending;
|
|
741
|
+
case "paused":
|
|
742
|
+
return labels.paused;
|
|
743
|
+
case "failed":
|
|
744
|
+
return labels.notSent;
|
|
745
|
+
case "conflict":
|
|
746
|
+
return labels.conflict;
|
|
747
|
+
default:
|
|
748
|
+
return null;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
var DefaultMessage = memo(function DefaultMessage2(message) {
|
|
687
752
|
const colors = useThemeRoles();
|
|
688
|
-
const failed = message.status === "failed";
|
|
689
753
|
const { labels } = message;
|
|
690
|
-
const
|
|
754
|
+
const broken = message.status === "failed" || message.status === "conflict";
|
|
755
|
+
const waiting = message.status === "sending" || message.status === "pending" || message.status === "paused";
|
|
756
|
+
const internal = message.tone === "internal";
|
|
757
|
+
const state = stateLabel(message);
|
|
758
|
+
const label = [message.mine ? labels.you : message.authorName ?? "", internal ? labels.internal : null, message.body, message.timeLabel, state].filter(Boolean).join(", ");
|
|
759
|
+
const canDiscard = Boolean(message.onDiscard) && (broken || message.status === "pending" || message.status === "paused");
|
|
760
|
+
const actions = [
|
|
761
|
+
...broken && message.onRetry ? [{ name: "activate", label: labels.retryHint }] : [],
|
|
762
|
+
...canDiscard ? [{ name: "discard", label: labels.discard }] : []
|
|
763
|
+
];
|
|
691
764
|
return /* @__PURE__ */ jsxs(View, { style: { alignItems: message.mine ? "flex-end" : "flex-start" }, children: [
|
|
692
765
|
!message.mine && message.authorName ? /* @__PURE__ */ jsx(NativeText, { style: { marginLeft: 12, marginBottom: 2, color: colors.secondaryLabel, fontSize: 12, lineHeight: 16 }, children: message.authorName }) : null,
|
|
693
766
|
/* @__PURE__ */ jsx(
|
|
@@ -695,90 +768,47 @@ function DefaultMessage(message) {
|
|
|
695
768
|
{
|
|
696
769
|
testID: message.testID,
|
|
697
770
|
accessible: true,
|
|
771
|
+
accessibilityRole: broken && message.onRetry ? "button" : void 0,
|
|
698
772
|
accessibilityLabel: label,
|
|
699
|
-
accessibilityHint:
|
|
700
|
-
|
|
773
|
+
accessibilityHint: broken && message.onRetry ? labels.retryHint : void 0,
|
|
774
|
+
accessibilityActions: actions.length ? actions : void 0,
|
|
775
|
+
onAccessibilityAction: (e) => {
|
|
776
|
+
if (e.nativeEvent.actionName === "discard" && canDiscard) message.onDiscard?.();
|
|
777
|
+
else if (e.nativeEvent.actionName === "activate" && broken) message.onRetry?.();
|
|
778
|
+
},
|
|
779
|
+
onPress: broken ? message.onRetry : void 0,
|
|
701
780
|
style: {
|
|
702
781
|
maxWidth: "80%",
|
|
703
782
|
paddingHorizontal: 14,
|
|
704
783
|
paddingVertical: 8,
|
|
705
784
|
borderRadius: 18,
|
|
706
|
-
backgroundColor: message.mine ? colors.tint : colors.surface,
|
|
707
|
-
|
|
785
|
+
backgroundColor: internal ? colors.surface : message.mine ? colors.tint : colors.surface,
|
|
786
|
+
borderWidth: internal || message.highlighted ? 2 : 0,
|
|
787
|
+
borderColor: internal ? colors.warning : colors.tint,
|
|
788
|
+
opacity: waiting ? 0.6 : 1
|
|
708
789
|
},
|
|
709
|
-
children: /* @__PURE__ */ jsx(NativeText, { className: message.mine ? "text-primary-foreground" : void 0, style: message.mine ? MINE_TEXT : { ...MINE_TEXT, color: colors.label }, children: message.body })
|
|
790
|
+
children: /* @__PURE__ */ jsx(NativeText, { className: message.mine && !internal ? "text-primary-foreground" : void 0, style: message.mine && !internal ? MINE_TEXT : { ...MINE_TEXT, color: colors.label }, children: message.body })
|
|
710
791
|
}
|
|
711
792
|
),
|
|
712
|
-
/* @__PURE__ */
|
|
713
|
-
NativeText,
|
|
714
|
-
{
|
|
715
|
-
|
|
716
|
-
style: { marginTop: 2, marginHorizontal: 12, color: failed ? colors.destructive : colors.tertiaryLabel, fontSize: 11, lineHeight: 14 },
|
|
717
|
-
children: failed ? labels.notSent : message.timeLabel
|
|
718
|
-
}
|
|
719
|
-
)
|
|
793
|
+
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "center", gap: 8, marginTop: 2, marginHorizontal: 12 }, children: [
|
|
794
|
+
/* @__PURE__ */ jsx(NativeText, { testID: `${message.testID}-time`, style: { color: broken ? colors.destructive : colors.tertiaryLabel, fontSize: 11, lineHeight: 14 }, children: state ?? message.timeLabel }),
|
|
795
|
+
canDiscard ? /* @__PURE__ */ jsx(Pressable, { testID: `${message.testID}-discard`, accessibilityRole: "button", accessibilityLabel: labels.discard, onPress: message.onDiscard, hitSlop: { top: 15, bottom: 15, left: 12, right: 12 }, children: /* @__PURE__ */ jsx(NativeText, { style: { color: colors.secondaryLabel, fontSize: 11, lineHeight: 14 }, children: labels.discard }) }) : null
|
|
796
|
+
] })
|
|
720
797
|
] });
|
|
721
|
-
}
|
|
722
|
-
function DefaultAttachment({ uri, width, height, accessibilityLabel, onPress, testID }) {
|
|
798
|
+
});
|
|
799
|
+
function DefaultAttachment({ id, uri, width, height, accessibilityLabel, onPress, testID }) {
|
|
800
|
+
const { image: ExpoImage } = useGenesisModules();
|
|
723
801
|
const ratio = width && height ? width / height : 0.6;
|
|
724
802
|
const w = 140;
|
|
725
|
-
|
|
803
|
+
const style = { width: w, height: Math.round(w / ratio), borderRadius: 12 };
|
|
804
|
+
return /* @__PURE__ */ jsx(Pressable, { testID, accessibilityRole: "image", accessibilityLabel: accessibilityLabel ?? "Attachment", onPress, disabled: !onPress, children: ExpoImage ? /* @__PURE__ */ jsx(ExpoImage, { source: { uri }, style, contentFit: "cover", recyclingKey: id }) : /* @__PURE__ */ jsx(Image, { source: { uri }, style, resizeMode: "cover" }, uri) });
|
|
726
805
|
}
|
|
727
806
|
function DefaultReadReceipt({ label, testID }) {
|
|
728
807
|
const colors = useThemeRoles();
|
|
729
808
|
return /* @__PURE__ */ jsx(NativeText, { testID, style: { alignSelf: "flex-end", marginHorizontal: 12, color: colors.secondaryLabel, fontSize: 11, lineHeight: 14 }, children: label });
|
|
730
809
|
}
|
|
731
|
-
function DefaultComposer({
|
|
732
|
-
|
|
733
|
-
onChangeText,
|
|
734
|
-
onSend,
|
|
735
|
-
sending = false,
|
|
736
|
-
placeholder = "Message",
|
|
737
|
-
sendLabel = "Send",
|
|
738
|
-
disabled = false,
|
|
739
|
-
maxLength,
|
|
740
|
-
testID,
|
|
741
|
-
accessory
|
|
742
|
-
}) {
|
|
743
|
-
const colors = useThemeRoles();
|
|
744
|
-
const blank = !value.trim();
|
|
745
|
-
return /* @__PURE__ */ jsxs(
|
|
746
|
-
View,
|
|
747
|
-
{
|
|
748
|
-
testID,
|
|
749
|
-
style: { flexDirection: "row", alignItems: "flex-end", gap: 8, paddingHorizontal: 12, paddingTop: 8, paddingBottom: 8, backgroundColor: colors.groupedBackground },
|
|
750
|
-
children: [
|
|
751
|
-
accessory,
|
|
752
|
-
/* @__PURE__ */ jsx(
|
|
753
|
-
TextInput,
|
|
754
|
-
{
|
|
755
|
-
testID: `${testID}-input`,
|
|
756
|
-
value,
|
|
757
|
-
onChangeText,
|
|
758
|
-
placeholder,
|
|
759
|
-
placeholderTextColor: colors.tertiaryLabel,
|
|
760
|
-
accessibilityLabel: placeholder,
|
|
761
|
-
multiline: true,
|
|
762
|
-
maxLength,
|
|
763
|
-
editable: !sending,
|
|
764
|
-
style: {
|
|
765
|
-
flex: 1,
|
|
766
|
-
minHeight: 36,
|
|
767
|
-
maxHeight: 120,
|
|
768
|
-
paddingHorizontal: 14,
|
|
769
|
-
paddingTop: 8,
|
|
770
|
-
paddingBottom: 8,
|
|
771
|
-
borderRadius: 18,
|
|
772
|
-
fontSize: 17,
|
|
773
|
-
color: colors.label,
|
|
774
|
-
backgroundColor: colors.surface
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
),
|
|
778
|
-
sending ? /* @__PURE__ */ jsx(View, { style: { height: 36, justifyContent: "center", paddingHorizontal: 8 }, children: /* @__PURE__ */ jsx(ActivityIndicator, { testID: `${testID}-sending`, accessibilityLabel: "Sending" }) }) : /* @__PURE__ */ jsx(NativeButton, { size: "sm", onPress: onSend, disabled: disabled || blank, testID: `${testID}-send`, children: sendLabel })
|
|
779
|
-
]
|
|
780
|
-
}
|
|
781
|
-
);
|
|
810
|
+
function DefaultComposer({ accessory, testID, ...composer }) {
|
|
811
|
+
return /* @__PURE__ */ jsx(NativeComposerBar, { ...composer, leading: accessory, testID });
|
|
782
812
|
}
|
|
783
813
|
function AuthBranding({
|
|
784
814
|
logo,
|
|
@@ -1118,6 +1148,6 @@ function googleProvider({ onPress, label = "Continue with Google", icon, disable
|
|
|
1118
1148
|
return { id: "google", label, icon, onPress, disabled };
|
|
1119
1149
|
}
|
|
1120
1150
|
|
|
1121
|
-
export { AppleSignInButton, AuthBranding, AuthForm, AuthScreen, ForgotPasswordLink, KEYBOARD_TOOLBAR_HEIGHT, KeyboardScrollProvider, NotificationsPage, SettingsPage, SettingsSubPage, SocialAuthRow, ThreadPage, appleProvider, confirmDiscardChanges, defaultStickyHeaderOffset, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions, getThreadPageStackOptions, googleProvider, iosCompactNavigationBarHeight,
|
|
1122
|
-
//# sourceMappingURL=chunk-
|
|
1123
|
-
//# sourceMappingURL=chunk-
|
|
1151
|
+
export { AppleSignInButton, AuthBranding, AuthForm, AuthScreen, ForgotPasswordLink, KEYBOARD_TOOLBAR_HEIGHT, KeyboardScrollProvider, NotificationsPage, SettingsPage, SettingsSubPage, SocialAuthRow, ThreadPage, appleProvider, confirmDiscardChanges, defaultStickyHeaderOffset, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions, getThreadPageStackOptions, googleProvider, iosCompactNavigationBarHeight, useKeyboardScroll, useKeyboardToolbar };
|
|
1152
|
+
//# sourceMappingURL=chunk-GBNIBHSU.js.map
|
|
1153
|
+
//# sourceMappingURL=chunk-GBNIBHSU.js.map
|