@azure/communication-react 1.16.0-alpha-202405132107 → 1.16.0-alpha-202405132302

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 (161) hide show
  1. package/dist/communication-react.d.ts +96 -113
  2. package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-DWzf8cuK.js → ChatMessageComponentAsRichTextEditBox-Vvv1aBkI.js} +23 -14
  3. package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-Vvv1aBkI.js.map +1 -0
  4. package/dist/dist-cjs/communication-react/{index-W6o1SuXO.js → index-DdWRffLC.js} +647 -869
  5. package/dist/dist-cjs/communication-react/index-DdWRffLC.js.map +1 -0
  6. package/dist/dist-cjs/communication-react/index.js +1 -1
  7. package/dist/dist-esm/acs-ui-common/src/common.d.ts +74 -0
  8. package/dist/dist-esm/acs-ui-common/src/common.js.map +1 -1
  9. package/dist/dist-esm/acs-ui-common/src/index.d.ts +2 -0
  10. package/dist/dist-esm/acs-ui-common/src/index.js.map +1 -1
  11. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
  12. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
  13. package/dist/dist-esm/chat-component-bindings/src/handlers/createHandlers.d.ts +3 -6
  14. package/dist/dist-esm/chat-component-bindings/src/handlers/createHandlers.js +43 -26
  15. package/dist/dist-esm/chat-component-bindings/src/handlers/createHandlers.js.map +1 -1
  16. package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js +0 -2
  17. package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js.map +1 -1
  18. package/dist/dist-esm/communication-react/src/index.d.ts +5 -3
  19. package/dist/dist-esm/communication-react/src/index.js.map +1 -1
  20. package/dist/dist-esm/react-components/src/components/{AttachmentCard.d.ts → Attachment/AttachmentCard.d.ts} +3 -2
  21. package/dist/dist-esm/react-components/src/components/{AttachmentCard.js → Attachment/AttachmentCard.js} +17 -16
  22. package/dist/dist-esm/react-components/src/components/Attachment/AttachmentCard.js.map +1 -0
  23. package/dist/dist-esm/react-components/src/components/{AttachmentCardGroup.js → Attachment/AttachmentCardGroup.js} +1 -1
  24. package/dist/dist-esm/react-components/src/components/Attachment/AttachmentCardGroup.js.map +1 -0
  25. package/dist/dist-esm/react-components/src/components/{AttachmentDownloadCards.d.ts → Attachment/AttachmentDownloadCards.d.ts} +3 -2
  26. package/dist/dist-esm/react-components/src/components/{AttachmentDownloadCards.js → Attachment/AttachmentDownloadCards.js} +2 -2
  27. package/dist/dist-esm/react-components/src/components/Attachment/AttachmentDownloadCards.js.map +1 -0
  28. package/dist/dist-esm/react-components/src/components/{AttachmentUploadCards.d.ts → Attachment/AttachmentUploadCards.d.ts} +3 -3
  29. package/dist/dist-esm/react-components/src/components/{AttachmentUploadCards.js → Attachment/AttachmentUploadCards.js} +3 -3
  30. package/dist/dist-esm/react-components/src/components/Attachment/AttachmentUploadCards.js.map +1 -0
  31. package/dist/dist-esm/react-components/src/components/Caption.js.map +1 -1
  32. package/dist/dist-esm/react-components/src/components/CaptionsBanner.js.map +1 -1
  33. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentWrapper.d.ts +3 -2
  34. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentWrapper.js.map +1 -1
  35. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.d.ts +1 -1
  36. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js.map +1 -1
  37. package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/ChatMessageComponentAsMessageBubble.d.ts +3 -2
  38. package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/ChatMessageComponentAsMessageBubble.js.map +1 -1
  39. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.d.ts +2 -4
  40. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.js +21 -12
  41. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.js.map +1 -1
  42. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.d.ts +2 -4
  43. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.js.map +1 -1
  44. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.d.ts +2 -4
  45. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js +25 -14
  46. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js.map +1 -1
  47. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponent.d.ts +6 -3
  48. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponent.js +31 -13
  49. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponent.js.map +1 -1
  50. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.d.ts +3 -2
  51. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.js.map +1 -1
  52. package/dist/dist-esm/react-components/src/components/MessageThread.d.ts +6 -7
  53. package/dist/dist-esm/react-components/src/components/MessageThread.js.map +1 -1
  54. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.d.ts +30 -23
  55. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js +43 -27
  56. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js.map +1 -1
  57. package/dist/dist-esm/react-components/src/components/SendBox.d.ts +4 -4
  58. package/dist/dist-esm/react-components/src/components/SendBox.js +42 -17
  59. package/dist/dist-esm/react-components/src/components/SendBox.js.map +1 -1
  60. package/dist/dist-esm/react-components/src/components/index.d.ts +6 -6
  61. package/dist/dist-esm/react-components/src/components/index.js +3 -3
  62. package/dist/dist-esm/react-components/src/components/index.js.map +1 -1
  63. package/dist/dist-esm/react-components/src/components/styles/AttachmentCard.styles.d.ts +4 -0
  64. package/dist/dist-esm/react-components/src/components/styles/AttachmentCard.styles.js +4 -0
  65. package/dist/dist-esm/react-components/src/components/styles/AttachmentCard.styles.js.map +1 -1
  66. package/dist/dist-esm/react-components/src/components/styles/SendBox.styles.js +0 -1
  67. package/dist/dist-esm/react-components/src/components/styles/SendBox.styles.js.map +1 -1
  68. package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js +2 -1
  69. package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js.map +1 -1
  70. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.d.ts +27 -2
  71. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.js +14 -2
  72. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.js.map +1 -1
  73. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentUtils.d.ts +3 -2
  74. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentUtils.js +6 -5
  75. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentUtils.js.map +1 -1
  76. package/dist/dist-esm/react-components/src/components/utils/RichTextEditorStringsUtils.js +18 -18
  77. package/dist/dist-esm/react-components/src/components/utils/RichTextEditorStringsUtils.js.map +1 -1
  78. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.d.ts +3 -3
  79. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js +1 -1
  80. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js.map +1 -1
  81. package/dist/dist-esm/react-components/src/components/utils/common.d.ts +1 -1
  82. package/dist/dist-esm/react-components/src/components/utils/common.js.map +1 -1
  83. package/dist/dist-esm/react-components/src/localization/locales/ar-SA/strings.json +18 -18
  84. package/dist/dist-esm/react-components/src/localization/locales/cs-CZ/strings.json +18 -18
  85. package/dist/dist-esm/react-components/src/localization/locales/de-DE/strings.json +18 -18
  86. package/dist/dist-esm/react-components/src/localization/locales/en-GB/strings.json +18 -18
  87. package/dist/dist-esm/react-components/src/localization/locales/en-US/strings.json +38 -19
  88. package/dist/dist-esm/react-components/src/localization/locales/es-ES/strings.json +18 -18
  89. package/dist/dist-esm/react-components/src/localization/locales/fi-FI/strings.json +18 -18
  90. package/dist/dist-esm/react-components/src/localization/locales/fr-FR/strings.json +18 -18
  91. package/dist/dist-esm/react-components/src/localization/locales/he-IL/strings.json +18 -18
  92. package/dist/dist-esm/react-components/src/localization/locales/it-IT/strings.json +18 -18
  93. package/dist/dist-esm/react-components/src/localization/locales/ja-JP/strings.json +18 -18
  94. package/dist/dist-esm/react-components/src/localization/locales/ko-KR/strings.json +18 -18
  95. package/dist/dist-esm/react-components/src/localization/locales/nb-NO/strings.json +18 -18
  96. package/dist/dist-esm/react-components/src/localization/locales/nl-NL/strings.json +18 -18
  97. package/dist/dist-esm/react-components/src/localization/locales/pl-PL/strings.json +18 -18
  98. package/dist/dist-esm/react-components/src/localization/locales/pt-BR/strings.json +18 -18
  99. package/dist/dist-esm/react-components/src/localization/locales/ru-RU/strings.json +18 -18
  100. package/dist/dist-esm/react-components/src/localization/locales/sv-SE/strings.json +18 -18
  101. package/dist/dist-esm/react-components/src/localization/locales/tr-TR/strings.json +18 -18
  102. package/dist/dist-esm/react-components/src/localization/locales/zh-CN/strings.json +18 -18
  103. package/dist/dist-esm/react-components/src/localization/locales/zh-TW/strings.json +18 -18
  104. package/dist/dist-esm/react-components/src/types/Attachment.d.ts +21 -49
  105. package/dist/dist-esm/react-components/src/types/Attachment.js.map +1 -1
  106. package/dist/dist-esm/react-components/src/types/ChatMessage.d.ts +1 -1
  107. package/dist/dist-esm/react-components/src/types/ChatMessage.js.map +1 -1
  108. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.d.ts +3 -14
  109. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js +5 -76
  110. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js.map +1 -1
  111. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.d.ts +3 -23
  112. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.js.map +1 -1
  113. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.d.ts +5 -11
  114. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js +22 -40
  115. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js.map +1 -1
  116. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/state/CallWithChatAdapterState.d.ts +0 -9
  117. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/state/CallWithChatAdapterState.js +1 -5
  118. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/state/CallWithChatAdapterState.js.map +1 -1
  119. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js +73 -15
  120. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js.map +1 -1
  121. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.d.ts +3 -16
  122. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js +29 -89
  123. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js.map +1 -1
  124. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.d.ts +6 -19
  125. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.js.map +1 -1
  126. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapterProvider.d.ts +0 -5
  127. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapterProvider.js +0 -31
  128. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapterProvider.js.map +1 -1
  129. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.d.ts +66 -61
  130. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.js +33 -44
  131. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.js.map +1 -1
  132. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.js +2 -2
  133. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.js.map +1 -1
  134. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.d.ts +1 -8
  135. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.js.map +1 -1
  136. package/dist/dist-esm/react-composites/src/composites/ChatComposite/hooks/useHandlers.js +22 -10
  137. package/dist/dist-esm/react-composites/src/composites/ChatComposite/hooks/useHandlers.js.map +1 -1
  138. package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.d.ts +1 -2
  139. package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.js.map +1 -1
  140. package/dist/dist-esm/react-composites/src/composites/ChatComposite/styles/Chat.styles.js +1 -1
  141. package/dist/dist-esm/react-composites/src/composites/ChatComposite/styles/Chat.styles.js.map +1 -1
  142. package/package.json +1 -1
  143. package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-DWzf8cuK.js.map +0 -1
  144. package/dist/dist-cjs/communication-react/index-W6o1SuXO.js.map +0 -1
  145. package/dist/dist-esm/react-components/src/components/AttachmentCard.js.map +0 -1
  146. package/dist/dist-esm/react-components/src/components/AttachmentCardGroup.js.map +0 -1
  147. package/dist/dist-esm/react-components/src/components/AttachmentDownloadCards.js.map +0 -1
  148. package/dist/dist-esm/react-components/src/components/AttachmentUploadCards.js.map +0 -1
  149. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.d.ts +0 -48
  150. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.js +0 -188
  151. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.js.map +0 -1
  152. package/dist/dist-esm/react-composites/src/composites/ChatComposite/hooks/useSelector.d.ts +0 -6
  153. package/dist/dist-esm/react-composites/src/composites/ChatComposite/hooks/useSelector.js +0 -11
  154. package/dist/dist-esm/react-composites/src/composites/ChatComposite/hooks/useSelector.js.map +0 -1
  155. package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/attachmentUploadsSelector.d.ts +0 -29
  156. package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/attachmentUploadsSelector.js +0 -12
  157. package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/attachmentUploadsSelector.js.map +0 -1
  158. package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.d.ts +0 -12
  159. package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.js +0 -15
  160. package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.js.map +0 -1
  161. /package/dist/dist-esm/react-components/src/components/{AttachmentCardGroup.d.ts → Attachment/AttachmentCardGroup.d.ts} +0 -0
