botframework-webchat-component 4.14.1 → 4.15.2-main.20220413.af6e8a3

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 (411) hide show
  1. package/.eslintrc.yml +4 -106
  2. package/.prettierrc.yml +1 -1
  3. package/lib/Activity/CarouselFilmStrip.js +1 -1
  4. package/lib/Activity/CarouselFilmStripAttachment.js +1 -1
  5. package/lib/Activity/CarouselLayout.js +3 -3
  6. package/lib/Activity/Speak.d.ts +2 -2
  7. package/lib/Activity/Speak.d.ts.map +1 -1
  8. package/lib/Activity/Speak.js +15 -8
  9. package/lib/Activity/StackedLayout.d.ts +5 -3
  10. package/lib/Activity/StackedLayout.d.ts.map +1 -1
  11. package/lib/Activity/StackedLayout.js +16 -21
  12. package/lib/Attachment/FileAttachment.js +2 -2
  13. package/lib/Attachment/FileContent.d.ts.map +1 -1
  14. package/lib/Attachment/FileContent.js +11 -1
  15. package/lib/BasicSendBox.d.ts.map +1 -1
  16. package/lib/BasicSendBox.js +8 -9
  17. package/lib/BasicToast.js +1 -1
  18. package/lib/BasicToaster.js +6 -3
  19. package/lib/BasicTranscript.d.ts +7 -0
  20. package/lib/BasicTranscript.d.ts.map +1 -0
  21. package/lib/BasicTranscript.js +386 -728
  22. package/lib/BasicTypingIndicator.d.ts +2 -1
  23. package/lib/BasicTypingIndicator.d.ts.map +1 -1
  24. package/lib/BasicTypingIndicator.js +12 -4
  25. package/lib/Composer.d.ts.map +1 -1
  26. package/lib/Composer.js +37 -32
  27. package/lib/ConnectivityStatus/Connecting.js +1 -1
  28. package/lib/Dictation.js +1 -1
  29. package/lib/Middleware/Activity/createCoreMiddleware.d.ts.map +1 -1
  30. package/lib/Middleware/Activity/createCoreMiddleware.js +9 -12
  31. package/lib/Middleware/ActivityStatus/SendStatus/SendFailedRetry.js +1 -1
  32. package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.d.ts +2 -2
  33. package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.d.ts.map +1 -1
  34. package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.js +5 -4
  35. package/lib/Middleware/ActivityStatus/Timestamp.d.ts +2 -2
  36. package/lib/Middleware/ActivityStatus/Timestamp.d.ts.map +1 -1
  37. package/lib/Middleware/ActivityStatus/Timestamp.js +4 -2
  38. package/lib/Middleware/ActivityStatus/createSendStatusMiddleware.js +20 -17
  39. package/lib/Middleware/Attachment/createCoreMiddleware.js +2 -5
  40. package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.d.ts.map +1 -1
  41. package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.js +1 -1
  42. package/lib/Middleware/Avatar/createCoreMiddleware.d.ts.map +1 -1
  43. package/lib/Middleware/Avatar/createCoreMiddleware.js +2 -3
  44. package/lib/Middleware/CardAction/createCoreMiddleware.js +10 -3
  45. package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.d.ts.map +1 -1
  46. package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.js +1 -1
  47. package/lib/Middleware/Toast/createCoreMiddleware.d.ts.map +1 -1
  48. package/lib/Middleware/Toast/createCoreMiddleware.js +1 -1
  49. package/lib/Middleware/TypingIndicator/createCoreMiddleware.d.ts.map +1 -1
  50. package/lib/Middleware/TypingIndicator/createCoreMiddleware.js +8 -6
  51. package/lib/ReactWebChat.js +2 -2
  52. package/lib/ScreenReaderActivity.js +15 -6
  53. package/lib/ScreenReaderText.d.ts +9 -0
  54. package/lib/ScreenReaderText.d.ts.map +1 -0
  55. package/lib/ScreenReaderText.js +22 -8
  56. package/lib/SendBox/AutoResizeTextArea.js +1 -1
  57. package/lib/SendBox/DictationInterims.js +1 -1
  58. package/lib/SendBox/IconButton.d.ts +11 -0
  59. package/lib/SendBox/IconButton.d.ts.map +1 -0
  60. package/lib/SendBox/IconButton.js +26 -6
  61. package/lib/SendBox/MicrophoneButton.js +2 -2
  62. package/lib/SendBox/SendButton.js +2 -2
  63. package/lib/SendBox/SuggestedAction.d.ts +17 -0
  64. package/lib/SendBox/SuggestedAction.d.ts.map +1 -0
  65. package/lib/SendBox/SuggestedAction.js +26 -17
  66. package/lib/SendBox/SuggestedActions.d.ts.map +1 -1
  67. package/lib/SendBox/SuggestedActions.js +26 -9
  68. package/lib/SendBox/TextBox.js +4 -4
  69. package/lib/SendBox/UploadButton.js +4 -4
  70. package/lib/Styles/StyleSet/BasicTranscript.d.ts +13 -5
  71. package/lib/Styles/StyleSet/BasicTranscript.d.ts.map +1 -1
  72. package/lib/Styles/StyleSet/BasicTranscript.js +21 -9
  73. package/lib/Styles/StyleSet/Bubble.d.ts.map +1 -1
  74. package/lib/Styles/StyleSet/Bubble.js +3 -3
  75. package/lib/Styles/StyleSet/CarouselFilmStrip.d.ts.map +1 -1
  76. package/lib/Styles/StyleSet/CarouselFilmStrip.js +3 -3
  77. package/lib/Styles/StyleSet/CarouselFilmStripAttachment.d.ts.map +1 -1
  78. package/lib/Styles/StyleSet/CarouselFilmStripAttachment.js +3 -3
  79. package/lib/Styles/StyleSet/KeyboardHelp.d.ts +123 -0
  80. package/lib/Styles/StyleSet/KeyboardHelp.d.ts.map +1 -0
  81. package/lib/Styles/StyleSet/KeyboardHelp.js +145 -0
  82. package/lib/Styles/StyleSet/ScrollToEndButton.d.ts +1 -1
  83. package/lib/Styles/StyleSet/ScrollToEndButton.js +2 -2
  84. package/lib/Styles/StyleSet/SendBoxButton.d.ts +56 -10
  85. package/lib/Styles/StyleSet/SendBoxButton.d.ts.map +1 -1
  86. package/lib/Styles/StyleSet/SendBoxButton.js +76 -12
  87. package/lib/Styles/StyleSet/SendBoxTextBox.d.ts +1 -1
  88. package/lib/Styles/StyleSet/SendBoxTextBox.d.ts.map +1 -1
  89. package/lib/Styles/StyleSet/SendBoxTextBox.js +3 -3
  90. package/lib/Styles/StyleSet/StackedLayout.d.ts.map +1 -1
  91. package/lib/Styles/StyleSet/StackedLayout.js +1 -1
  92. package/lib/Styles/StyleSet/SuggestedAction.d.ts +73 -28
  93. package/lib/Styles/StyleSet/SuggestedAction.d.ts.map +1 -1
  94. package/lib/Styles/StyleSet/SuggestedAction.js +116 -41
  95. package/lib/Styles/StyleSet/SuggestedActions.d.ts +13 -6
  96. package/lib/Styles/StyleSet/SuggestedActions.d.ts.map +1 -1
  97. package/lib/Styles/StyleSet/SuggestedActions.js +13 -6
  98. package/lib/Styles/createStyleSet.d.ts +324 -55
  99. package/lib/Styles/createStyleSet.d.ts.map +1 -1
  100. package/lib/Styles/createStyleSet.js +6 -3
  101. package/lib/Styles/mirrorStyle.js +12 -3
  102. package/lib/Toast/NotificationIcon.js +7 -3
  103. package/lib/Toast/createToastMiddleware.d.ts.map +1 -1
  104. package/lib/Toast/createToastMiddleware.js +1 -1
  105. package/lib/Transcript/ActivityRow.d.ts +9 -0
  106. package/lib/Transcript/ActivityRow.d.ts.map +1 -0
  107. package/lib/Transcript/ActivityRow.js +159 -0
  108. package/lib/Transcript/ActivityTextAlt.js +57 -0
  109. package/lib/Transcript/FocusTrap.d.ts +8 -0
  110. package/lib/Transcript/FocusTrap.d.ts.map +1 -0
  111. package/lib/Transcript/FocusTrap.js +74 -0
  112. package/lib/Transcript/KeyboardHelp.d.ts +4 -0
  113. package/lib/Transcript/KeyboardHelp.d.ts.map +1 -0
  114. package/lib/Transcript/KeyboardHelp.js +550 -0
  115. package/lib/Transcript/LiveRegionTranscript.d.ts +8 -0
  116. package/lib/Transcript/LiveRegionTranscript.d.ts.map +1 -0
  117. package/lib/Transcript/LiveRegionTranscript.js +229 -0
  118. package/lib/Transcript/types.d.ts +2 -0
  119. package/lib/Transcript/types.d.ts.map +1 -0
  120. package/lib/Transcript/types.js +2 -0
  121. package/lib/Transcript/useActivityAccessibleName.d.ts +4 -0
  122. package/lib/Transcript/useActivityAccessibleName.d.ts.map +1 -0
  123. package/lib/Transcript/useActivityAccessibleName.js +97 -0
  124. package/lib/Transcript/useTypistNames.d.ts +3 -0
  125. package/lib/Transcript/useTypistNames.d.ts.map +1 -0
  126. package/lib/Transcript/useTypistNames.js +61 -0
  127. package/lib/Utils/AccessKeySink/Surface.js +1 -1
  128. package/lib/Utils/AccessibleButton.d.ts +11 -0
  129. package/lib/Utils/AccessibleButton.d.ts.map +1 -0
  130. package/lib/Utils/AccessibleButton.js +12 -7
  131. package/lib/Utils/AccessibleInputText.js +1 -1
  132. package/lib/Utils/AccessibleTextArea.js +1 -1
  133. package/lib/Utils/CroppedImage.js +1 -1
  134. package/lib/Utils/FocusRedirector.d.ts +9 -0
  135. package/lib/Utils/FocusRedirector.d.ts.map +1 -0
  136. package/lib/Utils/FocusRedirector.js +17 -14
  137. package/lib/Utils/InlineMarkdown.js +15 -8
  138. package/lib/Utils/TypeFocusSink/FocusBox.js +1 -1
  139. package/lib/Utils/TypeFocusSink/inputtableKey.d.ts +2 -0
  140. package/lib/Utils/TypeFocusSink/inputtableKey.d.ts.map +1 -0
  141. package/lib/Utils/TypeFocusSink/inputtableKey.js +5 -2
  142. package/lib/Utils/activityAltText.d.ts +8 -0
  143. package/lib/Utils/activityAltText.d.ts.map +1 -0
  144. package/lib/Utils/addTargetBlankToHyperlinksMarkdown.js +2 -2
  145. package/lib/Utils/createCustomEvent.js +8 -2
  146. package/lib/Utils/detectBrowser.js +4 -2
  147. package/lib/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingWorker.js +1 -1
  148. package/lib/Utils/downscaleImageToDataURL/index.js +1 -1
  149. package/lib/Utils/findAncestor.js +17 -0
  150. package/lib/Utils/getActivityUniqueId.js +4 -2
  151. package/lib/Utils/intersectionOf.d.ts +5 -0
  152. package/lib/Utils/intersectionOf.d.ts.map +1 -0
  153. package/lib/Utils/intersectionOf.js +17 -2
  154. package/lib/Utils/isZeroOrPositive.d.ts +5 -0
  155. package/lib/Utils/isZeroOrPositive.d.ts.map +1 -0
  156. package/lib/Utils/isZeroOrPositive.js +4 -1
  157. package/lib/Utils/mapMap.js +9 -2
  158. package/lib/Utils/readDataURIToBlob.js +1 -1
  159. package/lib/Utils/scrollIntoViewWithBlockNearest.d.ts +7 -0
  160. package/lib/Utils/scrollIntoViewWithBlockNearest.d.ts.map +1 -0
  161. package/lib/Utils/scrollIntoViewWithBlockNearest.js +48 -0
  162. package/lib/Utils/shallowEquals.js +7 -3
  163. package/lib/Utils/supportPseudoClass.d.ts +2 -0
  164. package/lib/Utils/supportPseudoClass.d.ts.map +1 -0
  165. package/lib/Utils/supportPseudoClass.js +23 -0
  166. package/lib/Utils/tabbableElements.d.ts +2 -0
  167. package/lib/Utils/tabbableElements.d.ts.map +1 -0
  168. package/lib/Utils/tabbableElements.js +2 -2
  169. package/lib/connectToWebChat.js +15 -7
  170. package/lib/hooks/index.js +24 -24
  171. package/lib/hooks/internal/BypassSpeechSynthesisPonyfill.js +8 -7
  172. package/lib/hooks/internal/useChanged.js +8 -1
  173. package/lib/hooks/internal/useDispatchScrollPosition.js +3 -7
  174. package/lib/hooks/internal/useDispatchTranscriptFocusByActivityKey.d.ts +2 -0
  175. package/lib/hooks/internal/useDispatchTranscriptFocusByActivityKey.d.ts.map +1 -0
  176. package/lib/hooks/internal/useDispatchTranscriptFocusByActivityKey.js +15 -0
  177. package/lib/hooks/internal/useFocusVisible.d.ts +3 -0
  178. package/lib/hooks/internal/useFocusVisible.d.ts.map +1 -0
  179. package/lib/hooks/internal/useFocusVisible.js +48 -0
  180. package/lib/hooks/internal/useMemoWithPrevious.d.ts +3 -0
  181. package/lib/hooks/internal/useMemoWithPrevious.d.ts.map +1 -0
  182. package/lib/hooks/internal/useMemoWithPrevious.js +22 -0
  183. package/lib/hooks/internal/useMemoize.d.ts +14 -0
  184. package/lib/hooks/internal/useMemoize.d.ts.map +1 -0
  185. package/lib/hooks/internal/useMemoize.js +11 -2
  186. package/lib/hooks/internal/useObserveFocusVisible.d.ts +3 -0
  187. package/lib/hooks/internal/useObserveFocusVisible.d.ts.map +1 -0
  188. package/lib/hooks/internal/useObserveFocusVisible.js +208 -0
  189. package/lib/hooks/internal/usePrevious.d.ts +2 -0
  190. package/lib/hooks/internal/usePrevious.d.ts.map +1 -0
  191. package/lib/hooks/internal/usePrevious.js +18 -0
  192. package/lib/hooks/internal/useStateRef.d.ts +3 -0
  193. package/lib/hooks/internal/useStateRef.d.ts.map +1 -0
  194. package/lib/hooks/internal/useStateRef.js +40 -0
  195. package/lib/hooks/internal/useValueRef.d.ts +3 -0
  196. package/lib/hooks/internal/useValueRef.d.ts.map +1 -0
  197. package/lib/hooks/internal/useValueRef.js +25 -0
  198. package/lib/hooks/useFocus.d.ts +1 -1
  199. package/lib/hooks/useFocus.d.ts.map +1 -1
  200. package/lib/hooks/useFocus.js +1 -1
  201. package/lib/hooks/useObserveTranscriptFocus.d.ts +2 -2
  202. package/lib/hooks/useObserveTranscriptFocus.d.ts.map +1 -1
  203. package/lib/hooks/useObserveTranscriptFocus.js +1 -1
  204. package/lib/hooks/useRenderMarkdownAsHTML.d.ts.map +1 -1
  205. package/lib/hooks/useRenderMarkdownAsHTML.js +1 -1
  206. package/lib/hooks/useScrollTo.d.ts.map +1 -1
  207. package/lib/hooks/useScrollTo.js +1 -1
  208. package/lib/hooks/useScrollToEnd.d.ts.map +1 -1
  209. package/lib/hooks/useScrollToEnd.js +1 -1
  210. package/lib/hooks/useSendFiles.d.ts.map +1 -1
  211. package/lib/hooks/useSendFiles.js +4 -4
  212. package/lib/index.d.ts +13 -3
  213. package/lib/index.d.ts.map +1 -1
  214. package/lib/index.js +20 -18
  215. package/lib/providers/ActivityTree/ActivityTreeComposer.d.ts +5 -0
  216. package/lib/providers/ActivityTree/ActivityTreeComposer.d.ts.map +1 -0
  217. package/lib/providers/ActivityTree/ActivityTreeComposer.js +86 -0
  218. package/lib/providers/ActivityTree/private/Context.d.ts +9 -0
  219. package/lib/providers/ActivityTree/private/Context.d.ts.map +1 -0
  220. package/lib/providers/ActivityTree/private/Context.js +13 -0
  221. package/lib/providers/ActivityTree/private/types.d.ts +10 -0
  222. package/lib/providers/ActivityTree/private/types.d.ts.map +1 -0
  223. package/lib/providers/ActivityTree/private/types.js +2 -0
  224. package/lib/providers/ActivityTree/private/useActivitiesWithRenderer.d.ts +4 -0
  225. package/lib/providers/ActivityTree/private/useActivitiesWithRenderer.d.ts.map +1 -0
  226. package/lib/providers/ActivityTree/private/useActivitiesWithRenderer.js +58 -0
  227. package/lib/providers/ActivityTree/private/useActivityTreeWithRenderer.d.ts +5 -0
  228. package/lib/providers/ActivityTree/private/useActivityTreeWithRenderer.d.ts.map +1 -0
  229. package/lib/providers/ActivityTree/private/useActivityTreeWithRenderer.js +166 -0
  230. package/lib/providers/ActivityTree/private/useContext.d.ts +3 -0
  231. package/lib/providers/ActivityTree/private/useContext.d.ts.map +1 -0
  232. package/lib/providers/ActivityTree/private/useContext.js +24 -0
  233. package/lib/providers/ActivityTree/useActivityTreeWithRenderer.d.ts +8 -0
  234. package/lib/providers/ActivityTree/useActivityTreeWithRenderer.d.ts.map +1 -0
  235. package/lib/providers/ActivityTree/useActivityTreeWithRenderer.js +17 -0
  236. package/lib/providers/LiveRegionTwin/LiveRegionTwinComposer.d.ts +37 -0
  237. package/lib/providers/LiveRegionTwin/LiveRegionTwinComposer.d.ts.map +1 -0
  238. package/lib/providers/LiveRegionTwin/LiveRegionTwinComposer.js +160 -0
  239. package/lib/providers/LiveRegionTwin/private/Context.d.ts +10 -0
  240. package/lib/providers/LiveRegionTwin/private/Context.d.ts.map +1 -0
  241. package/lib/providers/LiveRegionTwin/private/Context.js +13 -0
  242. package/lib/providers/LiveRegionTwin/private/LiveRegionTwinContainer.d.ts +12 -0
  243. package/lib/providers/LiveRegionTwin/private/LiveRegionTwinContainer.d.ts.map +1 -0
  244. package/lib/providers/LiveRegionTwin/private/LiveRegionTwinContainer.js +100 -0
  245. package/lib/providers/LiveRegionTwin/private/types.d.ts +8 -0
  246. package/lib/providers/LiveRegionTwin/private/types.d.ts.map +1 -0
  247. package/lib/providers/LiveRegionTwin/private/types.js +2 -0
  248. package/lib/providers/LiveRegionTwin/private/useContext.d.ts +3 -0
  249. package/lib/providers/LiveRegionTwin/private/useContext.d.ts.map +1 -0
  250. package/lib/providers/LiveRegionTwin/private/useContext.js +24 -0
  251. package/lib/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.d.ts +2 -0
  252. package/lib/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.d.ts.map +1 -0
  253. package/lib/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.js +24 -0
  254. package/lib/providers/LiveRegionTwin/private/useStaticElementEntries.d.ts +3 -0
  255. package/lib/providers/LiveRegionTwin/private/useStaticElementEntries.d.ts.map +1 -0
  256. package/lib/providers/LiveRegionTwin/private/useStaticElementEntries.js +15 -0
  257. package/lib/providers/LiveRegionTwin/useQueueStaticElement.d.ts +8 -0
  258. package/lib/providers/LiveRegionTwin/useQueueStaticElement.d.ts.map +1 -0
  259. package/lib/providers/LiveRegionTwin/useQueueStaticElement.js +20 -0
  260. package/lib/providers/TranscriptFocus/TranscriptFocusComposer.d.ts +7 -0
  261. package/lib/providers/TranscriptFocus/TranscriptFocusComposer.d.ts.map +1 -0
  262. package/lib/providers/TranscriptFocus/TranscriptFocusComposer.js +184 -0
  263. package/lib/providers/TranscriptFocus/private/Context.d.ts +12 -0
  264. package/lib/providers/TranscriptFocus/private/Context.d.ts.map +1 -0
  265. package/lib/providers/TranscriptFocus/private/Context.js +13 -0
  266. package/lib/providers/TranscriptFocus/private/useContext.d.ts +2 -0
  267. package/lib/providers/TranscriptFocus/private/useContext.d.ts.map +1 -0
  268. package/lib/providers/TranscriptFocus/private/useContext.js +24 -0
  269. package/lib/providers/TranscriptFocus/useActiveDescendantId.d.ts +2 -0
  270. package/lib/providers/TranscriptFocus/useActiveDescendantId.d.ts.map +1 -0
  271. package/lib/providers/TranscriptFocus/useActiveDescendantId.js +15 -0
  272. package/lib/providers/TranscriptFocus/useFocusByActivityKey.d.ts +8 -0
  273. package/lib/providers/TranscriptFocus/useFocusByActivityKey.d.ts.map +1 -0
  274. package/lib/providers/TranscriptFocus/useFocusByActivityKey.js +21 -0
  275. package/lib/providers/TranscriptFocus/useFocusRelativeActivity.d.ts +2 -0
  276. package/lib/providers/TranscriptFocus/useFocusRelativeActivity.d.ts.map +1 -0
  277. package/lib/providers/TranscriptFocus/useFocusRelativeActivity.js +15 -0
  278. package/lib/providers/TranscriptFocus/useFocusedActivityKey.d.ts +2 -0
  279. package/lib/providers/TranscriptFocus/useFocusedActivityKey.d.ts.map +1 -0
  280. package/lib/providers/TranscriptFocus/useFocusedActivityKey.js +15 -0
  281. package/lib/providers/TranscriptFocus/useFocusedExplicitly.d.ts +2 -0
  282. package/lib/providers/TranscriptFocus/useFocusedExplicitly.d.ts.map +1 -0
  283. package/lib/providers/TranscriptFocus/useFocusedExplicitly.js +15 -0
  284. package/lib/providers/TranscriptFocus/useGetDescendantIdByActivityKey.d.ts +2 -0
  285. package/lib/providers/TranscriptFocus/useGetDescendantIdByActivityKey.d.ts.map +1 -0
  286. package/lib/providers/TranscriptFocus/useGetDescendantIdByActivityKey.js +15 -0
  287. package/package.json +30 -33
  288. package/src/Activity/CarouselFilmStripAttachment.js +0 -1
  289. package/src/Activity/Speak.tsx +21 -18
  290. package/src/Activity/StackedLayout.tsx +30 -35
  291. package/src/Attachment/FileAttachment.js +1 -1
  292. package/src/Attachment/FileContent.tsx +12 -0
  293. package/src/BasicSendBox.tsx +3 -2
  294. package/src/BasicToaster.js +5 -1
  295. package/src/BasicTranscript.tsx +894 -0
  296. package/src/BasicTypingIndicator.tsx +3 -2
  297. package/src/Composer.tsx +41 -29
  298. package/src/Middleware/Activity/createCoreMiddleware.tsx +47 -46
  299. package/src/Middleware/ActivityStatus/SendStatus/SendStatus.tsx +5 -3
  300. package/src/Middleware/ActivityStatus/Timestamp.tsx +5 -3
  301. package/src/Middleware/ActivityStatus/createSendStatusMiddleware.js +2 -0
  302. package/src/Middleware/Attachment/createCoreMiddleware.tsx +28 -28
  303. package/src/Middleware/AttachmentForScreenReader/createCoreMiddleware.tsx +25 -23
  304. package/src/Middleware/Avatar/createCoreMiddleware.tsx +9 -8
  305. package/src/Middleware/CardAction/createCoreMiddleware.js +9 -2
  306. package/src/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.ts +11 -9
  307. package/src/Middleware/Toast/createCoreMiddleware.tsx +12 -10
  308. package/src/Middleware/TypingIndicator/createCoreMiddleware.tsx +8 -2
  309. package/src/ScreenReaderActivity.js +18 -3
  310. package/src/{ScreenReaderText.js → ScreenReaderText.tsx} +27 -9
  311. package/src/SendBox/{IconButton.js → IconButton.tsx} +19 -3
  312. package/src/SendBox/{SuggestedAction.js → SuggestedAction.tsx} +72 -35
  313. package/src/SendBox/SuggestedActions.tsx +48 -21
  314. package/src/Styles/StyleSet/BasicTranscript.ts +34 -20
  315. package/src/Styles/StyleSet/Bubble.ts +0 -1
  316. package/src/Styles/StyleSet/CarouselFilmStrip.ts +12 -10
  317. package/src/Styles/StyleSet/CarouselFilmStripAttachment.ts +4 -3
  318. package/src/Styles/StyleSet/KeyboardHelp.ts +157 -0
  319. package/src/Styles/StyleSet/ScrollToEndButton.ts +1 -1
  320. package/src/Styles/StyleSet/SendBoxButton.ts +84 -13
  321. package/src/Styles/StyleSet/SendBoxTextBox.ts +1 -2
  322. package/src/Styles/StyleSet/StackedLayout.ts +13 -11
  323. package/src/Styles/StyleSet/SuggestedAction.ts +129 -42
  324. package/src/Styles/StyleSet/SuggestedActions.ts +13 -5
  325. package/src/Styles/createStyleSet.ts +2 -1
  326. package/src/Styles/mirrorStyle.js +10 -2
  327. package/src/Toast/NotificationIcon.js +4 -1
  328. package/src/Toast/createToastMiddleware.tsx +4 -1
  329. package/src/Transcript/ActivityRow.tsx +123 -0
  330. package/src/Transcript/ActivityTextAlt.tsx +31 -0
  331. package/src/Transcript/FocusTrap.tsx +64 -0
  332. package/src/Transcript/KeyboardHelp.tsx +282 -0
  333. package/src/Transcript/LiveRegionTranscript.tsx +196 -0
  334. package/src/Transcript/types.ts +1 -0
  335. package/src/Transcript/useActivityAccessibleName.ts +84 -0
  336. package/src/Transcript/useTypistNames.ts +37 -0
  337. package/src/Utils/{AccessibleButton.js → AccessibleButton.tsx} +19 -4
  338. package/src/Utils/{FocusRedirector.js → FocusRedirector.tsx} +21 -8
  339. package/src/Utils/InlineMarkdown.js +18 -2
  340. package/src/Utils/TypeFocusSink/inputtableKey.ts +5 -1
  341. package/src/Utils/createCustomEvent.js +7 -1
  342. package/src/Utils/detectBrowser.js +2 -1
  343. package/src/Utils/findAncestor.ts +12 -0
  344. package/src/Utils/getActivityUniqueId.ts +5 -0
  345. package/src/Utils/intersectionOf.ts +14 -0
  346. package/src/Utils/isZeroOrPositive.ts +7 -0
  347. package/src/Utils/mapMap.js +7 -1
  348. package/src/Utils/scrollIntoViewWithBlockNearest.ts +20 -0
  349. package/src/Utils/shallowEquals.js +8 -1
  350. package/src/Utils/supportPseudoClass.ts +17 -0
  351. package/src/Utils/{tabbableElements.js → tabbableElements.ts} +6 -5
  352. package/src/connectToWebChat.js +11 -4
  353. package/src/hooks/internal/BypassSpeechSynthesisPonyfill.js +3 -1
  354. package/src/hooks/internal/useChanged.ts +17 -0
  355. package/src/hooks/internal/useDispatchScrollPosition.js +1 -3
  356. package/src/hooks/internal/useDispatchTranscriptFocusByActivityKey.ts +5 -0
  357. package/src/hooks/internal/useFocusVisible.ts +22 -0
  358. package/src/hooks/internal/useMemoWithPrevious.ts +16 -0
  359. package/src/hooks/internal/useMemoize.spec.js +1 -1
  360. package/src/hooks/internal/useMemoize.ts +53 -0
  361. package/src/hooks/internal/useObserveFocusVisible.ts +252 -0
  362. package/src/hooks/internal/usePrevious.ts +12 -0
  363. package/src/hooks/internal/useStateRef.ts +31 -0
  364. package/src/hooks/internal/useValueRef.ts +22 -0
  365. package/src/hooks/useFocus.ts +1 -1
  366. package/src/hooks/useObserveTranscriptFocus.ts +2 -2
  367. package/src/hooks/useRenderMarkdownAsHTML.ts +4 -5
  368. package/src/hooks/useScrollTo.ts +4 -3
  369. package/src/hooks/useScrollToEnd.ts +4 -3
  370. package/src/hooks/useSendFiles.ts +7 -5
  371. package/src/index.ts +0 -1
  372. package/src/providers/ActivityTree/ActivityTreeComposer.tsx +74 -0
  373. package/src/providers/ActivityTree/private/Context.ts +12 -0
  374. package/src/providers/ActivityTree/private/types.ts +12 -0
  375. package/src/providers/ActivityTree/private/useActivitiesWithRenderer.ts +64 -0
  376. package/src/providers/ActivityTree/private/useActivityTreeWithRenderer.ts +135 -0
  377. package/src/providers/ActivityTree/private/useContext.ts +15 -0
  378. package/src/providers/ActivityTree/useActivityTreeWithRenderer.ts +16 -0
  379. package/src/providers/LiveRegionTwin/LiveRegionTwinComposer.tsx +161 -0
  380. package/src/providers/LiveRegionTwin/private/Context.ts +15 -0
  381. package/src/providers/LiveRegionTwin/private/LiveRegionTwinContainer.tsx +80 -0
  382. package/src/providers/LiveRegionTwin/private/types.ts +10 -0
  383. package/src/providers/LiveRegionTwin/private/useContext.ts +15 -0
  384. package/src/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.ts +13 -0
  385. package/src/providers/LiveRegionTwin/private/useStaticElementEntries.ts +7 -0
  386. package/src/providers/LiveRegionTwin/useQueueStaticElement.ts +12 -0
  387. package/src/providers/TranscriptFocus/TranscriptFocusComposer.tsx +180 -0
  388. package/src/providers/TranscriptFocus/private/Context.ts +16 -0
  389. package/src/providers/TranscriptFocus/private/useContext.ts +13 -0
  390. package/src/providers/TranscriptFocus/useActiveDescendantId.ts +5 -0
  391. package/src/providers/TranscriptFocus/useFocusByActivityKey.ts +14 -0
  392. package/src/providers/TranscriptFocus/useFocusRelativeActivity.ts +5 -0
  393. package/src/providers/TranscriptFocus/useFocusedActivityKey.ts +5 -0
  394. package/src/providers/TranscriptFocus/useFocusedExplicitly.ts +5 -0
  395. package/src/providers/TranscriptFocus/useGetDescendantIdByActivityKey.ts +5 -0
  396. package/.eslintignore +0 -1
  397. package/lib/Middleware/GroupActivities/createCoreMiddleware.js +0 -69
  398. package/lib/Utils/findLastIndex.js +0 -32
  399. package/lib/hooks/internal/useAcknowledgedActivity.js +0 -90
  400. package/lib/hooks/internal/useDispatchTranscriptFocus.js +0 -19
  401. package/src/BasicTranscript.js +0 -1139
  402. package/src/Middleware/GroupActivities/createCoreMiddleware.js +0 -57
  403. package/src/Utils/findLastIndex.js +0 -11
  404. package/src/Utils/findLastIndex.spec.js +0 -31
  405. package/src/Utils/getActivityUniqueId.js +0 -3
  406. package/src/Utils/intersectionOf.js +0 -11
  407. package/src/Utils/isZeroOrPositive.js +0 -4
  408. package/src/hooks/internal/useAcknowledgedActivity.js +0 -65
  409. package/src/hooks/internal/useChanged.js +0 -10
  410. package/src/hooks/internal/useDispatchTranscriptFocus.js +0 -7
  411. package/src/hooks/internal/useMemoize.js +0 -37
