stream-chat-react-native-core 5.24.1-beta.1 → 5.25.0-beta.2
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/lib/commonjs/components/AutoCompleteInput/AutoCompleteInput.js.map +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionItem.js.map +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionList.js +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionList.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +16 -13
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -0
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/commonjs/components/MessageInput/SendButton.js +3 -1
- package/lib/commonjs/components/MessageInput/SendButton.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +13 -11
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +2 -0
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/suggestionsContext/SuggestionsContext.js.map +1 -1
- package/lib/commonjs/emoji-data/compile.js +63 -11
- package/lib/commonjs/emoji-data/compile.js.map +1 -1
- package/lib/commonjs/emoji-data/index.js +9843 -37
- package/lib/commonjs/emoji-data/index.js.map +1 -1
- package/lib/commonjs/i18n/en.json +1 -1
- package/lib/commonjs/i18n/es.json +34 -34
- package/lib/commonjs/i18n/fr.json +36 -36
- package/lib/commonjs/i18n/he.json +36 -36
- package/lib/commonjs/i18n/hi.json +36 -36
- package/lib/commonjs/i18n/it.json +36 -36
- package/lib/commonjs/i18n/ja.json +36 -36
- package/lib/commonjs/i18n/ko.json +36 -36
- package/lib/commonjs/i18n/nl.json +36 -36
- package/lib/commonjs/i18n/ru.json +35 -35
- package/lib/commonjs/i18n/tr.json +36 -36
- package/lib/commonjs/index.js +4 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/utils.js +84 -31
- package/lib/commonjs/utils/utils.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteInput.js.map +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionItem.js.map +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionList.js +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionList.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +16 -13
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -0
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/module/components/MessageInput/SendButton.js +3 -1
- package/lib/module/components/MessageInput/SendButton.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +13 -11
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +2 -0
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/module/contexts/suggestionsContext/SuggestionsContext.js.map +1 -1
- package/lib/module/emoji-data/compile.js +63 -11
- package/lib/module/emoji-data/compile.js.map +1 -1
- package/lib/module/emoji-data/index.js +9843 -37
- package/lib/module/emoji-data/index.js.map +1 -1
- package/lib/module/i18n/en.json +1 -1
- package/lib/module/i18n/es.json +34 -34
- package/lib/module/i18n/fr.json +36 -36
- package/lib/module/i18n/he.json +36 -36
- package/lib/module/i18n/hi.json +36 -36
- package/lib/module/i18n/it.json +36 -36
- package/lib/module/i18n/ja.json +36 -36
- package/lib/module/i18n/ko.json +36 -36
- package/lib/module/i18n/nl.json +36 -36
- package/lib/module/i18n/ru.json +35 -35
- package/lib/module/i18n/tr.json +36 -36
- package/lib/module/index.js +4 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/utils.js +84 -31
- package/lib/module/utils/utils.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts +1 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +11 -3
- package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts +1 -1
- package/lib/typescript/contexts/suggestionsContext/SuggestionsContext.d.ts +1 -1
- package/lib/typescript/emoji-data/index.d.ts +9 -0
- package/lib/typescript/i18n/en.json +1 -1
- package/lib/typescript/i18n/es.json +34 -34
- package/lib/typescript/i18n/fr.json +36 -36
- package/lib/typescript/i18n/he.json +36 -36
- package/lib/typescript/i18n/hi.json +36 -36
- package/lib/typescript/i18n/it.json +36 -36
- package/lib/typescript/i18n/ja.json +36 -36
- package/lib/typescript/i18n/ko.json +36 -36
- package/lib/typescript/i18n/nl.json +36 -36
- package/lib/typescript/i18n/ru.json +35 -35
- package/lib/typescript/i18n/tr.json +36 -36
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/utils/utils.d.ts +9 -4
- package/package.json +3 -2
- package/src/components/AutoCompleteInput/AutoCompleteInput.tsx +1 -1
- package/src/components/AutoCompleteInput/AutoCompleteSuggestionItem.tsx +1 -1
- package/src/components/AutoCompleteInput/AutoCompleteSuggestionList.tsx +1 -1
- package/src/components/Channel/Channel.tsx +3 -0
- package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +2 -0
- package/src/components/MessageInput/SendButton.tsx +1 -1
- package/src/contexts/messageInputContext/MessageInputContext.tsx +17 -2
- package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +2 -0
- package/src/contexts/suggestionsContext/SuggestionsContext.tsx +1 -1
- package/src/emoji-data/compile.js +56 -36
- package/src/emoji-data/index.ts +5178 -0
- package/src/i18n/en.json +1 -1
- package/src/i18n/es.json +34 -34
- package/src/i18n/fr.json +36 -36
- package/src/i18n/he.json +36 -36
- package/src/i18n/hi.json +36 -36
- package/src/i18n/it.json +36 -36
- package/src/i18n/ja.json +36 -36
- package/src/i18n/ko.json +36 -36
- package/src/i18n/nl.json +36 -36
- package/src/i18n/ru.json +35 -35
- package/src/i18n/tr.json +36 -36
- package/src/index.ts +1 -1
- package/src/utils/utils.ts +47 -33
- package/src/version.json +1 -1
- package/lib/commonjs/emoji-data/compiled.js +0 -15587
- package/lib/commonjs/emoji-data/compiled.js.map +0 -1
- package/lib/commonjs/emoji-data/emojiNames.js +0 -4913
- package/lib/commonjs/emoji-data/emojiNames.js.map +0 -1
- package/lib/commonjs/emoji-data/emojis.js +0 -13155
- package/lib/commonjs/emoji-data/emojis.js.map +0 -1
- package/lib/module/emoji-data/compiled.js +0 -15587
- package/lib/module/emoji-data/compiled.js.map +0 -1
- package/lib/module/emoji-data/emojiNames.js +0 -4913
- package/lib/module/emoji-data/emojiNames.js.map +0 -1
- package/lib/module/emoji-data/emojis.js +0 -13155
- package/lib/module/emoji-data/emojis.js.map +0 -1
- package/lib/typescript/emoji-data/compiled.d.ts +0 -20
- package/lib/typescript/emoji-data/emojiNames.d.ts +0 -0
- package/lib/typescript/emoji-data/emojis.d.ts +0 -0
- package/src/emoji-data/compiled.ts +0 -8930
- package/src/emoji-data/emojiNames.ts +0 -6960
- package/src/emoji-data/emojis.ts +0 -14893
- package/src/emoji-data/index.js +0 -38
package/src/utils/utils.ts
CHANGED
|
@@ -14,13 +14,16 @@ import type {
|
|
|
14
14
|
} from 'stream-chat';
|
|
15
15
|
|
|
16
16
|
import type { MessageType } from '../components/MessageList/hooks/useMessageList';
|
|
17
|
-
import type {
|
|
17
|
+
import type {
|
|
18
|
+
EmojiSearchIndex,
|
|
19
|
+
MentionAllAppUsersQuery,
|
|
20
|
+
} from '../contexts/messageInputContext/MessageInputContext';
|
|
18
21
|
import type {
|
|
19
22
|
SuggestionCommand,
|
|
20
23
|
SuggestionComponentType,
|
|
21
24
|
SuggestionUser,
|
|
22
25
|
} from '../contexts/suggestionsContext/SuggestionsContext';
|
|
23
|
-
import { compiledEmojis, Emoji } from '../emoji-data
|
|
26
|
+
import { compiledEmojis, Emoji } from '../emoji-data';
|
|
24
27
|
import type { IconProps } from '../icons/utils/base';
|
|
25
28
|
import type { TableRowJoinedUser } from '../store/types';
|
|
26
29
|
import type { DefaultStreamChatGenerics, ValueOf } from '../types/types';
|
|
@@ -287,7 +290,7 @@ export type TriggerSettings<
|
|
|
287
290
|
query: Emoji['name'],
|
|
288
291
|
_: string,
|
|
289
292
|
onReady?: (data: Emoji[], q: Emoji['name']) => void,
|
|
290
|
-
) => Emoji[]
|
|
293
|
+
) => Emoji[] | Promise<Emoji[]>;
|
|
291
294
|
output: (entity: Emoji) => {
|
|
292
295
|
caretPosition: string;
|
|
293
296
|
key: string;
|
|
@@ -325,6 +328,7 @@ export type ACITriggerSettingsParams<
|
|
|
325
328
|
channel: Channel<StreamChatGenerics>;
|
|
326
329
|
client: StreamChat<StreamChatGenerics>;
|
|
327
330
|
onMentionSelectItem: (item: SuggestionUser<StreamChatGenerics>) => void;
|
|
331
|
+
emojiSearchIndex?: EmojiSearchIndex;
|
|
328
332
|
};
|
|
329
333
|
|
|
330
334
|
export type QueryUsersFunction<
|
|
@@ -350,6 +354,41 @@ export type QueryMembersFunction<
|
|
|
350
354
|
},
|
|
351
355
|
) => Promise<void>;
|
|
352
356
|
|
|
357
|
+
/**
|
|
358
|
+
* Default emoji search index for auto complete text input
|
|
359
|
+
*/
|
|
360
|
+
export const defaultEmojiSearchIndex: EmojiSearchIndex = {
|
|
361
|
+
search: (query) => {
|
|
362
|
+
const results = [];
|
|
363
|
+
|
|
364
|
+
for (const emoji of compiledEmojis) {
|
|
365
|
+
if (results.length >= 10) return results;
|
|
366
|
+
if (emoji.names.some((name) => name.includes(query))) {
|
|
367
|
+
// Aggregate skins as different toned emojis - if skins are present
|
|
368
|
+
if (emoji.skins) {
|
|
369
|
+
results.push({
|
|
370
|
+
...emoji,
|
|
371
|
+
name: `${emoji.name}-tone-1`,
|
|
372
|
+
skins: undefined,
|
|
373
|
+
});
|
|
374
|
+
emoji.skins.forEach((tone, index) =>
|
|
375
|
+
results.push({
|
|
376
|
+
...emoji,
|
|
377
|
+
name: `${emoji.name}-tone-${index + 2}`,
|
|
378
|
+
skins: undefined,
|
|
379
|
+
unicode: tone,
|
|
380
|
+
}),
|
|
381
|
+
);
|
|
382
|
+
} else {
|
|
383
|
+
results.push(emoji);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return results;
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
|
|
353
392
|
/**
|
|
354
393
|
* ACI = AutoCompleteInput
|
|
355
394
|
*
|
|
@@ -366,6 +405,7 @@ export const ACITriggerSettings = <
|
|
|
366
405
|
>({
|
|
367
406
|
channel,
|
|
368
407
|
client,
|
|
408
|
+
emojiSearchIndex,
|
|
369
409
|
onMentionSelectItem,
|
|
370
410
|
}: ACITriggerSettingsParams<StreamChatGenerics>): TriggerSettings<StreamChatGenerics> => ({
|
|
371
411
|
'/': {
|
|
@@ -409,42 +449,16 @@ export const ACITriggerSettings = <
|
|
|
409
449
|
type: 'command',
|
|
410
450
|
},
|
|
411
451
|
':': {
|
|
412
|
-
dataProvider: (query, _, onReady) => {
|
|
452
|
+
dataProvider: async (query, _, onReady) => {
|
|
413
453
|
if (!query) return [];
|
|
414
454
|
|
|
415
|
-
const
|
|
416
|
-
if (acc.length >= 10) return acc;
|
|
417
|
-
|
|
418
|
-
if (cur.names.some((name) => name.includes(query))) {
|
|
419
|
-
const emoji = compiledEmojis.emojiLib[cur.name];
|
|
420
|
-
// Since there can be no emojiLib for the current name we need to check for it being undefined
|
|
421
|
-
if (emoji?.skin_variations) {
|
|
422
|
-
acc.push({
|
|
423
|
-
...emoji,
|
|
424
|
-
name: `${emoji.name}-tone-1`,
|
|
425
|
-
skin_variations: undefined,
|
|
426
|
-
});
|
|
427
|
-
emoji.skin_variations.forEach((tone, index) =>
|
|
428
|
-
acc.push({
|
|
429
|
-
...emoji,
|
|
430
|
-
name: `${emoji.name}-tone-${index + 2}`,
|
|
431
|
-
skin_variations: undefined,
|
|
432
|
-
unicode: tone,
|
|
433
|
-
}),
|
|
434
|
-
);
|
|
435
|
-
} else if (emoji) {
|
|
436
|
-
acc.push(emoji);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
return acc;
|
|
441
|
-
}, [] as Emoji[]);
|
|
455
|
+
const emojis = (await emojiSearchIndex?.search(query)) ?? [];
|
|
442
456
|
|
|
443
457
|
if (onReady) {
|
|
444
|
-
onReady(
|
|
458
|
+
onReady(emojis, query);
|
|
445
459
|
}
|
|
446
460
|
|
|
447
|
-
return
|
|
461
|
+
return emojis;
|
|
448
462
|
},
|
|
449
463
|
output: (entity) => ({
|
|
450
464
|
caretPosition: 'next',
|
package/src/version.json
CHANGED