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.
Files changed (133) hide show
  1. package/lib/commonjs/components/AutoCompleteInput/AutoCompleteInput.js.map +1 -1
  2. package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionItem.js.map +1 -1
  3. package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionList.js +1 -1
  4. package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionList.js.map +1 -1
  5. package/lib/commonjs/components/Channel/Channel.js +16 -13
  6. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  7. package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -0
  8. package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
  9. package/lib/commonjs/components/MessageInput/SendButton.js +3 -1
  10. package/lib/commonjs/components/MessageInput/SendButton.js.map +1 -1
  11. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +13 -11
  12. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  13. package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +2 -0
  14. package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
  15. package/lib/commonjs/contexts/suggestionsContext/SuggestionsContext.js.map +1 -1
  16. package/lib/commonjs/emoji-data/compile.js +63 -11
  17. package/lib/commonjs/emoji-data/compile.js.map +1 -1
  18. package/lib/commonjs/emoji-data/index.js +9843 -37
  19. package/lib/commonjs/emoji-data/index.js.map +1 -1
  20. package/lib/commonjs/i18n/en.json +1 -1
  21. package/lib/commonjs/i18n/es.json +34 -34
  22. package/lib/commonjs/i18n/fr.json +36 -36
  23. package/lib/commonjs/i18n/he.json +36 -36
  24. package/lib/commonjs/i18n/hi.json +36 -36
  25. package/lib/commonjs/i18n/it.json +36 -36
  26. package/lib/commonjs/i18n/ja.json +36 -36
  27. package/lib/commonjs/i18n/ko.json +36 -36
  28. package/lib/commonjs/i18n/nl.json +36 -36
  29. package/lib/commonjs/i18n/ru.json +35 -35
  30. package/lib/commonjs/i18n/tr.json +36 -36
  31. package/lib/commonjs/index.js +4 -4
  32. package/lib/commonjs/index.js.map +1 -1
  33. package/lib/commonjs/utils/utils.js +84 -31
  34. package/lib/commonjs/utils/utils.js.map +1 -1
  35. package/lib/commonjs/version.json +1 -1
  36. package/lib/module/components/AutoCompleteInput/AutoCompleteInput.js.map +1 -1
  37. package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionItem.js.map +1 -1
  38. package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionList.js +1 -1
  39. package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionList.js.map +1 -1
  40. package/lib/module/components/Channel/Channel.js +16 -13
  41. package/lib/module/components/Channel/Channel.js.map +1 -1
  42. package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -0
  43. package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
  44. package/lib/module/components/MessageInput/SendButton.js +3 -1
  45. package/lib/module/components/MessageInput/SendButton.js.map +1 -1
  46. package/lib/module/contexts/messageInputContext/MessageInputContext.js +13 -11
  47. package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  48. package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +2 -0
  49. package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
  50. package/lib/module/contexts/suggestionsContext/SuggestionsContext.js.map +1 -1
  51. package/lib/module/emoji-data/compile.js +63 -11
  52. package/lib/module/emoji-data/compile.js.map +1 -1
  53. package/lib/module/emoji-data/index.js +9843 -37
  54. package/lib/module/emoji-data/index.js.map +1 -1
  55. package/lib/module/i18n/en.json +1 -1
  56. package/lib/module/i18n/es.json +34 -34
  57. package/lib/module/i18n/fr.json +36 -36
  58. package/lib/module/i18n/he.json +36 -36
  59. package/lib/module/i18n/hi.json +36 -36
  60. package/lib/module/i18n/it.json +36 -36
  61. package/lib/module/i18n/ja.json +36 -36
  62. package/lib/module/i18n/ko.json +36 -36
  63. package/lib/module/i18n/nl.json +36 -36
  64. package/lib/module/i18n/ru.json +35 -35
  65. package/lib/module/i18n/tr.json +36 -36
  66. package/lib/module/index.js +4 -4
  67. package/lib/module/index.js.map +1 -1
  68. package/lib/module/utils/utils.js +84 -31
  69. package/lib/module/utils/utils.js.map +1 -1
  70. package/lib/module/version.json +1 -1
  71. package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts +1 -1
  72. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +11 -3
  73. package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts +1 -1
  74. package/lib/typescript/contexts/suggestionsContext/SuggestionsContext.d.ts +1 -1
  75. package/lib/typescript/emoji-data/index.d.ts +9 -0
  76. package/lib/typescript/i18n/en.json +1 -1
  77. package/lib/typescript/i18n/es.json +34 -34
  78. package/lib/typescript/i18n/fr.json +36 -36
  79. package/lib/typescript/i18n/he.json +36 -36
  80. package/lib/typescript/i18n/hi.json +36 -36
  81. package/lib/typescript/i18n/it.json +36 -36
  82. package/lib/typescript/i18n/ja.json +36 -36
  83. package/lib/typescript/i18n/ko.json +36 -36
  84. package/lib/typescript/i18n/nl.json +36 -36
  85. package/lib/typescript/i18n/ru.json +35 -35
  86. package/lib/typescript/i18n/tr.json +36 -36
  87. package/lib/typescript/index.d.ts +1 -1
  88. package/lib/typescript/utils/utils.d.ts +9 -4
  89. package/package.json +3 -2
  90. package/src/components/AutoCompleteInput/AutoCompleteInput.tsx +1 -1
  91. package/src/components/AutoCompleteInput/AutoCompleteSuggestionItem.tsx +1 -1
  92. package/src/components/AutoCompleteInput/AutoCompleteSuggestionList.tsx +1 -1
  93. package/src/components/Channel/Channel.tsx +3 -0
  94. package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +2 -0
  95. package/src/components/MessageInput/SendButton.tsx +1 -1
  96. package/src/contexts/messageInputContext/MessageInputContext.tsx +17 -2
  97. package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +2 -0
  98. package/src/contexts/suggestionsContext/SuggestionsContext.tsx +1 -1
  99. package/src/emoji-data/compile.js +56 -36
  100. package/src/emoji-data/index.ts +5178 -0
  101. package/src/i18n/en.json +1 -1
  102. package/src/i18n/es.json +34 -34
  103. package/src/i18n/fr.json +36 -36
  104. package/src/i18n/he.json +36 -36
  105. package/src/i18n/hi.json +36 -36
  106. package/src/i18n/it.json +36 -36
  107. package/src/i18n/ja.json +36 -36
  108. package/src/i18n/ko.json +36 -36
  109. package/src/i18n/nl.json +36 -36
  110. package/src/i18n/ru.json +35 -35
  111. package/src/i18n/tr.json +36 -36
  112. package/src/index.ts +1 -1
  113. package/src/utils/utils.ts +47 -33
  114. package/src/version.json +1 -1
  115. package/lib/commonjs/emoji-data/compiled.js +0 -15587
  116. package/lib/commonjs/emoji-data/compiled.js.map +0 -1
  117. package/lib/commonjs/emoji-data/emojiNames.js +0 -4913
  118. package/lib/commonjs/emoji-data/emojiNames.js.map +0 -1
  119. package/lib/commonjs/emoji-data/emojis.js +0 -13155
  120. package/lib/commonjs/emoji-data/emojis.js.map +0 -1
  121. package/lib/module/emoji-data/compiled.js +0 -15587
  122. package/lib/module/emoji-data/compiled.js.map +0 -1
  123. package/lib/module/emoji-data/emojiNames.js +0 -4913
  124. package/lib/module/emoji-data/emojiNames.js.map +0 -1
  125. package/lib/module/emoji-data/emojis.js +0 -13155
  126. package/lib/module/emoji-data/emojis.js.map +0 -1
  127. package/lib/typescript/emoji-data/compiled.d.ts +0 -20
  128. package/lib/typescript/emoji-data/emojiNames.d.ts +0 -0
  129. package/lib/typescript/emoji-data/emojis.d.ts +0 -0
  130. package/src/emoji-data/compiled.ts +0 -8930
  131. package/src/emoji-data/emojiNames.ts +0 -6960
  132. package/src/emoji-data/emojis.ts +0 -14893
  133. package/src/emoji-data/index.js +0 -38
