@robono/messaging-react-native 0.17.0 → 0.19.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/BRIDGE-MESSENGER.md +125 -0
- package/CHANGELOG.md +13 -0
- package/README.md +21 -1
- package/SBOM.spdx.json +567 -279
- package/dist/account.js +5 -3
- package/dist/appearance-context.d.ts +11 -0
- package/dist/appearance-context.js +5 -0
- package/dist/attachment-menu.js +9 -6
- package/dist/brand.js +5 -4
- package/dist/calling.js +3 -2
- package/dist/chat-options.d.ts +12 -0
- package/dist/chat-options.js +25 -0
- package/dist/contact-directory.js +3 -3
- package/dist/conversation-details.d.ts +2 -0
- package/dist/conversation-details.js +7 -5
- package/dist/expo-bridge.d.ts +22 -0
- package/dist/expo-bridge.js +29 -0
- package/dist/expo-history.js +1 -1
- package/dist/expo-media.js +2 -2
- package/dist/expo-messenger.js +14 -4
- package/dist/expo-outbox.js +1 -1
- package/dist/expo-screen.js +15 -11
- package/dist/expo-storage-digest.d.ts +1 -0
- package/dist/expo-storage-digest.js +5 -0
- package/dist/expo.d.ts +1 -0
- package/dist/expo.js +1 -0
- package/dist/extras.d.ts +3 -1
- package/dist/extras.js +5 -3
- package/dist/forward.js +4 -3
- package/dist/group-editor.js +6 -3
- package/dist/header-calls.js +4 -3
- package/dist/inbox-search.js +4 -3
- package/dist/inbox.js +12 -9
- package/dist/index.d.ts +16 -2
- package/dist/index.js +173 -74
- package/dist/media-ui.js +15 -7
- package/dist/message-menu.d.ts +2 -1
- package/dist/message-menu.js +9 -4
- package/dist/native-outbox.d.ts +2 -1
- package/dist/native-outbox.js +20 -3
- package/dist/polls.js +10 -6
- package/dist/popup.d.ts +5 -2
- package/dist/popup.js +13 -7
- package/dist/public-rooms.js +4 -2
- package/dist/quick-send.js +2 -2
- package/dist/room-moderation.js +9 -4
- package/dist/safety.d.ts +5 -2
- package/dist/safety.js +16 -10
- package/dist/saved.js +3 -2
- package/dist/scheduled.js +11 -6
- package/dist/search.js +4 -2
- package/dist/sign-in.js +9 -7
- package/dist/social.d.ts +5 -0
- package/dist/social.js +4 -3
- package/dist/storage-digest-cache.d.ts +2 -0
- package/dist/storage-digest-cache.js +19 -0
- package/dist/translation-settings.js +5 -3
- package/dist/typography.d.ts +8 -3
- package/dist/typography.js +22 -9
- package/dist/use-quote-gesture.js +7 -3
- package/examples/existing-bridge-chat.tsx +44 -0
- package/package.json +11 -5
- package/setup.plugin.cjs +1 -0
package/dist/media-ui.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { messagingMediaColors, messagingContrastInk } from '@robono/messaging';
|
|
3
|
+
import { useMessagingAppearance } from './appearance-context.js';
|
|
2
4
|
import { Text } from './typography.js';
|
|
3
5
|
import { useRobonoLocale } from './localization.js';
|
|
4
6
|
import { messengerVoiceWaveform } from './voice-waveform.js';
|
|
@@ -15,24 +17,29 @@ export function VoicePlayback({ ink, accent, waveform, showWaveform = true, foot
|
|
|
15
17
|
setPlayed(true);
|
|
16
18
|
onPlayed?.();
|
|
17
19
|
} }, [playing, positionMs, onPlayed]);
|
|
18
|
-
const
|
|
20
|
+
const voiceStyle = useMessagingAppearance()?.voicePlayer;
|
|
21
|
+
const buttonOverride = mine ? voiceStyle?.sent : heard || played ? voiceStyle?.played : voiceStyle?.unplayed;
|
|
22
|
+
const buttonColor = buttonOverride ?? (mine ? '#ffffff29' : heard || played ? accent : '#2e9d63');
|
|
23
|
+
const buttonInk = buttonOverride ? messagingContrastInk(buttonOverride) : ink;
|
|
24
|
+
const bars = showWaveform ? messengerVoiceWaveform(waveform, durationMs) : null, fill = voiceStyle?.waveform ?? (mine ? ink : accent);
|
|
19
25
|
const hold = () => { held.current = true; onLongPress?.(); };
|
|
20
26
|
return _jsxs(View, { testID: "voice-message-player", style: { width: 220, maxWidth: '100%', minHeight: 44, borderRadius: 24, borderWidth: 1, borderColor: ink + '24', backgroundColor: background ?? (mine ? '#1F5F7A' : '#1D1D1D'), paddingLeft: 5, paddingRight: 8, paddingVertical: 3 }, children: [_jsxs(View, { style: { flexDirection: 'row', direction: 'ltr', alignItems: 'center', gap: 8 }, children: [_jsx(Pressable, { testID: "voice-play-control", accessibilityRole: "button", accessibilityLabel: playing ? uiText("Pause voice message") : uiText("Play voice message"), accessibilityState: { busy: loading }, disabled: loading, hitSlop: 6, delayLongPress: 360, onPressIn: () => { held.current = false; }, onPress: () => { if (!held.current)
|
|
21
|
-
onToggle(); }, onLongPress: hold, style: { width: 36, height: 36, borderRadius: 18, paddingLeft: playing ? 0 : 2, backgroundColor:
|
|
27
|
+
onToggle(); }, onLongPress: hold, style: { width: 36, height: 36, borderRadius: 18, paddingLeft: playing ? 0 : 2, backgroundColor: buttonColor, alignItems: 'center', justifyContent: 'center' }, children: loading ? _jsx(ActivityIndicator, { size: "small", color: buttonInk }) : _jsx(MessageIcon, { name: playing ? 'pause' : 'play', color: buttonInk, size: 20 }) }), _jsxs(View, { style: { flex: 1, minWidth: 0, gap: 7 }, children: [_jsx(Pressable, { onLongPress: hold, accessibilityRole: "adjustable", accessibilityLabel: showWaveform ? uiText("Voice waveform") : uiText("Voice position"), accessibilityValue: { min: 0, max: Math.ceil(durationMs / 1000), now: Math.floor(positionMs / 1000) }, accessibilityActions: [{ name: 'increment', label: uiText("Forward five seconds") }, { name: 'decrement', label: uiText("Back five seconds") }], onAccessibilityAction: e => onSeek?.(Math.max(0, Math.min(durationMs, positionMs + (e.nativeEvent.actionName === 'increment' ? 5000 : -5000)))), onLayout: e => { width.current = e.nativeEvent.layout.width; }, onPressIn: () => { held.current = false; }, onPress: e => { if (held.current)
|
|
22
28
|
return; const bounds = Platform.OS === 'web' ? e.currentTarget.getBoundingClientRect() : null; const x = bounds ? e.nativeEvent.clientX - bounds.left : e.nativeEvent.locationX; const total = bounds?.width ?? width.current; if (total > 0 && Number.isFinite(x))
|
|
23
29
|
onSeek?.(Math.max(0, Math.min(1, x / total)) * durationMs); }, style: { height: bars ? 24 : 9, transform: [{ translateY: 4 }], flexDirection: 'row', alignItems: 'center', gap: 1 }, children: bars ? bars.map((sample, i) => _jsx(View, { pointerEvents: "none", style: { flex: 1, flexBasis: 0, borderRadius: 2, overflow: 'hidden', backgroundColor: ink + (mine ? '33' : '38'), height: 2 + sample * 18 }, children: _jsx(View, { style: { height: '100%', backgroundColor: fill, width: `${Math.max(0, Math.min(1, progress * bars.length - i)) * 100}%` } }) }, i)) : _jsx(View, { pointerEvents: "none", style: { flex: 1, height: 9, borderRadius: 5, overflow: 'hidden', backgroundColor: ink + '33' }, children: _jsx(View, { style: { height: 9, borderRadius: 5, backgroundColor: fill, width: `${progress * 100}%` } }) }) }), _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 4, paddingRight: footer ? 6 : 0 }, children: [_jsx(Text, { testID: "voice-duration", style: { color: ink, opacity: .75, fontSize: 11, fontWeight: '800', fontVariant: ['tabular-nums'] }, children: duration(playing || positionMs > 0 ? Math.max(0, durationMs - positionMs) : durationMs) }), footer && _jsx(View, { testID: "voice-message-actions", style: { flexShrink: 1, maxWidth: 112, alignItems: 'flex-end' }, children: footer })] })] })] }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: ink, fontSize: 12, marginTop: 6 }, children: error })] });
|
|
24
30
|
}
|
|
25
31
|
export function MediaPlaybackControls({ playing = false, loading = false, positionMs = 0, durationMs = 0, error, onToggle, onSeek, onFullscreen, fullscreen = false }) {
|
|
26
32
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
33
|
+
const appearance = useMessagingAppearance(), c = messagingMediaColors(appearance);
|
|
27
34
|
const width = useRef(1);
|
|
28
|
-
return _jsxs(View, { style: { paddingHorizontal: 18, paddingVertical: 10, gap: 6, backgroundColor: '#111316' }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: playing ? uiText("Pause video") : uiText("Play video"), disabled: loading, onPress: onToggle, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: loading ? _jsx(ActivityIndicator, { color:
|
|
29
|
-
onSeek?.(Math.max(0, Math.min(1, x / total)) * durationMs); }, style: { flex: 1, height: 44, justifyContent: 'center' }, children: _jsx(View, { style: { height: 3, borderRadius: 2, backgroundColor: '
|
|
35
|
+
return _jsxs(View, { style: { paddingHorizontal: 18, paddingVertical: 10, gap: 6, backgroundColor: appearance?.mediaViewer?.controls ?? '#111316' }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: playing ? uiText("Pause video") : uiText("Play video"), disabled: loading, onPress: onToggle, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: loading ? _jsx(ActivityIndicator, { color: c.foreground }) : _jsx(MessageIcon, { name: playing ? 'pause' : 'play', color: c.foreground }) }), _jsx(Text, { style: { color: c.foreground, fontSize: 12, fontVariant: ['tabular-nums'] }, children: duration(positionMs) }), _jsx(Pressable, { accessibilityRole: "adjustable", accessibilityLabel: uiText("Video position"), accessibilityValue: { min: 0, max: Math.ceil(durationMs / 1000), now: Math.floor(positionMs / 1000) }, accessibilityActions: [{ name: 'increment' }, { name: 'decrement' }], onAccessibilityAction: e => onSeek?.(Math.max(0, Math.min(durationMs, positionMs + (e.nativeEvent.actionName === 'increment' ? 5000 : -5000)))), onLayout: e => { width.current = e.nativeEvent.layout.width; }, onPress: e => { const bounds = Platform.OS === "web" ? e.currentTarget.getBoundingClientRect() : null; const x = bounds ? e.nativeEvent.clientX - bounds.left : e.nativeEvent.locationX, total = bounds?.width ?? width.current; if (total > 0 && Number.isFinite(x))
|
|
36
|
+
onSeek?.(Math.max(0, Math.min(1, x / total)) * durationMs); }, style: { flex: 1, height: 44, justifyContent: 'center' }, children: _jsx(View, { style: { height: 3, borderRadius: 2, backgroundColor: c.foreground + '44' }, children: _jsx(View, { style: { height: 3, borderRadius: 2, backgroundColor: appearance?.mediaViewer?.accent ?? '#ffffff', width: `${durationMs ? Math.min(100, positionMs / durationMs * 100) : 0}%` } }) }) }), _jsx(Text, { style: { color: c.foreground, fontSize: 12, fontVariant: ['tabular-nums'] }, children: duration(durationMs) }), onFullscreen && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: fullscreen ? uiText("Exit full screen") : uiText("Full screen video"), disabled: loading, onPress: onFullscreen, style: { width: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: _jsx(MessageIcon, { name: fullscreen ? "close" : "open-in-new", color: c.foreground, size: 22 }) })] }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground, fontSize: 13 }, children: error })] });
|
|
30
37
|
}
|
|
31
38
|
/** A full-size photo surface. The same tap-to-hide-controls, pinch and pan handling runs in the preview and native app. */
|
|
32
39
|
export function ZoomablePhoto({ uri, label, onTap, expanded = false }) {
|
|
33
40
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
34
41
|
label ??= uiText('Photo');
|
|
35
|
-
const mediaReady = useContext(MediaReadiness);
|
|
42
|
+
const mediaReady = useContext(MediaReadiness), appearance = useMessagingAppearance();
|
|
36
43
|
const [transform, setTransform] = useState({ zoom: 1, x: 0, y: 0 }), [error, setError] = useState(false);
|
|
37
44
|
const [viewport, setViewport] = useState({ width: 1, height: 1 }), [imageSize, setImageSize] = useState({ width: 1, height: 1 });
|
|
38
45
|
const rotated = expanded && imageSize.width > imageSize.height && viewport.height > viewport.width;
|
|
@@ -102,14 +109,15 @@ export function ZoomablePhoto({ uri, label, onTap, expanded = false }) {
|
|
|
102
109
|
} }, () => { }); return () => { active = false; }; }, [uri, controller]);
|
|
103
110
|
useEffect(() => { controller.reset(); }, [expanded, controller]);
|
|
104
111
|
useEffect(() => { controller.layout(stageWidth, stageHeight); }, [controller, stageWidth, stageHeight]);
|
|
105
|
-
return _jsxs(View, { style: { flex: 1, minHeight: 0, overflow: 'hidden', alignItems: 'center', justifyContent: 'center' }, onLayout: e => setViewport(e.nativeEvent.layout), children: [_jsx(View, { testID: "photo-image-stage", style: { width: stageWidth, height: stageHeight, transform: rotated ? [{ rotate: '90deg' }] : [] }, children: _jsx(View, { ref: webRef, ...(Platform.OS === 'web' ? {} : pan.panHandlers), testID: "photo-gesture-surface", accessible: true, accessibilityRole: "button", accessibilityLabel: uiText("Toggle photo controls"), onAccessibilityTap: () => tap.current?.(), ...(Platform.OS === 'web' ? { tabIndex: 0 } : {}), style: { flex: 1, overflow: 'hidden', ...(Platform.OS === 'web' ? { touchAction: 'none', userSelect: 'none' } : {}) }, children: _jsx(Image, { testID: "photo-zoom-image", accessibilityLabel: label, source: { uri }, resizeMode: "contain", onLoad: () => mediaReady('image-loaded', uri), onError: () => setError(true), style: { width: '100%', height: '100%', transform: [{ translateX: transform.x }, { translateY: transform.y }, { scale: transform.zoom }] } }) }) }), error && _jsx(Text, { accessibilityRole: "alert", style: { position: 'absolute', top: '50%', alignSelf: 'center', color:
|
|
112
|
+
return _jsxs(View, { style: { flex: 1, minHeight: 0, overflow: 'hidden', alignItems: 'center', justifyContent: 'center' }, onLayout: e => setViewport(e.nativeEvent.layout), children: [_jsx(View, { testID: "photo-image-stage", style: { width: stageWidth, height: stageHeight, transform: rotated ? [{ rotate: '90deg' }] : [] }, children: _jsx(View, { ref: webRef, ...(Platform.OS === 'web' ? {} : pan.panHandlers), testID: "photo-gesture-surface", accessible: true, accessibilityRole: "button", accessibilityLabel: uiText("Toggle photo controls"), onAccessibilityTap: () => tap.current?.(), ...(Platform.OS === 'web' ? { tabIndex: 0 } : {}), style: { flex: 1, overflow: 'hidden', ...(Platform.OS === 'web' ? { touchAction: 'none', userSelect: 'none' } : {}) }, children: _jsx(Image, { testID: "photo-zoom-image", accessibilityLabel: label, source: { uri }, resizeMode: "contain", onLoad: () => mediaReady('image-loaded', uri), onError: () => setError(true), style: { width: '100%', height: '100%', transform: [{ translateX: transform.x }, { translateY: transform.y }, { scale: transform.zoom }] } }) }) }), error && _jsx(Text, { accessibilityRole: "alert", style: { position: 'absolute', top: '50%', alignSelf: 'center', color: messagingMediaColors(appearance).foreground }, children: uiText("This photo could not be opened.") })] });
|
|
106
113
|
}
|
|
107
114
|
export function MediaViewer({ title, subtitle, kind, uri, fileName, byteSize, children, loading, error, onClose, onFileAction, reviewAction, onReview, onDownload, onShare, onForward, onDelete, downloading = false, expanded, onExpandedChange, keepControlsVisible = false, status, transferProgress }) {
|
|
108
115
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
116
|
+
const appearance = useMessagingAppearance(), c = messagingMediaColors(appearance), actionBackground = appearance?.mediaViewer?.accent ?? '#ffffff';
|
|
109
117
|
const [localExpanded, setLocalExpanded] = useState(false);
|
|
110
118
|
const photoExpanded = kind === 'image' && (expanded ?? localExpanded), controls = keepControlsVisible || !photoExpanded;
|
|
111
119
|
const setExpanded = (value) => { setLocalExpanded(value); onExpandedChange?.(value); };
|
|
112
120
|
useEffect(() => { setLocalExpanded(false); }, [uri]);
|
|
113
121
|
const visual = kind === 'image' || kind === 'video';
|
|
114
|
-
return _jsxs(View, { testID: "messenger-media-viewer", accessibilityViewIsModal: true, style: { flex: 1, minHeight: 0, backgroundColor: controls ? 'rgba(0,0,0,0.94)' : '#000000' }, children: [_jsxs(View, { style: { flex: 1, minHeight: 0, justifyContent: 'center', paddingHorizontal: visual && controls ? 12 : 0 }, children: [controls && _jsxs(View, { testID: "media-action-toolbar", style: { position: 'absolute', top: 12, left: 12, right: 12, zIndex: 3, minHeight: 52, borderRadius:
|
|
122
|
+
return _jsxs(View, { testID: "messenger-media-viewer", accessibilityViewIsModal: true, style: { flex: 1, minHeight: 0, backgroundColor: appearance?.mediaViewer?.background ?? (controls ? 'rgba(0,0,0,0.94)' : '#000000') }, children: [_jsxs(View, { style: { flex: 1, minHeight: 0, justifyContent: 'center', paddingHorizontal: visual && controls ? 12 : 0 }, children: [controls && _jsxs(View, { testID: "media-action-toolbar", style: { position: 'absolute', top: 12, left: 12, right: 12, zIndex: 3, minHeight: 52, borderRadius: c.radius, borderWidth: 1, borderColor: c.foreground + '1f', backgroundColor: c.controls + 'eb', paddingLeft: 8, paddingRight: 4, flexDirection: 'row', alignItems: 'center', gap: 2 }, children: [[[onFileAction, 'Open', 'open-in-new', false, false], [onDownload, 'Download', 'download-outline', downloading, false], [onDelete, 'Delete', 'trash-outline', false, true], [onForward, 'Forward', 'arrow-redo-outline', false, false], [onShare, 'Share', 'share-social-outline', false, false]].filter(([action]) => !!action).map(([action, label, icon, busy, destructive]) => _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("{value1} media", { value1: label }), accessibilityState: { busy }, disabled: !action || busy || downloading, onPress: action, style: { opacity: !action ? .5 : 1, flex: 1, minWidth: 44, minHeight: 44, borderRadius: Math.min(22, c.radius), alignItems: 'center', justifyContent: 'center', gap: 1, paddingHorizontal: 2 }, children: [busy ? _jsx(ActivityIndicator, { size: "small", color: c.accent }) : _jsx(MessageIcon, { name: icon, size: 20, color: !action ? c.foreground + '88' : destructive ? c.danger : c.foreground }), _jsx(Text, { numberOfLines: 1, style: { color: !action ? c.foreground + '88' : destructive ? c.danger : c.foreground, fontSize: 10, fontWeight: '800' }, children: label })] }, label)), _jsx(View, { style: { flex: (!visual || !!reviewAction) && !onDownload && !onDelete && !onForward && !onShare ? 1 : 0, minWidth: 0 }, children: (!visual || !!reviewAction) && !onDownload && !onDelete && !onForward && !onShare && _jsx(Text, { numberOfLines: 1, style: { color: c.foreground, fontSize: 14, paddingLeft: 8 }, children: title }) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close media"), onPress: onClose, style: { width: 44, height: 44, borderRadius: Math.min(22, c.radius), backgroundColor: c.foreground + '14', alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "close", size: 24, color: c.foreground }) })] }), loading ? _jsxs(View, { style: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 16 }, children: [_jsx(ActivityIndicator, { color: c.foreground }), _jsx(Text, { style: { color: c.foreground }, children: uiText("Opening…") })] }) : kind === 'image' && uri ? _jsx(View, { style: { height: controls ? '82%' : '100%', width: '100%' }, children: _jsx(ZoomablePhoto, { uri: uri, label: fileName, expanded: photoExpanded, onTap: () => setExpanded(!photoExpanded) }) }) : kind === 'document' && children ? _jsx(View, { style: { flex: 1, minHeight: 0, paddingTop: 76 }, children: children }) : kind === 'document' ? _jsxs(View, { style: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: 32, gap: 20 }, children: [_jsx(View, { style: { width: 88, height: 106, borderRadius: 16, backgroundColor: c.foreground + '12', alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "document", color: c.foreground, size: 40 }) }), _jsx(Text, { style: { color: c.foreground, fontSize: 19, fontWeight: '600', textAlign: 'center' }, children: fileName }), _jsxs(Text, { style: { color: c.foreground, fontSize: 13 }, children: [fileName?.split('.').pop()?.toUpperCase(), " \u00B7 ", fileSize(byteSize)] }), onFileAction && _jsx(Pressable, { accessibilityRole: "button", onPress: onFileAction, style: { borderRadius: 24, paddingHorizontal: 28, paddingVertical: 14, backgroundColor: actionBackground }, children: _jsx(Text, { style: { color: messagingContrastInk(actionBackground), fontWeight: '600' }, children: uiText("Open file") }) })] }) : kind === 'video' ? _jsx(View, { testID: "media-video-stage", style: { height: '72%', width: '100%' }, children: children }) : children] }), !controls && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Show photo controls"), onPress: () => setExpanded(false), style: { position: "absolute", top: 12, right: 12, width: 44, height: 44, borderRadius: Math.min(22, c.radius), backgroundColor: c.controls + 'cc', alignItems: "center", justifyContent: "center" }, children: _jsx(MessageIcon, { name: "more", color: c.foreground, size: 24 }) }), downloading && transferProgress !== undefined && _jsx(View, { accessibilityRole: "progressbar", accessibilityValue: { min: 0, max: 100, now: Math.round(transferProgress * 100) }, style: { height: 3, backgroundColor: c.foreground + '22' }, children: _jsx(View, { style: { height: 3, width: `${Math.round(transferProgress * 100)}%`, backgroundColor: c.accent } }) }), !!status && _jsx(Text, { accessibilityLiveRegion: "polite", style: { color: c.foreground, padding: 12 }, children: status }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground, padding: 16 }, children: error }), controls && reviewAction && onReview && _jsx(View, { style: { padding: 16, borderTopWidth: 1, borderTopColor: c.foreground + '15' }, children: _jsx(Pressable, { accessibilityRole: "button", onPress: onReview, style: { minHeight: 48, borderRadius: 24, backgroundColor: actionBackground, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { fontWeight: '600', color: messagingContrastInk(actionBackground) }, children: reviewAction }) }) })] });
|
|
115
123
|
}
|
package/dist/message-menu.d.ts
CHANGED
|
@@ -8,13 +8,14 @@ export type MessageMenuPosition = {
|
|
|
8
8
|
};
|
|
9
9
|
/** Anchor outside the selected bubble, never at its text's center. */
|
|
10
10
|
export declare function messageMenuPosition(x: number, y: number, width: number, height: number, screenWidth: number, screenHeight: number, mine: boolean): MessageMenuPosition;
|
|
11
|
-
export declare function MessageMenuRow({ icon, label, onPress, disabled, danger, divider }: {
|
|
11
|
+
export declare function MessageMenuRow({ icon, label, onPress, disabled, danger, divider, scope }: {
|
|
12
12
|
icon: React.ComponentProps<typeof MessageIcon>['name'];
|
|
13
13
|
label: string;
|
|
14
14
|
onPress: () => void;
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
danger?: boolean;
|
|
17
17
|
divider?: boolean;
|
|
18
|
+
scope?: 'message' | 'friends';
|
|
18
19
|
}): React.JSX.Element;
|
|
19
20
|
export declare function MessageMenu({ visible, position, screenHeight, mine, reactions, children, onClose, onDismiss }: {
|
|
20
21
|
visible: boolean;
|
package/dist/message-menu.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { defaultMessagingSettings, messagingMenuColors, messagingMenuLayout, messagingContrastInk } from '@robono/messaging';
|
|
3
|
+
import { useMessagingAppearance } from './appearance-context.js';
|
|
2
4
|
import { Text } from './typography.js';
|
|
3
5
|
import { useRobonoLocale } from './localization.js';
|
|
4
6
|
import { messagingPopupBackdrop, MessagingMenuSurface } from './popup.js';
|
|
@@ -12,11 +14,14 @@ export function messageMenuPosition(x, y, width, height, screenWidth, screenHeig
|
|
|
12
14
|
const menuWidth = Math.min(300, screenWidth - 24);
|
|
13
15
|
return { x: Math.max(12, Math.min(mine ? x + width - menuWidth : x, screenWidth - menuWidth - 12)), y: above ? top : bottom, above, available: Math.max(44, (above ? top : screenHeight - bottom) - 24) };
|
|
14
16
|
}
|
|
15
|
-
export function MessageMenuRow({ icon, label, onPress, disabled, danger, divider }) {
|
|
16
|
-
|
|
17
|
+
export function MessageMenuRow({ icon, label, onPress, disabled, danger, divider, scope = 'message' }) {
|
|
18
|
+
const appearance = useMessagingAppearance() ?? defaultMessagingSettings().appearance, palette = messagingMenuColors(appearance, scope), layout = messagingMenuLayout(appearance.menus?.[scope]);
|
|
19
|
+
const dangerColor = messagingContrastInk(palette.background) === '#000000' ? '#b42318' : '#F87171';
|
|
20
|
+
return _jsxs(_Fragment, { children: [divider && _jsx(View, { style: { height: 1, marginHorizontal: 12, marginVertical: 4, backgroundColor: palette.foreground + '22' } }), _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: label, disabled: disabled, onPress: onPress, style: ({ pressed }) => ({ minHeight: layout.rowHeight, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 8, opacity: disabled ? .5 : 1, backgroundColor: pressed ? palette.foreground + '12' : 'transparent' }), children: [layout.showIcons && _jsx(MessageIcon, { name: icon, color: danger ? dangerColor : palette.icons, size: 22 }), _jsx(Text, { style: { flex: 1, color: danger ? dangerColor : palette.foreground, fontSize: layout.textSize, fontWeight: '700' }, children: label })] })] });
|
|
17
21
|
}
|
|
18
22
|
export function MessageMenu({ visible, position, screenHeight, mine, reactions, children, onClose, onDismiss }) {
|
|
19
|
-
const { text: uiText
|
|
23
|
+
const { text: uiText } = useRobonoLocale();
|
|
24
|
+
const appearance = useMessagingAppearance() ?? defaultMessagingSettings().appearance, palette = messagingMenuColors(appearance, 'message'), layout = messagingMenuLayout(appearance.menus?.message);
|
|
20
25
|
useEffect(() => { if (!visible || Platform.OS !== 'web')
|
|
21
26
|
return; const key = (e) => { if (e.key === 'Escape') {
|
|
22
27
|
e.stopPropagation();
|
|
@@ -25,7 +30,7 @@ export function MessageMenu({ visible, position, screenHeight, mine, reactions,
|
|
|
25
30
|
return _jsx(MessagingMenuSurface, { visible: visible, onClose: onClose, onDismiss: onDismiss, children: rect => {
|
|
26
31
|
const menuWidth = Math.min(300, rect.width - 24), y = Math.max(12, Math.min(position.y - rect.top, rect.height - 12));
|
|
27
32
|
const local = { ...position, x: Math.max(12, Math.min(position.x - rect.left, rect.width - menuWidth - 12)), y, available: Math.max(44, (position.above ? y : rect.height - y) - 24) };
|
|
28
|
-
const card = _jsx(View, { testID: "message-action-card", style: { width: 218, maxWidth: '100%', maxHeight: Math.min(310, Math.max(43, local.available - (reactions ? 58 : 0))), borderRadius:
|
|
33
|
+
const card = _jsx(View, { testID: "message-action-card", style: { width: 218, maxWidth: '100%', maxHeight: Math.min(310, Math.max(43, local.available - (reactions ? 58 : 0))), borderRadius: layout.radius, borderWidth: .5, borderColor: palette.foreground + '22', backgroundColor: palette.background, paddingVertical: 4, overflow: 'hidden', boxShadow: '0 8px 18px #0006', alignSelf: mine ? 'flex-end' : 'flex-start' }, children: _jsx(ScrollView, { showsVerticalScrollIndicator: false, bounces: false, keyboardShouldPersistTaps: "handled", children: children }) });
|
|
29
34
|
return _jsxs(View, { style: { flex: 1 }, children: [_jsx(Pressable, { accessibilityLabel: uiText("Close message options"), onPress: onClose, style: { position: 'absolute', inset: 0, backgroundColor: messagingPopupBackdrop } }), _jsxs(View, { testID: "message-context-menu", style: { position: 'absolute', left: local.x, ...(position.above ? { bottom: rect.height - local.y + 12 } : { top: local.y + 12 }), width: menuWidth, maxWidth: '94%', gap: 8 }, children: [position.above ? card : reactions, position.above ? reactions : card] })] });
|
|
30
35
|
} });
|
|
31
36
|
}
|
package/dist/native-outbox.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare class NativeMessagingOutbox implements MessagingOutbox {
|
|
|
29
29
|
private files;
|
|
30
30
|
private generation;
|
|
31
31
|
private scope;
|
|
32
|
+
private queuedDraft?;
|
|
32
33
|
constructor(endpoint: string, userId: string, files: NativeDraftFiles, namespace?: string);
|
|
33
34
|
private serial;
|
|
34
35
|
conversations(): Promise<string[]>;
|
|
@@ -45,7 +46,7 @@ export declare class NativeMessagingOutbox implements MessagingOutbox {
|
|
|
45
46
|
needsPreparation?: boolean;
|
|
46
47
|
}[];
|
|
47
48
|
attachments: {
|
|
48
|
-
kind: "
|
|
49
|
+
kind: "poll" | "text" | "image" | "document" | "video" | "voice";
|
|
49
50
|
media: MessageMedia;
|
|
50
51
|
}[];
|
|
51
52
|
quickMessage?: string | undefined;
|
package/dist/native-outbox.js
CHANGED
|
@@ -6,6 +6,7 @@ export class NativeMessagingOutbox {
|
|
|
6
6
|
files;
|
|
7
7
|
generation = 0;
|
|
8
8
|
scope;
|
|
9
|
+
queuedDraft;
|
|
9
10
|
constructor(endpoint, userId, files, namespace = 'default') {
|
|
10
11
|
this.files = files;
|
|
11
12
|
this.scope = JSON.stringify([endpoint, namespace, userId]);
|
|
@@ -18,17 +19,33 @@ export class NativeMessagingOutbox {
|
|
|
18
19
|
actions.push(action);
|
|
19
20
|
else
|
|
20
21
|
actions[index] = action; state.actions = actions; await this.files.write(this.scope, cid, state); }); }
|
|
21
|
-
removeAction(cid, id) { return this.serial(async () => { const state = await this.files.read(this.scope, cid);
|
|
22
|
+
removeAction(cid, id) { return this.serial(async () => { const state = await this.files.read(this.scope, cid); if (!state.actions?.some(a => a.id === id))
|
|
23
|
+
return; state.actions = state.actions.filter(a => a.id !== id); await this.files.write(this.scope, cid, state); }); }
|
|
22
24
|
load(cid) { return this.serial(async () => { const saved = await this.files.read(this.scope, cid), used = new Set(saved.messages.map(m => m.fileId)); return { ...(saved.translationPreference ? { translationPreference: saved.translationPreference } : {}), ...(saved.quickMessage ? { quickMessage: saved.quickMessage } : {}), draft: saved.draft, messages: saved.messages.map(({ fileId, ...message }) => message), attachments: Object.entries(saved.files).filter(([id]) => !used.has(id)).map(([, f]) => ({ kind: f.kind, media: f.media })) }; }); }
|
|
23
25
|
put(cid, message) { return this.serial(async () => { const state = await this.files.read(this.scope, cid), previous = state.messages.find(m => m.clientMessageId === message.clientMessageId); state.messages = state.messages.filter(m => m.clientMessageId !== message.clientMessageId); state.messages.push({ ...message, fileId: message.needsPreparation ? message.content.media?.assetId : previous?.fileId }); await this.files.write(this.scope, cid, state); }); }
|
|
24
|
-
remove(cid, id) { return this.serial(async () => { const state = await this.files.read(this.scope, cid),
|
|
26
|
+
remove(cid, id) { return this.serial(async () => { const state = await this.files.read(this.scope, cid), message = state.messages.find(m => m.clientMessageId === id); if (!message)
|
|
27
|
+
return; const fileId = message.fileId; state.messages = state.messages.filter(m => m.clientMessageId !== id); if (fileId && !state.messages.some(m => m.fileId === fileId)) {
|
|
25
28
|
delete state.files[fileId];
|
|
26
29
|
await this.files.write(this.scope, cid, state);
|
|
27
30
|
await this.files.remove(this.scope, cid, fileId);
|
|
28
31
|
}
|
|
29
32
|
else
|
|
30
33
|
await this.files.write(this.scope, cid, state); }); }
|
|
31
|
-
draft(cid, text) {
|
|
34
|
+
draft(cid, text) {
|
|
35
|
+
const queued = this.queuedDraft;
|
|
36
|
+
// Replace only a draft that has not started and is still the scope's last
|
|
37
|
+
// operation. A send/read/clear, including another instance, is a barrier.
|
|
38
|
+
if (queued?.cid === cid && queues.get(this.scope) === queued.promise) {
|
|
39
|
+
queued.text = text.slice(0, 10000);
|
|
40
|
+
return queued.promise;
|
|
41
|
+
}
|
|
42
|
+
const next = { cid, text: text.slice(0, 10000), promise: undefined };
|
|
43
|
+
next.promise = this.serial(async () => { if (this.queuedDraft === next)
|
|
44
|
+
this.queuedDraft = undefined; const state = await this.files.read(this.scope, cid); if (state.draft === next.text)
|
|
45
|
+
return; state.draft = next.text; await this.files.write(this.scope, cid, state); });
|
|
46
|
+
this.queuedDraft = next;
|
|
47
|
+
return next.promise;
|
|
48
|
+
}
|
|
32
49
|
translationPreference(cid, value) { return this.serial(async () => { const state = await this.files.read(this.scope, cid); state.translationPreference = value; await this.files.write(this.scope, cid, state); }); }
|
|
33
50
|
quickMessage(cid, emoji) { return this.serial(async () => { const state = await this.files.read(this.scope, cid); state.quickMessage = emoji; await this.files.write(this.scope, cid, state); }); }
|
|
34
51
|
clear(cid) { this.generation++; epochs.set(this.scope, (epochs.get(this.scope) ?? 0) + 1); return this.serial(() => this.files.clear(this.scope, cid)); }
|
package/dist/polls.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { messagingContrastInk } from '@robono/messaging';
|
|
2
3
|
import { Text, TextInput } from './typography.js';
|
|
3
4
|
import { useRobonoLocale } from './localization.js';
|
|
4
|
-
import {
|
|
5
|
+
import { useMessagingPopupColors } from './popup.js';
|
|
5
6
|
import { ExtraPopup } from './extras.js';
|
|
6
7
|
import { MessageIcon } from './icons.js';
|
|
7
8
|
import { useRef, useState } from 'react';
|
|
@@ -12,6 +13,7 @@ const PollArea = View;
|
|
|
12
13
|
import { MessagingPopup as PollModal } from './popup.js';
|
|
13
14
|
/** Optional reusable poll content. Votes are submitted as a complete selection, not a toggle request. */
|
|
14
15
|
export function PollMessage({ message, userId, ink, accent, enabled, onVote, onClose, resolveVoterName, background = '#101010', foreground = '#fff', renderDetails, detailsOpen, onDetailsOpenChange, onLongPress }) {
|
|
16
|
+
const messagingPopupColors = useMessagingPopupColors(undefined, 'pollResults');
|
|
15
17
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
16
18
|
const [busy, setBusy] = useState(false), [error, setError] = useState(''), [localShowVotes, setLocalShowVotes] = useState(false);
|
|
17
19
|
const showVotes = detailsOpen ?? localShowVotes;
|
|
@@ -53,11 +55,12 @@ export function PollMessage({ message, userId, ink, accent, enabled, onVote, onC
|
|
|
53
55
|
const count = votes.filter(v => v.options.includes(index)).length, checked = selected.includes(index);
|
|
54
56
|
return _jsxs(View, { style: { minHeight: 36, paddingVertical: 3, gap: 2 }, children: [_jsxs(View, { style: { flexDirection: 'row', gap: 10, alignItems: 'center' }, children: [_jsx(Pressable, { accessibilityRole: poll.multiple ? 'checkbox' : 'radio', accessibilityLabel: uiText('{option}, {votes}', { option: label, votes: uiCount(count, '{count} vote', '{count} votes') }), "aria-checked": checked, accessibilityState: { checked, disabled: !enabled || closed || busy, busy: pending !== null }, hitSlop: 4, disabled: !enabled || closed || busy, onPress: event => { event.stopPropagation(); if (!enabled || closed || busy || actionBusy.current)
|
|
55
57
|
return; const previous = selection.current; setError(''); void queue.current(previous.includes(index) ? previous.filter(x => x !== index) : poll.multiple ? [...previous, index] : [index]); }, style: { width: 20, height: 20, borderRadius: poll.multiple ? 4 : 10, borderWidth: 2, borderColor: checked ? accent : ink, alignItems: 'center', justifyContent: 'center' }, children: checked && _jsx(View, { style: { width: 10, height: 10, borderRadius: poll.multiple ? 2 : 5, backgroundColor: accent } }) }), _jsx(Text, { style: { flex: 1, color: ink, fontSize: 16 }, children: label }), _jsx(Text, { style: { color: ink, fontSize: 13 }, children: count })] }), _jsx(View, { pointerEvents: "none", style: { height: 3, marginLeft: 30, backgroundColor: ink + '20', borderRadius: 2, overflow: 'hidden' }, children: _jsx(View, { style: { height: 3, width: `${votes.length ? count / votes.length * 100 : 0}%`, backgroundColor: accent } }) })] }, index);
|
|
56
|
-
}), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: ink }, children: error })] }), showVotes && (renderDetails ? renderDetails(details, () => setShowVotes(false)) : _jsx(ExtraPopup, { title: uiText("Votes"), background: background, foreground: foreground, onClose: () => setShowVotes(false), children: _jsx(ScrollView, { style: { flexShrink: 1 }, children: details }) }))] });
|
|
58
|
+
}), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: ink }, children: error })] }), showVotes && (renderDetails ? renderDetails(details, () => setShowVotes(false)) : _jsx(ExtraPopup, { screen: "pollResults", title: uiText("Votes"), background: background, foreground: foreground, onClose: () => setShowVotes(false), children: _jsx(ScrollView, { style: { flexShrink: 1 }, children: details }) }))] });
|
|
57
59
|
}
|
|
58
60
|
/** Recipient-only decision. Keep the attempted answer on an uncertain failure so
|
|
59
61
|
* retry cannot silently switch an answer the server may already have accepted. */
|
|
60
62
|
function YesNoQuestion({ message, userId, ink, accent, enabled, onVote, onClose, resolveVoterName, renderDetails, detailsOpen, onDetailsOpenChange, onLongPress, background = '#111111', foreground = '#fff' }) {
|
|
63
|
+
const messagingPopupColors = useMessagingPopupColors(undefined, 'answer');
|
|
61
64
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
62
65
|
const [attempt, setAttempt] = useState(null), [busy, setBusy] = useState(false), [error, setError] = useState(''), [localOpen, setLocalOpen] = useState(false);
|
|
63
66
|
const inFlight = useRef(false), firstChoice = useRef(null);
|
|
@@ -91,9 +94,10 @@ function YesNoQuestion({ message, userId, ink, accent, enabled, onVote, onClose,
|
|
|
91
94
|
const details = _jsxs(View, { style: { gap: 12 }, children: [_jsx(Text, { style: { color: messagingPopupColors.foreground, fontSize: 17, lineHeight: 23, fontWeight: '600' }, children: poll.question }), _jsx(Text, { style: { color: messagingPopupColors.foreground, fontSize: 15, lineHeight: 21 }, children: answer !== undefined ? uiText("{value1} answered {value2}.", { value1: respondent === userId ? 'You' : resolveVoterName?.(respondent) || 'Recipient', value2: poll.options[answer] }) : closed ? uiText("Closed without an answer.") : attempt !== null ? uiText("Confirming your answer…") : uiText("Waiting for an answer.") }), mine && !closed && enabled && _jsx(Pressable, { accessibilityRole: "button", onPress: () => { if (inFlight.current)
|
|
92
95
|
return; inFlight.current = true; void onClose().catch(() => setError(uiText("Could not close the question. Try again."))).finally(() => { inFlight.current = false; }); }, style: { minHeight: 36, alignSelf: 'flex-end', justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent }, children: uiText("End question") }) })] });
|
|
93
96
|
return _jsxs(_Fragment, { children: [_jsxs(Pressable, { accessible: false, onLongPress: onLongPress, onPress: e => { e.stopPropagation(); setOpen(true); }, testID: "yes-no-question", style: { maxWidth: 270, minWidth: 160 }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'flex-start', gap: 6 }, children: [_jsx(View, { style: { paddingTop: 3 }, children: _jsx(MessageIcon, { name: "poll", color: accent, size: 16 }) }), _jsx(Text, { accessibilityRole: "button", onLongPress: onLongPress, onPress: () => setOpen(true), style: { flexShrink: 1, fontSize: 16, lineHeight: 22, fontWeight: '600', color: ink }, children: poll.question })] }), _jsx(View, { style: { flexDirection: 'row', gap: 20, marginTop: 2 }, children: poll.options.map((label, index) => _jsxs(Pressable, { accessibilityRole: "radio", accessibilityLabel: label, accessibilityState: { checked: chosen === index, disabled: !enabled || mine || closed || attempt !== null, busy }, disabled: !enabled || mine || closed || attempt !== null, onPress: e => { e.stopPropagation(); void choose(index); }, hitSlop: 4, style: { flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 32 }, children: [_jsx(View, { style: { width: 20, height: 20, borderRadius: 10, borderWidth: 2, borderColor: chosen === index ? accent : ink, alignItems: 'center', justifyContent: 'center', opacity: chosen === undefined && mine ? .5 : 1 }, children: chosen === index && _jsx(View, { style: { width: 10, height: 10, borderRadius: 5, backgroundColor: accent } }) }), _jsx(Text, { style: { color: ink, fontSize: 16, fontWeight: chosen === index ? '600' : '400' }, children: label })] }, index)) }), !!error && !closed && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Retry answer"), disabled: busy || closed || attempt === null, onPress: e => { e.stopPropagation(); if (attempt !== null)
|
|
94
|
-
void choose(attempt); }, children: _jsx(Text, { accessibilityRole: "alert", style: { color: ink, fontSize: 13 }, children: error }) })] }), open && (renderDetails ? renderDetails(details, () => setOpen(false)) : _jsx(ExtraPopup, { title: uiText("Answer"), background: background, foreground: foreground, onClose: () => setOpen(false), children: _jsx(ScrollView, { style: { flexShrink: 1 }, children: details }) }))] });
|
|
97
|
+
void choose(attempt); }, children: _jsx(Text, { accessibilityRole: "alert", style: { color: ink, fontSize: 13 }, children: error }) })] }), open && (renderDetails ? renderDetails(details, () => setOpen(false)) : _jsx(ExtraPopup, { screen: "answer", title: uiText("Answer"), background: background, foreground: foreground, onClose: () => setOpen(false), children: _jsx(ScrollView, { style: { flexShrink: 1 }, children: details }) }))] });
|
|
95
98
|
}
|
|
96
99
|
export function PollComposer({ appearance, onSend, onCancel, retrySafe = false, yesNo = false }) {
|
|
100
|
+
const messagingPopupColors = useMessagingPopupColors(appearance, yesNo ? 'question' : 'poll');
|
|
97
101
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
98
102
|
const [question, setQuestion] = useState(''), [options, setOptions] = useState(['', '']), [multiple, setMultiple] = useState(false), [busy, setBusy] = useState(false), [error, setError] = useState(''), [submitted, setSubmitted] = useState(false);
|
|
99
103
|
const c = { ...appearance.colors, ...messagingPopupColors };
|
|
@@ -116,13 +120,13 @@ export function PollComposer({ appearance, onSend, onCancel, retrySafe = false,
|
|
|
116
120
|
finally {
|
|
117
121
|
setBusy(false);
|
|
118
122
|
} }
|
|
119
|
-
const inputStyle = { fontSize: 17, color: c.foreground, minHeight: 48, borderWidth: 1, borderColor: '
|
|
123
|
+
const inputStyle = { fontSize: 17, color: c.foreground, minHeight: 48, borderWidth: 1, borderColor: c.foreground + '20', borderRadius: 10, backgroundColor: c.incoming, padding: 12 };
|
|
120
124
|
let ready = false;
|
|
121
125
|
try {
|
|
122
126
|
validatePoll(yesNo ? { question, options: ['Yes', 'No'], multiple: false, kind: 'yes_no' } : { question, options, multiple });
|
|
123
127
|
ready = true;
|
|
124
128
|
}
|
|
125
129
|
catch { }
|
|
126
|
-
return _jsx(PollModal, { contentWidth: 640, form: true, title: yesNo ? uiText("Yes/No question") : uiText("New poll"), foreground: c.foreground, closeDisabled: busy, background: c.background, onClose: () => { if (!busy)
|
|
127
|
-
onCancel(); }, children: _jsxs(PollArea, { style: { flex: 1, minHeight: 0, backgroundColor: c.background }, children: [_jsx(View, { style: { flexShrink: 1 }, children: _jsxs(ScrollView, { keyboardShouldPersistTaps: "handled", keyboardDismissMode: "on-drag", contentContainerStyle: { padding: 0, paddingBottom: 12, gap: 8 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 13, fontWeight: '600', marginTop: 4 }, children: uiText("Question") }), _jsx(TextInput, { accessibilityLabel: uiText("Poll question"), placeholder: uiText("Ask a question"), placeholderTextColor: c.secondary, maxLength: 300, multiline: true, value: question, onChangeText: setQuestion, editable: !busy, style: inputStyle }), !yesNo && _jsxs(_Fragment, { children: [_jsx(Text, { style: { color: c.secondary, fontSize: 13, fontWeight: '600', marginTop: 12 }, children: uiText("Answers") }), options.map((option, i) => _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8 }, children: [_jsx(TextInput, { accessibilityLabel: uiText("Option {value1}", { value1: i + 1 }), placeholder: uiText("Add an option"), placeholderTextColor: c.secondary, maxLength: 100, value: option, onChangeText: v => setOptions(items => items.map((x, n) => n === i ? v : x)), editable: !busy, style: { ...inputStyle, flex: 1 } }), options.length > 2 && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Remove option {value1}", { value1: i + 1 }), disabled: busy, onPress: () => setOptions(items => items.filter((_, n) => n !== i)), style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.secondary, fontSize: 26 }, children: "\u00D7" }) })] }, i)), options.length < 12 && _jsx(Pressable, { accessibilityRole: "button", disabled: busy, onPress: () => setOptions(items => [...items, '']), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 16 }, children: uiText("Add option") }) }), _jsxs(View, { style: { minHeight: 48, flexDirection: 'row', gap: 12, alignItems: 'center', marginTop: 8 }, children: [_jsx(Text, { style: { color: c.foreground, fontSize: 16, flex: 1 }, children: uiText("Allow multiple answers") }), _jsx(Switch, { accessibilityLabel: uiText("Allow multiple answers"), disabled: busy, value: multiple, onValueChange: setMultiple, trackColor: { true: c.accent } })] }), _jsx(Text, { style: { color: c.secondary, fontSize: 13, lineHeight: 19 }, children: uiText("Everyone in the chat can see the votes.") })] }), yesNo && _jsx(Text, { style: { color: c.secondary, fontSize: 13, lineHeight: 19, marginTop: 8 }, children: uiText("Their first Yes or No answer is final.") }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground, marginTop: 8 }, children: error })] }) }), _jsxs(View, { style: { flexDirection: 'row', gap: 8, marginTop: 8 }, children: [_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel"), disabled: busy, onPress: onCancel, style: { flex: 1, minHeight: 44, borderRadius: 12, backgroundColor: c.secondary + '20', alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.foreground, fontSize: 16, fontWeight: '600' }, children: uiText("Cancel") }) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: yesNo ? uiText("Send question") : uiText("Send poll"), disabled: busy || submitted || !ready, onPress: () => void send(), style: { flex: 1, minHeight: 44, borderRadius: 12, backgroundColor: c.accent, opacity: (busy || submitted || !ready) ? 0.45 : 1, alignItems: 'center', justifyContent: 'center' }, children: busy ? _jsx(ActivityIndicator, { color:
|
|
130
|
+
return _jsx(PollModal, { screen: yesNo ? 'question' : 'poll', contentWidth: 640, form: true, title: yesNo ? uiText("Yes/No question") : uiText("New poll"), foreground: c.foreground, closeDisabled: busy, background: c.background, onClose: () => { if (!busy)
|
|
131
|
+
onCancel(); }, children: _jsxs(PollArea, { style: { flex: 1, minHeight: 0, backgroundColor: c.background }, children: [_jsx(View, { style: { flexShrink: 1 }, children: _jsxs(ScrollView, { keyboardShouldPersistTaps: "handled", keyboardDismissMode: "on-drag", contentContainerStyle: { padding: 0, paddingBottom: 12, gap: 8 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 13, fontWeight: '600', marginTop: 4 }, children: uiText("Question") }), _jsx(TextInput, { accessibilityLabel: uiText("Poll question"), placeholder: uiText("Ask a question"), placeholderTextColor: c.secondary, maxLength: 300, multiline: true, value: question, onChangeText: setQuestion, editable: !busy, style: inputStyle }), !yesNo && _jsxs(_Fragment, { children: [_jsx(Text, { style: { color: c.secondary, fontSize: 13, fontWeight: '600', marginTop: 12 }, children: uiText("Answers") }), options.map((option, i) => _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8 }, children: [_jsx(TextInput, { accessibilityLabel: uiText("Option {value1}", { value1: i + 1 }), placeholder: uiText("Add an option"), placeholderTextColor: c.secondary, maxLength: 100, value: option, onChangeText: v => setOptions(items => items.map((x, n) => n === i ? v : x)), editable: !busy, style: { ...inputStyle, flex: 1 } }), options.length > 2 && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Remove option {value1}", { value1: i + 1 }), disabled: busy, onPress: () => setOptions(items => items.filter((_, n) => n !== i)), style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.secondary, fontSize: 26 }, children: "\u00D7" }) })] }, i)), options.length < 12 && _jsx(Pressable, { accessibilityRole: "button", disabled: busy, onPress: () => setOptions(items => [...items, '']), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 16 }, children: uiText("Add option") }) }), _jsxs(View, { style: { minHeight: 48, flexDirection: 'row', gap: 12, alignItems: 'center', marginTop: 8 }, children: [_jsx(Text, { style: { color: c.foreground, fontSize: 16, flex: 1 }, children: uiText("Allow multiple answers") }), _jsx(Switch, { accessibilityLabel: uiText("Allow multiple answers"), disabled: busy, value: multiple, onValueChange: setMultiple, trackColor: { true: c.accent } })] }), _jsx(Text, { style: { color: c.secondary, fontSize: 13, lineHeight: 19 }, children: uiText("Everyone in the chat can see the votes.") })] }), yesNo && _jsx(Text, { style: { color: c.secondary, fontSize: 13, lineHeight: 19, marginTop: 8 }, children: uiText("Their first Yes or No answer is final.") }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground, marginTop: 8 }, children: error })] }) }), _jsxs(View, { style: { flexDirection: 'row', gap: 8, marginTop: 8 }, children: [_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel"), disabled: busy, onPress: onCancel, style: { flex: 1, minHeight: 44, borderRadius: 12, backgroundColor: c.secondary + '20', alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.foreground, fontSize: 16, fontWeight: '600' }, children: uiText("Cancel") }) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: yesNo ? uiText("Send question") : uiText("Send poll"), disabled: busy || submitted || !ready, onPress: () => void send(), style: { flex: 1, minHeight: 44, borderRadius: 12, backgroundColor: c.accent, opacity: (busy || submitted || !ready) ? 0.45 : 1, alignItems: 'center', justifyContent: 'center' }, children: busy ? _jsx(ActivityIndicator, { color: messagingContrastInk(c.accent) }) : _jsx(Text, { style: { color: messagingContrastInk(c.accent), fontSize: 16, fontWeight: '600' }, children: uiText("Send") }) })] })] }) });
|
|
128
132
|
}
|
package/dist/popup.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MessagingStyleScreen } from '@robono/messaging';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { View } from 'react-native';
|
|
3
4
|
export interface MessagingPopupSurfaceProps {
|
|
@@ -10,6 +11,7 @@ export interface MessagingPopupSurfaceProps {
|
|
|
10
11
|
/** Browser hosts can keep settings dialogs inside their embedded chat. */
|
|
11
12
|
export declare const MessagingPopupSurface: React.Context<React.ComponentType<MessagingPopupSurfaceProps> | null>;
|
|
12
13
|
export declare const messagingPopupBackdrop = "#000000d9";
|
|
14
|
+
export { useMessagingPopupColors } from './appearance-context.js';
|
|
13
15
|
export declare const messagingPopupColors: {
|
|
14
16
|
background: string;
|
|
15
17
|
foreground: string;
|
|
@@ -55,7 +57,9 @@ export declare function MessagingMenuSurface({ visible, onClose, onDismiss, chil
|
|
|
55
57
|
children: (rect: MenuRect) => React.ReactNode;
|
|
56
58
|
}): React.JSX.Element;
|
|
57
59
|
/** Content panels occupy the area below the persistent header; confirmations stay compact. */
|
|
58
|
-
export declare function MessagingPopup({ children, onClose, background, form, visible, onDismiss, expanded, bottomPadding, title, foreground, closeLabel, closeDisabled, contentWidth, headerBack, withinChat, compact }: {
|
|
60
|
+
export declare function MessagingPopup({ screen, children, onClose, background, form, visible, onDismiss, expanded, bottomPadding, title, foreground, closeLabel, closeDisabled, contentWidth, headerBack, withinChat, compact, mediaSurface }: {
|
|
61
|
+
screen?: MessagingStyleScreen;
|
|
62
|
+
mediaSurface?: boolean;
|
|
59
63
|
compact?: boolean;
|
|
60
64
|
withinChat?: boolean;
|
|
61
65
|
children: React.ReactNode;
|
|
@@ -73,4 +77,3 @@ export declare function MessagingPopup({ children, onClose, background, form, vi
|
|
|
73
77
|
contentWidth?: number;
|
|
74
78
|
headerBack?: boolean;
|
|
75
79
|
}): React.JSX.Element;
|
|
76
|
-
export {};
|
package/dist/popup.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useMessagingAppearance, useMessagingPopupColors } from './appearance-context.js';
|
|
2
3
|
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
|
3
|
-
import { Text } from './typography.js';
|
|
4
|
+
import { Text, MessagingTypography } from './typography.js';
|
|
4
5
|
import { useRobonoLocale } from './localization.js';
|
|
5
6
|
import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState, useCallback, useMemo } from 'react';
|
|
6
7
|
import { Keyboard, KeyboardAvoidingView, Modal, Platform, Pressable, SafeAreaView, StatusBar, View, useWindowDimensions } from 'react-native';
|
|
@@ -8,11 +9,12 @@ import { MessageIcon } from './icons.js';
|
|
|
8
9
|
/** Browser hosts can keep settings dialogs inside their embedded chat. */
|
|
9
10
|
export const MessagingPopupSurface = createContext(null);
|
|
10
11
|
export const messagingPopupBackdrop = '#000000d9';
|
|
12
|
+
export { useMessagingPopupColors } from './appearance-context.js';
|
|
11
13
|
export const messagingPopupColors = { background: '#000000', foreground: '#ffffff', secondary: '#aaaaaa', incoming: '#202020' };
|
|
12
14
|
/** One title/close row for forms, menus and expanded content. */
|
|
13
15
|
export function MessagingPopupHeader({ title, foreground, onClose, closeLabel, disabled = false, back = false }) {
|
|
14
16
|
const { text: uiText } = useRobonoLocale();
|
|
15
|
-
return _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 44, borderBottomWidth: 1, borderBottomColor: '
|
|
17
|
+
return _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 44, borderBottomWidth: 1, borderBottomColor: foreground + '18' }, children: [_jsx(Text, { accessibilityRole: "header", style: { flex: 1, color: foreground, fontSize: 17, lineHeight: 23, fontWeight: '600' }, children: title }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: closeLabel ?? uiText('Close {name}', { name: title }), disabled: disabled, accessibilityState: { disabled }, onPress: onClose, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center', opacity: disabled ? 0.45 : 1 }, children: _jsx(MessageIcon, { name: back ? 'back' : 'close', color: foreground, size: 24 }) })] });
|
|
16
18
|
}
|
|
17
19
|
// Measure the host and its persistent header, including embedded native layouts.
|
|
18
20
|
const PopupBounds = createContext(null);
|
|
@@ -93,11 +95,14 @@ export function MessagingMenuSurface({ visible, onClose, onDismiss, children })
|
|
|
93
95
|
previous.focus({ preventScroll: true }); };
|
|
94
96
|
}, [visible, !!rect]);
|
|
95
97
|
if (Platform.OS !== 'web')
|
|
96
|
-
return _jsx(Modal, { visible: visible, transparent: true, animationType: "none", onRequestClose: onClose, onDismiss: onDismiss, children: children({ left: 0, top: 0, width: viewport.width, height: viewport.height }) });
|
|
98
|
+
return _jsx(Modal, { visible: visible, transparent: true, animationType: "none", onRequestClose: onClose, onDismiss: onDismiss, children: visible ? children({ left: 0, top: 0, width: viewport.width, height: viewport.height }) : null });
|
|
97
99
|
return _jsx(MessagingPopupLayer, { children: visible && rect ? _jsx(View, { ref: panel, testID: "messaging-menu-surface", style: { position: 'absolute', inset: 0, zIndex: 1000, overflow: 'hidden' }, children: children(rect) }) : null });
|
|
98
100
|
}
|
|
99
101
|
/** Content panels occupy the area below the persistent header; confirmations stay compact. */
|
|
100
|
-
export function MessagingPopup({ children, onClose, background, form = false, visible = true, onDismiss, expanded = true, bottomPadding, title, foreground, closeLabel, closeDisabled = false, contentWidth, headerBack = false, withinChat = false, compact = false }) {
|
|
102
|
+
export function MessagingPopup({ screen = 'panels', children, onClose, background, form = false, visible = true, onDismiss, expanded = true, bottomPadding, title, foreground, closeLabel, closeDisabled = false, contentWidth, headerBack = false, withinChat = false, compact = false, mediaSurface = false }) {
|
|
103
|
+
const appearance = useMessagingAppearance(), panelStyle = appearance?.panels, themeColors = useMessagingPopupColors(undefined, screen);
|
|
104
|
+
const colors = mediaSurface ? messagingPopupColors : themeColors;
|
|
105
|
+
const panelRadius = panelStyle?.corners === 'square' ? 0 : panelStyle?.corners === 'soft' ? 8 : undefined, panelPadding = panelStyle?.spacing === 'compact' ? 8 : panelStyle?.spacing === 'relaxed' ? 20 : undefined;
|
|
101
106
|
const ChatSurface = useContext(MessagingPopupSurface), bounds = useContext(PopupBounds), viewport = useWindowDimensions(), safeInsets = useContext(SafeAreaInsetsContext);
|
|
102
107
|
const [rect, setRect] = useState(null);
|
|
103
108
|
useLayoutEffect(() => {
|
|
@@ -140,8 +145,9 @@ export function MessagingPopup({ children, onClose, background, form = false, vi
|
|
|
140
145
|
} }; document.addEventListener('keydown', escape, true); return () => document.removeEventListener('keydown', escape, true); }, [visible]);
|
|
141
146
|
const bounded = Platform.OS !== 'web' && !!bounds;
|
|
142
147
|
const Frame = Platform.OS === 'ios' && !bounded ? SafeAreaView : View;
|
|
143
|
-
const content = _jsx(Frame, { style: [{ flex: 1, backgroundColor: messagingPopupBackdrop }, bounded ? { position: 'absolute', ...(rect ?? { left: 0, top: 0, width: 0, height: 0 }) } : Platform.OS === 'android' ? { paddingTop: safeInsets?.top ?? StatusBar.currentHeight ?? 0, paddingBottom: safeInsets?.bottom ?? 0 } : undefined], children: _jsxs(KeyboardAvoidingView, { testID: "messaging-popup-backdrop", behavior: Platform.OS === 'ios' ? 'padding' : undefined, style: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: compact ? 24 : 8 }, children: [_jsx(Pressable, { accessible: false, onPress: onClose, style: { position: 'absolute', inset: 0 } }), _jsxs(View, { testID: "messaging-popup-panel", accessibilityViewIsModal: true, onAccessibilityEscape: onClose, style: { width: '100%', ...(compact ? { maxWidth: 360, maxHeight: '100%', flexShrink: 1 } : { flex: 1, minHeight: 0 }), backgroundColor: compact ? '#111111' :
|
|
148
|
+
const content = _jsx(Frame, { style: [{ flex: 1, backgroundColor: messagingPopupBackdrop }, bounded ? { position: 'absolute', ...(rect ?? { left: 0, top: 0, width: 0, height: 0 }) } : Platform.OS === 'android' ? { paddingTop: safeInsets?.top ?? StatusBar.currentHeight ?? 0, paddingBottom: safeInsets?.bottom ?? 0 } : undefined], children: _jsxs(KeyboardAvoidingView, { testID: "messaging-popup-backdrop", behavior: Platform.OS === 'ios' ? 'padding' : undefined, style: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: compact ? 24 : 8 }, children: [_jsx(Pressable, { accessible: false, onPress: onClose, style: { position: 'absolute', inset: 0 } }), _jsxs(View, { testID: "messaging-popup-panel", accessibilityViewIsModal: true, onAccessibilityEscape: onClose, style: { width: '100%', ...(compact ? { maxWidth: 360, maxHeight: '100%', flexShrink: 1 } : { flex: 1, minHeight: 0 }), backgroundColor: compact && !panelStyle?.background && !appearance?.defaultStyle?.colors?.background && !(screen !== 'main' && appearance?.screenStyles?.[screen]?.colors?.background) ? '#111111' : colors.background, borderRadius: panelRadius ?? (compact ? 20 : 18), paddingHorizontal: panelPadding ?? (compact ? 20 : 8), paddingTop: compact ? 8 : 0, paddingBottom: bottomPadding ?? (compact ? 20 : 4), overflow: 'hidden' }, children: [title && _jsx(MessagingPopupHeader, { title: title, foreground: colors.foreground, onClose: onClose, closeLabel: closeLabel, disabled: closeDisabled, back: headerBack }), contentWidth ? _jsx(View, { style: { ...(compact ? { flexShrink: 1 } : { flex: 1, minHeight: 0 }), width: '100%', maxWidth: contentWidth, alignSelf: 'center', paddingTop: 12 }, children: children }) : children] })] }) });
|
|
149
|
+
const styledContent = appearance ? _jsx(MessagingTypography, { appearance: appearance, screen: screen, children: content }) : content;
|
|
144
150
|
if (Platform.OS === 'web' && ChatSurface)
|
|
145
|
-
return _jsx(ChatSurface, { visible: visible, title: title, onDismiss: onDismiss, onClose: onClose, children:
|
|
146
|
-
return _jsx(Modal, { visible: visible, statusBarTranslucent: true, navigationBarTranslucent: true, onDismiss: onDismiss, transparent: true, animationType: "fade", onRequestClose: onClose, children:
|
|
151
|
+
return _jsx(ChatSurface, { visible: visible, title: title, onDismiss: onDismiss, onClose: onClose, children: styledContent });
|
|
152
|
+
return _jsx(Modal, { visible: visible, statusBarTranslucent: true, navigationBarTranslucent: true, onDismiss: onDismiss, transparent: true, animationType: "fade", onRequestClose: onClose, children: styledContent });
|
|
147
153
|
}
|
package/dist/public-rooms.js
CHANGED
|
@@ -3,9 +3,11 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
3
3
|
import { ActivityIndicator, FlatList, Platform, Pressable, View } from 'react-native';
|
|
4
4
|
import { Text, TextInput } from './typography.js';
|
|
5
5
|
import { useRobonoLocale } from './localization.js';
|
|
6
|
-
import { MessagingPopup,
|
|
6
|
+
import { MessagingPopup, useMessagingPopupColors } from './popup.js';
|
|
7
7
|
/** Shared, pane-bounded public group discovery. No user directory is required. */
|
|
8
8
|
export function MessagingPublicRooms({ inbox, accent, createRequestId, onClose, onJoined }) {
|
|
9
|
+
const c = useMessagingPopupColors(undefined, 'publicGroups');
|
|
10
|
+
accent = c.accent;
|
|
9
11
|
const { text, count } = useRobonoLocale();
|
|
10
12
|
const [query, setQuery] = useState(''), [rows, setRows] = useState([]), [next, setNext] = useState(null), [loading, setLoading] = useState(false), [joining, setJoining] = useState(null), [error, setError] = useState('');
|
|
11
13
|
const generation = useRef(0), controller = useRef(null), attempts = useRef(new Map()), busy = useRef(false), mounted = useRef(true);
|
|
@@ -74,5 +76,5 @@ export function MessagingPublicRooms({ inbox, accent, createRequestId, onClose,
|
|
|
74
76
|
setJoining(null);
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
|
-
return _jsxs(MessagingPopup, { visible: visible, onDismiss: finish, title: text('Public groups'), background: c.background, onClose: onClose, children: [_jsx(TextInput, { accessibilityLabel: text('Search public groups'), placeholder: text('Search public groups'), placeholderTextColor: c.secondary, value: query, onChangeText: setQuery, maxLength: 200, style: { color: c.foreground, fontSize: 17, minHeight: 48, paddingHorizontal: 12, borderBottomWidth: 1, borderBottomColor: '
|
|
79
|
+
return _jsxs(MessagingPopup, { screen: 'publicGroups', visible: visible, onDismiss: finish, title: text('Public groups'), background: c.background, onClose: onClose, children: [_jsx(TextInput, { accessibilityLabel: text('Search public groups'), placeholder: text('Search public groups'), placeholderTextColor: c.secondary, value: query, onChangeText: setQuery, maxLength: 200, style: { backgroundColor: c.incoming, color: c.foreground, fontSize: 17, minHeight: 48, paddingHorizontal: 12, borderBottomWidth: 1, borderBottomColor: c.foreground + '30' } }), !!error && _jsxs(View, { style: { padding: 12, gap: 4 }, children: [_jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: error }), _jsx(Pressable, { accessibilityRole: "button", disabled: loading, onPress: () => void load(), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent }, children: text('Retry') }) })] }), _jsx(FlatList, { data: rows, keyExtractor: r => r.id, style: { flex: 1 }, keyboardShouldPersistTaps: "handled", contentContainerStyle: { paddingHorizontal: 12, paddingBottom: 12 }, initialNumToRender: 15, renderItem: ({ item: room }) => _jsxs(View, { style: { flexDirection: 'row', gap: 12, alignItems: 'center', paddingVertical: 14, borderBottomWidth: 1, borderBottomColor: c.foreground + '18' }, children: [_jsxs(View, { style: { flex: 1, gap: 4 }, children: [_jsx(Text, { style: { color: c.foreground, fontSize: 18, fontWeight: '600' }, children: room.name }), !!room.description && _jsx(Text, { numberOfLines: 3, style: { color: c.secondary, fontSize: 15, lineHeight: 21 }, children: room.description }), _jsx(Text, { style: { color: c.secondary, fontSize: 13 }, children: count(room.memberCount, '{count} member', '{count} members') })] }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: text(room.joined ? 'Open {name}' : 'Join {name}', { name: room.name }), accessibilityState: { disabled: !!joining || !room.joined && !room.joinable }, disabled: !!joining || !room.joined && !room.joinable, onPress: () => void join(room), style: { minHeight: 44, minWidth: 70, paddingHorizontal: 12, alignItems: 'center', justifyContent: 'center', borderRadius: 12, borderWidth: 1, borderColor: accent, opacity: !room.joined && !room.joinable ? .4 : 1 }, children: joining === room.id ? _jsx(ActivityIndicator, { color: accent }) : _jsx(Text, { style: { color: accent, fontWeight: '600' }, children: text(room.joined ? 'Open' : room.joinable ? 'Join' : 'Closed') }) })] }), ListEmptyComponent: !loading && !error ? _jsx(Text, { style: { color: c.secondary, paddingVertical: 24, textAlign: 'center' }, children: text(query.trim() ? 'No matching public groups.' : 'No public groups yet.') }) : null, ListFooterComponent: _jsxs(View, { children: [loading && _jsx(ActivityIndicator, { accessibilityLabel: text('Loading public groups'), color: accent, style: { padding: 16 } }), next && !loading && _jsx(Pressable, { accessibilityRole: "button", onPress: () => void load(true), style: { minHeight: 48, justifyContent: 'center', alignItems: 'center' }, children: _jsx(Text, { style: { color: accent }, children: text('Load more') }) })] }) })] });
|
|
78
80
|
}
|
package/dist/quick-send.js
CHANGED
|
@@ -10,7 +10,7 @@ import { MessageIcon, chatSurface } from './icons.js';
|
|
|
10
10
|
export function QuickSendButton({ choice, empty, enabled, disabled, editing, sendAvailable, appearance, onChoose, onSend, onQuickSend, onSchedule }) {
|
|
11
11
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
12
12
|
const [anchor, setAnchor] = useState(null), held = useRef(false), button = useRef(null), viewport = useWindowDimensions();
|
|
13
|
-
const emoji = validQuickMessage(choice) ? choice : '👍', quick = empty && enabled && !editing, unavailable = disabled || (!quick && !sendAvailable), c = appearance.colors;
|
|
13
|
+
const emoji = validQuickMessage(choice) ? choice : '👍', quick = empty && enabled && !editing, unavailable = disabled || (!quick && !sendAvailable), c = appearance.colors, reactions = appearance.menus?.message;
|
|
14
14
|
useEffect(() => { if (!quick || disabled)
|
|
15
15
|
setAnchor(null); }, [quick, disabled]);
|
|
16
16
|
const show = () => { held.current = true; button.current?.measureInWindow((x, y, width) => setAnchor({ x: x + width, y })); };
|
|
@@ -37,5 +37,5 @@ export function QuickSendButton({ choice, empty, enabled, disabled, editing, sen
|
|
|
37
37
|
held.current = true;
|
|
38
38
|
onSchedule?.();
|
|
39
39
|
}
|
|
40
|
-
} } } : {}), style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center', opacity: unavailable ? .4 : 1 }, children: quick ? _jsx(Text, { style: { fontSize: 26, lineHeight: 32 }, children: emoji }) : _jsx(MessageIcon, { name: editing ? 'check' : 'send', size: 24, color: c.accent }) }), _jsx(MessagingMenuSurface, { visible: anchor !== null, onClose: () => setAnchor(null), children: rect => _jsxs(View, { accessibilityViewIsModal: true, style: { flex: 1 }, children: [_jsx(Pressable, { accessibilityLabel: uiText("Close quick messages"), onPress: () => setAnchor(null), style: { position: 'absolute', inset: 0, backgroundColor: messagingPopupBackdrop } }), _jsxs(View, { style: { position: 'absolute', width: Math.min(304, rect.width - 24), maxHeight: Math.max(100, rect.height - 24), left: Math.max(12, Math.min((anchor?.x ?? rect.width) - rect.left - 304, rect.width - Math.min(304, rect.width - 24) - 12)), top: Math.max(12, Math.min((anchor?.y ?? rect.height) - rect.top - 282, rect.height - 312)), backgroundColor: chatSurface(c.background), borderRadius: 18, borderWidth: 1, borderColor: c.secondary + '40', padding: 8, boxShadow: '0 4px 18px #0005' }, children: [_jsx(MessagingPopupHeader, { title: uiText("Quick message"), foreground: c.foreground, closeLabel: uiText("Close quick message picker"), onClose: () => setAnchor(null) }), _jsx(ScrollView, { style: { maxHeight: Math.min(220, Math.max(44, rect.height - 90)) }, keyboardShouldPersistTaps: "handled", contentContainerStyle: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'center' }, children: quickMessageOptions.map(item => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText(item.label), accessibilityState: { selected: emoji === item.emoji }, onPress: () => { held.current = false; setAnchor(null); onChoose(item.emoji); }, style: { width: 46, height: 44, alignItems: 'center', justifyContent: 'center', borderRadius: 10, backgroundColor: emoji === item.emoji ? c.accent + '20' : 'transparent' }, children: _jsx(Text, { style: { fontSize: 26, lineHeight: 32 }, children: item.emoji }) }, item.emoji)) })] })] }) })] });
|
|
40
|
+
} } } : {}), style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center', opacity: unavailable ? .4 : 1 }, children: quick ? _jsx(Text, { style: { fontSize: 26, lineHeight: 32 }, children: emoji }) : _jsx(MessageIcon, { name: editing ? 'check' : 'send', size: 24, color: c.accent }) }), _jsx(MessagingMenuSurface, { visible: anchor !== null, onClose: () => setAnchor(null), children: rect => _jsxs(View, { accessibilityViewIsModal: true, style: { flex: 1 }, children: [_jsx(Pressable, { accessibilityLabel: uiText("Close quick messages"), onPress: () => setAnchor(null), style: { position: 'absolute', inset: 0, backgroundColor: messagingPopupBackdrop } }), _jsxs(View, { style: { position: 'absolute', width: Math.min(304, rect.width - 24), maxHeight: Math.max(100, rect.height - 24), left: Math.max(12, Math.min((anchor?.x ?? rect.width) - rect.left - 304, rect.width - Math.min(304, rect.width - 24) - 12)), top: Math.max(12, Math.min((anchor?.y ?? rect.height) - rect.top - 282, rect.height - 312)), backgroundColor: reactions?.reactionBackground ?? chatSurface(c.background), borderRadius: reactions?.corners === 'square' ? 0 : reactions?.corners === 'soft' ? 8 : 18, borderWidth: 1, borderColor: c.secondary + '40', padding: 8, boxShadow: '0 4px 18px #0005' }, children: [_jsx(MessagingPopupHeader, { title: uiText("Quick message"), foreground: reactions?.foreground ?? c.foreground, closeLabel: uiText("Close quick message picker"), onClose: () => setAnchor(null) }), _jsx(ScrollView, { style: { maxHeight: Math.min(220, Math.max(44, rect.height - 90)) }, keyboardShouldPersistTaps: "handled", contentContainerStyle: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'center' }, children: quickMessageOptions.map(item => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText(item.label), accessibilityState: { selected: emoji === item.emoji }, onPress: () => { held.current = false; setAnchor(null); onChoose(item.emoji); }, style: { width: 46, height: 44, alignItems: 'center', justifyContent: 'center', borderRadius: 10, backgroundColor: emoji === item.emoji ? (reactions?.reactionSelected ?? c.accent + '20') : 'transparent' }, children: _jsx(Text, { style: { fontSize: reactions?.reactionSize ?? 26, lineHeight: 32 }, children: item.emoji }) }, item.emoji)) })] })] }) })] });
|
|
41
41
|
}
|
package/dist/room-moderation.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { messagingContrastInk } from '@robono/messaging';
|
|
2
3
|
import { useEffect, useRef, useState } from 'react';
|
|
3
4
|
import { ActivityIndicator, FlatList, Image, Pressable, View } from 'react-native';
|
|
4
5
|
import { Text, TextInput } from './typography.js';
|
|
5
6
|
import { useRobonoLocale } from './localization.js';
|
|
6
|
-
import { MessagingPopup,
|
|
7
|
+
import { MessagingPopup, useMessagingPopupColors } from './popup.js';
|
|
7
8
|
/** Owners/moderators see current roles; the service decides whether each change is allowed. */
|
|
8
9
|
export function MessagingRoomModeration({ client, userId, participants = {}, accent, onClose }) {
|
|
10
|
+
const c = useMessagingPopupColors(undefined, 'moderation');
|
|
11
|
+
accent = c.accent;
|
|
9
12
|
const { text } = useRobonoLocale();
|
|
10
13
|
const [rows, setRows] = useState([]), [next, setNext] = useState(null), [loading, setLoading] = useState(false), [busy, setBusy] = useState(false), [error, setError] = useState(''), [selected, setSelected] = useState(null), [confirm, setConfirm] = useState(null);
|
|
11
14
|
const generation = useRef(0), attempt = useRef(null), working = useRef(false);
|
|
@@ -56,17 +59,19 @@ export function MessagingRoomModeration({ client, userId, participants = {}, acc
|
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
const labels = { promote: 'Make moderator', demote: 'Remove moderator role', mute: 'Mute member', unmute: 'Unmute member', ban: 'Ban member', unban: 'Remove ban' };
|
|
59
|
-
return _jsxs(MessagingPopup, { title: text('Group moderation'), background: c.background, onClose: onClose, children: [confirm ? _jsxs(View, { style: { gap: 16, paddingVertical: 12 }, children: [_jsxs(Text, { style: { color: c.foreground, fontSize: 20, fontWeight: '600' }, children: [text(labels[confirm.action]), " \u00B7 ", participants[confirm.userId]?.name ?? confirm.userId] }), _jsx(Text, { style: { color: c.secondary, fontSize: 16, lineHeight: 23 }, children: text(confirm.action === 'ban' ? 'They will leave this group and cannot rejoin until the ban is removed.' : confirm.action === 'mute' ? 'They can read this group but cannot post or react.' : confirm.action === 'promote' ? 'They can mute and ban members. Only the owner can change moderator roles.' : confirm.action === 'unban' ? 'They can choose to join again. This does not automatically rejoin them.' : 'This changes their permissions in this group.') }), _jsxs(View, { style: { flexDirection: 'row', gap: 16 }, children: [_jsx(Pressable, { accessibilityRole: "button", disabled: busy, onPress: () => void apply(), style: { minHeight: 48, justifyContent: 'center', paddingHorizontal: 16, borderRadius: 12, backgroundColor: confirm.action === 'ban' ? '#b72d34' : accent }, children: _jsx(Text, { style: { color: confirm.action === 'ban' ? '#fff' :
|
|
62
|
+
return _jsxs(MessagingPopup, { screen: 'moderation', title: text('Group moderation'), background: c.background, onClose: onClose, children: [confirm ? _jsxs(View, { style: { gap: 16, paddingVertical: 12 }, children: [_jsxs(Text, { style: { color: c.foreground, fontSize: 20, fontWeight: '600' }, children: [text(labels[confirm.action]), " \u00B7 ", participants[confirm.userId]?.name ?? confirm.userId] }), _jsx(Text, { style: { color: c.secondary, fontSize: 16, lineHeight: 23 }, children: text(confirm.action === 'ban' ? 'They will leave this group and cannot rejoin until the ban is removed.' : confirm.action === 'mute' ? 'They can read this group but cannot post or react.' : confirm.action === 'promote' ? 'They can mute and ban members. Only the owner can change moderator roles.' : confirm.action === 'unban' ? 'They can choose to join again. This does not automatically rejoin them.' : 'This changes their permissions in this group.') }), _jsxs(View, { style: { flexDirection: 'row', gap: 16 }, children: [_jsx(Pressable, { accessibilityRole: "button", disabled: busy, onPress: () => void apply(), style: { minHeight: 48, justifyContent: 'center', paddingHorizontal: 16, borderRadius: 12, backgroundColor: confirm.action === 'ban' ? '#b72d34' : accent }, children: _jsx(Text, { style: { color: confirm.action === 'ban' ? '#fff' : messagingContrastInk(accent), fontWeight: '600' }, children: busy ? text('Saving…') : text(labels[confirm.action]) }) }), _jsx(Pressable, { accessibilityRole: "button", disabled: busy, onPress: () => setConfirm(null), style: { minHeight: 48, justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent }, children: text('Back') }) })] })] }) : _jsx(FlatList, { data: rows, keyExtractor: m => m.userId, style: { flex: 1 }, contentContainerStyle: { paddingHorizontal: 8, paddingBottom: 12 }, renderItem: ({ item }) => {
|
|
60
63
|
const allowed = item.userId !== userId && item.role !== 'owner' && (owner || item.role !== 'moderator');
|
|
61
64
|
const actions = item.banned ? ['unban'] : ['mute', 'ban'];
|
|
62
65
|
if (!item.banned && item.muted)
|
|
63
66
|
actions[0] = 'unmute';
|
|
64
67
|
if (owner && !item.banned)
|
|
65
68
|
actions.unshift(item.role === 'moderator' ? 'demote' : 'promote');
|
|
66
|
-
return _jsxs(View, { style: { borderBottomWidth: 1, borderBottomColor: '
|
|
69
|
+
return _jsxs(View, { style: { borderBottomWidth: 1, borderBottomColor: c.foreground + '20' }, children: [_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: text('Manage {name}', { name: participants[item.userId]?.name ?? item.userId }), disabled: !allowed, onPress: () => setSelected(selected === item.userId ? null : item.userId), style: { minHeight: 64, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [participants[item.userId]?.avatarUrl && _jsx(Image, { source: { uri: participants[item.userId].avatarUrl }, style: { width: 36, height: 36, borderRadius: 18 } }), _jsxs(View, { style: { flex: 1, gap: 4 }, children: [_jsx(Text, { style: { color: c.foreground, fontSize: 17 }, children: item.userId === userId ? text('You') : participants[item.userId]?.name ?? item.userId }), _jsx(Text, { style: { color: c.secondary, fontSize: 14 }, children: text(item.banned ? 'Banned' : item.role === 'owner' ? 'Owner' : item.role === 'moderator' ? 'Moderator' : item.muted ? 'Muted' : 'Member') })] }), allowed && _jsx(Text, { style: { color: accent, fontSize: 15 }, children: text('Manage') })] }), allowed && selected === item.userId && _jsx(View, { style: { gap: 4, paddingBottom: 12 }, children: actions.map(action => _jsx(Pressable, { accessibilityRole: "button", onPress: () => { setError(''); setConfirm({ userId: item.userId, action }); }, style: { minHeight: 44, justifyContent: 'center', paddingHorizontal: 12, borderRadius: 10, backgroundColor: c.incoming }, children: _jsx(Text, { style: { color: action === 'ban' ? c.danger : accent, fontSize: 16 }, children: text(labels[action]) }) }, action)) })] });
|
|
67
70
|
}, ListFooterComponent: _jsxs(View, { children: [loading && _jsx(ActivityIndicator, { color: accent, accessibilityLabel: text('Loading group members'), style: { padding: 16 } }), next && !loading && _jsx(Pressable, { accessibilityRole: "button", onPress: () => void load(true), style: { minHeight: 48, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent }, children: text('Load more members') }) })] }) }), !!error && _jsxs(View, { style: { padding: 12, gap: 4 }, children: [_jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: error }), !confirm && _jsx(Pressable, { accessibilityRole: "button", onPress: () => void load(), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent }, children: text('Retry') }) })] })] });
|
|
68
71
|
}
|
|
69
72
|
export function MessagingRoomRemoval({ client, message, accent, onClose }) {
|
|
73
|
+
const c = useMessagingPopupColors(undefined, 'moderation');
|
|
74
|
+
accent = c.accent;
|
|
70
75
|
const { text } = useRobonoLocale();
|
|
71
76
|
const [reason, setReason] = useState(''), [busy, setBusy] = useState(false), [error, setError] = useState('');
|
|
72
77
|
const attempt = useRef(null), working = useRef(false);
|
|
@@ -83,5 +88,5 @@ export function MessagingRoomRemoval({ client, message, accent, onClose }) {
|
|
|
83
88
|
working.current = false;
|
|
84
89
|
setBusy(false);
|
|
85
90
|
} }
|
|
86
|
-
return _jsx(MessagingPopup, { compact: true, title: text('Remove from group?'), background: c.background, closeDisabled: busy, onClose: onClose, children: _jsxs(View, { style: { gap: 12, paddingTop: 12 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 16, lineHeight: 23 }, children: text('This removes the message for everyone in this group, even if it has been read. Your reason is kept in the moderation record.') }), _jsx(TextInput, { accessibilityLabel: text('Reason for removing message'), placeholder: text('Reason'), placeholderTextColor: c.secondary, multiline: true, maxLength: 1000, value: reason, onChangeText: setReason, editable: !busy, style: { color: c.foreground, fontSize: 16, minHeight: 80, padding: 12, borderWidth: 1, borderColor: c.secondary, borderRadius: 12 } }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: error }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: text('Remove message for group'), disabled: busy || !reason.trim(), onPress: () => void remove(), style: { minHeight: 48, borderRadius: 12, alignItems: 'center', justifyContent: 'center', backgroundColor: '#b72d34', opacity: busy || !reason.trim() ? .5 : 1 }, children: _jsx(Text, { style: { color: '#fff', fontSize: 16, fontWeight: '600' }, children: busy ? text('Removing…') : text('Remove message') }) })] }) });
|
|
91
|
+
return _jsx(MessagingPopup, { screen: 'moderation', compact: true, title: text('Remove from group?'), background: c.background, closeDisabled: busy, onClose: onClose, children: _jsxs(View, { style: { gap: 12, paddingTop: 12 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 16, lineHeight: 23 }, children: text('This removes the message for everyone in this group, even if it has been read. Your reason is kept in the moderation record.') }), _jsx(TextInput, { accessibilityLabel: text('Reason for removing message'), placeholder: text('Reason'), placeholderTextColor: c.secondary, multiline: true, maxLength: 1000, value: reason, onChangeText: setReason, editable: !busy, style: { backgroundColor: c.incoming, color: c.foreground, fontSize: 16, minHeight: 80, padding: 12, borderWidth: 1, borderColor: c.secondary, borderRadius: 12 } }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: error }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: text('Remove message for group'), disabled: busy || !reason.trim(), onPress: () => void remove(), style: { minHeight: 48, borderRadius: 12, alignItems: 'center', justifyContent: 'center', backgroundColor: '#b72d34', opacity: busy || !reason.trim() ? .5 : 1 }, children: _jsx(Text, { style: { color: '#fff', fontSize: 16, fontWeight: '600' }, children: busy ? text('Removing…') : text('Remove message') }) })] }) });
|
|
87
92
|
}
|
package/dist/safety.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { MessagingClient, MessagingAppearance, MessagingState } from '@robono/messaging';
|
|
3
3
|
/** Uses the authenticated messaging client's durable safety operations, or the host can keep its own UI. */
|
|
4
|
-
export declare function MessagingSafety({ client, state, appearance, name, messageId, onClose, onSearch, onDetails, onPins, onScheduled, onSaved, children, menuAnchor }: {
|
|
4
|
+
export declare function MessagingSafety({ client, state, appearance, name, messageId, onClose, onSearch, onDetails, onMedia, onOptions, onPins, onScheduled, onSaved, children, menuAnchor, initialMode }: {
|
|
5
5
|
client: MessagingClient;
|
|
6
|
-
state: MessagingState
|
|
6
|
+
state: Pick<MessagingState, 'conversation'>;
|
|
7
7
|
appearance: MessagingAppearance;
|
|
8
8
|
name: string;
|
|
9
9
|
messageId?: string;
|
|
10
10
|
onClose: () => void;
|
|
11
11
|
onSearch?: () => void;
|
|
12
12
|
onDetails?: () => void;
|
|
13
|
+
onMedia?: () => void;
|
|
14
|
+
onOptions?: () => void;
|
|
13
15
|
onPins?: () => void;
|
|
14
16
|
onScheduled?: () => void;
|
|
15
17
|
onSaved?: () => void;
|
|
@@ -18,4 +20,5 @@ export declare function MessagingSafety({ client, state, appearance, name, messa
|
|
|
18
20
|
x: number;
|
|
19
21
|
y: number;
|
|
20
22
|
};
|
|
23
|
+
initialMode?: 'menu' | 'translation' | 'block' | 'report';
|
|
21
24
|
}): React.JSX.Element;
|