botframework-webchat-component 4.13.0 → 4.15.0

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 (698) hide show
  1. package/.eslintrc.yml +4 -100
  2. package/.prettierrc.yml +1 -1
  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 +21 -31
  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 +11 -13
  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 +19 -15
  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/FileAttachment.js +2 -2
  25. package/lib/Attachment/FileContent.d.ts +10 -0
  26. package/lib/Attachment/FileContent.d.ts.map +1 -0
  27. package/lib/Attachment/FileContent.js +14 -9
  28. package/lib/Attachment/HTMLVideoContent.d.ts +11 -0
  29. package/lib/Attachment/HTMLVideoContent.d.ts.map +1 -0
  30. package/lib/Attachment/HTMLVideoContent.js +2 -2
  31. package/lib/Attachment/ImageContent.d.ts +8 -0
  32. package/lib/Attachment/ImageContent.d.ts.map +1 -0
  33. package/lib/Attachment/ImageContent.js +2 -2
  34. package/lib/Attachment/TextContent.d.ts +8 -0
  35. package/lib/Attachment/TextContent.d.ts.map +1 -0
  36. package/lib/Attachment/TextContent.js +4 -4
  37. package/lib/Attachment/VideoAttachment.js +2 -2
  38. package/lib/Attachment/VideoContent.d.ts +11 -0
  39. package/lib/Attachment/VideoContent.d.ts.map +1 -0
  40. package/lib/Attachment/VideoContent.js +1 -1
  41. package/lib/Attachment/VimeoContent.d.ts +10 -0
  42. package/lib/Attachment/VimeoContent.d.ts.map +1 -0
  43. package/lib/Attachment/VimeoContent.js +8 -8
  44. package/lib/Attachment/YouTubeContent.d.ts +10 -0
  45. package/lib/Attachment/YouTubeContent.d.ts.map +1 -0
  46. package/lib/Attachment/YouTubeContent.js +5 -5
  47. package/lib/Avatar/ImageAvatar.js +2 -2
  48. package/lib/Avatar/InitialsAvatar.js +2 -2
  49. package/lib/BasicConnectivityStatus.js +2 -2
  50. package/lib/BasicSendBox.d.ts +9 -0
  51. package/lib/BasicSendBox.d.ts.map +1 -0
  52. package/lib/BasicSendBox.js +7 -6
  53. package/lib/BasicToast.js +4 -4
  54. package/lib/BasicToaster.js +8 -5
  55. package/lib/BasicTranscript.d.ts +7 -0
  56. package/lib/BasicTranscript.d.ts.map +1 -0
  57. package/lib/BasicTranscript.js +406 -743
  58. package/lib/BasicTypingIndicator.d.ts +6 -0
  59. package/lib/BasicTypingIndicator.d.ts.map +1 -0
  60. package/lib/BasicTypingIndicator.js +13 -5
  61. package/lib/BasicWebChat.d.ts +9 -0
  62. package/lib/BasicWebChat.d.ts.map +1 -0
  63. package/lib/BasicWebChat.js +6 -4
  64. package/lib/Composer.d.ts +23 -0
  65. package/lib/Composer.d.ts.map +1 -0
  66. package/lib/Composer.js +65 -82
  67. package/lib/ConnectivityStatus/Assets/ErrorNotificationIcon.js +2 -2
  68. package/lib/ConnectivityStatus/Assets/SpinnerAnimation.js +2 -2
  69. package/lib/ConnectivityStatus/Assets/WarningNotificationIcon.js +2 -2
  70. package/lib/ConnectivityStatus/Connected.js +1 -1
  71. package/lib/ConnectivityStatus/Connecting.js +4 -4
  72. package/lib/ConnectivityStatus/FailedToConnect.js +2 -2
  73. package/lib/ConnectivityStatus/JavaScriptError.js +2 -2
  74. package/lib/Dictation.js +13 -4
  75. package/lib/ErrorBox.d.ts +8 -0
  76. package/lib/ErrorBox.d.ts.map +1 -0
  77. package/lib/ErrorBox.js +2 -2
  78. package/lib/Middleware/Activity/createCoreMiddleware.d.ts +3 -0
  79. package/lib/Middleware/Activity/createCoreMiddleware.d.ts.map +1 -0
  80. package/lib/Middleware/Activity/createCoreMiddleware.js +1 -1
  81. package/lib/Middleware/ActivityStatus/AbsoluteTime.js +1 -1
  82. package/lib/Middleware/ActivityStatus/RelativeTime.js +1 -1
  83. package/lib/Middleware/ActivityStatus/SendStatus/SendFailedRetry.js +3 -3
  84. package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.d.ts +11 -0
  85. package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.d.ts.map +1 -0
  86. package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.js +5 -5
  87. package/lib/Middleware/ActivityStatus/Timestamp.d.ts +9 -0
  88. package/lib/Middleware/ActivityStatus/Timestamp.d.ts.map +1 -0
  89. package/lib/Middleware/ActivityStatus/Timestamp.js +2 -2
  90. package/lib/Middleware/ActivityStatus/createCoreMiddleware.d.ts +3 -0
  91. package/lib/Middleware/ActivityStatus/createCoreMiddleware.d.ts.map +1 -0
  92. package/lib/Middleware/ActivityStatus/createCoreMiddleware.js +1 -1
  93. package/lib/Middleware/ActivityStatus/createSendStatusMiddleware.js +21 -16
  94. package/lib/Middleware/ActivityStatus/createTimestampMiddleware.js +1 -1
  95. package/lib/Middleware/Attachment/createCoreMiddleware.d.ts +3 -0
  96. package/lib/Middleware/Attachment/createCoreMiddleware.d.ts.map +1 -0
  97. package/lib/Middleware/Attachment/createCoreMiddleware.js +10 -13
  98. package/lib/Middleware/AttachmentForScreenReader/AudioAttachment.js +1 -1
  99. package/lib/Middleware/AttachmentForScreenReader/FileAttachment.js +1 -1
  100. package/lib/Middleware/AttachmentForScreenReader/ImageAttachment.js +1 -1
  101. package/lib/Middleware/AttachmentForScreenReader/TextAttachment.js +1 -1
  102. package/lib/Middleware/AttachmentForScreenReader/VideoAttachment.js +1 -1
  103. package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.d.ts +3 -0
  104. package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.d.ts.map +1 -0
  105. package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.js +9 -5
  106. package/lib/Middleware/Avatar/createCoreMiddleware.d.ts +11 -0
  107. package/lib/Middleware/Avatar/createCoreMiddleware.d.ts.map +1 -0
  108. package/lib/Middleware/Avatar/createCoreMiddleware.js +3 -4
  109. package/lib/Middleware/CardAction/createCoreMiddleware.js +11 -4
  110. package/lib/Middleware/GroupActivities/createCoreMiddleware.js +1 -1
  111. package/lib/Middleware/ScrollToEndButton/ScrollToEndButton.js +71 -0
  112. package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.d.ts +3 -0
  113. package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.d.ts.map +1 -0
  114. package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.js +27 -0
  115. package/lib/Middleware/Toast/createCoreMiddleware.d.ts +4 -0
  116. package/lib/Middleware/Toast/createCoreMiddleware.d.ts.map +1 -0
  117. package/lib/Middleware/Toast/createCoreMiddleware.js +1 -1
  118. package/lib/Middleware/TypingIndicator/createCoreMiddleware.d.ts +3 -0
  119. package/lib/Middleware/TypingIndicator/createCoreMiddleware.d.ts.map +1 -0
  120. package/lib/Middleware/TypingIndicator/createCoreMiddleware.js +9 -6
  121. package/lib/ReactWebChat.d.ts +10 -0
  122. package/lib/ReactWebChat.d.ts.map +1 -0
  123. package/lib/ReactWebChat.js +19 -7
  124. package/lib/ScreenReaderActivity.js +76 -48
  125. package/lib/ScreenReaderText.d.ts +9 -0
  126. package/lib/ScreenReaderText.d.ts.map +1 -0
  127. package/lib/ScreenReaderText.js +22 -8
  128. package/lib/SendBox/Assets/AttachmentIcon.js +3 -1
  129. package/lib/SendBox/Assets/MicrophoneIcon.js +3 -1
  130. package/lib/SendBox/Assets/SendIcon.js +2 -2
  131. package/lib/SendBox/AutoResizeTextArea.d.ts +23 -0
  132. package/lib/SendBox/AutoResizeTextArea.d.ts.map +1 -0
  133. package/lib/SendBox/AutoResizeTextArea.js +6 -6
  134. package/lib/SendBox/DictationInterims.d.ts +9 -0
  135. package/lib/SendBox/DictationInterims.d.ts.map +1 -0
  136. package/lib/SendBox/DictationInterims.js +3 -3
  137. package/lib/SendBox/IconButton.d.ts +11 -0
  138. package/lib/SendBox/IconButton.d.ts.map +1 -0
  139. package/lib/SendBox/IconButton.js +27 -7
  140. package/lib/SendBox/MicrophoneButton.d.ts +11 -0
  141. package/lib/SendBox/MicrophoneButton.d.ts.map +1 -0
  142. package/lib/SendBox/MicrophoneButton.js +25 -24
  143. package/lib/SendBox/SendButton.d.ts +9 -0
  144. package/lib/SendBox/SendButton.d.ts.map +1 -0
  145. package/lib/SendBox/SendButton.js +8 -6
  146. package/lib/SendBox/SuggestedAction.d.ts +17 -0
  147. package/lib/SendBox/SuggestedAction.d.ts.map +1 -0
  148. package/lib/SendBox/SuggestedAction.js +29 -24
  149. package/lib/SendBox/SuggestedActions.d.ts +5 -0
  150. package/lib/SendBox/SuggestedActions.d.ts.map +1 -0
  151. package/lib/SendBox/SuggestedActions.js +33 -13
  152. package/lib/SendBox/TextBox.d.ts +28 -0
  153. package/lib/SendBox/TextBox.d.ts.map +1 -0
  154. package/lib/SendBox/TextBox.js +13 -8
  155. package/lib/SendBox/UploadButton.d.ts +9 -0
  156. package/lib/SendBox/UploadButton.d.ts.map +1 -0
  157. package/lib/SendBox/UploadButton.js +6 -6
  158. package/lib/Styles/StyleSet/Activities.d.ts +5 -0
  159. package/lib/Styles/StyleSet/Activities.d.ts.map +1 -0
  160. package/lib/Styles/StyleSet/AudioAttachment.d.ts +6 -0
  161. package/lib/Styles/StyleSet/AudioAttachment.d.ts.map +1 -0
  162. package/lib/Styles/StyleSet/AudioContent.d.ts +4 -0
  163. package/lib/Styles/StyleSet/AudioContent.d.ts.map +1 -0
  164. package/lib/Styles/StyleSet/AutoResizeTextArea.d.ts +37 -0
  165. package/lib/Styles/StyleSet/AutoResizeTextArea.d.ts.map +1 -0
  166. package/lib/Styles/StyleSet/Avatar.d.ts +9 -0
  167. package/lib/Styles/StyleSet/Avatar.d.ts.map +1 -0
  168. package/lib/Styles/StyleSet/BasicTranscript.d.ts +85 -0
  169. package/lib/Styles/StyleSet/BasicTranscript.d.ts.map +1 -0
  170. package/lib/Styles/StyleSet/BasicTranscript.js +21 -9
  171. package/lib/Styles/StyleSet/Bubble.d.ts +5 -0
  172. package/lib/Styles/StyleSet/Bubble.d.ts.map +1 -0
  173. package/lib/Styles/StyleSet/Bubble.js +2 -2
  174. package/lib/Styles/StyleSet/CarouselFilmStrip.d.ts +5 -0
  175. package/lib/Styles/StyleSet/CarouselFilmStrip.d.ts.map +1 -0
  176. package/lib/Styles/StyleSet/CarouselFilmStrip.js +2 -18
  177. package/lib/Styles/StyleSet/CarouselFilmStripAttachment.d.ts +3 -0
  178. package/lib/Styles/StyleSet/CarouselFilmStripAttachment.d.ts.map +1 -0
  179. package/lib/Styles/StyleSet/CarouselFilmStripAttachment.js +63 -0
  180. package/lib/Styles/StyleSet/CarouselFlipper.d.ts +27 -0
  181. package/lib/Styles/StyleSet/CarouselFlipper.d.ts.map +1 -0
  182. package/lib/Styles/StyleSet/ConnectivityNotification.d.ts +13 -0
  183. package/lib/Styles/StyleSet/ConnectivityNotification.d.ts.map +1 -0
  184. package/lib/Styles/StyleSet/DictationInterims.d.ts +13 -0
  185. package/lib/Styles/StyleSet/DictationInterims.d.ts.map +1 -0
  186. package/lib/Styles/StyleSet/ErrorBox.d.ts +33 -0
  187. package/lib/Styles/StyleSet/ErrorBox.d.ts.map +1 -0
  188. package/lib/Styles/StyleSet/ErrorNotification.d.ts +23 -0
  189. package/lib/Styles/StyleSet/ErrorNotification.d.ts.map +1 -0
  190. package/lib/Styles/StyleSet/FileContent.d.ts +32 -0
  191. package/lib/Styles/StyleSet/FileContent.d.ts.map +1 -0
  192. package/lib/Styles/StyleSet/ImageAvatar.d.ts +7 -0
  193. package/lib/Styles/StyleSet/ImageAvatar.d.ts.map +1 -0
  194. package/lib/Styles/StyleSet/InitialsAvatar.d.ts +19 -0
  195. package/lib/Styles/StyleSet/InitialsAvatar.d.ts.map +1 -0
  196. package/lib/Styles/StyleSet/KeyboardHelp.d.ts +123 -0
  197. package/lib/Styles/StyleSet/KeyboardHelp.d.ts.map +1 -0
  198. package/lib/Styles/StyleSet/KeyboardHelp.js +145 -0
  199. package/lib/Styles/StyleSet/MicrophoneButton.d.ts +13 -0
  200. package/lib/Styles/StyleSet/MicrophoneButton.d.ts.map +1 -0
  201. package/lib/Styles/StyleSet/Root.d.ts +8 -0
  202. package/lib/Styles/StyleSet/Root.d.ts.map +1 -0
  203. package/lib/Styles/StyleSet/ScrollToEndButton.d.ts +36 -0
  204. package/lib/Styles/StyleSet/ScrollToEndButton.d.ts.map +1 -0
  205. package/lib/Styles/StyleSet/ScrollToEndButton.js +36 -34
  206. package/lib/Styles/StyleSet/SendBox.d.ts +24 -0
  207. package/lib/Styles/StyleSet/SendBox.d.ts.map +1 -0
  208. package/lib/Styles/StyleSet/SendBoxButton.d.ts +79 -0
  209. package/lib/Styles/StyleSet/SendBoxButton.d.ts.map +1 -0
  210. package/lib/Styles/StyleSet/SendBoxButton.js +76 -12
  211. package/lib/Styles/StyleSet/SendBoxTextBox.d.ts +41 -0
  212. package/lib/Styles/StyleSet/SendBoxTextBox.d.ts.map +1 -0
  213. package/lib/Styles/StyleSet/SendBoxTextBox.js +3 -3
  214. package/lib/Styles/StyleSet/SendStatus.d.ts +8 -0
  215. package/lib/Styles/StyleSet/SendStatus.d.ts.map +1 -0
  216. package/lib/Styles/StyleSet/SingleAttachmentActivity.d.ts +11 -0
  217. package/lib/Styles/StyleSet/SingleAttachmentActivity.d.ts.map +1 -0
  218. package/lib/Styles/StyleSet/SpinnerAnimation.d.ts +15 -0
  219. package/lib/Styles/StyleSet/SpinnerAnimation.d.ts.map +1 -0
  220. package/lib/Styles/StyleSet/StackedLayout.d.ts +63 -0
  221. package/lib/Styles/StyleSet/StackedLayout.d.ts.map +1 -0
  222. package/lib/Styles/StyleSet/StackedLayout.js +1 -1
  223. package/lib/Styles/StyleSet/SuggestedAction.d.ts +94 -0
  224. package/lib/Styles/StyleSet/SuggestedAction.d.ts.map +1 -0
  225. package/lib/Styles/StyleSet/SuggestedAction.js +116 -41
  226. package/lib/Styles/StyleSet/SuggestedActions.d.ts +125 -0
  227. package/lib/Styles/StyleSet/SuggestedActions.d.ts.map +1 -0
  228. package/lib/Styles/StyleSet/SuggestedActions.js +13 -6
  229. package/lib/Styles/StyleSet/TextContent.d.ts +28 -0
  230. package/lib/Styles/StyleSet/TextContent.d.ts.map +1 -0
  231. package/lib/Styles/StyleSet/Toast.d.ts +65 -0
  232. package/lib/Styles/StyleSet/Toast.d.ts.map +1 -0
  233. package/lib/Styles/StyleSet/Toaster.d.ts +111 -0
  234. package/lib/Styles/StyleSet/Toaster.d.ts.map +1 -0
  235. package/lib/Styles/StyleSet/TypingAnimation.d.ts +8 -0
  236. package/lib/Styles/StyleSet/TypingAnimation.d.ts.map +1 -0
  237. package/lib/Styles/StyleSet/TypingIndicator.d.ts +11 -0
  238. package/lib/Styles/StyleSet/TypingIndicator.d.ts.map +1 -0
  239. package/lib/Styles/StyleSet/UploadButton.d.ts +14 -0
  240. package/lib/Styles/StyleSet/UploadButton.d.ts.map +1 -0
  241. package/lib/Styles/StyleSet/VideoAttachment.d.ts +2 -0
  242. package/lib/Styles/StyleSet/VideoAttachment.d.ts.map +1 -0
  243. package/lib/Styles/StyleSet/VideoContent.d.ts +6 -0
  244. package/lib/Styles/StyleSet/VideoContent.d.ts.map +1 -0
  245. package/lib/Styles/StyleSet/VimeoContent.d.ts +7 -0
  246. package/lib/Styles/StyleSet/VimeoContent.d.ts.map +1 -0
  247. package/lib/Styles/StyleSet/WarningNotification.d.ts +22 -0
  248. package/lib/Styles/StyleSet/WarningNotification.d.ts.map +1 -0
  249. package/lib/Styles/StyleSet/YouTubeContent.d.ts +7 -0
  250. package/lib/Styles/StyleSet/YouTubeContent.d.ts.map +1 -0
  251. package/lib/Styles/createStyleSet.d.ts +1372 -0
  252. package/lib/Styles/createStyleSet.d.ts.map +1 -0
  253. package/lib/Styles/createStyleSet.js +47 -41
  254. package/lib/Styles/mirrorStyle.js +13 -4
  255. package/lib/Toast/CollapseIcon.js +3 -1
  256. package/lib/Toast/DismissIcon.js +3 -1
  257. package/lib/Toast/ExpandIcon.js +3 -1
  258. package/lib/Toast/NotificationIcon.js +7 -3
  259. package/lib/Toast/createToastMiddleware.d.ts +4 -0
  260. package/lib/Toast/createToastMiddleware.d.ts.map +1 -0
  261. package/lib/Toast/createToastMiddleware.js +2 -2
  262. package/lib/Transcript/ActivityRow.d.ts +9 -0
  263. package/lib/Transcript/ActivityRow.d.ts.map +1 -0
  264. package/lib/Transcript/ActivityRow.js +157 -0
  265. package/lib/Transcript/ActivityTextAlt.js +57 -0
  266. package/lib/Transcript/FocusTrap.d.ts +8 -0
  267. package/lib/Transcript/FocusTrap.d.ts.map +1 -0
  268. package/lib/Transcript/FocusTrap.js +74 -0
  269. package/lib/Transcript/KeyboardHelp.d.ts +4 -0
  270. package/lib/Transcript/KeyboardHelp.d.ts.map +1 -0
  271. package/lib/Transcript/KeyboardHelp.js +550 -0
  272. package/lib/Transcript/LiveRegionTranscript.d.ts +8 -0
  273. package/lib/Transcript/LiveRegionTranscript.d.ts.map +1 -0
  274. package/lib/Transcript/LiveRegionTranscript.js +214 -0
  275. package/lib/Transcript/types.d.ts +2 -0
  276. package/lib/Transcript/types.d.ts.map +1 -0
  277. package/lib/Transcript/types.js +2 -0
  278. package/lib/Transcript/useActivityAccessibleName.d.ts +4 -0
  279. package/lib/Transcript/useActivityAccessibleName.d.ts.map +1 -0
  280. package/lib/Transcript/useActivityAccessibleName.js +97 -0
  281. package/lib/Utils/AccessKeySink/Surface.js +7 -5
  282. package/lib/Utils/AccessibleButton.d.ts +11 -0
  283. package/lib/Utils/AccessibleButton.d.ts.map +1 -0
  284. package/lib/Utils/AccessibleButton.js +15 -8
  285. package/lib/Utils/AccessibleInputText.d.ts +21 -0
  286. package/lib/Utils/AccessibleInputText.d.ts.map +1 -0
  287. package/lib/Utils/AccessibleInputText.js +29 -25
  288. package/lib/Utils/AccessibleTextArea.d.ts +20 -0
  289. package/lib/Utils/AccessibleTextArea.d.ts.map +1 -0
  290. package/lib/Utils/AccessibleTextArea.js +35 -24
  291. package/lib/Utils/CroppedImage.js +2 -2
  292. package/lib/Utils/Fade.js +2 -2
  293. package/lib/Utils/FocusRedirector.d.ts +9 -0
  294. package/lib/Utils/FocusRedirector.d.ts.map +1 -0
  295. package/lib/Utils/FocusRedirector.js +18 -15
  296. package/lib/Utils/InlineMarkdown.js +17 -10
  297. package/lib/Utils/TypeFocusSink/FocusBox.js +6 -4
  298. package/lib/Utils/TypeFocusSink/getTabIndex.d.ts +2 -0
  299. package/lib/Utils/TypeFocusSink/getTabIndex.d.ts.map +1 -0
  300. package/lib/Utils/TypeFocusSink/getTabIndex.js +1 -1
  301. package/lib/Utils/TypeFocusSink/inputtableKey.d.ts +2 -0
  302. package/lib/Utils/TypeFocusSink/inputtableKey.d.ts.map +1 -0
  303. package/lib/Utils/TypeFocusSink/inputtableKey.js +5 -2
  304. package/lib/Utils/TypeFocusSink/navigableEvent.js +1 -1
  305. package/lib/Utils/activityAltText.d.ts +8 -0
  306. package/lib/Utils/activityAltText.d.ts.map +1 -0
  307. package/lib/Utils/activityAltText.js +100 -0
  308. package/lib/Utils/addTargetBlankToHyperlinksMarkdown.js +1 -1
  309. package/lib/Utils/createCustomEvent.js +9 -3
  310. package/lib/Utils/debounce.js +1 -1
  311. package/lib/Utils/detectBrowser.js +4 -2
  312. package/lib/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingWorker.js +3 -3
  313. package/lib/Utils/downscaleImageToDataURL/index.js +2 -2
  314. package/lib/Utils/filterMap.js +1 -1
  315. package/lib/Utils/findAncestor.js +17 -0
  316. package/lib/Utils/getActivityUniqueId.js +4 -2
  317. package/lib/Utils/intersectionOf.d.ts +5 -0
  318. package/lib/Utils/intersectionOf.d.ts.map +1 -0
  319. package/lib/Utils/intersectionOf.js +17 -2
  320. package/lib/Utils/isZeroOrPositive.d.ts +5 -0
  321. package/lib/Utils/isZeroOrPositive.d.ts.map +1 -0
  322. package/lib/Utils/isZeroOrPositive.js +4 -1
  323. package/lib/Utils/mapMap.js +10 -3
  324. package/lib/Utils/readDataURIToBlob.js +3 -3
  325. package/lib/Utils/scrollIntoViewWithBlockNearest.d.ts +7 -0
  326. package/lib/Utils/scrollIntoViewWithBlockNearest.d.ts.map +1 -0
  327. package/lib/Utils/scrollIntoViewWithBlockNearest.js +48 -0
  328. package/lib/Utils/shallowEquals.js +7 -3
  329. package/lib/Utils/singleToArray.js +1 -1
  330. package/lib/Utils/supportPseudoClass.d.ts +2 -0
  331. package/lib/Utils/supportPseudoClass.d.ts.map +1 -0
  332. package/lib/Utils/supportPseudoClass.js +23 -0
  333. package/lib/Utils/tabbableElements.d.ts +2 -0
  334. package/lib/Utils/tabbableElements.d.ts.map +1 -0
  335. package/lib/Utils/tabbableElements.js +2 -2
  336. package/lib/connectToWebChat.js +17 -7
  337. package/lib/hooks/index.d.ts +21 -0
  338. package/lib/hooks/index.d.ts.map +1 -0
  339. package/lib/hooks/index.js +25 -25
  340. package/lib/hooks/internal/BypassSpeechSynthesisPonyfill.js +100 -41
  341. package/lib/hooks/internal/UITracker.js +2 -2
  342. package/lib/hooks/internal/useChanged.js +8 -1
  343. package/lib/hooks/internal/useDispatchScrollPosition.js +3 -7
  344. package/lib/hooks/internal/useDispatchTranscriptFocusByActivityKey.d.ts +2 -0
  345. package/lib/hooks/internal/useDispatchTranscriptFocusByActivityKey.d.ts.map +1 -0
  346. package/lib/hooks/internal/useDispatchTranscriptFocusByActivityKey.js +15 -0
  347. package/lib/hooks/internal/useEnterKeyHint.js +1 -1
  348. package/lib/hooks/internal/useFocusVisible.d.ts +3 -0
  349. package/lib/hooks/internal/useFocusVisible.d.ts.map +1 -0
  350. package/lib/hooks/internal/useFocusVisible.js +48 -0
  351. package/lib/hooks/internal/useForceRender.js +2 -2
  352. package/lib/hooks/internal/useForceRenderAtInterval.js +2 -2
  353. package/lib/hooks/internal/useInternalRenderMarkdownInline.js +1 -1
  354. package/lib/hooks/internal/useLocalizeAccessKey.js +2 -2
  355. package/lib/hooks/internal/useMemoWithPrevious.d.ts +3 -0
  356. package/lib/hooks/internal/useMemoWithPrevious.d.ts.map +1 -0
  357. package/lib/hooks/internal/useMemoWithPrevious.js +22 -0
  358. package/lib/hooks/internal/useMemoize.d.ts +14 -0
  359. package/lib/hooks/internal/useMemoize.d.ts.map +1 -0
  360. package/lib/hooks/internal/useMemoize.js +12 -3
  361. package/lib/hooks/internal/useNavigatorPlatform.js +1 -1
  362. package/lib/hooks/internal/useNonce.js +1 -1
  363. package/lib/hooks/internal/useObserveFocusVisible.d.ts +3 -0
  364. package/lib/hooks/internal/useObserveFocusVisible.d.ts.map +1 -0
  365. package/lib/hooks/internal/useObserveFocusVisible.js +208 -0
  366. package/lib/hooks/internal/usePrevious.d.ts +2 -0
  367. package/lib/hooks/internal/usePrevious.d.ts.map +1 -0
  368. package/lib/hooks/internal/usePrevious.js +18 -0
  369. package/lib/hooks/internal/useRegisterFocusSendBox.js +1 -1
  370. package/lib/hooks/internal/useRegisterFocusTranscript.js +1 -1
  371. package/lib/hooks/internal/useRegisterScrollRelative.js +1 -1
  372. package/lib/hooks/internal/useRegisterScrollTo.js +1 -1
  373. package/lib/hooks/internal/useRegisterScrollToEnd.js +1 -1
  374. package/lib/hooks/internal/useReplaceEmoticon.js +2 -2
  375. package/lib/hooks/internal/useResumeAudioContext.js +33 -0
  376. package/lib/hooks/internal/useScrollRelative.js +1 -1
  377. package/lib/hooks/internal/useSettableDictateAbortable.js +1 -1
  378. package/lib/hooks/internal/useStateRef.d.ts +3 -0
  379. package/lib/hooks/internal/useStateRef.d.ts.map +1 -0
  380. package/lib/hooks/internal/useStateRef.js +40 -0
  381. package/lib/hooks/internal/useSuggestedActionsAccessKey.js +1 -1
  382. package/lib/hooks/internal/useUniqueId.d.ts +2 -0
  383. package/lib/hooks/internal/useUniqueId.d.ts.map +1 -0
  384. package/lib/hooks/internal/useUniqueId.js +1 -1
  385. package/lib/hooks/internal/useValueRef.d.ts +3 -0
  386. package/lib/hooks/internal/useValueRef.d.ts.map +1 -0
  387. package/lib/hooks/internal/useValueRef.js +25 -0
  388. package/lib/hooks/useDictateAbortable.d.ts +2 -0
  389. package/lib/hooks/useDictateAbortable.d.ts.map +1 -0
  390. package/lib/hooks/useDictateAbortable.js +2 -2
  391. package/lib/hooks/useFocus.d.ts +2 -0
  392. package/lib/hooks/useFocus.d.ts.map +1 -0
  393. package/lib/hooks/useFocus.js +1 -1
  394. package/lib/hooks/useFocusSendBox.d.ts +3 -0
  395. package/lib/hooks/useFocusSendBox.d.ts.map +1 -0
  396. package/lib/hooks/useFocusSendBox.js +2 -1
  397. package/lib/hooks/useObserveScrollPosition.d.ts +3 -0
  398. package/lib/hooks/useObserveScrollPosition.d.ts.map +1 -0
  399. package/lib/hooks/useObserveScrollPosition.js +2 -2
  400. package/lib/hooks/useObserveTranscriptFocus.d.ts +5 -0
  401. package/lib/hooks/useObserveTranscriptFocus.d.ts.map +1 -0
  402. package/lib/hooks/useObserveTranscriptFocus.js +2 -2
  403. package/lib/hooks/useRenderMarkdownAsHTML.d.ts +5 -0
  404. package/lib/hooks/useRenderMarkdownAsHTML.d.ts.map +1 -0
  405. package/lib/hooks/useRenderMarkdownAsHTML.js +2 -2
  406. package/lib/hooks/useScrollDown.d.ts +4 -0
  407. package/lib/hooks/useScrollDown.d.ts.map +1 -0
  408. package/lib/hooks/useScrollDown.js +1 -1
  409. package/lib/hooks/useScrollTo.d.ts +5 -0
  410. package/lib/hooks/useScrollTo.d.ts.map +1 -0
  411. package/lib/hooks/useScrollTo.js +1 -1
  412. package/lib/hooks/useScrollToEnd.d.ts +2 -0
  413. package/lib/hooks/useScrollToEnd.d.ts.map +1 -0
  414. package/lib/hooks/useScrollToEnd.js +1 -1
  415. package/lib/hooks/useScrollUp.d.ts +4 -0
  416. package/lib/hooks/useScrollUp.d.ts.map +1 -0
  417. package/lib/hooks/useScrollUp.js +1 -1
  418. package/lib/hooks/useSendFiles.d.ts +2 -0
  419. package/lib/hooks/useSendFiles.d.ts.map +1 -0
  420. package/lib/hooks/useSendFiles.js +3 -3
  421. package/lib/hooks/useStyleSet.d.ts +2 -0
  422. package/lib/hooks/useStyleSet.d.ts.map +1 -0
  423. package/lib/hooks/useStyleSet.js +1 -1
  424. package/lib/hooks/useWebSpeechPonyfill.d.ts +3 -0
  425. package/lib/hooks/useWebSpeechPonyfill.d.ts.map +1 -0
  426. package/lib/hooks/useWebSpeechPonyfill.js +1 -1
  427. package/lib/index.d.ts +219 -22
  428. package/lib/index.d.ts.map +1 -1
  429. package/lib/index.js +22 -20
  430. package/lib/providers/ActivityTree/ActivityTreeComposer.d.ts +5 -0
  431. package/lib/providers/ActivityTree/ActivityTreeComposer.d.ts.map +1 -0
  432. package/lib/providers/ActivityTree/ActivityTreeComposer.js +86 -0
  433. package/lib/providers/ActivityTree/private/Context.d.ts +9 -0
  434. package/lib/providers/ActivityTree/private/Context.d.ts.map +1 -0
  435. package/lib/providers/ActivityTree/private/Context.js +13 -0
  436. package/lib/providers/ActivityTree/private/types.d.ts +10 -0
  437. package/lib/providers/ActivityTree/private/types.d.ts.map +1 -0
  438. package/lib/providers/ActivityTree/private/types.js +2 -0
  439. package/lib/providers/ActivityTree/private/useActivitiesWithRenderer.d.ts +4 -0
  440. package/lib/providers/ActivityTree/private/useActivitiesWithRenderer.d.ts.map +1 -0
  441. package/lib/providers/ActivityTree/private/useActivitiesWithRenderer.js +58 -0
  442. package/lib/providers/ActivityTree/private/useActivityTreeWithRenderer.d.ts +5 -0
  443. package/lib/providers/ActivityTree/private/useActivityTreeWithRenderer.d.ts.map +1 -0
  444. package/lib/providers/ActivityTree/private/useActivityTreeWithRenderer.js +166 -0
  445. package/lib/providers/ActivityTree/private/useContext.d.ts +3 -0
  446. package/lib/providers/ActivityTree/private/useContext.d.ts.map +1 -0
  447. package/lib/providers/ActivityTree/private/useContext.js +24 -0
  448. package/lib/providers/ActivityTree/useActivityTreeWithRenderer.d.ts +8 -0
  449. package/lib/providers/ActivityTree/useActivityTreeWithRenderer.d.ts.map +1 -0
  450. package/lib/providers/ActivityTree/useActivityTreeWithRenderer.js +17 -0
  451. package/lib/providers/LiveRegionTwin/LiveRegionTwinComposer.d.ts +35 -0
  452. package/lib/providers/LiveRegionTwin/LiveRegionTwinComposer.d.ts.map +1 -0
  453. package/lib/providers/LiveRegionTwin/LiveRegionTwinComposer.js +156 -0
  454. package/lib/providers/LiveRegionTwin/private/Context.d.ts +10 -0
  455. package/lib/providers/LiveRegionTwin/private/Context.d.ts.map +1 -0
  456. package/lib/providers/LiveRegionTwin/private/Context.js +13 -0
  457. package/lib/providers/LiveRegionTwin/private/LiveRegionTwinContainer.d.ts +11 -0
  458. package/lib/providers/LiveRegionTwin/private/LiveRegionTwinContainer.d.ts.map +1 -0
  459. package/lib/providers/LiveRegionTwin/private/LiveRegionTwinContainer.js +86 -0
  460. package/lib/providers/LiveRegionTwin/private/types.d.ts +8 -0
  461. package/lib/providers/LiveRegionTwin/private/types.d.ts.map +1 -0
  462. package/lib/providers/LiveRegionTwin/private/types.js +2 -0
  463. package/lib/providers/LiveRegionTwin/private/useContext.d.ts +3 -0
  464. package/lib/providers/LiveRegionTwin/private/useContext.d.ts.map +1 -0
  465. package/lib/providers/LiveRegionTwin/private/useContext.js +24 -0
  466. package/lib/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.d.ts +2 -0
  467. package/lib/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.d.ts.map +1 -0
  468. package/lib/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.js +24 -0
  469. package/lib/providers/LiveRegionTwin/private/useStaticElementEntries.d.ts +3 -0
  470. package/lib/providers/LiveRegionTwin/private/useStaticElementEntries.d.ts.map +1 -0
  471. package/lib/providers/LiveRegionTwin/private/useStaticElementEntries.js +15 -0
  472. package/lib/providers/LiveRegionTwin/useQueueStaticElement.d.ts +8 -0
  473. package/lib/providers/LiveRegionTwin/useQueueStaticElement.d.ts.map +1 -0
  474. package/lib/providers/LiveRegionTwin/useQueueStaticElement.js +20 -0
  475. package/lib/providers/TranscriptFocus/TranscriptFocusComposer.d.ts +7 -0
  476. package/lib/providers/TranscriptFocus/TranscriptFocusComposer.d.ts.map +1 -0
  477. package/lib/providers/TranscriptFocus/TranscriptFocusComposer.js +184 -0
  478. package/lib/providers/TranscriptFocus/private/Context.d.ts +12 -0
  479. package/lib/providers/TranscriptFocus/private/Context.d.ts.map +1 -0
  480. package/lib/providers/TranscriptFocus/private/Context.js +13 -0
  481. package/lib/providers/TranscriptFocus/private/useContext.d.ts +2 -0
  482. package/lib/providers/TranscriptFocus/private/useContext.d.ts.map +1 -0
  483. package/lib/providers/TranscriptFocus/private/useContext.js +24 -0
  484. package/lib/providers/TranscriptFocus/useActiveDescendantId.d.ts +2 -0
  485. package/lib/providers/TranscriptFocus/useActiveDescendantId.d.ts.map +1 -0
  486. package/lib/providers/TranscriptFocus/useActiveDescendantId.js +15 -0
  487. package/lib/providers/TranscriptFocus/useFocusByActivityKey.d.ts +8 -0
  488. package/lib/providers/TranscriptFocus/useFocusByActivityKey.d.ts.map +1 -0
  489. package/lib/providers/TranscriptFocus/useFocusByActivityKey.js +21 -0
  490. package/lib/providers/TranscriptFocus/useFocusRelativeActivity.d.ts +2 -0
  491. package/lib/providers/TranscriptFocus/useFocusRelativeActivity.d.ts.map +1 -0
  492. package/lib/providers/TranscriptFocus/useFocusRelativeActivity.js +15 -0
  493. package/lib/providers/TranscriptFocus/useFocusedActivityKey.d.ts +2 -0
  494. package/lib/providers/TranscriptFocus/useFocusedActivityKey.d.ts.map +1 -0
  495. package/lib/providers/TranscriptFocus/useFocusedActivityKey.js +15 -0
  496. package/lib/providers/TranscriptFocus/useFocusedExplicitly.d.ts +2 -0
  497. package/lib/providers/TranscriptFocus/useFocusedExplicitly.d.ts.map +1 -0
  498. package/lib/providers/TranscriptFocus/useFocusedExplicitly.js +15 -0
  499. package/lib/providers/TranscriptFocus/useGetDescendantIdByActivityKey.d.ts +2 -0
  500. package/lib/providers/TranscriptFocus/useGetDescendantIdByActivityKey.d.ts.map +1 -0
  501. package/lib/providers/TranscriptFocus/useGetDescendantIdByActivityKey.js +15 -0
  502. package/lib/tsconfig.json +1 -1
  503. package/lib/types/ScrollPosition.d.ts +6 -0
  504. package/lib/types/ScrollPosition.d.ts.map +1 -0
  505. package/lib/types/ScrollPosition.js +2 -0
  506. package/package.json +33 -40
  507. package/src/Activity/{Avatar.js → Avatar.tsx} +9 -2
  508. package/src/Activity/{Bubble.js → Bubble.tsx} +10 -2
  509. package/src/Activity/CarouselFilmStrip.js +20 -29
  510. package/src/Activity/CarouselFilmStripAttachment.js +91 -0
  511. package/src/Activity/{Speak.js → Speak.tsx} +12 -5
  512. package/src/Activity/{StackedLayout.js → StackedLayout.tsx} +46 -20
  513. package/src/Attachment/Assets/DownloadIcon.js +8 -1
  514. package/src/Attachment/{AudioContent.js → AudioContent.tsx} +12 -3
  515. package/src/Attachment/FileAttachment.js +1 -1
  516. package/src/Attachment/{FileContent.js → FileContent.tsx} +22 -7
  517. package/src/Attachment/{HTMLVideoContent.js → HTMLVideoContent.tsx} +10 -2
  518. package/src/Attachment/{ImageContent.js → ImageContent.tsx} +7 -2
  519. package/src/Attachment/{TextContent.js → TextContent.tsx} +14 -7
  520. package/src/Attachment/{VideoContent.js → VideoContent.tsx} +10 -2
  521. package/src/Attachment/{VimeoContent.js → VimeoContent.tsx} +15 -8
  522. package/src/Attachment/{YouTubeContent.js → YouTubeContent.tsx} +12 -5
  523. package/src/{BasicSendBox.js → BasicSendBox.tsx} +9 -5
  524. package/src/BasicToaster.js +9 -5
  525. package/src/BasicTranscript.tsx +878 -0
  526. package/src/{BasicTypingIndicator.js → BasicTypingIndicator.tsx} +4 -3
  527. package/src/{BasicWebChat.js → BasicWebChat.tsx} +13 -4
  528. package/src/{Composer.js → Composer.tsx} +82 -71
  529. package/src/Dictation.js +13 -4
  530. package/src/{ErrorBox.js → ErrorBox.tsx} +7 -2
  531. package/src/Middleware/Activity/createCoreMiddleware.tsx +78 -0
  532. package/src/Middleware/ActivityStatus/SendStatus/{SendStatus.js → SendStatus.tsx} +8 -3
  533. package/src/Middleware/ActivityStatus/{Timestamp.js → Timestamp.tsx} +8 -2
  534. package/src/Middleware/ActivityStatus/{createCoreMiddleware.js → createCoreMiddleware.tsx} +3 -1
  535. package/src/Middleware/ActivityStatus/createSendStatusMiddleware.js +10 -6
  536. package/src/Middleware/ActivityStatus/createTimestampMiddleware.js +10 -8
  537. package/src/Middleware/Attachment/createCoreMiddleware.tsx +44 -0
  538. package/src/Middleware/AttachmentForScreenReader/createCoreMiddleware.tsx +40 -0
  539. package/src/Middleware/Avatar/{createCoreMiddleware.js → createCoreMiddleware.tsx} +19 -11
  540. package/src/Middleware/CardAction/createCoreMiddleware.js +51 -42
  541. package/src/Middleware/GroupActivities/createCoreMiddleware.js +6 -4
  542. package/src/Middleware/ScrollToEndButton/ScrollToEndButton.js +45 -0
  543. package/src/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.ts +19 -0
  544. package/src/Middleware/Toast/createCoreMiddleware.tsx +24 -0
  545. package/src/Middleware/TypingIndicator/{createCoreMiddleware.js → createCoreMiddleware.tsx} +10 -5
  546. package/src/{ReactWebChat.js → ReactWebChat.tsx} +25 -7
  547. package/src/ScreenReaderActivity.js +65 -40
  548. package/src/{ScreenReaderText.js → ScreenReaderText.tsx} +27 -9
  549. package/src/SendBox/Assets/AttachmentIcon.js +1 -1
  550. package/src/SendBox/Assets/MicrophoneIcon.js +1 -1
  551. package/src/SendBox/{AutoResizeTextArea.js → AutoResizeTextArea.tsx} +30 -4
  552. package/src/SendBox/{DictationInterims.js → DictationInterims.tsx} +6 -2
  553. package/src/SendBox/{IconButton.js → IconButton.tsx} +19 -3
  554. package/src/SendBox/{MicrophoneButton.js → MicrophoneButton.tsx} +35 -25
  555. package/src/SendBox/{SendButton.js → SendButton.tsx} +8 -3
  556. package/src/SendBox/{SuggestedAction.js → SuggestedAction.tsx} +62 -39
  557. package/src/SendBox/{SuggestedActions.js → SuggestedActions.tsx} +70 -22
  558. package/src/SendBox/{TextBox.js → TextBox.tsx} +21 -7
  559. package/src/SendBox/{UploadButton.js → UploadButton.tsx} +7 -3
  560. package/src/Styles/StyleSet/BasicTranscript.ts +34 -20
  561. package/src/Styles/StyleSet/Bubble.ts +0 -1
  562. package/src/Styles/StyleSet/CarouselFilmStrip.ts +12 -30
  563. package/src/Styles/StyleSet/CarouselFilmStripAttachment.ts +57 -0
  564. package/src/Styles/StyleSet/KeyboardHelp.ts +157 -0
  565. package/src/Styles/StyleSet/ScrollToEndButton.ts +33 -31
  566. package/src/Styles/StyleSet/SendBoxButton.ts +84 -13
  567. package/src/Styles/StyleSet/SendBoxTextBox.ts +1 -2
  568. package/src/Styles/StyleSet/StackedLayout.ts +13 -11
  569. package/src/Styles/StyleSet/SuggestedAction.ts +130 -43
  570. package/src/Styles/StyleSet/SuggestedActions.ts +13 -5
  571. package/src/Styles/createStyleSet.ts +43 -40
  572. package/src/Styles/mirrorStyle.js +10 -2
  573. package/src/Toast/CollapseIcon.js +9 -1
  574. package/src/Toast/DismissIcon.js +9 -1
  575. package/src/Toast/ExpandIcon.js +9 -1
  576. package/src/Toast/NotificationIcon.js +4 -1
  577. package/src/Toast/createToastMiddleware.tsx +15 -0
  578. package/src/Transcript/ActivityRow.tsx +124 -0
  579. package/src/Transcript/ActivityTextAlt.tsx +32 -0
  580. package/src/Transcript/FocusTrap.tsx +64 -0
  581. package/src/Transcript/KeyboardHelp.tsx +282 -0
  582. package/src/Transcript/LiveRegionTranscript.tsx +181 -0
  583. package/src/Transcript/types.ts +1 -0
  584. package/src/Transcript/useActivityAccessibleName.ts +85 -0
  585. package/src/Utils/{AccessibleButton.js → AccessibleButton.tsx} +19 -4
  586. package/src/Utils/{AccessibleInputText.js → AccessibleInputText.tsx} +48 -5
  587. package/src/Utils/{AccessibleTextArea.js → AccessibleTextArea.tsx} +67 -6
  588. package/src/Utils/{FocusRedirector.js → FocusRedirector.tsx} +21 -8
  589. package/src/Utils/InlineMarkdown.js +18 -2
  590. package/src/Utils/TypeFocusSink/FocusBox.js +4 -4
  591. package/src/Utils/TypeFocusSink/getTabIndex.ts +1 -1
  592. package/src/Utils/TypeFocusSink/inputtableKey.ts +5 -1
  593. package/src/Utils/activityAltText.ts +135 -0
  594. package/src/Utils/createCustomEvent.js +7 -1
  595. package/src/Utils/detectBrowser.js +2 -1
  596. package/src/Utils/findAncestor.ts +12 -0
  597. package/src/Utils/getActivityUniqueId.ts +5 -0
  598. package/src/Utils/intersectionOf.spec.js +2 -0
  599. package/src/Utils/intersectionOf.ts +14 -0
  600. package/src/Utils/isZeroOrPositive.ts +7 -0
  601. package/src/Utils/mapMap.js +7 -1
  602. package/src/Utils/mapMap.spec.js +2 -0
  603. package/src/Utils/removeInline.spec.js +2 -0
  604. package/src/Utils/scrollIntoViewWithBlockNearest.ts +20 -0
  605. package/src/Utils/shallowEquals.js +8 -1
  606. package/src/Utils/{singleToArray.js → singleToArray.ts} +1 -1
  607. package/src/Utils/supportPseudoClass.ts +17 -0
  608. package/src/Utils/{tabbableElements.js → tabbableElements.ts} +6 -5
  609. package/src/Utils/walkMarkdownTokens.spec.js +3 -3
  610. package/src/connectToWebChat.js +11 -4
  611. package/src/hooks/{index.js → index.ts} +1 -0
  612. package/src/hooks/internal/BypassSpeechSynthesisPonyfill.js +70 -17
  613. package/src/hooks/internal/useChanged.ts +17 -0
  614. package/src/hooks/internal/useDispatchScrollPosition.js +1 -3
  615. package/src/hooks/internal/useDispatchTranscriptFocusByActivityKey.ts +5 -0
  616. package/src/hooks/internal/useFocusVisible.ts +22 -0
  617. package/src/hooks/internal/useMemoWithPrevious.ts +16 -0
  618. package/src/hooks/internal/useMemoize.spec.js +3 -1
  619. package/src/hooks/internal/useMemoize.ts +53 -0
  620. package/src/hooks/internal/useObserveFocusVisible.ts +252 -0
  621. package/src/hooks/internal/usePrevious.ts +12 -0
  622. package/src/hooks/internal/useResumeAudioContext.ts +7 -0
  623. package/src/hooks/internal/useScrollRelative.js +4 -3
  624. package/src/hooks/internal/useStateRef.ts +31 -0
  625. package/src/hooks/internal/{useUniqueId.js → useUniqueId.ts} +1 -1
  626. package/src/hooks/internal/useValueRef.ts +22 -0
  627. package/src/hooks/{useDictateAbortable.js → useDictateAbortable.ts} +1 -1
  628. package/src/hooks/{useFocus.js → useFocus.ts} +1 -1
  629. package/src/hooks/{useFocusSendBox.js → useFocusSendBox.ts} +2 -1
  630. package/src/hooks/{useObserveScrollPosition.js → useObserveScrollPosition.ts} +6 -1
  631. package/src/hooks/{useObserveTranscriptFocus.js → useObserveTranscriptFocus.ts} +6 -1
  632. package/src/hooks/useRenderMarkdownAsHTML.ts +23 -0
  633. package/src/hooks/{useScrollDown.js → useScrollDown.ts} +1 -1
  634. package/src/hooks/useScrollTo.ts +16 -0
  635. package/src/hooks/useScrollToEnd.ts +12 -0
  636. package/src/hooks/{useScrollUp.js → useScrollUp.ts} +1 -1
  637. package/src/hooks/{useSendFiles.js → useSendFiles.ts} +3 -2
  638. package/src/hooks/{useStyleSet.js → useStyleSet.ts} +1 -1
  639. package/src/hooks/useWebSpeechPonyfill.ts +7 -0
  640. package/src/index.ts +7 -12
  641. package/src/providers/ActivityTree/ActivityTreeComposer.tsx +74 -0
  642. package/src/providers/ActivityTree/private/Context.ts +12 -0
  643. package/src/providers/ActivityTree/private/types.ts +12 -0
  644. package/src/providers/ActivityTree/private/useActivitiesWithRenderer.ts +66 -0
  645. package/src/providers/ActivityTree/private/useActivityTreeWithRenderer.ts +140 -0
  646. package/src/providers/ActivityTree/private/useContext.ts +15 -0
  647. package/src/providers/ActivityTree/useActivityTreeWithRenderer.ts +16 -0
  648. package/src/providers/LiveRegionTwin/LiveRegionTwinComposer.tsx +154 -0
  649. package/src/providers/LiveRegionTwin/private/Context.ts +15 -0
  650. package/src/providers/LiveRegionTwin/private/LiveRegionTwinContainer.tsx +64 -0
  651. package/src/providers/LiveRegionTwin/private/types.ts +10 -0
  652. package/src/providers/LiveRegionTwin/private/useContext.ts +15 -0
  653. package/src/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.ts +13 -0
  654. package/src/providers/LiveRegionTwin/private/useStaticElementEntries.ts +7 -0
  655. package/src/providers/LiveRegionTwin/useQueueStaticElement.ts +12 -0
  656. package/src/providers/TranscriptFocus/TranscriptFocusComposer.tsx +180 -0
  657. package/src/providers/TranscriptFocus/private/Context.ts +16 -0
  658. package/src/providers/TranscriptFocus/private/useContext.ts +13 -0
  659. package/src/providers/TranscriptFocus/useActiveDescendantId.ts +5 -0
  660. package/src/providers/TranscriptFocus/useFocusByActivityKey.ts +14 -0
  661. package/src/providers/TranscriptFocus/useFocusRelativeActivity.ts +5 -0
  662. package/src/providers/TranscriptFocus/useFocusedActivityKey.ts +5 -0
  663. package/src/providers/TranscriptFocus/useFocusedExplicitly.ts +5 -0
  664. package/src/providers/TranscriptFocus/useGetDescendantIdByActivityKey.ts +5 -0
  665. package/src/tsconfig.json +1 -1
  666. package/src/types/ScrollPosition.ts +6 -0
  667. package/.eslintignore +0 -9
  668. package/lib/Activity/ScrollToEndButton.js +0 -81
  669. package/lib/Attachment/Assets/ErrorIcon.js +0 -22
  670. package/lib/Utils/findLastIndex.js +0 -32
  671. package/lib/Utils/remarkStripMarkdown.js +0 -26
  672. package/lib/hooks/internal/useAcknowledgedActivity.js +0 -90
  673. package/lib/hooks/internal/useDispatchTranscriptFocus.js +0 -19
  674. package/lib/hooks/internal/useStripMarkdown.js +0 -19
  675. package/src/Activity/ScrollToEndButton.js +0 -58
  676. package/src/Attachment/Assets/ErrorIcon.js +0 -9
  677. package/src/BasicTranscript.js +0 -1123
  678. package/src/Middleware/Activity/createCoreMiddleware.js +0 -71
  679. package/src/Middleware/Attachment/createCoreMiddleware.js +0 -43
  680. package/src/Middleware/AttachmentForScreenReader/createCoreMiddleware.js +0 -37
  681. package/src/Middleware/Toast/createCoreMiddleware.js +0 -20
  682. package/src/Toast/createToastMiddleware.js +0 -11
  683. package/src/Utils/findLastIndex.js +0 -11
  684. package/src/Utils/findLastIndex.spec.js +0 -29
  685. package/src/Utils/getActivityUniqueId.js +0 -3
  686. package/src/Utils/intersectionOf.js +0 -11
  687. package/src/Utils/isZeroOrPositive.js +0 -4
  688. package/src/Utils/remarkStripMarkdown.js +0 -13
  689. package/src/hooks/internal/useAcknowledgedActivity.js +0 -65
  690. package/src/hooks/internal/useChanged.js +0 -10
  691. package/src/hooks/internal/useDispatchTranscriptFocus.js +0 -7
  692. package/src/hooks/internal/useMemoize.js +0 -37
  693. package/src/hooks/internal/useStripMarkdown.js +0 -7
  694. package/src/hooks/useRenderMarkdownAsHTML.js +0 -20
  695. package/src/hooks/useScrollTo.js +0 -11
  696. package/src/hooks/useScrollToEnd.js +0 -11
  697. package/src/hooks/useWebSpeechPonyfill.js +0 -5
  698. package/src/index.tsx +0 -35