@@ -1,4 +1,5 @@
1
1
  import { hooks } from 'botframework-webchat-api';
2
+ import React, { Fragment, VFC } from 'react';
2
3
 
3
4
  const { useActiveTyping, useRenderTypingIndicator } = hooks;
4
5
 
@@ -8,13 +9,13 @@ function useTypingIndicatorVisible(): [boolean] {
8
9
  return [!!Object.values(activeTyping).filter(({ role }) => role !== 'user').length];
9
10
  }
10
11
 
11
- const BasicTypingIndicator = () => {
12
+ const BasicTypingIndicator: VFC<{}> = () => {
12
13
  const [activeTyping] = useActiveTyping();
13
14
  const [visible] = useTypingIndicatorVisible();
14
15
  const [typing] = useActiveTyping(Infinity);
15
16
  const renderTypingIndicator = useRenderTypingIndicator();
16
17
 
17
- return renderTypingIndicator({ activeTyping, typing, visible });
18
+ return <Fragment>{renderTypingIndicator({ activeTyping, typing, visible })}</Fragment>;
18
19
  };
19
20
 
20
21
  export default BasicTypingIndicator;
package/src/Composer.tsx CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  speechSynthesis as bypassSpeechSynthesis,
17
17
  SpeechSynthesisUtterance as BypassSpeechSynthesisUtterance
18
18
  } from './hooks/internal/BypassSpeechSynthesisPonyfill';
