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.
- package/.eslintrc.yml +4 -106
- package/.prettierrc.yml +1 -1
- package/lib/Activity/CarouselFilmStrip.js +1 -1
- package/lib/Activity/CarouselFilmStripAttachment.js +1 -1
- package/lib/Activity/CarouselLayout.js +3 -3
- package/lib/Activity/Speak.d.ts +2 -2
- package/lib/Activity/Speak.d.ts.map +1 -1
- package/lib/Activity/Speak.js +15 -8
- package/lib/Activity/StackedLayout.d.ts +5 -3
- package/lib/Activity/StackedLayout.d.ts.map +1 -1
- package/lib/Activity/StackedLayout.js +16 -21
- package/lib/Attachment/FileAttachment.js +2 -2
- package/lib/Attachment/FileContent.d.ts.map +1 -1
- package/lib/Attachment/FileContent.js +11 -1
- package/lib/BasicSendBox.d.ts.map +1 -1
- package/lib/BasicSendBox.js +8 -9
- package/lib/BasicToast.js +1 -1
- package/lib/BasicToaster.js +6 -3
- package/lib/BasicTranscript.d.ts +7 -0
- package/lib/BasicTranscript.d.ts.map +1 -0
- package/lib/BasicTranscript.js +386 -728
- package/lib/BasicTypingIndicator.d.ts +2 -1
- package/lib/BasicTypingIndicator.d.ts.map +1 -1
- package/lib/BasicTypingIndicator.js +12 -4
- package/lib/Composer.d.ts.map +1 -1
- package/lib/Composer.js +37 -32
- package/lib/ConnectivityStatus/Connecting.js +1 -1
- package/lib/Dictation.js +1 -1
- package/lib/Middleware/Activity/createCoreMiddleware.d.ts.map +1 -1
- package/lib/Middleware/Activity/createCoreMiddleware.js +9 -12
- package/lib/Middleware/ActivityStatus/SendStatus/SendFailedRetry.js +1 -1
- package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.d.ts +2 -2
- package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.d.ts.map +1 -1
- package/lib/Middleware/ActivityStatus/SendStatus/SendStatus.js +5 -4
- package/lib/Middleware/ActivityStatus/Timestamp.d.ts +2 -2
- package/lib/Middleware/ActivityStatus/Timestamp.d.ts.map +1 -1
- package/lib/Middleware/ActivityStatus/Timestamp.js +4 -2
- package/lib/Middleware/ActivityStatus/createSendStatusMiddleware.js +20 -17
- package/lib/Middleware/Attachment/createCoreMiddleware.js +2 -5
- package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.d.ts.map +1 -1
- package/lib/Middleware/AttachmentForScreenReader/createCoreMiddleware.js +1 -1
- package/lib/Middleware/Avatar/createCoreMiddleware.d.ts.map +1 -1
- package/lib/Middleware/Avatar/createCoreMiddleware.js +2 -3
- package/lib/Middleware/CardAction/createCoreMiddleware.js +10 -3
- package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.d.ts.map +1 -1
- package/lib/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.js +1 -1
- package/lib/Middleware/Toast/createCoreMiddleware.d.ts.map +1 -1
- package/lib/Middleware/Toast/createCoreMiddleware.js +1 -1
- package/lib/Middleware/TypingIndicator/createCoreMiddleware.d.ts.map +1 -1
- package/lib/Middleware/TypingIndicator/createCoreMiddleware.js +8 -6
- package/lib/ReactWebChat.js +2 -2
- package/lib/ScreenReaderActivity.js +15 -6
- package/lib/ScreenReaderText.d.ts +9 -0
- package/lib/ScreenReaderText.d.ts.map +1 -0
- package/lib/ScreenReaderText.js +22 -8
- package/lib/SendBox/AutoResizeTextArea.js +1 -1
- package/lib/SendBox/DictationInterims.js +1 -1
- package/lib/SendBox/IconButton.d.ts +11 -0
- package/lib/SendBox/IconButton.d.ts.map +1 -0
- package/lib/SendBox/IconButton.js +26 -6
- package/lib/SendBox/MicrophoneButton.js +2 -2
- package/lib/SendBox/SendButton.js +2 -2
- package/lib/SendBox/SuggestedAction.d.ts +17 -0
- package/lib/SendBox/SuggestedAction.d.ts.map +1 -0
- package/lib/SendBox/SuggestedAction.js +26 -17
- package/lib/SendBox/SuggestedActions.d.ts.map +1 -1
- package/lib/SendBox/SuggestedActions.js +26 -9
- package/lib/SendBox/TextBox.js +4 -4
- package/lib/SendBox/UploadButton.js +4 -4
- package/lib/Styles/StyleSet/BasicTranscript.d.ts +13 -5
- package/lib/Styles/StyleSet/BasicTranscript.d.ts.map +1 -1
- package/lib/Styles/StyleSet/BasicTranscript.js +21 -9
- package/lib/Styles/StyleSet/Bubble.d.ts.map +1 -1
- package/lib/Styles/StyleSet/Bubble.js +3 -3
- package/lib/Styles/StyleSet/CarouselFilmStrip.d.ts.map +1 -1
- package/lib/Styles/StyleSet/CarouselFilmStrip.js +3 -3
- package/lib/Styles/StyleSet/CarouselFilmStripAttachment.d.ts.map +1 -1
- package/lib/Styles/StyleSet/CarouselFilmStripAttachment.js +3 -3
- 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/ScrollToEndButton.d.ts +1 -1
- package/lib/Styles/StyleSet/ScrollToEndButton.js +2 -2
- package/lib/Styles/StyleSet/SendBoxButton.d.ts +56 -10
- package/lib/Styles/StyleSet/SendBoxButton.d.ts.map +1 -1
- package/lib/Styles/StyleSet/SendBoxButton.js +76 -12
- package/lib/Styles/StyleSet/SendBoxTextBox.d.ts +1 -1
- package/lib/Styles/StyleSet/SendBoxTextBox.d.ts.map +1 -1
- package/lib/Styles/StyleSet/SendBoxTextBox.js +3 -3
- package/lib/Styles/StyleSet/StackedLayout.d.ts.map +1 -1
- package/lib/Styles/StyleSet/StackedLayout.js +1 -1
- package/lib/Styles/StyleSet/SuggestedAction.d.ts +73 -28
- package/lib/Styles/StyleSet/SuggestedAction.d.ts.map +1 -1
- package/lib/Styles/StyleSet/SuggestedAction.js +116 -41
- package/lib/Styles/StyleSet/SuggestedActions.d.ts +13 -6
- package/lib/Styles/StyleSet/SuggestedActions.d.ts.map +1 -1
- package/lib/Styles/StyleSet/SuggestedActions.js +13 -6
- package/lib/Styles/createStyleSet.d.ts +324 -55
- package/lib/Styles/createStyleSet.d.ts.map +1 -1
- package/lib/Styles/createStyleSet.js +6 -3
- package/lib/Styles/mirrorStyle.js +12 -3
- package/lib/Toast/NotificationIcon.js +7 -3
- package/lib/Toast/createToastMiddleware.d.ts.map +1 -1
- package/lib/Toast/createToastMiddleware.js +1 -1
- package/lib/Transcript/ActivityRow.d.ts +9 -0
- package/lib/Transcript/ActivityRow.d.ts.map +1 -0
- package/lib/Transcript/ActivityRow.js +159 -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 +229 -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/Transcript/useTypistNames.d.ts +3 -0
- package/lib/Transcript/useTypistNames.d.ts.map +1 -0
- package/lib/Transcript/useTypistNames.js +61 -0
- package/lib/Utils/AccessKeySink/Surface.js +1 -1
- package/lib/Utils/AccessibleButton.d.ts +11 -0
- package/lib/Utils/AccessibleButton.d.ts.map +1 -0
- package/lib/Utils/AccessibleButton.js +12 -7
- package/lib/Utils/AccessibleInputText.js +1 -1
- package/lib/Utils/AccessibleTextArea.js +1 -1
- package/lib/Utils/CroppedImage.js +1 -1
- package/lib/Utils/FocusRedirector.d.ts +9 -0
- package/lib/Utils/FocusRedirector.d.ts.map +1 -0
- package/lib/Utils/FocusRedirector.js +17 -14
- package/lib/Utils/InlineMarkdown.js +15 -8
- package/lib/Utils/TypeFocusSink/FocusBox.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/activityAltText.d.ts +8 -0
- package/lib/Utils/activityAltText.d.ts.map +1 -0
- package/lib/Utils/addTargetBlankToHyperlinksMarkdown.js +2 -2
- package/lib/Utils/createCustomEvent.js +8 -2
- package/lib/Utils/detectBrowser.js +4 -2
- package/lib/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingWorker.js +1 -1
- package/lib/Utils/downscaleImageToDataURL/index.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 +9 -2
- package/lib/Utils/readDataURIToBlob.js +1 -1
- 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/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 +15 -7
- package/lib/hooks/index.js +24 -24
- package/lib/hooks/internal/BypassSpeechSynthesisPonyfill.js +8 -7
- 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/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/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 +11 -2
- 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/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/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/useFocus.d.ts +1 -1
- package/lib/hooks/useFocus.d.ts.map +1 -1
- package/lib/hooks/useFocus.js +1 -1
- package/lib/hooks/useObserveTranscriptFocus.d.ts +2 -2
- package/lib/hooks/useObserveTranscriptFocus.d.ts.map +1 -1
- package/lib/hooks/useObserveTranscriptFocus.js +1 -1
- package/lib/hooks/useRenderMarkdownAsHTML.d.ts.map +1 -1
- package/lib/hooks/useRenderMarkdownAsHTML.js +1 -1
- package/lib/hooks/useScrollTo.d.ts.map +1 -1
- package/lib/hooks/useScrollTo.js +1 -1
- package/lib/hooks/useScrollToEnd.d.ts.map +1 -1
- package/lib/hooks/useScrollToEnd.js +1 -1
- package/lib/hooks/useSendFiles.d.ts.map +1 -1
- package/lib/hooks/useSendFiles.js +4 -4
- package/lib/index.d.ts +13 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +20 -18
- 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 +37 -0
- package/lib/providers/LiveRegionTwin/LiveRegionTwinComposer.d.ts.map +1 -0
- package/lib/providers/LiveRegionTwin/LiveRegionTwinComposer.js +160 -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 +12 -0
- package/lib/providers/LiveRegionTwin/private/LiveRegionTwinContainer.d.ts.map +1 -0
- package/lib/providers/LiveRegionTwin/private/LiveRegionTwinContainer.js +100 -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/package.json +30 -33
- package/src/Activity/CarouselFilmStripAttachment.js +0 -1
- package/src/Activity/Speak.tsx +21 -18
- package/src/Activity/StackedLayout.tsx +30 -35
- package/src/Attachment/FileAttachment.js +1 -1
- package/src/Attachment/FileContent.tsx +12 -0
- package/src/BasicSendBox.tsx +3 -2
- package/src/BasicToaster.js +5 -1
- package/src/BasicTranscript.tsx +894 -0
- package/src/BasicTypingIndicator.tsx +3 -2
- package/src/Composer.tsx +41 -29
- package/src/Middleware/Activity/createCoreMiddleware.tsx +47 -46
- package/src/Middleware/ActivityStatus/SendStatus/SendStatus.tsx +5 -3
- package/src/Middleware/ActivityStatus/Timestamp.tsx +5 -3
- package/src/Middleware/ActivityStatus/createSendStatusMiddleware.js +2 -0
- package/src/Middleware/Attachment/createCoreMiddleware.tsx +28 -28
- package/src/Middleware/AttachmentForScreenReader/createCoreMiddleware.tsx +25 -23
- package/src/Middleware/Avatar/createCoreMiddleware.tsx +9 -8
- package/src/Middleware/CardAction/createCoreMiddleware.js +9 -2
- package/src/Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware.ts +11 -9
- package/src/Middleware/Toast/createCoreMiddleware.tsx +12 -10
- package/src/Middleware/TypingIndicator/createCoreMiddleware.tsx +8 -2
- package/src/ScreenReaderActivity.js +18 -3
- package/src/{ScreenReaderText.js → ScreenReaderText.tsx} +27 -9
- package/src/SendBox/{IconButton.js → IconButton.tsx} +19 -3
- package/src/SendBox/{SuggestedAction.js → SuggestedAction.tsx} +72 -35
- package/src/SendBox/SuggestedActions.tsx +48 -21
- package/src/Styles/StyleSet/BasicTranscript.ts +34 -20
- package/src/Styles/StyleSet/Bubble.ts +0 -1
- package/src/Styles/StyleSet/CarouselFilmStrip.ts +12 -10
- package/src/Styles/StyleSet/CarouselFilmStripAttachment.ts +4 -3
- package/src/Styles/StyleSet/KeyboardHelp.ts +157 -0
- package/src/Styles/StyleSet/ScrollToEndButton.ts +1 -1
- 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 +129 -42
- package/src/Styles/StyleSet/SuggestedActions.ts +13 -5
- package/src/Styles/createStyleSet.ts +2 -1
- package/src/Styles/mirrorStyle.js +10 -2
- package/src/Toast/NotificationIcon.js +4 -1
- package/src/Toast/createToastMiddleware.tsx +4 -1
- package/src/Transcript/ActivityRow.tsx +123 -0
- package/src/Transcript/ActivityTextAlt.tsx +31 -0
- package/src/Transcript/FocusTrap.tsx +64 -0
- package/src/Transcript/KeyboardHelp.tsx +282 -0
- package/src/Transcript/LiveRegionTranscript.tsx +196 -0
- package/src/Transcript/types.ts +1 -0
- package/src/Transcript/useActivityAccessibleName.ts +84 -0
- package/src/Transcript/useTypistNames.ts +37 -0
- package/src/Utils/{AccessibleButton.js → AccessibleButton.tsx} +19 -4
- package/src/Utils/{FocusRedirector.js → FocusRedirector.tsx} +21 -8
- package/src/Utils/InlineMarkdown.js +18 -2
- package/src/Utils/TypeFocusSink/inputtableKey.ts +5 -1
- 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.ts +14 -0
- package/src/Utils/isZeroOrPositive.ts +7 -0
- package/src/Utils/mapMap.js +7 -1
- package/src/Utils/scrollIntoViewWithBlockNearest.ts +20 -0
- package/src/Utils/shallowEquals.js +8 -1
- package/src/Utils/supportPseudoClass.ts +17 -0
- package/src/Utils/{tabbableElements.js → tabbableElements.ts} +6 -5
- package/src/connectToWebChat.js +11 -4
- package/src/hooks/internal/BypassSpeechSynthesisPonyfill.js +3 -1
- 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 +1 -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/useStateRef.ts +31 -0
- package/src/hooks/internal/useValueRef.ts +22 -0
- package/src/hooks/useFocus.ts +1 -1
- package/src/hooks/useObserveTranscriptFocus.ts +2 -2
- package/src/hooks/useRenderMarkdownAsHTML.ts +4 -5
- package/src/hooks/useScrollTo.ts +4 -3
- package/src/hooks/useScrollToEnd.ts +4 -3
- package/src/hooks/useSendFiles.ts +7 -5
- package/src/index.ts +0 -1
- 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 +64 -0
- package/src/providers/ActivityTree/private/useActivityTreeWithRenderer.ts +135 -0
- package/src/providers/ActivityTree/private/useContext.ts +15 -0
- package/src/providers/ActivityTree/useActivityTreeWithRenderer.ts +16 -0
- package/src/providers/LiveRegionTwin/LiveRegionTwinComposer.tsx +161 -0
- package/src/providers/LiveRegionTwin/private/Context.ts +15 -0
- package/src/providers/LiveRegionTwin/private/LiveRegionTwinContainer.tsx +80 -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/.eslintignore +0 -1
- package/lib/Middleware/GroupActivities/createCoreMiddleware.js +0 -69
- package/lib/Utils/findLastIndex.js +0 -32
- package/lib/hooks/internal/useAcknowledgedActivity.js +0 -90
- package/lib/hooks/internal/useDispatchTranscriptFocus.js +0 -19
- package/src/BasicTranscript.js +0 -1139
- package/src/Middleware/GroupActivities/createCoreMiddleware.js +0 -57
- package/src/Utils/findLastIndex.js +0 -11
- package/src/Utils/findLastIndex.spec.js +0 -31
- package/src/Utils/getActivityUniqueId.js +0 -3
- package/src/Utils/intersectionOf.js +0 -11
- package/src/Utils/isZeroOrPositive.js +0 -4
- 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
|
@@ -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
|
-
|
|
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
|
|
143
|
+
[scrollPositionObserversRef]
|
|
145
144
|
);
|
|
146
145
|
|
|
147
146
|
const transcriptFocusObserversRef = useRef([]);
|
|
148
147
|
const [numTranscriptFocusObservers, setNumTranscriptFocusObservers] = useState(0);
|
|
149
148
|
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
<
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
-
() =>
|
|
11
|
-
|
|
9
|
+
() =>
|
|
10
|
+
next =>
|
|
11
|
+
(...args) => {
|
|
12
|
+
const [{ activity }] = args;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
// TODO: [P4] Can we simplify these if-statement to something more readable?
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
const { type } = activity;
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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 <
|
|
66
|
+
return <StackedLayout activity={activity} renderAttachment={renderAttachment} {...props} />;
|
|
55
67
|
};
|
|
56
68
|
}
|
|
57
69
|
|
|
58
|
-
|
|
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
|
|
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:
|
|
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:
|
|
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
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
25
|
+
const isText = /^text\//u.test(contentType);
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
() =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
23
|
+
const isText = /^text\//u.test(contentType);
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
() =>
|
|
63
|
-
|
|
62
|
+
() =>
|
|
63
|
+
() =>
|
|
64
|
+
({ fromUser, styleOptions }) => {
|
|
65
|
+
const { botAvatarImage, botAvatarInitials, userAvatarImage, userAvatarInitials } = styleOptions;
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
67
|
+
if (fromUser ? userAvatarImage || userAvatarInitials : botAvatarImage || botAvatarInitials) {
|
|
68
|
+
return () => <DefaultAvatar fromUser={fromUser} />;
|
|
69
|
+
}
|
|
69
70
|
|
|
70
|
-
|
|
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
|
-
|
|
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
|
-
() =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
() =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
() =>
|
|
8
|
+
next =>
|
|
9
|
+
(...args) => {
|
|
10
|
+
const [
|
|
11
|
+
{
|
|
12
|
+
notification: { id }
|
|
13
|
+
}
|
|
14
|
+
] = args;
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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
|
}
|