botframework-webchat-component 4.13.0 → 4.14.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 (451) hide show
  1. package/.eslintignore +1 -9
  2. package/.eslintrc.yml +6 -0
  3. package/lib/Activity/Avatar.d.ts +10 -0
  4. package/lib/Activity/Avatar.d.ts.map +1 -0
  5. package/lib/Activity/Avatar.js +2 -1
  6. package/lib/Activity/Bubble.d.ts +11 -0
  7. package/lib/Activity/Bubble.d.ts.map +1 -0
  8. package/lib/Activity/Bubble.js +2 -2
  9. package/lib/Activity/CarouselFilmStrip.js +20 -30
  10. package/lib/Activity/CarouselFilmStripAttachment.js +120 -0
  11. package/lib/Activity/CarouselLayout.js +5 -5
  12. package/lib/Activity/Speak.d.ts +10 -0
  13. package/lib/Activity/Speak.d.ts.map +1 -0
  14. package/lib/Activity/Speak.js +10 -12
  15. package/lib/Activity/StackedLayout.d.ts +18 -0
  16. package/lib/Activity/StackedLayout.d.ts.map +1 -0
  17. package/lib/Activity/StackedLayout.js +18 -14
  18. package/lib/Assets/TypingAnimation.js +2 -2
  19. package/lib/Attachment/Assets/DownloadIcon.js +3 -1
  20. package/lib/Attachment/AudioAttachment.js +2 -2
  21. package/lib/Attachment/AudioContent.d.ts +11 -0
  22. package/lib/Attachment/AudioContent.d.ts.map +1 -0
  23. package/lib/Attachment/AudioContent.js +4 -4
  24. package/lib/Attachment/FileContent.d.ts +10 -0
  25. package/lib/Attachment/FileContent.d.ts.map +1 -0
  26. package/lib/Attachment/FileContent.js +4 -9
  27. package/lib/Attachment/HTMLVideoContent.d.ts +11 -0
  28. package/lib/Attachment/HTMLVideoContent.d.ts.map +1 -0
  29. package/lib/Attachment/HTMLVideoContent.js +2 -2
  30. package/lib/Attachment/ImageContent.d.ts +8 -0
  31. package/lib/Attachment/ImageContent.d.ts.map +1 -0
  32. package/lib/Attachment/ImageContent.js +2 -2
  33. package/lib/Attachment/TextContent.d.ts +8 -0
  34. package/lib/Attachment/TextContent.d.ts.map +1 -0
  35. package/lib/Attachment/TextContent.js +4 -4
  36. package/lib/Attachment/VideoAttachment.js +2 -2
  37. package/lib/Attachment/VideoContent.d.ts +11 -0
  38. package/lib/Attachment/VideoContent.d.ts.map +1 -0
  39. package/lib/Attachment/VideoContent.js +1 -1
  40. package/lib/Attachment/VimeoContent.d.ts +10 -0
  41. package/lib/Attachment/VimeoContent.d.ts.map +1 -0
  42. package/lib/Attachment/VimeoContent.js +8 -8
  43. package/lib/Attachment/YouTubeContent.d.ts +10 -0
  44. package/lib/Attachment/YouTubeContent.d.ts.map +1 -0
  45. package/lib/Attachment/YouTubeContent.js +5 -5
  46. package/lib/Avatar/ImageAvatar.js +2 -2
  47. package/lib/Avatar/InitialsAvatar.js +2 -2
  48. package/lib/BasicConnectivityStatus.js +2 -2
  49. package/lib/BasicSendBox.d.ts +9 -0
  50. package/lib/BasicSendBox.d.ts.map +1 -0
  51. package/lib/BasicSendBox.js +6 -5
  52. package/lib/BasicToast.js +4 -4
  53. package/lib/BasicToaster.js +4 -4
  54. package/lib/BasicTranscript.js +143 -123
  55. package/lib/BasicTypingIndicator.d.ts +5 -0
  56. package/lib/BasicTypingIndicator.d.ts.map +1 -0
  57. package/lib/BasicTypingIndicator.js +2 -2
  58. package/lib/BasicWebChat.d.ts +9 -0
  59. package/lib/BasicWebChat.d.ts.map +1 -0
  60. package/lib/BasicWebChat.js +6 -4
  61. package/lib/Composer.d.ts +23 -0
  62. package/lib/Composer.d.ts.map +1 -0
  63. package/lib/Composer.js +33 -55
  64. package/lib/ConnectivityStatus/Assets/ErrorNotificationIcon.js +2 -2
  65. package/lib/ConnectivityStatus/Assets/SpinnerAnimation.js +2 -2
  66. package/lib/ConnectivityStatus/Assets/WarningNotificationIcon.js +2 -2
  67. package/lib/ConnectivityStatus/Connected.js +1 -1
  68. package/lib/ConnectivityStatus/Connecting.js +4 -4
  69. package/lib/ConnectivityStatus/FailedToConnect.js +2 -2
  70. package/lib/ConnectivityStatus/JavaScriptError.js +2 -2
  71. package/lib/Dictation.js +13 -4
  72. package/lib/ErrorBox.d.ts +8 -0
  73. package/lib/ErrorBox.d.ts.map +1 -0
  74. package/lib/ErrorBox.js +2 -2
  75. package/lib/Middleware/Activity/createCoreMiddleware.d.ts +3 -0
  76. package/lib/Middleware/Activity/createCoreMiddleware.d.ts.map +1 -0
  77. package/lib/Middleware/Activity/createCoreMiddleware.js +1 -1
  78. package/lib/Middleware/ActivityStatus/AbsoluteTime.js +1 -1
  79. package/lib/Middleware/ActivityStatus/RelativeTime.js +1 -1
  80. package/lib/Middleware/ActivityStatus/SendStatus/SendFailedRetry.js +3 -3
  81. package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.d.ts +11 -0
  82. package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.d.ts.map +1 -0
  83. package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.js +4 -4
  84. package/lib/Middleware/ActivityStatus/Timestamp.d.ts +9 -0
  85. package/lib/Middleware/ActivityStatus/Timestamp.d.ts.map +1 -0
  86. package/lib/Middleware/ActivityStatus/Timestamp.js +2 -2
  87. package/lib/Middleware/ActivityStatus/createCoreMiddleware.d.ts +3 -0
  88. package/lib/Middleware/ActivityStatus/createCoreMiddleware.d.ts.map +1 -0
  89. package/lib/Middleware/ActivityStatus/createCoreMiddleware.js +1 -1
  90. package/lib/Middleware/ActivityStatus/createSendStatusMiddleware.js +5 -3
  91. package/lib/Middleware/ActivityStatus/createTimestampMiddleware.js +1 -1
  92. package/lib/Middleware/Attachment/createCoreMiddleware.d.ts +3 -0
  93. package/lib/Middleware/Attachment/createCoreMiddleware.d.ts.map +1 -0
  94. package/lib/Middleware/Attachment/createCoreMiddleware.js +9 -9
  95. package/lib/Middleware/AttachmentForScreenReader/AudioAttachment.js +1 -1
  96. package/lib/Middleware/AttachmentForScreenReader/FileAttachment.js +1 -1
  97. package/lib/Middleware/AttachmentForScreenReader/ImageAttachment.js +1 -1
  98. package/lib/Middleware/AttachmentForScreenReader/TextAttachment.js +1 -1
  99. package/lib/Middleware/AttachmentForScreenReader/VideoAttachment.js +1 -1
  100. package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.d.ts +3 -0
  101. package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.d.ts.map +1 -0
  102. package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.js +9 -5
  103. package/lib/Middleware/Avatar/createCoreMiddleware.d.ts +11 -0
  104. package/lib/Middleware/Avatar/createCoreMiddleware.d.ts.map +1 -0
  105. package/lib/Middleware/Avatar/createCoreMiddleware.js +2 -2
  106. package/lib/Middleware/CardAction/createCoreMiddleware.js +2 -2
  107. package/lib/Middleware/GroupActivities/createCoreMiddleware.js +1 -1
  108. package/lib/Middleware/ScrollToEndButton/ScrollToEndButton.js +71 -0
  109. package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.d.ts +3 -0
  110. package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.d.ts.map +1 -0
  111. package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.js +27 -0
  112. package/lib/Middleware/Toast/createCoreMiddleware.d.ts +4 -0
  113. package/lib/Middleware/Toast/createCoreMiddleware.d.ts.map +1 -0
  114. package/lib/Middleware/Toast/createCoreMiddleware.js +1 -1
  115. package/lib/Middleware/TypingIndicator/createCoreMiddleware.d.ts +3 -0
  116. package/lib/Middleware/TypingIndicator/createCoreMiddleware.d.ts.map +1 -0
  117. package/lib/Middleware/TypingIndicator/createCoreMiddleware.js +3 -2
  118. package/lib/ReactWebChat.d.ts +10 -0
  119. package/lib/ReactWebChat.d.ts.map +1 -0
  120. package/lib/ReactWebChat.js +19 -7
  121. package/lib/ScreenReaderActivity.js +64 -45
  122. package/lib/SendBox/Assets/AttachmentIcon.js +3 -1
  123. package/lib/SendBox/Assets/MicrophoneIcon.js +3 -1
  124. package/lib/SendBox/Assets/SendIcon.js +2 -2
  125. package/lib/SendBox/AutoResizeTextArea.d.ts +23 -0
  126. package/lib/SendBox/AutoResizeTextArea.d.ts.map +1 -0
  127. package/lib/SendBox/AutoResizeTextArea.js +6 -6
  128. package/lib/SendBox/DictationInterims.d.ts +9 -0
  129. package/lib/SendBox/DictationInterims.d.ts.map +1 -0
  130. package/lib/SendBox/DictationInterims.js +2 -2
  131. package/lib/SendBox/IconButton.js +2 -2
  132. package/lib/SendBox/MicrophoneButton.d.ts +11 -0
  133. package/lib/SendBox/MicrophoneButton.d.ts.map +1 -0
  134. package/lib/SendBox/MicrophoneButton.js +25 -24
  135. package/lib/SendBox/SendButton.d.ts +9 -0
  136. package/lib/SendBox/SendButton.d.ts.map +1 -0
  137. package/lib/SendBox/SendButton.js +7 -5
  138. package/lib/SendBox/SuggestedAction.js +5 -9
  139. package/lib/SendBox/SuggestedActions.d.ts +5 -0
  140. package/lib/SendBox/SuggestedActions.d.ts.map +1 -0
  141. package/lib/SendBox/SuggestedActions.js +10 -7
  142. package/lib/SendBox/TextBox.d.ts +28 -0
  143. package/lib/SendBox/TextBox.d.ts.map +1 -0
  144. package/lib/SendBox/TextBox.js +12 -7
  145. package/lib/SendBox/UploadButton.d.ts +9 -0
  146. package/lib/SendBox/UploadButton.d.ts.map +1 -0
  147. package/lib/SendBox/UploadButton.js +5 -5
  148. package/lib/Styles/StyleSet/Activities.d.ts +5 -0
  149. package/lib/Styles/StyleSet/Activities.d.ts.map +1 -0
  150. package/lib/Styles/StyleSet/AudioAttachment.d.ts +6 -0
  151. package/lib/Styles/StyleSet/AudioAttachment.d.ts.map +1 -0
  152. package/lib/Styles/StyleSet/AudioContent.d.ts +4 -0
  153. package/lib/Styles/StyleSet/AudioContent.d.ts.map +1 -0
  154. package/lib/Styles/StyleSet/AutoResizeTextArea.d.ts +37 -0
  155. package/lib/Styles/StyleSet/AutoResizeTextArea.d.ts.map +1 -0
  156. package/lib/Styles/StyleSet/Avatar.d.ts +9 -0
  157. package/lib/Styles/StyleSet/Avatar.d.ts.map +1 -0
  158. package/lib/Styles/StyleSet/BasicTranscript.d.ts +77 -0
  159. package/lib/Styles/StyleSet/BasicTranscript.d.ts.map +1 -0
  160. package/lib/Styles/StyleSet/Bubble.d.ts +5 -0
  161. package/lib/Styles/StyleSet/Bubble.d.ts.map +1 -0
  162. package/lib/Styles/StyleSet/Bubble.js +1 -1
  163. package/lib/Styles/StyleSet/CarouselFilmStrip.d.ts +5 -0
  164. package/lib/Styles/StyleSet/CarouselFilmStrip.d.ts.map +1 -0
  165. package/lib/Styles/StyleSet/CarouselFilmStrip.js +2 -18
  166. package/lib/Styles/StyleSet/CarouselFilmStripAttachment.d.ts +3 -0
  167. package/lib/Styles/StyleSet/CarouselFilmStripAttachment.d.ts.map +1 -0
  168. package/lib/Styles/StyleSet/CarouselFilmStripAttachment.js +63 -0
  169. package/lib/Styles/StyleSet/CarouselFlipper.d.ts +27 -0
  170. package/lib/Styles/StyleSet/CarouselFlipper.d.ts.map +1 -0
  171. package/lib/Styles/StyleSet/ConnectivityNotification.d.ts +13 -0
  172. package/lib/Styles/StyleSet/ConnectivityNotification.d.ts.map +1 -0
  173. package/lib/Styles/StyleSet/DictationInterims.d.ts +13 -0
  174. package/lib/Styles/StyleSet/DictationInterims.d.ts.map +1 -0
  175. package/lib/Styles/StyleSet/ErrorBox.d.ts +33 -0
  176. package/lib/Styles/StyleSet/ErrorBox.d.ts.map +1 -0
  177. package/lib/Styles/StyleSet/ErrorNotification.d.ts +23 -0
  178. package/lib/Styles/StyleSet/ErrorNotification.d.ts.map +1 -0
  179. package/lib/Styles/StyleSet/FileContent.d.ts +32 -0
  180. package/lib/Styles/StyleSet/FileContent.d.ts.map +1 -0
  181. package/lib/Styles/StyleSet/ImageAvatar.d.ts +7 -0
  182. package/lib/Styles/StyleSet/ImageAvatar.d.ts.map +1 -0
  183. package/lib/Styles/StyleSet/InitialsAvatar.d.ts +19 -0
  184. package/lib/Styles/StyleSet/InitialsAvatar.d.ts.map +1 -0
  185. package/lib/Styles/StyleSet/MicrophoneButton.d.ts +13 -0
  186. package/lib/Styles/StyleSet/MicrophoneButton.d.ts.map +1 -0
  187. package/lib/Styles/StyleSet/Root.d.ts +8 -0
  188. package/lib/Styles/StyleSet/Root.d.ts.map +1 -0
  189. package/lib/Styles/StyleSet/ScrollToEndButton.d.ts +36 -0
  190. package/lib/Styles/StyleSet/ScrollToEndButton.d.ts.map +1 -0
  191. package/lib/Styles/StyleSet/ScrollToEndButton.js +36 -34
  192. package/lib/Styles/StyleSet/SendBox.d.ts +24 -0
  193. package/lib/Styles/StyleSet/SendBox.d.ts.map +1 -0
  194. package/lib/Styles/StyleSet/SendBoxButton.d.ts +33 -0
  195. package/lib/Styles/StyleSet/SendBoxButton.d.ts.map +1 -0
  196. package/lib/Styles/StyleSet/SendBoxTextBox.d.ts +41 -0
  197. package/lib/Styles/StyleSet/SendBoxTextBox.d.ts.map +1 -0
  198. package/lib/Styles/StyleSet/SendStatus.d.ts +8 -0
  199. package/lib/Styles/StyleSet/SendStatus.d.ts.map +1 -0
  200. package/lib/Styles/StyleSet/SingleAttachmentActivity.d.ts +11 -0
  201. package/lib/Styles/StyleSet/SingleAttachmentActivity.d.ts.map +1 -0
  202. package/lib/Styles/StyleSet/SpinnerAnimation.d.ts +15 -0
  203. package/lib/Styles/StyleSet/SpinnerAnimation.d.ts.map +1 -0
  204. package/lib/Styles/StyleSet/StackedLayout.d.ts +63 -0
  205. package/lib/Styles/StyleSet/StackedLayout.d.ts.map +1 -0
  206. package/lib/Styles/StyleSet/SuggestedAction.d.ts +49 -0
  207. package/lib/Styles/StyleSet/SuggestedAction.d.ts.map +1 -0
  208. package/lib/Styles/StyleSet/SuggestedAction.js +2 -2
  209. package/lib/Styles/StyleSet/SuggestedActions.d.ts +118 -0
  210. package/lib/Styles/StyleSet/SuggestedActions.d.ts.map +1 -0
  211. package/lib/Styles/StyleSet/TextContent.d.ts +28 -0
  212. package/lib/Styles/StyleSet/TextContent.d.ts.map +1 -0
  213. package/lib/Styles/StyleSet/Toast.d.ts +65 -0
  214. package/lib/Styles/StyleSet/Toast.d.ts.map +1 -0
  215. package/lib/Styles/StyleSet/Toaster.d.ts +111 -0
  216. package/lib/Styles/StyleSet/Toaster.d.ts.map +1 -0
  217. package/lib/Styles/StyleSet/TypingAnimation.d.ts +8 -0
  218. package/lib/Styles/StyleSet/TypingAnimation.d.ts.map +1 -0
  219. package/lib/Styles/StyleSet/TypingIndicator.d.ts +11 -0
  220. package/lib/Styles/StyleSet/TypingIndicator.d.ts.map +1 -0
  221. package/lib/Styles/StyleSet/UploadButton.d.ts +14 -0
  222. package/lib/Styles/StyleSet/UploadButton.d.ts.map +1 -0
  223. package/lib/Styles/StyleSet/VideoAttachment.d.ts +2 -0
  224. package/lib/Styles/StyleSet/VideoAttachment.d.ts.map +1 -0
  225. package/lib/Styles/StyleSet/VideoContent.d.ts +6 -0
  226. package/lib/Styles/StyleSet/VideoContent.d.ts.map +1 -0
  227. package/lib/Styles/StyleSet/VimeoContent.d.ts +7 -0
  228. package/lib/Styles/StyleSet/VimeoContent.d.ts.map +1 -0
  229. package/lib/Styles/StyleSet/WarningNotification.d.ts +22 -0
  230. package/lib/Styles/StyleSet/WarningNotification.d.ts.map +1 -0
  231. package/lib/Styles/StyleSet/YouTubeContent.d.ts +7 -0
  232. package/lib/Styles/StyleSet/YouTubeContent.d.ts.map +1 -0
  233. package/lib/Styles/createStyleSet.d.ts +1103 -0
  234. package/lib/Styles/createStyleSet.d.ts.map +1 -0
  235. package/lib/Styles/createStyleSet.js +44 -41
  236. package/lib/Styles/mirrorStyle.js +2 -2
  237. package/lib/Toast/CollapseIcon.js +3 -1
  238. package/lib/Toast/DismissIcon.js +3 -1
  239. package/lib/Toast/ExpandIcon.js +3 -1
  240. package/lib/Toast/NotificationIcon.js +1 -1
  241. package/lib/Toast/createToastMiddleware.d.ts +4 -0
  242. package/lib/Toast/createToastMiddleware.d.ts.map +1 -0
  243. package/lib/Toast/createToastMiddleware.js +2 -2
  244. package/lib/Utils/AccessKeySink/Surface.js +7 -5
  245. package/lib/Utils/AccessibleButton.js +6 -4
  246. package/lib/Utils/AccessibleInputText.d.ts +21 -0
  247. package/lib/Utils/AccessibleInputText.d.ts.map +1 -0
  248. package/lib/Utils/AccessibleInputText.js +29 -25
  249. package/lib/Utils/AccessibleTextArea.d.ts +20 -0
  250. package/lib/Utils/AccessibleTextArea.d.ts.map +1 -0
  251. package/lib/Utils/AccessibleTextArea.js +35 -24
  252. package/lib/Utils/CroppedImage.js +2 -2
  253. package/lib/Utils/Fade.js +2 -2
  254. package/lib/Utils/FocusRedirector.js +3 -3
  255. package/lib/Utils/InlineMarkdown.js +6 -6
  256. package/lib/Utils/TypeFocusSink/FocusBox.js +6 -4
  257. package/lib/Utils/TypeFocusSink/getTabIndex.d.ts +2 -0
  258. package/lib/Utils/TypeFocusSink/getTabIndex.d.ts.map +1 -0
  259. package/lib/Utils/TypeFocusSink/getTabIndex.js +1 -1
  260. package/lib/Utils/TypeFocusSink/navigableEvent.js +1 -1
  261. package/lib/Utils/activityAltText.js +100 -0
  262. package/lib/Utils/addTargetBlankToHyperlinksMarkdown.js +1 -1
  263. package/lib/Utils/createCustomEvent.js +1 -1
  264. package/lib/Utils/debounce.js +1 -1
  265. package/lib/Utils/detectBrowser.js +1 -1
  266. package/lib/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingWorker.js +2 -2
  267. package/lib/Utils/downscaleImageToDataURL/index.js +2 -2
  268. package/lib/Utils/filterMap.js +1 -1
  269. package/lib/Utils/findLastIndex.js +2 -2
  270. package/lib/Utils/mapMap.js +1 -1
  271. package/lib/Utils/readDataURIToBlob.js +2 -2
  272. package/lib/Utils/singleToArray.js +1 -1
  273. package/lib/connectToWebChat.js +5 -3
  274. package/lib/hooks/index.d.ts +21 -0
  275. package/lib/hooks/index.d.ts.map +1 -0
  276. package/lib/hooks/index.js +1 -1
  277. package/lib/hooks/internal/BypassSpeechSynthesisPonyfill.js +97 -39
  278. package/lib/hooks/internal/UITracker.js +2 -2
  279. package/lib/hooks/internal/useAcknowledgedActivity.js +2 -2
  280. package/lib/hooks/internal/useDispatchScrollPosition.js +1 -1
  281. package/lib/hooks/internal/useDispatchTranscriptFocus.js +1 -1
  282. package/lib/hooks/internal/useEnterKeyHint.js +1 -1
  283. package/lib/hooks/internal/useForceRender.js +2 -2
  284. package/lib/hooks/internal/useForceRenderAtInterval.js +2 -2
  285. package/lib/hooks/internal/useInternalRenderMarkdownInline.js +1 -1
  286. package/lib/hooks/internal/useLocalizeAccessKey.js +2 -2
  287. package/lib/hooks/internal/useMemoize.js +2 -2
  288. package/lib/hooks/internal/useNavigatorPlatform.js +1 -1
  289. package/lib/hooks/internal/useNonce.js +1 -1
  290. package/lib/hooks/internal/useRegisterFocusSendBox.js +1 -1
  291. package/lib/hooks/internal/useRegisterFocusTranscript.js +1 -1
  292. package/lib/hooks/internal/useRegisterScrollRelative.js +1 -1
  293. package/lib/hooks/internal/useRegisterScrollTo.js +1 -1
  294. package/lib/hooks/internal/useRegisterScrollToEnd.js +1 -1
  295. package/lib/hooks/internal/useReplaceEmoticon.js +2 -2
  296. package/lib/hooks/internal/useResumeAudioContext.js +33 -0
  297. package/lib/hooks/internal/useScrollRelative.js +1 -1
  298. package/lib/hooks/internal/useSettableDictateAbortable.js +1 -1
  299. package/lib/hooks/internal/useSuggestedActionsAccessKey.js +1 -1
  300. package/lib/hooks/internal/useUniqueId.d.ts +2 -0
  301. package/lib/hooks/internal/useUniqueId.d.ts.map +1 -0
  302. package/lib/hooks/internal/useUniqueId.js +1 -1
  303. package/lib/hooks/useDictateAbortable.d.ts +2 -0
  304. package/lib/hooks/useDictateAbortable.d.ts.map +1 -0
  305. package/lib/hooks/useDictateAbortable.js +2 -2
  306. package/lib/hooks/useFocus.d.ts +2 -0
  307. package/lib/hooks/useFocus.d.ts.map +1 -0
  308. package/lib/hooks/useFocus.js +1 -1
  309. package/lib/hooks/useFocusSendBox.d.ts +3 -0
  310. package/lib/hooks/useFocusSendBox.d.ts.map +1 -0
  311. package/lib/hooks/useFocusSendBox.js +2 -1
  312. package/lib/hooks/useObserveScrollPosition.d.ts +3 -0
  313. package/lib/hooks/useObserveScrollPosition.d.ts.map +1 -0
  314. package/lib/hooks/useObserveScrollPosition.js +2 -2
  315. package/lib/hooks/useObserveTranscriptFocus.d.ts +5 -0
  316. package/lib/hooks/useObserveTranscriptFocus.d.ts.map +1 -0
  317. package/lib/hooks/useObserveTranscriptFocus.js +2 -2
  318. package/lib/hooks/useRenderMarkdownAsHTML.d.ts +5 -0
  319. package/lib/hooks/useRenderMarkdownAsHTML.d.ts.map +1 -0
  320. package/lib/hooks/useRenderMarkdownAsHTML.js +2 -2
  321. package/lib/hooks/useScrollDown.d.ts +4 -0
  322. package/lib/hooks/useScrollDown.d.ts.map +1 -0
  323. package/lib/hooks/useScrollDown.js +1 -1
  324. package/lib/hooks/useScrollTo.d.ts +5 -0
  325. package/lib/hooks/useScrollTo.d.ts.map +1 -0
  326. package/lib/hooks/useScrollTo.js +1 -1
  327. package/lib/hooks/useScrollToEnd.d.ts +2 -0
  328. package/lib/hooks/useScrollToEnd.d.ts.map +1 -0
  329. package/lib/hooks/useScrollToEnd.js +1 -1
  330. package/lib/hooks/useScrollUp.d.ts +4 -0
  331. package/lib/hooks/useScrollUp.d.ts.map +1 -0
  332. package/lib/hooks/useScrollUp.js +1 -1
  333. package/lib/hooks/useSendFiles.d.ts +2 -0
  334. package/lib/hooks/useSendFiles.d.ts.map +1 -0
  335. package/lib/hooks/useSendFiles.js +3 -3
  336. package/lib/hooks/useStyleSet.d.ts +2 -0
  337. package/lib/hooks/useStyleSet.d.ts.map +1 -0
  338. package/lib/hooks/useStyleSet.js +1 -1
  339. package/lib/hooks/useWebSpeechPonyfill.d.ts +3 -0
  340. package/lib/hooks/useWebSpeechPonyfill.d.ts.map +1 -0
  341. package/lib/hooks/useWebSpeechPonyfill.js +1 -1
  342. package/lib/index.d.ts +209 -22
  343. package/lib/index.d.ts.map +1 -1
  344. package/lib/index.js +19 -19
  345. package/lib/tsconfig.json +1 -1
  346. package/lib/types/ScrollPosition.d.ts +6 -0
  347. package/lib/types/ScrollPosition.d.ts.map +1 -0
  348. package/lib/types/ScrollPosition.js +2 -0
  349. package/package.json +38 -38
  350. package/src/Activity/{Avatar.js → Avatar.tsx} +9 -2
  351. package/src/Activity/{Bubble.js → Bubble.tsx} +10 -2
  352. package/src/Activity/CarouselFilmStrip.js +20 -29
  353. package/src/Activity/CarouselFilmStripAttachment.js +92 -0
  354. package/src/Activity/{Speak.js → Speak.tsx} +12 -5
  355. package/src/Activity/{StackedLayout.js → StackedLayout.tsx} +36 -11
  356. package/src/Attachment/Assets/DownloadIcon.js +8 -1
  357. package/src/Attachment/{AudioContent.js → AudioContent.tsx} +12 -3
  358. package/src/Attachment/{FileContent.js → FileContent.tsx} +10 -7
  359. package/src/Attachment/{HTMLVideoContent.js → HTMLVideoContent.tsx} +10 -2
  360. package/src/Attachment/{ImageContent.js → ImageContent.tsx} +7 -2
  361. package/src/Attachment/{TextContent.js → TextContent.tsx} +14 -7
  362. package/src/Attachment/{VideoContent.js → VideoContent.tsx} +10 -2
  363. package/src/Attachment/{VimeoContent.js → VimeoContent.tsx} +15 -8
  364. package/src/Attachment/{YouTubeContent.js → YouTubeContent.tsx} +12 -5
  365. package/src/{BasicSendBox.js → BasicSendBox.tsx} +9 -5
  366. package/src/BasicToaster.js +4 -4
  367. package/src/BasicTranscript.js +114 -98
  368. package/src/{BasicTypingIndicator.js → BasicTypingIndicator.tsx} +1 -1
  369. package/src/{BasicWebChat.js → BasicWebChat.tsx} +13 -4
  370. package/src/{Composer.js → Composer.tsx} +41 -42
  371. package/src/Dictation.js +13 -4
  372. package/src/{ErrorBox.js → ErrorBox.tsx} +7 -2
  373. package/src/Middleware/Activity/{createCoreMiddleware.js → createCoreMiddleware.tsx} +2 -1
  374. package/src/Middleware/ActivityStatus/SendStatus/{SendStatus.js → SendStatus.tsx} +8 -3
  375. package/src/Middleware/ActivityStatus/{Timestamp.js → Timestamp.tsx} +8 -2
  376. package/src/Middleware/ActivityStatus/{createCoreMiddleware.js → createCoreMiddleware.tsx} +3 -1
  377. package/src/Middleware/ActivityStatus/createSendStatusMiddleware.js +8 -6
  378. package/src/Middleware/ActivityStatus/createTimestampMiddleware.js +10 -8
  379. package/src/Middleware/Attachment/{createCoreMiddleware.js → createCoreMiddleware.tsx} +8 -7
  380. package/src/Middleware/AttachmentForScreenReader/{createCoreMiddleware.js → createCoreMiddleware.tsx} +4 -3
  381. package/src/Middleware/Avatar/{createCoreMiddleware.js → createCoreMiddleware.tsx} +10 -3
  382. package/src/Middleware/CardAction/createCoreMiddleware.js +43 -41
  383. package/src/Middleware/GroupActivities/createCoreMiddleware.js +6 -4
  384. package/src/Middleware/ScrollToEndButton/ScrollToEndButton.js +45 -0
  385. package/src/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.ts +17 -0
  386. package/src/Middleware/Toast/{createCoreMiddleware.js → createCoreMiddleware.tsx} +3 -1
  387. package/src/Middleware/TypingIndicator/{createCoreMiddleware.js → createCoreMiddleware.tsx} +3 -4
  388. package/src/{ReactWebChat.js → ReactWebChat.tsx} +25 -7
  389. package/src/ScreenReaderActivity.js +47 -37
  390. package/src/SendBox/Assets/AttachmentIcon.js +1 -1
  391. package/src/SendBox/Assets/MicrophoneIcon.js +1 -1
  392. package/src/SendBox/{AutoResizeTextArea.js → AutoResizeTextArea.tsx} +30 -4
  393. package/src/SendBox/{DictationInterims.js → DictationInterims.tsx} +6 -2
  394. package/src/SendBox/{MicrophoneButton.js → MicrophoneButton.tsx} +35 -25
  395. package/src/SendBox/{SendButton.js → SendButton.tsx} +8 -3
  396. package/src/SendBox/SuggestedAction.js +1 -15
  397. package/src/SendBox/{SuggestedActions.js → SuggestedActions.tsx} +42 -21
  398. package/src/SendBox/{TextBox.js → TextBox.tsx} +21 -7
  399. package/src/SendBox/{UploadButton.js → UploadButton.tsx} +7 -3
  400. package/src/Styles/StyleSet/CarouselFilmStrip.ts +0 -20
  401. package/src/Styles/StyleSet/CarouselFilmStripAttachment.ts +56 -0
  402. package/src/Styles/StyleSet/ScrollToEndButton.ts +33 -31
  403. package/src/Styles/StyleSet/SuggestedAction.ts +1 -1
  404. package/src/Styles/createStyleSet.ts +41 -39
  405. package/src/Toast/CollapseIcon.js +9 -1
  406. package/src/Toast/DismissIcon.js +9 -1
  407. package/src/Toast/ExpandIcon.js +9 -1
  408. package/src/Toast/{createToastMiddleware.js → createToastMiddleware.tsx} +3 -2
  409. package/src/Utils/{AccessibleInputText.js → AccessibleInputText.tsx} +48 -5
  410. package/src/Utils/{AccessibleTextArea.js → AccessibleTextArea.tsx} +67 -6
  411. package/src/Utils/TypeFocusSink/FocusBox.js +4 -4
  412. package/src/Utils/TypeFocusSink/getTabIndex.ts +1 -1
  413. package/src/Utils/activityAltText.ts +135 -0
  414. package/src/Utils/findLastIndex.spec.js +2 -0
  415. package/src/Utils/intersectionOf.spec.js +2 -0
  416. package/src/Utils/mapMap.spec.js +2 -0
  417. package/src/Utils/removeInline.spec.js +2 -0
  418. package/src/Utils/{singleToArray.js → singleToArray.ts} +1 -1
  419. package/src/Utils/walkMarkdownTokens.spec.js +3 -3
  420. package/src/hooks/{index.js → index.ts} +1 -0
  421. package/src/hooks/internal/BypassSpeechSynthesisPonyfill.js +68 -17
  422. package/src/hooks/internal/useMemoize.spec.js +2 -0
  423. package/src/hooks/internal/useResumeAudioContext.ts +7 -0
  424. package/src/hooks/internal/useScrollRelative.js +4 -3
  425. package/src/hooks/internal/{useUniqueId.js → useUniqueId.ts} +1 -1
  426. package/src/hooks/{useDictateAbortable.js → useDictateAbortable.ts} +1 -1
  427. package/src/hooks/{useFocus.js → useFocus.ts} +1 -1
  428. package/src/hooks/{useFocusSendBox.js → useFocusSendBox.ts} +2 -1
  429. package/src/hooks/{useObserveScrollPosition.js → useObserveScrollPosition.ts} +6 -1
  430. package/src/hooks/{useObserveTranscriptFocus.js → useObserveTranscriptFocus.ts} +6 -1
  431. package/src/hooks/{useRenderMarkdownAsHTML.js → useRenderMarkdownAsHTML.ts} +6 -2
  432. package/src/hooks/{useScrollDown.js → useScrollDown.ts} +1 -1
  433. package/src/hooks/{useScrollTo.js → useScrollTo.ts} +5 -1
  434. package/src/hooks/{useScrollToEnd.js → useScrollToEnd.ts} +1 -1
  435. package/src/hooks/{useScrollUp.js → useScrollUp.ts} +1 -1
  436. package/src/hooks/{useSendFiles.js → useSendFiles.ts} +3 -2
  437. package/src/hooks/{useStyleSet.js → useStyleSet.ts} +1 -1
  438. package/src/hooks/useWebSpeechPonyfill.ts +7 -0
  439. package/src/index.ts +7 -11
  440. package/src/tsconfig.json +1 -1
  441. package/src/types/ScrollPosition.ts +6 -0
  442. package/lib/Activity/ScrollToEndButton.js +0 -81
  443. package/lib/Attachment/Assets/ErrorIcon.js +0 -22
  444. package/lib/Utils/remarkStripMarkdown.js +0 -26
  445. package/lib/hooks/internal/useStripMarkdown.js +0 -19
  446. package/src/Activity/ScrollToEndButton.js +0 -58
  447. package/src/Attachment/Assets/ErrorIcon.js +0 -9
  448. package/src/Utils/remarkStripMarkdown.js +0 -13
  449. package/src/hooks/internal/useStripMarkdown.js +0 -7
  450. package/src/hooks/useWebSpeechPonyfill.js +0 -5
  451. package/src/index.tsx +0 -35