19
+ import ActivityTreeComposer from './providers/ActivityTree/ActivityTreeComposer';
19
20
  import addTargetBlankToHyperlinksMarkdown from './Utils/addTargetBlankToHyperlinksMarkdown';
20
21
  import createCSSKey from './Utils/createCSSKey';
21
22
  import createDefaultActivityMiddleware from './Middleware/Activity/createCoreMiddleware';
@@ -34,9 +35,8 @@ import mapMap from './Utils/mapMap';
34
35
  import UITracker from './hooks/internal/UITracker';
35
36
  import WebChatUIContext from './hooks/internal/WebChatUIContext';
36
37
 
37
- const { useReferenceGrammarID, useStyleOptions } = hooks;
38
+ const { useGetActivityByKey, useReferenceGrammarID, useStyleOptions } = hooks;
38
39
 
39
- // eslint-disable-next-line no-undef
40
40
  const node_env = process.env.node_env || process.env.NODE_ENV;
41
41
 
42
42
  const emotionPool = {};
@@ -98,7 +98,9 @@ const ComposerCore: FC<ComposerCoreProps> = ({
98
98
  // 1. If 2 instances use different nonce, they should result in different hash;
99
99
  // 2. If 2 instances are being mounted, pooling will make sure we render only 1 set of <style> tags, instead of 2.
100
100
  const emotion =
101
- emotionPool[nonce] || (emotionPool[nonce] = createEmotion({ key: `webchat--css-${createCSSKey()}`, nonce }));
101
+ // Prefix "id-" to prevent object injection attack.
102
+ emotionPool[`id-${nonce}`] ||
103
+ (emotionPool[`id-${nonce}`] = createEmotion({ key: `webchat--css-${createCSSKey()}`, nonce }));
102
104
 
103
105
  return style => emotion.css(style);
104
106
  }, [nonce]);
