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
@@ -3,11 +3,11 @@
3
3
  import { hooks } from 'botframework-webchat-api';
4
4
  import classNames from 'classnames';
5
5
  import PropTypes from 'prop-types';
6
- import React from 'react';
6
+ import React, { Fragment, useMemo } from 'react';
7
7
 
8
- import textFormatToContentType from './Utils/textFormatToContentType';
9
- import useStripMarkdown from './hooks/internal/useStripMarkdown';
8
+ import activityAltText from './Utils/activityAltText';
10
9
  import useStyleToEmotionObject from './hooks/internal/useStyleToEmotionObject';
10
+ import useRenderMarkdownAsHTML from './hooks/useRenderMarkdownAsHTML';
11
11
 
12
12
  const { useAvatarForBot, useCreateAttachmentForScreenReaderRenderer, useDateFormatter, useLocalizer } = hooks;
13
13
 
@@ -32,45 +32,63 @@ const ACTIVITY_NUM_ATTACHMENTS_ALT_IDS = {
32
32
  two: 'ACTIVITY_NUM_ATTACHMENTS_TWO_ALT'
33
33
  };
34
34
 
35
+ const ScreenReaderAttachments = ({ activity, renderAttachments }) => {
36
+ const { attachments = [] } = activity;
37
+ const createAttachmentForScreenReaderRenderer = useCreateAttachmentForScreenReaderRenderer();
38
+ const localizeWithPlural = useLocalizer({ plural: true });
39
+
40
+ const attachmentForScreenReaderRenderers = renderAttachments
41
+ ? attachments
42
+ .map(attachment => createAttachmentForScreenReaderRenderer({ activity, attachment }))
43
+ .filter(render => render)
44
+ : [];
45
+
46
+ const numGenericAttachments = attachments.length - attachmentForScreenReaderRenderers.length;
47
+
48
+ const numAttachmentsAlt =
49
+ !!numGenericAttachments && localizeWithPlural(ACTIVITY_NUM_ATTACHMENTS_ALT_IDS, numGenericAttachments);
50
+
51
+ return (
52
+ <Fragment>
53
+ {!!attachmentForScreenReaderRenderers.length && (
54
+ <ul>
55
+ {attachmentForScreenReaderRenderers.map((render, index) => (
56
+ // eslint-disable-next-line react/no-array-index-key
57
+ <li key={index}>{render()}</li>
58
+ ))}
59
+ </ul>
60
+ )}
61
+ {numAttachmentsAlt && <p>{numAttachmentsAlt}</p>}
62
+ </Fragment>
63
+ );
64
+ };
65
+
66
+ ScreenReaderAttachments.propTypes = {
67
+ activity: PropTypes.shape({
68
+ attachments: PropTypes.array
69
+ }).isRequired,
70
+ renderAttachments: PropTypes.bool.isRequired
71
+ };
72
+
35
73
  // When "renderAttachments" is false, we will not render the content of attachments.
36
74
  // That means, it will only render "2 attachments", instead of "image attachment".
37
75
  // This is used in the visual transcript, where we render "Press ENTER to interact."