@@ -2,8 +2,7 @@ import type { ChatMessage, ChatParticipant, SendMessageOptions } from '@azure/co
2
2
  import type { CommunicationIdentifierKind, CommunicationUserKind } from '@azure/communication-common';
3
3
  import { ChatThreadClientState } from "../../../../../chat-stateful-client/src";
4
4
  import type { AdapterError, AdapterErrors, AdapterState, Disposable } from '../../common/adapters';
5
- import { _AttachmentUploadAdapter, _AttachmentUploadsUiState } from './AzureCommunicationAttachmentUploadAdapter';
6
- import { AttachmentMetadata } from "../../../../../react-components/src";
5
+ import { MessageOptions } from "../../../../../acs-ui-common/src";
7
6
  /**
8
7
  * {@link ChatAdapter} state for pure UI purposes.
9
8
  *
@@ -11,14 +10,6 @@ import { AttachmentMetadata } from "../../../../../react-components/src";
11
10
  */
12
11
  export type ChatAdapterUiState = {
13
12
  error?: Error;
14
- /**
15
- * Attachments being uploaded by a user in the current thread.
16
- * Should be set to null once the upload is complete.
17
- * Array of type {@link _AttachmentUploadsUiState}
18
- *
19
- * @internal
20
- */
21
- _attachmentUploads?: _AttachmentUploadsUiState;
22
13
  };
23
14
  /**
24
15
  * {@link ChatAdapter} state inferred from Azure Communication Services backend.
@@ -54,12 +45,9 @@ export interface ChatAdapterThreadManagement {
54
45
  fetchInitialData(): Promise<void>;
55
46
  /**
56
47
  * Send a message in the thread.
48
+ * Please note that SendMessageOptions is being deprecated, please use MessageOptions instead.
57
49
  */
58
- sendMessage(content: string, options?: SendMessageOptions): Promise<void>;
59
- /**
60
- * Send a message with attachments in the chat thread.
61
- */
62
- sendMessageWithAttachments(content: string, attachments: AttachmentMetadata[]): Promise<void>;
50
+ sendMessage(content: string, options?: SendMessageOptions | /* @conditional-compile-remove(attachment-upload) */ MessageOptions): Promise<void>;
63
51
  /**
64
52
  * Send a read receipt for a message.
65
53
  */