@@ -0,0 +1,135 @@
1
+ import textFormatToContentType from './textFormatToContentType';
2
+
3
+ function walk<T extends Node>(document: Document, walker: (node: T) => string[]): string[] {
4
+ const nodes: T[] = [].slice.call(document.childNodes);
5
+ const results: string[] = [];
6
+
7
+ while (nodes.length) {
8
+ const node = nodes.shift();
9
+ const { childNodes } = node;
10
+
11
+ results.push(...(walker(node) || []));
12
+ nodes.unshift(...[].slice.call(childNodes));
13
+ }
14
+
15
+ return results;
16
+ }
17
+
18
+ // From https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
19
+ const HTML_INLINE_TAGS = [
20
+ 'A',
21
+ 'ABBR',
22
+ 'ACRONYM',
23
+ 'AUDIO',
24
+ 'B',
25
+ 'BDI',
26
+ 'BDO',
27
+ 'BIG',
28
+ 'BR',
29
+ 'BUTTON',
30
+ 'CANVAS',
31
+ 'CITE',
32
+ 'CODE',
33
+ 'DATA',
34
+ 'DATALIST',
35
+ 'DEL',
36
+ 'DFN',
37
+ 'EM',
38
+ 'EMBED',
39
+ 'I',
40
+ 'IFRAME',
41
+ 'IMG',
42
+ 'INPUT',
43
+ 'INS',
44
+ 'KBD',
45
+ 'LABEL',
46
+ 'MAP',
47
+ 'MARK',
48
+ 'METER',
49
+ 'NOSCRIPT',
50
+ 'OBJECT',
51
+ 'OUTPUT',
52
+ 'PICTURE',
53
+ 'PROGRESS',
54
+ 'Q',
55
+ 'RUBY',
56
+ 'S',
57
+ 'SAMP',
58
+ 'SCRIPT',
59
+ 'SELECT',
60
+ 'SLOT',
61
+ 'SMALL',
62
+ 'SPAN',
63
+ 'STRONG',
64
+ 'SUB',
65
+ 'SUP',
66
+ 'SVG',
67
+ 'TEMPLATE',
68
+ 'TEXTAREA',
69
+ 'TIME',
70
+ 'U',
71
+ 'TT',
72
+ 'VAR',
73
+ 'VIDEO',
74
+ 'WBR'
75
+ ];
76
+
77
+ /**
78
+ * Computes all text from a given HTML document as flattened array. This is best-effort.
79
+ *
80
+ * @param {Document} document - HTML document to computes texts from.
81
+ */
82
+ function htmlTextAlternatives(document: Document): string[] {
83
+ // TODO: [P2] #3923 Revisit this logic with W3C standard, we could do a better text alternatives computation.
84
+ // For example, <abbr title="..."> is not computed.
85
+ // https://www.w3.org/TR/accname-1.1/#mapping_additional_nd_name
86
+ return walk<HTMLElement>(document, node => {
87
+ const { nodeType, tagName, textContent } = node;
88
+
89
+ if (nodeType === Node.TEXT_NODE) {
90
+ return [textContent];
91
+ } else if (tagName === 'IMG') {
92
+ return [node.getAttribute('alt')];
93
+ } else if (!HTML_INLINE_TAGS.includes(tagName)) {
94
+ return ['\n'];
95
+ }
96
+ });
97
+ }
98
+
99
+ /**
100
+ * Returns the text alternatives for a message activity.
101
+ *
102
+ * @param {object} activity - Activity to compute the text alternatives.
103
+ * @param {function} renderMarkdownAsHTML - Callback function to render Markdown as HTML string.
104
+ */
105
+ export default function activityAltText(
106
+ activity: any,
107
+ renderMarkdownAsHTML?: (markdown: string) => string
108
+ ): false | string {
109
+ if (activity.type !== 'message') {
110
+ return false;
111
+ }
112
+
113
+ const fallbackText = activity?.channelData?.['webchat:fallback-text'];
114
+
115
+ if (typeof fallbackText === 'string') {
116
+ // If `fallbackText` is an empty string, we will treat the activity as presentational and skip narrating it (return false).
117
+ return fallbackText || false;
118
+ }
119
+
120
+ const text = activity?.channelData?.messageBack?.displayText || activity.text;
121
+
122
+ if (!text) {
123
+ // We will continue to narrate the activity, as empty.
124
+ return '';
125
+ }
126
+
127
+ if (renderMarkdownAsHTML && textFormatToContentType(activity.textFormat) === 'text/markdown') {
128
+ return htmlTextAlternatives(new DOMParser().parseFromString(renderMarkdownAsHTML(text), 'text/html'))
129
+ .join('')
130
+ .replace(/\n{2,}/gu, '\n')
131
+ .trim();
132
+ }
133
+
134
+ return text;
135
+ }
@@ -1,3 +1,5 @@
1
+ /* eslint no-magic-numbers: "off" */
2
+
1
3
  import findLastIndex from './findLastIndex';
