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.
- package/.eslintrc.yml +4 -100
- package/.prettierrc.yml +1 -1
- package/lib/Activity/Avatar.d.ts +10 -0
- package/lib/Activity/Avatar.d.ts.map +1 -0
- package/lib/Activity/Avatar.js +2 -1
- package/lib/Activity/Bubble.d.ts +11 -0
- package/lib/Activity/Bubble.d.ts.map +1 -0
- package/lib/Activity/Bubble.js +2 -2
- package/lib/Activity/CarouselFilmStrip.js +21 -31
- package/lib/Activity/CarouselFilmStripAttachment.js +120 -0
- package/lib/Activity/CarouselLayout.js +5 -5
- package/lib/Activity/Speak.d.ts +10 -0
- package/lib/Activity/Speak.d.ts.map +1 -0
- package/lib/Activity/Speak.js +11 -13
- package/lib/Activity/StackedLayout.d.ts +18 -0
- package/lib/Activity/StackedLayout.d.ts.map +1 -0
- package/lib/Activity/StackedLayout.js +19 -15
- package/lib/Assets/TypingAnimation.js +2 -2
- package/lib/Attachment/Assets/DownloadIcon.js +3 -1
- package/lib/Attachment/AudioAttachment.js +2 -2
- package/lib/Attachment/AudioContent.d.ts +11 -0
- package/lib/Attachment/AudioContent.d.ts.map +1 -0
- package/lib/Attachment/AudioContent.js +4 -4
- package/lib/Attachment/FileAttachment.js +2 -2
- package/lib/Attachment/FileContent.d.ts +10 -0
- package/lib/Attachment/FileContent.d.ts.map +1 -0
- package/lib/Attachment/FileContent.js +14 -9
- package/lib/Attachment/HTMLVideoContent.d.ts +11 -0
- package/lib/Attachment/HTMLVideoContent.d.ts.map +1 -0
- package/lib/Attachment/HTMLVideoContent.js +2 -2
- package/lib/Attachment/ImageContent.d.ts +8 -0
- package/lib/Attachment/ImageContent.d.ts.map +1 -0
- package/lib/Attachment/ImageContent.js +2 -2
- package/lib/Attachment/TextContent.d.ts +8 -0
- package/lib/Attachment/TextContent.d.ts.map +1 -0
- package/lib/Attachment/TextContent.js +4 -4
- package/lib/Attachment/VideoAttachment.js +2 -2
- package/lib/Attachment/VideoContent.d.ts +11 -0
- package/lib/Attachment/VideoContent.d.ts.map +1 -0
- package/lib/Attachment/VideoContent.js +1 -1
- package/lib/Attachment/VimeoContent.d.ts +10 -0
- package/lib/Attachment/VimeoContent.d.ts.map +1 -0
- package/lib/Attachment/VimeoContent.js +8 -8
- package/lib/Attachment/YouTubeContent.d.ts +10 -0
- package/lib/Attachment/YouTubeContent.d.ts.map +1 -0
- package/lib/Attachment/YouTubeContent.js +5 -5
- package/lib/Avatar/ImageAvatar.js +2 -2
- package/lib/Avatar/InitialsAvatar.js +2 -2
- package/lib/BasicConnectivityStatus.js +2 -2
- package/lib/BasicSendBox.d.ts +9 -0
- package/lib/BasicSendBox.d.ts.map +1 -0
- package/lib/BasicSendBox.js +7 -6
- package/lib/BasicToast.js +4 -4
- package/lib/BasicToaster.js +8 -5
- package/lib/BasicTranscript.d.ts +7 -0
- package/lib/BasicTranscript.d.ts.map +1 -0
- package/lib/BasicTranscript.js +406 -743
- package/lib/BasicTypingIndicator.d.ts +6 -0
- package/lib/BasicTypingIndicator.d.ts.map +1 -0
- package/lib/BasicTypingIndicator.js +13 -5
- package/lib/BasicWebChat.d.ts +9 -0
- package/lib/BasicWebChat.d.ts.map +1 -0
- package/lib/BasicWebChat.js +6 -4
- package/lib/Composer.d.ts +23 -0
- package/lib/Composer.d.ts.map +1 -0
- package/lib/Composer.js +65 -82
- package/lib/ConnectivityStatus/Assets/ErrorNotificationIcon.js +2 -2
- package/lib/ConnectivityStatus/Assets/SpinnerAnimation.js +2 -2
- package/lib/ConnectivityStatus/Assets/WarningNotificationIcon.js +2 -2
- package/lib/ConnectivityStatus/Connected.js +1 -1
- package/lib/ConnectivityStatus/Connecting.js +4 -4
- package/lib/ConnectivityStatus/FailedToConnect.js +2 -2
- package/lib/ConnectivityStatus/JavaScriptError.js +2 -2
- package/lib/Dictation.js +13 -4
- package/lib/ErrorBox.d.ts +8 -0
- package/lib/ErrorBox.d.ts.map +1 -0
- package/lib/ErrorBox.js +2 -2
- package/lib/Middleware/Activity/createCoreMiddleware.d.ts +3 -0
- package/lib/Middleware/Activity/createCoreMiddleware.d.ts.map +1 -0
- package/lib/Middleware/Activity/createCoreMiddleware.js +1 -1
- package/lib/Middleware/ActivityStatus/AbsoluteTime.js +1 -1
- package/lib/Middleware/ActivityStatus/RelativeTime.js +1 -1
- package/lib/Middleware/ActivityStatus/SendStatus/SendFailedRetry.js +3 -3
- package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.d.ts +11 -0
- package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.d.ts.map +1 -0
- package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.js +5 -5
- package/lib/Middleware/ActivityStatus/Timestamp.d.ts +9 -0
- package/lib/Middleware/ActivityStatus/Timestamp.d.ts.map +1 -0
- package/lib/Middleware/ActivityStatus/Timestamp.js +2 -2
- package/lib/Middleware/ActivityStatus/createCoreMiddleware.d.ts +3 -0
- package/lib/Middleware/ActivityStatus/createCoreMiddleware.d.ts.map +1 -0
- package/lib/Middleware/ActivityStatus/createCoreMiddleware.js +1 -1
- package/lib/Middleware/ActivityStatus/createSendStatusMiddleware.js +21 -16
- package/lib/Middleware/ActivityStatus/createTimestampMiddleware.js +1 -1
- package/lib/Middleware/Attachment/createCoreMiddleware.d.ts +3 -0
- package/lib/Middleware/Attachment/createCoreMiddleware.d.ts.map +1 -0
- package/lib/Middleware/Attachment/createCoreMiddleware.js +10 -13
- package/lib/Middleware/AttachmentForScreenReader/AudioAttachment.js +1 -1
- package/lib/Middleware/AttachmentForScreenReader/FileAttachment.js +1 -1
- package/lib/Middleware/AttachmentForScreenReader/ImageAttachment.js +1 -1
- package/lib/Middleware/AttachmentForScreenReader/TextAttachment.js +1 -1
- package/lib/Middleware/AttachmentForScreenReader/VideoAttachment.js +1 -1
- package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.d.ts +3 -0
- package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.d.ts.map +1 -0
- package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.js +9 -5
- package/lib/Middleware/Avatar/createCoreMiddleware.d.ts +11 -0
- package/lib/Middleware/Avatar/createCoreMiddleware.d.ts.map +1 -0
- package/lib/Middleware/Avatar/createCoreMiddleware.js +3 -4
- package/lib/Middleware/CardAction/createCoreMiddleware.js +11 -4
- package/lib/Middleware/GroupActivities/createCoreMiddleware.js +1 -1
- package/lib/Middleware/ScrollToEndButton/ScrollToEndButton.js +71 -0
- package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.d.ts +3 -0
- package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.d.ts.map +1 -0
- package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.js +27 -0
- package/lib/Middleware/Toast/createCoreMiddleware.d.ts +4 -0
- package/lib/Middleware/Toast/createCoreMiddleware.d.ts.map +1 -0
- package/lib/Middleware/Toast/createCoreMiddleware.js +1 -1
- package/lib/Middleware/TypingIndicator/createCoreMiddleware.d.ts +3 -0
- package/lib/Middleware/TypingIndicator/createCoreMiddleware.d.ts.map +1 -0
- package/lib/Middleware/TypingIndicator/createCoreMiddleware.js +9 -6
- package/lib/ReactWebChat.d.ts +10 -0
- package/lib/ReactWebChat.d.ts.map +1 -0
- package/lib/ReactWebChat.js +19 -7
- package/lib/ScreenReaderActivity.js +76 -48
- package/lib/ScreenReaderText.d.ts +9 -0
- package/lib/ScreenReaderText.d.ts.map +1 -0
- package/lib/ScreenReaderText.js +22 -8
- package/lib/SendBox/Assets/AttachmentIcon.js +3 -1
- package/lib/SendBox/Assets/MicrophoneIcon.js +3 -1
- package/lib/SendBox/Assets/SendIcon.js +2 -2
- package/lib/SendBox/AutoResizeTextArea.d.ts +23 -0
- package/lib/SendBox/AutoResizeTextArea.d.ts.map +1 -0
- package/lib/SendBox/AutoResizeTextArea.js +6 -6
- package/lib/SendBox/DictationInterims.d.ts +9 -0
- package/lib/SendBox/DictationInterims.d.ts.map +1 -0
- package/lib/SendBox/DictationInterims.js +3 -3
- package/lib/SendBox/IconButton.d.ts +11 -0
- package/lib/SendBox/IconButton.d.ts.map +1 -0
- package/lib/SendBox/IconButton.js +27 -7
- package/lib/SendBox/MicrophoneButton.d.ts +11 -0
- package/lib/SendBox/MicrophoneButton.d.ts.map +1 -0
- package/lib/SendBox/MicrophoneButton.js +25 -24
- package/lib/SendBox/SendButton.d.ts +9 -0
- package/lib/SendBox/SendButton.d.ts.map +1 -0
- package/lib/SendBox/SendButton.js +8 -6
- package/lib/SendBox/SuggestedAction.d.ts +17 -0
- package/lib/SendBox/SuggestedAction.d.ts.map +1 -0
- package/lib/SendBox/SuggestedAction.js +29 -24
- package/lib/SendBox/SuggestedActions.d.ts +5 -0
- package/lib/SendBox/SuggestedActions.d.ts.map +1 -0
- package/lib/SendBox/SuggestedActions.js +33 -13
- package/lib/SendBox/TextBox.d.ts +28 -0
- package/lib/SendBox/TextBox.d.ts.map +1 -0
- package/lib/SendBox/TextBox.js +13 -8
- package/lib/SendBox/UploadButton.d.ts +9 -0
- package/lib/SendBox/UploadButton.d.ts.map +1 -0
- package/lib/SendBox/UploadButton.js +6 -6
- package/lib/Styles/StyleSet/Activities.d.ts +5 -0
- package/lib/Styles/StyleSet/Activities.d.ts.map +1 -0
- package/lib/Styles/StyleSet/AudioAttachment.d.ts +6 -0
- package/lib/Styles/StyleSet/AudioAttachment.d.ts.map +1 -0
- package/lib/Styles/StyleSet/AudioContent.d.ts +4 -0
- package/lib/Styles/StyleSet/AudioContent.d.ts.map +1 -0
- package/lib/Styles/StyleSet/AutoResizeTextArea.d.ts +37 -0
- package/lib/Styles/StyleSet/AutoResizeTextArea.d.ts.map +1 -0
- package/lib/Styles/StyleSet/Avatar.d.ts +9 -0
- package/lib/Styles/StyleSet/Avatar.d.ts.map +1 -0
- package/lib/Styles/StyleSet/BasicTranscript.d.ts +85 -0
- package/lib/Styles/StyleSet/BasicTranscript.d.ts.map +1 -0
- package/lib/Styles/StyleSet/BasicTranscript.js +21 -9
- package/lib/Styles/StyleSet/Bubble.d.ts +5 -0
- package/lib/Styles/StyleSet/Bubble.d.ts.map +1 -0
- package/lib/Styles/StyleSet/Bubble.js +2 -2
- package/lib/Styles/StyleSet/CarouselFilmStrip.d.ts +5 -0
- package/lib/Styles/StyleSet/CarouselFilmStrip.d.ts.map +1 -0
- package/lib/Styles/StyleSet/CarouselFilmStrip.js +2 -18
- package/lib/Styles/StyleSet/CarouselFilmStripAttachment.d.ts +3 -0
- package/lib/Styles/StyleSet/CarouselFilmStripAttachment.d.ts.map +1 -0
- package/lib/Styles/StyleSet/CarouselFilmStripAttachment.js +63 -0
- package/lib/Styles/StyleSet/CarouselFlipper.d.ts +27 -0
- package/lib/Styles/StyleSet/CarouselFlipper.d.ts.map +1 -0
- package/lib/Styles/StyleSet/ConnectivityNotification.d.ts +13 -0
- package/lib/Styles/StyleSet/ConnectivityNotification.d.ts.map +1 -0
- package/lib/Styles/StyleSet/DictationInterims.d.ts +13 -0
- package/lib/Styles/StyleSet/DictationInterims.d.ts.map +1 -0
- package/lib/Styles/StyleSet/ErrorBox.d.ts +33 -0
- package/lib/Styles/StyleSet/ErrorBox.d.ts.map +1 -0
- package/lib/Styles/StyleSet/ErrorNotification.d.ts +23 -0
- package/lib/Styles/StyleSet/ErrorNotification.d.ts.map +1 -0
- package/lib/Styles/StyleSet/FileContent.d.ts +32 -0
- package/lib/Styles/StyleSet/FileContent.d.ts.map +1 -0
- package/lib/Styles/StyleSet/ImageAvatar.d.ts +7 -0
- package/lib/Styles/StyleSet/ImageAvatar.d.ts.map +1 -0
- package/lib/Styles/StyleSet/InitialsAvatar.d.ts +19 -0
- package/lib/Styles/StyleSet/InitialsAvatar.d.ts.map +1 -0
- package/lib/Styles/StyleSet/KeyboardHelp.d.ts +123 -0
- package/lib/Styles/StyleSet/KeyboardHelp.d.ts.map +1 -0
- package/lib/Styles/StyleSet/KeyboardHelp.js +145 -0
- package/lib/Styles/StyleSet/MicrophoneButton.d.ts +13 -0
- package/lib/Styles/StyleSet/MicrophoneButton.d.ts.map +1 -0
- package/lib/Styles/StyleSet/Root.d.ts +8 -0
- package/lib/Styles/StyleSet/Root.d.ts.map +1 -0
- package/lib/Styles/StyleSet/ScrollToEndButton.d.ts +36 -0
- package/lib/Styles/StyleSet/ScrollToEndButton.d.ts.map +1 -0
- package/lib/Styles/StyleSet/ScrollToEndButton.js +36 -34
- package/lib/Styles/StyleSet/SendBox.d.ts +24 -0
- package/lib/Styles/StyleSet/SendBox.d.ts.map +1 -0
- package/lib/Styles/StyleSet/SendBoxButton.d.ts +79 -0
- package/lib/Styles/StyleSet/SendBoxButton.d.ts.map +1 -0
- package/lib/Styles/StyleSet/SendBoxButton.js +76 -12
- package/lib/Styles/StyleSet/SendBoxTextBox.d.ts +41 -0
- package/lib/Styles/StyleSet/SendBoxTextBox.d.ts.map +1 -0
- package/lib/Styles/StyleSet/SendBoxTextBox.js +3 -3
- package/lib/Styles/StyleSet/SendStatus.d.ts +8 -0
- package/lib/Styles/StyleSet/SendStatus.d.ts.map +1 -0
- package/lib/Styles/StyleSet/SingleAttachmentActivity.d.ts +11 -0
- package/lib/Styles/StyleSet/SingleAttachmentActivity.d.ts.map +1 -0
- package/lib/Styles/StyleSet/SpinnerAnimation.d.ts +15 -0
- package/lib/Styles/StyleSet/SpinnerAnimation.d.ts.map +1 -0
- package/lib/Styles/StyleSet/StackedLayout.d.ts +63 -0
- package/lib/Styles/StyleSet/StackedLayout.d.ts.map +1 -0
- package/lib/Styles/StyleSet/StackedLayout.js +1 -1
- package/lib/Styles/StyleSet/SuggestedAction.d.ts +94 -0
- package/lib/Styles/StyleSet/SuggestedAction.d.ts.map +1 -0
- package/lib/Styles/StyleSet/SuggestedAction.js +116 -41
- package/lib/Styles/StyleSet/SuggestedActions.d.ts +125 -0
- package/lib/Styles/StyleSet/SuggestedActions.d.ts.map +1 -0
- package/lib/Styles/StyleSet/SuggestedActions.js +13 -6
- package/lib/Styles/StyleSet/TextContent.d.ts +28 -0
- package/lib/Styles/StyleSet/TextContent.d.ts.map +1 -0
- package/lib/Styles/StyleSet/Toast.d.ts +65 -0
- package/lib/Styles/StyleSet/Toast.d.ts.map +1 -0
- package/lib/Styles/StyleSet/Toaster.d.ts +111 -0
- package/lib/Styles/StyleSet/Toaster.d.ts.map +1 -0
- package/lib/Styles/StyleSet/TypingAnimation.d.ts +8 -0
- package/lib/Styles/StyleSet/TypingAnimation.d.ts.map +1 -0
- package/lib/Styles/StyleSet/TypingIndicator.d.ts +11 -0
- package/lib/Styles/StyleSet/TypingIndicator.d.ts.map +1 -0
- package/lib/Styles/StyleSet/UploadButton.d.ts +14 -0
- package/lib/Styles/StyleSet/UploadButton.d.ts.map +1 -0
- package/lib/Styles/StyleSet/VideoAttachment.d.ts +2 -0
- package/lib/Styles/StyleSet/VideoAttachment.d.ts.map +1 -0
- package/lib/Styles/StyleSet/VideoContent.d.ts +6 -0
- package/lib/Styles/StyleSet/VideoContent.d.ts.map +1 -0
- package/lib/Styles/StyleSet/VimeoContent.d.ts +7 -0
- package/lib/Styles/StyleSet/VimeoContent.d.ts.map +1 -0
- package/lib/Styles/StyleSet/WarningNotification.d.ts +22 -0
- package/lib/Styles/StyleSet/WarningNotification.d.ts.map +1 -0
- package/lib/Styles/StyleSet/YouTubeContent.d.ts +7 -0
- package/lib/Styles/StyleSet/YouTubeContent.d.ts.map +1 -0
- package/lib/Styles/createStyleSet.d.ts +1372 -0
- package/lib/Styles/createStyleSet.d.ts.map +1 -0
- package/lib/Styles/createStyleSet.js +47 -41
- package/lib/Styles/mirrorStyle.js +13 -4
- package/lib/Toast/CollapseIcon.js +3 -1
- package/lib/Toast/DismissIcon.js +3 -1
- package/lib/Toast/ExpandIcon.js +3 -1
- package/lib/Toast/NotificationIcon.js +7 -3
- package/lib/Toast/createToastMiddleware.d.ts +4 -0
- package/lib/Toast/createToastMiddleware.d.ts.map +1 -0
- package/lib/Toast/createToastMiddleware.js +2 -2
- package/lib/Transcript/ActivityRow.d.ts +9 -0
- package/lib/Transcript/ActivityRow.d.ts.map +1 -0
- package/lib/Transcript/ActivityRow.js +157 -0
- package/lib/Transcript/ActivityTextAlt.js +57 -0
- package/lib/Transcript/FocusTrap.d.ts +8 -0
- package/lib/Transcript/FocusTrap.d.ts.map +1 -0
- package/lib/Transcript/FocusTrap.js +74 -0
- package/lib/Transcript/KeyboardHelp.d.ts +4 -0
- package/lib/Transcript/KeyboardHelp.d.ts.map +1 -0
- package/lib/Transcript/KeyboardHelp.js +550 -0
- package/lib/Transcript/LiveRegionTranscript.d.ts +8 -0
- package/lib/Transcript/LiveRegionTranscript.d.ts.map +1 -0
- package/lib/Transcript/LiveRegionTranscript.js +214 -0
- package/lib/Transcript/types.d.ts +2 -0
- package/lib/Transcript/types.d.ts.map +1 -0
- package/lib/Transcript/types.js +2 -0
- package/lib/Transcript/useActivityAccessibleName.d.ts +4 -0
- package/lib/Transcript/useActivityAccessibleName.d.ts.map +1 -0
- package/lib/Transcript/useActivityAccessibleName.js +97 -0
- package/lib/Utils/AccessKeySink/Surface.js +7 -5
- package/lib/Utils/AccessibleButton.d.ts +11 -0
- package/lib/Utils/AccessibleButton.d.ts.map +1 -0
- package/lib/Utils/AccessibleButton.js +15 -8
- package/lib/Utils/AccessibleInputText.d.ts +21 -0
- package/lib/Utils/AccessibleInputText.d.ts.map +1 -0
- package/lib/Utils/AccessibleInputText.js +29 -25
- package/lib/Utils/AccessibleTextArea.d.ts +20 -0
- package/lib/Utils/AccessibleTextArea.d.ts.map +1 -0
- package/lib/Utils/AccessibleTextArea.js +35 -24
- package/lib/Utils/CroppedImage.js +2 -2
- package/lib/Utils/Fade.js +2 -2
- package/lib/Utils/FocusRedirector.d.ts +9 -0
- package/lib/Utils/FocusRedirector.d.ts.map +1 -0
- package/lib/Utils/FocusRedirector.js +18 -15
- package/lib/Utils/InlineMarkdown.js +17 -10
- package/lib/Utils/TypeFocusSink/FocusBox.js +6 -4
- package/lib/Utils/TypeFocusSink/getTabIndex.d.ts +2 -0
- package/lib/Utils/TypeFocusSink/getTabIndex.d.ts.map +1 -0
- package/lib/Utils/TypeFocusSink/getTabIndex.js +1 -1
- package/lib/Utils/TypeFocusSink/inputtableKey.d.ts +2 -0
- package/lib/Utils/TypeFocusSink/inputtableKey.d.ts.map +1 -0
- package/lib/Utils/TypeFocusSink/inputtableKey.js +5 -2
- package/lib/Utils/TypeFocusSink/navigableEvent.js +1 -1
- package/lib/Utils/activityAltText.d.ts +8 -0
- package/lib/Utils/activityAltText.d.ts.map +1 -0
- package/lib/Utils/activityAltText.js +100 -0
- package/lib/Utils/addTargetBlankToHyperlinksMarkdown.js +1 -1
- package/lib/Utils/createCustomEvent.js +9 -3
- package/lib/Utils/debounce.js +1 -1
- package/lib/Utils/detectBrowser.js +4 -2
- package/lib/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingWorker.js +3 -3
- package/lib/Utils/downscaleImageToDataURL/index.js +2 -2
- package/lib/Utils/filterMap.js +1 -1
- package/lib/Utils/findAncestor.js +17 -0
- package/lib/Utils/getActivityUniqueId.js +4 -2
- package/lib/Utils/intersectionOf.d.ts +5 -0
- package/lib/Utils/intersectionOf.d.ts.map +1 -0
- package/lib/Utils/intersectionOf.js +17 -2
- package/lib/Utils/isZeroOrPositive.d.ts +5 -0
- package/lib/Utils/isZeroOrPositive.d.ts.map +1 -0
- package/lib/Utils/isZeroOrPositive.js +4 -1
- package/lib/Utils/mapMap.js +10 -3
- package/lib/Utils/readDataURIToBlob.js +3 -3
- package/lib/Utils/scrollIntoViewWithBlockNearest.d.ts +7 -0
- package/lib/Utils/scrollIntoViewWithBlockNearest.d.ts.map +1 -0
- package/lib/Utils/scrollIntoViewWithBlockNearest.js +48 -0
- package/lib/Utils/shallowEquals.js +7 -3
- package/lib/Utils/singleToArray.js +1 -1
- package/lib/Utils/supportPseudoClass.d.ts +2 -0
- package/lib/Utils/supportPseudoClass.d.ts.map +1 -0
- package/lib/Utils/supportPseudoClass.js +23 -0
- package/lib/Utils/tabbableElements.d.ts +2 -0
- package/lib/Utils/tabbableElements.d.ts.map +1 -0
- package/lib/Utils/tabbableElements.js +2 -2
- package/lib/connectToWebChat.js +17 -7
- package/lib/hooks/index.d.ts +21 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/index.js +25 -25
- package/lib/hooks/internal/BypassSpeechSynthesisPonyfill.js +100 -41
- package/lib/hooks/internal/UITracker.js +2 -2
- package/lib/hooks/internal/useChanged.js +8 -1
- package/lib/hooks/internal/useDispatchScrollPosition.js +3 -7
- package/lib/hooks/internal/useDispatchTranscriptFocusByActivityKey.d.ts +2 -0
- package/lib/hooks/internal/useDispatchTranscriptFocusByActivityKey.d.ts.map +1 -0
- package/lib/hooks/internal/useDispatchTranscriptFocusByActivityKey.js +15 -0
- package/lib/hooks/internal/useEnterKeyHint.js +1 -1
- package/lib/hooks/internal/useFocusVisible.d.ts +3 -0
- package/lib/hooks/internal/useFocusVisible.d.ts.map +1 -0
- package/lib/hooks/internal/useFocusVisible.js +48 -0
- package/lib/hooks/internal/useForceRender.js +2 -2
- package/lib/hooks/internal/useForceRenderAtInterval.js +2 -2
- package/lib/hooks/internal/useInternalRenderMarkdownInline.js +1 -1
- package/lib/hooks/internal/useLocalizeAccessKey.js +2 -2
- package/lib/hooks/internal/useMemoWithPrevious.d.ts +3 -0
- package/lib/hooks/internal/useMemoWithPrevious.d.ts.map +1 -0
- package/lib/hooks/internal/useMemoWithPrevious.js +22 -0
- package/lib/hooks/internal/useMemoize.d.ts +14 -0
- package/lib/hooks/internal/useMemoize.d.ts.map +1 -0
- package/lib/hooks/internal/useMemoize.js +12 -3
- package/lib/hooks/internal/useNavigatorPlatform.js +1 -1
- package/lib/hooks/internal/useNonce.js +1 -1
- package/lib/hooks/internal/useObserveFocusVisible.d.ts +3 -0
- package/lib/hooks/internal/useObserveFocusVisible.d.ts.map +1 -0
- package/lib/hooks/internal/useObserveFocusVisible.js +208 -0
- package/lib/hooks/internal/usePrevious.d.ts +2 -0
- package/lib/hooks/internal/usePrevious.d.ts.map +1 -0
- package/lib/hooks/internal/usePrevious.js +18 -0
- package/lib/hooks/internal/useRegisterFocusSendBox.js +1 -1
- package/lib/hooks/internal/useRegisterFocusTranscript.js +1 -1
- package/lib/hooks/internal/useRegisterScrollRelative.js +1 -1
- package/lib/hooks/internal/useRegisterScrollTo.js +1 -1
- package/lib/hooks/internal/useRegisterScrollToEnd.js +1 -1
- package/lib/hooks/internal/useReplaceEmoticon.js +2 -2
- package/lib/hooks/internal/useResumeAudioContext.js +33 -0
- package/lib/hooks/internal/useScrollRelative.js +1 -1
- package/lib/hooks/internal/useSettableDictateAbortable.js +1 -1
- package/lib/hooks/internal/useStateRef.d.ts +3 -0
- package/lib/hooks/internal/useStateRef.d.ts.map +1 -0
- package/lib/hooks/internal/useStateRef.js +40 -0
- package/lib/hooks/internal/useSuggestedActionsAccessKey.js +1 -1
- package/lib/hooks/internal/useUniqueId.d.ts +2 -0
- package/lib/hooks/internal/useUniqueId.d.ts.map +1 -0
- package/lib/hooks/internal/useUniqueId.js +1 -1
- package/lib/hooks/internal/useValueRef.d.ts +3 -0
- package/lib/hooks/internal/useValueRef.d.ts.map +1 -0
- package/lib/hooks/internal/useValueRef.js +25 -0
- package/lib/hooks/useDictateAbortable.d.ts +2 -0
- package/lib/hooks/useDictateAbortable.d.ts.map +1 -0
- package/lib/hooks/useDictateAbortable.js +2 -2
- package/lib/hooks/useFocus.d.ts +2 -0
- package/lib/hooks/useFocus.d.ts.map +1 -0
- package/lib/hooks/useFocus.js +1 -1
- package/lib/hooks/useFocusSendBox.d.ts +3 -0
- package/lib/hooks/useFocusSendBox.d.ts.map +1 -0
- package/lib/hooks/useFocusSendBox.js +2 -1
- package/lib/hooks/useObserveScrollPosition.d.ts +3 -0
- package/lib/hooks/useObserveScrollPosition.d.ts.map +1 -0
- package/lib/hooks/useObserveScrollPosition.js +2 -2
- package/lib/hooks/useObserveTranscriptFocus.d.ts +5 -0
- package/lib/hooks/useObserveTranscriptFocus.d.ts.map +1 -0
- package/lib/hooks/useObserveTranscriptFocus.js +2 -2
- package/lib/hooks/useRenderMarkdownAsHTML.d.ts +5 -0
- package/lib/hooks/useRenderMarkdownAsHTML.d.ts.map +1 -0
- package/lib/hooks/useRenderMarkdownAsHTML.js +2 -2
- package/lib/hooks/useScrollDown.d.ts +4 -0
- package/lib/hooks/useScrollDown.d.ts.map +1 -0
- package/lib/hooks/useScrollDown.js +1 -1
- package/lib/hooks/useScrollTo.d.ts +5 -0
- package/lib/hooks/useScrollTo.d.ts.map +1 -0
- package/lib/hooks/useScrollTo.js +1 -1
- package/lib/hooks/useScrollToEnd.d.ts +2 -0
- package/lib/hooks/useScrollToEnd.d.ts.map +1 -0
- package/lib/hooks/useScrollToEnd.js +1 -1
- package/lib/hooks/useScrollUp.d.ts +4 -0
- package/lib/hooks/useScrollUp.d.ts.map +1 -0
- package/lib/hooks/useScrollUp.js +1 -1
- package/lib/hooks/useSendFiles.d.ts +2 -0
- package/lib/hooks/useSendFiles.d.ts.map +1 -0
- package/lib/hooks/useSendFiles.js +3 -3
- package/lib/hooks/useStyleSet.d.ts +2 -0
- package/lib/hooks/useStyleSet.d.ts.map +1 -0
- package/lib/hooks/useStyleSet.js +1 -1
- package/lib/hooks/useWebSpeechPonyfill.d.ts +3 -0
- package/lib/hooks/useWebSpeechPonyfill.d.ts.map +1 -0
- package/lib/hooks/useWebSpeechPonyfill.js +1 -1
- package/lib/index.d.ts +219 -22
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +22 -20
- package/lib/providers/ActivityTree/ActivityTreeComposer.d.ts +5 -0
- package/lib/providers/ActivityTree/ActivityTreeComposer.d.ts.map +1 -0
- package/lib/providers/ActivityTree/ActivityTreeComposer.js +86 -0
- package/lib/providers/ActivityTree/private/Context.d.ts +9 -0
- package/lib/providers/ActivityTree/private/Context.d.ts.map +1 -0
- package/lib/providers/ActivityTree/private/Context.js +13 -0
- package/lib/providers/ActivityTree/private/types.d.ts +10 -0
- package/lib/providers/ActivityTree/private/types.d.ts.map +1 -0
- package/lib/providers/ActivityTree/private/types.js +2 -0
- package/lib/providers/ActivityTree/private/useActivitiesWithRenderer.d.ts +4 -0
- package/lib/providers/ActivityTree/private/useActivitiesWithRenderer.d.ts.map +1 -0
- package/lib/providers/ActivityTree/private/useActivitiesWithRenderer.js +58 -0
- package/lib/providers/ActivityTree/private/useActivityTreeWithRenderer.d.ts +5 -0
- package/lib/providers/ActivityTree/private/useActivityTreeWithRenderer.d.ts.map +1 -0
- package/lib/providers/ActivityTree/private/useActivityTreeWithRenderer.js +166 -0
- package/lib/providers/ActivityTree/private/useContext.d.ts +3 -0
- package/lib/providers/ActivityTree/private/useContext.d.ts.map +1 -0
- package/lib/providers/ActivityTree/private/useContext.js +24 -0
- package/lib/providers/ActivityTree/useActivityTreeWithRenderer.d.ts +8 -0
- package/lib/providers/ActivityTree/useActivityTreeWithRenderer.d.ts.map +1 -0
- package/lib/providers/ActivityTree/useActivityTreeWithRenderer.js +17 -0
- package/lib/providers/LiveRegionTwin/LiveRegionTwinComposer.d.ts +35 -0
- package/lib/providers/LiveRegionTwin/LiveRegionTwinComposer.d.ts.map +1 -0
- package/lib/providers/LiveRegionTwin/LiveRegionTwinComposer.js +156 -0
- package/lib/providers/LiveRegionTwin/private/Context.d.ts +10 -0
- package/lib/providers/LiveRegionTwin/private/Context.d.ts.map +1 -0
- package/lib/providers/LiveRegionTwin/private/Context.js +13 -0
- package/lib/providers/LiveRegionTwin/private/LiveRegionTwinContainer.d.ts +11 -0
- package/lib/providers/LiveRegionTwin/private/LiveRegionTwinContainer.d.ts.map +1 -0
- package/lib/providers/LiveRegionTwin/private/LiveRegionTwinContainer.js +86 -0
- package/lib/providers/LiveRegionTwin/private/types.d.ts +8 -0
- package/lib/providers/LiveRegionTwin/private/types.d.ts.map +1 -0
- package/lib/providers/LiveRegionTwin/private/types.js +2 -0
- package/lib/providers/LiveRegionTwin/private/useContext.d.ts +3 -0
- package/lib/providers/LiveRegionTwin/private/useContext.d.ts.map +1 -0
- package/lib/providers/LiveRegionTwin/private/useContext.js +24 -0
- package/lib/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.d.ts +2 -0
- package/lib/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.d.ts.map +1 -0
- package/lib/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.js +24 -0
- package/lib/providers/LiveRegionTwin/private/useStaticElementEntries.d.ts +3 -0
- package/lib/providers/LiveRegionTwin/private/useStaticElementEntries.d.ts.map +1 -0
- package/lib/providers/LiveRegionTwin/private/useStaticElementEntries.js +15 -0
- package/lib/providers/LiveRegionTwin/useQueueStaticElement.d.ts +8 -0
- package/lib/providers/LiveRegionTwin/useQueueStaticElement.d.ts.map +1 -0
- package/lib/providers/LiveRegionTwin/useQueueStaticElement.js +20 -0
- package/lib/providers/TranscriptFocus/TranscriptFocusComposer.d.ts +7 -0
- package/lib/providers/TranscriptFocus/TranscriptFocusComposer.d.ts.map +1 -0
- package/lib/providers/TranscriptFocus/TranscriptFocusComposer.js +184 -0
- package/lib/providers/TranscriptFocus/private/Context.d.ts +12 -0
- package/lib/providers/TranscriptFocus/private/Context.d.ts.map +1 -0
- package/lib/providers/TranscriptFocus/private/Context.js +13 -0
- package/lib/providers/TranscriptFocus/private/useContext.d.ts +2 -0
- package/lib/providers/TranscriptFocus/private/useContext.d.ts.map +1 -0
- package/lib/providers/TranscriptFocus/private/useContext.js +24 -0
- package/lib/providers/TranscriptFocus/useActiveDescendantId.d.ts +2 -0
- package/lib/providers/TranscriptFocus/useActiveDescendantId.d.ts.map +1 -0
- package/lib/providers/TranscriptFocus/useActiveDescendantId.js +15 -0
- package/lib/providers/TranscriptFocus/useFocusByActivityKey.d.ts +8 -0
- package/lib/providers/TranscriptFocus/useFocusByActivityKey.d.ts.map +1 -0
- package/lib/providers/TranscriptFocus/useFocusByActivityKey.js +21 -0
- package/lib/providers/TranscriptFocus/useFocusRelativeActivity.d.ts +2 -0
- package/lib/providers/TranscriptFocus/useFocusRelativeActivity.d.ts.map +1 -0
- package/lib/providers/TranscriptFocus/useFocusRelativeActivity.js +15 -0
- package/lib/providers/TranscriptFocus/useFocusedActivityKey.d.ts +2 -0
- package/lib/providers/TranscriptFocus/useFocusedActivityKey.d.ts.map +1 -0
- package/lib/providers/TranscriptFocus/useFocusedActivityKey.js +15 -0
- package/lib/providers/TranscriptFocus/useFocusedExplicitly.d.ts +2 -0
- package/lib/providers/TranscriptFocus/useFocusedExplicitly.d.ts.map +1 -0
- package/lib/providers/TranscriptFocus/useFocusedExplicitly.js +15 -0
- package/lib/providers/TranscriptFocus/useGetDescendantIdByActivityKey.d.ts +2 -0
- package/lib/providers/TranscriptFocus/useGetDescendantIdByActivityKey.d.ts.map +1 -0
- package/lib/providers/TranscriptFocus/useGetDescendantIdByActivityKey.js +15 -0
- package/lib/tsconfig.json +1 -1
- package/lib/types/ScrollPosition.d.ts +6 -0
- package/lib/types/ScrollPosition.d.ts.map +1 -0
- package/lib/types/ScrollPosition.js +2 -0
- package/package.json +33 -40
- package/src/Activity/{Avatar.js → Avatar.tsx} +9 -2
- package/src/Activity/{Bubble.js → Bubble.tsx} +10 -2
- package/src/Activity/CarouselFilmStrip.js +20 -29
- package/src/Activity/CarouselFilmStripAttachment.js +91 -0
- package/src/Activity/{Speak.js → Speak.tsx} +12 -5
- package/src/Activity/{StackedLayout.js → StackedLayout.tsx} +46 -20
- package/src/Attachment/Assets/DownloadIcon.js +8 -1
- package/src/Attachment/{AudioContent.js → AudioContent.tsx} +12 -3
- package/src/Attachment/FileAttachment.js +1 -1
- package/src/Attachment/{FileContent.js → FileContent.tsx} +22 -7
- package/src/Attachment/{HTMLVideoContent.js → HTMLVideoContent.tsx} +10 -2
- package/src/Attachment/{ImageContent.js → ImageContent.tsx} +7 -2
- package/src/Attachment/{TextContent.js → TextContent.tsx} +14 -7
- package/src/Attachment/{VideoContent.js → VideoContent.tsx} +10 -2
- package/src/Attachment/{VimeoContent.js → VimeoContent.tsx} +15 -8
- package/src/Attachment/{YouTubeContent.js → YouTubeContent.tsx} +12 -5
- package/src/{BasicSendBox.js → BasicSendBox.tsx} +9 -5
- package/src/BasicToaster.js +9 -5
- package/src/BasicTranscript.tsx +878 -0
- package/src/{BasicTypingIndicator.js → BasicTypingIndicator.tsx} +4 -3
- package/src/{BasicWebChat.js → BasicWebChat.tsx} +13 -4
- package/src/{Composer.js → Composer.tsx} +82 -71
- package/src/Dictation.js +13 -4
- package/src/{ErrorBox.js → ErrorBox.tsx} +7 -2
- package/src/Middleware/Activity/createCoreMiddleware.tsx +78 -0
- package/src/Middleware/ActivityStatus/SendStatus/{SendStatus.js → SendStatus.tsx} +8 -3
- package/src/Middleware/ActivityStatus/{Timestamp.js → Timestamp.tsx} +8 -2
- package/src/Middleware/ActivityStatus/{createCoreMiddleware.js → createCoreMiddleware.tsx} +3 -1
- package/src/Middleware/ActivityStatus/createSendStatusMiddleware.js +10 -6
- package/src/Middleware/ActivityStatus/createTimestampMiddleware.js +10 -8
- package/src/Middleware/Attachment/createCoreMiddleware.tsx +44 -0
- package/src/Middleware/AttachmentForScreenReader/createCoreMiddleware.tsx +40 -0
- package/src/Middleware/Avatar/{createCoreMiddleware.js → createCoreMiddleware.tsx} +19 -11
- package/src/Middleware/CardAction/createCoreMiddleware.js +51 -42
- package/src/Middleware/GroupActivities/createCoreMiddleware.js +6 -4
- package/src/Middleware/ScrollToEndButton/ScrollToEndButton.js +45 -0
- package/src/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.ts +19 -0
- package/src/Middleware/Toast/createCoreMiddleware.tsx +24 -0
- package/src/Middleware/TypingIndicator/{createCoreMiddleware.js → createCoreMiddleware.tsx} +10 -5
- package/src/{ReactWebChat.js → ReactWebChat.tsx} +25 -7
- package/src/ScreenReaderActivity.js +65 -40
- package/src/{ScreenReaderText.js → ScreenReaderText.tsx} +27 -9
- package/src/SendBox/Assets/AttachmentIcon.js +1 -1
- package/src/SendBox/Assets/MicrophoneIcon.js +1 -1
- package/src/SendBox/{AutoResizeTextArea.js → AutoResizeTextArea.tsx} +30 -4
- package/src/SendBox/{DictationInterims.js → DictationInterims.tsx} +6 -2
- package/src/SendBox/{IconButton.js → IconButton.tsx} +19 -3
- package/src/SendBox/{MicrophoneButton.js → MicrophoneButton.tsx} +35 -25
- package/src/SendBox/{SendButton.js → SendButton.tsx} +8 -3
- package/src/SendBox/{SuggestedAction.js → SuggestedAction.tsx} +62 -39
- package/src/SendBox/{SuggestedActions.js → SuggestedActions.tsx} +70 -22
- package/src/SendBox/{TextBox.js → TextBox.tsx} +21 -7
- package/src/SendBox/{UploadButton.js → UploadButton.tsx} +7 -3
- package/src/Styles/StyleSet/BasicTranscript.ts +34 -20
- package/src/Styles/StyleSet/Bubble.ts +0 -1
- package/src/Styles/StyleSet/CarouselFilmStrip.ts +12 -30
- package/src/Styles/StyleSet/CarouselFilmStripAttachment.ts +57 -0
- package/src/Styles/StyleSet/KeyboardHelp.ts +157 -0
- package/src/Styles/StyleSet/ScrollToEndButton.ts +33 -31
- package/src/Styles/StyleSet/SendBoxButton.ts +84 -13
- package/src/Styles/StyleSet/SendBoxTextBox.ts +1 -2
- package/src/Styles/StyleSet/StackedLayout.ts +13 -11
- package/src/Styles/StyleSet/SuggestedAction.ts +130 -43
- package/src/Styles/StyleSet/SuggestedActions.ts +13 -5
- package/src/Styles/createStyleSet.ts +43 -40
- package/src/Styles/mirrorStyle.js +10 -2
- package/src/Toast/CollapseIcon.js +9 -1
- package/src/Toast/DismissIcon.js +9 -1
- package/src/Toast/ExpandIcon.js +9 -1
- package/src/Toast/NotificationIcon.js +4 -1
- package/src/Toast/createToastMiddleware.tsx +15 -0
- package/src/Transcript/ActivityRow.tsx +124 -0
- package/src/Transcript/ActivityTextAlt.tsx +32 -0
- package/src/Transcript/FocusTrap.tsx +64 -0
- package/src/Transcript/KeyboardHelp.tsx +282 -0
- package/src/Transcript/LiveRegionTranscript.tsx +181 -0
- package/src/Transcript/types.ts +1 -0
- package/src/Transcript/useActivityAccessibleName.ts +85 -0
- package/src/Utils/{AccessibleButton.js → AccessibleButton.tsx} +19 -4
- package/src/Utils/{AccessibleInputText.js → AccessibleInputText.tsx} +48 -5
- package/src/Utils/{AccessibleTextArea.js → AccessibleTextArea.tsx} +67 -6
- package/src/Utils/{FocusRedirector.js → FocusRedirector.tsx} +21 -8
- package/src/Utils/InlineMarkdown.js +18 -2
- package/src/Utils/TypeFocusSink/FocusBox.js +4 -4
- package/src/Utils/TypeFocusSink/getTabIndex.ts +1 -1
- package/src/Utils/TypeFocusSink/inputtableKey.ts +5 -1
- package/src/Utils/activityAltText.ts +135 -0
- package/src/Utils/createCustomEvent.js +7 -1
- package/src/Utils/detectBrowser.js +2 -1
- package/src/Utils/findAncestor.ts +12 -0
- package/src/Utils/getActivityUniqueId.ts +5 -0
- package/src/Utils/intersectionOf.spec.js +2 -0
- package/src/Utils/intersectionOf.ts +14 -0
- package/src/Utils/isZeroOrPositive.ts +7 -0
- package/src/Utils/mapMap.js +7 -1
- package/src/Utils/mapMap.spec.js +2 -0
- package/src/Utils/removeInline.spec.js +2 -0
- package/src/Utils/scrollIntoViewWithBlockNearest.ts +20 -0
- package/src/Utils/shallowEquals.js +8 -1
- package/src/Utils/{singleToArray.js → singleToArray.ts} +1 -1
- package/src/Utils/supportPseudoClass.ts +17 -0
- package/src/Utils/{tabbableElements.js → tabbableElements.ts} +6 -5
- package/src/Utils/walkMarkdownTokens.spec.js +3 -3
- package/src/connectToWebChat.js +11 -4
- package/src/hooks/{index.js → index.ts} +1 -0
- package/src/hooks/internal/BypassSpeechSynthesisPonyfill.js +70 -17
- package/src/hooks/internal/useChanged.ts +17 -0
- package/src/hooks/internal/useDispatchScrollPosition.js +1 -3
- package/src/hooks/internal/useDispatchTranscriptFocusByActivityKey.ts +5 -0
- package/src/hooks/internal/useFocusVisible.ts +22 -0
- package/src/hooks/internal/useMemoWithPrevious.ts +16 -0
- package/src/hooks/internal/useMemoize.spec.js +3 -1
- package/src/hooks/internal/useMemoize.ts +53 -0
- package/src/hooks/internal/useObserveFocusVisible.ts +252 -0
- package/src/hooks/internal/usePrevious.ts +12 -0
- package/src/hooks/internal/useResumeAudioContext.ts +7 -0
- package/src/hooks/internal/useScrollRelative.js +4 -3
- package/src/hooks/internal/useStateRef.ts +31 -0
- package/src/hooks/internal/{useUniqueId.js → useUniqueId.ts} +1 -1
- package/src/hooks/internal/useValueRef.ts +22 -0
- package/src/hooks/{useDictateAbortable.js → useDictateAbortable.ts} +1 -1
- package/src/hooks/{useFocus.js → useFocus.ts} +1 -1
- package/src/hooks/{useFocusSendBox.js → useFocusSendBox.ts} +2 -1
- package/src/hooks/{useObserveScrollPosition.js → useObserveScrollPosition.ts} +6 -1
- package/src/hooks/{useObserveTranscriptFocus.js → useObserveTranscriptFocus.ts} +6 -1
- package/src/hooks/useRenderMarkdownAsHTML.ts +23 -0
- package/src/hooks/{useScrollDown.js → useScrollDown.ts} +1 -1
- package/src/hooks/useScrollTo.ts +16 -0
- package/src/hooks/useScrollToEnd.ts +12 -0
- package/src/hooks/{useScrollUp.js → useScrollUp.ts} +1 -1
- package/src/hooks/{useSendFiles.js → useSendFiles.ts} +3 -2
- package/src/hooks/{useStyleSet.js → useStyleSet.ts} +1 -1
- package/src/hooks/useWebSpeechPonyfill.ts +7 -0
- package/src/index.ts +7 -12
- package/src/providers/ActivityTree/ActivityTreeComposer.tsx +74 -0
- package/src/providers/ActivityTree/private/Context.ts +12 -0
- package/src/providers/ActivityTree/private/types.ts +12 -0
- package/src/providers/ActivityTree/private/useActivitiesWithRenderer.ts +66 -0
- package/src/providers/ActivityTree/private/useActivityTreeWithRenderer.ts +140 -0
- package/src/providers/ActivityTree/private/useContext.ts +15 -0
- package/src/providers/ActivityTree/useActivityTreeWithRenderer.ts +16 -0
- package/src/providers/LiveRegionTwin/LiveRegionTwinComposer.tsx +154 -0
- package/src/providers/LiveRegionTwin/private/Context.ts +15 -0
- package/src/providers/LiveRegionTwin/private/LiveRegionTwinContainer.tsx +64 -0
- package/src/providers/LiveRegionTwin/private/types.ts +10 -0
- package/src/providers/LiveRegionTwin/private/useContext.ts +15 -0
- package/src/providers/LiveRegionTwin/private/useMarkAllAsRenderedEffect.ts +13 -0
- package/src/providers/LiveRegionTwin/private/useStaticElementEntries.ts +7 -0
- package/src/providers/LiveRegionTwin/useQueueStaticElement.ts +12 -0
- package/src/providers/TranscriptFocus/TranscriptFocusComposer.tsx +180 -0
- package/src/providers/TranscriptFocus/private/Context.ts +16 -0
- package/src/providers/TranscriptFocus/private/useContext.ts +13 -0
- package/src/providers/TranscriptFocus/useActiveDescendantId.ts +5 -0
- package/src/providers/TranscriptFocus/useFocusByActivityKey.ts +14 -0
- package/src/providers/TranscriptFocus/useFocusRelativeActivity.ts +5 -0
- package/src/providers/TranscriptFocus/useFocusedActivityKey.ts +5 -0
- package/src/providers/TranscriptFocus/useFocusedExplicitly.ts +5 -0
- package/src/providers/TranscriptFocus/useGetDescendantIdByActivityKey.ts +5 -0
- package/src/tsconfig.json +1 -1
- package/src/types/ScrollPosition.ts +6 -0
- package/.eslintignore +0 -9
- package/lib/Activity/ScrollToEndButton.js +0 -81
- package/lib/Attachment/Assets/ErrorIcon.js +0 -22
- package/lib/Utils/findLastIndex.js +0 -32
- package/lib/Utils/remarkStripMarkdown.js +0 -26
- package/lib/hooks/internal/useAcknowledgedActivity.js +0 -90
- package/lib/hooks/internal/useDispatchTranscriptFocus.js +0 -19
- package/lib/hooks/internal/useStripMarkdown.js +0 -19
- package/src/Activity/ScrollToEndButton.js +0 -58
- package/src/Attachment/Assets/ErrorIcon.js +0 -9
- package/src/BasicTranscript.js +0 -1123
- package/src/Middleware/Activity/createCoreMiddleware.js +0 -71
- package/src/Middleware/Attachment/createCoreMiddleware.js +0 -43
- package/src/Middleware/AttachmentForScreenReader/createCoreMiddleware.js +0 -37
- package/src/Middleware/Toast/createCoreMiddleware.js +0 -20
- package/src/Toast/createToastMiddleware.js +0 -11
- package/src/Utils/findLastIndex.js +0 -11
- package/src/Utils/findLastIndex.spec.js +0 -29
- package/src/Utils/getActivityUniqueId.js +0 -3
- package/src/Utils/intersectionOf.js +0 -11
- package/src/Utils/isZeroOrPositive.js +0 -4
- package/src/Utils/remarkStripMarkdown.js +0 -13
- package/src/hooks/internal/useAcknowledgedActivity.js +0 -65
- package/src/hooks/internal/useChanged.js +0 -10
- package/src/hooks/internal/useDispatchTranscriptFocus.js +0 -7
- package/src/hooks/internal/useMemoize.js +0 -37
- package/src/hooks/internal/useStripMarkdown.js +0 -7
- package/src/hooks/useRenderMarkdownAsHTML.js +0 -20
- package/src/hooks/useScrollTo.js +0 -11
- package/src/hooks/useScrollToEnd.js +0 -11
- package/src/hooks/useWebSpeechPonyfill.js +0 -5
- package/src/index.tsx +0 -35
|
@@ -5,7 +5,8 @@ import useWebChatUIContext from './useWebChatUIContext';
|
|
|
5
5
|
export default function useScrollRelative() {
|
|
6
6
|
const { scrollRelativeCallbacksRef } = useWebChatUIContext();
|
|
7
7
|
|
|
8
|
-
return useCallback(
|
|
9
|
-
scrollRelativeCallbacksRef
|
|
10
|
-
|
|
8
|
+
return useCallback(
|
|
9
|
+
(...args) => scrollRelativeCallbacksRef.current.forEach(callback => callback(...args)),
|
|
10
|
+
[scrollRelativeCallbacksRef]
|
|
11
|
+
);
|
|
11
12
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
|
4
|
+
|
|
5
|
+
export default function useStateRef<T>(
|
|
6
|
+
initialValue?: T
|
|
7
|
+
): readonly [T, Dispatch<SetStateAction<T>>, MutableRefObject<T>] {
|
|
8
|
+
const [_, forceRender] = useState<{}>();
|
|
9
|
+
const valueRef: MutableRefObject<T> = useRef<T>(initialValue);
|
|
10
|
+
|
|
11
|
+
const setter: Dispatch<SetStateAction<T>> = useCallback(
|
|
12
|
+
(value: SetStateAction<T>) => {
|
|
13
|
+
const { current } = valueRef;
|
|
14
|
+
|
|
15
|
+
value = value instanceof Function ? value(current) : value;
|
|
16
|
+
|
|
17
|
+
if (current !== value) {
|
|
18
|
+
valueRef.current = value;
|
|
19
|
+
|
|
20
|
+
forceRender({});
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
[forceRender, valueRef]
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return Object.freeze([valueRef.current, setter, valueRef]) as readonly [
|
|
27
|
+
T,
|
|
28
|
+
Dispatch<SetStateAction<T>>,
|
|
29
|
+
MutableRefObject<T>
|
|
30
|
+
];
|
|
31
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import random from 'math-random';
|
|
5
5
|
|
|
6
|
-
export default function useUniqueId(prefix) {
|
|
6
|
+
export default function useUniqueId(prefix?: string): string {
|
|
7
7
|
const id = useMemo(() => random().toString(36).substr(2, 5), []);
|
|
8
8
|
|
|
9
9
|
prefix = prefix ? `${prefix}--` : '';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// TODO: [P0] #4133 Don't copy.
|
|
2
|
+
import { RefObject, useMemo, useRef } from 'react';
|
|
3
|
+
|
|
4
|
+
export default function useValueRef<T>(value: T): RefObject<T> {
|
|
5
|
+
const ref = useRef<T>();
|
|
6
|
+
const readOnlyRef = useMemo(
|
|
7
|
+
() =>
|
|
8
|
+
Object.create(
|
|
9
|
+
{},
|
|
10
|
+
{
|
|
11
|
+
current: {
|
|
12
|
+
get: () => ref.current
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
),
|
|
16
|
+
[]
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
ref.current = value;
|
|
20
|
+
|
|
21
|
+
return readOnlyRef;
|
|
22
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import useSettableDictateAbortable from './internal/useSettableDictateAbortable';
|
|
2
2
|
|
|
3
|
-
export default function useDictateAbortable() {
|
|
3
|
+
export default function useDictateAbortable(): [boolean] {
|
|
4
4
|
// We are only exporting a read-only version of dictateAbortable.
|
|
5
5
|
const [dictateAbortable] = useSettableDictateAbortable();
|
|
6
6
|
|
|
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import useWebChatUIContext from './internal/useWebChatUIContext';
|
|
4
4
|
|
|
5
|
-
export default function useFocus() {
|
|
5
|
+
export default function useFocus(): (where?: 'main' | 'sendBox' | 'sendBoxWithoutKeyboard') => void {
|
|
6
6
|
const { focusSendBoxCallbacksRef, focusTranscriptCallbacksRef } = useWebChatUIContext();
|
|
7
7
|
|
|
8
8
|
return useCallback(
|
|
@@ -2,7 +2,8 @@ import useFocus from './useFocus';
|
|
|
2
2
|
|
|
3
3
|
let showDeprecationNotes = true;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/** @deprecated Please use `useFocus('sendBox')` instead. */
|
|
6
|
+
export default function useFocusSendBox(): () => void {
|
|
6
7
|
if (showDeprecationNotes) {
|
|
7
8
|
console.warn(
|
|
8
9
|
'botframework-webchat: "useFocusSendBox" is deprecated and will be removed on or after 2022-04-21. Please use "useFocus(\'sendBox\')" instead.'
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import ScrollPosition from '../types/ScrollPosition';
|
|
2
4
|
import useWebChatUIContext from './internal/useWebChatUIContext';
|
|
3
5
|
|
|
4
|
-
export default function useObserveScrollPosition(
|
|
6
|
+
export default function useObserveScrollPosition(
|
|
7
|
+
observer: (scrollPosition: ScrollPosition) => void,
|
|
8
|
+
deps: any[]
|
|
9
|
+
): void {
|
|
5
10
|
if (typeof observer !== 'function') {
|
|
6
11
|
observer = undefined;
|
|
7
12
|
console.warn('botframework-webchat: First argument passed to "useObserveScrollPosition" must be a function.');
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { DirectLineActivity } from 'botframework-webchat-core';
|
|
1
2
|
import { useEffect } from 'react';
|
|
3
|
+
|
|
2
4
|
import useWebChatUIContext from './internal/useWebChatUIContext';
|
|
3
5
|
|
|
4
|
-
export default function useObserveTranscriptFocus(
|
|
6
|
+
export default function useObserveTranscriptFocus(
|
|
7
|
+
observer: (event: { activity: DirectLineActivity }) => void,
|
|
8
|
+
deps: any[]
|
|
9
|
+
): void {
|
|
5
10
|
if (typeof observer !== 'function') {
|
|
6
11
|
observer = undefined;
|
|
7
12
|
console.warn('botframework-webchat: First argument passed to "useObserveTranscriptFocus" must be a function.');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { hooks, StrictStyleOptions } from 'botframework-webchat-api';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
import useWebChatUIContext from './internal/useWebChatUIContext';
|
|
5
|
+
|
|
6
|
+
const { useLocalizer, useStyleOptions } = hooks;
|
|
7
|
+
|
|
8
|
+
export default function useRenderMarkdownAsHTML(): (
|
|
9
|
+
markdown: string,
|
|
10
|
+
styleOptions?: StrictStyleOptions,
|
|
11
|
+
options?: { externalLinkAlt: string }
|
|
12
|
+
) => string {
|
|
13
|
+
const { renderMarkdown } = useWebChatUIContext();
|
|
14
|
+
const [styleOptions] = useStyleOptions();
|
|
15
|
+
const localize = useLocalizer();
|
|
16
|
+
|
|
17
|
+
const externalLinkAlt = localize('MARKDOWN_EXTERNAL_LINK_ALT');
|
|
18
|
+
|
|
19
|
+
return useMemo(
|
|
20
|
+
() => renderMarkdown && (markdown => renderMarkdown(markdown, styleOptions, { externalLinkAlt })),
|
|
21
|
+
[externalLinkAlt, renderMarkdown, styleOptions]
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import useScrollRelative from './internal/useScrollRelative';
|
|
4
4
|
|
|
5
|
-
export default function useScrollDown() {
|
|
5
|
+
export default function useScrollDown(): (options?: { displacement: number }) => void {
|
|
6
6
|
const scrollRelative = useScrollRelative();
|
|
7
7
|
|
|
8
8
|
return useCallback((...args) => scrollRelative('down', ...args), [scrollRelative]);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import ScrollPosition from '../types/ScrollPosition';
|
|
4
|
+
import useWebChatUIContext from './internal/useWebChatUIContext';
|
|
5
|
+
|
|
6
|
+
export default function useScrollTo(): (
|
|
7
|
+
position: ScrollPosition,
|
|
8
|
+
scrollToOptions: { behavior?: 'auto' | 'smooth' }
|
|
9
|
+
) => void {
|
|
10
|
+
const { scrollToCallbacksRef } = useWebChatUIContext();
|
|
11
|
+
|
|
12
|
+
return useCallback(
|
|
13
|
+
(...args) => scrollToCallbacksRef.current.forEach(callback => callback(...args)),
|
|
14
|
+
[scrollToCallbacksRef]
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import useWebChatUIContext from './internal/useWebChatUIContext';
|
|
4
|
+
|
|
5
|
+
export default function useScrollToEnd(): () => void {
|
|
6
|
+
const { scrollToEndCallbacksRef } = useWebChatUIContext();
|
|
7
|
+
|
|
8
|
+
return useCallback(
|
|
9
|
+
() => scrollToEndCallbacksRef.current.forEach(callback => callback({ behavior: 'smooth' })),
|
|
10
|
+
[scrollToEndCallbacksRef]
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import useScrollRelative from './internal/useScrollRelative';
|
|
4
4
|
|
|
5
|
-
export default function useScrollUp() {
|
|
5
|
+
export default function useScrollUp(): (options?: { displacement: number }) => void {
|
|
6
6
|
const scrollRelative = useScrollRelative();
|
|
7
7
|
|
|
8
8
|
return useCallback((...args) => scrollRelative('up', ...args), [scrollRelative]);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1024] }] */
|
|
2
2
|
|
|
3
|
+
import { DirectLineAttachment } from 'botframework-webchat-core';
|
|
3
4
|
import { hooks } from 'botframework-webchat-api';
|
|
4
5
|
import { useCallback } from 'react';
|
|
5
6
|
|
|
@@ -19,7 +20,7 @@ async function makeThumbnail(file, width, height, contentType, quality) {
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
export default function useSendFiles() {
|
|
23
|
+
export default function useSendFiles(): (files: File[]) => void {
|
|
23
24
|
const sendFiles = useAPISendFiles();
|
|
24
25
|
const [
|
|
25
26
|
{
|
|
@@ -40,7 +41,7 @@ export default function useSendFiles() {
|
|
|
40
41
|
// TODO: [P3] We need to find revokeObjectURL on the UI side
|
|
41
42
|
// Redux store should not know about the browser environment
|
|
42
43
|
// One fix is to use ArrayBuffer instead of object URL, but that would requires change to DirectLineJS
|
|
43
|
-
const attachments = await Promise.all(
|
|
44
|
+
const attachments: DirectLineAttachment[] = await Promise.all(
|
|
44
45
|
[].map.call(files, async file => {
|
|
45
46
|
let thumbnail;
|
|
46
47
|
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { concatMiddleware, hooks as apiHooks, Localize, localize } from 'botframework-webchat-api';
|
|
2
|
+
|
|
3
|
+
import ReactWebChat, { ReactWebChatProps } from './ReactWebChat';
|
|
2
4
|
|
|
3
|
-
import Composer from './Composer';
|
|
5
|
+
import Composer, { ComposerProps } from './Composer';
|
|
4
6
|
|
|
5
|
-
import BasicWebChat from './BasicWebChat';
|
|
7
|
+
import BasicWebChat, { BasicWebChatProps } from './BasicWebChat';
|
|
6
8
|
|
|
7
9
|
import Avatar from './Activity/Avatar';
|
|
8
10
|
import Bubble from './Activity/Bubble';
|
|
@@ -35,14 +37,6 @@ import createCoreAttachmentMiddleware from './Middleware/Attachment/createCoreMi
|
|
|
35
37
|
import createStyleSet from './Styles/createStyleSet';
|
|
36
38
|
import getTabIndex from './Utils/TypeFocusSink/getTabIndex';
|
|
37
39
|
|
|
38
|
-
declare module 'botframework-webchat-api' {
|
|
39
|
-
export function concatMiddleware(): any;
|
|
40
|
-
export const hooks: any;
|
|
41
|
-
export function Localize(): any;
|
|
42
|
-
export function localize(): any;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
import { concatMiddleware, hooks as apiHooks, Localize, localize } from 'botframework-webchat-api';
|
|
46
40
|
import * as componentHooks from './hooks/index';
|
|
47
41
|
|
|
48
42
|
const hooks = {
|
|
@@ -50,7 +44,6 @@ const hooks = {
|
|
|
50
44
|
...componentHooks
|
|
51
45
|
};
|
|
52
46
|
|
|
53
|
-
// eslint-disable-next-line no-undef
|
|
54
47
|
const version = process.env.npm_package_version;
|
|
55
48
|
|
|
56
49
|
const Components = {
|
|
@@ -111,3 +104,5 @@ export {
|
|
|
111
104
|
localize,
|
|
112
105
|
version
|
|
113
106
|
};
|
|
107
|
+
|
|
108
|
+
export type { BasicWebChatProps, ComposerProps, ReactWebChatProps };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { hooks } from 'botframework-webchat-api';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { ActivityComponentFactory } from 'botframework-webchat-api';
|
|
5
|
+
import type { DirectLineActivity } from 'botframework-webchat-core';
|
|
6
|
+
import type { FC, PropsWithChildren } from 'react';
|
|
7
|
+
|
|
8
|
+
import { ActivityWithRenderer, ReadonlyActivityTree } from './private/types';
|
|
9
|
+
import ActivityTreeContext from './private/Context';
|
|
10
|
+
import useActivitiesWithRenderer from './private/useActivitiesWithRenderer';
|
|
11
|
+
import useActivityTreeContext from './private/useContext';
|
|
12
|
+
import useActivityTreeWithRenderer from './private/useActivityTreeWithRenderer';
|
|
13
|
+
import useMemoWithPrevious from '../../hooks/internal/useMemoWithPrevious';
|
|
14
|
+
|
|
15
|
+
import type { ActivityTreeContextType } from './private/Context';
|
|
16
|
+
|
|
17
|
+
type ActivityTreeComposerProps = PropsWithChildren<{}>;
|
|
18
|
+
|
|
19
|
+
const { useActivities, useCreateActivityRenderer } = hooks;
|
|
20
|
+
|
|
21
|
+
const ActivityTreeComposer: FC<ActivityTreeComposerProps> = ({ children }) => {
|
|
22
|
+
const existingContext = useActivityTreeContext(false);
|
|
23
|
+
|
|
24
|
+
if (existingContext) {
|
|
25
|
+
throw new Error('botframework-webchat internal: <ActivityTreeComposer> should not be nested.');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const [activities]: [DirectLineActivity[]] = useActivities();
|
|
29
|
+
const createActivityRenderer: ActivityComponentFactory = useCreateActivityRenderer();
|
|
30
|
+
|
|
31
|
+
const activitiesWithRenderer = useActivitiesWithRenderer(activities, createActivityRenderer);
|
|
32
|
+
|
|
33
|
+
const activityTreeWithRenderer = useActivityTreeWithRenderer(activitiesWithRenderer);
|
|
34
|
+
|
|
35
|
+
const flattenedActivityTreeWithRenderer = useMemoWithPrevious<Readonly<ActivityWithRenderer[]>>(
|
|
36
|
+
prevFlattenedActivityTree => {
|
|
37
|
+
const nextFlattenedActivityTree = Object.freeze(
|
|
38
|
+
activityTreeWithRenderer.reduce<ActivityWithRenderer[]>(
|
|
39
|
+
(intermediate, entriesWithSameSender) =>
|
|
40
|
+
entriesWithSameSender.reduce<ActivityWithRenderer[]>(
|
|
41
|
+
(intermediate, entriesWithSameSenderAndStatus) =>
|
|
42
|
+
entriesWithSameSenderAndStatus.reduce<ActivityWithRenderer[]>((intermediate, entry) => {
|
|
43
|
+
intermediate.push(entry);
|
|
44
|
+
|
|
45
|
+
return intermediate;
|
|
46
|
+
}, intermediate),
|
|
47
|
+
intermediate
|
|
48
|
+
),
|
|
49
|
+
[]
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return nextFlattenedActivityTree.length === prevFlattenedActivityTree?.length &&
|
|
54
|
+
nextFlattenedActivityTree.every((item, index) => item === prevFlattenedActivityTree[+index])
|
|
55
|
+
? prevFlattenedActivityTree
|
|
56
|
+
: nextFlattenedActivityTree;
|
|
57
|
+
},
|
|
58
|
+
[activityTreeWithRenderer]
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const contextValue: ActivityTreeContextType = useMemo(
|
|
62
|
+
() => ({
|
|
63
|
+
activityTreeWithRendererState: Object.freeze([activityTreeWithRenderer]) as readonly [ReadonlyActivityTree],
|
|
64
|
+
flattenedActivityTreeWithRendererState: Object.freeze([flattenedActivityTreeWithRenderer]) as readonly [
|
|
65
|
+
readonly ActivityWithRenderer[]
|
|
66
|
+
]
|
|
67
|
+
}),
|
|
68
|
+
[activityTreeWithRenderer, flattenedActivityTreeWithRenderer]
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return <ActivityTreeContext.Provider value={contextValue}>{children}</ActivityTreeContext.Provider>;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default ActivityTreeComposer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { ActivityWithRenderer, ReadonlyActivityTree } from './types';
|
|
4
|
+
|
|
5
|
+
type ActivityTreeContextType = {
|
|
6
|
+
activityTreeWithRendererState: readonly [ReadonlyActivityTree];
|
|
7
|
+
flattenedActivityTreeWithRendererState: readonly [readonly ActivityWithRenderer[]];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default createContext<ActivityTreeContextType>(undefined);
|
|
11
|
+
|
|
12
|
+
export type { ActivityTreeContextType };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ActivityComponentFactory } from 'botframework-webchat-api';
|
|
2
|
+
import type { DirectLineActivity } from 'botframework-webchat-core';
|
|
3
|
+
|
|
4
|
+
type ActivityWithRenderer = {
|
|
5
|
+
activity: DirectLineActivity;
|
|
6
|
+
renderActivity: Exclude<ReturnType<ActivityComponentFactory>, false>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type ActivityTree = ActivityWithRenderer[][][];
|
|
10
|
+
type ReadonlyActivityTree = readonly (readonly (readonly ActivityWithRenderer[])[])[];
|
|
11
|
+
|
|
12
|
+
export type { ActivityTree, ActivityWithRenderer, ReadonlyActivityTree };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { DirectLineActivity } from 'botframework-webchat-core';
|
|
4
|
+
|
|
5
|
+
import useMemoize from '../../../hooks/internal/useMemoize';
|
|
6
|
+
|
|
7
|
+
import type { ActivityWithRenderer } from './types';
|
|
8
|
+
|
|
9
|
+
export default function useActivitiesWithRenderer(
|
|
10
|
+
activities: readonly DirectLineActivity[],
|
|
11
|
+
createActivityRenderer
|
|
12
|
+
): readonly ActivityWithRenderer[] {
|
|
13
|
+
const createActivityRendererWithLiteralArgs = useCallback(
|
|
14
|
+
(activity: DirectLineActivity, nextVisibleActivity: DirectLineActivity) =>
|
|
15
|
+
createActivityRenderer({ activity, nextVisibleActivity }),
|
|
16
|
+
[createActivityRenderer]
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
// Create a memoized context of the createActivityRenderer function.
|
|
20
|
+
// TODO: [P2] Rename useMemoize to useMemoAll
|
|
21
|
+
const entries = useMemoize(
|
|
22
|
+
createActivityRendererWithLiteralArgs,
|
|
23
|
+
createActivityRendererWithLiteralArgsMemoized => {
|
|
24
|
+
// All calls to createActivityRendererWithLiteralArgsMemoized() in this function will be memoized (LRU = 1).
|
|
25
|
+
// In the next render cycle, calls to createActivityRendererWithLiteralArgsMemoized() might return the memoized result instead.
|
|
26
|
+
// This is an improvement to React useMemo(), because it only allows 1 memoization.
|
|
27
|
+
// useMemoize() allows any number of memoization.
|
|
28
|
+
|
|
29
|
+
const activitiesWithRenderer: ActivityWithRenderer[] = [];
|
|
30
|
+
let nextVisibleActivity: DirectLineActivity;
|
|
31
|
+
|
|
32
|
+
for (let index = activities.length - 1; index >= 0; index--) {
|
|
33
|
+
const activity = activities[+index];
|
|
34
|
+
const renderActivity = createActivityRendererWithLiteralArgsMemoized(activity, nextVisibleActivity);
|
|
35
|
+
|
|
36
|
+
if (renderActivity) {
|
|
37
|
+
activitiesWithRenderer.splice(0, 0, {
|
|
38
|
+
activity,
|
|
39
|
+
renderActivity
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
nextVisibleActivity = activity;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return Object.freeze(activitiesWithRenderer);
|
|
47
|
+
},
|
|
48
|
+
[activities]
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const prevEntriesRef = useRef<readonly ActivityWithRenderer[]>([]);
|
|
52
|
+
const { current: prevEntries } = prevEntriesRef;
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
prevEntries.length !== entries.length ||
|
|
56
|
+
prevEntries.some((prevEntry, index) => {
|
|
57
|
+
const entry = entries[+index];
|
|
58
|
+
|
|
59
|
+
return entry.activity !== prevEntry.activity || entry.renderActivity !== prevEntry.renderActivity;
|
|
60
|
+
})
|
|
61
|
+
) {
|
|
62
|
+
prevEntriesRef.current = entries;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return prevEntriesRef.current;
|
|
66
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { hooks } from 'botframework-webchat-api';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { DirectLineActivity } from 'botframework-webchat-core';
|
|
5
|
+
|
|
6
|
+
import intersectionOf from '../../../Utils/intersectionOf';
|
|
7
|
+
import removeInline from '../../../Utils/removeInline';
|
|
8
|
+
|
|
9
|
+
import type { ActivityWithRenderer, ReadonlyActivityTree } from './types';
|
|
10
|
+
|
|
11
|
+
const { useGroupActivities } = hooks;
|
|
12
|
+
|
|
13
|
+
function validateAllEntriesTagged(
|
|
14
|
+
entries: readonly ActivityWithRenderer[],
|
|
15
|
+
bins: readonly (readonly ActivityWithRenderer[])[]
|
|
16
|
+
): boolean {
|
|
17
|
+
return entries.every(entry => bins.some(bin => bin.includes(entry)));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Activity tree is a multidimensional array, while activities is a 1D array.
|
|
21
|
+
// - The first dimension of the array contains activities with same sender;
|
|
22
|
+
// - The second dimension of the array contains activities with same status.
|
|
23
|
+
|
|
24
|
+
// [
|
|
25
|
+
// [
|
|
26
|
+
// // Both messages are from bot and is sent as a batch, we will group them as an array.
|
|
27
|
+
// 'Bot: Hello!'
|
|
28
|
+
// 'Bot: What can I help today?'
|
|
29
|
+
// ],
|
|
30
|
+
// [
|
|
31
|
+
// 'User: What is the weather?'
|
|
32
|
+
// ],
|
|
33
|
+
// [
|
|
34
|
+
// 'Bot: Let me look it up... hold on.'
|
|
35
|
+
// ],
|
|
36
|
+
// [
|
|
37
|
+
// // This message is in a different group because it is more than a few seconds apart from the previous message.
|
|
38
|
+
// 'Bot: Here is the weather forecast.'
|
|
39
|
+
// ]
|
|
40
|
+
// ]
|
|
41
|
+
|
|
42
|
+
function useActivityTreeWithRenderer(entries: readonly ActivityWithRenderer[]): ReadonlyActivityTree {
|
|
43
|
+
const groupActivities = useGroupActivities();
|
|
44
|
+
|
|
45
|
+
// We bin activities in 2 different ways:
|
|
46
|
+
// - `activitiesBySender` is a 2D array containing activities with same sender
|
|
47
|
+
// - `activitiesByStatus` is a 2D array containing activities with same status
|
|
48
|
+
// Both arrays should contains all activities.
|
|
49
|
+
|
|
50
|
+
const { entriesBySender, entriesByStatus } = useMemo<{
|
|
51
|
+
entriesBySender: readonly (readonly DirectLineActivity[])[];
|
|
52
|
+
entriesByStatus: readonly (readonly DirectLineActivity[])[];
|
|
53
|
+
}>(() => {
|
|
54
|
+
const visibleActivities = entries.map(({ activity }) => activity);
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
sender: activitiesBySender,
|
|
58
|
+
status: activitiesByStatus
|
|
59
|
+
}: {
|
|
60
|
+
sender: readonly (readonly DirectLineActivity[])[];
|
|
61
|
+
status: readonly (readonly DirectLineActivity[])[];
|
|
62
|
+
} = groupActivities({
|
|
63
|
+
activities: visibleActivities
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const [entriesBySender, entriesByStatus] = [activitiesBySender, activitiesByStatus].map(bins =>
|
|
67
|
+
bins.map(bin => bin.map(activity => entries.find(entry => entry.activity === activity)))
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
if (!validateAllEntriesTagged(visibleActivities, activitiesBySender)) {
|
|
71
|
+
console.warn(
|
|
72
|
+
'botframework-webchat: Not every activities are grouped in the "sender" property. Please fix "groupActivitiesMiddleware" and group every activities.'
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!validateAllEntriesTagged(visibleActivities, activitiesByStatus)) {
|
|
77
|
+
console.warn(
|
|
78
|
+
'botframework-webchat: Not every activities are grouped in the "status" property. Please fix "groupActivitiesMiddleware" and group every activities.'
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
entriesBySender,
|
|
84
|
+
entriesByStatus
|
|
85
|
+
};
|
|
86
|
+
}, [entries, groupActivities]);
|
|
87
|
+
|
|
88
|
+
// Create a tree of activities with 2 dimensions: sender, followed by status.
|
|
89
|
+
|
|
90
|
+
const activityTree: ReadonlyActivityTree = useMemo(() => {
|
|
91
|
+
const entriesPendingGrouping = [...entries];
|
|
92
|
+
const activityTree: (readonly (readonly ActivityWithRenderer[])[])[] = [];
|
|
93
|
+
|
|
94
|
+
while (entriesPendingGrouping.length) {
|
|
95
|
+
const entriesWithSameSender = entriesBySender.find(bin => bin.includes(entriesPendingGrouping[0]));
|
|
96
|
+
const senderTree: (readonly ActivityWithRenderer[])[] = [];
|
|
97
|
+
|
|
98
|
+
entriesWithSameSender.forEach(entry => {
|
|
99
|
+
const entriesWithSameStatus = entriesByStatus.find(bin => bin.includes(entry));
|
|
100
|
+
|
|
101
|
+
const entriesWithSameSenderAndStatus = intersectionOf<ActivityWithRenderer>(
|
|
102
|
+
entriesPendingGrouping,
|
|
103
|
+
entriesWithSameSender,
|
|
104
|
+
entriesWithSameStatus
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
if (entriesWithSameSenderAndStatus.length) {
|
|
108
|
+
senderTree.push(Object.freeze(entriesWithSameSenderAndStatus));
|
|
109
|
+
removeInline(entriesPendingGrouping, ...entriesWithSameSenderAndStatus);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
activityTree.push(Object.freeze(senderTree));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Assertion: All entries must be assigned to the activityTree.
|
|
117
|
+
if (
|
|
118
|
+
!entries.every(activity =>
|
|
119
|
+
activityTree.some(activitiesWithSameSender =>
|
|
120
|
+
activitiesWithSameSender.some(activitiesWithSameSenderAndStatus =>
|
|
121
|
+
activitiesWithSameSenderAndStatus.includes(activity)
|
|
122
|
+
)
|
|
123
|
+
)
|
|
124
|
+
)
|
|
125
|
+
) {
|
|
126
|
+
console.warn('botframework-webchat internal: Not all visible activities are grouped in the activityTree.', {
|
|
127
|
+
entries,
|
|
128
|
+
activityTree
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return Object.freeze(activityTree);
|
|
133
|
+
}, [entriesBySender, entriesByStatus, entries]);
|
|
134
|
+
|
|
135
|
+
return activityTree;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export type { ActivityWithRenderer };
|
|
139
|
+
|
|
140
|
+
export default useActivityTreeWithRenderer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import ActivityTreeContext from './Context';
|
|
4
|
+
|
|
5
|
+
import type { ActivityTreeContextType } from './Context';
|
|
6
|
+
|
|
7
|
+
export default function useActivityTreeContext(thrownOnUndefined = true): ActivityTreeContextType {
|
|
8
|
+
const contextValue = useContext(ActivityTreeContext);
|
|
9
|
+
|
|
10
|
+
if (thrownOnUndefined && !contextValue) {
|
|
11
|
+
throw new Error('botframework-webchat internal: This hook can only be used under <ActivityTreeComposer>.');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return contextValue;
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import useActivityTreeContext from './private/useContext';
|
|
2
|
+
|
|
3
|
+
import type { ActivityWithRenderer, ReadonlyActivityTree } from './private/types';
|
|
4
|
+
|
|
5
|
+
export default function useActivityTreeWithRenderer(options?: { flat?: false }): readonly [ReadonlyActivityTree];
|
|
6
|
+
export default function useActivityTreeWithRenderer(options: {
|
|
7
|
+
flat: true;
|
|
8
|
+
}): readonly [readonly ActivityWithRenderer[]];
|
|
9
|
+
|
|
10
|
+
export default function useActivityTreeWithRenderer(options: { flat?: boolean } = {}) {
|
|
11
|
+
const context = useActivityTreeContext();
|
|
12
|
+
|
|
13
|
+
return options?.flat === true
|
|
14
|
+
? context.flattenedActivityTreeWithRendererState
|
|
15
|
+
: context.activityTreeWithRendererState;
|
|
16
|
+
}
|