@@ -78,10 +66,9 @@ export interface ChatAdapterThreadManagement {
78
66
  setTopic(topicName: string): Promise<void>;
79
67
  /**
80
68
  * Update a message content.
69
+ * Please note that metadata is being deprecated, please use MessageOptions.metadata instead.
81
70
  */
82
- updateMessage(messageId: string, content: string, metadata?: Record<string, string>, options?: {
83
- attachmentMetadata?: AttachmentMetadata[];
84
- }): Promise<void>;
71
+ updateMessage(messageId: string, content: string, options?: Record<string, string> | /* @conditional-compile-remove(attachment-upload) */ MessageOptions): Promise<void>;
85
72
  /**
86
73
  * Delete a message in the thread.
87
74
  */
@@ -197,7 +184,7 @@ export interface ChatAdapterSubscribers {
197
184
  *
198
185
  * @public
199
186
  */
200
- export type ChatAdapter = ChatAdapterThreadManagement & AdapterState<ChatAdapterState> & Disposable & ChatAdapterSubscribers & _AttachmentUploadAdapter;
187
+ export type ChatAdapter = ChatAdapterThreadManagement & AdapterState<ChatAdapterState> & Disposable & ChatAdapterSubscribers;
201
188
  /**
202
189
  * Callback for {@link ChatAdapterSubscribers} 'messageReceived' event.
203
190
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ChatAdapter.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/ChatAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ChatMessage, ChatParticipant, SendMessageOptions } from '@azure/communication-chat';\nimport type { CommunicationIdentifierKind, CommunicationUserKind } from '@azure/communication-common';\nimport { ChatThreadClientState } from '@internal/chat-stateful-client';\nimport type { AdapterError, AdapterErrors, AdapterState, Disposable } from '../../common/adapters';\n/* @conditional-compile-remove(attachment-upload) */\nimport { _AttachmentUploadAdapter, _AttachmentUploadsUiState } from './AzureCommunicationAttachmentUploadAdapter';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AttachmentMetadata } from '@internal/react-components';\n\n/**\n * {@link ChatAdapter} state for pure UI purposes.\n *\n * @public\n */\nexport type ChatAdapterUiState = {\n // FIXME(Delete?)\n // Self-contained state for composite\n error?: Error;\n /* @conditional-compile-remove(attachment-upload) */\n /**\n * Attachments being uploaded by a user in the current thread.\n * Should be set to null once the upload is complete.\n * Array of type {@link _AttachmentUploadsUiState}\n *\n * @internal\n */\n _attachmentUploads?: _AttachmentUploadsUiState;\n};\n\n/**\n * {@link ChatAdapter} state inferred from Azure Communication Services backend.\n *\n * @public\n */\nexport type ChatCompositeClientState = {\n userId: CommunicationIdentifierKind;\n displayName: string;\n thread: ChatThreadClientState;\n /**\n * Latest error encountered for each operation performed via the adapter.\n */\n latestErrors: AdapterErrors;\n};\n\n/**\n * {@link ChatAdapter} state.\n *\n * @public\n */\nexport type ChatAdapterState = ChatAdapterUiState & ChatCompositeClientState;\n\n/**\n * Functionality for managing the current chat thread.\n *\n * @public\n */\nexport interface ChatAdapterThreadManagement {\n /**\n * Fetch initial state for the Chat adapter.\n *\n * Performs the minimal fetch necessary for ChatComposite and API methods.\n */\n fetchInitialData(): Promise<void>;\n /**\n * Send a message in the thread.\n */\n sendMessage(content: string, options?: SendMessageOptions): Promise<void>;\n /* @conditional-compile-remove(attachment-upload) */\n /**\n * Send a message with attachments in the chat thread.\n */\n sendMessageWithAttachments(content: string, attachments: AttachmentMetadata[]): Promise<void>;\n /**\n * Send a read receipt for a message.\n */\n sendReadReceipt(chatMessageId: string): Promise<void>;\n /**\n * Send typing indicator in the thread.\n */\n sendTypingIndicator(): Promise<void>;\n /**\n * Remove a participant in the thread.\n */\n removeParticipant(userId: string): Promise<void>;\n /**\n * Set the topic for the thread.\n */\n setTopic(topicName: string): Promise<void>;\n /**\n * Update a message content.\n */\n updateMessage(\n messageId: string,\n content: string,\n metadata?: Record<string, string>,\n /* @conditional-compile-remove(attachment-upload) */\n options?: {\n attachmentMetadata?: AttachmentMetadata[];\n }\n ): Promise<void>;\n /**\n * Delete a message in the thread.\n */\n deleteMessage(messageId: string): Promise<void>;\n /**\n * Load more previous messages in the chat thread history.\n *\n * @remarks\n * This method is usually used to control incremental fetch/infinite scroll\n *\n */\n loadPreviousChatMessages(messagesToLoad: number): Promise<boolean>;\n /**\n * Downloads a resource into the cache for the given message.\n */\n downloadResourceToCache(resourceDetails: ResourceDetails): Promise<void>;\n /**\n * Removes a resource from the cache for the given message.\n */\n removeResourceFromCache(resourceDetails: ResourceDetails): void;\n}\n/**\n * Details required for download a resource to cache.\n *\n * @public\n */\nexport type ResourceDetails = {\n threadId: string;\n messageId: string;\n resourceUrl: string;\n};\n\n/**\n * Chat composite events that can be subscribed to.\n *\n * @public\n */\nexport interface ChatAdapterSubscribers {\n /**\n * Subscribe function for 'messageReceived' event.\n */\n on(event: 'messageReceived', listener: MessageReceivedListener): void;\n /**\n * Subscribe function for 'messageEdited' event.\n */\n on(event: 'messageEdited', listener: MessageEditedListener): void;\n /**\n * Subscribe function for 'messageDeleted' event.\n */\n on(event: 'messageDeleted', listener: MessageDeletedListener): void;\n /**\n * Subscribe function for 'messageSent' event.\n */\n on(event: 'messageSent', listener: MessageSentListener): void;\n /**\n * Subscribe function for 'messageRead' event.\n */\n on(event: 'messageRead', listener: MessageReadListener): void;\n /**\n * Subscribe function for 'participantsAdded' event.\n */\n on(event: 'participantsAdded', listener: ParticipantsAddedListener): void;\n /**\n * Subscribe function for 'participantsRemoved' event.\n */\n on(event: 'participantsRemoved', listener: ParticipantsRemovedListener): void;\n /**\n * Subscribe function for 'topicChanged' event.\n */\n on(event: 'topicChanged', listener: TopicChangedListener): void;\n /**\n * Subscribe function for 'error' event.\n */\n on(event: 'error', listener: (e: AdapterError) => void): void;\n\n /**\n * Unsubscribe function for 'messageReceived' event.\n */\n off(event: 'messageReceived', listener: MessageReceivedListener): void;\n /**\n * Unsubscribe function for 'messageEdited' event.\n */\n off(event: 'messageEdited', listener: MessageEditedListener): void;\n /**\n * Unsubscribe function for 'messageDeleted' event.\n */\n off(event: 'messageDeleted', listener: MessageDeletedListener): void;\n /**\n * Unsubscribe function for 'messageSent' event.\n */\n off(event: 'messageSent', listener: MessageSentListener): void;\n /**\n * Unsubscribe function for 'messageRead' event.\n */\n off(event: 'messageRead', listener: MessageReadListener): void;\n /**\n * Unsubscribe function for 'participantsAdded' event.\n */\n off(event: 'participantsAdded', listener: ParticipantsAddedListener): void;\n /**\n * Unsubscribe function for 'participantsRemoved' event.\n */\n off(event: 'participantsRemoved', listener: ParticipantsRemovedListener): void;\n /**\n * Unsubscribe function for 'topicChanged' event.\n */\n off(event: 'topicChanged', listener: TopicChangedListener): void;\n /**\n * Unsubscribe function for 'error' event.\n */\n off(event: 'error', listener: (e: AdapterError) => void): void;\n}\n\n/**\n * {@link ChatComposite} Adapter interface.\n *\n * @public\n */\nexport type ChatAdapter = ChatAdapterThreadManagement &\n AdapterState<ChatAdapterState> &\n Disposable &\n ChatAdapterSubscribers &\n /* @conditional-compile-remove(attachment-upload) */\n _AttachmentUploadAdapter;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageReceived' event.\n *\n * @public\n */\nexport type MessageReceivedListener = (event: { message: ChatMessage }) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageSent' event.\n *\n * @public\n */\nexport type MessageSentListener = MessageReceivedListener;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageEdited' event.\n *\n * @public\n */\nexport type MessageEditedListener = MessageReceivedListener;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageDeleted' event.\n *\n * @public\n */\nexport type MessageDeletedListener = MessageReceivedListener;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageRead' event.\n *\n * @public\n */\nexport type MessageReadListener = (event: { message: ChatMessage; readBy: CommunicationUserKind }) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'participantsAdded' event.\n *\n * @public\n */\nexport type ParticipantsAddedListener = (event: {\n participantsAdded: ChatParticipant[];\n addedBy: ChatParticipant;\n}) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'participantsRemoved' event.\n *\n * @public\n */\nexport type ParticipantsRemovedListener = (event: {\n participantsRemoved: ChatParticipant[];\n removedBy: ChatParticipant;\n}) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'topicChanged' event.\n *\n * @public\n */\nexport type TopicChangedListener = (event: { topic: string }) => void;\n"]}
1
+ {"version":3,"file":"ChatAdapter.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/ChatAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ChatMessage, ChatParticipant, SendMessageOptions } from '@azure/communication-chat';\nimport type { CommunicationIdentifierKind, CommunicationUserKind } from '@azure/communication-common';\nimport { ChatThreadClientState } from '@internal/chat-stateful-client';\nimport type { AdapterError, AdapterErrors, AdapterState, Disposable } from '../../common/adapters';\n/* @conditional-compile-remove(attachment-upload) */\nimport { MessageOptions } from '@internal/acs-ui-common';\n\n/**\n * {@link ChatAdapter} state for pure UI purposes.\n *\n * @public\n */\nexport type ChatAdapterUiState = {\n // FIXME(Delete?)\n // Self-contained state for composite\n error?: Error;\n};\n\n/**\n * {@link ChatAdapter} state inferred from Azure Communication Services backend.\n *\n * @public\n */\nexport type ChatCompositeClientState = {\n userId: CommunicationIdentifierKind;\n displayName: string;\n thread: ChatThreadClientState;\n /**\n * Latest error encountered for each operation performed via the adapter.\n */\n latestErrors: AdapterErrors;\n};\n\n/**\n * {@link ChatAdapter} state.\n *\n * @public\n */\nexport type ChatAdapterState = ChatAdapterUiState & ChatCompositeClientState;\n\n/**\n * Functionality for managing the current chat thread.\n *\n * @public\n */\nexport interface ChatAdapterThreadManagement {\n /**\n * Fetch initial state for the Chat adapter.\n *\n * Performs the minimal fetch necessary for ChatComposite and API methods.\n */\n fetchInitialData(): Promise<void>;\n /**\n * Send a message in the thread.\n * Please note that SendMessageOptions is being deprecated, please use MessageOptions instead.\n */\n sendMessage(\n content: string,\n options?: SendMessageOptions | /* @conditional-compile-remove(attachment-upload) */ MessageOptions\n ): Promise<void>;\n /**\n * Send a read receipt for a message.\n */\n sendReadReceipt(chatMessageId: string): Promise<void>;\n /**\n * Send typing indicator in the thread.\n */\n sendTypingIndicator(): Promise<void>;\n /**\n * Remove a participant in the thread.\n */\n removeParticipant(userId: string): Promise<void>;\n /**\n * Set the topic for the thread.\n */\n setTopic(topicName: string): Promise<void>;\n /**\n * Update a message content.\n * Please note that metadata is being deprecated, please use MessageOptions.metadata instead.\n */\n updateMessage(\n messageId: string,\n content: string,\n options?: Record<string, string> | /* @conditional-compile-remove(attachment-upload) */ MessageOptions\n ): Promise<void>;\n /**\n * Delete a message in the thread.\n */\n deleteMessage(messageId: string): Promise<void>;\n /**\n * Load more previous messages in the chat thread history.\n *\n * @remarks\n * This method is usually used to control incremental fetch/infinite scroll\n *\n */\n loadPreviousChatMessages(messagesToLoad: number): Promise<boolean>;\n /**\n * Downloads a resource into the cache for the given message.\n */\n downloadResourceToCache(resourceDetails: ResourceDetails): Promise<void>;\n /**\n * Removes a resource from the cache for the given message.\n */\n removeResourceFromCache(resourceDetails: ResourceDetails): void;\n}\n/**\n * Details required for download a resource to cache.\n *\n * @public\n */\nexport type ResourceDetails = {\n threadId: string;\n messageId: string;\n resourceUrl: string;\n};\n\n/**\n * Chat composite events that can be subscribed to.\n *\n * @public\n */\nexport interface ChatAdapterSubscribers {\n /**\n * Subscribe function for 'messageReceived' event.\n */\n on(event: 'messageReceived', listener: MessageReceivedListener): void;\n /**\n * Subscribe function for 'messageEdited' event.\n */\n on(event: 'messageEdited', listener: MessageEditedListener): void;\n /**\n * Subscribe function for 'messageDeleted' event.\n */\n on(event: 'messageDeleted', listener: MessageDeletedListener): void;\n /**\n * Subscribe function for 'messageSent' event.\n */\n on(event: 'messageSent', listener: MessageSentListener): void;\n /**\n * Subscribe function for 'messageRead' event.\n */\n on(event: 'messageRead', listener: MessageReadListener): void;\n /**\n * Subscribe function for 'participantsAdded' event.\n */\n on(event: 'participantsAdded', listener: ParticipantsAddedListener): void;\n /**\n * Subscribe function for 'participantsRemoved' event.\n */\n on(event: 'participantsRemoved', listener: ParticipantsRemovedListener): void;\n /**\n * Subscribe function for 'topicChanged' event.\n */\n on(event: 'topicChanged', listener: TopicChangedListener): void;\n /**\n * Subscribe function for 'error' event.\n */\n on(event: 'error', listener: (e: AdapterError) => void): void;\n\n /**\n * Unsubscribe function for 'messageReceived' event.\n */\n off(event: 'messageReceived', listener: MessageReceivedListener): void;\n /**\n * Unsubscribe function for 'messageEdited' event.\n */\n off(event: 'messageEdited', listener: MessageEditedListener): void;\n /**\n * Unsubscribe function for 'messageDeleted' event.\n */\n off(event: 'messageDeleted', listener: MessageDeletedListener): void;\n /**\n * Unsubscribe function for 'messageSent' event.\n */\n off(event: 'messageSent', listener: MessageSentListener): void;\n /**\n * Unsubscribe function for 'messageRead' event.\n */\n off(event: 'messageRead', listener: MessageReadListener): void;\n /**\n * Unsubscribe function for 'participantsAdded' event.\n */\n off(event: 'participantsAdded', listener: ParticipantsAddedListener): void;\n /**\n * Unsubscribe function for 'participantsRemoved' event.\n */\n off(event: 'participantsRemoved', listener: ParticipantsRemovedListener): void;\n /**\n * Unsubscribe function for 'topicChanged' event.\n */\n off(event: 'topicChanged', listener: TopicChangedListener): void;\n /**\n * Unsubscribe function for 'error' event.\n */\n off(event: 'error', listener: (e: AdapterError) => void): void;\n}\n\n/**\n * {@link ChatComposite} Adapter interface.\n *\n * @public\n */\nexport type ChatAdapter = ChatAdapterThreadManagement &\n AdapterState<ChatAdapterState> &\n Disposable &\n ChatAdapterSubscribers;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageReceived' event.\n *\n * @public\n */\nexport type MessageReceivedListener = (event: { message: ChatMessage }) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageSent' event.\n *\n * @public\n */\nexport type MessageSentListener = MessageReceivedListener;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageEdited' event.\n *\n * @public\n */\nexport type MessageEditedListener = MessageReceivedListener;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageDeleted' event.\n *\n * @public\n */\nexport type MessageDeletedListener = MessageReceivedListener;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageRead' event.\n *\n * @public\n */\nexport type MessageReadListener = (event: { message: ChatMessage; readBy: CommunicationUserKind }) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'participantsAdded' event.\n *\n * @public\n */\nexport type ParticipantsAddedListener = (event: {\n participantsAdded: ChatParticipant[];\n addedBy: ChatParticipant;\n}) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'participantsRemoved' event.\n *\n * @public\n */\nexport type ParticipantsRemovedListener = (event: {\n participantsRemoved: ChatParticipant[];\n removedBy: ChatParticipant;\n}) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'topicChanged' event.\n *\n * @public\n */\nexport type TopicChangedListener = (event: { topic: string }) => void;\n"]}
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { _AttachmentUploadAdapter } from './AzureCommunicationAttachmentUploadAdapter';
3
2
  import { ChatAdapter } from './ChatAdapter';
4
3
  /**
5
4
  * @private
@@ -16,9 +15,5 @@ export declare const ChatAdapterProvider: (props: ChatProviderProps) => JSX.Elem
16
15
  * @private
17
16
  */
18
17
  export declare const useAdapter: () => ChatAdapter;
19
- /**
20
- * @private
21
- */
22
- export declare const useAttachmentUploadAdapter: () => _AttachmentUploadAdapter;
23
18
  export {};
24
19
  //# sourceMappingURL=ChatAdapterProvider.d.ts.map
@@ -19,35 +19,4 @@ export const useAdapter = () => {
19
19
  }
20
20
  return adapter;
21
21
  };
