botframework-webchat 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 +5 -104
- package/.prettierrc.yml +1 -1
- package/README.md +33 -36
- package/babel.config.json +2 -2
- package/babel.sanitize-html.config.json +10 -0
- package/lib/AddFullBundle.d.ts +30 -0
- package/lib/AddFullBundle.d.ts.map +1 -0
- package/lib/AddFullBundle.js +76 -0
- package/lib/FullComposer.d.ts +8 -0
- package/lib/FullComposer.d.ts.map +1 -0
- package/lib/FullComposer.js +6 -16
- package/lib/FullReactWebChat.d.ts +8 -0
- package/lib/FullReactWebChat.d.ts.map +1 -0
- package/lib/FullReactWebChat.js +8 -23
- package/lib/adaptiveCards/AdaptiveCardsComposer.d.ts +10 -0
- package/lib/adaptiveCards/AdaptiveCardsComposer.d.ts.map +1 -0
- package/lib/adaptiveCards/AdaptiveCardsComposer.js +6 -2
- package/lib/adaptiveCards/AdaptiveCardsContext.d.ts +8 -0
- package/lib/adaptiveCards/AdaptiveCardsContext.d.ts.map +1 -0
- package/lib/adaptiveCards/AdaptiveCardsContext.js +3 -3
- package/lib/adaptiveCards/AdaptiveCardsStyleOptions.d.ts +5 -3
- package/lib/adaptiveCards/AdaptiveCardsStyleOptions.d.ts.map +1 -1
- package/lib/adaptiveCards/AdaptiveCardsStyleSet.d.ts +7 -0
- package/lib/adaptiveCards/AdaptiveCardsStyleSet.d.ts.map +1 -0
- package/lib/{FullBundleStyleOptions.js → adaptiveCards/AdaptiveCardsStyleSet.js} +0 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardAttachment.d.ts +9 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardAttachment.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardAttachment.js +1 -1
- package/lib/adaptiveCards/Attachment/AdaptiveCardBuilder.d.ts +28 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardBuilder.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardBuilder.js +13 -6
- package/lib/adaptiveCards/Attachment/AdaptiveCardContent.d.ts +9 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardContent.js +8 -4
- package/lib/adaptiveCards/Attachment/AdaptiveCardRenderer.d.ts +12 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardRenderer.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardRenderer.js +310 -85
- package/lib/adaptiveCards/Attachment/AnimationCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/AnimationCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AnimationCardContent.js +1 -1
- package/lib/adaptiveCards/Attachment/AudioCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/AudioCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AudioCardContent.js +1 -1
- package/lib/adaptiveCards/Attachment/CommonCard.js +11 -6
- package/lib/adaptiveCards/Attachment/HeroCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/HeroCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/HeroCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/OAuthCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/OAuthCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/OAuthCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/ReceiptCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/ReceiptCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/ReceiptCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/SignInCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/SignInCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/SignInCardContent.js +1 -1
- package/lib/adaptiveCards/Attachment/ThumbnailCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/ThumbnailCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/ThumbnailCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/VideoCardContent.d.ts +20 -0
- package/lib/adaptiveCards/Attachment/VideoCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/VideoCardContent.js +7 -5
- package/lib/adaptiveCards/AttachmentForScreenReader/AdaptiveCardAttachment.js +7 -3
- package/lib/adaptiveCards/AttachmentForScreenReader/RichCardAttachment.js +1 -1
- package/lib/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.d.ts +59 -0
- package/lib/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.d.ts.map +1 -0
- package/lib/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.js +8 -1
- package/lib/adaptiveCards/Styles/adaptiveCardHostConfig.d.ts +126 -0
- package/lib/adaptiveCards/Styles/adaptiveCardHostConfig.d.ts.map +1 -0
- package/lib/adaptiveCards/Styles/adaptiveCardHostConfig.js +29 -9
- package/lib/adaptiveCards/Styles/createAdaptiveCardsStyleSet.d.ts +5 -0
- package/lib/adaptiveCards/Styles/createAdaptiveCardsStyleSet.d.ts.map +1 -0
- package/lib/adaptiveCards/Styles/createAdaptiveCardsStyleSet.js +2 -2
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentForScreenReaderMiddleware.d.ts +3 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentForScreenReaderMiddleware.d.ts.map +1 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentForScreenReaderMiddleware.js +5 -11
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.d.ts +3 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.d.ts.map +1 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.js +2 -15
- package/lib/adaptiveCards/defaultStyleOptions.d.ts +4 -0
- package/lib/adaptiveCards/defaultStyleOptions.d.ts.map +1 -0
- package/lib/adaptiveCards/defaultStyleOptions.js +3 -2
- package/lib/adaptiveCards/hooks/internal/useAdaptiveCardsContext.d.ts +3 -0
- package/lib/adaptiveCards/hooks/internal/useAdaptiveCardsContext.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/internal/useAdaptiveCardsContext.js +1 -1
- package/lib/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.d.ts +2 -0
- package/lib/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.js +7 -5
- package/lib/adaptiveCards/hooks/internal/useUniqueId.js +1 -1
- package/lib/adaptiveCards/hooks/useAdaptiveCardsHostConfig.d.ts +2 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsHostConfig.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsHostConfig.js +3 -5
- package/lib/adaptiveCards/hooks/useAdaptiveCardsPackage.d.ts +3 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsPackage.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsPackage.js +1 -1
- package/lib/adaptiveCards/normalizeStyleOptions.d.ts +3 -0
- package/lib/adaptiveCards/normalizeStyleOptions.d.ts.map +1 -0
- package/lib/adaptiveCards/normalizeStyleOptions.js +1 -1
- package/lib/addVersion.js +2 -2
- package/lib/createBrowserWebSpeechPonyfillFactory.d.ts +3 -0
- package/lib/createBrowserWebSpeechPonyfillFactory.d.ts.map +1 -0
- package/lib/createBrowserWebSpeechPonyfillFactory.js +7 -4
- package/lib/createCognitiveServicesSpeechServicesPonyfillFactory.d.ts +17 -0
- package/lib/createCognitiveServicesSpeechServicesPonyfillFactory.d.ts.map +1 -0
- package/lib/createCognitiveServicesSpeechServicesPonyfillFactory.js +17 -11
- package/lib/createDirectLine.d.ts +17 -0
- package/lib/createDirectLine.d.ts.map +1 -0
- package/lib/createDirectLine.js +3 -2
- package/lib/createDirectLineAppServiceExtension.d.ts +7 -0
- package/lib/createDirectLineAppServiceExtension.d.ts.map +1 -0
- package/lib/createDirectLineAppServiceExtension.js +1 -1
- package/lib/createDirectLineSpeechAdapters.d.ts +25 -0
- package/lib/createDirectLineSpeechAdapters.d.ts.map +1 -0
- package/lib/createDirectLineSpeechAdapters.js +57 -3
- package/lib/createFullStyleSet.d.ts +1375 -0
- package/lib/createFullStyleSet.d.ts.map +1 -0
- package/lib/createFullStyleSet.js +2 -2
- package/lib/fullBundleDefaultStyleOptions.js +4 -4
- package/lib/hooks/useStyleOptions.d.ts +3 -0
- package/lib/hooks/useStyleOptions.d.ts.map +1 -0
- package/lib/hooks/useStyleOptions.js +21 -0
- package/lib/index-es5.d.ts +4 -20
- package/lib/index-es5.d.ts.map +1 -1
- package/lib/index-es5.js +3 -43
- package/lib/index-minimal.d.ts +9 -6
- package/lib/index-minimal.d.ts.map +1 -1
- package/lib/index-minimal.js +27 -21
- package/lib/index.d.ts +164 -18
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -12
- package/lib/polyfill.d.ts +23 -0
- package/lib/polyfill.d.ts.map +1 -0
- package/lib/polyfill.js +46 -0
- package/lib/renderMarkdown.d.ts +6 -0
- package/lib/renderMarkdown.d.ts.map +1 -0
- package/lib/renderMarkdown.js +36 -5
- package/lib/renderWebChat.d.ts +3 -0
- package/lib/renderWebChat.d.ts.map +1 -0
- package/lib/renderWebChat.js +1 -1
- package/lib/speech/CustomAudioInputStream.d.ts +94 -0
- package/lib/speech/CustomAudioInputStream.d.ts.map +1 -0
- package/lib/speech/CustomAudioInputStream.js +441 -0
- package/lib/speech/bytesPerSample.d.ts +2 -0
- package/lib/speech/bytesPerSample.d.ts.map +1 -0
- package/lib/speech/bytesPerSample.js +12 -0
- package/lib/speech/createAudioConfig.d.ts +23 -0
- package/lib/speech/createAudioConfig.d.ts.map +1 -0
- package/lib/speech/createAudioConfig.js +90 -0
- package/lib/speech/createAudioContext.d.ts +3 -0
- package/lib/speech/createAudioContext.d.ts.map +1 -0
- package/lib/speech/createAudioContext.js +22 -0
- package/lib/speech/createMicrophoneAudioConfigAndAudioContext.d.ts +9 -0
- package/lib/speech/createMicrophoneAudioConfigAndAudioContext.d.ts.map +1 -0
- package/lib/speech/createMicrophoneAudioConfigAndAudioContext.js +161 -0
- package/lib/speech/getUserMedia.d.ts +2 -0
- package/lib/speech/getUserMedia.d.ts.map +1 -0
- package/lib/speech/getUserMedia.js +25 -0
- package/lib/types/AdaptiveCardsPackage.d.ts +13 -0
- package/lib/types/AdaptiveCardsPackage.d.ts.map +1 -0
- package/lib/types/AdaptiveCardsPackage.js +2 -0
- package/lib/types/CognitiveServicesAudioOutputFormat.d.ts +3 -0
- package/lib/types/CognitiveServicesAudioOutputFormat.d.ts.map +1 -0
- package/lib/types/CognitiveServicesAudioOutputFormat.js +2 -0
- package/lib/types/CognitiveServicesCredentials.d.ts +18 -0
- package/lib/types/CognitiveServicesCredentials.d.ts.map +1 -0
- package/lib/types/CognitiveServicesCredentials.js +2 -0
- package/lib/types/CognitiveServicesTextNormalization.d.ts +3 -0
- package/lib/types/CognitiveServicesTextNormalization.d.ts.map +1 -0
- package/lib/types/CognitiveServicesTextNormalization.js +2 -0
- package/lib/{FullBundleStyleOptions.d.ts → types/FullBundleStyleOptions.d.ts} +1 -1
- package/lib/types/FullBundleStyleOptions.d.ts.map +1 -0
- package/lib/types/FullBundleStyleOptions.js +2 -0
- package/lib/useComposerProps.d.ts +22 -0
- package/lib/useComposerProps.d.ts.map +1 -0
- package/lib/useComposerProps.js +6 -8
- package/package.json +46 -48
- package/src/AddFullBundle.tsx +93 -0
- package/src/FullComposer.tsx +38 -0
- package/src/FullReactWebChat.tsx +32 -0
- package/src/__tests__/createDirectLine.spec.js +2 -0
- package/src/__tests__/renderMarkdown.spec.js +1 -1
- package/src/__tests__/versionTag.es5.spec.js +3 -0
- package/src/__tests__/versionTag.full.spec.js +3 -0
- package/src/__tests__/versionTag.minimal.spec.js +3 -0
- package/src/adaptiveCards/{AdaptiveCardsComposer.js → AdaptiveCardsComposer.tsx} +17 -5
- package/src/adaptiveCards/AdaptiveCardsContext.ts +12 -0
- package/src/adaptiveCards/AdaptiveCardsStyleOptions.ts +5 -3
- package/src/adaptiveCards/AdaptiveCardsStyleSet.ts +7 -0
- package/src/adaptiveCards/Attachment/{AdaptiveCardAttachment.js → AdaptiveCardAttachment.tsx} +8 -2
- package/src/adaptiveCards/Attachment/AdaptiveCardBuilder.ts +27 -17
- package/src/adaptiveCards/Attachment/{AdaptiveCardContent.js → AdaptiveCardContent.tsx} +8 -2
- package/src/adaptiveCards/Attachment/AdaptiveCardRenderer.tsx +768 -0
- package/src/adaptiveCards/Attachment/{AnimationCardContent.js → AnimationCardContent.tsx} +9 -2
- package/src/adaptiveCards/Attachment/{AudioCardContent.js → AudioCardContent.tsx} +9 -2
- package/src/adaptiveCards/Attachment/CommonCard.js +2 -1
- package/src/adaptiveCards/Attachment/{HeroCardContent.js → HeroCardContent.tsx} +12 -3
- package/src/adaptiveCards/Attachment/{OAuthCardContent.js → OAuthCardContent.tsx} +11 -3
- package/src/adaptiveCards/Attachment/{ReceiptCardContent.js → ReceiptCardContent.tsx} +58 -28
- package/src/adaptiveCards/Attachment/{SignInCardContent.js → SignInCardContent.tsx} +9 -2
- package/src/adaptiveCards/Attachment/{ThumbnailCardContent.js → ThumbnailCardContent.tsx} +12 -3
- package/src/adaptiveCards/Attachment/{VideoCardContent.js → VideoCardContent.tsx} +15 -3
- package/src/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.ts +9 -1
- package/src/adaptiveCards/Styles/adaptiveCardHostConfig.ts +28 -8
- package/src/adaptiveCards/Styles/createAdaptiveCardsStyleSet.spec.js +2 -0
- package/src/adaptiveCards/Styles/createAdaptiveCardsStyleSet.ts +7 -4
- package/src/adaptiveCards/{createAdaptiveCardsAttachmentForScreenReaderMiddleware.js → createAdaptiveCardsAttachmentForScreenReaderMiddleware.tsx} +16 -15
- package/src/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.tsx +44 -0
- package/src/adaptiveCards/defaultStyleOptions.ts +2 -1
- package/src/adaptiveCards/hooks/internal/{useAdaptiveCardsContext.js → useAdaptiveCardsContext.ts} +1 -1
- package/src/adaptiveCards/hooks/internal/{useParseAdaptiveCardJSON.js → useParseAdaptiveCardJSON.ts} +5 -2
- package/src/adaptiveCards/hooks/internal/{useUniqueId.js → useUniqueId.ts} +1 -1
- package/src/adaptiveCards/hooks/{useAdaptiveCardsHostConfig.js → useAdaptiveCardsHostConfig.ts} +6 -8
- package/src/adaptiveCards/hooks/{useAdaptiveCardsPackage.js → useAdaptiveCardsPackage.ts} +2 -1
- package/src/createBrowserWebSpeechPonyfillFactory.ts +21 -0
- package/src/createCognitiveServicesSpeechServicesPonyfillFactory.spec.js +36 -6
- package/src/createCognitiveServicesSpeechServicesPonyfillFactory.ts +78 -0
- package/src/createDirectLine.ts +65 -0
- package/src/createDirectLineAppServiceExtension.ts +22 -0
- package/src/createDirectLineSpeechAdapters.ts +84 -0
- package/src/createFullStyleSet.ts +2 -2
- package/src/fullBundleDefaultStyleOptions.ts +3 -3
- package/src/hooks/useStyleOptions.ts +9 -0
- package/src/index-es5.ts +3 -28
- package/src/index-minimal.ts +3 -2
- package/src/index.ts +22 -10
- package/src/polyfill.ts +29 -0
- package/src/renderMarkdown.ts +140 -0
- package/src/renderWebChat.tsx +6 -0
- package/src/speech/CustomAudioInputStream.ts +356 -0
- package/src/speech/bytesPerSample.ts +4 -0
- package/src/speech/createAudioConfig.spec.js +23 -0
- package/src/speech/createAudioConfig.ts +77 -0
- package/src/speech/createAudioContext.ts +16 -0
- package/src/speech/createMicrophoneAudioConfigAndAudioContext.ts +146 -0
- package/src/speech/getUserMedia.ts +14 -0
- package/src/tsconfig.json +1 -1
- package/src/types/AdaptiveCardsPackage.ts +23 -0
- package/src/types/CognitiveServicesAudioOutputFormat.ts +28 -0
- package/src/types/CognitiveServicesCredentials.ts +28 -0
- package/src/types/CognitiveServicesTextNormalization.ts +3 -0
- package/src/{FullBundleStyleOptions.ts → types/FullBundleStyleOptions.ts} +1 -1
- package/src/{useComposerProps.js → useComposerProps.ts} +21 -11
- package/webpack.config.js +46 -6
- package/.eslintignore +0 -9
- package/lib/FullBundleStyleOptions.d.ts.map +0 -1
- package/src/FullComposer.js +0 -40
- package/src/FullReactWebChat.js +0 -47
- package/src/adaptiveCards/AdaptiveCardsContext.js +0 -5
- package/src/adaptiveCards/Attachment/AdaptiveCardRenderer.js +0 -492
- package/src/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.js +0 -41
- package/src/createBrowserWebSpeechPonyfillFactory.js +0 -16
- package/src/createCognitiveServicesSpeechServicesPonyfillFactory.js +0 -58
- package/src/createDirectLine.js +0 -38
- package/src/createDirectLineAppServiceExtension.js +0 -12
- package/src/createDirectLineSpeechAdapters.js +0 -5
- package/src/index-es5.tsx +0 -49
- package/src/index-minimal.tsx +0 -9
- package/src/index.tsx +0 -45
- package/src/renderMarkdown.js +0 -97
- package/src/renderWebChat.js +0 -6
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { AttachmentForScreenReaderMiddleware, AttachmentMiddleware, StyleOptions } from 'botframework-webchat-api';
|
|
2
|
+
import { OneOrMany, singleToArray, warnOnce } from 'botframework-webchat-core';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React, { FC, ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
import { StrictFullBundleStyleOptions } from './types/FullBundleStyleOptions';
|
|
7
|
+
import AdaptiveCardsComposer from './adaptiveCards/AdaptiveCardsComposer';
|
|
8
|
+
import AdaptiveCardsPackage from './types/AdaptiveCardsPackage';
|
|
9
|
+
import AdaptiveCardsStyleOptions from './adaptiveCards/AdaptiveCardsStyleOptions';
|
|
10
|
+
import useComposerProps from './useComposerProps';
|
|
11
|
+
|
|
12
|
+
type AddFullBundleProps = {
|
|
13
|
+
adaptiveCardsHostConfig?: any;
|
|
14
|
+
adaptiveCardsPackage?: AdaptiveCardsPackage;
|
|
15
|
+
attachmentForScreenReaderMiddleware?: OneOrMany<AttachmentForScreenReaderMiddleware>;
|
|
16
|
+
attachmentMiddleware?: OneOrMany<AttachmentMiddleware>;
|
|
17
|
+
children: ({ extraStyleSet }: { extraStyleSet: any }) => ReactNode;
|
|
18
|
+
renderMarkdown?: (markdown: string, { markdownRespectCRLF: boolean }, { externalLinkAlt: string }) => string;
|
|
19
|
+
styleOptions?: StyleOptions & AdaptiveCardsStyleOptions;
|
|
20
|
+
styleSet?: any & { options: StrictFullBundleStyleOptions };
|
|
21
|
+
|
|
22
|
+
/** @deprecated Rename to "adaptiveCardsHostConfig" */
|
|
23
|
+
adaptiveCardHostConfig?: any;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const adaptiveCardHostConfigDeprecation = warnOnce(
|
|
27
|
+
'"adaptiveCardHostConfig" is deprecated. Please use "adaptiveCardsHostConfig" instead. "adaptiveCardHostConfig" will be removed on or after 2022-01-01.'
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const AddFullBundle: FC<AddFullBundleProps> = ({
|
|
31
|
+
adaptiveCardHostConfig,
|
|
32
|
+
adaptiveCardsHostConfig,
|
|
33
|
+
adaptiveCardsPackage,
|
|
34
|
+
attachmentForScreenReaderMiddleware,
|
|
35
|
+
attachmentMiddleware,
|
|
36
|
+
children,
|
|
37
|
+
renderMarkdown,
|
|
38
|
+
styleOptions,
|
|
39
|
+
styleSet
|
|
40
|
+
}) => {
|
|
41
|
+
adaptiveCardHostConfig && adaptiveCardHostConfigDeprecation();
|
|
42
|
+
|
|
43
|
+
const patchedProps = useComposerProps({
|
|
44
|
+
attachmentForScreenReaderMiddleware: singleToArray(attachmentForScreenReaderMiddleware),
|
|
45
|
+
attachmentMiddleware: singleToArray(attachmentMiddleware),
|
|
46
|
+
renderMarkdown,
|
|
47
|
+
styleOptions,
|
|
48
|
+
styleSet
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<AdaptiveCardsComposer
|
|
53
|
+
adaptiveCardsHostConfig={adaptiveCardHostConfig || adaptiveCardsHostConfig}
|
|
54
|
+
adaptiveCardsPackage={adaptiveCardsPackage}
|
|
55
|
+
>
|
|
56
|
+
{children(patchedProps)}
|
|
57
|
+
</AdaptiveCardsComposer>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
AddFullBundle.defaultProps = {
|
|
62
|
+
adaptiveCardHostConfig: undefined,
|
|
63
|
+
adaptiveCardsHostConfig: undefined,
|
|
64
|
+
adaptiveCardsPackage: undefined,
|
|
65
|
+
attachmentForScreenReaderMiddleware: undefined,
|
|
66
|
+
attachmentMiddleware: undefined,
|
|
67
|
+
renderMarkdown: undefined,
|
|
68
|
+
styleOptions: undefined,
|
|
69
|
+
styleSet: undefined
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
AddFullBundle.propTypes = {
|
|
73
|
+
adaptiveCardHostConfig: PropTypes.any,
|
|
74
|
+
adaptiveCardsHostConfig: PropTypes.any,
|
|
75
|
+
// TypeScript class is not mappable to PropTypes.func
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
adaptiveCardsPackage: PropTypes.shape({
|
|
78
|
+
AdaptiveCard: PropTypes.func.isRequired,
|
|
79
|
+
HorizontalAlignment: PropTypes.any.isRequired,
|
|
80
|
+
TextSize: PropTypes.any.isRequired,
|
|
81
|
+
TextWeight: PropTypes.any.isRequired
|
|
82
|
+
}),
|
|
83
|
+
attachmentForScreenReaderMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
|
|
84
|
+
attachmentMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
|
|
85
|
+
children: PropTypes.func.isRequired,
|
|
86
|
+
renderMarkdown: PropTypes.func,
|
|
87
|
+
styleOptions: PropTypes.any,
|
|
88
|
+
styleSet: PropTypes.any
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default AddFullBundle;
|
|
92
|
+
|
|
93
|
+
export type { AddFullBundleProps };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ComposerProps } from 'botframework-webchat-api';
|
|
2
|
+
import { Components } from 'botframework-webchat-component';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React, { FC } from 'react';
|
|
5
|
+
|
|
6
|
+
import AddFullBundle, { AddFullBundleProps } from './AddFullBundle';
|
|
7
|
+
|
|
8
|
+
const { Composer } = Components;
|
|
9
|
+
|
|
10
|
+
type FullComposerProps = ComposerProps & AddFullBundleProps;
|
|
11
|
+
|
|
12
|
+
const FullComposer: FC<FullComposerProps> = props => (
|
|
13
|
+
<AddFullBundle {...props}>
|
|
14
|
+
{extraProps => (
|
|
15
|
+
<Composer {...props} {...extraProps}>
|
|
16
|
+
{props.children}
|
|
17
|
+
</Composer>
|
|
18
|
+
)}
|
|
19
|
+
</AddFullBundle>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
FullComposer.defaultProps = {
|
|
23
|
+
...Composer.defaultProps,
|
|
24
|
+
adaptiveCardsHostConfig: undefined,
|
|
25
|
+
adaptiveCardsPackage: undefined,
|
|
26
|
+
children: undefined
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
FullComposer.propTypes = {
|
|
30
|
+
...Composer.propTypes,
|
|
31
|
+
adaptiveCardsHostConfig: PropTypes.any,
|
|
32
|
+
adaptiveCardsPackage: PropTypes.any,
|
|
33
|
+
children: PropTypes.any
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default FullComposer;
|
|
37
|
+
|
|
38
|
+
export type { FullComposerProps };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { VFC } from 'react';
|
|
3
|
+
import ReactWebChat, { ReactWebChatProps } from 'botframework-webchat-component';
|
|
4
|
+
|
|
5
|
+
import AddFullBundle, { AddFullBundleProps } from './AddFullBundle';
|
|
6
|
+
|
|
7
|
+
type FullReactWebChatProps = ReactWebChatProps & Omit<AddFullBundleProps, 'children'>;
|
|
8
|
+
|
|
9
|
+
// Add additional props to <WebChat>, so it support additional features
|
|
10
|
+
const FullReactWebChat: VFC<FullReactWebChatProps> = props => (
|
|
11
|
+
<AddFullBundle {...props}>{extraProps => <ReactWebChat {...props} {...extraProps} />}</AddFullBundle>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
FullReactWebChat.defaultProps = {
|
|
15
|
+
...ReactWebChat.defaultProps,
|
|
16
|
+
adaptiveCardHostConfig: undefined,
|
|
17
|
+
adaptiveCardsHostConfig: undefined,
|
|
18
|
+
adaptiveCardsPackage: undefined,
|
|
19
|
+
renderMarkdown: undefined
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
FullReactWebChat.propTypes = {
|
|
23
|
+
...ReactWebChat.propTypes,
|
|
24
|
+
adaptiveCardHostConfig: PropTypes.any,
|
|
25
|
+
adaptiveCardsHostConfig: PropTypes.any,
|
|
26
|
+
adaptiveCardsPackage: PropTypes.any,
|
|
27
|
+
renderMarkdown: PropTypes.func
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default FullReactWebChat;
|
|
31
|
+
|
|
32
|
+
export type { FullReactWebChatProps };
|
|
@@ -17,7 +17,7 @@ describe('renderMarkdown', () => {
|
|
|
17
17
|
);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
it('should respect
|
|
20
|
+
it('should respect CRLF', () => {
|
|
21
21
|
const styleOptions = { markdownRespectCRLF: true };
|
|
22
22
|
|
|
23
23
|
expect(renderMarkdown('Same Line.\n\rSame Line.\r\n2nd line.', styleOptions)).toBe(
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import * as defaultAdaptiveCardsPackage from 'adaptivecards';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
3
|
+
import React, { FC, ReactNode, useMemo } from 'react';
|
|
4
4
|
|
|
5
5
|
import AdaptiveCardsContext from './AdaptiveCardsContext';
|
|
6
|
+
import AdaptiveCardsPackage from '../types/AdaptiveCardsPackage';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
type AdaptiveCardsComposerProps = {
|
|
9
|
+
adaptiveCardsHostConfig: any;
|
|
10
|
+
adaptiveCardsPackage: AdaptiveCardsPackage;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const AdaptiveCardsComposer: FC<AdaptiveCardsComposerProps> = ({
|
|
15
|
+
adaptiveCardsHostConfig,
|
|
16
|
+
adaptiveCardsPackage,
|
|
17
|
+
children
|
|
18
|
+
}) => {
|
|
19
|
+
const patchedAdaptiveCardsPackage = useMemo(
|
|
20
|
+
() => adaptiveCardsPackage || defaultAdaptiveCardsPackage,
|
|
21
|
+
[adaptiveCardsPackage]
|
|
22
|
+
);
|
|
11
23
|
|
|
12
24
|
const adaptiveCardsContext = useMemo(
|
|
13
25
|
() => ({
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import AdaptiveCardsPackage from '../types/AdaptiveCardsPackage';
|
|
4
|
+
|
|
5
|
+
type AdaptiveCardsContext = {
|
|
6
|
+
adaptiveCardsPackage: AdaptiveCardsPackage;
|
|
7
|
+
hostConfigFromProps: any;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const AdaptiveCardsContext = createContext<AdaptiveCardsContext>(undefined);
|
|
11
|
+
|
|
12
|
+
export default AdaptiveCardsContext;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive Cards styling
|
|
3
|
+
*/
|
|
1
4
|
type AdaptiveCardsStyleOptions = {
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
+
/** Adaptive Cards: Specify the maximum schema version supported by the Adaptive Card serializer. */
|
|
6
|
+
adaptiveCardsParserMaxVersion?: string;
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Adaptive Cards styling for 'emphasis' container style
|
package/src/adaptiveCards/Attachment/{AdaptiveCardAttachment.js → AdaptiveCardAttachment.tsx}
RENAMED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { DirectLineAttachment } from 'botframework-webchat-core';
|
|
1
2
|
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
+
import React, { FC } from 'react';
|
|
3
4
|
|
|
4
5
|
import AdaptiveCardContent from './AdaptiveCardContent';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
type AdaptiveCardAttachmentProps = {
|
|
8
|
+
attachment: DirectLineAttachment;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const AdaptiveCardAttachment: FC<AdaptiveCardAttachmentProps> = ({ attachment: { content }, disabled }) => (
|
|
7
13
|
<AdaptiveCardContent content={content} disabled={disabled} />
|
|
8
14
|
);
|
|
9
15
|
|
|
@@ -16,14 +16,16 @@ import {
|
|
|
16
16
|
TextWeight
|
|
17
17
|
} from 'adaptivecards';
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { DirectLineCardAction, isForbiddenPropertyName } from 'botframework-webchat-core';
|
|
20
|
+
import AdaptiveCardsPackage from '../../types/AdaptiveCardsPackage';
|
|
21
|
+
import AdaptiveCardsStyleOptions from '../AdaptiveCardsStyleOptions';
|
|
20
22
|
|
|
21
23
|
export interface BotFrameworkCardAction {
|
|
22
|
-
__isBotFrameworkCardAction:
|
|
23
|
-
cardAction:
|
|
24
|
+
__isBotFrameworkCardAction: true;
|
|
25
|
+
cardAction: DirectLineCardAction;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
function addCardAction(cardAction:
|
|
28
|
+
function addCardAction(cardAction: DirectLineCardAction, includesOAuthButtons?: boolean) {
|
|
27
29
|
const { type } = cardAction;
|
|
28
30
|
let action;
|
|
29
31
|
|
|
@@ -40,11 +42,11 @@ function addCardAction(cardAction: CardAction, includesOAuthButtons?: boolean) {
|
|
|
40
42
|
cardAction
|
|
41
43
|
};
|
|
42
44
|
|
|
43
|
-
action.title = cardAction.title;
|
|
45
|
+
action.title = (cardAction as { title: string }).title;
|
|
44
46
|
} else {
|
|
45
47
|
action = new OpenUrlAction();
|
|
46
48
|
|
|
47
|
-
action.title = cardAction.title;
|
|
49
|
+
action.title = (cardAction as { title: string }).title;
|
|
48
50
|
action.url = cardAction.type === 'call' ? `tel:${cardAction.value}` : cardAction.value;
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -54,9 +56,13 @@ function addCardAction(cardAction: CardAction, includesOAuthButtons?: boolean) {
|
|
|
54
56
|
export default class AdaptiveCardBuilder {
|
|
55
57
|
card: AdaptiveCard;
|
|
56
58
|
container: Container;
|
|
57
|
-
styleOptions:
|
|
59
|
+
styleOptions: AdaptiveCardsStyleOptions;
|
|
58
60
|
|
|
59
|
-
constructor(
|
|
61
|
+
constructor(
|
|
62
|
+
adaptiveCards: AdaptiveCardsPackage,
|
|
63
|
+
styleOptions: AdaptiveCardsStyleOptions,
|
|
64
|
+
direction: 'ltr' | 'rtl' | 'auto' = 'ltr'
|
|
65
|
+
) {
|
|
60
66
|
this.card = new adaptiveCards.AdaptiveCard();
|
|
61
67
|
this.container = new Container();
|
|
62
68
|
this.container.rtl = direction === 'rtl';
|
|
@@ -65,7 +71,7 @@ export default class AdaptiveCardBuilder {
|
|
|
65
71
|
this.card.addItem(this.container);
|
|
66
72
|
}
|
|
67
73
|
|
|
68
|
-
addColumnSet(sizes: number[], container: Container = this.container, selectAction?:
|
|
74
|
+
addColumnSet(sizes: number[], container: Container = this.container, selectAction?: DirectLineCardAction) {
|
|
69
75
|
const columnSet = new ColumnSet();
|
|
70
76
|
|
|
71
77
|
columnSet.selectAction = selectAction && addCardAction(selectAction);
|
|
@@ -90,9 +96,12 @@ export default class AdaptiveCardBuilder {
|
|
|
90
96
|
if (typeof text !== 'undefined') {
|
|
91
97
|
const textblock = new TextBlock();
|
|
92
98
|
|
|
93
|
-
// tslint:disable-next-line:forin
|
|
94
99
|
for (const prop in template) {
|
|
95
|
-
|
|
100
|
+
if (!isForbiddenPropertyName(prop)) {
|
|
101
|
+
// Mitigated through denylisting.
|
|
102
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
103
|
+
textblock[prop] = template[prop];
|
|
104
|
+
}
|
|
96
105
|
}
|
|
97
106
|
|
|
98
107
|
textblock.text = text;
|
|
@@ -101,7 +110,7 @@ export default class AdaptiveCardBuilder {
|
|
|
101
110
|
}
|
|
102
111
|
}
|
|
103
112
|
|
|
104
|
-
addButtons(cardActions:
|
|
113
|
+
addButtons(cardActions: DirectLineCardAction[], includesOAuthButtons?: boolean) {
|
|
105
114
|
cardActions &&
|
|
106
115
|
cardActions.forEach(cardAction => {
|
|
107
116
|
this.card.addAction(addCardAction(cardAction, includesOAuthButtons));
|
|
@@ -111,13 +120,14 @@ export default class AdaptiveCardBuilder {
|
|
|
111
120
|
addCommonHeaders(content: ICommonContent) {
|
|
112
121
|
const { richCardWrapTitle } = this.styleOptions;
|
|
113
122
|
this.addTextBlock(content.title, {
|
|
114
|
-
color: TextColor.
|
|
123
|
+
color: TextColor.Default,
|
|
115
124
|
size: TextSize.Medium,
|
|
125
|
+
style: 'heading',
|
|
116
126
|
weight: TextWeight.Bolder,
|
|
117
127
|
wrap: richCardWrapTitle
|
|
118
128
|
});
|
|
119
|
-
this.addTextBlock(content.subtitle, { color: TextColor.
|
|
120
|
-
this.addTextBlock(content.text, { color: TextColor.
|
|
129
|
+
this.addTextBlock(content.subtitle, { color: TextColor.Default, isSubtle: true, wrap: richCardWrapTitle });
|
|
130
|
+
this.addTextBlock(content.text, { color: TextColor.Default, wrap: true });
|
|
121
131
|
}
|
|
122
132
|
|
|
123
133
|
addCommon(content: ICommonContent) {
|
|
@@ -125,7 +135,7 @@ export default class AdaptiveCardBuilder {
|
|
|
125
135
|
this.addButtons(content.buttons);
|
|
126
136
|
}
|
|
127
137
|
|
|
128
|
-
addImage(url: string, container?: Container, selectAction?:
|
|
138
|
+
addImage(url: string, container?: Container, selectAction?: DirectLineCardAction, altText?: string) {
|
|
129
139
|
container = container || this.container;
|
|
130
140
|
|
|
131
141
|
const image = new Image();
|
|
@@ -140,7 +150,7 @@ export default class AdaptiveCardBuilder {
|
|
|
140
150
|
}
|
|
141
151
|
|
|
142
152
|
export interface ICommonContent {
|
|
143
|
-
buttons?:
|
|
153
|
+
buttons?: DirectLineCardAction[];
|
|
144
154
|
subtitle?: string;
|
|
145
155
|
text?: string;
|
|
146
156
|
title?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import React, { useMemo } from 'react';
|
|
2
|
+
import React, { FC, useMemo } from 'react';
|
|
3
3
|
|
|
4
4
|
import AdaptiveCardRenderer from './AdaptiveCardRenderer';
|
|
5
5
|
import useParseAdaptiveCardJSON from '../hooks/internal/useParseAdaptiveCardJSON';
|
|
@@ -17,7 +17,13 @@ function stripSubmitAction(card) {
|
|
|
17
17
|
return { ...card, nextActions };
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
type AdaptiveCardContentProps = {
|
|
21
|
+
actionPerformedClassName?: string;
|
|
22
|
+
content: any;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const AdaptiveCardContent: FC<AdaptiveCardContentProps> = ({ actionPerformedClassName, content, disabled }) => {
|
|
21
27
|
const parseAdaptiveCardJSON = useParseAdaptiveCardJSON();
|
|
22
28
|
|
|
23
29
|
const card = useMemo(
|