@@ -0,0 +1,40 @@
1
+ import { AttachmentForScreenReaderMiddleware } from 'botframework-webchat-api';
2
+ import React from 'react';
3
+
4
+ import AudioAttachment from './AudioAttachment';
5
+ import FileAttachment from './FileAttachment';
6
+ import ImageAttachment from './ImageAttachment';
7
+ import TextAttachment from './TextAttachment';
8
+ import VideoAttachment from './VideoAttachment';
9
+
10
+ export default function createCoreMiddleware(): AttachmentForScreenReaderMiddleware[] {
11
+ return [
12
+ () =>
13
+ next =>
14
+ (...args) => {
15
+ const [
16
+ {
17
+ activity: { from: { role = undefined } = {} } = {},
18
+ attachment,
19
+ attachment: { contentType = undefined, contentUrl = undefined, thumbnailUrl = undefined } = {}
20
+ }
21
+ ] = args;
22
+
23
+ const isText = /^text\//u.test(contentType);
24
+
25
+ return (isText ? !attachment.content : role === 'user' && !thumbnailUrl)
26
+ ? () => <FileAttachment attachment={attachment} />
27
+ : /^audio\//u.test(contentType)
28
+ ? () => <AudioAttachment />
29
+ : /^image\//u.test(contentType)
30
+ ? () => <ImageAttachment />
31
+ : /^video\//u.test(contentType)
32
+ ? () => <VideoAttachment />
33
+ : contentUrl || contentType === 'application/octet-stream'
34
+ ? () => <FileAttachment attachment={attachment} />
35
+ : isText
36
+ ? () => <TextAttachment attachment={attachment} />
37
+ : next(...args);
38
+ }
39
+ ];
40
+ }
@@ -1,6 +1,7 @@
1
+ import { AvatarMiddleware } from 'botframework-webchat-api';
1
2
  import classNames from 'classnames';