22
- /**
23
- * @private
24
- */
25
- export const useAttachmentUploadAdapter = () => {
26
- /* @conditional-compile-remove(attachment-upload) */
27
- return useAdapter();
28
- // A stub that short-circuits all logic because none of the fields are available.
29
- return {
30
- registerActiveUploads() {
31
- return [];
32
- },
33
- registerCompletedUploads() {
34
- return [];
35
- },
36
- cancelUpload() {
37
- // noop
38
- },
39
- clearUploads() {
40
- // noop
41
- },
42
- updateUploadStatusMessage() {
43
- // noop
44
- },
45
- updateUploadProgress() {
46
- // noop
47
- },
48
- updateUploadMetadata() {
49
- // noop
50
- }
51
- };
52
- };
53
22
  //# sourceMappingURL=ChatAdapterProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatAdapterProvider.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/ChatAdapterProvider.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAazD,MAAM,kBAAkB,GAAG,aAAa,CAA0B,SAAS,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAwB,EAAe,EAAE;IAC3E,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,OAAO,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAAG,KAAK,CAAC,QAAQ,CAA+B,CAAC;AACrG,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAgB,EAAE;IAC1C,MAAM,OAAO,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,qDAAqD,CAAC;IAC9D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAA6B,EAAE;IACvE,oDAAoD;IACpD,OAAO,UAAU,EAAE,CAAC;IACpB,iFAAiF;IACjF,OAAO;QACL,qBAAqB;YACnB,OAAO,EAA4B,CAAC;QACtC,CAAC;QACD,wBAAwB;YACtB,OAAO,EAA4B,CAAC;QACtC,CAAC;QACD,YAAY;YACV,OAAO;QACT,CAAC;QACD,YAAY;YACV,OAAO;QACT,CAAC;QACD,yBAAyB;YACvB,OAAO;QACT,CAAC;QACD,oBAAoB;YAClB,OAAO;QACT,CAAC;QACD,oBAAoB;YAClB,OAAO;QACT,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport React, { createContext, useContext } from 'react';\nimport { AttachmentUploadTask } from '@internal/react-components';\nimport { _AttachmentUploadAdapter } from './AzureCommunicationAttachmentUploadAdapter';\nimport { ChatAdapter } from './ChatAdapter';\n\n/**\n * @private\n */\ntype ChatProviderProps = {\n children: React.ReactNode;\n adapter: ChatAdapter;\n};\n\nconst ChatAdapterContext = createContext<ChatAdapter | undefined>(undefined);\n\n/**\n * @private\n */\nexport const ChatAdapterProvider = (props: ChatProviderProps): JSX.Element => {\n const { adapter } = props;\n return <ChatAdapterContext.Provider value={adapter}>{props.children}</ChatAdapterContext.Provider>;\n};\n\n/**\n * @private\n */\nexport const useAdapter = (): ChatAdapter => {\n const adapter = useContext(ChatAdapterContext);\n if (!adapter) {\n throw 'Cannot find adapter please initialize before usage.';\n }\n return adapter;\n};\n\n/**\n * @private\n */\nexport const useAttachmentUploadAdapter = (): _AttachmentUploadAdapter => {\n /* @conditional-compile-remove(attachment-upload) */\n return useAdapter();\n // A stub that short-circuits all logic because none of the fields are available.\n return {\n registerActiveUploads() {\n return [] as AttachmentUploadTask[];\n },\n registerCompletedUploads() {\n return [] as AttachmentUploadTask[];\n },\n cancelUpload() {\n // noop\n },\n clearUploads() {\n // noop\n },\n updateUploadStatusMessage() {\n // noop\n },\n updateUploadProgress() {\n // noop\n },\n updateUploadMetadata() {\n // noop\n }\n };\n};\n"]}
1
+ {"version":3,"file":"ChatAdapterProvider.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/ChatAdapterProvider.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAWzD,MAAM,kBAAkB,GAAG,aAAa,CAA0B,SAAS,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAwB,EAAe,EAAE;IAC3E,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,OAAO,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAAG,KAAK,CAAC,QAAQ,CAA+B,CAAC;AACrG,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAgB,EAAE;IAC1C,MAAM,OAAO,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,qDAAqD,CAAC;IAC9D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport React, { createContext, useContext } from 'react';\nimport { ChatAdapter } from './ChatAdapter';\n\n/**\n * @private\n */\ntype ChatProviderProps = {\n children: React.ReactNode;\n adapter: ChatAdapter;\n};\n\nconst ChatAdapterContext = createContext<ChatAdapter | undefined>(undefined);\n\n/**\n * @private\n */\nexport const ChatAdapterProvider = (props: ChatProviderProps): JSX.Element => {\n const { adapter } = props;\n return <ChatAdapterContext.Provider value={adapter}>{props.children}</ChatAdapterContext.Provider>;\n};\n\n/**\n * @private\n */\nexport const useAdapter = (): ChatAdapter => {\n const adapter = useContext(ChatAdapterContext);\n if (!adapter) {\n throw 'Cannot find adapter please initialize before usage.';\n }\n return adapter;\n};\n"]}
@@ -1,75 +1,80 @@
1
- import { AttachmentMetadata, AttachmentSelectionHandler, AttachmentUploadTask, AttachmentProgressError } from "../../../../../react-components/src";
1
+ import { AttachmentUploadTask, AttachmentSelectionHandler, AttachmentActionHandler } from "../../../../../react-components/src";
2
+ import { AttachmentMetadata, AttachmentMetadataInProgress, AttachmentProgressError } from "../../../../../acs-ui-common/src";
3
+ /**
4
+ * @internal
5
+ */
6
+ export interface AttachmentUpload extends AttachmentUploadTask {
7
+ metadata: AttachmentMetadataInProgress;
8
+ }
9
+ /**
10
+ * @private
11
+ */
12
+ export declare enum AttachmentUploadActionType {
13
+ Set = "set",
14
+ Progress = "progress",
15
+ Completed = "completed",
16
+ Failed = "failed",
17
+ Remove = "remove",
18
+ Clear = "clear"
19
+ }
2
20
  /**
3
- * A wrapper object for a attachments that is being uploaded.
4
- * Provides common functions for updating the upload progress, canceling an upload etc.
5
21
  * @private
6
22
  */