38
76
  const ScreenReaderActivity = ({ activity, children, id, renderAttachments }) => {
39
77
  const [{ initials: botInitials }] = useAvatarForBot();
40
- const createAttachmentForScreenReaderRenderer = useCreateAttachmentForScreenReaderRenderer();
41
78
  const formatDate = useDateFormatter();
42
79
  const localize = useLocalizer();
43
- const localizeWithPlural = useLocalizer({ plural: true });
80
+ const renderMarkdownAsHTML = useRenderMarkdownAsHTML();
44
81
  const rootClassName = useStyleToEmotionObject()(ROOT_STYLE) + '';
82
+ const textAlt = useMemo(() => activityAltText(activity, renderMarkdownAsHTML), [activity, renderMarkdownAsHTML]);
45
83
 
46
- const {
47
- attachments = [],
48
- channelData: { messageBack: { displayText: messageBackDisplayText } = {} } = {},
49
- from: { role } = {},
50
- text,
51
- textFormat,
52
- timestamp
53
- } = activity;
84
+ const { channelData: { 'webchat:fallback-text': fallbackText } = {}, from: { role } = {}, timestamp } = activity;
54
85
 
55
86
  const fromUser = role === 'user';
56
- const contentTypeMarkdown = textFormatToContentType(textFormat) === 'text/markdown';
57
- const displayText = messageBackDisplayText || text;
58
-
59
- const attachmentForScreenReaderRenderers = renderAttachments
60
- ? attachments
61
- .map(attachment => createAttachmentForScreenReaderRenderer({ activity, attachment }))
62
- .filter(render => render)
63
- : [];
64
87
 
65
- const greetingAlt = (fromUser
66
- ? localize('ACTIVITY_YOU_SAID_ALT')
67
- : localize('ACTIVITY_BOT_SAID_ALT', botInitials || '')
88
+ const greetingAlt = (
89
+ fromUser ? localize('ACTIVITY_YOU_SAID_ALT') : localize('ACTIVITY_BOT_SAID_ALT', botInitials || '')
68
90
  ).replace(/\s{2,}/gu, ' ');
69
- const numGenericAttachments = attachments.length - attachmentForScreenReaderRenderers.length;
70
91
 
71
- const numAttachmentsAlt =
72
- !!numGenericAttachments && localizeWithPlural(ACTIVITY_NUM_ATTACHMENTS_ALT_IDS, numGenericAttachments);
73
- const textAlt = useStripMarkdown(contentTypeMarkdown && displayText) || displayText;
74
92
  const timestampAlt = localize('ACTIVITY_STATUS_SEND_STATUS_ALT_SENT_AT', formatDate(timestamp));
75
93
 
76
94
  return (
@@ -87,15 +105,7 @@ const ScreenReaderActivity = ({ activity, children, id, renderAttachments }) =>
87
105
  <span>{greetingAlt}</span>
88
106
  <span>{textAlt}</span>
89
107
  </p>
90
- {!!attachmentForScreenReaderRenderers.length && (
91
- <ul>
92
- {attachmentForScreenReaderRenderers.map((render, index) => (
93
- // eslint-disable-next-line react/no-array-index-key
94
- <li key={index}>{render()}</li>
95
- ))}
96
- </ul>
97
- )}
98
- {numAttachmentsAlt && <p>{numAttachmentsAlt}</p>}
108
+ {!fallbackText && <ScreenReaderAttachments activity={activity} renderAttachments={renderAttachments} />}
99
109
  <p className="webchat__screen-reader-activity__timestamp">{timestampAlt}</p>
100
110
  {children}
101
111
  </article>
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
3
  const AttachmentIcon = () => (
4
- <svg height={28} viewBox="0 0 25.75 46" width={28}>
4
+ <svg focusable={false} height={28} role="presentation" viewBox="0 0 25.75 46" width={28}>
5
5
  <path
6
6
  clipRule="evenodd"
7
7
  d="M20.75 11.75v21.37a7.69 7.69 0 0 1-.62 3.07 7.95 7.95 0 0 1-4.19 4.19 7.89 7.89 0 0 1-6.13 0 7.95 7.95 0 0 1-4.19-4.19 7.69 7.69 0 0 1-.62-3.07v-22.5a5.27 5.27 0 0 1 .45-2.17 5.69 5.69 0 0 1 3-3 5.48 5.48 0 0 1 4.35 0 5.69 5.69 0 0 1 3 3 5.27 5.27 0 0 1 .45 2.17v22.5a3.41 3.41 0 0 1-.26 1.32 3.31 3.31 0 0 1-1.8 1.8 3.46 3.46 0 0 1-2.63 0 3.31 3.31 0 0 1-1.8-1.8 3.41 3.41 0 0 1-.26-1.32V14h2.25v19.12a1.13 1.13 0 1 0 2.25 0v-22.5a3.4 3.4 0 0 0-.26-1.31 3.31 3.31 0 0 0-1.8-1.8 3.46 3.46 0 0 0-2.63 0 3.31 3.31 0 0 0-1.8 1.8 3.4 3.4 0 0 0-.26 1.31v22.5a5.32 5.32 0 0 0 .45 2.18 5.69 5.69 0 0 0 3 3 5.48 5.48 0 0 0 4.35 0 5.69 5.69 0 0 0 3-3 5.32 5.32 0 0 0 .45-2.18v-21.37z"
@@ -2,7 +2,7 @@ import React from 'react';
2
2
 
3
3
  // eslint-disable-next-line react/prop-types
4
4
  const MicrophoneIcon = ({ className }) => (
5
- <svg className={className} height={28} viewBox="0 0 34.75 46" width={28}>
5
+ <svg className={className} focusable={false} height={28} role="presentation" viewBox="0 0 34.75 46" width={28}>
6
6
  <path
7
7
  className="a"
8
8
  d="M29.75,23v6.36a7,7,0,0,1-.56,2.78,7.16,7.16,0,0,1-3.8,3.8,7,7,0,0,1-2.78.56H18.5v2.25H23V41H11.75v-2.25h4.5V36.5h-4.11a7,7,0,0,1-2.78-.56,7.16,7.16,0,0,1-3.8-3.8,7,7,0,0,1-.56-2.78V23h2.25v6.36a4.72,4.72,0,0,0,.39,1.9,4.78,4.78,0,0,0,2.6,2.6,4.72,4.72,0,0,0,1.9.39h10.47a4.72,4.72,0,0,0,1.9-.39,4.78,4.78,0,0,0,2.6-2.6,4.72,4.72,0,0,0,.39-1.9V23Zm-18,5.62a1.13,1.13,0,0,0,1.13,1.13h9a1.13,1.13,0,0,0,1.12-1.13V8.38a1.13,1.13,0,0,0-1.12-1.13h-9a1.13,1.13,0,0,0-1.13,1.13Zm1.13,3.38a3.41,3.41,0,0,1-1.32-.26,3.31,3.31,0,0,1-1.8-1.8,3.41,3.41,0,0,1-.26-1.32V8.38a3.41,3.41,0,0,1,.26-1.32,3.31,3.31,0,0,1,1.8-1.8,3.41,3.41,0,0,1,1.32-.26h9a3.4,3.4,0,0,1,1.31.26,3.31,3.31,0,0,1,1.8,1.8,3.41,3.41,0,0,1,.26,1.32v20.24a3.41,3.41,0,0,1-.26,1.32,3.31,3.31,0,0,1-1.8,1.8,3.4,3.4,0,0,1-1.31.26Z"
@@ -1,12 +1,38 @@
1
1
  import classNames from 'classnames';
2
2
  import PropTypes from 'prop-types';
3
- import React, { forwardRef } from 'react';
3
+ import React, {
4
+ ChangeEventHandler,
5
+ FocusEventHandler,
6
+ forwardRef,
7
+ KeyboardEventHandler,
8
+ ReactEventHandler
9
+ } from 'react';
4
10
 
5
11
  import AccessibleTextArea from '../Utils/AccessibleTextArea';
6
12
  import useEnterKeyHint from '../hooks/internal/useEnterKeyHint';
7
13
  import useStyleSet from '../hooks/useStyleSet';
8
14
 
9
- const AutoResizeTextArea = forwardRef(
15
+ type AutoResizeTextAreaProps = {
16
+ 'aria-label'?: string;
17
+ className?: string;
18
+ 'data-id'?: string;
19
+ disabled?: boolean;
20
+ enterKeyHint?: string;
21
+ inputMode?: 'text' | 'none' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
22
+ onChange?: ChangeEventHandler<HTMLTextAreaElement>;
23
+ onFocus?: FocusEventHandler<HTMLTextAreaElement>;
24
+ onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;
25
+ onKeyDownCapture?: KeyboardEventHandler<HTMLTextAreaElement>;
26
+ onKeyPress?: KeyboardEventHandler<HTMLTextAreaElement>;
27
+ onSelect?: ReactEventHandler<HTMLTextAreaElement>;
28
+ placeholder?: string;
29
+ readOnly?: boolean;
30
+ rows?: number;
31
+ textAreaClassName?: string;
32
+ value?: string;
33
+ };
34
+
35
+ const AutoResizeTextArea = forwardRef<HTMLTextAreaElement, AutoResizeTextAreaProps>(
10
36
  (
11
37
  {
12
38
  'aria-label': ariaLabel,
@@ -88,7 +114,7 @@ AutoResizeTextArea.propTypes = {
88
114
  'data-id': PropTypes.string,
89
115
  disabled: PropTypes.bool,
90
116
  enterKeyHint: PropTypes.string,
91
- inputMode: PropTypes.string,
117
+ inputMode: PropTypes.oneOf(['text', 'none', 'tel', 'url', 'email', 'numeric', 'decimal', 'search']),
92
118
  onChange: PropTypes.func,
93
119
  onFocus: PropTypes.func,
94
120
  onKeyDown: PropTypes.func,
@@ -97,7 +123,7 @@ AutoResizeTextArea.propTypes = {
97
123
  onSelect: PropTypes.func,
98
124
  placeholder: PropTypes.string,
99
125
  readOnly: PropTypes.bool,
100
- rows: PropTypes.string,
126
+ rows: PropTypes.number,
101
127
  textAreaClassName: PropTypes.string,
102
128
  value: PropTypes.string
103
129
  };
@@ -4,7 +4,7 @@ import { Constants } from 'botframework-webchat-core';
4
4
  import { hooks } from 'botframework-webchat-api';
5
5
  import classNames from 'classnames';
6
6
  import PropTypes from 'prop-types';
7
- import React from 'react';
7
+ import React, { FC } from 'react';
8
8
 
9
9
  import connectToWebChat from '../connectToWebChat';
10
10
  import useStyleSet from '../hooks/useStyleSet';
@@ -31,7 +31,11 @@ const connectDictationInterims = (...selectors) =>
31
31
  ...selectors
32
32
  );
33
33
 
34
- const DictationInterims = ({ className }) => {
34
+ type DictationInterimsProps = {
35
+ className?: string;
36
+ };
37
+
38
+ const DictationInterims: FC<DictationInterimsProps> = ({ className }) => {
35
39
  const [dictateInterims] = useDictateInterims();
36
40
  const [dictateState] = useDictateState();
37
41
  const [{ dictationInterims: dictationInterimsStyleSet }] = useStyleSet();
@@ -6,7 +6,7 @@ import { hooks } from 'botframework-webchat-api';
6
6
  import classNames from 'classnames';
7
7
  import memoize from 'memoize-one';
8
8
  import PropTypes from 'prop-types';
9
- import React, { useCallback, useState } from 'react';
9
+ import React, { FC, useCallback, useState } from 'react';
10
10
 
11
11
  import connectToWebChat from '../connectToWebChat';
12
12
  import IconButton from './IconButton';
@@ -66,38 +66,44 @@ const connectMicrophoneButton = (...selectors) => {
66
66
  startDictate,
67
67
  stopDictate,
68
68
  stopSpeakingActivity,
69
- webSpeechPonyfill: { speechSynthesis, SpeechSynthesisUtterance } = {}
70
- }) => ({
71
- click: () => {
72
- if (dictateState === DictateState.WILL_START) {
73
- stopSpeakingActivity();
74
- } else if (dictateState === DictateState.DICTATING) {
75
- stopDictate();
76
- setSendBox(dictateInterims.join(' '));
77
- } else {
78
- stopSpeakingActivity();
79
- startDictate();
80
- }
81
-
82
- primeSpeechSynthesis(speechSynthesis, SpeechSynthesisUtterance);
83
- },
84
- dictating: dictateState === DictateState.DICTATING,
85
- disabled: disabled || (dictateState === DictateState.STARTING && dictateState === DictateState.STOPPING),
86
- language
87
- }),
69
+ webSpeechPonyfill
70
+ }) => {
71
+ const { speechSynthesis, SpeechSynthesisUtterance } = webSpeechPonyfill || {};
72
+
73
+ return {
74
+ click: () => {
75
+ if (dictateState === DictateState.WILL_START) {
76
+ stopSpeakingActivity();
77
+ } else if (dictateState === DictateState.DICTATING) {
78
+ stopDictate();
79
+ setSendBox(dictateInterims.join(' '));
80
+ } else {
81
+ stopSpeakingActivity();
82
+ startDictate();
83
+ }
84
+
85
+ primeSpeechSynthesis(speechSynthesis, SpeechSynthesisUtterance);
86
+ },
87
+ dictating: dictateState === DictateState.DICTATING,
88
+ disabled: disabled || (dictateState === DictateState.STARTING && dictateState === DictateState.STOPPING),
89
+ language
90
+ };
91
+ },
88
92
  ...selectors
89
93
  );
90
94
  };
91
95
 
92
- const useMicrophoneButtonClick = () => {
96
+ function useMicrophoneButtonClick(): () => void {
93
97
  const [, setSendBox] = useSendBoxValue();
94
98
  const [, setShouldSpeakIncomingActivity] = useShouldSpeakIncomingActivity();
95
- const [{ speechSynthesis, SpeechSynthesisUtterance } = {}] = useWebSpeechPonyfill();
96
99
  const [dictateInterims] = useDictateInterims();
97
100
  const [dictateState] = useDictateState();
101
+ const [webSpeechPonyfill] = useWebSpeechPonyfill();
98
102
  const startDictate = useStartDictate();
99
103
  const stopDictate = useStopDictate();
100
104
 
105
+ const { speechSynthesis, SpeechSynthesisUtterance } = webSpeechPonyfill || {};
106
+
101
107
  const [primeSpeechSynthesis] = useState(() =>
102
108
  memoize((speechSynthesis, SpeechSynthesisUtterance) => {
103
109
  if (speechSynthesis && SpeechSynthesisUtterance) {
@@ -134,9 +140,9 @@ const useMicrophoneButtonClick = () => {
134
140
  startDictate,
135
141
  stopDictate
136
142
  ]);
137
- };
143
+ }
138
144
 
139
- function useMicrophoneButtonDisabled() {
145
+ function useMicrophoneButtonDisabled(): [boolean] {
140
146
  const [abortable] = useDictateAbortable();
141
147
  const [dictateState] = useDictateState();
142
148
  const [disabled] = useDisabled();
@@ -149,7 +155,11 @@ function useMicrophoneButtonDisabled() {
149
155
  ];
150
156
  }
151
157
 
152
- const MicrophoneButton = ({ className }) => {
158
+ type MicrophoneButtonProps = {
159
+ className?: string;
160
+ };
161
+
162
+ const MicrophoneButton: FC<MicrophoneButtonProps> = ({ className }) => {
153
163
  const [{ microphoneButton: microphoneButtonStyleSet }] = useStyleSet();
154
164
  const [dictateState] = useDictateState();
155
165
  const [disabled] = useMicrophoneButtonDisabled();
@@ -1,6 +1,7 @@
1
1
  import { hooks } from 'botframework-webchat-api';
2
+ import classNames from 'classnames';
2
3
  import PropTypes from 'prop-types';
3
- import React, { useCallback } from 'react';
4
+ import React, { FC, useCallback } from 'react';
4
5
 
5
6
  import connectToWebChat from '../connectToWebChat';
6
7
  import IconButton from './IconButton';
@@ -20,7 +21,11 @@ const connectSendButton = (...selectors) =>
20
21
  ...selectors
21
22
  );
22
23
 
23
- const SendButton = ({ className }) => {
24
+ type SendButtonProps = {
25
+ className?: string;
26
+ };
27
+
28
+ const SendButton: FC<SendButtonProps> = ({ className }) => {
24
29
  const [disabled] = useDisabled();
25
30
  const focus = useFocus();
26
31
  const localize = useLocalizer();
@@ -36,7 +41,7 @@ const SendButton = ({ className }) => {
36
41
  return (
37
42
  <IconButton
38
43
  alt={localize('TEXT_INPUT_SEND_BUTTON_ALT')}
39
- className={className}
44
+ className={classNames('webchat__send-button', className)}
40
45
  disabled={disabled}
41
46
  onClick={handleClick}
42
47
  >
@@ -37,18 +37,7 @@ const connectSuggestedAction = (...selectors) =>
37
37
  ...selectors
38
38
  );
39
39
 
40
- const SuggestedAction = ({
41
- 'aria-hidden': ariaHidden,
42
- buttonText,
43
- className,
44
- displayText,
45
- image,
46
- imageAlt,
47
- text,
48
- textClassName,
49
- type,
50
- value
51
- }) => {
40
+ const SuggestedAction = ({ buttonText, className, displayText, image, imageAlt, text, textClassName, type, value }) => {
52
41
  const [_, setSuggestedActions] = useSuggestedActions();
53
42
  const [{ suggestedActionsStackedLayoutButtonTextWrap }] = useStyleOptions();
54
43
  const [{ suggestedAction: suggestedActionStyleSet }] = useStyleSet();
@@ -79,7 +68,6 @@ const SuggestedAction = ({
79
68
 
80
69
  return (
81
70
  <div
82
- aria-hidden={ariaHidden}
83
71
  className={classNames(
84
72
  'webchat__suggested-action',
85
73
  { 'webchat__suggested-action--rtl': direction === 'rtl' },
@@ -115,7 +103,6 @@ const SuggestedAction = ({
115
103
  };
116
104
 
117
105
  SuggestedAction.defaultProps = {
118
- 'aria-hidden': false,
119
106
  className: '',
120
107
  displayText: '',
121
108
  image: '',
@@ -127,7 +114,6 @@ SuggestedAction.defaultProps = {
127
114
  };
128
115
 
129
116
  SuggestedAction.propTypes = {
130
- 'aria-hidden': PropTypes.bool,
131
117
  buttonText: PropTypes.string.isRequired,
132
118
  className: PropTypes.string,
133
119
  displayText: PropTypes.string,
@@ -1,10 +1,11 @@
1
1
  /* eslint react/no-array-index-key: "off" */
2
2
 
3
+ import { DirectLineCardAction } from 'botframework-webchat-core';
3
4
  import { hooks } from 'botframework-webchat-api';
4
5
  import BasicFilm, { createBasicStyleSet as createBasicStyleSetForReactFilm } from 'react-film';
5
6
  import classNames from 'classnames';
6
7
  import PropTypes from 'prop-types';
7
- import React, { useMemo } from 'react';
8
+ import React, { FC, useMemo } from 'react';
8
9
 
9
10
  import connectToWebChat from '../connectToWebChat';
10
11
  import ScreenReaderText from '../ScreenReaderText';
@@ -206,7 +207,12 @@ SuggestedActionStackedContainer.propTypes = {
206
207
  screenReaderText: PropTypes.string.isRequired
207
208
  };
208
209
 
209
- const SuggestedActions = ({ className, suggestedActions = [] }) => {
210
+ type SuggestedActionsProps = {
211
+ className?: string;
212
+ suggestedActions?: DirectLineCardAction[];
213
+ };
214
+
215
+ const SuggestedActions: FC<SuggestedActionsProps> = ({ className, suggestedActions = [] }) => {
210
216
  const [{ suggestedActionLayout, suggestedActionsStackedLayoutButtonTextWrap }] = useStyleOptions();
211
217
  const [accessKey] = useSuggestedActionsAccessKey();
212
218
  const localize = useLocalizer();
@@ -221,25 +227,36 @@ const SuggestedActions = ({ className, suggestedActions = [] }) => {
221
227
  : localize('SUGGESTED_ACTIONS_ALT_NO_CONTENT')
222
228
  );
223
229
 
224
- const children = suggestedActions.map(({ displayText, image, imageAltText, text, title, type, value }, index) => (
225
- <SuggestedAction
226
- ariaHidden={true}
227
- buttonText={suggestedActionText({ displayText, title, type, value })}
228
- className="webchat__suggested-actions__button"
229
- displayText={displayText}
230
- image={image}
231
- imageAlt={imageAltText}
232
- key={index}
233
- text={text}
234
- textClassName={
235
- suggestedActionLayout === 'stacked' && suggestedActionsStackedLayoutButtonTextWrap
236
- ? 'webchat__suggested-actions__button-text-stacked-text-wrap'
237
- : 'webchat__suggested-actions__button-text'
238
- }
239
- type={type}
240
- value={value}
241
- />
242
- ));
230
+ const children = suggestedActions.map((cardAction, index) => {
231
+ const { displayText, image, imageAltText, text, title, type, value } = cardAction as {
232
+ displayText?: string;
233
+ image?: string;
234
+ imageAltText?: string;
235
+ text?: string;
236
+ title?: string;
237
+ type: string;
238
+ value?: { [key: string]: any } | string;
239
+ };
240
+
241
+ return (
242
+ <SuggestedAction
243
+ buttonText={suggestedActionText({ displayText, title, type, value })}
244
+ className="webchat__suggested-actions__button"
245
+ displayText={displayText}
246
+ image={image}
247
+ imageAlt={imageAltText}
248
+ key={index}
249
+ text={text}
250
+ textClassName={
251
+ suggestedActionLayout === 'stacked' && suggestedActionsStackedLayoutButtonTextWrap
252
+ ? 'webchat__suggested-actions__button-text-stacked-text-wrap'
253
+ : 'webchat__suggested-actions__button-text'
254
+ }
255
+ type={type}
256
+ value={value}
257
+ />
258
+ );
259
+ });
243
260
 
244
261
  if (suggestedActionLayout === 'flow') {
245
262
  return (
@@ -268,6 +285,10 @@ SuggestedActions.defaultProps = {
268
285
 
269
286
  SuggestedActions.propTypes = {
270
287
  className: PropTypes.string,
288
+
289
+ // TypeScript class is not mappable to PropTypes.func
290
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
291
+ // @ts-ignore
271
292
  suggestedActions: PropTypes.arrayOf(
272
293
  PropTypes.shape({
273
294
  displayText: PropTypes.string,
@@ -1,8 +1,9 @@
1
1
  import { hooks } from 'botframework-webchat-api';
2
2
  import classNames from 'classnames';
3
3
  import PropTypes from 'prop-types';
4
- import React, { useCallback, useEffect, useRef } from 'react';
4
+ import React, { MutableRefObject, useCallback, useEffect, useRef } from 'react';
5
5
 
6
+ import { ie11 } from '../Utils/detectBrowser';
6
7
  import AccessibleInputText from '../Utils/AccessibleInputText';
7
8
  import AutoResizeTextArea from './AutoResizeTextArea';
8
9
  import connectToWebChat from '../connectToWebChat';
@@ -66,7 +67,7 @@ const connectSendTextBox = (...selectors) =>
66
67
  ...selectors
67
68
  );
68
69
 
69
- function useTextBoxSubmit() {
70
+ function useTextBoxSubmit(): (setFocus?: boolean | 'sendBox') => void {
70
71
  const [sendBoxValue] = useSendBoxValue();
71
72
  const focus = useFocus();
72
73
  const scrollToEnd = useScrollToEnd();
@@ -97,7 +98,13 @@ function useTextBoxSubmit() {
97
98
  );
98
99
  }
99
100
 
100
- function useTextBoxValue() {
101
+ function useTextBoxValue(): [
102
+ string,
103
+ (
104
+ textBoxValue: string,
105
+ options: { selectionEnd: number; selectionStart: number }
106
+ ) => { selectionEnd: number; selectionStart: number; value: string }
107
+ ] {
101
108
  const [value, setValue] = useSendBoxValue();
102
109
  const replaceEmoticon = useReplaceEmoticon();
103
110
  const stopDictate = useStopDictate();
@@ -146,10 +153,14 @@ const TextBox = ({ className }) => {
146
153
  const [{ sendBoxTextWrap }] = useStyleOptions();
147
154
  const [disabled] = useDisabled();
148
155
  const [textBoxValue, setTextBoxValue] = useTextBoxValue();
149
- const inputElementRef = useRef();
156
+ const inputElementRef: MutableRefObject<HTMLInputElement & HTMLTextAreaElement> = useRef();
150
157
  const localize = useLocalizer();
151
158
  const placeCheckpointOnChangeRef = useRef(false);
152
- const prevInputStateRef = useRef();
159
+ const prevInputStateRef: MutableRefObject<{
160
+ selectionEnd: number;
161
+ selectionStart: number;
162
+ value: string;
163
+ }> = useRef();
153
164
  const rootClassName = useStyleToEmotionObject()(ROOT_STYLE) + '';
154
165
  const scrollDown = useScrollDown();
155
166
  const scrollUp = useScrollUp();
@@ -332,7 +343,10 @@ const TextBox = ({ className }) => {
332
343
  const { current } = inputElementRef;
333
344
 
334
345
  if (current) {
335
- if (noKeyboard) {
346
+ // The "disable soft keyboard on mobile devices" logic will not work on IE11. It will cause the <input> to become read-only until next focus.
347
+ // Thus, no mobile devices carry IE11 so we don't need to explicitly disable soft keyboard on IE11.
348
+ // See #3757 for repro and details.
349
+ if (noKeyboard && !ie11) {
336
350
  // To not activate the virtual keyboard while changing focus to an input, we will temporarily set it as read-only and flip it back.
337
351
  // https://stackoverflow.com/questions/7610758/prevent-iphone-default-keyboard-when-focusing-an-input/7610923
338
352
  const readOnly = current.getAttribute('readonly');
@@ -405,7 +419,7 @@ const TextBox = ({ className }) => {
405
419
  placeholder={typeYourMessageString}
406
420
  readOnly={disabled}
407
421
  ref={inputElementRef}
408
- rows="1"
422
+ rows={1}
409
423
  textAreaClassName="webchat__send-box-text-box__html-text-area"
410
424
  value={textBoxValue}
411
425
  />
@@ -1,7 +1,7 @@
1
1
  import { hooks } from 'botframework-webchat-api';
2
2
  import classNames from 'classnames';
3
3
  import PropTypes from 'prop-types';
4
- import React, { useCallback, useRef } from 'react';
4
+ import React, { FC, useCallback, useRef } from 'react';
5
5
 
6
6
  import AttachmentIcon from './Assets/AttachmentIcon';
7
7
  import connectToWebChat from '../connectToWebChat';
@@ -89,10 +89,14 @@ const connectUploadButton = (...selectors) =>
89
89
  ...selectors
90
90
  );
91
91
 
92
- const UploadButton = ({ className }) => {
92
+ type UploadButtonProps = {
93
+ className?: string;
94
+ };
95
+
96
+ const UploadButton: FC<UploadButtonProps> = ({ className }) => {
93
97
  const [{ uploadButton: uploadButtonStyleSet }] = useStyleSet();
94
98
  const [disabled] = useDisabled();
95
- const inputRef = useRef();
99
+ const inputRef = useRef<HTMLInputElement>();
96
100
  const localize = useLocalizer();
97
101
  const rootClassName = useStyleToEmotionObject()(ROOT_STYLE) + '';
98
102
  const sendFiles = useSendFiles();
@@ -6,7 +6,6 @@ import mirrorStyle from '../mirrorStyle';
6
6
  export default function CarouselFilmStrip({
7
7
  avatarSize,
8
8
  bubbleMaxWidth,
9
- bubbleMinWidth,
10
9
  paddingRegular,
11
10
  transitionDuration
12
11
  }: StrictStyleOptions) {
@@ -18,13 +17,6 @@ export default function CarouselFilmStrip({
18
17
  marginBottom: -17
19
18
  },
20
19
 
21
- '& .webchat__carousel-filmstrip__attachment': {
22
- minWidth: bubbleMinWidth,
23
- maxWidth: bubbleMaxWidth,
24
- transitionDuration,
25
- transitionProperty: 'max-width, min-width'
26
- },
27
-
28
20
  '& .webchat__carousel-filmstrip__message': {
29
21
  maxWidth: bubbleMaxWidth,
30
22
  transitionDuration,
@@ -88,17 +80,9 @@ export default function CarouselFilmStrip({
88
80
  marginLeft: -paddingRegular
89
81
  },
90
82
 
91
- '& .webchat__carousel-filmstrip__attachment': {
92
- paddingLeft: paddingRegular
93
- },
94
-
95
83
  '&.webchat__carousel-filmstrip--hide-avatar, &.webchat__carousel-filmstrip--show-avatar': {
96
84
  '& .webchat__carousel-filmstrip__attachments': {
97
85
  marginLeft: -(avatarSize + paddingRegular * 2)
98
- },
99
-
100
- '& .webchat__carousel-filmstrip__attachment:first-child': {
101
- paddingLeft: avatarSize + paddingRegular * 2
102
86
  }
103
87
  },
104
88
 
@@ -106,10 +90,6 @@ export default function CarouselFilmStrip({
106
90
  '&:not(.webchat__carousel-filmstrip--hide-avatar.webchat__carousel-filmstrip--show-avatar)': {
107
91
  '& .webchat__carousel-filmstrip__attachments': {
108
92
  marginLeft: -paddingRegular * 2
109
- },
110
-
111
- '& .webchat__carousel-filmstrip__attachment:first-child': {
112
- paddingLeft: paddingRegular * 2
113
93
  }
114
94
  }
115
95
  }