2
3
  import PropTypes from 'prop-types';
3
- import React from 'react';
4
+ import React, { FC } from 'react';
4
5
 
5
6
  import ImageAvatar from '../../Avatar/ImageAvatar';
6
7
  import InitialsAvatar from '../../Avatar/InitialsAvatar';
@@ -18,7 +19,13 @@ const ROOT_STYLE = {
18
19
  }
19
20
  };
20
21
 
21
- const DefaultAvatar = ({ 'aria-hidden': ariaHidden, className, fromUser }) => {
22
+ type DefaultAvatarProps = {
23
+ 'aria-hidden'?: boolean;
24
+ className?: string;
25
+ fromUser: boolean;
26
+ };
27
+
28
+ const DefaultAvatar: FC<DefaultAvatarProps> = ({ 'aria-hidden': ariaHidden, className, fromUser }) => {
22
29
  const [{ avatar: avatarStyleSet }] = useStyleSet();
23
30
  const rootClassName = useStyleToEmotionObject()(ROOT_STYLE) + '';
24
31
 
@@ -50,18 +57,19 @@ DefaultAvatar.propTypes = {
50
57
  fromUser: PropTypes.bool.isRequired
51
58
  };
52
59
 
53
- export default function createCoreAvatarMiddleware() {
60
+ export default function createCoreAvatarMiddleware(): AvatarMiddleware[] {
54
61
  return [
55
- () => () => ({ fromUser, styleOptions }) => {
56
- const { botAvatarImage, botAvatarInitials, userAvatarImage, userAvatarInitials } = styleOptions;
62
+ () =>
63
+ () =>
64
+ ({ fromUser, styleOptions }) => {
65
+ const { botAvatarImage, botAvatarInitials, userAvatarImage, userAvatarInitials } = styleOptions;
57
66
 
58
- if (fromUser ? userAvatarImage || userAvatarInitials : botAvatarImage || botAvatarInitials) {
59
- // eslint-disable-next-line react/display-name
60
- return () => <DefaultAvatar fromUser={fromUser} />;
61
- }
67
+ if (fromUser ? userAvatarImage || userAvatarInitials : botAvatarImage || botAvatarInitials) {
68
+ return () => <DefaultAvatar fromUser={fromUser} />;
69
+ }
62
70
 
63
- return false;
64
- }
71
+ return false;
72
+ }
65
73
  ];
66
74
  }
67
75
 
@@ -2,7 +2,7 @@ import { ie11 } from '../../Utils/detectBrowser';
2
2
 
3
3
  // This code is adopted from sanitize-html/naughtyScheme.
4
4
  // sanitize-html is a dependency of Web Chat but the naughtScheme function is neither exposed nor reusable.
5
- // https://github.com/apostrophecms/sanitize-html/blob/master/src/index.js#L526
5
+ // https://github.com/apostrophecms/sanitize-html/
6
6
  function getScheme(href) {
7
7
  // Browsers ignore character codes of 32 (space) and below in a surprising
8
8
  // number of situations. Start reading here:
@@ -31,55 +31,64 @@ const ALLOWED_SCHEMES = ['data', 'http', 'https', 'ftp', 'mailto', 'sip', 'tel']
31
31
 
32
32
  export default function createDefaultCardActionMiddleware() {
33
33
  return [
34
- () => next => (...args) => {
35
- const [
36
- {
37
- cardAction: { type, value },
38
- getSignInUrl
39
- }
40
- ] = args;
41
-
42
- switch (type) {
43
- case 'call':
44
- case 'downloadFile':
45
- case 'openUrl':
46
- case 'playAudio':
47
- case 'playVideo':
48
- case 'showImage':
49
- if (ALLOWED_SCHEMES.includes(getScheme(value))) {
50
- if (ie11) {
51
- const newWindow = window.open();
52
- newWindow.opener = null;
53
- newWindow.location = value;
34
+ () =>
35
+ next =>
36
+ (...args) => {
37
+ const [
38
+ {
39
+ cardAction: { type, value },
40
+ getSignInUrl
41
+ }
42
+ ] = args;
43
+
44
+ switch (type) {
45
+ case 'call':
46
+ case 'downloadFile':
47
+ case 'openUrl':
48
+ case 'playAudio':
49
+ case 'playVideo':
50
+ case 'showImage':
51
+ if (ALLOWED_SCHEMES.includes(getScheme(value))) {
52
+ if (ie11) {
53
+ const newWindow = window.open();
54
+ newWindow.opener = null;
55
+ newWindow.location = value;
56
+ } else {
57
+ // False alarm: this is "window.open", and not "fs.open".
58
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
59
+ window.open(value, '_blank', 'noopener noreferrer');
60
+ }
54
61
  } else {
55
- window.open(value, '_blank', 'noopener noreferrer');
62
+ console.warn('botframework-webchat: Cannot open URL with disallowed schemes.', value);
56
63
  }
57
- } else {
58
- console.warn('botframework-webchat: Cannot open URL with disallowed schemes.', value);
59
- }
60
64
 
61
- break;
65
+ break;
62
66
 
63
- case 'signin': {
64
- /**
65
- * @todo TODO: [P3] We should prime the URL into the OAuthCard directly, instead of calling getSessionId on-demand
66
- * This is to eliminate the delay between window.open() and location.href call
67
- */
67
+ case 'signin': {
68
+ /**
69
+ * @todo TODO: [P3] We should prime the URL into the OAuthCard directly, instead of calling getSessionId on-demand
70
+ * This is to eliminate the delay between window.open() and location.href call
71
+ */
68
72
 
69
- // eslint-disable-next-line wrap-iife
70
- (async function () {
71
- const popup = window.open();
72
- const url = await getSignInUrl();
73
+ (async function () {
74
+ const popup = window.open();
75
+ const url = await getSignInUrl();
73
76
 
74
- popup.location.href = url;
75
- })();
77
+ if (['http', 'https'].includes(getScheme(url))) {
78
+ popup.location.href = url;
79
+ } else {
80
+ console.warn('botframework-webchat: Cannot open URL with disallowed schemes.', url);
76
81
 
77
- break;
78
- }
82
+ popup.close();
83
+ }
84
+ })();
85
+
86
+ break;
87
+ }
79
88
 
80
- default:
81
- return next(...args);
89
+ default:
90
+ return next(...args);
91
+ }
82
92
  }
83
- }
84
93
  ];
85
94
  }
@@ -48,8 +48,10 @@ function shouldGroupTimestamp(activityX, activityY, groupTimestamp) {
48
48
  }
49
49
 
50
50
  export default function createDefaultGroupActivityMiddleware({ groupTimestamp }) {
51
- return () => () => ({ activities }) => ({
52
- sender: bin(activities, (x, y) => x.from.role === y.from.role),
53
- status: bin(activities, (x, y) => shouldGroupTimestamp(x, y, groupTimestamp))
54
- });
51
+ return () =>
52
+ () =>
53
+ ({ activities }) => ({
54
+ sender: bin(activities, (x, y) => x.from.role === y.from.role),
55
+ status: bin(activities, (x, y) => shouldGroupTimestamp(x, y, groupTimestamp))
56
+ });
55
57
  }
@@ -0,0 +1,45 @@
1
+ import { hooks } from 'botframework-webchat-api';
2
+ import classNames from 'classnames';
3
+ import PropTypes from 'prop-types';
4
+ import React from 'react';
5
+
6
+ import useStyleSet from '../../hooks/useStyleSet';
7
+
8
+ const { useDirection, useLocalizer, useStyleOptions } = hooks;
9
+
10
+ const ScrollToEndButton = ({ onClick }) => {
11
+ const [{ scrollToEndButton: scrollToEndButtonStyleSet }] = useStyleSet();
12
+ const [{ scrollToEndButtonBehavior }] = useStyleOptions();
13
+ const [direction] = useDirection();
14
+ const localize = useLocalizer();
15
+
16
+ const text = localize(scrollToEndButtonBehavior === 'any' ? 'TRANSCRIPT_MORE_MESSAGES' : 'TRANSCRIPT_NEW_MESSAGES');
17
+
18
+ return (
19
+ <button
20
+ aria-label={text}
21
+ className={classNames(
22
+ 'webchat__scroll-to-end-button',
23
+ scrollToEndButtonStyleSet + '',
24
+ direction === 'rtl' ? 'webchat__scroll-to-end-button--rtl' : ''
25
+ )}
26
+ onClick={onClick}
27
+ tabIndex={0}
28
+ type="button"
29
+ >
30
+ {text}
31
+ </button>
32
+ );
33
+ };
34
+
35
+ ScrollToEndButton.defaultProps = {
36
+ onClick: undefined
37
+ };
38
+
39
+ ScrollToEndButton.displayName = 'ScrollToEndButton';
40
+
41
+ ScrollToEndButton.propTypes = {
42
+ onClick: PropTypes.func
43
+ };
44
+
45
+ export default ScrollToEndButton;
@@ -0,0 +1,19 @@
1
+ import { ScrollToEndButtonMiddleware } from 'botframework-webchat-api';
2
+
3
+ import ScrollToEndButton from './ScrollToEndButton';
4
+
5
+ export default function createScrollToEndButtonMiddleware(): ScrollToEndButtonMiddleware[] {
6
+ return [
7
+ () =>
8
+ () =>
9
+ ({ atEnd, styleOptions: { scrollToEndButtonBehavior }, unread }) =>
10
+ !scrollToEndButtonBehavior
11
+ ? // Don't show the button when it is set to false.
12
+ false
13
+ : scrollToEndButtonBehavior === 'any'
14
+ ? // Show when the scroll view is not at the end, regardless of number of unread activities.
15
+ !atEnd && ScrollToEndButton
16
+ : // Show when the scroll view is not at the end of the transcript, and there are new/unread activities.
17
+ !atEnd && unread && ScrollToEndButton
18
+ ];
19
+ }
@@ -0,0 +1,24 @@
1
+ import { ToastMiddleware } from 'botframework-webchat-api';
2
+
3
+ import createToastMiddleware from '../../Toast/createToastMiddleware';
4
+
5
+ function createCoreMiddleware(): ToastMiddleware[] {
6
+ return [
7
+ () =>
8
+ next =>
9
+ (...args) => {
10
+ const [
11
+ {
12
+ notification: { id }
13
+ }
14
+ ] = args;
15
+
16
+ // We are ignoring "connectivitystatus" notifications, we will render it using <BasicConnectivityStatus> instead.
17
+ // If devs want to render it, they can add a middleware.
18
+ return id !== 'connectivitystatus' && next(...args);
19
+ },
20
+ createToastMiddleware()
21
+ ];
22
+ }
23
+
24
+ export default createCoreMiddleware;
@@ -1,6 +1,4 @@
1
- /* eslint react/prop-types: "off"*/
2
-
3
- import { hooks } from 'botframework-webchat-api';
1
+ import { hooks, TypingIndicatorMiddleware } from 'botframework-webchat-api';
4
2
  import classNames from 'classnames';
5
3
  import React from 'react';
6
4
 
@@ -22,6 +20,13 @@ const DotIndicator = () => {
22
20
  };
23
21
 
24
22
  // TODO: [P4] Rename this file or the whole middleware, it looks either too simple or too comprehensive now
25
- export default function createCoreMiddleware() {
26
- return [() => () => ({ visible }) => visible && <DotIndicator />];
23
+ export default function createCoreMiddleware(): TypingIndicatorMiddleware[] {
24
+ return [
25
+ () =>
26
+ () =>
27
+ // This is not a React component.
28
+ // eslint-disable-next-line react/prop-types
29
+ ({ visible }) =>
30
+ visible && <DotIndicator />
31
+ ];
27
32
  }
@@ -1,8 +1,8 @@
1
1
  import PropTypes from 'prop-types';
2
- import React from 'react';
2
+ import React, { VFC } from 'react';
3
3
 
4
4
  import BasicWebChat from './BasicWebChat';
5
- import Composer from './Composer';
5
+ import Composer, { ComposerProps } from './Composer';
6
6
 
7
7
  // Please keep this file as simple as possible. This is for setting up the surface (a.k.a. <Composer>) and <BasicWebChat> only.
8
8
 
@@ -12,22 +12,40 @@ import Composer from './Composer';
12
12
  // - They can run hooks outside of activity/attachment middleware
13
13
  // - They will put <Composer> as very top of their page, and allow buttons on their existing page to send message to bot
14
14
 
15
- const ReactWebChat = ({ className, role, ...composerProps }) => (
15
+ // Subset of landmark roles: https://w3.org/TR/wai-aria/#landmark_roles
16
+ const ARIA_LANDMARK_ROLES = ['complementary', 'contentinfo', 'form', 'main', 'region'];
17
+
18
+ type ReactWebChatProps = Omit<ComposerProps, 'children'> & {
19
+ className?: string;
20
+ role?: 'complementary' | 'contentinfo' | 'form' | 'main' | 'region';
21
+ };
22
+
23
+ const ReactWebChat: VFC<ReactWebChatProps> = ({ className, role, ...composerProps }) => (
16
24
  <Composer {...composerProps}>
17
25
  <BasicWebChat className={className} role={role} />
18
26
  </Composer>
19
27
  );
20
28
 
21
- export default ReactWebChat;
22
-
23
29
  ReactWebChat.defaultProps = {
24
30
  className: undefined,
25
31
  role: undefined,
26
32
  ...Composer.defaultProps
27
33
  };
28
34
 
35
+ const {
36
+ // Excluding "children" from ComposerProps.
37
+ children: _,
38
+ ...composerPropTypesWithoutChildren
39
+ } = Composer.propTypes;
40
+
29
41
  ReactWebChat.propTypes = {
30
42
  className: PropTypes.string,
31
- role: PropTypes.string,
32
- ...Composer.propTypes
43
+ // Ignoring deficiencies with TypeScript/PropTypes inference.
44
+ // @ts-ignore
45
+ role: PropTypes.oneOf(ARIA_LANDMARK_ROLES),
46
+ ...composerPropTypesWithoutChildren
33
47
  };
48
+
49
+ export default ReactWebChat;
50
+
51
+ export type { ReactWebChatProps };
@@ -3,13 +3,19 @@
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
- const { useAvatarForBot, useCreateAttachmentForScreenReaderRenderer, useDateFormatter, useLocalizer } = hooks;
12
+ const {
13
+ useAvatarForBot,
14
+ useCreateAttachmentForScreenReaderRenderer,
15
+ useDateFormatter,
16
+ useGetKeyByActivity,
17
+ useLocalizer
18
+ } = hooks;
13
19
 
14
20
  const ROOT_STYLE = {
15
21
  '&.webchat__screen-reader-activity': {
@@ -32,70 +38,89 @@ const ACTIVITY_NUM_ATTACHMENTS_ALT_IDS = {
32
38
  two: 'ACTIVITY_NUM_ATTACHMENTS_TWO_ALT'
33
39
  };
34
40
 
41
+ const ScreenReaderAttachments = ({ activity, renderAttachments }) => {
42
+ const { attachments = [] } = activity;
43
+ const createAttachmentForScreenReaderRenderer = useCreateAttachmentForScreenReaderRenderer();
44
+ const localizeWithPlural = useLocalizer({ plural: true });
45
+
46
+ const attachmentForScreenReaderRenderers = renderAttachments
47
+ ? attachments
48
+ .map(attachment => createAttachmentForScreenReaderRenderer({ activity, attachment }))
49
+ .filter(render => render)
50
+ : [];
51
+
52
+ const numGenericAttachments = attachments.length - attachmentForScreenReaderRenderers.length;
53
+
54
+ const numAttachmentsAlt =
55
+ !!numGenericAttachments && localizeWithPlural(ACTIVITY_NUM_ATTACHMENTS_ALT_IDS, numGenericAttachments);
56
+
57
+ return (
58
+ <Fragment>
59
+ {!!attachmentForScreenReaderRenderers.length && (
60
+ <ul>
61
+ {attachmentForScreenReaderRenderers.map((render, index) => (
62
+ // eslint-disable-next-line react/no-array-index-key
63
+ <li key={index}>{render()}</li>
64
+ ))}
65
+ </ul>
66
+ )}
67
+ {numAttachmentsAlt && <p>{numAttachmentsAlt}</p>}
68
+ </Fragment>
69
+ );
70
+ };
71
+
72
+ ScreenReaderAttachments.propTypes = {
73
+ activity: PropTypes.shape({
74
+ attachments: PropTypes.array
75
+ }).isRequired,
76
+ renderAttachments: PropTypes.bool.isRequired
77
+ };
78
+
35
79
  // When "renderAttachments" is false, we will not render the content of attachments.
36
80
  // That means, it will only render "2 attachments", instead of "image attachment".
37
81
  // This is used in the visual transcript, where we render "Press ENTER to interact."
38
82
  const ScreenReaderActivity = ({ activity, children, id, renderAttachments }) => {
39
83
  const [{ initials: botInitials }] = useAvatarForBot();
40
- const createAttachmentForScreenReaderRenderer = useCreateAttachmentForScreenReaderRenderer();
41
84
  const formatDate = useDateFormatter();
85
+ const getKeyByActivity = useGetKeyByActivity();
42
86
  const localize = useLocalizer();
43
- const localizeWithPlural = useLocalizer({ plural: true });
87
+ const renderMarkdownAsHTML = useRenderMarkdownAsHTML();
44
88
  const rootClassName = useStyleToEmotionObject()(ROOT_STYLE) + '';
89
+ const textAlt = useMemo(() => activityAltText(activity, renderMarkdownAsHTML), [activity, renderMarkdownAsHTML]);
45
90
 
46
- const {
47
- attachments = [],
48
- channelData: { messageBack: { displayText: messageBackDisplayText } = {} } = {},
49
- from: { role } = {},
50
- text,
51
- textFormat,
52
- timestamp
53
- } = activity;
91
+ const { channelData: { 'webchat:fallback-text': fallbackText } = {}, from: { role } = {}, timestamp } = activity;
54
92
 
55
93
  const fromUser = role === 'user';
56
- const contentTypeMarkdown = textFormatToContentType(textFormat) === 'text/markdown';
57
- const displayText = messageBackDisplayText || text;
58
94
 
59
- const attachmentForScreenReaderRenderers = renderAttachments
60
- ? attachments
61
- .map(attachment => createAttachmentForScreenReaderRenderer({ activity, attachment }))
62
- .filter(render => render)
63
- : [];
64
-
65
- const greetingAlt = (fromUser
66
- ? localize('ACTIVITY_YOU_SAID_ALT')
67
- : localize('ACTIVITY_BOT_SAID_ALT', botInitials || '')
95
+ const greetingAlt = (
96
+ fromUser ? localize('ACTIVITY_YOU_SAID_ALT') : localize('ACTIVITY_BOT_SAID_ALT', botInitials || '')
68
97
  ).replace(/\s{2,}/gu, ' ');
69
- const numGenericAttachments = attachments.length - attachmentForScreenReaderRenderers.length;
70
98
 
71
- const numAttachmentsAlt =
72
- !!numGenericAttachments && localizeWithPlural(ACTIVITY_NUM_ATTACHMENTS_ALT_IDS, numGenericAttachments);
73
- const textAlt = useStripMarkdown(contentTypeMarkdown && displayText) || displayText;
74
99
  const timestampAlt = localize('ACTIVITY_STATUS_SEND_STATUS_ALT_SENT_AT', formatDate(timestamp));
100
+ const labelId = useMemo(
101
+ () => `webchat__screen-reader-activity__label-${getKeyByActivity(activity)}`,
102
+ [activity, getKeyByActivity]
103
+ );
75
104
 
76
105
  return (
77
106
  <article
78
107
  aria-atomic={true}
108
+ // Narrator requires the "aria-labelledby" attribute, otherwise, it will only read "aria-roledescription".
109
+ // However, iOS VoiceOver and NVDA both ignore the "aria-labelledby" and read out the whole content, including timestamp.
110
+ aria-labelledby={labelId}
79
111
  aria-roledescription="message"
80
112
  className={classNames('webchat__screen-reader-activity', rootClassName)}
81
113
  // "id" attribute is used by `aria-labelledby`.
82
114
  // eslint-disable-next-line react/forbid-dom-props
83
115
  id={id}
84
- role="region"
85
116
  >
86
- <p>
117
+ {/* "id" attribute is used by `aria-labelledby`. */}
118
+ {/* eslint-disable-next-line react/forbid-dom-props */}
119
+ <p id={labelId}>
87
120
  <span>{greetingAlt}</span>
88
121
  <span>{textAlt}</span>
89
122
  </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>}
123
+ {!fallbackText && <ScreenReaderAttachments activity={activity} renderAttachments={renderAttachments} />}
99
124
  <p className="webchat__screen-reader-activity__timestamp">{timestampAlt}</p>
100
125
  {children}
101
126
  </article>
@@ -1,7 +1,9 @@
1
1
  /* eslint react/forbid-dom-props: ["off"] */
2
2
 
3
3
  import PropTypes from 'prop-types';
4
- import React from 'react';
4
+ import React, { forwardRef } from 'react';
5
+
6
+ import type { VFC } from 'react';
5
7
 
6
8
  import useStyleToEmotionObject from './hooks/internal/useStyleToEmotionObject';
7
9
 
@@ -21,21 +23,37 @@ const ROOT_STYLE = {
21
23
  width: 1
22
24
  };
23
25
 
24
- const ScreenReaderText = ({ id, text }) => {
25
- const rootClassName = useStyleToEmotionObject()(ROOT_STYLE) + '';
26
-
27
- return (
28
- <div className={rootClassName} id={id}>
29
- {text}
30
- </div>
31
- );
26
+ type ScreenReaderTextProps = {
27
+ 'aria-hidden'?: boolean;
28
+ id?: string;
29
+ text: string;
32
30
  };
33
31
 
32
+ const ScreenReaderText: VFC<ScreenReaderTextProps> = forwardRef<HTMLDivElement, ScreenReaderTextProps>(
33
+ ({ 'aria-hidden': ariaHidden, id, text }, ref) => {
34
+ const rootClassName = useStyleToEmotionObject()(ROOT_STYLE) + '';
35
+
36
+ if (ariaHidden && !id) {
37
+ console.warn(
38
+ 'botframework-webchat assertion: when "aria-hidden" is set, the screen reader text should be read by "aria-labelledby". Thus, "id" must be set.'
39
+ );
40
+ }
41
+
42
+ return (
43
+ <div aria-hidden={ariaHidden} className={rootClassName} id={id} ref={ref}>
44
+ {text}
45
+ </div>
46
+ );
47
+ }
48
+ );
49
+
34
50
  ScreenReaderText.defaultProps = {
51
+ 'aria-hidden': undefined,
35
52
  id: undefined
36
53
  };
37
54
 
38
55
  ScreenReaderText.propTypes = {
56
+ 'aria-hidden': PropTypes.bool,
39
57
  id: PropTypes.string,
40
58
  text: PropTypes.string.isRequired
41
59
  };
@@ -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"