@streamplace/components 0.7.18 → 0.7.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/emoji-data.json +19371 -0
- package/dist/components/chat/chat-box.js +319 -0
- package/dist/components/chat/chat-message.js +87 -0
- package/dist/components/chat/chat.js +150 -0
- package/dist/components/chat/emoji-suggestions.js +35 -0
- package/dist/components/chat/mention-suggestions.js +42 -0
- package/dist/components/chat/mod-view.js +112 -0
- package/dist/components/chat/system-message.js +19 -0
- package/dist/components/dashboard/chat-panel.js +38 -0
- package/dist/components/dashboard/header.js +80 -0
- package/dist/components/dashboard/index.js +14 -0
- package/dist/components/dashboard/information-widget.js +234 -0
- package/dist/components/dashboard/mod-actions.js +71 -0
- package/dist/components/dashboard/problems.js +74 -0
- package/dist/components/icons/bluesky-icon.js +9 -0
- package/dist/components/keep-awake.js +7 -0
- package/dist/components/keep-awake.native.js +16 -0
- package/dist/components/mobile-player/fullscreen.js +76 -0
- package/dist/components/mobile-player/fullscreen.native.js +141 -0
- package/dist/components/mobile-player/player.js +94 -0
- package/dist/components/mobile-player/props.js +2 -0
- package/dist/components/mobile-player/shared.js +54 -0
- package/dist/components/mobile-player/ui/autoplay-button.js +68 -0
- package/dist/components/mobile-player/ui/countdown.js +83 -0
- package/dist/components/mobile-player/ui/index.js +12 -0
- package/dist/components/mobile-player/ui/input.js +42 -0
- package/dist/components/mobile-player/ui/metrics.js +44 -0
- package/dist/components/mobile-player/ui/report-modal.js +90 -0
- package/dist/components/mobile-player/ui/streamer-context-menu.js +7 -0
- package/dist/components/mobile-player/ui/streamer-loading-overlay.js +104 -0
- package/dist/components/mobile-player/ui/viewer-context-menu.js +51 -0
- package/dist/components/mobile-player/ui/viewer-loading-overlay.js +49 -0
- package/dist/components/mobile-player/ui/viewers.js +23 -0
- package/dist/components/mobile-player/use-webrtc.js +243 -0
- package/dist/components/mobile-player/video-async.native.js +276 -0
- package/dist/components/mobile-player/video-retry.js +29 -0
- package/dist/components/mobile-player/video.js +475 -0
- package/dist/components/mobile-player/video.native.js +56 -0
- package/dist/components/mobile-player/webrtc-diagnostics.js +110 -0
- package/dist/components/mobile-player/webrtc-primitives.js +27 -0
- package/dist/components/mobile-player/webrtc-primitives.native.js +8 -0
- package/dist/components/share/sharesheet.js +91 -0
- package/dist/components/ui/button.js +223 -0
- package/dist/components/ui/dialog.js +206 -0
- package/dist/components/ui/dropdown.js +172 -0
- package/dist/components/ui/icons.js +25 -0
- package/dist/components/ui/index.js +34 -0
- package/dist/components/ui/info-box.js +31 -0
- package/dist/components/ui/info-row.js +23 -0
- package/dist/components/ui/input.js +205 -0
- package/dist/components/ui/loader.js +10 -0
- package/dist/components/ui/primitives/button.js +125 -0
- package/dist/components/ui/primitives/input.js +206 -0
- package/dist/components/ui/primitives/modal.js +206 -0
- package/dist/components/ui/primitives/text.js +292 -0
- package/dist/components/ui/resizeable.js +121 -0
- package/dist/components/ui/slider.js +5 -0
- package/dist/components/ui/text.js +177 -0
- package/dist/components/ui/textarea.js +19 -0
- package/dist/components/ui/toast.js +175 -0
- package/dist/components/ui/view.js +252 -0
- package/dist/hooks/index.js +14 -0
- package/dist/hooks/useAvatars.js +35 -0
- package/dist/hooks/useCameraToggle.js +12 -0
- package/dist/hooks/useKeyboard.js +36 -0
- package/dist/hooks/useKeyboardSlide.js +14 -0
- package/dist/hooks/useLivestreamInfo.js +69 -0
- package/dist/hooks/useOuterAndInnerDimensions.js +30 -0
- package/dist/hooks/usePlayerDimensions.js +22 -0
- package/dist/hooks/usePointerDevice.js +71 -0
- package/dist/hooks/useSegmentDimensions.js +17 -0
- package/dist/hooks/useSegmentTiming.js +65 -0
- package/dist/index.js +34 -0
- package/dist/lib/browser.js +35 -0
- package/dist/lib/facet.js +92 -0
- package/dist/lib/system-messages.js +101 -0
- package/dist/lib/theme/atoms.js +646 -0
- package/dist/lib/theme/atoms.types.js +6 -0
- package/dist/lib/theme/index.js +35 -0
- package/dist/lib/theme/theme.js +256 -0
- package/dist/lib/theme/tokens.js +659 -0
- package/dist/lib/utils.js +105 -0
- package/dist/livestream-provider/index.js +30 -0
- package/dist/livestream-provider/websocket.js +45 -0
- package/dist/livestream-store/chat.js +308 -0
- package/dist/livestream-store/context.js +5 -0
- package/dist/livestream-store/index.js +7 -0
- package/dist/livestream-store/livestream-state.js +2 -0
- package/dist/livestream-store/livestream-store.js +58 -0
- package/dist/livestream-store/problems.js +76 -0
- package/dist/livestream-store/stream-key.js +88 -0
- package/dist/livestream-store/websocket-consumer.js +94 -0
- package/dist/player-store/context.js +5 -0
- package/dist/player-store/index.js +9 -0
- package/dist/player-store/player-provider.js +58 -0
- package/dist/player-store/player-state.js +25 -0
- package/dist/player-store/player-store.js +201 -0
- package/dist/player-store/single-player-provider.js +121 -0
- package/dist/streamplace-provider/context.js +5 -0
- package/dist/streamplace-provider/index.js +20 -0
- package/dist/streamplace-provider/poller.js +49 -0
- package/dist/streamplace-provider/xrpc.js +0 -0
- package/dist/streamplace-store/block.js +65 -0
- package/dist/streamplace-store/index.js +6 -0
- package/dist/streamplace-store/stream.js +247 -0
- package/dist/streamplace-store/streamplace-store.js +47 -0
- package/dist/streamplace-store/user.js +52 -0
- package/dist/streamplace-store/xrpc.js +15 -0
- package/dist/ui/index.js +79 -0
- package/node-compile-cache/v22.15.0-x64-efe9a9df-0/37be0eec +0 -0
- package/package.json +5 -4
- package/src/components/chat/chat-box.tsx +3 -0
- package/src/components/chat/mod-view.tsx +39 -5
- package/src/components/mobile-player/fullscreen.tsx +2 -0
- package/src/components/mobile-player/ui/autoplay-button.tsx +86 -0
- package/src/components/mobile-player/ui/index.ts +1 -0
- package/src/components/mobile-player/video.tsx +11 -1
- package/src/livestream-store/chat.tsx +22 -0
- package/src/player-store/player-provider.tsx +2 -1
- package/src/player-store/player-state.tsx +6 -0
- package/src/player-store/player-store.tsx +4 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatBox = ChatBox;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("@emoji-mart/react"));
|
|
7
|
+
const lucide_react_native_1 = require("lucide-react-native");
|
|
8
|
+
const react_2 = require("react");
|
|
9
|
+
const react_native_1 = require("react-native");
|
|
10
|
+
const __1 = require("../../");
|
|
11
|
+
const atoms_1 = require("../../lib/theme/atoms");
|
|
12
|
+
const xrpc_1 = require("../../streamplace-store/xrpc");
|
|
13
|
+
const textarea_1 = require("../ui/textarea");
|
|
14
|
+
const chat_message_1 = require("./chat-message");
|
|
15
|
+
const emoji_suggestions_1 = require("./emoji-suggestions");
|
|
16
|
+
const mention_suggestions_1 = require("./mention-suggestions");
|
|
17
|
+
const COOL_EMOJI_LIST = [
|
|
18
|
+
..."😀🥸😍😘😁🥸😆🥸😜🥸😂😅🥸🙂🤫😱🥸🤣😗😄🥸😎🤓😲😯😰🥸😥🥸😣🥸😞😓🥸😩😩🥸😤🥱",
|
|
19
|
+
];
|
|
20
|
+
function ChatBox({ isPopout, chatBoxStyle, emojiData, setIsChatVisible, }) {
|
|
21
|
+
const [submitting, setSubmitting] = (0, react_2.useState)(false);
|
|
22
|
+
const [message, setMessage] = (0, react_2.useState)("");
|
|
23
|
+
const [showSuggestions, setShowSuggestions] = (0, react_2.useState)(false);
|
|
24
|
+
const [showEmojiSuggestions, setShowEmojiSuggestions] = (0, react_2.useState)(false);
|
|
25
|
+
const [showEmojiSelector, setShowEmojiSelector] = (0, react_2.useState)(false);
|
|
26
|
+
const [emojiIconIndex, setEmojiIconIndex] = (0, react_2.useState)(Math.floor(Math.random() * COOL_EMOJI_LIST.length));
|
|
27
|
+
const [highlightedIndex, setHighlightedIndex] = (0, react_2.useState)(0);
|
|
28
|
+
const [filteredAuthors, setFilteredAuthors] = (0, react_2.useState)(new Map());
|
|
29
|
+
const [filteredEmojis, setFilteredEmojis] = (0, react_2.useState)([]);
|
|
30
|
+
let linfo = (0, __1.useLivestream)();
|
|
31
|
+
const chat = (0, __1.useChat)();
|
|
32
|
+
const createChatMessage = (0, __1.useCreateChatMessage)();
|
|
33
|
+
const replyTo = (0, __1.useReplyToMessage)();
|
|
34
|
+
const setReplyToMessage = (0, __1.useSetReplyToMessage)();
|
|
35
|
+
const textAreaRef = (0, react_2.useRef)(null);
|
|
36
|
+
// are we logged in?
|
|
37
|
+
let agent = (0, xrpc_1.usePDSAgent)();
|
|
38
|
+
if (!agent?.did) {
|
|
39
|
+
(0, jsx_runtime_1.jsx)(__1.View, { style: [atoms_1.layout.flex.row, atoms_1.layout.flex.alignCenter, atoms_1.gap.all[2]], children: (0, jsx_runtime_1.jsx)(__1.Text, { children: "Log in to chat." }) });
|
|
40
|
+
}
|
|
41
|
+
const authors = (0, react_2.useMemo)(() => {
|
|
42
|
+
if (!chat)
|
|
43
|
+
return null;
|
|
44
|
+
return chat.reduce((acc, msg) => {
|
|
45
|
+
// our fake system user "did"
|
|
46
|
+
if (msg.author.did === "did:sys:system")
|
|
47
|
+
return acc;
|
|
48
|
+
if (acc.has(msg.author.handle))
|
|
49
|
+
return acc;
|
|
50
|
+
acc.set(msg.author.handle, msg.chatProfile);
|
|
51
|
+
return acc;
|
|
52
|
+
}, new Map());
|
|
53
|
+
}, [chat]);
|
|
54
|
+
const handleMentionSelect = (handle) => {
|
|
55
|
+
const beforeAt = message.slice(0, message.lastIndexOf("@"));
|
|
56
|
+
setMessage(`${beforeAt}@${handle} `);
|
|
57
|
+
setShowSuggestions(false);
|
|
58
|
+
};
|
|
59
|
+
const handleEmojiSelect = (emoji) => {
|
|
60
|
+
const beforeColon = message.slice(0, message.lastIndexOf(":"));
|
|
61
|
+
setMessage(`${beforeColon}${emoji.skins[0]?.native} `);
|
|
62
|
+
setShowEmojiSuggestions(false);
|
|
63
|
+
};
|
|
64
|
+
const updateSuggestions = (text) => {
|
|
65
|
+
// Handle mentions
|
|
66
|
+
const atIndex = text.lastIndexOf("@");
|
|
67
|
+
if (atIndex !== -1 && authors) {
|
|
68
|
+
const searchText = text.slice(atIndex + 1).toLowerCase();
|
|
69
|
+
const filteredAuthorsMap = new Map(Array.from(authors.entries()).filter(([handle]) => handle.toLowerCase().includes(searchText)));
|
|
70
|
+
setFilteredAuthors(filteredAuthorsMap);
|
|
71
|
+
setHighlightedIndex(0);
|
|
72
|
+
setShowSuggestions(filteredAuthorsMap.size > 0);
|
|
73
|
+
setShowEmojiSuggestions(false);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
setShowSuggestions(false);
|
|
77
|
+
}
|
|
78
|
+
const colonIndex = text.lastIndexOf(":");
|
|
79
|
+
if (colonIndex !== -1) {
|
|
80
|
+
const searchText = text.slice(colonIndex + 1).toLowerCase();
|
|
81
|
+
if (searchText.length > 0) {
|
|
82
|
+
const aliasMatches = Object.entries(emojiData.aliases)
|
|
83
|
+
.map(([alias, emojiId]) => {
|
|
84
|
+
const aliasLower = alias.toLowerCase();
|
|
85
|
+
if (aliasLower === searchText) {
|
|
86
|
+
return { emojiId, alias, matchType: 0, index: 0 };
|
|
87
|
+
}
|
|
88
|
+
else if (aliasLower.startsWith(searchText)) {
|
|
89
|
+
return { emojiId, alias, matchType: 1, index: 0 };
|
|
90
|
+
}
|
|
91
|
+
else if (aliasLower.includes(searchText)) {
|
|
92
|
+
return {
|
|
93
|
+
emojiId,
|
|
94
|
+
alias,
|
|
95
|
+
matchType: 2,
|
|
96
|
+
index: aliasLower.indexOf(searchText),
|
|
97
|
+
}; // includes
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
})
|
|
101
|
+
.filter(Boolean);
|
|
102
|
+
// Map emojiId to best alias match info
|
|
103
|
+
const bestAliasMatch = {};
|
|
104
|
+
for (const match of aliasMatches) {
|
|
105
|
+
if (!match)
|
|
106
|
+
continue;
|
|
107
|
+
const prev = bestAliasMatch[match.emojiId];
|
|
108
|
+
if (!prev ||
|
|
109
|
+
match?.matchType < prev.matchType ||
|
|
110
|
+
(match.matchType === prev.matchType && match.index < prev.index)) {
|
|
111
|
+
bestAliasMatch[match.emojiId] = match;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Collect all matching emojis by id, name, keywords, or alias
|
|
115
|
+
const allEmojis = Object.values(emojiData.emojis);
|
|
116
|
+
const filtered = allEmojis
|
|
117
|
+
.map((emoji) => {
|
|
118
|
+
// Check alias match
|
|
119
|
+
const aliasMatch = bestAliasMatch[emoji.id];
|
|
120
|
+
if (aliasMatch) {
|
|
121
|
+
return {
|
|
122
|
+
emoji,
|
|
123
|
+
sort: [aliasMatch.matchType, aliasMatch.index, 0],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// Check id, name, keywords
|
|
127
|
+
if (emoji.id.toLowerCase() === searchText) {
|
|
128
|
+
return { emoji, sort: [3, 0, 0] }; // exact id
|
|
129
|
+
}
|
|
130
|
+
if (emoji.id.toLowerCase().startsWith(searchText)) {
|
|
131
|
+
return { emoji, sort: [4, 0, 0] }; // startsWith id
|
|
132
|
+
}
|
|
133
|
+
if (emoji.id.toLowerCase().includes(searchText)) {
|
|
134
|
+
return {
|
|
135
|
+
emoji,
|
|
136
|
+
sort: [5, emoji.id.toLowerCase().indexOf(searchText), 0],
|
|
137
|
+
}; // includes id
|
|
138
|
+
}
|
|
139
|
+
if (emoji.name.toLowerCase().includes(searchText)) {
|
|
140
|
+
return {
|
|
141
|
+
emoji,
|
|
142
|
+
sort: [6, emoji.name.toLowerCase().indexOf(searchText), 0],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (emoji.keywords &&
|
|
146
|
+
emoji.keywords.some((keyword) => keyword.toLowerCase().includes(searchText))) {
|
|
147
|
+
return { emoji, sort: [7, 0, 0] };
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
})
|
|
151
|
+
.filter(Boolean)
|
|
152
|
+
// Remove duplicates by emoji id (keep best match)
|
|
153
|
+
.reduce((acc, curr) => {
|
|
154
|
+
if (!acc.find((e) => e.emoji.id === curr.emoji.id)) {
|
|
155
|
+
acc.push(curr);
|
|
156
|
+
}
|
|
157
|
+
return acc;
|
|
158
|
+
}, [])
|
|
159
|
+
// Sort by alias match type, then position, then fallback
|
|
160
|
+
.sort((a, b) => {
|
|
161
|
+
for (let i = 0; i < a.sort.length; ++i) {
|
|
162
|
+
if (a.sort[i] !== b.sort[i])
|
|
163
|
+
return a.sort[i] - b.sort[i];
|
|
164
|
+
}
|
|
165
|
+
return 0;
|
|
166
|
+
})
|
|
167
|
+
.slice(0, 10) // Limit to 10 results
|
|
168
|
+
.map((entry) => entry.emoji);
|
|
169
|
+
setFilteredEmojis(filtered);
|
|
170
|
+
setHighlightedIndex(0);
|
|
171
|
+
setShowEmojiSuggestions(filtered.length > 0);
|
|
172
|
+
setShowSuggestions(false);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
setShowEmojiSuggestions(false);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
setShowEmojiSuggestions(false);
|
|
180
|
+
}
|
|
181
|
+
// If neither mention nor emoji, hide all suggestions
|
|
182
|
+
if (atIndex === -1 && colonIndex === -1) {
|
|
183
|
+
setShowSuggestions(false);
|
|
184
|
+
setShowEmojiSuggestions(false);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
const submit = () => {
|
|
188
|
+
if (!message.trim())
|
|
189
|
+
return;
|
|
190
|
+
setMessage("");
|
|
191
|
+
setReplyToMessage(null);
|
|
192
|
+
setSubmitting(true);
|
|
193
|
+
createChatMessage({
|
|
194
|
+
text: message,
|
|
195
|
+
reply: replyTo || undefined,
|
|
196
|
+
});
|
|
197
|
+
setSubmitting(false);
|
|
198
|
+
// if we press "send" button, we want the same action as pressing "Enter"
|
|
199
|
+
// if we're already focused no need to do extra work
|
|
200
|
+
if (textAreaRef.current && !textAreaRef.current.isFocused()) {
|
|
201
|
+
textAreaRef.current.focus();
|
|
202
|
+
requestAnimationFrame(() => {
|
|
203
|
+
textAreaRef.current?.focus();
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
(0, react_2.useEffect)(() => {
|
|
208
|
+
if (replyTo && textAreaRef.current) {
|
|
209
|
+
textAreaRef.current.focus();
|
|
210
|
+
}
|
|
211
|
+
}, [replyTo]);
|
|
212
|
+
return ((0, jsx_runtime_1.jsxs)(__1.View, { style: [atoms_1.layout.flex.column, atoms_1.flex.shrink[1], atoms_1.gap.all[2]], children: [replyTo && ((0, jsx_runtime_1.jsxs)(__1.View, { style: [
|
|
213
|
+
atoms_1.layout.flex.row,
|
|
214
|
+
atoms_1.layout.flex.alignCenter,
|
|
215
|
+
atoms_1.layout.flex.spaceBetween,
|
|
216
|
+
atoms_1.pl[2],
|
|
217
|
+
atoms_1.pr[6],
|
|
218
|
+
atoms_1.mr[6],
|
|
219
|
+
atoms_1.mb[2],
|
|
220
|
+
atoms_1.py[1],
|
|
221
|
+
atoms_1.bg.gray[800],
|
|
222
|
+
{ borderRadius: 16 },
|
|
223
|
+
], children: [(0, jsx_runtime_1.jsx)(chat_message_1.RenderChatMessage, { item: replyTo, showReply: false, userCache: authors || new Map() }), (0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onPress: () => setReplyToMessage(null), children: (0, jsx_runtime_1.jsx)(__1.View, { style: [
|
|
224
|
+
atoms_1.layout.flex.row,
|
|
225
|
+
atoms_1.layout.flex.alignCenter,
|
|
226
|
+
atoms_1.layout.flex.justifyCenter,
|
|
227
|
+
atoms_1.h[12],
|
|
228
|
+
atoms_1.w[12],
|
|
229
|
+
atoms_1.bg.gray[600],
|
|
230
|
+
{ borderRadius: 999 },
|
|
231
|
+
], children: (0, jsx_runtime_1.jsx)(lucide_react_native_1.X, { size: 24 }) }) })] })), showEmojiSelector && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_1.Pressable, { style: {
|
|
232
|
+
position: "absolute",
|
|
233
|
+
top: 0,
|
|
234
|
+
left: 0,
|
|
235
|
+
right: 0,
|
|
236
|
+
bottom: 0,
|
|
237
|
+
zIndex: 200,
|
|
238
|
+
}, onPress: () => setShowEmojiSelector(false) }), (0, jsx_runtime_1.jsx)(__1.View, { style: {
|
|
239
|
+
position: "absolute",
|
|
240
|
+
bottom: "100%",
|
|
241
|
+
left: 0,
|
|
242
|
+
zIndex: 2001,
|
|
243
|
+
}, children: (0, jsx_runtime_1.jsx)(react_1.default, { data: emojiData, onEmojiSelect: (e) => setMessage(message + e.native) }) })] })), (0, jsx_runtime_1.jsxs)(__1.View, { style: [atoms_1.layout.flex.row, atoms_1.layout.flex.alignCenter, atoms_1.gap.all[2]], children: [(0, jsx_runtime_1.jsx)(textarea_1.Textarea, { ref: textAreaRef, numberOfLines: 1, value: message, enterKeyHint: "send", onSubmitEditing: (e) => {
|
|
244
|
+
e.preventDefault();
|
|
245
|
+
submit();
|
|
246
|
+
}, multiline: false, onChangeText: (text) => {
|
|
247
|
+
setMessage(text);
|
|
248
|
+
updateSuggestions(text);
|
|
249
|
+
}, onKeyPress: (k) => {
|
|
250
|
+
if (k.nativeEvent.key === "Enter") {
|
|
251
|
+
if (showSuggestions) {
|
|
252
|
+
k.preventDefault();
|
|
253
|
+
const handles = Array.from(filteredAuthors.keys());
|
|
254
|
+
if (handles.length > 0) {
|
|
255
|
+
handleMentionSelect(handles[highlightedIndex]);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else if (showEmojiSuggestions) {
|
|
259
|
+
k.preventDefault();
|
|
260
|
+
if (filteredEmojis.length > 0) {
|
|
261
|
+
handleEmojiSelect(filteredEmojis[highlightedIndex]);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
k.preventDefault();
|
|
266
|
+
submit();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else if (k.nativeEvent.key === "ArrowUp") {
|
|
270
|
+
if (showSuggestions || showEmojiSuggestions) {
|
|
271
|
+
k.preventDefault();
|
|
272
|
+
setHighlightedIndex((prev) => Math.max(prev - 1, 0));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else if (k.nativeEvent.key === "ArrowDown") {
|
|
276
|
+
if (showSuggestions) {
|
|
277
|
+
k.preventDefault();
|
|
278
|
+
setHighlightedIndex((prev) => Math.min(prev + 1, Array.from(filteredAuthors.keys()).length - 1));
|
|
279
|
+
}
|
|
280
|
+
else if (showEmojiSuggestions) {
|
|
281
|
+
k.preventDefault();
|
|
282
|
+
setHighlightedIndex((prev) => Math.min(prev + 1, filteredEmojis.length - 1));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else if (k.nativeEvent.key === "Escape") {
|
|
286
|
+
if (showSuggestions || showEmojiSuggestions) {
|
|
287
|
+
k.preventDefault();
|
|
288
|
+
setShowSuggestions(false);
|
|
289
|
+
setShowEmojiSuggestions(false);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}, style: [chatBoxStyle],
|
|
293
|
+
// "submit" won't blur on enter
|
|
294
|
+
submitBehavior: "submit", placeholder: "Type a message..." }), (0, jsx_runtime_1.jsx)(__1.Button, { disabled: submitting, variant: "secondary", style: { borderRadius: 16, height: 36, minWidth: 80 }, onPress: submit, children: submitting ? (0, jsx_runtime_1.jsx)(__1.Loader, {}) : "Send" })] }), showSuggestions && ((0, jsx_runtime_1.jsx)(mention_suggestions_1.MentionSuggestions, { authors: filteredAuthors || new Map(), highlightedIndex: highlightedIndex, onSelect: handleMentionSelect })), showEmojiSuggestions && ((0, jsx_runtime_1.jsx)(emoji_suggestions_1.EmojiSuggestions, { emojis: filteredEmojis, highlightedIndex: highlightedIndex, onSelect: handleEmojiSelect })), react_native_1.Platform.OS === "web" && ((0, jsx_runtime_1.jsxs)(__1.View, { style: [
|
|
295
|
+
atoms_1.layout.flex.row,
|
|
296
|
+
atoms_1.mb[2],
|
|
297
|
+
atoms_1.gap.all[2],
|
|
298
|
+
{ justifyContent: "flex-end" },
|
|
299
|
+
], children: [(0, jsx_runtime_1.jsx)(__1.Button, { variant: "secondary", style: { borderRadius: 16, height: 36, maxWidth: 36 }, onPress: () => {
|
|
300
|
+
// if the last character is not @, add it
|
|
301
|
+
!message.endsWith("@") && setMessage(message + "@");
|
|
302
|
+
// get all the text after the last @
|
|
303
|
+
const atIndex = message.lastIndexOf("@");
|
|
304
|
+
const searchText = message.slice(atIndex + 1).toLowerCase();
|
|
305
|
+
updateSuggestions(searchText);
|
|
306
|
+
setShowSuggestions(true);
|
|
307
|
+
// focus the textarea
|
|
308
|
+
textAreaRef.current?.focus();
|
|
309
|
+
}, children: (0, jsx_runtime_1.jsx)(lucide_react_native_1.AtSignIcon, { size: 20, color: "white" }) }), (0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onHoverOut: () => {
|
|
310
|
+
setEmojiIconIndex(Math.floor(Math.random() * COOL_EMOJI_LIST.length));
|
|
311
|
+
}, children: (0, jsx_runtime_1.jsx)(__1.Button, { variant: "secondary", style: { borderRadius: 16, height: 36, maxWidth: 36 }, onPress: () => setShowEmojiSelector(!showEmojiSelector), children: (0, jsx_runtime_1.jsx)(__1.Text, { children: COOL_EMOJI_LIST[emojiIconIndex] }) }) }), !isPopout && ((0, jsx_runtime_1.jsx)(__1.Button, { variant: "secondary", style: { borderRadius: 16, height: 36, maxWidth: 36 }, onPress: () => {
|
|
312
|
+
if (!linfo)
|
|
313
|
+
return;
|
|
314
|
+
const u = new URL(window.location.href);
|
|
315
|
+
u.pathname = `/chat-popout/${linfo?.author?.did}`;
|
|
316
|
+
window.open(u.toString(), "_blank", "popup=true");
|
|
317
|
+
setIsChatVisible?.(false);
|
|
318
|
+
}, children: (0, jsx_runtime_1.jsx)(lucide_react_native_1.ExternalLink, { size: 16 }) }))] }))] }));
|
|
319
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RenderChatMessage = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_native_1 = require("react-native");
|
|
7
|
+
const facet_1 = require("../../lib/facet");
|
|
8
|
+
const atoms_1 = require("../../lib/theme/atoms");
|
|
9
|
+
const ui_1 = require("../ui");
|
|
10
|
+
const livestream_store_1 = require("../../livestream-store");
|
|
11
|
+
const text_1 = require("../ui/text");
|
|
12
|
+
const getRgbColor = (color) => color ? `rgb(${color.red}, ${color.green}, ${color.blue})` : ui_1.colors.gray[500];
|
|
13
|
+
const segmentedObject = (obj, index, userCache) => {
|
|
14
|
+
if (obj.features && obj.features.length > 0) {
|
|
15
|
+
let ftr = obj.features[0];
|
|
16
|
+
// afaik there shouldn't be a case where facets overlap, at least currently
|
|
17
|
+
if (ftr.$type === "app.bsky.richtext.facet#link") {
|
|
18
|
+
let linkftr = ftr;
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(text_1.Text, { style: [{ color: ui_1.atoms.colors.ios.systemBlue, cursor: "pointer" }], onPress: () => react_native_1.Linking.openURL(linkftr.uri || ""), children: obj.text }, `mention-${index}`));
|
|
20
|
+
}
|
|
21
|
+
else if (ftr.$type === "app.bsky.richtext.facet#mention") {
|
|
22
|
+
let mtnftr = ftr;
|
|
23
|
+
const profile = userCache?.[mtnftr.did];
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(text_1.Text, { style: [
|
|
25
|
+
{
|
|
26
|
+
cursor: "pointer",
|
|
27
|
+
color: getRgbColor(profile?.color),
|
|
28
|
+
},
|
|
29
|
+
], onPress: () => react_native_1.Linking.openURL(`https://bsky.app/profile/${mtnftr.did || ""}`), children: obj.text }, `mention-${index}`));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return (0, jsx_runtime_1.jsx)(text_1.Text, { children: obj.text }, `text-${index}`);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const RichTextMessage = ({ text, facets, }) => {
|
|
37
|
+
if (!facets?.length)
|
|
38
|
+
return (0, jsx_runtime_1.jsx)(text_1.Text, { children: text });
|
|
39
|
+
const userCache = (0, livestream_store_1.useLivestreamStore)((state) => state.authors);
|
|
40
|
+
let segs = (0, facet_1.segmentize)(text, facets);
|
|
41
|
+
return segs.map((seg, i) => segmentedObject(seg, i, userCache));
|
|
42
|
+
};
|
|
43
|
+
exports.RenderChatMessage = (0, react_1.memo)(function RenderChatMessage({ item, showReply = true, showTime = true, }) {
|
|
44
|
+
const formatTime = (0, react_1.useCallback)((dateString) => {
|
|
45
|
+
return new Date(dateString).toLocaleString(undefined, {
|
|
46
|
+
hour: "2-digit",
|
|
47
|
+
minute: "2-digit",
|
|
48
|
+
hour12: false,
|
|
49
|
+
});
|
|
50
|
+
}, []);
|
|
51
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [item.replyTo && showReply && ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: [
|
|
52
|
+
atoms_1.gap.all[2],
|
|
53
|
+
ui_1.layout.flex.row,
|
|
54
|
+
{ minWidth: 0, maxWidth: "100%" },
|
|
55
|
+
atoms_1.borders.left.width.medium,
|
|
56
|
+
atoms_1.borders.left.color.gray[700],
|
|
57
|
+
atoms_1.ml[4],
|
|
58
|
+
atoms_1.pl[4],
|
|
59
|
+
atoms_1.opacity[80],
|
|
60
|
+
], children: (0, jsx_runtime_1.jsxs)(text_1.Text, { numberOfLines: 1, style: [
|
|
61
|
+
atoms_1.flex.shrink[1],
|
|
62
|
+
atoms_1.mr[4],
|
|
63
|
+
{ minWidth: 0, overflow: "hidden" },
|
|
64
|
+
], children: [(0, jsx_runtime_1.jsxs)(text_1.Text, { style: {
|
|
65
|
+
color: getRgbColor(item.replyTo.chatProfile.color),
|
|
66
|
+
fontWeight: "thin",
|
|
67
|
+
}, children: ["@", item.replyTo.author.handle] }), " ", (0, jsx_runtime_1.jsx)(text_1.Text, { style: {
|
|
68
|
+
color: ui_1.colors.gray[300],
|
|
69
|
+
fontStyle: "italic",
|
|
70
|
+
}, children: item.replyTo.record.text })] }) })), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [
|
|
71
|
+
atoms_1.gap.all[2],
|
|
72
|
+
ui_1.layout.flex.row,
|
|
73
|
+
{ minWidth: 0, maxWidth: "100%" },
|
|
74
|
+
], children: [showTime && ((0, jsx_runtime_1.jsx)(text_1.Text, { style: {
|
|
75
|
+
fontVariant: ["tabular-nums"],
|
|
76
|
+
color: ui_1.colors.gray[400],
|
|
77
|
+
}, children: formatTime(item.record.createdAt) })), (0, jsx_runtime_1.jsxs)(text_1.Text, { weight: "bold", color: "default", style: [atoms_1.flex.shrink[1], { minWidth: 0, overflow: "hidden" }], children: [(0, jsx_runtime_1.jsxs)(text_1.Text, { style: [
|
|
78
|
+
{
|
|
79
|
+
cursor: "pointer",
|
|
80
|
+
color: getRgbColor(item.chatProfile?.color),
|
|
81
|
+
},
|
|
82
|
+
], children: ["@", item.author.handle] }), ":", " ", (0, jsx_runtime_1.jsx)(RichTextMessage, { text: item.record.text, facets: item.record.facets || [] })] })] })] }));
|
|
83
|
+
}, (prevProps, nextProps) => {
|
|
84
|
+
return (prevProps.item.author.handle === nextProps.item.author.handle &&
|
|
85
|
+
prevProps.item.record.text === nextProps.item.record.text &&
|
|
86
|
+
prevProps.item.uri === nextProps.item.uri);
|
|
87
|
+
});
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Chat = Chat;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const lucide_react_native_1 = require("lucide-react-native");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const react_native_gesture_handler_1 = require("react-native-gesture-handler");
|
|
10
|
+
const ReanimatedSwipeable_1 = tslib_1.__importDefault(require("react-native-gesture-handler/ReanimatedSwipeable"));
|
|
11
|
+
const react_native_reanimated_1 = tslib_1.__importStar(require("react-native-reanimated"));
|
|
12
|
+
const __1 = require("../../");
|
|
13
|
+
const atoms_1 = require("../../lib/theme/atoms");
|
|
14
|
+
const chat_message_1 = require("./chat-message");
|
|
15
|
+
const mod_view_1 = require("./mod-view");
|
|
16
|
+
function RightAction(prog, drag) {
|
|
17
|
+
const styleAnimation = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
18
|
+
return {
|
|
19
|
+
transform: [{ translateX: drag.value + 25 }],
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [styleAnimation], children: (0, jsx_runtime_1.jsx)(lucide_react_native_1.Reply, { color: "white" }) }));
|
|
23
|
+
}
|
|
24
|
+
function LeftAction(prog, drag) {
|
|
25
|
+
const styleAnimation = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
26
|
+
return {
|
|
27
|
+
transform: [{ translateX: drag.value - 25 }],
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [styleAnimation], children: (0, jsx_runtime_1.jsx)(lucide_react_native_1.Ellipsis, { color: "white" }) }));
|
|
31
|
+
}
|
|
32
|
+
// ios/android, 25, else 100 msgs
|
|
33
|
+
const SHOWN_MSGS = react_native_1.Platform.OS === "ios" || react_native_1.Platform.OS === "android" ? 25 : 100;
|
|
34
|
+
const keyExtractor = (item, index) => {
|
|
35
|
+
return `${item.uri}`;
|
|
36
|
+
};
|
|
37
|
+
// Actions bar for larger screens
|
|
38
|
+
const ActionsBar = (0, react_1.memo)(({ item, visible, hoverTimeoutRef, }) => {
|
|
39
|
+
const setReply = (0, __1.useSetReplyToMessage)();
|
|
40
|
+
const setModMsg = (0, __1.usePlayerStore)((state) => state.setModMessage);
|
|
41
|
+
if (!visible)
|
|
42
|
+
return null;
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)(__1.View, { style: [
|
|
44
|
+
{
|
|
45
|
+
position: "absolute",
|
|
46
|
+
top: -14,
|
|
47
|
+
right: 8,
|
|
48
|
+
flexDirection: "row",
|
|
49
|
+
backgroundColor: "rgba(180,180,180, 0.5)",
|
|
50
|
+
borderRadius: 6,
|
|
51
|
+
borderWidth: 1,
|
|
52
|
+
padding: 1,
|
|
53
|
+
gap: 4,
|
|
54
|
+
zIndex: 10,
|
|
55
|
+
maxWidth: 120,
|
|
56
|
+
flexShrink: 0,
|
|
57
|
+
},
|
|
58
|
+
], children: [(0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onPress: () => setReply(item), style: [
|
|
59
|
+
{
|
|
60
|
+
padding: 6,
|
|
61
|
+
borderRadius: 4,
|
|
62
|
+
backgroundColor: "rgba(255, 255, 255, 0.1)",
|
|
63
|
+
},
|
|
64
|
+
], onHoverIn: () => {
|
|
65
|
+
// Keep the actions bar visible when hovering over it
|
|
66
|
+
if (hoverTimeoutRef.current) {
|
|
67
|
+
clearTimeout(hoverTimeoutRef.current);
|
|
68
|
+
hoverTimeoutRef.current = null;
|
|
69
|
+
}
|
|
70
|
+
}, children: (0, jsx_runtime_1.jsx)(lucide_react_native_1.Reply, { color: "white", size: 16 }) }), (0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onPress: () => setModMsg(item), style: [
|
|
71
|
+
{
|
|
72
|
+
padding: 6,
|
|
73
|
+
borderRadius: 4,
|
|
74
|
+
backgroundColor: "rgba(255, 255, 255, 0.1)",
|
|
75
|
+
},
|
|
76
|
+
], onHoverIn: () => {
|
|
77
|
+
// Keep the actions bar visible when hovering over it
|
|
78
|
+
if (hoverTimeoutRef.current) {
|
|
79
|
+
clearTimeout(hoverTimeoutRef.current);
|
|
80
|
+
hoverTimeoutRef.current = null;
|
|
81
|
+
}
|
|
82
|
+
}, children: (0, jsx_runtime_1.jsx)(lucide_react_native_1.Ellipsis, { color: "white", size: 16 }) })] }));
|
|
83
|
+
});
|
|
84
|
+
const ChatLine = (0, react_1.memo)(({ item, canModerate, }) => {
|
|
85
|
+
const setReply = (0, __1.useSetReplyToMessage)();
|
|
86
|
+
const setModMsg = (0, __1.usePlayerStore)((state) => state.setModMessage);
|
|
87
|
+
const swipeableRef = (0, react_1.useRef)(null);
|
|
88
|
+
const [isHovered, setIsHovered] = (0, react_1.useState)(false);
|
|
89
|
+
const hoverTimeoutRef = (0, react_1.useRef)(null);
|
|
90
|
+
const handleHoverIn = () => {
|
|
91
|
+
if (hoverTimeoutRef.current) {
|
|
92
|
+
clearTimeout(hoverTimeoutRef.current);
|
|
93
|
+
hoverTimeoutRef.current = null;
|
|
94
|
+
}
|
|
95
|
+
setIsHovered(true);
|
|
96
|
+
};
|
|
97
|
+
const handleHoverOut = () => {
|
|
98
|
+
hoverTimeoutRef.current = setTimeout(() => {
|
|
99
|
+
setIsHovered(false);
|
|
100
|
+
}, 50);
|
|
101
|
+
};
|
|
102
|
+
(0, react_1.useEffect)(() => {
|
|
103
|
+
return () => {
|
|
104
|
+
if (hoverTimeoutRef.current) {
|
|
105
|
+
clearTimeout(hoverTimeoutRef.current);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}, []);
|
|
109
|
+
if (item.author.did === "did:sys:system") {
|
|
110
|
+
return ((0, jsx_runtime_1.jsx)(__1.SystemMessage, { timestamp: new Date(item.record.createdAt), title: item.record.text }));
|
|
111
|
+
}
|
|
112
|
+
if (react_native_1.Platform.OS === "web") {
|
|
113
|
+
return ((0, jsx_runtime_1.jsxs)(__1.View, { style: [
|
|
114
|
+
atoms_1.py[1],
|
|
115
|
+
atoms_1.px[2],
|
|
116
|
+
{
|
|
117
|
+
position: "relative",
|
|
118
|
+
borderRadius: 8,
|
|
119
|
+
minWidth: 0,
|
|
120
|
+
maxWidth: "100%",
|
|
121
|
+
},
|
|
122
|
+
isHovered && atoms_1.bg.gray[950],
|
|
123
|
+
], onPointerEnter: handleHoverIn, onPointerLeave: handleHoverOut, children: [(0, jsx_runtime_1.jsx)(react_native_1.Pressable, { style: [{ minWidth: 0, maxWidth: "100%" }], children: (0, jsx_runtime_1.jsx)(chat_message_1.RenderChatMessage, { item: item }) }), (0, jsx_runtime_1.jsx)(ActionsBar, { item: item, visible: isHovered, hoverTimeoutRef: hoverTimeoutRef })] }));
|
|
124
|
+
}
|
|
125
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(ReanimatedSwipeable_1.default, { containerStyle: [atoms_1.py[1]], friction: 2, enableTrackpadTwoFingerGesture: true, rightThreshold: 40, leftThreshold: 40, renderRightActions: react_native_1.Platform.OS === "android" ? undefined : RightAction, renderLeftActions: react_native_1.Platform.OS === "android" ? undefined : LeftAction, overshootFriction: 9, ref: (ref) => {
|
|
126
|
+
swipeableRef.current = ref;
|
|
127
|
+
}, onSwipeableOpen: (r) => {
|
|
128
|
+
if (r === (react_native_1.Platform.OS === "android" ? "right" : "left")) {
|
|
129
|
+
setReply(item);
|
|
130
|
+
}
|
|
131
|
+
if (r === (react_native_1.Platform.OS === "android" ? "left" : "right")) {
|
|
132
|
+
setModMsg(item);
|
|
133
|
+
}
|
|
134
|
+
// close this swipeable
|
|
135
|
+
const swipeable = swipeableRef.current;
|
|
136
|
+
if (swipeable) {
|
|
137
|
+
swipeable.close();
|
|
138
|
+
}
|
|
139
|
+
}, children: (0, jsx_runtime_1.jsx)(chat_message_1.RenderChatMessage, { item: item }) }) }));
|
|
140
|
+
});
|
|
141
|
+
function Chat({ shownMessages = SHOWN_MSGS, style: propsStyle, canModerate = false, ...props }) {
|
|
142
|
+
const chat = (0, __1.useChat)();
|
|
143
|
+
if (!chat)
|
|
144
|
+
return ((0, jsx_runtime_1.jsx)(__1.View, { style: [atoms_1.flex.shrink[1], { minWidth: 0, maxWidth: "100%" }], children: (0, jsx_runtime_1.jsx)(__1.Text, { children: "Loading chaat..." }) }));
|
|
145
|
+
return ((0, jsx_runtime_1.jsxs)(__1.View, { style: [atoms_1.flex.shrink[1], { minWidth: 0, maxWidth: "100%" }].concat(propsStyle || []), children: [(0, jsx_runtime_1.jsx)(react_native_gesture_handler_1.FlatList, { style: [
|
|
146
|
+
atoms_1.flex.grow[1],
|
|
147
|
+
atoms_1.flex.shrink[1],
|
|
148
|
+
{ minWidth: 0, maxWidth: "100%" },
|
|
149
|
+
], data: chat.slice(0, shownMessages), inverted: true, keyExtractor: keyExtractor, renderItem: ({ item, index }) => ((0, jsx_runtime_1.jsx)(ChatLine, { item: item, canModerate: canModerate })), removeClippedSubviews: true, maxToRenderPerBatch: 10, initialNumToRender: 10, updateCellsBatchingPeriod: 50 }), (0, jsx_runtime_1.jsx)(mod_view_1.ModView, {})] }));
|
|
150
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmojiSuggestions = EmojiSuggestions;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
const atoms_1 = require("../../lib/theme/atoms");
|
|
8
|
+
function EmojiSuggestions({ emojis, onSelect, highlightedIndex, }) {
|
|
9
|
+
if (!emojis || emojis.length === 0) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(__1.View, { style: [
|
|
13
|
+
atoms_1.bg.gray[800],
|
|
14
|
+
atoms_1.layout.position.absolute,
|
|
15
|
+
atoms_1.left[0],
|
|
16
|
+
atoms_1.right[0],
|
|
17
|
+
atoms_1.zIndex[50],
|
|
18
|
+
{
|
|
19
|
+
bottom: "100%",
|
|
20
|
+
borderRadius: 8,
|
|
21
|
+
boxShadow: "0px 4px 6px rgba(0, 0, 0, 0.1)",
|
|
22
|
+
maxHeight: 200,
|
|
23
|
+
overflow: "auto",
|
|
24
|
+
},
|
|
25
|
+
], children: emojis.map((emoji, index) => ((0, jsx_runtime_1.jsxs)(react_native_1.Pressable, { onPress: () => onSelect(emoji), style: [
|
|
26
|
+
{
|
|
27
|
+
padding: 8,
|
|
28
|
+
flexDirection: "row",
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
backgroundColor: index === highlightedIndex
|
|
31
|
+
? "rgba(255, 255, 255, 0.1)"
|
|
32
|
+
: "transparent",
|
|
33
|
+
},
|
|
34
|
+
], children: [(0, jsx_runtime_1.jsx)(__1.Text, { style: { fontSize: 16, marginRight: 8 }, children: emoji.skins[0]?.native }), (0, jsx_runtime_1.jsxs)(__1.Text, { style: { color: "white", fontSize: 14 }, children: [(0, jsx_runtime_1.jsxs)(__1.Code, { style: [atoms_1.bg.gray[950]], children: [":", emoji.id, ":"] }), " ", emoji.name] })] }, emoji.id))) }));
|
|
35
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MentionSuggestions = MentionSuggestions;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
const atoms_1 = require("../../lib/theme/atoms");
|
|
8
|
+
function MentionSuggestions({ authors, onSelect, highlightedIndex, }) {
|
|
9
|
+
if (!authors || authors.size === 0) {
|
|
10
|
+
return null; // No authors to display
|
|
11
|
+
}
|
|
12
|
+
const authorHandles = Array.from(authors.keys());
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(__1.View, { style: [
|
|
14
|
+
atoms_1.bg.gray[800],
|
|
15
|
+
atoms_1.layout.position.absolute,
|
|
16
|
+
atoms_1.left[0],
|
|
17
|
+
atoms_1.right[0],
|
|
18
|
+
atoms_1.zIndex[50],
|
|
19
|
+
{
|
|
20
|
+
bottom: "100%",
|
|
21
|
+
borderRadius: 8,
|
|
22
|
+
boxShadow: "0px 4px 6px rgba(0, 0, 0, 0.1)",
|
|
23
|
+
},
|
|
24
|
+
], children: authorHandles.map((handle, index) => {
|
|
25
|
+
let profile = authors.get(handle);
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onPress: () => onSelect(handle), style: [
|
|
27
|
+
{
|
|
28
|
+
padding: 8,
|
|
29
|
+
flexDirection: "row",
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
backgroundColor: index === highlightedIndex
|
|
32
|
+
? "rgba(0, 0, 0, 0.1)"
|
|
33
|
+
: "rgba(0, 0, 0, 0.5)",
|
|
34
|
+
},
|
|
35
|
+
], children: (0, jsx_runtime_1.jsxs)(__1.Text, { style: {
|
|
36
|
+
color: profile?.color
|
|
37
|
+
? `rgb(${profile.color.red}, ${profile.color.green}, ${profile.color.blue})`
|
|
38
|
+
: "black",
|
|
39
|
+
fontWeight: "bold",
|
|
40
|
+
}, children: ["@", handle] }) }, handle));
|
|
41
|
+
}) }));
|
|
42
|
+
}
|