@@ -8,6 +8,7 @@ import { lookup } from 'mime-types';
8
8
  import {
9
9
  Attachment,
10
10
  logChatPromiseExecution,
11
+ Message,
11
12
  SendFileAPIResponse,
12
13
  StreamChat,
13
14
  Message as StreamMessage,
@@ -36,6 +37,7 @@ import type { MoreOptionsButtonProps } from '../../components/MessageInput/MoreO
36
37
  import type { SendButtonProps } from '../../components/MessageInput/SendButton';
37
38
  import type { UploadProgressIndicatorProps } from '../../components/MessageInput/UploadProgressIndicator';
38
39
  import type { MessageType } from '../../components/MessageList/hooks/useMessageList';
40
+ import type { Emoji } from '../../emoji-data';
39
41
  import { pickDocument } from '../../native';
40
42
  import type {
41
43
  Asset,
@@ -68,6 +70,10 @@ import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
68
70
  import { getDisplayName } from '../utils/getDisplayName';
69
71
  import { isTestEnvironment } from '../utils/isTestEnvironment';
70
72
 
73
+ export type EmojiSearchIndex = {
74
+ search: (query: string) => PromiseLike<Array<Emoji>> | Array<Emoji> | null;
75
+ };
76
+
71
77
  export type MentionAllAppUsersQuery<
72
78
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
73
79
  > = {
@@ -159,7 +165,7 @@ export type LocalMessageInputContext<
159
165
  resetInput: (pendingAttachments?: Attachment<StreamChatGenerics>[]) => void;
160
166
  selectedPicker: string | undefined;
161
167
  sending: React.MutableRefObject<boolean>;
162
- sendMessage: () => Promise<void>;
168
+ sendMessage: (customMessageData?: Partial<Message<StreamChatGenerics>>) => Promise<void>;
163
169
  sendMessageAsync: (id: string) => void;
164
170
  sendThreadMessageInChannel: boolean;
165
171
  setAsyncIds: React.Dispatch<React.SetStateAction<string[]>>;
@@ -338,6 +344,11 @@ export type InputMessageInputContextValue<
338
344
  */
339
345
  editing?: MessageType<StreamChatGenerics>;
340
346
 
347
+ /**
348
+ * Prop to override the default emoji search index in auto complete suggestion list.
349
+ */
350
+ emojiSearchIndex?: EmojiSearchIndex;
351
+
341
352
  /** Initial value to set on input */
342
353
  initialValue?: string;
343
354
  /**
@@ -696,7 +707,7 @@ export const MessageInputProvider = <
696
707
 
697
708
  // TODO: Figure out why this is async, as it doesn't await any promise.
698
709
  // eslint-disable-next-line require-await
699
- const sendMessage = async () => {
710
+ const sendMessage = async (customMessageData?: Partial<Message<StreamChatGenerics>>) => {
700
711
  if (sending.current) {
701
712
  return;
702
713
  }
@@ -790,6 +801,7 @@ export const MessageInputProvider = <
790
801
  mentioned_users: mentionedUsers,
791
802
  quoted_message: undefined,
792
803
  text: prevText,
804
+ ...customMessageData,
793
805
  } as Parameters<StreamChat<StreamChatGenerics>['updateMessage']>[0];
794
806
 
795
807
  // TODO: Remove this line and show an error when submit fails
@@ -822,6 +834,7 @@ export const MessageInputProvider = <
822
834
  typeof value.quotedMessage === 'boolean' ? undefined : value.quotedMessage.id,
823
835
  show_in_channel: sendThreadMessageInChannel || undefined,
824
836
  text: prevText,
837
+ ...customMessageData,
825
838
  } as unknown as StreamMessage<StreamChatGenerics>);
826
839
 
827
840
  value.clearQuotedMessageState();
@@ -891,12 +904,14 @@ export const MessageInputProvider = <
891
904
  triggerSettings = value.autoCompleteTriggerSettings({
892
905
  channel,
893
906
  client,
907
+ emojiSearchIndex: value.emojiSearchIndex,
894
908
  onMentionSelectItem: onSelectItem,
895
909
  });
896
910
  } else {
897
911
  triggerSettings = ACITriggerSettings<StreamChatGenerics>({
898
912
  channel,
899
913
  client,
914
+ emojiSearchIndex: value.emojiSearchIndex,
900
915
  onMentionSelectItem: onSelectItem,
901
916
  });
902
917
  }
@@ -24,6 +24,7 @@ export const useCreateMessageInputContext = <
24
24
  doImageUploadRequest,
25
25
  editing,
26
26
  editMessage,
27
+ emojiSearchIndex,
27
28
  FileUploadPreview,
28
29
  fileUploads,
29
30
  giphyActive,
@@ -127,6 +128,7 @@ export const useCreateMessageInputContext = <
127
128
  doImageUploadRequest,
128
129
  editing,
129
130
  editMessage,
131
+ emojiSearchIndex,
130
132
  FileUploadPreview,
131
133
  fileUploads,
132
134
  giphyActive,
@@ -5,7 +5,7 @@ import type { CommandResponse, UserResponse } from 'stream-chat';
5
5
  import type { AutoCompleteSuggestionHeaderProps } from '../../components/AutoCompleteInput/AutoCompleteSuggestionHeader';
6
6
  import type { AutoCompleteSuggestionItemProps } from '../../components/AutoCompleteInput/AutoCompleteSuggestionItem';
7
7
  import type { AutoCompleteSuggestionListProps } from '../../components/AutoCompleteInput/AutoCompleteSuggestionList';
8
- import type { Emoji } from '../../emoji-data/compiled';
8
+ import type { Emoji } from '../../emoji-data';
9
9
  import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
10
10
  import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
11
11
 
@@ -1,41 +1,61 @@
1
1
  /* eslint-disable no-undef */
2
2
  const fs = require('fs');
3
3
 
4
- const { emojiArray, emojiLib } = require('./index.js');
4
+ const getEmojis = async () => {
5
+ try {
6
+ const response = await fetch(
7
+ 'https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json',
8
+ );
9
+ const emojis = await response.json();
10
+ const emojiLib = emojis
11
+ .map((emoji) => ({
12
+ id: emoji.short_name,
13
+ name: emoji.short_name,
14
+ names: emoji.short_names,
15
+ ...(emoji.skin_variations
16
+ ? {
17
+ skins: Object.values(emoji.skin_variations).map((skin) =>
18
+ String.fromCodePoint.apply(
19
+ null,
20
+ skin.unified.split('-').map((unicode) => `0x${unicode}`),
21
+ ),
22
+ ),
23
+ }
24
+ : {}),
25
+ unicode: String.fromCodePoint.apply(
26
+ null,
27
+ emoji.unified.split('-').map((unicode) => `0x${unicode}`),
28
+ ),
29
+ }))
30
+ .sort((a, b) => (a.name < b.name ? -1 : 1));
5
31
 
6
- const stingified = JSON.stringify({
7
- emojiArray,
8
- emojiLib,
9
- }).replace(/(["'])require(?:(?=(\\?))\2.)*?\1/g, (value) => value.replace(/"/g, ''));
10
-
11
- fs.writeFile(
12
- 'compiled.ts',
13
- `export type EmojiArrayItem = {
14
- name: string;
15
- names: string[];
32
+ return { emojiLib };
33
+ } catch (error) {
34
+ console.log(error);
16
35
  }
17
-
18
- export type EmojiArray = EmojiArrayItem[];
19
-
20
- export type Emoji = {
21
- name: string;
22
- names: string[];
23
- sort_order: number;
24
- unicode: string;
25
- skin_variations?: string[];
26
- };
27
-
28
- export type EmojiLib = {
29
- [key: string]: Emoji;
30
- };
31
-
32
- export type CompiledEmojis = {
33
- emojiArray: EmojiArray;
34
- emojiLib: EmojiLib;
35
- };
36
-
37
- export const compiledEmojis: CompiledEmojis = ${stingified}`,
38
- (err) => {
39
- if (err) throw err;
40
- },
41
- );
36
+ };
37
+
38
+ getEmojis().then(({ emojiLib }) => {
39
+ const stingified = JSON.stringify(emojiLib).replace(
40
+ /(["'])require(?:(?=(\\?))\2.)*?\1/g,
41
+ (value) => value.replace(/"/g, ''),
42
+ );
43
+
44
+ fs.writeFile(
45
+ 'src/emoji-data/index.ts',
46
+ `export type Emoji = {
47
+ id: string;
48
+ name: string;
49
+ names: string[];
50
+ unicode: string;
51
+ skins?: string[];
52
+ };
53
+
54
+ export type Emojis = Emoji[];
55
+
56
+ export const compiledEmojis: Emojis = ${stingified}`,
57
+ (err) => {
58
+ if (err) throw err;
59
+ },
60
+ );
61
+ });