2
4
 
3
5
  describe('find last index', () => {
@@ -1,3 +1,5 @@
1
+ /* eslint no-magic-numbers: "off" */
2
+
1
3
  import intersectionOf from './intersectionOf';
2
4
 
3
5
  test('intersection of [1, 2, 3] and [3, 4, 5] should return [3]', () => {
@@ -1,3 +1,5 @@
1
+ /* eslint no-magic-numbers: "off" */
2
+
1
3
  import mapMap from './mapMap';
2
4
 
3
5
  test('multiple a map by 10', () => {
@@ -1,3 +1,5 @@
1
+ /* eslint no-magic-numbers: "off" */
2
+
1
3
  import removeInline from './removeInline';
2
4
 
3
5
  test('remove single occurrence', () => {
@@ -1,3 +1,3 @@
1
- export default function singleToArray(singleOrArray) {
1
+ export default function singleToArray<T>(singleOrArray: T | T[]): T[] {
2
2
  return singleOrArray ? (Array.isArray(singleOrArray) ? singleOrArray : [singleOrArray]) : [];
3
3
  }
@@ -6,9 +6,9 @@ import walkMarkdownTokens from './walkMarkdownTokens';
6
6
  test('walk every node and add class="markdown"', () => {
7
7
  const markdownIt = new MarkdownIt();
8
8
  const tree = markdownIt.parse('Hello, [World](#world)!');
9
- const patchedTree = walkMarkdownTokens(tree, token => {
10
- return updateIn(token, ['attrs'], attrs => [...(attrs || []), ['class', 'markdown']]);
11
- });
9
+ const patchedTree = walkMarkdownTokens(tree, token =>
10
+ updateIn(token, ['attrs'], attrs => [...(attrs || []), ['class', 'markdown']])
11
+ );
12
12
  const actual = markdownIt.renderer.render(patchedTree);
13
13
 
14
14
  expect(actual).toMatchInlineSnapshot(`
@@ -20,6 +20,7 @@ import { useTypingIndicatorVisible } from '../BasicTypingIndicator';
20
20
  export {
21
21
  useDictateAbortable,
22
22
  useFocus,
23
+ /** @deprecated Please use `useFocus('sendBox')` instead. */
23
24
  useFocusSendBox,
24
25
  useMicrophoneButtonClick,
25
26
  useMicrophoneButtonDisabled,
@@ -6,11 +6,12 @@
6
6
  /* eslint max-classes-per-file: ["error", 4] */
7
7
  /* eslint no-empty-function: "off" */
8
8
 
9
- import EventTarget, { defineEventAttribute } from 'event-target-shim-es5';
9
+ import EventTarget, { Event, getEventAttributeValue, setEventAttributeValue } from 'event-target-shim/es5';
10
10
 
11
- class SpeechSynthesisEvent {
11
+ class SpeechSynthesisEvent extends Event {
12
12
  constructor(type, utterance) {
13
- this._type = type;
13
+ super(type);
14
+
14
15
  this._utterance = utterance;
15
16
  }
16
17
 
@@ -24,10 +25,6 @@ class SpeechSynthesisEvent {
24
25
 
25
26
  get name() {}
26
27
 
27
- get type() {
28
- return this._type;
29
- }
30
-
31
28
  get utterance() {
32
29
  return this._utterance;
33
30
  }
@@ -92,15 +89,63 @@ class SpeechSynthesisUtterance extends EventTarget {
92
89
  set volume(value) {
93
90
  this._volume = value;
94
91
  }
95
- }
96
92
 
97
- defineEventAttribute(SpeechSynthesisUtterance.prototype, 'boundary');
98
- defineEventAttribute(SpeechSynthesisUtterance.prototype, 'end');
99
- defineEventAttribute(SpeechSynthesisUtterance.prototype, 'error');
100
- defineEventAttribute(SpeechSynthesisUtterance.prototype, 'mark');
101
- defineEventAttribute(SpeechSynthesisUtterance.prototype, 'pause');
102
- defineEventAttribute(SpeechSynthesisUtterance.prototype, 'resume');
103
- defineEventAttribute(SpeechSynthesisUtterance.prototype, 'start');
93
+ get onboundary() {
94
+ return getEventAttributeValue(this, 'boundary');
95
+ }
96
+
97
+ set onboundary(value) {
98
+ setEventAttributeValue(this, 'boundary', value);
99
+ }
100
+
101
+ get onend() {
102
+ return getEventAttributeValue(this, 'end');
103
+ }
104
+
105
+ set onend(value) {
106
+ setEventAttributeValue(this, 'end', value);
107
+ }
108
+
109
+ get onerror() {
110
+ return getEventAttributeValue(this, 'error');
111
+ }
112
+
113
+ set onerror(value) {
114
+ setEventAttributeValue(this, 'error', value);
115
+ }
116
+
117
+ get onmark() {
118
+ return getEventAttributeValue(this, 'mark');
119
+ }
120
+
121
+ set onmark(value) {
122
+ setEventAttributeValue(this, 'mark', value);
123
+ }
124
+
125
+ get onpause() {
126
+ return getEventAttributeValue(this, 'pause');
127
+ }
128
+
129
+ set onpause(value) {
130
+ setEventAttributeValue(this, 'pause', value);
131
+ }
132
+
133
+ get onresume() {
134
+ return getEventAttributeValue(this, 'resume');
135
+ }
136
+
137
+ set onresume(value) {
138
+ setEventAttributeValue(this, 'resume', value);
139
+ }
140
+
141
+ get onstart() {
142
+ return getEventAttributeValue(this, 'start');
143
+ }
144
+
145
+ set onstart(value) {
146
+ setEventAttributeValue(this, 'start', value);
147
+ }
148
+ }
104
149
 
105
150
  class SpeechSynthesisVoice {
106
151
  get default() {
@@ -155,9 +200,15 @@ class SpeechSynthesis extends EventTarget {
155
200
  utterance.dispatchEvent(new SpeechSynthesisEvent('start', utterance));
156
201
  utterance.dispatchEvent(new SpeechSynthesisEvent('end', utterance));
157
202
  }
158
- }
159
203
 
160
- defineEventAttribute(SpeechSynthesis.prototype, 'voiceschanged');
204
+ get onvoiceschanged() {
205
+ return getEventAttributeValue(this, 'voiceschanged');
206
+ }
207
+
208
+ set onvoiceschanged(value) {
209
+ setEventAttributeValue(this, 'voiceschanged', value);
210
+ }
211
+ }
161
212
 
162
213
  const speechSynthesis = new SpeechSynthesis();
163
214
 
@@ -1,3 +1,5 @@
1
+ /* eslint no-magic-numbers: "off" */
2
+
1
3
  import useMemoize from './useMemoize';
2
4
 
3
5
  jest.mock('react', () => {
@@ -0,0 +1,7 @@
1
+ import useWebSpeechPonyfill from '../useWebSpeechPonyfill';
2
+
3
+ export default function useResumeAudioContext(): () => Promise<void> {
4
+ const [{ resumeAudioContext }] = useWebSpeechPonyfill();
5
+
6
+ return () => resumeAudioContext && resumeAudioContext();
7
+ }
@@ -5,7 +5,8 @@ import useWebChatUIContext from './useWebChatUIContext';
5
5
  export default function useScrollRelative() {
6
6
  const { scrollRelativeCallbacksRef } = useWebChatUIContext();
7
7
 
8
- return useCallback((...args) => scrollRelativeCallbacksRef.current.forEach(callback => callback(...args)), [
9
- scrollRelativeCallbacksRef
10
- ]);
8
+ return useCallback(
9
+ (...args) => scrollRelativeCallbacksRef.current.forEach(callback => callback(...args)),
10
+ [scrollRelativeCallbacksRef]
11
+ );
11
12
  }
@@ -3,7 +3,7 @@
3
3
  import { useMemo } from 'react';
4
4
  import random from 'math-random';
5
5
 
6
- export default function useUniqueId(prefix) {
6
+ export default function useUniqueId(prefix?: string): string {
7
7
  const id = useMemo(() => random().toString(36).substr(2, 5), []);
8
8
 
9
9
  prefix = prefix ? `${prefix}--` : '';
@@ -1,6 +1,6 @@
1
1
  import useSettableDictateAbortable from './internal/useSettableDictateAbortable';
2
2
 
3
- export default function useDictateAbortable() {
3
+ export default function useDictateAbortable(): [boolean] {
4
4
  // We are only exporting a read-only version of dictateAbortable.
5
5
  const [dictateAbortable] = useSettableDictateAbortable();
6
6
 
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
2
2
 
3
3
  import useWebChatUIContext from './internal/useWebChatUIContext';
4
4
 
5
- export default function useFocus() {
5
+ export default function useFocus(): (where?: 'sendBox' | 'sendBoxWithoutKeyboard') => void {
6
6
  const { focusSendBoxCallbacksRef, focusTranscriptCallbacksRef } = useWebChatUIContext();
7
7
 
8
8
  return useCallback(
@@ -2,7 +2,8 @@ import useFocus from './useFocus';
2
2
 
3
3
  let showDeprecationNotes = true;
4
4
 
5
- export default function useFocusSendBox() {
5
+ /** @deprecated Please use `useFocus('sendBox')` instead. */
6
+ export default function useFocusSendBox(): () => void {
6
7
  if (showDeprecationNotes) {
7
8
  console.warn(
8
9
  'botframework-webchat: "useFocusSendBox" is deprecated and will be removed on or after 2022-04-21. Please use "useFocus(\'sendBox\')" instead.'
@@ -1,7 +1,12 @@
1
1
  import { useEffect } from 'react';
2
+
3
+ import ScrollPosition from '../types/ScrollPosition';
2
4
  import useWebChatUIContext from './internal/useWebChatUIContext';
3
5
 
4
- export default function useObserveScrollPosition(observer, deps) {
6
+ export default function useObserveScrollPosition(
7
+ observer: (scrollPosition: ScrollPosition) => void,
8
+ deps: any[]
9
+ ): void {
5
10
  if (typeof observer !== 'function') {
6
11
  observer = undefined;
7
12
  console.warn('botframework-webchat: First argument passed to "useObserveScrollPosition" must be a function.');
@@ -1,7 +1,12 @@
1
+ import { DirectLineActivity } from 'botframework-webchat-core';
1
2
  import { useEffect } from 'react';
3
+
2
4
  import useWebChatUIContext from './internal/useWebChatUIContext';
3
5
 
4
- export default function useObserveTranscriptFocus(observer, deps) {
6
+ export default function useObserveTranscriptFocus(
7
+ observer: (event: { activity: DirectLineActivity }) => void,
8
+ deps: any[]
9
+ ): void {
5
10
  if (typeof observer !== 'function') {
6
11
  observer = undefined;
7
12
  console.warn('botframework-webchat: First argument passed to "useObserveTranscriptFocus" must be a function.');
@@ -1,11 +1,15 @@
1
- import { hooks } from 'botframework-webchat-api';
1
+ import { hooks, StrictStyleOptions } from 'botframework-webchat-api';
2
2
  import { useMemo } from 'react';
3
3
 
4
4
  import useWebChatUIContext from './internal/useWebChatUIContext';
5
5
 
6
6
  const { useLocalizer, useStyleOptions } = hooks;
7
7
 
8
- export default function useRenderMarkdownAsHTML() {
8
+ export default function useRenderMarkdownAsHTML(): (
9
+ markdown: string,
10
+ styleOptions?: StrictStyleOptions,
11
+ options?: { externalLinkAlt: string }
12
+ ) => string {
9
13
  const { renderMarkdown } = useWebChatUIContext();
10
14
  const [styleOptions] = useStyleOptions();
11
15
  const localize = useLocalizer();
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
2
2
 
3
3
  import useScrollRelative from './internal/useScrollRelative';
4
4
 
5
- export default function useScrollDown() {
5
+ export default function useScrollDown(): (options?: { displacement: number }) => void {
6
6
  const scrollRelative = useScrollRelative();
7
7
 
8
8
  return useCallback((...args) => scrollRelative('down', ...args), [scrollRelative]);
@@ -1,8 +1,12 @@
1
1
  import { useCallback } from 'react';
2
2
 
3
+ import ScrollPosition from '../types/ScrollPosition';
3
4
  import useWebChatUIContext from './internal/useWebChatUIContext';
4
5
 
5
- export default function useScrollTo() {
6
+ export default function useScrollTo(): (
7
+ position: ScrollPosition,
8
+ scrollToOptions: { behavior?: 'auto' | 'smooth' }
9
+ ) => void {
6
10
  const { scrollToCallbacksRef } = useWebChatUIContext();
7
11
 
8
12
  return useCallback((...args) => scrollToCallbacksRef.current.forEach(callback => callback(...args)), [
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
2
2
 
3
3
  import useWebChatUIContext from './internal/useWebChatUIContext';
4
4
 
5
- export default function useScrollToEnd() {
5
+ export default function useScrollToEnd(): () => void {
6
6
  const { scrollToEndCallbacksRef } = useWebChatUIContext();
7
7
 
8
8
  return useCallback(() => scrollToEndCallbacksRef.current.forEach(callback => callback({ behavior: 'smooth' })), [
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
2
2
 
3
3
  import useScrollRelative from './internal/useScrollRelative';
4
4
 
5
- export default function useScrollUp() {
5
+ export default function useScrollUp(): (options?: { displacement: number }) => void {
6
6
  const scrollRelative = useScrollRelative();
7
7
 
8
8
  return useCallback((...args) => scrollRelative('up', ...args), [scrollRelative]);
@@ -1,5 +1,6 @@
1
1
  /* eslint no-magic-numbers: ["error", { "ignore": [0, 1024] }] */
2
2
 
3
+ import { DirectLineAttachment } from 'botframework-webchat-core';
3
4
  import { hooks } from 'botframework-webchat-api';
4
5
  import { useCallback } from 'react';
5
6
 
@@ -19,7 +20,7 @@ async function makeThumbnail(file, width, height, contentType, quality) {
19
20
  }
20
21
  }
21
22
 
22
- export default function useSendFiles() {
23
+ export default function useSendFiles(): (files: File[]) => void {
23
24
  const sendFiles = useAPISendFiles();
24
25
  const [
25
26
  {
@@ -40,7 +41,7 @@ export default function useSendFiles() {
40
41
  // TODO: [P3] We need to find revokeObjectURL on the UI side
41
42
  // Redux store should not know about the browser environment
42
43
  // One fix is to use ArrayBuffer instead of object URL, but that would requires change to DirectLineJS
43
- const attachments = await Promise.all(
44
+ const attachments: DirectLineAttachment[] = await Promise.all(
44
45
  [].map.call(files, async file => {
45
46
  let thumbnail;
46
47
 
@@ -1,5 +1,5 @@
1
1
  import useWebChatUIContext from './internal/useWebChatUIContext';
2
2
 
3
- export default function useStyleSet() {
3
+ export default function useStyleSet(): [any] {
4
4
  return [useWebChatUIContext().styleSet];
5
5
  }
@@ -0,0 +1,7 @@
1
+ import { WebSpeechPonyfill } from 'botframework-webchat-api';
2
+
3
+ import useWebChatUIContext from './internal/useWebChatUIContext';
4
+
5
+ export default function useWebSpeechPonyfill(): [WebSpeechPonyfill] {
6
+ return [useWebChatUIContext().webSpeechPonyfill];
7
+ }
package/src/index.ts CHANGED
@@ -1,8 +1,10 @@
1
- import ReactWebChat from './ReactWebChat';
1
+ import { concatMiddleware, hooks as apiHooks, Localize, localize } from 'botframework-webchat-api';
2
+
3
+ import ReactWebChat, { ReactWebChatProps } from './ReactWebChat';
2
4
 
3
- import Composer from './Composer';
5
+ import Composer, { ComposerProps } from './Composer';
4
6
 
5
- import BasicWebChat from './BasicWebChat';
7
+ import BasicWebChat, { BasicWebChatProps } from './BasicWebChat';
6
8
 
7
9
  import Avatar from './Activity/Avatar';
8
10
  import Bubble from './Activity/Bubble';
@@ -35,14 +37,6 @@ import createCoreAttachmentMiddleware from './Middleware/Attachment/createCoreMi
35
37
  import createStyleSet from './Styles/createStyleSet';
36
38
  import getTabIndex from './Utils/TypeFocusSink/getTabIndex';
37
39
 
38
- declare module 'botframework-webchat-api' {
39
- export function concatMiddleware(): any;
40
- export const hooks: any;
41
- export function Localize(): any;
42
- export function localize(): any;
43
- }
44
-
45
- import { concatMiddleware, hooks as apiHooks, Localize, localize } from 'botframework-webchat-api';
46
40
  import * as componentHooks from './hooks/index';
47
41
 
48
42
  const hooks = {
@@ -111,3 +105,5 @@ export {
111
105
  localize,
112
106
  version
113
107
  };
108
+
109
+ export type { BasicWebChatProps, ComposerProps, ReactWebChatProps };
package/src/tsconfig.json CHANGED
@@ -11,5 +11,5 @@
11
11
  "skipLibCheck": true,
12
12
  "sourceMap": true
13
13
  },
14
- "files": ["index.tsx"]
14
+ "files": ["index.ts"]
15
15
  }
@@ -0,0 +1,6 @@
1
+ type ScrollPosition = {
2
+ activityID?: string;
3
+ scrollTop: number;
4
+ };
5
+
6
+ export default ScrollPosition;
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _botframeworkWebchatApi = require("botframework-webchat-api");
11
-
12
- var _classnames = _interopRequireDefault(require("classnames"));
13
-
14
- var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
- var _react = _interopRequireWildcard(require("react"));
17
-
18
- var _useScrollToEnd = _interopRequireDefault(require("../hooks/useScrollToEnd"));
19
-
20
- var _useStyleSet3 = _interopRequireDefault(require("../hooks/useStyleSet"));
21
-
22
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
23
-
24
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
29
-
30
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
31
-
32
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
33
-
34
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
35
-
36
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
37
-
38
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39
-
40
- var useDirection = _botframeworkWebchatApi.hooks.useDirection,
41
- useLocalizer = _botframeworkWebchatApi.hooks.useLocalizer;
42
- var ScrollToEndButton = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
43
- var className = _ref.className,
44
- onClick = _ref.onClick;
45
-
46
- var _useStyleSet = (0, _useStyleSet3.default)(),
47
- _useStyleSet2 = _slicedToArray(_useStyleSet, 1),
48
- scrollToEndButtonStyleSet = _useStyleSet2[0].scrollToEndButton;
49
-
50
- var _useDirection = useDirection(),
51
- _useDirection2 = _slicedToArray(_useDirection, 1),
52
- direction = _useDirection2[0];
53
-
54
- var localize = useLocalizer();
55
- var scrollToEnd = (0, _useScrollToEnd.default)();
56
- var handleClick = (0, _react.useCallback)(function (event) {
57
- onClick && onClick(event);
58
- scrollToEnd();
59
- }, [onClick, scrollToEnd]);
60
- var newMessageText = localize('TRANSCRIPT_NEW_MESSAGES');
61
- return /*#__PURE__*/_react.default.createElement("button", {
62
- "aria-label": newMessageText,
63
- className: (0, _classnames.default)('webchat__scrollToEndButton', scrollToEndButtonStyleSet + '', className + '', direction === 'rtl' ? 'webchat__overlay--rtl' : ''),
64
- onClick: handleClick,
65
- ref: ref,
66
- tabIndex: 0,
67
- type: "button"
68
- }, newMessageText);
69
- });
70
- ScrollToEndButton.defaultProps = {
71
- className: '',
72
- onClick: undefined
73
- };
74
- ScrollToEndButton.displayName = 'ScrollToEndButton';
75
- ScrollToEndButton.propTypes = {
76
- className: _propTypes.default.string,
77
- onClick: _propTypes.default.func
78
- };
79
- var _default = ScrollToEndButton;
80
- exports.default = _default;
81
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9BY3Rpdml0eS9TY3JvbGxUb0VuZEJ1dHRvbi5qcyJdLCJuYW1lcyI6WyJ1c2VEaXJlY3Rpb24iLCJob29rcyIsInVzZUxvY2FsaXplciIsIlNjcm9sbFRvRW5kQnV0dG9uIiwicmVmIiwiY2xhc3NOYW1lIiwib25DbGljayIsInNjcm9sbFRvRW5kQnV0dG9uU3R5bGVTZXQiLCJzY3JvbGxUb0VuZEJ1dHRvbiIsImRpcmVjdGlvbiIsImxvY2FsaXplIiwic2Nyb2xsVG9FbmQiLCJoYW5kbGVDbGljayIsImV2ZW50IiwibmV3TWVzc2FnZVRleHQiLCJkZWZhdWx0UHJvcHMiLCJ1bmRlZmluZWQiLCJkaXNwbGF5TmFtZSIsInByb3BUeXBlcyIsIlByb3BUeXBlcyIsInN0cmluZyIsImZ1bmMiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUFBOztBQUNBOztBQUNBOztBQUNBOztBQUVBOztBQUNBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7OztJQUVRQSxZLEdBQStCQyw2QixDQUEvQkQsWTtJQUFjRSxZLEdBQWlCRCw2QixDQUFqQkMsWTtBQUV0QixJQUFNQyxpQkFBaUIsZ0JBQUcsdUJBQVcsZ0JBQXlCQyxHQUF6QixFQUFpQztBQUFBLE1BQTlCQyxTQUE4QixRQUE5QkEsU0FBOEI7QUFBQSxNQUFuQkMsT0FBbUIsUUFBbkJBLE9BQW1COztBQUFBLHFCQUNULDRCQURTO0FBQUE7QUFBQSxNQUN4Q0MseUJBRHdDLG9CQUMzREMsaUJBRDJEOztBQUFBLHNCQUVoRFIsWUFBWSxFQUZvQztBQUFBO0FBQUEsTUFFN0RTLFNBRjZEOztBQUdwRSxNQUFNQyxRQUFRLEdBQUdSLFlBQVksRUFBN0I7QUFDQSxNQUFNUyxXQUFXLEdBQUcsOEJBQXBCO0FBRUEsTUFBTUMsV0FBVyxHQUFHLHdCQUNsQixVQUFBQyxLQUFLLEVBQUk7QUFDUFAsSUFBQUEsT0FBTyxJQUFJQSxPQUFPLENBQUNPLEtBQUQsQ0FBbEI7QUFDQUYsSUFBQUEsV0FBVztBQUNaLEdBSmlCLEVBS2xCLENBQUNMLE9BQUQsRUFBVUssV0FBVixDQUxrQixDQUFwQjtBQVFBLE1BQU1HLGNBQWMsR0FBR0osUUFBUSxDQUFDLHlCQUFELENBQS9CO0FBRUEsc0JBQ0U7QUFDRSxrQkFBWUksY0FEZDtBQUVFLElBQUEsU0FBUyxFQUFFLHlCQUNULDRCQURTLEVBRVRQLHlCQUF5QixHQUFHLEVBRm5CLEVBR1RGLFNBQVMsR0FBRyxFQUhILEVBSVRJLFNBQVMsS0FBSyxLQUFkLEdBQXNCLHVCQUF0QixHQUFnRCxFQUp2QyxDQUZiO0FBUUUsSUFBQSxPQUFPLEVBQUVHLFdBUlg7QUFTRSxJQUFBLEdBQUcsRUFBRVIsR0FUUDtBQVVFLElBQUEsUUFBUSxFQUFFLENBVlo7QUFXRSxJQUFBLElBQUksRUFBQztBQVhQLEtBYUdVLGNBYkgsQ0FERjtBQWlCRCxDQWpDeUIsQ0FBMUI7QUFtQ0FYLGlCQUFpQixDQUFDWSxZQUFsQixHQUFpQztBQUMvQlYsRUFBQUEsU0FBUyxFQUFFLEVBRG9CO0FBRS9CQyxFQUFBQSxPQUFPLEVBQUVVO0FBRnNCLENBQWpDO0FBS0FiLGlCQUFpQixDQUFDYyxXQUFsQixHQUFnQyxtQkFBaEM7QUFFQWQsaUJBQWlCLENBQUNlLFNBQWxCLEdBQThCO0FBQzVCYixFQUFBQSxTQUFTLEVBQUVjLG1CQUFVQyxNQURPO0FBRTVCZCxFQUFBQSxPQUFPLEVBQUVhLG1CQUFVRTtBQUZTLENBQTlCO2VBS2VsQixpQiIsInNvdXJjZVJvb3QiOiJjb21wb25lbnQ6Ly8vIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgaG9va3MgfSBmcm9tICdib3RmcmFtZXdvcmstd2ViY2hhdC1hcGknO1xuaW1wb3J0IGNsYXNzTmFtZXMgZnJvbSAnY2xhc3NuYW1lcyc7XG5pbXBvcnQgUHJvcFR5cGVzIGZyb20gJ3Byb3AtdHlwZXMnO1xuaW1wb3J0IFJlYWN0LCB7IGZvcndhcmRSZWYsIHVzZUNhbGxiYWNrIH0gZnJvbSAncmVhY3QnO1xuXG5pbXBvcnQgdXNlU2Nyb2xsVG9FbmQgZnJvbSAnLi4vaG9va3MvdXNlU2Nyb2xsVG9FbmQnO1xuaW1wb3J0IHVzZVN0eWxlU2V0IGZyb20gJy4uL2hvb2tzL3VzZVN0eWxlU2V0JztcblxuY29uc3QgeyB1c2VEaXJlY3Rpb24sIHVzZUxvY2FsaXplciB9ID0gaG9va3M7XG5cbmNvbnN0IFNjcm9sbFRvRW5kQnV0dG9uID0gZm9yd2FyZFJlZigoeyBjbGFzc05hbWUsIG9uQ2xpY2sgfSwgcmVmKSA9PiB7XG4gIGNvbnN0IFt7IHNjcm9sbFRvRW5kQnV0dG9uOiBzY3JvbGxUb0VuZEJ1dHRvblN0eWxlU2V0IH1dID0gdXNlU3R5bGVTZXQoKTtcbiAgY29uc3QgW2RpcmVjdGlvbl0gPSB1c2VEaXJlY3Rpb24oKTtcbiAgY29uc3QgbG9jYWxpemUgPSB1c2VMb2NhbGl6ZXIoKTtcbiAgY29uc3Qgc2Nyb2xsVG9FbmQgPSB1c2VTY3JvbGxUb0VuZCgpO1xuXG4gIGNvbnN0IGhhbmRsZUNsaWNrID0gdXNlQ2FsbGJhY2soXG4gICAgZXZlbnQgPT4ge1xuICAgICAgb25DbGljayAmJiBvbkNsaWNrKGV2ZW50KTtcbiAgICAgIHNjcm9sbFRvRW5kKCk7XG4gICAgfSxcbiAgICBbb25DbGljaywgc2Nyb2xsVG9FbmRdXG4gICk7XG5cbiAgY29uc3QgbmV3TWVzc2FnZVRleHQgPSBsb2NhbGl6ZSgnVFJBTlNDUklQVF9ORVdfTUVTU0FHRVMnKTtcblxuICByZXR1cm4gKFxuICAgIDxidXR0b25cbiAgICAgIGFyaWEtbGFiZWw9e25ld01lc3NhZ2VUZXh0fVxuICAgICAgY2xhc3NOYW1lPXtjbGFzc05hbWVzKFxuICAgICAgICAnd2ViY2hhdF9fc2Nyb2xsVG9FbmRCdXR0b24nLFxuICAgICAgICBzY3JvbGxUb0VuZEJ1dHRvblN0eWxlU2V0ICsgJycsXG4gICAgICAgIGNsYXNzTmFtZSArICcnLFxuICAgICAgICBkaXJlY3Rpb24gPT09ICdydGwnID8gJ3dlYmNoYXRfX292ZXJsYXktLXJ0bCcgOiAnJ1xuICAgICAgKX1cbiAgICAgIG9uQ2xpY2s9e2hhbmRsZUNsaWNrfVxuICAgICAgcmVmPXtyZWZ9XG4gICAgICB0YWJJbmRleD17MH1cbiAgICAgIHR5cGU9XCJidXR0b25cIlxuICAgID5cbiAgICAgIHtuZXdNZXNzYWdlVGV4dH1cbiAgICA8L2J1dHRvbj5cbiAgKTtcbn0pO1xuXG5TY3JvbGxUb0VuZEJ1dHRvbi5kZWZhdWx0UHJvcHMgPSB7XG4gIGNsYXNzTmFtZTogJycsXG4gIG9uQ2xpY2s6IHVuZGVmaW5lZFxufTtcblxuU2Nyb2xsVG9FbmRCdXR0b24uZGlzcGxheU5hbWUgPSAnU2Nyb2xsVG9FbmRCdXR0b24nO1xuXG5TY3JvbGxUb0VuZEJ1dHRvbi5wcm9wVHlwZXMgPSB7XG4gIGNsYXNzTmFtZTogUHJvcFR5cGVzLnN0cmluZyxcbiAgb25DbGljazogUHJvcFR5cGVzLmZ1bmNcbn07XG5cbmV4cG9ydCBkZWZhdWx0IFNjcm9sbFRvRW5kQnV0dG9uO1xuIl19