7
- export declare class AttachmentUpload implements AttachmentUploadTask, AttachmentUploadEventEmitter {
8
- private _emitter;
9
- readonly taskId: string;
10
- readonly file?: File;
11
- /**
12
- * Name to be displayed in the UI during attachment upload.
13
- */
14
- readonly name: string;
15
- /**
16
- * Optional object of type {@link AttachmentMetadata}
17
- */
18
- metadata?: AttachmentMetadata;
19
- constructor(data: File | AttachmentMetadata);
20
- notifyUploadProgressChanged(value: number): void;
21
- notifyUploadCompleted(id: string, url: string): void;
22
- notifyUploadFailed(message: string): void;
23
- on(event: 'uploadProgressChange', listener: UploadProgressListener): void;
24
- on(event: 'uploadComplete', listener: UploadCompleteListener): void;
25
- on(event: 'uploadFail', listener: UploadFailedListener): void;
26
- off(event: 'uploadProgressChange', listener: UploadProgressListener): void;
27
- off(event: 'uploadComplete', listener: UploadCompleteListener): void;
28
- off(event: 'uploadFail', listener: UploadFailedListener): void;
23
+ interface Action {
24
+ type: AttachmentUploadActionType;
29
25
  }
30
- export type { AttachmentMetadata, AttachmentSelectionHandler, AttachmentUploadTask, AttachmentProgressError };
31
26
  /**
32
- * Listener for `uploadProgressed` event.
33
- * @beta
27
+ * @private
34
28
  */
35
- type UploadProgressListener = (taskId: string, value: number) => void;
29
+ interface SetAction extends Action {
30
+ type: AttachmentUploadActionType.Set;
31
+ newUploads: AttachmentUpload[];
32
+ }
36
33
  /**
37
- * Listener for `uploadComplete` event.
38
- * @beta
34
+ * @private
39
35
  */
40
- type UploadCompleteListener = (taskId: string, attachmentId: string, attachmentUrl: string) => void;
36
+ interface ProgressAction extends Action {
37
+ type: AttachmentUploadActionType.Progress;
38
+ taskId: string;
39
+ progress: number;
40
+ }
41
41
  /**
42
- * Listener for `uploadFailed` event.
43
- * @beta
42
+ * @private
44
43
  */
45
- type UploadFailedListener = (taskId: string, message: string) => void;
44
+ interface CompleteAction extends Action {
45
+ type: AttachmentUploadActionType.Completed;
46
+ taskId: string;
47
+ id: string;
48
+ url: string;
49
+ }
46
50
  /**
47
- * @beta
51
+ * @private
48
52
  */
49
- interface AttachmentUploadEventEmitter {
50
- /**
51
- * Subscriber function for `uploadProgressed` event.
52
- */
53
- on(event: 'uploadProgressChange', listener: UploadProgressListener): void;
54
- /**
55
- * Subscriber function for `uploadComplete` event.
56
- */
57
- on(event: 'uploadComplete', listener: UploadCompleteListener): void;
58
- /**
59
- * Subscriber function for `uploadFailed` event.
60
- */
61
- on(event: 'uploadFail', listener: UploadFailedListener): void;
62
- /**
63
- * Unsubscriber function for `uploadProgressed` event.
64
- */
65
- off(event: 'uploadProgressChange', listener: UploadProgressListener): void;
66
- /**
67
- * Unsubscriber function for `uploadComplete` event.
68
- */
69
- off(event: 'uploadComplete', listener: UploadCompleteListener): void;
70
- /**
71
- * Unsubscriber function for `uploadFailed` event.
72
- */
73
- off(event: 'uploadFail', listener: UploadFailedListener): void;
53
+ interface FailedAction extends Action {
54
+ type: AttachmentUploadActionType.Failed;
55
+ taskId: string;
56
+ message: string;
74
57
  }
58
+ /**
59
+ * @private
60
+ */
61
+ interface RemoveAction extends Action {
62
+ type: AttachmentUploadActionType.Remove;
63
+ id: string;
64
+ }
65
+ /**
66
+ * @private
67
+ */
68
+ interface ClearAction extends Action {
69
+ type: AttachmentUploadActionType.Clear;
70
+ }
71
+ /**
72
+ * @private
73
+ */
74
+ type Actions = SetAction | ProgressAction | CompleteAction | FailedAction | RemoveAction | ClearAction;
75
+ /**
76
+ * @internal
77
+ */
78
+ export declare const AttachmentUploadReducer: (state: AttachmentUpload[], action: Actions) => AttachmentUpload[];
79
+ export type { AttachmentMetadata, AttachmentSelectionHandler, AttachmentActionHandler, AttachmentUploadTask, AttachmentProgressError };
75
80
  //# sourceMappingURL=AttachmentUpload.d.ts.map
@@ -1,51 +1,40 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { EventEmitter } from 'events';
4
- import { nanoid } from 'nanoid';
5
- import { _MAX_EVENT_LISTENERS } from "../../../../../acs-ui-common/src";
6
3
  /**
7
- * A wrapper object for a attachments that is being uploaded.
8
- * Provides common functions for updating the upload progress, canceling an upload etc.
9
4
  * @private
10
5
  */
11
- export class AttachmentUpload {
12
- constructor(data) {
13
- this._emitter = new EventEmitter();
14
- this._emitter.setMaxListeners(_MAX_EVENT_LISTENERS);
15
- this.taskId = nanoid();
16
- if (data instanceof File) {
17
- this.file = data;
18
- }
19
- else {
20
- this.metadata = data;
21
- }
22
- const name = data === null || data === void 0 ? void 0 : data.name;
23
- this.name = name;
24
- }
25
- notifyUploadProgressChanged(value) {
26
- this._emitter.emit('uploadProgressChange', this.taskId, value);
27
- }
28
- notifyUploadCompleted(id, url) {
29
- this._emitter.emit('uploadComplete', this.taskId, id, url);
30
- }
31
- notifyUploadFailed(message) {
32
- this._emitter.emit('uploadFail', this.taskId, message);
33
- }
34
- /**
35
- * Attachment upload event subscriber.
36
- * @param event - {@link AttachmentUploadEvents}
37
- * @param listener - {@link AttachmentUploadEventListener}
38
- */
39
- on(event, listener) {
40
- this._emitter.addListener(event, listener);
41
- }
42
- /**
43
- * Attachment upload event unsubscriber.
44
- * @param event - {@link AttachmentUploadEvents}
45
- * @param listener - {@link AttachmentUploadEventListener}
46
- */
47
- off(event, listener) {
48
- this._emitter.removeListener(event, listener);
6
+ export var AttachmentUploadActionType;
7
+ (function (AttachmentUploadActionType) {
8
+ AttachmentUploadActionType["Set"] = "set";
9
+ AttachmentUploadActionType["Progress"] = "progress";
10
+ AttachmentUploadActionType["Completed"] = "completed";
11
+ AttachmentUploadActionType["Failed"] = "failed";
12
+ AttachmentUploadActionType["Remove"] = "remove";
13
+ AttachmentUploadActionType["Clear"] = "clear";
14
+ })(AttachmentUploadActionType || (AttachmentUploadActionType = {}));
15
+ /**
16
+ * @internal
17
+ */
18
+ export const AttachmentUploadReducer = (state, action) => {
19
+ switch (action.type) {
20
+ case AttachmentUploadActionType.Set:
21
+ return state.filter((v) => !v.metadata.error).concat(action.newUploads);
22
+ case AttachmentUploadActionType.Completed:
23
+ return state.map((v) => v.taskId === action.taskId
24
+ ? Object.assign(Object.assign({}, v), { metadata: Object.assign(Object.assign({}, v.metadata), { id: action.id, url: action.url, progress: 1 }) }) : v);
25
+ case AttachmentUploadActionType.Failed:
26
+ return state.map((v) => v.taskId === action.taskId
27
+ ? Object.assign(Object.assign({}, v), { metadata: Object.assign(Object.assign({}, v.metadata), { error: {
28
+ message: action.message
29
+ } }) }) : v);
30
+ case AttachmentUploadActionType.Remove:
31
+ return state.filter((v) => !v.metadata.error).filter((v) => v.metadata.id !== action.id);
32
+ case AttachmentUploadActionType.Progress:
33
+ return state.map((v) => v.taskId === action.taskId ? Object.assign(Object.assign({}, v), { metadata: Object.assign(Object.assign({}, v.metadata), { progress: action.progress }) }) : v);
34
+ case AttachmentUploadActionType.Clear:
35
+ return [];
36
+ default:
37
+ return state;
49
38
  }
50
- }
39
+ };
51
40
  //# sourceMappingURL=AttachmentUpload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentUpload.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,yCAAgC;AAQ/D;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAe3B,YAAY,IAA+B;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;QACvB,IAAI,IAAI,YAAY,IAAI,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,CAAC;QACD,MAAM,IAAI,GAAI,IAAsC,aAAtC,IAAI,uBAAJ,IAAI,CAAoC,IAAI,CAAC;QAC3D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,2BAA2B,CAAC,KAAa;QACvC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,sBAAsB,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACjE,CAAC;IAED,qBAAqB,CAAC,EAAU,EAAE,GAAW;QAC3C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IAC7D,CAAC;IAED,kBAAkB,CAAC,OAAe;QAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAKD;;;;OAIG;IACH,EAAE,CAAC,KAA6B,EAAE,QAAuC;QACvE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAKD;;;;OAIG;IACH,GAAG,CAAC,KAA6B,EAAE,QAAuC;QACxE,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { EventEmitter } from 'events';\nimport { nanoid } from 'nanoid';\nimport { _MAX_EVENT_LISTENERS } from '@internal/acs-ui-common';\nimport {\n AttachmentMetadata,\n AttachmentSelectionHandler,\n AttachmentUploadTask,\n AttachmentProgressError\n} from '@internal/react-components';\n\n/**\n * A wrapper object for a attachments that is being uploaded.\n * Provides common functions for updating the upload progress, canceling an upload etc.\n * @private\n */\nexport class AttachmentUpload implements AttachmentUploadTask, AttachmentUploadEventEmitter {\n private _emitter: EventEmitter;\n // a nanoid to uniquely identify each upload task\n public readonly taskId: string;\n // a file object that represents the attachment selected by the user via browser file picker\n public readonly file?: File;\n /**\n * Name to be displayed in the UI during attachment upload.\n */\n public readonly name: string;\n /**\n * Optional object of type {@link AttachmentMetadata}\n */\n public metadata?: AttachmentMetadata;\n\n constructor(data: File | AttachmentMetadata) {\n this._emitter = new EventEmitter();\n this._emitter.setMaxListeners(_MAX_EVENT_LISTENERS);\n this.taskId = nanoid();\n if (data instanceof File) {\n this.file = data;\n } else {\n this.metadata = data;\n }\n const name = (data as unknown as AttachmentMetadata)?.name;\n this.name = name;\n }\n\n notifyUploadProgressChanged(value: number): void {\n this._emitter.emit('uploadProgressChange', this.taskId, value);\n }\n\n notifyUploadCompleted(id: string, url: string): void {\n this._emitter.emit('uploadComplete', this.taskId, id, url);\n }\n\n notifyUploadFailed(message: string): void {\n this._emitter.emit('uploadFail', this.taskId, message);\n }\n\n on(event: 'uploadProgressChange', listener: UploadProgressListener): void;\n on(event: 'uploadComplete', listener: UploadCompleteListener): void;\n on(event: 'uploadFail', listener: UploadFailedListener): void;\n /**\n * Attachment upload event subscriber.\n * @param event - {@link AttachmentUploadEvents}\n * @param listener - {@link AttachmentUploadEventListener}\n */\n on(event: AttachmentUploadEvents, listener: AttachmentUploadEventListener): void {\n this._emitter.addListener(event, listener);\n }\n\n off(event: 'uploadProgressChange', listener: UploadProgressListener): void;\n off(event: 'uploadComplete', listener: UploadCompleteListener): void;\n off(event: 'uploadFail', listener: UploadFailedListener): void;\n /**\n * Attachment upload event unsubscriber.\n * @param event - {@link AttachmentUploadEvents}\n * @param listener - {@link AttachmentUploadEventListener}\n */\n off(event: AttachmentUploadEvents, listener: AttachmentUploadEventListener): void {\n this._emitter.removeListener(event, listener);\n }\n}\n\nexport type { AttachmentMetadata, AttachmentSelectionHandler, AttachmentUploadTask, AttachmentProgressError };\n\n/**\n * Events emitted by the AttachmentUpload class.\n * @beta\n */\ntype AttachmentUploadEvents = 'uploadProgressChange' | 'uploadComplete' | 'uploadFail';\n\n/**\n * Events listeners supported by the AttachmentUpload class.\n * @beta\n */\ntype AttachmentUploadEventListener = UploadProgressListener | UploadCompleteListener | UploadFailedListener;\n\n/**\n * Listener for `uploadProgressed` event.\n * @beta\n */\ntype UploadProgressListener = (taskId: string, value: number) => void;\n/**\n * Listener for `uploadComplete` event.\n * @beta\n */\ntype UploadCompleteListener = (taskId: string, attachmentId: string, attachmentUrl: string) => void;\n/**\n * Listener for `uploadFailed` event.\n * @beta\n */\ntype UploadFailedListener = (taskId: string, message: string) => void;\n\n/**\n * @beta\n */\ninterface AttachmentUploadEventEmitter {\n /**\n * Subscriber function for `uploadProgressed` event.\n */\n on(event: 'uploadProgressChange', listener: UploadProgressListener): void;\n /**\n * Subscriber function for `uploadComplete` event.\n */\n on(event: 'uploadComplete', listener: UploadCompleteListener): void;\n /**\n * Subscriber function for `uploadFailed` event.\n */\n on(event: 'uploadFail', listener: UploadFailedListener): void;\n\n /**\n * Unsubscriber function for `uploadProgressed` event.\n */\n off(event: 'uploadProgressChange', listener: UploadProgressListener): void;\n /**\n * Unsubscriber function for `uploadComplete` event.\n */\n off(event: 'uploadComplete', listener: UploadCompleteListener): void;\n /**\n * Unsubscriber function for `uploadFailed` event.\n */\n off(event: 'uploadFail', listener: UploadFailedListener): void;\n}\n"]}
1
+ {"version":3,"file":"AttachmentUpload.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC;;GAEG;AACH,MAAM,CAAN,IAAY,0BAOX;AAPD,WAAY,0BAA0B;IACpC,yCAAW,CAAA;IACX,mDAAqB,CAAA;IACrB,qDAAuB,CAAA;IACvB,+CAAiB,CAAA;IACjB,+CAAiB,CAAA;IACjB,6CAAe,CAAA;AACjB,CAAC,EAPW,0BAA0B,KAA1B,0BAA0B,QAOrC;AAiED;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAyB,EAAE,MAAe,EAAsB,EAAE;IACxG,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,0BAA0B,CAAC,GAAG;YACjC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAE1E,KAAK,0BAA0B,CAAC,SAAS;YACvC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACrB,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;gBACxB,CAAC,iCAAM,CAAC,KAAE,QAAQ,kCAAO,CAAC,CAAC,QAAQ,KAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,OAChF,CAAC,CAAC,CAAC,CACN,CAAC;QAEJ,KAAK,0BAA0B,CAAC,MAAM;YACpC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACrB,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;gBACxB,CAAC,iCACM,CAAC,KACJ,QAAQ,kCACH,CAAC,CAAC,QAAQ,KACb,KAAK,EAAE;4BACL,OAAO,EAAE,MAAM,CAAC,OAAO;yBACxB,OAGP,CAAC,CAAC,CAAC,CACN,CAAC;QAEJ,KAAK,0BAA0B,CAAC,MAAM;YACpC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;QAE3F,KAAK,0BAA0B,CAAC,QAAQ;YACtC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACrB,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,iCAAM,CAAC,KAAE,QAAQ,kCAAO,CAAC,CAAC,QAAQ,KAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,OAAK,CAAC,CAAC,CAAC,CAClG,CAAC;QAEJ,KAAK,0BAA0B,CAAC,KAAK;YACnC,OAAO,EAAE,CAAC;QACZ;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AttachmentUploadTask, AttachmentSelectionHandler, AttachmentActionHandler } from '@internal/react-components';\nimport { AttachmentMetadata, AttachmentMetadataInProgress, AttachmentProgressError } from '@internal/acs-ui-common';\n\n/**\n * @internal\n */\nexport interface AttachmentUpload extends AttachmentUploadTask {\n metadata: AttachmentMetadataInProgress;\n}\n\n/**\n * @private\n */\nexport enum AttachmentUploadActionType {\n Set = 'set',\n Progress = 'progress',\n Completed = 'completed',\n Failed = 'failed',\n Remove = 'remove',\n Clear = 'clear'\n}\n\n/**\n * @private\n */\ninterface Action {\n type: AttachmentUploadActionType;\n}\n\n/**\n * @private\n */\ninterface SetAction extends Action {\n type: AttachmentUploadActionType.Set;\n newUploads: AttachmentUpload[];\n}\n\n/**\n * @private\n */\ninterface ProgressAction extends Action {\n type: AttachmentUploadActionType.Progress;\n taskId: string;\n progress: number;\n}\n\n/**\n * @private\n */\ninterface CompleteAction extends Action {\n type: AttachmentUploadActionType.Completed;\n taskId: string;\n id: string;\n url: string;\n}\n\n/**\n * @private\n */\ninterface FailedAction extends Action {\n type: AttachmentUploadActionType.Failed;\n taskId: string;\n message: string;\n}\n\n/**\n * @private\n */\ninterface RemoveAction extends Action {\n type: AttachmentUploadActionType.Remove;\n id: string;\n}\n\n/**\n * @private\n */\ninterface ClearAction extends Action {\n type: AttachmentUploadActionType.Clear;\n}\n\n/**\n * @private\n */\ntype Actions = SetAction | ProgressAction | CompleteAction | FailedAction | RemoveAction | ClearAction;\n\n/**\n * @internal\n */\nexport const AttachmentUploadReducer = (state: AttachmentUpload[], action: Actions): AttachmentUpload[] => {\n switch (action.type) {\n case AttachmentUploadActionType.Set:\n return state.filter((v) => !v.metadata.error).concat(action.newUploads);\n\n case AttachmentUploadActionType.Completed:\n return state.map((v) =>\n v.taskId === action.taskId\n ? { ...v, metadata: { ...v.metadata, id: action.id, url: action.url, progress: 1 } }\n : v\n );\n\n case AttachmentUploadActionType.Failed:\n return state.map((v) =>\n v.taskId === action.taskId\n ? {\n ...v,\n metadata: {\n ...v.metadata,\n error: {\n message: action.message\n }\n }\n }\n : v\n );\n\n case AttachmentUploadActionType.Remove:\n return state.filter((v) => !v.metadata.error).filter((v) => v.metadata.id !== action.id);\n\n case AttachmentUploadActionType.Progress:\n return state.map((v) =>\n v.taskId === action.taskId ? { ...v, metadata: { ...v.metadata, progress: action.progress } } : v\n );\n\n case AttachmentUploadActionType.Clear:\n return [];\n default:\n return state;\n }\n};\n\nexport type {\n AttachmentMetadata,\n AttachmentSelectionHandler,\n AttachmentActionHandler,\n AttachmentUploadTask,\n AttachmentProgressError\n};\n"]}
@@ -39,7 +39,7 @@ export const AttachmentUploadButton = (props) => {
39
39
  } },
40
40
  React.createElement(IconButton, { className: iconButtonClassName, ariaLabel: uploadAttachmentButtonStringTrampoline() },
41
41
  React.createElement(SendBoxAttachFileIconTrampoline, null))),
