botframework-webchat-api 4.14.1 → 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 -105
- package/.prettierrc.yml +1 -1
- package/lib/StyleOptions.d.ts +242 -12
- package/lib/StyleOptions.d.ts.map +1 -1
- package/lib/defaultStyleOptions.d.ts.map +1 -1
- package/lib/defaultStyleOptions.js +67 -14
- package/lib/hooks/Composer.d.ts +1 -1
- package/lib/hooks/Composer.d.ts.map +1 -1
- package/lib/hooks/Composer.js +24 -8
- package/lib/hooks/index.d.ts +11 -1
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/index.js +81 -1
- package/lib/hooks/internal/useCreateActivityRendererInternal.d.ts.map +1 -1
- package/lib/hooks/internal/useCreateActivityRendererInternal.js +1 -1
- package/lib/hooks/internal/useDebugDeps.js +10 -4
- 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 +17 -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 +24 -0
- package/lib/hooks/middleware/concatMiddleware.d.ts.map +1 -1
- package/lib/hooks/middleware/concatMiddleware.js +2 -2
- package/lib/hooks/middleware/createDefaultCardActionMiddleware.d.ts.map +1 -1
- package/lib/hooks/middleware/createDefaultCardActionMiddleware.js +1 -1
- package/lib/hooks/useActivityKeys.d.ts +3 -0
- package/lib/hooks/useActivityKeys.d.ts.map +1 -0
- package/lib/hooks/useActivityKeys.js +14 -0
- package/lib/hooks/useActivityKeysByRead.d.ts +3 -0
- package/lib/hooks/useActivityKeysByRead.d.ts.map +1 -0
- package/lib/hooks/useActivityKeysByRead.js +14 -0
- package/lib/hooks/useCreateActivityStatusRenderer.d.ts.map +1 -1
- package/lib/hooks/useCreateActivityStatusRenderer.js +1 -1
- package/lib/hooks/useCreateAvatarRenderer.d.ts +4 -2
- package/lib/hooks/useCreateAvatarRenderer.d.ts.map +1 -1
- package/lib/hooks/useCreateAvatarRenderer.js +1 -1
- package/lib/hooks/useDateFormatter.d.ts.map +1 -1
- package/lib/hooks/useDateFormatter.js +1 -1
- package/lib/hooks/useDebouncedNotifications.js +1 -1
- package/lib/hooks/useGetActivityByKey.d.ts +3 -0
- package/lib/hooks/useGetActivityByKey.d.ts.map +1 -0
- package/lib/hooks/useGetActivityByKey.js +14 -0
- package/lib/hooks/useGetHasAcknowledgedByActivityKey.d.ts +3 -0
- package/lib/hooks/useGetHasAcknowledgedByActivityKey.d.ts.map +1 -0
- package/lib/hooks/useGetHasAcknowledgedByActivityKey.js +14 -0
- package/lib/hooks/useGetKeyByActivity.d.ts +3 -0
- package/lib/hooks/useGetKeyByActivity.d.ts.map +1 -0
- package/lib/hooks/useGetKeyByActivity.js +14 -0
- package/lib/hooks/useGetKeyByActivityId.d.ts +3 -0
- package/lib/hooks/useGetKeyByActivityId.d.ts.map +1 -0
- package/lib/hooks/useGetKeyByActivityId.js +14 -0
- package/lib/hooks/useGetSendTimeoutForActivity.d.ts.map +1 -1
- package/lib/hooks/useGetSendTimeoutForActivity.js +1 -1
- package/lib/hooks/useGroupActivities.d.ts.map +1 -1
- package/lib/hooks/useGroupActivities.js +1 -1
- package/lib/hooks/useLastAcknowledgedActivityKey.d.ts +3 -0
- package/lib/hooks/useLastAcknowledgedActivityKey.d.ts.map +1 -0
- package/lib/hooks/useLastAcknowledgedActivityKey.js +14 -0
- package/lib/hooks/useLastReadActivityKey.d.ts +3 -0
- package/lib/hooks/useLastReadActivityKey.d.ts.map +1 -0
- package/lib/hooks/useLastReadActivityKey.js +14 -0
- package/lib/hooks/useLocalizer.d.ts +1 -1
- package/lib/hooks/useLocalizer.d.ts.map +1 -1
- package/lib/hooks/useLocalizer.js +8 -2
- package/lib/hooks/useMarkActivityKeyAsRead.d.ts +3 -0
- package/lib/hooks/useMarkActivityKeyAsRead.d.ts.map +1 -0
- package/lib/hooks/useMarkActivityKeyAsRead.js +14 -0
- package/lib/hooks/useMarkAllAsAcknowledged.d.ts +3 -0
- package/lib/hooks/useMarkAllAsAcknowledged.d.ts.map +1 -0
- package/lib/hooks/useMarkAllAsAcknowledged.js +14 -0
- package/lib/hooks/usePerformCardAction.d.ts +2 -2
- package/lib/hooks/usePerformCardAction.d.ts.map +1 -1
- package/lib/hooks/usePerformCardAction.js +1 -1
- package/lib/hooks/useSubmitSendBox.d.ts.map +1 -1
- package/lib/hooks/useSubmitSendBox.js +8 -5
- package/lib/hooks/utils/ErrorBoundary.js +1 -1
- package/lib/index.js +7 -7
- package/lib/localization/Localize.d.ts.map +1 -1
- package/lib/localization/Localize.js +12 -6
- package/lib/localization/ar-SA.json +23 -4
- package/lib/localization/bg-BG.json +23 -4
- package/lib/localization/ca-ES.json +23 -4
- package/lib/localization/cs-CZ.json +23 -4
- package/lib/localization/da-DK.json +23 -4
- package/lib/localization/de-DE.json +23 -4
- package/lib/localization/el-GR.json +23 -4
- package/lib/localization/en-US.json +29 -7
- package/lib/localization/es-ES.json +23 -4
- package/lib/localization/et-EE.json +23 -4
- package/lib/localization/eu-ES.json +23 -4
- package/lib/localization/fi-FI.json +23 -4
- package/lib/localization/fr-FR.json +23 -4
- package/lib/localization/gl-ES.json +23 -4
- package/lib/localization/he-IL.json +23 -4
- package/lib/localization/hi-IN.json +23 -4
- package/lib/localization/hr-HR.json +23 -4
- package/lib/localization/hu-HU.json +23 -4
- package/lib/localization/id-ID.json +23 -4
- package/lib/localization/it-IT.json +23 -4
- package/lib/localization/ja-JP.json +23 -4
- package/lib/localization/kk-KZ.json +23 -4
- package/lib/localization/ko-KR.json +23 -4
- package/lib/localization/lt-LT.json +23 -4
- package/lib/localization/lv-LV.json +23 -4
- package/lib/localization/mergeLocalizedStrings.d.ts.map +1 -1
- package/lib/localization/mergeLocalizedStrings.js +11 -4
- package/lib/localization/ms-MY.json +23 -4
- package/lib/localization/nb-NO.json +23 -4
- package/lib/localization/nl-NL.json +23 -4
- package/lib/localization/pl-PL.json +23 -4
- package/lib/localization/pt-BR.json +23 -4
- package/lib/localization/pt-PT.json +23 -4
- package/lib/localization/ro-RO.json +23 -4
- package/lib/localization/ru-RU.json +23 -4
- package/lib/localization/sk-SK.json +23 -4
- package/lib/localization/sl-SI.json +23 -4
- package/lib/localization/sr-Cyrl-CS.json +23 -4
- package/lib/localization/sr-Latn-CS.json +23 -4
- package/lib/localization/sv-SE.json +23 -4
- package/lib/localization/th-TH.json +23 -4
- package/lib/localization/tr-TR.json +23 -4
- package/lib/localization/uk-UA.json +23 -4
- package/lib/localization/vi-VN.json +23 -4
- package/lib/localization/yue.json +26 -7
- package/lib/localization/zh-CN.json +23 -4
- package/lib/localization/zh-HK.json +23 -4
- package/lib/localization/zh-TW.json +23 -4
- package/lib/normalizeStyleOptions.d.ts.map +1 -1
- package/lib/normalizeStyleOptions.js +47 -2
- package/lib/patchStyleOptionsFromDeprecatedProps.js +1 -2
- package/lib/providers/ActivityAcknowledgement/ActivityAcknowledgementComposer.d.ts +5 -0
- package/lib/providers/ActivityAcknowledgement/ActivityAcknowledgementComposer.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/ActivityAcknowledgementComposer.js +184 -0
- package/lib/providers/ActivityAcknowledgement/private/Context.d.ts +13 -0
- package/lib/providers/ActivityAcknowledgement/private/Context.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/private/Context.js +13 -0
- package/lib/providers/ActivityAcknowledgement/private/types.d.ts +6 -0
- package/lib/providers/ActivityAcknowledgement/private/types.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/private/types.js +2 -0
- package/lib/providers/ActivityAcknowledgement/private/useContext.d.ts +3 -0
- package/lib/providers/ActivityAcknowledgement/private/useContext.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/private/useContext.js +24 -0
- package/lib/providers/ActivityAcknowledgement/useActivityKeysByRead.d.ts +5 -0
- package/lib/providers/ActivityAcknowledgement/useActivityKeysByRead.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useActivityKeysByRead.js +18 -0
- package/lib/providers/ActivityAcknowledgement/useGetHasAcknowledgedByActivityKey.d.ts +2 -0
- package/lib/providers/ActivityAcknowledgement/useGetHasAcknowledgedByActivityKey.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useGetHasAcknowledgedByActivityKey.js +15 -0
- package/lib/providers/ActivityAcknowledgement/useLastAcknowledgedActivityKey.d.ts +2 -0
- package/lib/providers/ActivityAcknowledgement/useLastAcknowledgedActivityKey.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useLastAcknowledgedActivityKey.js +15 -0
- package/lib/providers/ActivityAcknowledgement/useLastReadActivityKey.d.ts +2 -0
- package/lib/providers/ActivityAcknowledgement/useLastReadActivityKey.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useLastReadActivityKey.js +15 -0
- package/lib/providers/ActivityAcknowledgement/useMarkActivityKeyAsRead.d.ts +2 -0
- package/lib/providers/ActivityAcknowledgement/useMarkActivityKeyAsRead.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useMarkActivityKeyAsRead.js +15 -0
- package/lib/providers/ActivityAcknowledgement/useMarkAllAsAcknowledged.d.ts +2 -0
- package/lib/providers/ActivityAcknowledgement/useMarkAllAsAcknowledged.d.ts.map +1 -0
- package/lib/providers/ActivityAcknowledgement/useMarkAllAsAcknowledged.js +15 -0
- package/lib/providers/ActivityKeyer/ActivityKeyerComposer.d.ts +18 -0
- package/lib/providers/ActivityKeyer/ActivityKeyerComposer.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/ActivityKeyerComposer.js +153 -0
- package/lib/providers/ActivityKeyer/private/Context.d.ts +12 -0
- package/lib/providers/ActivityKeyer/private/Context.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/Context.js +13 -0
- package/lib/providers/ActivityKeyer/private/getActivityId.d.ts +3 -0
- package/lib/providers/ActivityKeyer/private/getActivityId.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/getActivityId.js +11 -0
- package/lib/providers/ActivityKeyer/private/getClientActivityId.d.ts +3 -0
- package/lib/providers/ActivityKeyer/private/getClientActivityId.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/getClientActivityId.js +13 -0
- package/lib/providers/ActivityKeyer/private/uniqueId.d.ts +2 -0
- package/lib/providers/ActivityKeyer/private/uniqueId.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/uniqueId.js +18 -0
- package/lib/providers/ActivityKeyer/private/useContext.d.ts +3 -0
- package/lib/providers/ActivityKeyer/private/useContext.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/private/useContext.js +24 -0
- package/lib/providers/ActivityKeyer/useActivityKeys.d.ts +2 -0
- package/lib/providers/ActivityKeyer/useActivityKeys.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/useActivityKeys.js +15 -0
- package/lib/providers/ActivityKeyer/useGetActivityByKey.d.ts +3 -0
- package/lib/providers/ActivityKeyer/useGetActivityByKey.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/useGetActivityByKey.js +15 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivity.d.ts +3 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivity.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivity.js +15 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivityId.d.ts +2 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivityId.d.ts.map +1 -0
- package/lib/providers/ActivityKeyer/useGetKeyByActivityId.js +15 -0
- package/lib/types/CardActionMiddleware.d.ts +3 -1
- package/lib/types/CardActionMiddleware.d.ts.map +1 -1
- package/lib/utils/createCustomEvent.d.ts.map +1 -1
- package/lib/utils/createCustomEvent.js +8 -2
- package/lib/utils/findLastIndex.d.ts +2 -0
- package/lib/utils/findLastIndex.d.ts.map +1 -0
- package/lib/utils/findLastIndex.js +32 -0
- package/lib/utils/findMin.js +1 -1
- package/lib/utils/mapMap.d.ts.map +1 -1
- package/lib/utils/mapMap.js +9 -2
- package/lib/utils/randomId.d.ts.map +1 -1
- package/lib/utils/randomId.js +1 -1
- package/package.json +13 -21
- package/src/StyleOptions.ts +293 -12
- package/src/defaultStyleOptions.ts +71 -13
- package/src/hooks/Composer.tsx +86 -49
- package/src/hooks/index.ts +20 -0
- package/src/hooks/internal/useCreateActivityRendererInternal.ts +21 -20
- package/src/hooks/internal/useDebugDeps.js +9 -2
- package/src/hooks/internal/usePrevious.ts +11 -0
- package/src/hooks/internal/useValueRef.ts +21 -0
- package/src/hooks/middleware/concatMiddleware.ts +6 -4
- package/src/hooks/middleware/createDefaultCardActionMiddleware.ts +29 -27
- package/src/hooks/useActivityKeys.ts +3 -0
- package/src/hooks/useActivityKeysByRead.ts +3 -0
- package/src/hooks/useCreateActivityStatusRenderer.tsx +10 -13
- package/src/hooks/useCreateAvatarRenderer.ts +23 -19
- package/src/hooks/useDateFormatter.ts +4 -3
- package/src/hooks/useGetActivityByKey.ts +3 -0
- package/src/hooks/useGetHasAcknowledgedByActivityKey.ts +3 -0
- package/src/hooks/useGetKeyByActivity.ts +3 -0
- package/src/hooks/useGetKeyByActivityId.ts +3 -0
- package/src/hooks/useGetSendTimeoutForActivity.ts +7 -6
- package/src/hooks/useGroupActivities.ts +1 -5
- package/src/hooks/useLastAcknowledgedActivityKey.ts +3 -0
- package/src/hooks/useLastReadActivityKey.ts +3 -0
- package/src/hooks/useLocalizer.ts +7 -2
- package/src/hooks/useMarkActivityKeyAsRead.ts +3 -0
- package/src/hooks/useMarkAllAsAcknowledged.ts +3 -0
- package/src/hooks/usePerformCardAction.ts +2 -3
- package/src/hooks/useSubmitSendBox.ts +2 -5
- package/src/localization/Localize.ts +9 -2
- package/src/localization/ar-SA.json +23 -4
- package/src/localization/bg-BG.json +23 -4
- package/src/localization/ca-ES.json +23 -4
- package/src/localization/cs-CZ.json +23 -4
- package/src/localization/da-DK.json +23 -4
- package/src/localization/de-DE.json +23 -4
- package/src/localization/el-GR.json +23 -4
- package/src/localization/en-US.json +29 -7
- package/src/localization/es-ES.json +23 -4
- package/src/localization/et-EE.json +23 -4
- package/src/localization/eu-ES.json +23 -4
- package/src/localization/fi-FI.json +23 -4
- package/src/localization/fr-FR.json +23 -4
- package/src/localization/gl-ES.json +23 -4
- package/src/localization/he-IL.json +23 -4
- package/src/localization/hi-IN.json +23 -4
- package/src/localization/hr-HR.json +23 -4
- package/src/localization/hu-HU.json +23 -4
- package/src/localization/id-ID.json +23 -4
- package/src/localization/it-IT.json +23 -4
- package/src/localization/ja-JP.json +23 -4
- package/src/localization/kk-KZ.json +23 -4
- package/src/localization/ko-KR.json +23 -4
- package/src/localization/lt-LT.json +23 -4
- package/src/localization/lv-LV.json +23 -4
- package/src/localization/mergeLocalizedStrings.ts +7 -1
- package/src/localization/ms-MY.json +23 -4
- package/src/localization/nb-NO.json +23 -4
- package/src/localization/nl-NL.json +23 -4
- package/src/localization/pl-PL.json +23 -4
- package/src/localization/pt-BR.json +23 -4
- package/src/localization/pt-PT.json +23 -4
- package/src/localization/ro-RO.json +23 -4
- package/src/localization/ru-RU.json +23 -4
- package/src/localization/sk-SK.json +23 -4
- package/src/localization/sl-SI.json +23 -4
- package/src/localization/sr-Cyrl-CS.json +23 -4
- package/src/localization/sr-Latn-CS.json +23 -4
- package/src/localization/sv-SE.json +23 -4
- package/src/localization/th-TH.json +23 -4
- package/src/localization/tr-TR.json +23 -4
- package/src/localization/uk-UA.json +23 -4
- package/src/localization/vi-VN.json +23 -4
- package/src/localization/yue.json +26 -7
- package/src/localization/zh-CN.json +23 -4
- package/src/localization/zh-HK.json +23 -4
- package/src/localization/zh-TW.json +23 -4
- package/src/normalizeStyleOptions.ts +70 -0
- package/src/patchStyleOptionsFromDeprecatedProps.js +0 -2
- package/src/providers/ActivityAcknowledgement/ActivityAcknowledgementComposer.tsx +180 -0
- package/src/providers/ActivityAcknowledgement/private/Context.ts +18 -0
- package/src/providers/ActivityAcknowledgement/private/types.ts +6 -0
- package/src/providers/ActivityAcknowledgement/private/useContext.ts +19 -0
- package/src/providers/ActivityAcknowledgement/useActivityKeysByRead.tsx +8 -0
- package/src/providers/ActivityAcknowledgement/useGetHasAcknowledgedByActivityKey.ts +5 -0
- package/src/providers/ActivityAcknowledgement/useLastAcknowledgedActivityKey.ts +5 -0
- package/src/providers/ActivityAcknowledgement/useLastReadActivityKey.ts +5 -0
- package/src/providers/ActivityAcknowledgement/useMarkActivityKeyAsRead.ts +5 -0
- package/src/providers/ActivityAcknowledgement/useMarkAllAsAcknowledged.ts +5 -0
- package/src/providers/ActivityKeyer/ActivityKeyerComposer.tsx +151 -0
- package/src/providers/ActivityKeyer/private/Context.ts +14 -0
- package/src/providers/ActivityKeyer/private/getActivityId.ts +5 -0
- package/src/providers/ActivityKeyer/private/getClientActivityId.ts +5 -0
- package/src/providers/ActivityKeyer/private/uniqueId.ts +8 -0
- package/src/providers/ActivityKeyer/private/useContext.ts +15 -0
- package/src/providers/ActivityKeyer/useActivityKeys.ts +5 -0
- package/src/providers/ActivityKeyer/useGetActivityByKey.ts +7 -0
- package/src/providers/ActivityKeyer/useGetKeyByActivity.ts +7 -0
- package/src/providers/ActivityKeyer/useGetKeyByActivityId.ts +5 -0
- package/src/types/CardActionMiddleware.ts +1 -1
- package/src/utils/createCustomEvent.ts +7 -1
- package/src/utils/findLastIndex.spec.js +31 -0
- package/src/utils/findLastIndex.ts +11 -0
- package/src/utils/mapMap.ts +7 -1
- package/src/utils/randomId.ts +1 -1
- package/.eslintignore +0 -1
package/src/hooks/Composer.tsx
CHANGED
|
@@ -36,6 +36,8 @@ import {
|
|
|
36
36
|
} from 'botframework-webchat-core';
|
|
37
37
|
|
|
38
38
|
import { default as WebChatAPIContext } from './internal/WebChatAPIContext';
|
|
39
|
+
import ActivityAcknowledgementComposer from '../providers/ActivityAcknowledgement/ActivityAcknowledgementComposer';
|
|
40
|
+
import ActivityKeyerComposer from '../providers/ActivityKeyer/ActivityKeyerComposer';
|
|
39
41
|
import ActivityMiddleware from '../types/ActivityMiddleware';
|
|
40
42
|
import ActivityStatusMiddleware from '../types/ActivityStatusMiddleware';
|
|
41
43
|
import AttachmentForScreenReaderMiddleware from '../types/AttachmentForScreenReaderMiddleware';
|
|
@@ -63,6 +65,7 @@ import TelemetryMeasurementEvent, { TelemetryExceptionMeasurementEvent } from '.
|
|
|
63
65
|
import ToastMiddleware from '../types/ToastMiddleware';
|
|
64
66
|
import Tracker from './internal/Tracker';
|
|
65
67
|
import TypingIndicatorMiddleware from '../types/TypingIndicatorMiddleware';
|
|
68
|
+
import useMarkAllAsAcknowledged from './useMarkAllAsAcknowledged';
|
|
66
69
|
import WebChatReduxContext, { useDispatch } from './internal/WebChatReduxContext';
|
|
67
70
|
|
|
68
71
|
import applyMiddleware, {
|
|
@@ -98,7 +101,7 @@ const DISPATCHERS = {
|
|
|
98
101
|
submitSendBox
|
|
99
102
|
};
|
|
100
103
|
|
|
101
|
-
function createCardActionContext({ cardActionMiddleware, directLine, dispatch }) {
|
|
104
|
+
function createCardActionContext({ cardActionMiddleware, directLine, dispatch, markAllAsAcknowledged }) {
|
|
102
105
|
const runMiddleware = applyMiddleware(
|
|
103
106
|
'card action',
|
|
104
107
|
...singleToArray(cardActionMiddleware),
|
|
@@ -106,8 +109,10 @@ function createCardActionContext({ cardActionMiddleware, directLine, dispatch })
|
|
|
106
109
|
)({ dispatch });
|
|
107
110
|
|
|
108
111
|
return {
|
|
109
|
-
onCardAction: (cardAction, { target }: { target?: any } = {}) =>
|
|
110
|
-
|
|
112
|
+
onCardAction: (cardAction, { target }: { target?: any } = {}) => {
|
|
113
|
+
markAllAsAcknowledged();
|
|
114
|
+
|
|
115
|
+
return runMiddleware({
|
|
111
116
|
cardAction,
|
|
112
117
|
getSignInUrl:
|
|
113
118
|
cardAction.type === 'signin'
|
|
@@ -131,7 +136,8 @@ function createCardActionContext({ cardActionMiddleware, directLine, dispatch })
|
|
|
131
136
|
}
|
|
132
137
|
: null,
|
|
133
138
|
target
|
|
134
|
-
})
|
|
139
|
+
});
|
|
140
|
+
}
|
|
135
141
|
};
|
|
136
142
|
}
|
|
137
143
|
|
|
@@ -167,6 +173,12 @@ function mergeStringsOverrides(localizedStrings, language, overrideLocalizedStri
|
|
|
167
173
|
return { ...localizedStrings, ...overrideLocalizedStrings };
|
|
168
174
|
}
|
|
169
175
|
|
|
176
|
+
// It seems "react/require-default-props" did not pick up `ComposerCore.defaultProps`.
|
|
177
|
+
// And it falsely complaint `optional?: string` must have a corresponding `ComposerCore.defaultProps.optional = undefined`, even we already set it below.
|
|
178
|
+
// Since we set both TypeScript `Props` class and `ComposerCore.propTypes`, this check will be done there as well.
|
|
179
|
+
// Ignoring it in TypeScript version should be safe, as we have `propTypes` version to protect us.
|
|
180
|
+
|
|
181
|
+
/* eslint-disable react/require-default-props */
|
|
170
182
|
type ComposerCoreProps = {
|
|
171
183
|
activityMiddleware?: OneOrMany<ActivityMiddleware>;
|
|
172
184
|
activityStatusMiddleware?: OneOrMany<ActivityStatusMiddleware>;
|
|
@@ -182,7 +194,6 @@ type ComposerCoreProps = {
|
|
|
182
194
|
grammars?: any;
|
|
183
195
|
groupActivitiesMiddleware?: OneOrMany<GroupActivitiesMiddleware>;
|
|
184
196
|
internalErrorBoxClass?: React.Component | Function;
|
|
185
|
-
internalRenderErrorBox?: any;
|
|
186
197
|
locale?: string;
|
|
187
198
|
onTelemetry?: (event: TelemetryMeasurementEvent) => void;
|
|
188
199
|
overrideLocalizedStrings?: LocalizedStrings | ((strings: LocalizedStrings, language: string) => LocalizedStrings);
|
|
@@ -213,6 +224,7 @@ type ComposerCoreProps = {
|
|
|
213
224
|
/** @deprecated Please use "typingIndicatorRenderer" instead. */
|
|
214
225
|
typingIndicatorRenderer?: any; // TODO: [P4] Remove on or after 2022-06-15.
|
|
215
226
|
};
|
|
227
|
+
/* eslint-enable react/require-default-props */
|
|
216
228
|
|
|
217
229
|
const ComposerCore: FC<ComposerCoreProps> = ({
|
|
218
230
|
activityMiddleware,
|
|
@@ -289,16 +301,17 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
289
301
|
};
|
|
290
302
|
}, [dispatch, directLine, userID, username]);
|
|
291
303
|
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
dispatch
|
|
296
|
-
|
|
304
|
+
const markAllAsAcknowledged = useMarkAllAsAcknowledged();
|
|
305
|
+
|
|
306
|
+
const cardActionContext = useMemo(
|
|
307
|
+
() => createCardActionContext({ cardActionMiddleware, directLine, dispatch, markAllAsAcknowledged }),
|
|
308
|
+
[cardActionMiddleware, directLine, dispatch, markAllAsAcknowledged]
|
|
309
|
+
);
|
|
297
310
|
|
|
298
|
-
const patchedSelectVoice = useMemo(
|
|
299
|
-
locale,
|
|
300
|
-
selectVoice
|
|
301
|
-
|
|
311
|
+
const patchedSelectVoice = useMemo(
|
|
312
|
+
() => selectVoice || defaultSelectVoice.bind(null, { language: locale }),
|
|
313
|
+
[locale, selectVoice]
|
|
314
|
+
);
|
|
302
315
|
|
|
303
316
|
const groupActivitiesContext = useMemo(
|
|
304
317
|
() =>
|
|
@@ -310,7 +323,13 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
310
323
|
);
|
|
311
324
|
|
|
312
325
|
const hoistedDispatchers = useMemo(
|
|
313
|
-
() =>
|
|
326
|
+
() =>
|
|
327
|
+
mapMap(
|
|
328
|
+
DISPATCHERS,
|
|
329
|
+
dispatcher =>
|
|
330
|
+
(...args) =>
|
|
331
|
+
dispatch(dispatcher(...args))
|
|
332
|
+
),
|
|
314
333
|
[dispatch]
|
|
315
334
|
);
|
|
316
335
|
|
|
@@ -358,13 +377,15 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
358
377
|
'activity',
|
|
359
378
|
{ strict: false },
|
|
360
379
|
...singleToArray(activityMiddleware),
|
|
361
|
-
() =>
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
380
|
+
() =>
|
|
381
|
+
() =>
|
|
382
|
+
({ activity }) => {
|
|
383
|
+
if (activity) {
|
|
384
|
+
throw new Error(`No renderer for activity of type "${activity.type}"`);
|
|
385
|
+
} else {
|
|
386
|
+
throw new Error('No activity to render');
|
|
387
|
+
}
|
|
366
388
|
}
|
|
367
|
-
}
|
|
368
389
|
)({})
|
|
369
390
|
);
|
|
370
391
|
}, [activityMiddleware, activityRenderer]);
|
|
@@ -392,19 +413,21 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
392
413
|
'attachment for screen reader',
|
|
393
414
|
{ strict: true },
|
|
394
415
|
...singleToArray(attachmentForScreenReaderMiddleware),
|
|
395
|
-
() =>
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
416
|
+
() =>
|
|
417
|
+
() =>
|
|
418
|
+
({ attachment }) => {
|
|
419
|
+
if (attachment) {
|
|
420
|
+
console.warn(`No renderer for attachment for screen reader of type "${attachment.contentType}"`);
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
return () => {
|
|
425
|
+
/**
|
|
426
|
+
* @todo TODO: [P4] Might be able to throw without returning a function -- investigate and possibly fix
|
|
427
|
+
*/
|
|
428
|
+
throw new Error('No attachment to render');
|
|
429
|
+
};
|
|
399
430
|
}
|
|
400
|
-
|
|
401
|
-
return () => {
|
|
402
|
-
/**
|
|
403
|
-
* @todo TODO: [P4] Might be able to throw without returning a function -- investigate and possibly fix
|
|
404
|
-
*/
|
|
405
|
-
throw new Error('No attachment to render');
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
431
|
)({}),
|
|
409
432
|
[attachmentForScreenReaderMiddleware]
|
|
410
433
|
);
|
|
@@ -422,13 +445,15 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
422
445
|
return applyMiddlewareForLegacyRenderer(
|
|
423
446
|
'attachment',
|
|
424
447
|
...singleToArray(attachmentMiddleware),
|
|
425
|
-
() =>
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
448
|
+
() =>
|
|
449
|
+
() =>
|
|
450
|
+
({ attachment }) => {
|
|
451
|
+
if (attachment) {
|
|
452
|
+
throw new Error(`No renderer for attachment of type "${attachment.contentType}"`);
|
|
453
|
+
} else {
|
|
454
|
+
throw new Error('No attachment to render');
|
|
455
|
+
}
|
|
430
456
|
}
|
|
431
|
-
}
|
|
432
457
|
)({});
|
|
433
458
|
}, [attachmentMiddleware, attachmentRenderer]);
|
|
434
459
|
|
|
@@ -440,8 +465,11 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
440
465
|
|
|
441
466
|
return (
|
|
442
467
|
avatarRenderer ||
|
|
443
|
-
applyMiddlewareForRenderer(
|
|
444
|
-
|
|
468
|
+
applyMiddlewareForRenderer(
|
|
469
|
+
'avatar',
|
|
470
|
+
{ strict: false },
|
|
471
|
+
...singleToArray(avatarMiddleware),
|
|
472
|
+
() => () => () => false
|
|
445
473
|
)({})
|
|
446
474
|
);
|
|
447
475
|
}, [avatarMiddleware, avatarRenderer]);
|
|
@@ -458,13 +486,15 @@ const ComposerCore: FC<ComposerCoreProps> = ({
|
|
|
458
486
|
'toast',
|
|
459
487
|
{ strict: false },
|
|
460
488
|
...singleToArray(toastMiddleware),
|
|
461
|
-
() =>
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
489
|
+
() =>
|
|
490
|
+
() =>
|
|
491
|
+
({ notification }) => {
|
|
492
|
+
if (notification) {
|
|
493
|
+
throw new Error(`No renderer for notification of type "${notification.contentType}"`);
|
|
494
|
+
} else {
|
|
495
|
+
throw new Error('No notification to render');
|
|
496
|
+
}
|
|
466
497
|
}
|
|
467
|
-
}
|
|
468
498
|
)({})
|
|
469
499
|
);
|
|
470
500
|
}, [toastMiddleware, toastRenderer]);
|
|
@@ -672,7 +702,10 @@ ComposerCore.propTypes = {
|
|
|
672
702
|
username: PropTypes.string
|
|
673
703
|
};
|
|
674
704
|
|
|
675
|
-
type ComposerProps = ComposerCoreProps & {
|
|
705
|
+
type ComposerProps = ComposerCoreProps & {
|
|
706
|
+
internalRenderErrorBox?: any;
|
|
707
|
+
store?: any;
|
|
708
|
+
};
|
|
676
709
|
|
|
677
710
|
// We will create a Redux store if it was not passed in
|
|
678
711
|
const Composer: FC<ComposerProps> = ({ internalRenderErrorBox, onTelemetry, store, ...props }) => {
|
|
@@ -696,7 +729,11 @@ const Composer: FC<ComposerProps> = ({ internalRenderErrorBox, onTelemetry, stor
|
|
|
696
729
|
) : (
|
|
697
730
|
<ErrorBoundary onError={handleError}>
|
|
698
731
|
<Provider context={WebChatReduxContext} store={memoizedStore}>
|
|
699
|
-
<
|
|
732
|
+
<ActivityKeyerComposer>
|
|
733
|
+
<ActivityAcknowledgementComposer>
|
|
734
|
+
<ComposerCore onTelemetry={onTelemetry} {...props} />
|
|
735
|
+
</ActivityAcknowledgementComposer>
|
|
736
|
+
</ActivityKeyerComposer>
|
|
700
737
|
</Provider>
|
|
701
738
|
</ErrorBoundary>
|
|
702
739
|
);
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import useActiveTyping from './useActiveTyping';
|
|
2
2
|
import useActivities from './useActivities';
|
|
3
|
+
import useActivityKeys from './useActivityKeys';
|
|
4
|
+
import useActivityKeysByRead from './useActivityKeysByRead';
|
|
3
5
|
import useAvatarForBot from './useAvatarForBot';
|
|
4
6
|
import useAvatarForUser from './useAvatarForUser';
|
|
5
7
|
import useByteFormatter from './useByteFormatter';
|
|
@@ -17,16 +19,24 @@ import useDirection from './useDirection';
|
|
|
17
19
|
import useDisabled from './useDisabled';
|
|
18
20
|
import useDismissNotification from './useDismissNotification';
|
|
19
21
|
import useEmitTypingIndicator from './useEmitTypingIndicator';
|
|
22
|
+
import useGetActivityByKey from './useGetActivityByKey';
|
|
23
|
+
import useGetHasAcknowledgedByActivityKey from './useGetHasAcknowledgedByActivityKey';
|
|
24
|
+
import useGetKeyByActivity from './useGetKeyByActivity';
|
|
25
|
+
import useGetKeyByActivityId from './useGetKeyByActivityId';
|
|
20
26
|
import useGetSendTimeoutForActivity from './useGetSendTimeoutForActivity';
|
|
21
27
|
import useGrammars from './useGrammars';
|
|
22
28
|
import useGroupActivities from './useGroupActivities';
|
|
23
29
|
import useGroupTimestamp from './useGroupTimestamp';
|
|
24
30
|
import useLanguage from './useLanguage';
|
|
31
|
+
import useLastAcknowledgedActivityKey from './useLastAcknowledgedActivityKey';
|
|
32
|
+
import useLastReadActivityKey from './useLastReadActivityKey';
|
|
25
33
|
import useLastTypingAt from './useLastTypingAt';
|
|
26
34
|
import useLocalize from './useLocalize'; // Deprecated on or after 2022-02-12
|
|
27
35
|
import useLocalizeDate from './useLocalizeDate'; // Deprecated on or after 2022-02-12
|
|
28
36
|
import useLocalizer from './useLocalizer';
|
|
29
37
|
import useMarkActivityAsSpoken from './useMarkActivityAsSpoken';
|
|
38
|
+
import useMarkActivityKeyAsRead from './useMarkActivityKeyAsRead';
|
|
39
|
+
import useMarkAllAsAcknowledged from './useMarkAllAsAcknowledged';
|
|
30
40
|
import usePerformCardAction from './usePerformCardAction';
|
|
31
41
|
import usePostActivity from './usePostActivity';
|
|
32
42
|
import useReferenceGrammarID from './useReferenceGrammarID';
|
|
@@ -64,6 +74,8 @@ import useVoiceSelector from './useVoiceSelector';
|
|
|
64
74
|
export {
|
|
65
75
|
useActiveTyping,
|
|
66
76
|
useActivities,
|
|
77
|
+
useActivityKeys,
|
|
78
|
+
useActivityKeysByRead,
|
|
67
79
|
useAvatarForBot,
|
|
68
80
|
useAvatarForUser,
|
|
69
81
|
useByteFormatter,
|
|
@@ -81,16 +93,24 @@ export {
|
|
|
81
93
|
useDisabled,
|
|
82
94
|
useDismissNotification,
|
|
83
95
|
useEmitTypingIndicator,
|
|
96
|
+
useGetActivityByKey,
|
|
97
|
+
useGetHasAcknowledgedByActivityKey,
|
|
98
|
+
useGetKeyByActivity,
|
|
99
|
+
useGetKeyByActivityId,
|
|
84
100
|
useGetSendTimeoutForActivity,
|
|
85
101
|
useGrammars,
|
|
86
102
|
useGroupActivities,
|
|
87
103
|
useGroupTimestamp,
|
|
88
104
|
useLanguage,
|
|
105
|
+
useLastAcknowledgedActivityKey,
|
|
106
|
+
useLastReadActivityKey,
|
|
89
107
|
useLastTypingAt,
|
|
90
108
|
useLocalize,
|
|
91
109
|
useLocalizeDate,
|
|
92
110
|
useLocalizer,
|
|
93
111
|
useMarkActivityAsSpoken,
|
|
112
|
+
useMarkActivityKeyAsRead,
|
|
113
|
+
useMarkAllAsAcknowledged,
|
|
94
114
|
usePerformCardAction,
|
|
95
115
|
usePostActivity,
|
|
96
116
|
useReferenceGrammarID,
|
|
@@ -14,32 +14,33 @@ export default function useCreateActivityRendererInternal(
|
|
|
14
14
|
const renderAttachment: RenderAttachment = renderAttachmentOverride || defaultRenderAttachment;
|
|
15
15
|
|
|
16
16
|
return useMemo(
|
|
17
|
-
() =>
|
|
18
|
-
|
|
17
|
+
() =>
|
|
18
|
+
(...createActivityRendererOptions) => {
|
|
19
|
+
const renderActivity = createActivityRenderer(...createActivityRendererOptions);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return renderActivityOptions => {
|
|
25
|
-
if (isValidElement(renderActivity)) {
|
|
26
|
-
return renderActivity;
|
|
21
|
+
if (!renderActivity) {
|
|
22
|
+
return false;
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
return renderActivityOptions => {
|
|
26
|
+
if (isValidElement(renderActivity)) {
|
|
27
|
+
return renderActivity;
|
|
28
|
+
}
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'botframework-webchat: To hide an activity, the activity renderer should return false. It should not return a function that will return false when called.'
|
|
30
|
+
const activityElement = renderActivity(
|
|
31
|
+
(...renderAttachmentArgs) => renderAttachment(...renderAttachmentArgs),
|
|
32
|
+
renderActivityOptions
|
|
38
33
|
);
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
// "activityElement" cannot be false. If the middleware want to hide the "activityElement", it should return "false" when we call createActivityRenderer().
|
|
36
|
+
activityElement ||
|
|
37
|
+
console.warn(
|
|
38
|
+
'botframework-webchat: To hide an activity, the activity renderer should return false. It should not return a function that will return false when called.'
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return activityElement;
|
|
42
|
+
};
|
|
43
|
+
},
|
|
43
44
|
[createActivityRenderer, renderAttachment]
|
|
44
45
|
);
|
|
45
46
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint no-console: "off" */
|
|
2
2
|
|
|
3
|
+
import { isForbiddenPropertyNames } from 'botframework-webchat-core';
|
|
3
4
|
import { useRef } from 'react';
|
|
4
5
|
|
|
5
6
|
export default function useDebugDeps(depsMap, name) {
|
|
@@ -7,13 +8,19 @@ export default function useDebugDeps(depsMap, name) {
|
|
|
7
8
|
|
|
8
9
|
const { current: lastDepsMap } = lastDepsMapRef;
|
|
9
10
|
const keys = new Set([...Object.keys(depsMap), ...Object.keys(lastDepsMap)]);
|
|
10
|
-
const keysChanged = Array.from(keys).filter(
|
|
11
|
+
const keysChanged = Array.from(keys).filter(
|
|
12
|
+
// Mitigation through denylisting.
|
|
13
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
14
|
+
key => !isForbiddenPropertyNames(key) && !Object.is(depsMap[key], lastDepsMap[key])
|
|
15
|
+
);
|
|
11
16
|
|
|
12
17
|
if (keysChanged.length) {
|
|
13
18
|
console.groupCollapsed(`Changes found in ${name}`);
|
|
14
19
|
|
|
15
20
|
keysChanged.forEach(key => {
|
|
16
|
-
|
|
21
|
+
// Mitigation through denylisting.
|
|
22
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
23
|
+
isForbiddenPropertyNames(key) || console.log(key, { from: lastDepsMap[key], to: depsMap[key] });
|
|
17
24
|
});
|
|
18
25
|
|
|
19
26
|
console.groupEnd();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RefObject, useMemo, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
export default function useValueRef<T>(value: T): RefObject<T> {
|
|
4
|
+
const ref = useRef<T>();
|
|
5
|
+
const readOnlyRef = useMemo(
|
|
6
|
+
() =>
|
|
7
|
+
Object.create(
|
|
8
|
+
{},
|
|
9
|
+
{
|
|
10
|
+
current: {
|
|
11
|
+
get: () => ref.current
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
),
|
|
15
|
+
[]
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
ref.current = value;
|
|
19
|
+
|
|
20
|
+
return readOnlyRef;
|
|
21
|
+
}
|
|
@@ -13,11 +13,13 @@ export default function concatMiddleware<Setup, Result>(
|
|
|
13
13
|
|
|
14
14
|
return last => {
|
|
15
15
|
const stack = setup.slice();
|
|
16
|
-
const work =
|
|
17
|
-
|
|
16
|
+
const work =
|
|
17
|
+
(index: number) =>
|
|
18
|
+
(...runArgs) => {
|
|
19
|
+
const next = stack[+index];
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
return (next ? next(work(index + 1)) : last)(...runArgs);
|
|
22
|
+
};
|
|
21
23
|
|
|
22
24
|
return work(0);
|
|
23
25
|
};
|
|
@@ -3,38 +3,40 @@ import { sendMessage, sendMessageBack, sendPostBack } from 'botframework-webchat
|
|
|
3
3
|
import CardActionMiddleware from '../../types/CardActionMiddleware';
|
|
4
4
|
|
|
5
5
|
export default function createDefaultCardActionMiddleware(): CardActionMiddleware {
|
|
6
|
-
return ({ dispatch }) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// We cannot use destructured "type" here because TypeScript don't recognize "messageBack" is "MessageBackCardAction".
|
|
15
|
-
switch (cardAction.type) {
|
|
16
|
-
case 'imBack':
|
|
17
|
-
if (typeof value === 'string') {
|
|
18
|
-
// TODO: [P4] Instead of calling dispatch, we should move to dispatchers instead for completeness
|
|
19
|
-
dispatch(sendMessage(value, 'imBack'));
|
|
20
|
-
} else {
|
|
21
|
-
throw new Error('cannot send "imBack" with a non-string value');
|
|
6
|
+
return ({ dispatch }) =>
|
|
7
|
+
next =>
|
|
8
|
+
(...args) => {
|
|
9
|
+
const [
|
|
10
|
+
{
|
|
11
|
+
cardAction,
|
|
12
|
+
cardAction: { value }
|
|
22
13
|
}
|
|
14
|
+
] = args;
|
|
15
|
+
|
|
16
|
+
// We cannot use destructured "type" here because TypeScript don't recognize "messageBack" is "MessageBackCardAction".
|
|
17
|
+
switch (cardAction.type) {
|
|
18
|
+
case 'imBack':
|
|
19
|
+
if (typeof value === 'string') {
|
|
20
|
+
// TODO: [P4] Instead of calling dispatch, we should move to dispatchers instead for completeness
|
|
21
|
+
dispatch(sendMessage(value, 'imBack'));
|
|
22
|
+
} else {
|
|
23
|
+
throw new Error('cannot send "imBack" with a non-string value');
|
|
24
|
+
}
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
break;
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
case 'messageBack':
|
|
29
|
+
dispatch(sendMessageBack(value, cardAction.text, cardAction.displayText));
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
break;
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
case 'postBack':
|
|
34
|
+
dispatch(sendPostBack(value));
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
break;
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
default:
|
|
39
|
+
return next(...args);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
40
42
|
}
|
|
@@ -58,19 +58,16 @@ export default function useCreateActivityStatusRenderer(): (renderOptions: {
|
|
|
58
58
|
nextVisibleActivity: DirectLineActivity;
|
|
59
59
|
}) => (props: { hideTimestamp?: boolean }) => ReactNode {
|
|
60
60
|
return useMemo(
|
|
61
|
-
() =>
|
|
62
|
-
activity,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
nextVisibleActivity={nextVisibleActivity}
|
|
72
|
-
/>
|
|
73
|
-
),
|
|
61
|
+
() =>
|
|
62
|
+
({ activity, nextVisibleActivity }: { activity: DirectLineActivity; nextVisibleActivity: DirectLineActivity }) =>
|
|
63
|
+
({ hideTimestamp }: { hideTimestamp?: boolean } = {}) =>
|
|
64
|
+
(
|
|
65
|
+
<ActivityStatusContainer
|
|
66
|
+
activity={activity}
|
|
67
|
+
hideTimestamp={hideTimestamp}
|
|
68
|
+
nextVisibleActivity={nextVisibleActivity}
|
|
69
|
+
/>
|
|
70
|
+
),
|
|
74
71
|
[]
|
|
75
72
|
);
|
|
76
73
|
}
|
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
import { DirectLineActivity } from 'botframework-webchat-core';
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
3
|
|
|
4
|
+
import { AvatarComponentFactory } from '../types/AvatarMiddleware';
|
|
4
5
|
import useStyleOptions from './useStyleOptions';
|
|
5
6
|
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
6
7
|
|
|
7
|
-
export default function useCreateAvatarRenderer(): (
|
|
8
|
-
activity
|
|
9
|
-
|
|
8
|
+
export default function useCreateAvatarRenderer(): ({
|
|
9
|
+
activity
|
|
10
|
+
}: {
|
|
11
|
+
activity: DirectLineActivity;
|
|
12
|
+
}) => AvatarComponentFactory {
|
|
10
13
|
const [styleOptions] = useStyleOptions();
|
|
11
14
|
const { avatarRenderer } = useWebChatAPIContext();
|
|
12
15
|
|
|
13
16
|
return useMemo(
|
|
14
|
-
() =>
|
|
15
|
-
|
|
17
|
+
() =>
|
|
18
|
+
({ activity }) => {
|
|
19
|
+
const { from: { role } = {} }: { from?: { role?: string } } = activity;
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const result = avatarRenderer({
|
|
22
|
+
activity,
|
|
23
|
+
fromUser: role === 'user',
|
|
24
|
+
styleOptions
|
|
25
|
+
});
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
if (result !== false && typeof result !== 'function') {
|
|
28
|
+
console.warn(
|
|
29
|
+
'botframework-webchat: avatarMiddleware should return a function to render the avatar, or return false if avatar should be hidden. Please refer to HOOKS.md for details.'
|
|
30
|
+
);
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
return () => result;
|
|
33
|
+
}
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
return result;
|
|
36
|
+
},
|
|
33
37
|
[avatarRenderer, styleOptions]
|
|
34
38
|
);
|
|
35
39
|
}
|
|
@@ -5,9 +5,10 @@ import useLocalizedGlobalize from './internal/useLocalizedGlobalize';
|
|
|
5
5
|
export default function useDateFormatter(): (date: number | Date) => string {
|
|
6
6
|
const [globalize] = useLocalizedGlobalize();
|
|
7
7
|
|
|
8
|
-
const formatDate = useMemo(
|
|
9
|
-
globalize
|
|
10
|
-
|
|
8
|
+
const formatDate = useMemo(
|
|
9
|
+
() => date => globalize.dateFormatter({ skeleton: 'MMMMdhm' })(new Date(date)),
|
|
10
|
+
[globalize]
|
|
11
|
+
);
|
|
11
12
|
|
|
12
13
|
return formatDate;
|
|
13
14
|
}
|