@@ -124,7 +126,6 @@ const ComposerCore: FC<ComposerCoreProps> = ({
124
126
  }, [referenceGrammarID, webSpeechPonyfillFactory]);
125
127
 
126
128
  const scrollPositionObserversRef = useRef([]);
127
- const [numScrollPositionObservers, setNumScrollPositionObservers] = useState(0);
128
129
 
129
130
  const dispatchScrollPosition = useCallback(
130
131
  event => scrollPositionObserversRef.current.forEach(observer => observer(event)),
@@ -134,23 +135,32 @@ const ComposerCore: FC<ComposerCoreProps> = ({
134
135
  const observeScrollPosition = useCallback(
135
136
  observer => {
136
137
  scrollPositionObserversRef.current = [...scrollPositionObserversRef.current, observer];
137
- setNumScrollPositionObservers(scrollPositionObserversRef.current.length);
138
138
 
139
139
  return () => {
140
140
  scrollPositionObserversRef.current = scrollPositionObserversRef.current.filter(target => target !== observer);
141
- setNumScrollPositionObservers(scrollPositionObserversRef.current.length);
142
141
  };
143
142
  },
144
- [scrollPositionObserversRef, setNumScrollPositionObservers]
143
+ [scrollPositionObserversRef]
145
144
  );
146
145
 
147
146
  const transcriptFocusObserversRef = useRef([]);
148
147
  const [numTranscriptFocusObservers, setNumTranscriptFocusObservers] = useState(0);
149
148
 
150
- const dispatchTranscriptFocus = useCallback(
151
- event => transcriptFocusObserversRef.current.forEach(observer => observer(event)),
152
- [transcriptFocusObserversRef]
153
- );
149
+ const getActivityByKey = useGetActivityByKey();
150
+
151
+ const dispatchTranscriptFocusByActivityKey = useMemo(() => {
152
+ let prevActivityKey: string | Symbol | undefined = Symbol();
153
+
154
+ return activityKey => {
155
+ if (activityKey !== prevActivityKey) {
156
+ prevActivityKey = activityKey;
157
+
158
+ const event = { activity: getActivityByKey(activityKey) };
159
+
160
+ transcriptFocusObserversRef.current.forEach(observer => observer(event));
161
+ }
162
+ };
163
+ }, [getActivityByKey, transcriptFocusObserversRef]);
154
164
 
155
165
  const observeTranscriptFocus = useCallback(
156
166
  observer => {
@@ -169,13 +179,12 @@ const ComposerCore: FC<ComposerCoreProps> = ({
169
179
  () => ({
170
180
  dictateAbortable,
171
181
  dispatchScrollPosition,
172
- dispatchTranscriptFocus,
182
+ dispatchTranscriptFocusByActivityKey,
173
183
  focusSendBoxCallbacksRef,
174
184
  focusTranscriptCallbacksRef,
175
185
  internalMarkdownItState: [internalMarkdownIt],
176
186
  internalRenderMarkdownInline,
177
187
  nonce,
178
- numScrollPositionObservers,
179
188
  numTranscriptFocusObservers,
180
189
  observeScrollPosition,
181
190
  observeTranscriptFocus,
@@ -192,13 +201,12 @@ const ComposerCore: FC<ComposerCoreProps> = ({
192
201
  [
193
202
  dictateAbortable,
194
203
  dispatchScrollPosition,
195
- dispatchTranscriptFocus,
204
+ dispatchTranscriptFocusByActivityKey,
196
205
  focusSendBoxCallbacksRef,
197
206
  focusTranscriptCallbacksRef,
198
207
  internalMarkdownIt,
199
208
  internalRenderMarkdownInline,
200
209
  nonce,
201
- numScrollPositionObservers,
202
210
  numTranscriptFocusObservers,
203
211
  observeScrollPosition,
204
212
  observeTranscriptFocus,
@@ -225,6 +233,7 @@ const ComposerCore: FC<ComposerCoreProps> = ({
225
233
  };
226
234
 
227
235
  ComposerCore.defaultProps = {
236
+ children: undefined,
228
237
  extraStyleSet: undefined,
229
238
  nonce: undefined,
230
239
  renderMarkdown: undefined,
@@ -301,9 +310,10 @@ const Composer: FC<ComposerProps> = ({
301
310
  [cardActionMiddleware]
302
311
  );
303
312
 
304
- const patchedToastMiddleware = useMemo(() => [...singleToArray(toastMiddleware), ...createDefaultToastMiddleware()], [
305
- toastMiddleware
306
- ]);
313
+ const patchedToastMiddleware = useMemo(
314
+ () => [...singleToArray(toastMiddleware), ...createDefaultToastMiddleware()],
315
+ [toastMiddleware]
316
+ );
307
317
 
308
318
  const patchedTypingIndicatorMiddleware = useMemo(
309
319
  () => [...singleToArray(typingIndicatorMiddleware), ...createDefaultTypingIndicatorMiddleware()],
@@ -335,17 +345,19 @@ const Composer: FC<ComposerProps> = ({
335
345
  typingIndicatorMiddleware={patchedTypingIndicatorMiddleware}
336
346
  {...composerProps}
337
347
  >
338
- <ComposerCore
339
- extraStyleSet={extraStyleSet}
340
- nonce={nonce}
341
- renderMarkdown={renderMarkdown}
342
- styleSet={styleSet}
343
- suggestedActionsAccessKey={suggestedActionsAccessKey}
344
- webSpeechPonyfillFactory={webSpeechPonyfillFactory}
345
- >
346
- {children}
347
- {onTelemetry && <UITracker />}
348
- </ComposerCore>
348
+ <ActivityTreeComposer>
349
+ <ComposerCore
350
+ extraStyleSet={extraStyleSet}
351
+ nonce={nonce}
352
+ renderMarkdown={renderMarkdown}
353
+ styleSet={styleSet}
354
+ suggestedActionsAccessKey={suggestedActionsAccessKey}
355
+ webSpeechPonyfillFactory={webSpeechPonyfillFactory}
356
+ >
357
+ {children}
358
+ {onTelemetry && <UITracker />}
359
+ </ComposerCore>
360
+ </ActivityTreeComposer>
349
361
  </APIComposer>
350
362
  </React.Fragment>
351
363
  );
@@ -1,4 +1,3 @@
1
- /* eslint-disable complexity */
2
1
  import { ActivityMiddleware } from 'botframework-webchat-api';
3
2
  import React from 'react';
4
3
 
@@ -7,66 +6,68 @@ import StackedLayout from '../../Activity/StackedLayout';
7
6
 
8
7
  export default function createCoreMiddleware(): ActivityMiddleware[] {
9
8
  return [
10
- () => next => (...args) => {
11
- const [{ activity }] = args;
9
+ () =>
10
+ next =>
11
+ (...args) => {
12
+ const [{ activity }] = args;
12
13
 
13
- // TODO: [P4] Can we simplify these if-statement to something more readable?
14
+ // TODO: [P4] Can we simplify these if-statement to something more readable?
14
15
 
15
- const { type } = activity;
16
+ const { type } = activity;
16
17
 
17
- // Filter out activities that should not be visible
18
- if (type === 'conversationUpdate' || type === 'event' || type === 'invoke' || type === 'typing') {
19
- return false;
20
- } else if (type === 'message') {
21
- const { attachments = [], channelData, text } = activity;
22
-
23
- if (
24
- // Do not show postback
25
- (channelData && channelData.postBack) ||
26
- // Do not show messageBack if displayText is undefined
27
- (channelData && channelData.messageBack && !channelData.messageBack.displayText) ||
28
- // Do not show empty bubbles (no text and attachments, and not "typing")
29
- !(text || attachments.length)
30
- ) {
18
+ // Filter out activities that should not be visible
19
+ if (type === 'conversationUpdate' || type === 'event' || type === 'invoke' || type === 'typing') {
31
20
  return false;
21
+ } else if (type === 'message') {
22
+ const { attachments, channelData, text } = activity;
23
+
24
+ if (
25
+ // Do not show postback
26
+ channelData?.postBack ||
27
+ // Do not show messageBack if displayText is undefined
28
+ (channelData?.messageBack && !channelData.messageBack.displayText) ||
29
+ // Do not show empty bubbles (no text and attachments, and not "typing")
30
+ !(text || attachments?.length)
31
+ ) {
32
+ return false;
33
+ }
32
34
  }
33
- // eslint-disable-next-line no-dupe-else-if
34
- } else if (type === 'typing' && activity.from.role === 'user') {
35
- // Do not show typing by oneself
36
- return false;
37
- }
38
35
 
39
- if (type === 'message' || type === 'typing') {
40
- if (type === 'message' && (activity.attachments || []).length > 1 && activity.attachmentLayout === 'carousel') {
41
- // The following line is not a React functional component, it's a render function called by useCreateActivityRenderer() hook.
42
- // The function signature need to be compatible with older version of activity middleware, which was:
43
- //
44
- // renderActivity(
45
- // renderAttachment: ({ activity, attachment }) => React.Element
46
- // ) => React.Element
36
+ if (type === 'message' || type === 'typing') {
37
+ if (
38
+ type === 'message' &&
39
+ (activity.attachments?.length || 0) > 1 &&
40
+ activity.attachmentLayout === 'carousel'
41
+ ) {
42
+ // The following line is not a React functional component, it's a render function called by useCreateActivityRenderer() hook.
43
+ // The function signature need to be compatible with older version of activity middleware, which was:
44
+ //
45
+ // renderActivity(
46
+ // renderAttachment: ({ activity, attachment }) => React.Element
47
+ // ) => React.Element
48
+
49
+ return function renderCarouselLayout(renderAttachment, props) {
50
+ typeof props === 'undefined' &&
51
+ console.warn(
52
+ 'botframework-webchat: One or more arguments were missing after passing through the activity middleware. Please check your custom activity middleware to make sure it passes all arguments.'
53
+ );
47
54
 
48
- return function renderCarouselLayout(renderAttachment, props) {
55
+ return <CarouselLayout activity={activity} renderAttachment={renderAttachment} {...props} />;
56
+ };
57
+ }
58
+
59
+ // The following line is not a React functional component, it's a render function called by useCreateActivityRenderer() hook.
60
+ return function renderStackedLayout(renderAttachment, props) {
49
61
  typeof props === 'undefined' &&
50
62
  console.warn(
51
63
  'botframework-webchat: One or more arguments were missing after passing through the activity middleware. Please check your custom activity middleware to make sure it passes all arguments.'
52
64
  );
53
65
 
54
- return <CarouselLayout activity={activity} renderAttachment={renderAttachment} {...props} />;
66
+ return <StackedLayout activity={activity} renderAttachment={renderAttachment} {...props} />;
55
67
  };
56
68
  }
57
69
 
58
- // The following line is not a React functional component, it's a render function called by useCreateActivityRenderer() hook.
59
- return function renderStackedLayout(renderAttachment, props) {
60
- typeof props === 'undefined' &&
61
- console.warn(
62
- 'botframework-webchat: One or more arguments were missing after passing through the activity middleware. Please check your custom activity middleware to make sure it passes all arguments.'
63
- );
64
-
65
- return <StackedLayout activity={activity} renderAttachment={renderAttachment} {...props} />;
66
- };
70
+ return next(...args);
67
71
  }
68
-
69
- return next(...args);
70
- }
71
72
  ];
72
73
  }
@@ -1,7 +1,8 @@
1
- import { Constants, DirectLineActivity } from 'botframework-webchat-core';
1
+ import { Constants } from 'botframework-webchat-core';
2
2
  import { hooks } from 'botframework-webchat-api';
3
3
  import PropTypes from 'prop-types';
4
4
  import React, { FC, useCallback } from 'react';
5
+ import type { WebChatActivity } from 'botframework-webchat-core';
5
6
 
6
7
  import connectToWebChat from '../../../connectToWebChat';
7
8
  import ScreenReaderText from '../../../ScreenReaderText';
@@ -33,7 +34,7 @@ const connectSendStatus = (...selectors) =>
33
34
  );
34
35
 
35
36
  type SendStatusProps = {
36
- activity: DirectLineActivity;
37
+ activity: WebChatActivity;
37
38
  sendState: 'sending' | 'send failed' | 'sent';
38
39
  };
39
40
 
@@ -72,9 +73,10 @@ const SendStatus: FC<SendStatusProps> = ({ activity, sendState }) => {
72
73
  };
73
74
 
74
75
  SendStatus.propTypes = {
76
+ // PropTypes cannot fully capture TypeScript types.
77
+ // @ts-ignore
75
78
  activity: PropTypes.shape({
76
79
  channelData: PropTypes.shape({
77
- clientTimestamp: PropTypes.string,
78
80
  state: PropTypes.string
79
81
  })
80
82
  }).isRequired,
@@ -1,8 +1,8 @@
1
- import { DirectLineActivity } from 'botframework-webchat-core';
2
1
  import { hooks } from 'botframework-webchat-api';
3
2
  import classNames from 'classnames';
4
3
  import PropTypes from 'prop-types';
5
4
  import React, { FC } from 'react';
5
+ import type { WebChatActivity } from 'botframework-webchat-core';
6
6
 
7
7
  import AbsoluteTime from './AbsoluteTime';
8
8
  import RelativeTime from './RelativeTime';
@@ -11,7 +11,7 @@ import useStyleSet from '../../hooks/useStyleSet';
11
11
  const { useStyleOptions } = hooks;
12
12
 
13
13
  type TimestampProps = {
14
- activity: DirectLineActivity;
14
+ activity: WebChatActivity;
15
15
  className?: string;
16
16
  };
17
17
 
@@ -40,8 +40,10 @@ Timestamp.defaultProps = {
40
40
  };
41
41
 
42
42
  Timestamp.propTypes = {
43
+ // PropTypes cannot fully capture TypeScript types.
44
+ // @ts-ignore
43
45
  activity: PropTypes.shape({
44
- timestamp: PropTypes.string.isRequired
46
+ timestamp: PropTypes.string
45
47
  }).isRequired,
46
48
  className: PropTypes.string
47
49
  };
@@ -10,6 +10,8 @@ const {
10
10
  export default function createSendStatusMiddleware() {
11
11
  return () =>
12
12
  next =>
13
+ // This is not a React component.
14
+ // eslint-disable-next-line react/prop-types
13
15
  ({ activity, sendState, ...args }) => {
14
16
  if (sendState !== SENT) {
15
17
  return <SendStatus activity={activity} sendState={sendState} />;
@@ -10,35 +10,35 @@ import VideoAttachment from '../../Attachment/VideoAttachment';
10
10
  // TODO: [P4] Rename this file or the whole middleware, it looks either too simple or too comprehensive now
11
11
  export default function createCoreMiddleware(): AttachmentMiddleware[] {
12
12
  return [
13
- // This is not returning a React component, but a render function.
14
- /* eslint-disable-next-line react/display-name */
15
- () => next => (...args) => {
16
- const [
17
- {
18
- activity = {},
19
- activity: { from: { role = undefined } = {} } = {},
20
- attachment,
21
- attachment: { contentType = undefined, contentUrl = undefined, thumbnailUrl = undefined } = {}
22
- }
23
- ] = args;
13
+ () =>
14
+ next =>
15
+ (...args) => {
16
+ const [
17
+ {
18
+ activity = {},
19
+ activity: { from: { role = undefined } = {} } = {},
20
+ attachment,
21
+ attachment: { contentType = undefined, contentUrl = undefined, thumbnailUrl = undefined } = {}
22
+ }
23
+ ] = args;
24
24
 
25
- const isText = /^text\//u.test(contentType);
25
+ const isText = /^text\//u.test(contentType);
26
26
 
27
- return (isText ? !attachment.content : role === 'user' && !thumbnailUrl) ? (
28
- <FileAttachment activity={activity} attachment={attachment} />
29
- ) : /^audio\//u.test(contentType) ? (
30
- <AudioAttachment attachment={attachment} />
31
- ) : /^image\//u.test(contentType) ? (
32
- <ImageAttachment attachment={attachment} />
33
- ) : /^video\//u.test(contentType) ? (
34
- <VideoAttachment attachment={attachment} />
35
- ) : contentUrl || contentType === 'application/octet-stream' ? (
36
- <FileAttachment activity={activity} attachment={attachment} />
37
- ) : isText ? (
38
- <TextAttachment attachment={attachment} />
39
- ) : (
40
- next(...args)
41
- );
42
- }
27
+ return (isText ? !attachment.content : role === 'user' && !thumbnailUrl) ? (
28
+ <FileAttachment activity={activity} attachment={attachment} />
29
+ ) : /^audio\//u.test(contentType) ? (
30
+ <AudioAttachment attachment={attachment} />
31
+ ) : /^image\//u.test(contentType) ? (
32
+ <ImageAttachment attachment={attachment} />
33
+ ) : /^video\//u.test(contentType) ? (
34
+ <VideoAttachment attachment={attachment} />
35
+ ) : contentUrl || contentType === 'application/octet-stream' ? (
36
+ <FileAttachment activity={activity} attachment={attachment} />
37
+ ) : isText ? (
38
+ <TextAttachment attachment={attachment} />
39
+ ) : (
40
+ next(...args)
41
+ );
42
+ }
43
43
  ];
44
44
  }
@@ -9,30 +9,32 @@ import VideoAttachment from './VideoAttachment';
9
9
 
10
10
  export default function createCoreMiddleware(): AttachmentForScreenReaderMiddleware[] {
11
11
  return [
12
- () => next => (...args) => {
13
- const [
14
- {
15
- activity: { from: { role = undefined } = {} } = {},
16
- attachment,
17
- attachment: { contentType = undefined, contentUrl = undefined, thumbnailUrl = undefined } = {}
18
- }
19
- ] = args;
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;
20
22
 
21
- const isText = /^text\//u.test(contentType);
23
+ const isText = /^text\//u.test(contentType);
22
24
 
23
- return (isText ? !attachment.content : role === 'user' && !thumbnailUrl)
24
- ? () => <FileAttachment attachment={attachment} />
25
- : /^audio\//u.test(contentType)
26
- ? () => <AudioAttachment />
27
- : /^image\//u.test(contentType)
28
- ? () => <ImageAttachment />
29
- : /^video\//u.test(contentType)
30
- ? () => <VideoAttachment />
31
- : contentUrl || contentType === 'application/octet-stream'
32
- ? () => <FileAttachment attachment={attachment} />
33
- : isText
34
- ? () => <TextAttachment attachment={attachment} />
35
- : next(...args);
36
- }
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
+ }
37
39
  ];
38
40
  }
@@ -59,16 +59,17 @@ DefaultAvatar.propTypes = {
59
59
 
60
60
  export default function createCoreAvatarMiddleware(): AvatarMiddleware[] {
61
61
  return [
62
- () => () => ({ fromUser, styleOptions }) => {
63
- const { botAvatarImage, botAvatarInitials, userAvatarImage, userAvatarInitials } = styleOptions;
62
+ () =>
63
+ () =>
64
+ ({ fromUser, styleOptions }) => {
65
+ const { botAvatarImage, botAvatarInitials, userAvatarImage, userAvatarInitials } = styleOptions;
64
66
 
65
- if (fromUser ? userAvatarImage || userAvatarInitials : botAvatarImage || botAvatarInitials) {
66
- // eslint-disable-next-line react/display-name
67
- return () => <DefaultAvatar fromUser={fromUser} />;
68
- }
67
+ if (fromUser ? userAvatarImage || userAvatarInitials : botAvatarImage || botAvatarInitials) {
68
+ return () => <DefaultAvatar fromUser={fromUser} />;
69
+ }
69
70
 
70
- return false;
71
- }
71
+ return false;
72
+ }
72
73
  ];
73
74
  }
74
75
 
@@ -54,6 +54,8 @@ export default function createDefaultCardActionMiddleware() {
54
54
  newWindow.opener = null;
55
55
  newWindow.location = value;
56
56
  } else {
57
+ // False alarm: this is "window.open", and not "fs.open".
58
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
57
59
  window.open(value, '_blank', 'noopener noreferrer');
58
60
  }
59
61
  } else {
@@ -68,12 +70,17 @@ export default function createDefaultCardActionMiddleware() {
68
70
  * This is to eliminate the delay between window.open() and location.href call
69
71
  */
70
72
 
71
- // eslint-disable-next-line wrap-iife
72
73
  (async function () {
73
74
  const popup = window.open();
74
75
  const url = await getSignInUrl();
75
76
 
76
- popup.location.href = url;
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);
81
+
82
+ popup.close();
83
+ }
77
84
  })();
78
85
 
79
86
  break;
@@ -4,14 +4,16 @@ import ScrollToEndButton from './ScrollToEndButton';
4
4
 
5
5
  export default function createScrollToEndButtonMiddleware(): ScrollToEndButtonMiddleware[] {
6
6
  return [
7
- () => () => ({ atEnd, styleOptions: { scrollToEndButtonBehavior }, unread }) =>
8
- !scrollToEndButtonBehavior
9
- ? // Don't show the button when it is set to false.
10
- false
11
- : scrollToEndButtonBehavior === 'any'
12
- ? // Show when the scroll view is not at the end, regardless of number of unread activities.
13
- !atEnd && ScrollToEndButton
14
- : // Show when the scroll view is not at the end of the transcript, and there are new/unread activities.
15
- !atEnd && unread && ScrollToEndButton
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
16
18
  ];
17
19
  }
@@ -4,17 +4,19 @@ import createToastMiddleware from '../../Toast/createToastMiddleware';
4
4
 
5
5
  function createCoreMiddleware(): ToastMiddleware[] {
6
6
  return [
7
- () => next => (...args) => {
8
- const [
9
- {
10
- notification: { id }
11
- }
12
- ] = args;
7
+ () =>
8
+ next =>
9
+ (...args) => {
10
+ const [
11
+ {
12
+ notification: { id }
13
+ }
14
+ ] = args;
13
15
 
14
- // We are ignoring "connectivitystatus" notifications, we will render it using <BasicConnectivityStatus> instead.
15
- // If devs want to render it, they can add a middleware.
16
- return id !== 'connectivitystatus' && next(...args);
17
- },
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
+ },
18
20
  createToastMiddleware()
19
21
  ];
20
22
  }
@@ -21,6 +21,12 @@ const DotIndicator = () => {
21
21
 
22
22
  // TODO: [P4] Rename this file or the whole middleware, it looks either too simple or too comprehensive now
23
23
  export default function createCoreMiddleware(): TypingIndicatorMiddleware[] {
24
- /* eslint-disable-next-line react/prop-types */
25
- return [() => () => ({ visible }) => visible && <DotIndicator />];
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
+ ];
26
32
  }