42
- React.createElement("input", { ref: inputRef, hidden: true, multiple: !disableMultipleUploads, accept: supportedMediaTypes.join(','), type: "file", onClick: (e) => {
42
+ React.createElement("input", { "data-testid": "attachment-upload-button", ref: inputRef, hidden: true, multiple: !disableMultipleUploads, accept: supportedMediaTypes.join(','), type: "file", onClick: (e) => {
43
43
  // To ensure that `onChange` is fired even if the same file is picked again.
44
44
  e.currentTarget.value = '';
45
45
  }, onChange: (e) => {
@@ -66,7 +66,7 @@ props) => {
66
66
  React.createElement(AttachmentUploadButton, Object.assign({}, props))));
67
67
  };
68
68
  const uploadAttachmentButtonStringTrampoline = () => {
69
- //@conditional-compile-remove(attachment-upload)
69
+ /* @conditional-compile-remove(attachment-upload) */
70
70
  //eslint-disable-next-line react-hooks/rules-of-hooks
71
71
  return useLocale().strings.chat.uploadAttachment;
72
72
  return '';
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentUploadButton.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.tsx"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IconButton, mergeStyles, Stack, useTheme } from '@fluentui/react';\nimport React from 'react';\nimport { ChatCompositeIcon } from '../../common/icons';\n/* @conditional-compile-remove(attachment-upload) */\nimport { useLocale } from '../../localization';\n\n/**\n * Props for {@link AttachmentUploadButton} component.\n * @internal\n */\nexport interface AttachmentUploadButtonProps {\n /**\n * A list of strings containing the comma separated list of supported media (aka. mime) types.\n * i.e. ['image/*', 'video/*', 'audio/*']\n * Default value is `['*']`, meaning all media types are supported.\n * Similar to the `accept` attribute of the `<input type=\"file\" />` element.\n */\n supportedMediaTypes?: string[];\n /**\n * Disable multiple files to be selected if set to `true`.\n * Default value is `false`, meaning multiple files can be selected.\n * Similar to the `multiple` attribute of the `<input type=\"file\" />` element.\n */\n disableMultipleUploads?: boolean;\n /**\n * onChange handler for the attachment upload button.\n * Similar to the `onChange` attribute of the `<input type=\"file\" />` element.\n * Called every time files are selected through the attachment upload button with a {@link FileList}\n * of selected files.\n */\n onChange?: (files: FileList | null) => void;\n}\n\n/**\n * @internal\n */\nexport const AttachmentUploadButton = (props: AttachmentUploadButtonProps): JSX.Element => {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const theme = useTheme();\n // default supportedMediaTypes is ['*'], meaning all media types are supported.\n // default disableMultipleUploads is false, meaning multiple files can be selected.\n const { supportedMediaTypes = ['*'], disableMultipleUploads = false, onChange } = props;\n\n const attachmentUploadButtonClassName = mergeStyles({\n width: '1.5rem',\n height: '1.5rem',\n cursor: 'pointer',\n padding: '0.15rem',\n ':hover': {\n backgroundColor: theme.palette.neutralLighter\n }\n });\n\n const iconButtonClassName = mergeStyles({\n color: 'unset',\n width: '1.5rem',\n height: '1.5rem',\n ':hover': {\n color: 'unset',\n background: 'transparent'\n }\n });\n\n return (\n <>\n <Stack\n verticalAlign=\"center\"\n horizontalAlign=\"center\"\n className={attachmentUploadButtonClassName}\n onClick={() => {\n inputRef.current?.click();\n }}\n >\n <IconButton className={iconButtonClassName} ariaLabel={uploadAttachmentButtonStringTrampoline()}>\n <SendBoxAttachFileIconTrampoline />\n </IconButton>\n </Stack>\n <input\n ref={inputRef}\n hidden\n multiple={!disableMultipleUploads}\n accept={supportedMediaTypes.join(',')}\n type=\"file\"\n onClick={(e) => {\n // To ensure that `onChange` is fired even if the same file is picked again.\n e.currentTarget.value = '';\n }}\n onChange={(e) => {\n onChange && onChange(e.currentTarget.files);\n }}\n />\n </>\n );\n};\n\nconst SendBoxAttachFileIconTrampoline = (): JSX.Element => {\n /* @conditional-compile-remove(attachment-upload) */\n return <ChatCompositeIcon iconName=\"SendBoxAttachFile\" />;\n // Return _some_ available icon, as the real icon is beta-only.\n return <ChatCompositeIcon iconName=\"EditBoxCancel\" />;\n};\n\n/**\n * A wrapper to return {@link AttachmentUploadButton} component conditionally.\n * It will return `<></>` for stable builds.\n * @internal\n */\nexport const AttachmentUploadButtonWrapper = (\n // To make conditional compilation not throw errors.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n props: Pick<AttachmentUploadButtonProps, 'supportedMediaTypes' | 'disableMultipleUploads' | 'onChange'>\n): JSX.Element => {\n return (\n <>\n {\n /* @conditional-compile-remove(attachment-upload) */\n <AttachmentUploadButton {...props} />\n }\n </>\n );\n};\n\nconst uploadAttachmentButtonStringTrampoline = (): string => {\n //@conditional-compile-remove(attachment-upload)\n //eslint-disable-next-line react-hooks/rules-of-hooks\n return useLocale().strings.chat.uploadAttachment;\n return '';\n};\n"]}
1
+ {"version":3,"file":"AttachmentUploadButton.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.tsx"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IconButton, mergeStyles, Stack, useTheme } from '@fluentui/react';\nimport React from 'react';\nimport { ChatCompositeIcon } from '../../common/icons';\n/* @conditional-compile-remove(attachment-upload) */\nimport { useLocale } from '../../localization';\n\n/**\n * Props for {@link AttachmentUploadButton} component.\n * @internal\n */\nexport interface AttachmentUploadButtonProps {\n /**\n * A list of strings containing the comma separated list of supported media (aka. mime) types.\n * i.e. ['image/*', 'video/*', 'audio/*']\n * Default value is `['*']`, meaning all media types are supported.\n * Similar to the `accept` attribute of the `<input type=\"file\" />` element.\n */\n supportedMediaTypes?: string[];\n /**\n * Disable multiple files to be selected if set to `true`.\n * Default value is `false`, meaning multiple files can be selected.\n * Similar to the `multiple` attribute of the `<input type=\"file\" />` element.\n */\n disableMultipleUploads?: boolean;\n /**\n * onChange handler for the attachment upload button.\n * Similar to the `onChange` attribute of the `<input type=\"file\" />` element.\n * Called every time files are selected through the attachment upload button with a {@link FileList}\n * of selected files.\n */\n onChange?: (files: FileList | null) => void;\n}\n\n/**\n * @internal\n */\nexport const AttachmentUploadButton = (props: AttachmentUploadButtonProps): JSX.Element => {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const theme = useTheme();\n // default supportedMediaTypes is ['*'], meaning all media types are supported.\n // default disableMultipleUploads is false, meaning multiple files can be selected.\n const { supportedMediaTypes = ['*'], disableMultipleUploads = false, onChange } = props;\n\n const attachmentUploadButtonClassName = mergeStyles({\n width: '1.5rem',\n height: '1.5rem',\n cursor: 'pointer',\n padding: '0.15rem',\n ':hover': {\n backgroundColor: theme.palette.neutralLighter\n }\n });\n\n const iconButtonClassName = mergeStyles({\n color: 'unset',\n width: '1.5rem',\n height: '1.5rem',\n ':hover': {\n color: 'unset',\n background: 'transparent'\n }\n });\n\n return (\n <>\n <Stack\n verticalAlign=\"center\"\n horizontalAlign=\"center\"\n className={attachmentUploadButtonClassName}\n onClick={() => {\n inputRef.current?.click();\n }}\n >\n <IconButton className={iconButtonClassName} ariaLabel={uploadAttachmentButtonStringTrampoline()}>\n <SendBoxAttachFileIconTrampoline />\n </IconButton>\n </Stack>\n <input\n data-testid=\"attachment-upload-button\"\n ref={inputRef}\n hidden\n multiple={!disableMultipleUploads}\n accept={supportedMediaTypes.join(',')}\n type=\"file\"\n onClick={(e) => {\n // To ensure that `onChange` is fired even if the same file is picked again.\n e.currentTarget.value = '';\n }}\n onChange={(e) => {\n onChange && onChange(e.currentTarget.files);\n }}\n />\n </>\n );\n};\n\nconst SendBoxAttachFileIconTrampoline = (): JSX.Element => {\n /* @conditional-compile-remove(attachment-upload) */\n return <ChatCompositeIcon iconName=\"SendBoxAttachFile\" />;\n // Return _some_ available icon, as the real icon is beta-only.\n return <ChatCompositeIcon iconName=\"EditBoxCancel\" />;\n};\n\n/**\n * A wrapper to return {@link AttachmentUploadButton} component conditionally.\n * It will return `<></>` for stable builds.\n * @internal\n */\nexport const AttachmentUploadButtonWrapper = (\n // To make conditional compilation not throw errors.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n props: Pick<AttachmentUploadButtonProps, 'supportedMediaTypes' | 'disableMultipleUploads' | 'onChange'>\n): JSX.Element => {\n return (\n <>\n {\n /* @conditional-compile-remove(attachment-upload) */\n <AttachmentUploadButton {...props} />\n }\n </>\n );\n};\n\nconst uploadAttachmentButtonStringTrampoline = (): string => {\n /* @conditional-compile-remove(attachment-upload) */\n //eslint-disable-next-line react-hooks/rules-of-hooks\n return useLocale().strings.chat.uploadAttachment;\n return '';\n};\n"]}
@@ -1,12 +1,5 @@
1
1
  export * from './AttachmentUpload';
2
2
  export * from './AttachmentUploadButton';
3
- export type { AttachmentOptions, AttachmentProgressError, AttachmentUploadOptions, AttachmentSelectionHandler, AttachmentRemovalHandler, AttachmentUploadTask } from "../../../../../react-components/src";
3
+ export type { AttachmentOptions, AttachmentUploadTask, AttachmentUploadOptions, AttachmentRemovalHandler, AttachmentMetadataWrapper, AttachmentSelectionHandler, AttachmentActionHandler } from "../../../../../react-components/src";
4
4
  export type { AttachmentDownloadOptions } from "../../../../../react-components/src";
5
- /**
6
- * Metadata used for setting uploaded attachments by a user using chat composite in a group call.
7
- * @internal
8
- */
9
- export type FileSharingMetadata = {
10
- fileSharingMetadata: string;
11
- };
12
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/file-sharing/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from './AttachmentUpload';\nexport * from './AttachmentUploadButton';\n\nexport type {\n AttachmentOptions,\n AttachmentProgressError,\n AttachmentUploadOptions,\n AttachmentSelectionHandler,\n AttachmentRemovalHandler,\n AttachmentUploadTask\n} from '@internal/react-components';\n\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\nexport type { AttachmentDownloadOptions } from '@internal/react-components';\n\n/**\n * Metadata used for setting uploaded attachments by a user using chat composite in a group call.\n * @internal\n */\nexport type FileSharingMetadata = {\n fileSharingMetadata: string;\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/file-sharing/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from './AttachmentUpload';\nexport * from './AttachmentUploadButton';\n\nexport type {\n AttachmentOptions,\n AttachmentUploadTask,\n AttachmentUploadOptions,\n AttachmentRemovalHandler,\n AttachmentMetadataWrapper,\n AttachmentSelectionHandler,\n AttachmentActionHandler\n} from '@internal/react-components';\n\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\nexport type { AttachmentDownloadOptions } from '@internal/react-components';\n"]}
@@ -12,24 +12,36 @@ _component) => {
12
12
  return createCompositeHandlers(useAdapter());
13
13
  };
14
14
  const createCompositeHandlers = memoizeOne((adapter) => ({
15
- onSendMessage: adapter.sendMessage,
15
+ // have to use `any` here so we don't import from Chat SDK
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ onSendMessage: (content, options) => {
18
+ /* @conditional-compile-remove(attachment-upload) */
19
+ if (options &&
20
+ 'attachments' in options &&
21
+ options.attachments &&
22
+ options.attachments[0] &&
23
+ !('attachmentType' in options.attachments[0])) {
24
+ const adapterMessageOption = {
25
+ metadata: Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.metadata), { fileSharingMetadata: JSON.stringify(options === null || options === void 0 ? void 0 : options.attachments) })
26
+ };
27
+ return adapter.sendMessage(content, adapterMessageOption);
28
+ }
29
+ return adapter.sendMessage(content, options);
30
+ },
16
31
  onLoadPreviousChatMessages: adapter.loadPreviousChatMessages,
17
32
  onMessageSeen: adapter.sendReadReceipt,
18
33
  onTyping: adapter.sendTypingIndicator,
19
34
  onRemoveParticipant: adapter.removeParticipant,
20
35
  updateThreadTopicName: adapter.setTopic,
21
- onUpdateMessage: (messageId, content,
36
+ onUpdateMessage: function (messageId, content,
22
37
  /* @conditional-compile-remove(attachment-upload) */
23
- options) => {
24
- let metadata = undefined;
25
- /* @conditional-compile-remove(attachment-upload) */
26
- metadata = options === null || options === void 0 ? void 0 : options.metadata;
38
+ options) {
27
39
  /* @conditional-compile-remove(attachment-upload) */
28
- const updatedOptions = {
29
- attachmentMetadata: options === null || options === void 0 ? void 0 : options.attachmentMetadata
40
+ const adapterMessageOptions = {
41
+ attachments: options === null || options === void 0 ? void 0 : options.attachments
30
42
  };
31
- return adapter.updateMessage(messageId, content, metadata,
32
- /* @conditional-compile-remove(attachment-upload) */ updatedOptions);
43
+ return adapter.updateMessage(messageId, content,
44
+ /* @conditional-compile-remove(attachment-upload) */ adapterMessageOptions);
33
45
  },
34
46
  onDeleteMessage: adapter.deleteMessage
35
47
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"useHandlers.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/hooks/useHandlers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAI5D;;GAEG;AACH,+HAA+H;AAC/H,MAAM,CAAC,MAAM,WAAW,GAAG;AACzB,6DAA6D;AAC7D,UAAkD,EACU,EAAE;IAC9D,OAAO,uBAAuB,CAAC,UAAU,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,UAAU,CACxC,CAAC,OAAoB,EAAgB,EAAE,CAAC,CAAC;IACvC,aAAa,EAAE,OAAO,CAAC,WAAW;IAClC,0BAA0B,EAAE,OAAO,CAAC,wBAAwB;IAC5D,aAAa,EAAE,OAAO,CAAC,eAAe;IACtC,QAAQ,EAAE,OAAO,CAAC,mBAAmB;IACrC,mBAAmB,EAAE,OAAO,CAAC,iBAAiB;IAC9C,qBAAqB,EAAE,OAAO,CAAC,QAAQ;IACvC,eAAe,EAAE,CACf,SAAiB,EACjB,OAAe;IACf,oDAAoD;IACpD,OAIC,EACD,EAAE;QACF,IAAI,QAAQ,GAAG,SAAS,CAAC;QACzB,oDAAoD;QACpD,QAAQ,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,CAAC;QAC7B,oDAAoD;QACpD,MAAM,cAAc,GAAG;YACrB,kBAAkB,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,kBAAkB;SAChD,CAAC;QACF,OAAO,OAAO,CAAC,aAAa,CAC1B,SAAS,EACT,OAAO,EACP,QAAQ;QACR,oDAAoD,CAAC,cAAc,CACpE,CAAC;IACJ,CAAC;IACD,eAAe,EAAE,OAAO,CAAC,aAAa;CACvC,CAAC,CACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { CommonProperties } from '@internal/acs-ui-common';\nimport { ChatHandlers } from '@internal/chat-component-bindings';\n\nimport { ReactElement } from 'react';\nimport memoizeOne from 'memoize-one';\nimport { ChatAdapter } from '../adapter/ChatAdapter';\nimport { useAdapter } from '../adapter/ChatAdapterProvider';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AttachmentMetadata } from '@internal/react-components';\n\n/**\n * @private\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type\nexport const useHandlers = <PropsT>(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _component: (props: PropsT) => ReactElement | null\n): Pick<ChatHandlers, CommonProperties<ChatHandlers, PropsT>> => {\n return createCompositeHandlers(useAdapter());\n};\n\nconst createCompositeHandlers = memoizeOne(\n (adapter: ChatAdapter): ChatHandlers => ({\n onSendMessage: adapter.sendMessage,\n onLoadPreviousChatMessages: adapter.loadPreviousChatMessages,\n onMessageSeen: adapter.sendReadReceipt,\n onTyping: adapter.sendTypingIndicator,\n onRemoveParticipant: adapter.removeParticipant,\n updateThreadTopicName: adapter.setTopic,\n onUpdateMessage: (\n messageId: string,\n content: string,\n /* @conditional-compile-remove(attachment-upload) */\n options?: {\n metadata?: Record<string, string>;\n /* @conditional-compile-remove(attachment-upload) */\n attachmentMetadata?: AttachmentMetadata[];\n }\n ) => {\n let metadata = undefined;\n /* @conditional-compile-remove(attachment-upload) */\n metadata = options?.metadata;\n /* @conditional-compile-remove(attachment-upload) */\n const updatedOptions = {\n attachmentMetadata: options?.attachmentMetadata\n };\n return adapter.updateMessage(\n messageId,\n content,\n metadata,\n /* @conditional-compile-remove(attachment-upload) */ updatedOptions\n );\n },\n onDeleteMessage: adapter.deleteMessage\n })\n);\n"]}
1
+ {"version":3,"file":"useHandlers.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/hooks/useHandlers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAI5D;;GAEG;AACH,+HAA+H;AAC/H,MAAM,CAAC,MAAM,WAAW,GAAG;AACzB,6DAA6D;AAC7D,UAAkD,EACU,EAAE;IAC9D,OAAO,uBAAuB,CAAC,UAAU,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,UAAU,CACxC,CAAC,OAAoB,EAAgB,EAAE,CAAC,CAAC;IACvC,0DAA0D;IAC1D,8DAA8D;IAC9D,aAAa,EAAE,CAAC,OAAe,EAAE,OAAY,EAAE,EAAE;QAC/C,oDAAoD;QACpD,IACE,OAAO;YACP,aAAa,IAAI,OAAO;YACxB,OAAO,CAAC,WAAW;YACnB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;YACtB,CAAC,CAAC,gBAAgB,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAC7C,CAAC;YACD,MAAM,oBAAoB,GAAG;gBAC3B,QAAQ,kCACH,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KACpB,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAC,GAC1D;aACF,CAAC;YACF,OAAO,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IACD,0BAA0B,EAAE,OAAO,CAAC,wBAAwB;IAC5D,aAAa,EAAE,OAAO,CAAC,eAAe;IACtC,QAAQ,EAAE,OAAO,CAAC,mBAAmB;IACrC,mBAAmB,EAAE,OAAO,CAAC,iBAAiB;IAC9C,qBAAqB,EAAE,OAAO,CAAC,QAAQ;IACvC,eAAe,EAAE,UACf,SAAiB,EACjB,OAAe;IACf,oDAAoD;IACpD,OAAwB;QAExB,oDAAoD;QACpD,MAAM,qBAAqB,GAAmB;YAC5C,WAAW,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW;SAClC,CAAC;QACF,OAAO,OAAO,CAAC,aAAa,CAC1B,SAAS,EACT,OAAO;QACP,oDAAoD,CAAC,qBAAqB,CAC3E,CAAC;IACJ,CAAC;IACD,eAAe,EAAE,OAAO,CAAC,aAAa;CACvC,CAAC,CACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { CommonProperties } from '@internal/acs-ui-common';\nimport { ChatHandlers } from '@internal/chat-component-bindings';\n\nimport { ReactElement } from 'react';\nimport memoizeOne from 'memoize-one';\nimport { ChatAdapter } from '../adapter/ChatAdapter';\nimport { useAdapter } from '../adapter/ChatAdapterProvider';\n/* @conditional-compile-remove(attachment-upload) */\nimport { MessageOptions } from '@internal/acs-ui-common';\n\n/**\n * @private\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type\nexport const useHandlers = <PropsT>(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _component: (props: PropsT) => ReactElement | null\n): Pick<ChatHandlers, CommonProperties<ChatHandlers, PropsT>> => {\n return createCompositeHandlers(useAdapter());\n};\n\nconst createCompositeHandlers = memoizeOne(\n (adapter: ChatAdapter): ChatHandlers => ({\n // have to use `any` here so we don't import from Chat SDK\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onSendMessage: (content: string, options: any) => {\n /* @conditional-compile-remove(attachment-upload) */\n if (\n options &&\n 'attachments' in options &&\n options.attachments &&\n options.attachments[0] &&\n !('attachmentType' in options.attachments[0])\n ) {\n const adapterMessageOption = {\n metadata: {\n ...options?.metadata,\n fileSharingMetadata: JSON.stringify(options?.attachments)\n }\n };\n return adapter.sendMessage(content, adapterMessageOption);\n }\n return adapter.sendMessage(content, options);\n },\n onLoadPreviousChatMessages: adapter.loadPreviousChatMessages,\n onMessageSeen: adapter.sendReadReceipt,\n onTyping: adapter.sendTypingIndicator,\n onRemoveParticipant: adapter.removeParticipant,\n updateThreadTopicName: adapter.setTopic,\n onUpdateMessage: function (\n messageId: string,\n content: string,\n /* @conditional-compile-remove(attachment-upload) */\n options?: MessageOptions\n ) {\n /* @conditional-compile-remove(attachment-upload) */\n const adapterMessageOptions: MessageOptions = {\n attachments: options?.attachments\n };\n return adapter.updateMessage(\n messageId,\n content,\n /* @conditional-compile-remove(attachment-upload) */ adapterMessageOptions\n );\n },\n onDeleteMessage: adapter.deleteMessage\n })\n);\n"]}
@@ -6,6 +6,5 @@ export type { ChatAdapter, ChatAdapterSubscribers, ChatAdapterThreadManagement,
6
6
  export type { ResourceDetails } from './adapter/ChatAdapter';
7
7
  export * from './Strings';
8
8
  export type { AttachmentOptions, AttachmentMetadata, AttachmentDownloadOptions } from './file-sharing';
9
- export type { AttachmentProgressError, AttachmentUploadOptions, AttachmentSelectionHandler, AttachmentRemovalHandler, AttachmentUploadTask } from './file-sharing';
10
- export type { _AttachmentUploadsUiState, _AttachmentUploadAdapter } from './adapter/AzureCommunicationAttachmentUploadAdapter';
9
+ export type { AttachmentProgressError, AttachmentUploadOptions, AttachmentSelectionHandler, AttachmentActionHandler, AttachmentRemovalHandler, AttachmentUploadTask } from './file-sharing';
11
10
  //# sourceMappingURL=index.d.ts.map