botframework-webchat-api 4.13.0 → 4.14.2
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/.eslintignore +1 -9
- package/.eslintrc.yml +43 -38
- package/lib/StyleOptions.d.ts +28 -3
- package/lib/StyleOptions.d.ts.map +1 -1
- package/lib/defaultStyleOptions.d.ts +4 -0
- package/lib/defaultStyleOptions.d.ts.map +1 -0
- package/lib/defaultStyleOptions.js +7 -3
- package/lib/external/PrecompiledGlobalize.js +24 -6
- package/lib/hooks/Composer.d.ts +71 -0
- package/lib/hooks/Composer.d.ts.map +1 -0
- package/lib/hooks/Composer.js +104 -88
- package/lib/hooks/index.d.ts +64 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/index.js +9 -1
- package/lib/hooks/internal/ErrorBox.js +2 -2
- package/lib/hooks/internal/Tracker.d.ts +4 -0
- package/lib/hooks/internal/Tracker.d.ts.map +1 -0
- package/lib/hooks/internal/WebChatAPIContext.d.ts +81 -0
- package/lib/hooks/internal/WebChatAPIContext.d.ts.map +1 -0
- package/lib/hooks/internal/WebChatAPIContext.js +2 -4
- package/lib/hooks/internal/useCreateActivityRendererInternal.d.ts +4 -0
- package/lib/hooks/internal/useCreateActivityRendererInternal.d.ts.map +1 -0
- package/lib/hooks/internal/useCreateActivityRendererInternal.js +1 -1
- package/lib/hooks/internal/useDebugDeps.js +2 -2
- package/lib/hooks/internal/useDownscaleImageToDataURL.js +1 -1
- package/lib/hooks/internal/useErrorBoxClass.js +1 -1
- package/lib/hooks/internal/useForceRender.js +2 -2
- package/lib/hooks/internal/useLocalizedStrings.js +1 -1
- package/lib/hooks/internal/useReadTelemetryDimensions.js +2 -2
- package/lib/hooks/internal/useTimePassed.js +2 -2
- package/lib/hooks/internal/useTracker.js +2 -2
- package/lib/hooks/middleware/UserlandBoundary.js +4 -4
- package/lib/hooks/middleware/applyMiddleware.js +6 -6
- package/lib/hooks/middleware/concatMiddleware.d.ts +6 -0
- package/lib/hooks/middleware/concatMiddleware.d.ts.map +1 -0
- package/lib/hooks/middleware/concatMiddleware.js +2 -2
- package/lib/hooks/middleware/createDefaultCardActionMiddleware.d.ts +3 -0
- package/lib/hooks/middleware/createDefaultCardActionMiddleware.d.ts.map +1 -0
- package/lib/hooks/middleware/createDefaultCardActionMiddleware.js +6 -8
- package/lib/hooks/middleware/createDefaultGroupActivitiesMiddleware.d.ts +5 -0
- package/lib/hooks/middleware/createDefaultGroupActivitiesMiddleware.d.ts.map +1 -0
- package/lib/hooks/middleware/createDefaultGroupActivitiesMiddleware.js +1 -1
- package/lib/hooks/useActiveTyping.d.ts +6 -0
- package/lib/hooks/useActiveTyping.d.ts.map +1 -0
- package/lib/hooks/useActiveTyping.js +4 -4
- package/lib/hooks/useActivities.d.ts +3 -0
- package/lib/hooks/useActivities.d.ts.map +1 -0
- package/lib/hooks/useActivities.js +1 -1
- package/lib/hooks/useAvatarForBot.d.ts +5 -0
- package/lib/hooks/useAvatarForBot.d.ts.map +1 -0
- package/lib/hooks/useAvatarForBot.js +2 -2
- package/lib/hooks/useAvatarForUser.d.ts +5 -0
- package/lib/hooks/useAvatarForUser.d.ts.map +1 -0
- package/lib/hooks/useAvatarForUser.js +2 -2
- package/lib/hooks/useByteFormatter.d.ts +2 -0
- package/lib/hooks/useByteFormatter.d.ts.map +1 -0
- package/lib/hooks/useByteFormatter.js +2 -2
- package/lib/hooks/useConnectivityStatus.d.ts +2 -0
- package/lib/hooks/useConnectivityStatus.d.ts.map +1 -0
- package/lib/hooks/useConnectivityStatus.js +1 -1
- package/lib/hooks/useCreateActivityRenderer.d.ts +3 -0
- package/lib/hooks/useCreateActivityRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateActivityRenderer.js +1 -2
- package/lib/hooks/useCreateActivityStatusRenderer.d.ts +9 -0
- package/lib/hooks/useCreateActivityStatusRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateActivityStatusRenderer.js +6 -4
- package/lib/hooks/useCreateAvatarRenderer.d.ts +4 -0
- package/lib/hooks/useCreateAvatarRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateAvatarRenderer.js +2 -2
- package/lib/hooks/useCreateScrollToEndButtonRenderer.d.ts +3 -0
- package/lib/hooks/useCreateScrollToEndButtonRenderer.d.ts.map +1 -0
- package/lib/hooks/useCreateScrollToEndButtonRenderer.js +15 -0
- package/lib/hooks/useDateFormatter.d.ts +2 -0
- package/lib/hooks/useDateFormatter.d.ts.map +1 -0
- package/lib/hooks/useDateFormatter.js +2 -2
- package/lib/hooks/useDebouncedNotifications.d.ts +13 -0
- package/lib/hooks/useDebouncedNotifications.d.ts.map +1 -0
- package/lib/hooks/useDebouncedNotifications.js +6 -6
- package/lib/hooks/useDictateInterims.d.ts +2 -0
- package/lib/hooks/useDictateInterims.d.ts.map +1 -0
- package/lib/hooks/useDictateInterims.js +1 -1
- package/lib/hooks/useDictateState.d.ts +2 -0
- package/lib/hooks/useDictateState.d.ts.map +1 -0
- package/lib/hooks/useDictateState.js +1 -1
- package/lib/hooks/useDirection.d.ts +2 -0
- package/lib/hooks/useDirection.d.ts.map +1 -0
- package/lib/hooks/useDirection.js +2 -2
- package/lib/hooks/useDisabled.d.ts +2 -0
- package/lib/hooks/useDisabled.d.ts.map +1 -0
- package/lib/hooks/useDisabled.js +1 -1
- package/lib/hooks/useDismissNotification.d.ts +2 -0
- package/lib/hooks/useDismissNotification.d.ts.map +1 -0
- package/lib/hooks/useDismissNotification.js +1 -1
- package/lib/hooks/useEmitTypingIndicator.d.ts +2 -0
- package/lib/hooks/useEmitTypingIndicator.d.ts.map +1 -0
- package/lib/hooks/useEmitTypingIndicator.js +1 -1
- package/lib/hooks/useGetSendTimeoutForActivity.d.ts +5 -0
- package/lib/hooks/useGetSendTimeoutForActivity.d.ts.map +1 -0
- package/lib/hooks/useGetSendTimeoutForActivity.js +2 -2
- package/lib/hooks/useGrammars.d.ts +2 -0
- package/lib/hooks/useGrammars.d.ts.map +1 -0
- package/lib/hooks/useGrammars.js +1 -1
- package/lib/hooks/useGroupActivities.d.ts +8 -0
- package/lib/hooks/useGroupActivities.d.ts.map +1 -0
- package/lib/hooks/useGroupActivities.js +1 -1
- package/lib/hooks/useGroupTimestamp.d.ts +2 -0
- package/lib/hooks/useGroupTimestamp.d.ts.map +1 -0
- package/lib/hooks/useGroupTimestamp.js +2 -2
- package/lib/hooks/useLanguage.d.ts +2 -0
- package/lib/hooks/useLanguage.d.ts.map +1 -0
- package/lib/hooks/useLanguage.js +1 -1
- package/lib/hooks/useLastTypingAt.d.ts +5 -0
- package/lib/hooks/useLastTypingAt.d.ts.map +1 -0
- package/lib/hooks/useLastTypingAt.js +2 -1
- package/lib/hooks/useLocalize.d.ts +3 -0
- package/lib/hooks/useLocalize.d.ts.map +1 -0
- package/lib/hooks/useLocalize.js +5 -2
- package/lib/hooks/useLocalizeDate.d.ts +3 -0
- package/lib/hooks/useLocalizeDate.d.ts.map +1 -0
- package/lib/hooks/useLocalizeDate.js +3 -2
- package/lib/hooks/useLocalizer.d.ts +13 -0
- package/lib/hooks/useLocalizer.d.ts.map +1 -0
- package/lib/hooks/useLocalizer.js +10 -6
- package/lib/hooks/useMarkActivityAsSpoken.d.ts +3 -0
- package/lib/hooks/useMarkActivityAsSpoken.d.ts.map +1 -0
- package/lib/hooks/useMarkActivityAsSpoken.js +1 -1
- package/lib/hooks/useNotifications.d.ts +3 -0
- package/lib/hooks/useNotifications.d.ts.map +1 -0
- package/lib/hooks/useNotifications.js +1 -1
- package/lib/hooks/usePerformCardAction.d.ts +3 -0
- package/lib/hooks/usePerformCardAction.d.ts.map +1 -0
- package/lib/hooks/usePerformCardAction.js +1 -1
- package/lib/hooks/usePostActivity.d.ts +4 -0
- package/lib/hooks/usePostActivity.d.ts.map +1 -0
- package/lib/hooks/usePostActivity.js +1 -1
- package/lib/hooks/useReferenceGrammarID.d.ts +2 -0
- package/lib/hooks/useReferenceGrammarID.d.ts.map +1 -0
- package/lib/hooks/useReferenceGrammarID.js +1 -1
- package/lib/hooks/useRelativeTimeFormatter.d.ts +2 -0
- package/lib/hooks/useRelativeTimeFormatter.d.ts.map +1 -0
- package/lib/hooks/useRelativeTimeFormatter.js +2 -2
- package/lib/hooks/useRenderActivity.js +2 -1
- package/lib/hooks/useRenderActivityStatus.js +2 -1
- package/lib/hooks/useRenderAttachment.js +1 -1
- package/lib/hooks/useRenderAvatar.js +2 -1
- package/lib/hooks/useRenderToast.d.ts +3 -0
- package/lib/hooks/useRenderToast.d.ts.map +1 -0
- package/lib/hooks/useRenderToast.js +1 -1
- package/lib/hooks/useRenderTypingIndicator.d.ts +3 -0
- package/lib/hooks/useRenderTypingIndicator.d.ts.map +1 -0
- package/lib/hooks/useRenderTypingIndicator.js +1 -1
- package/lib/hooks/useSendBoxValue.d.ts +2 -0
- package/lib/hooks/useSendBoxValue.d.ts.map +1 -0
- package/lib/hooks/useSendBoxValue.js +1 -1
- package/lib/hooks/useSendEvent.d.ts +2 -0
- package/lib/hooks/useSendEvent.d.ts.map +1 -0
- package/lib/hooks/useSendEvent.js +1 -1
- package/lib/hooks/useSendFiles.d.ts +2 -0
- package/lib/hooks/useSendFiles.d.ts.map +1 -0
- package/lib/hooks/useSendFiles.js +1 -1
- package/lib/hooks/useSendMessage.d.ts +4 -0
- package/lib/hooks/useSendMessage.d.ts.map +1 -0
- package/lib/hooks/useSendMessage.js +1 -1
- package/lib/hooks/useSendMessageBack.d.ts +2 -0
- package/lib/hooks/useSendMessageBack.d.ts.map +1 -0
- package/lib/hooks/useSendMessageBack.js +1 -1
- package/lib/hooks/useSendPostBack.d.ts +2 -0
- package/lib/hooks/useSendPostBack.d.ts.map +1 -0
- package/lib/hooks/useSendPostBack.js +1 -1
- package/lib/hooks/useSendTimeoutForActivity.d.ts +4 -0
- package/lib/hooks/useSendTimeoutForActivity.d.ts.map +1 -0
- package/lib/hooks/useSendTimeoutForActivity.js +2 -1
- package/lib/hooks/useSendTypingIndicator.d.ts +2 -0
- package/lib/hooks/useSendTypingIndicator.d.ts.map +1 -0
- package/lib/hooks/useSendTypingIndicator.js +1 -1
- package/lib/hooks/useSetNotification.d.ts +3 -0
- package/lib/hooks/useSetNotification.d.ts.map +1 -0
- package/lib/hooks/useSetNotification.js +1 -1
- package/lib/hooks/useShouldSpeakIncomingActivity.d.ts +2 -0
- package/lib/hooks/useShouldSpeakIncomingActivity.d.ts.map +1 -0
- package/lib/hooks/useShouldSpeakIncomingActivity.js +1 -1
- package/lib/hooks/useStartDictate.d.ts +2 -0
- package/lib/hooks/useStartDictate.d.ts.map +1 -0
- package/lib/hooks/useStartDictate.js +1 -1
- package/lib/hooks/useStopDictate.d.ts +2 -0
- package/lib/hooks/useStopDictate.d.ts.map +1 -0
- package/lib/hooks/useStopDictate.js +1 -1
- package/lib/hooks/useStyleOptions.d.ts +3 -0
- package/lib/hooks/useStyleOptions.d.ts.map +1 -0
- package/lib/hooks/useStyleOptions.js +1 -1
- package/lib/hooks/useSubmitSendBox.d.ts +4 -0
- package/lib/hooks/useSubmitSendBox.d.ts.map +1 -0
- package/lib/hooks/useSubmitSendBox.js +1 -1
- package/lib/hooks/useSuggestedActions.d.ts +6 -0
- package/lib/hooks/useSuggestedActions.d.ts.map +1 -0
- package/lib/hooks/useSuggestedActions.js +1 -1
- package/lib/hooks/useTimeoutForSend.d.ts +3 -0
- package/lib/hooks/useTimeoutForSend.d.ts.map +1 -0
- package/lib/hooks/useTimeoutForSend.js +2 -2
- package/lib/hooks/useTrackDimension.d.ts +2 -0
- package/lib/hooks/useTrackDimension.d.ts.map +1 -0
- package/lib/hooks/useTrackDimension.js +1 -1
- package/lib/hooks/useTrackEvent.d.ts +10 -0
- package/lib/hooks/useTrackEvent.d.ts.map +1 -0
- package/lib/hooks/useTrackEvent.js +1 -1
- package/lib/hooks/useTrackException.d.ts +2 -0
- package/lib/hooks/useTrackException.d.ts.map +1 -0
- package/lib/hooks/useTrackException.js +2 -2
- package/lib/hooks/useTrackTiming.d.ts +2 -0
- package/lib/hooks/useTrackTiming.d.ts.map +1 -0
- package/lib/hooks/useTrackTiming.js +1 -1
- package/lib/hooks/useUserID.d.ts +2 -0
- package/lib/hooks/useUserID.d.ts.map +1 -0
- package/lib/hooks/useUserID.js +1 -1
- package/lib/hooks/useUsername.d.ts +2 -0
- package/lib/hooks/useUsername.d.ts.map +1 -0
- package/lib/hooks/useUsername.js +1 -1
- package/lib/hooks/useVoiceSelector.d.ts +2 -0
- package/lib/hooks/useVoiceSelector.d.ts.map +1 -0
- package/lib/hooks/useVoiceSelector.js +1 -1
- package/lib/hooks/utils/ErrorBoundary.js +3 -3
- package/lib/hooks/utils/observableToPromise.d.ts +3 -0
- package/lib/hooks/utils/observableToPromise.d.ts.map +1 -0
- package/lib/hooks/utils/observableToPromise.js +1 -1
- package/lib/index.d.ts +20 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/localization/Localize.d.ts +10 -0
- package/lib/localization/Localize.d.ts.map +1 -0
- package/lib/localization/Localize.js +7 -7
- package/lib/localization/ar-SA.json +1 -0
- package/lib/localization/bg-BG.json +1 -0
- package/lib/localization/ca-ES.json +1 -0
- package/lib/localization/cs-CZ.json +1 -0
- package/lib/localization/da-DK.json +1 -0
- package/lib/localization/de-DE.json +1 -0
- package/lib/localization/el-GR.json +1 -0
- package/lib/localization/en-US.json +1 -0
- package/lib/localization/es-ES.json +1 -0
- package/lib/localization/et-EE.json +1 -0
- package/lib/localization/eu-ES.json +1 -0
- package/lib/localization/fi-FI.json +1 -0
- package/lib/localization/fr-FR.json +1 -0
- package/lib/localization/getAllLocalizedStrings.d.ts +6 -0
- package/lib/localization/getAllLocalizedStrings.d.ts.map +1 -0
- package/lib/localization/getAllLocalizedStrings.js +1 -1
- package/lib/localization/getLocaleString.d.ts +2 -0
- package/lib/localization/getLocaleString.d.ts.map +1 -0
- package/lib/localization/getLocaleString.js +3 -3
- package/lib/localization/getRTLList.d.ts +2 -0
- package/lib/localization/getRTLList.d.ts.map +1 -0
- package/lib/localization/getRTLList.js +1 -1
- package/lib/localization/gl-ES.json +1 -0
- package/lib/localization/he-IL.json +1 -0
- package/lib/localization/hi-IN.json +1 -0
- package/lib/localization/hr-HR.json +1 -0
- package/lib/localization/hu-HU.json +1 -0
- package/lib/localization/id-ID.json +1 -0
- package/lib/localization/it-IT.json +1 -0
- package/lib/localization/ja-JP.json +1 -0
- package/lib/localization/kk-KZ.json +1 -0
- package/lib/localization/ko-KR.json +1 -0
- package/lib/localization/lt-LT.json +1 -0
- package/lib/localization/lv-LV.json +1 -0
- package/lib/localization/mergeLocalizedStrings.d.ts +7 -0
- package/lib/localization/mergeLocalizedStrings.d.ts.map +1 -0
- package/lib/localization/mergeLocalizedStrings.js +4 -4
- package/lib/localization/ms-MY.json +1 -0
- package/lib/localization/nb-NO.json +1 -0
- package/lib/localization/nl-NL.json +1 -0
- package/lib/localization/pl-PL.json +1 -0
- package/lib/localization/pt-BR.json +1 -0
- package/lib/localization/pt-PT.json +1 -0
- package/lib/localization/ro-RO.json +1 -0
- package/lib/localization/ru-RU.json +1 -0
- package/lib/localization/sk-SK.json +1 -0
- package/lib/localization/sl-SI.json +1 -0
- package/lib/localization/sr-Cyrl-CS.json +1 -0
- package/lib/localization/sr-Latn-CS.json +1 -0
- package/lib/localization/sv-SE.json +1 -0
- package/lib/localization/th-TH.json +1 -0
- package/lib/localization/tr-TR.json +1 -0
- package/lib/localization/uk-UA.json +1 -0
- package/lib/localization/vi-VN.json +1 -0
- package/lib/localization/yue.json +1 -0
- package/lib/localization/zh-CN.json +1 -0
- package/lib/localization/zh-HK.json +1 -0
- package/lib/localization/zh-TW.json +1 -0
- package/lib/normalizeStyleOptions.d.ts +3 -0
- package/lib/normalizeStyleOptions.d.ts.map +1 -0
- package/lib/normalizeStyleOptions.js +40 -5
- package/lib/tsconfig.json +3 -1
- package/lib/types/ActivityMiddleware.d.ts +25 -0
- package/lib/types/ActivityMiddleware.d.ts.map +1 -0
- package/lib/types/ActivityMiddleware.js +2 -0
- package/lib/types/ActivityStatusMiddleware.d.ts +18 -0
- package/lib/types/ActivityStatusMiddleware.d.ts.map +1 -0
- package/lib/types/ActivityStatusMiddleware.js +2 -0
- package/lib/types/AttachmentForScreenReaderMiddleware.d.ts +14 -0
- package/lib/types/AttachmentForScreenReaderMiddleware.d.ts.map +1 -0
- package/lib/types/AttachmentForScreenReaderMiddleware.js +2 -0
- package/lib/types/AttachmentMiddleware.d.ts +12 -0
- package/lib/types/AttachmentMiddleware.d.ts.map +1 -0
- package/lib/types/AttachmentMiddleware.js +2 -0
- package/lib/types/AvatarMiddleware.d.ts +15 -0
- package/lib/types/AvatarMiddleware.d.ts.map +1 -0
- package/lib/types/AvatarMiddleware.js +2 -0
- package/lib/types/CardActionMiddleware.d.ts +17 -0
- package/lib/types/CardActionMiddleware.d.ts.map +1 -0
- package/lib/types/CardActionMiddleware.js +2 -0
- package/lib/types/ComponentMiddleware.d.ts +31 -0
- package/lib/types/ComponentMiddleware.d.ts.map +1 -0
- package/lib/types/ComponentMiddleware.js +2 -0
- package/lib/types/FunctionMiddleware.d.ts +6 -0
- package/lib/types/FunctionMiddleware.d.ts.map +1 -0
- package/lib/types/FunctionMiddleware.js +2 -0
- package/lib/types/GroupActivitiesMiddleware.d.ts +22 -0
- package/lib/types/GroupActivitiesMiddleware.d.ts.map +1 -0
- package/lib/types/GroupActivitiesMiddleware.js +2 -0
- package/lib/types/LocalizedStrings.d.ts +5 -0
- package/lib/types/LocalizedStrings.d.ts.map +1 -0
- package/lib/types/LocalizedStrings.js +2 -0
- package/lib/types/Notification.d.ts +10 -0
- package/lib/types/Notification.d.ts.map +1 -0
- package/lib/types/Notification.js +2 -0
- package/lib/types/PrecompiledGlobalize.d.ts +13 -0
- package/lib/types/PrecompiledGlobalize.d.ts.map +1 -0
- package/lib/types/PrecompiledGlobalize.js +2 -0
- package/lib/types/ScrollToEndButtonMiddleware.d.ts +30 -0
- package/lib/types/ScrollToEndButtonMiddleware.d.ts.map +1 -0
- package/lib/types/ScrollToEndButtonMiddleware.js +2 -0
- package/lib/types/SendState.d.ts +3 -0
- package/lib/types/SendState.d.ts.map +1 -0
- package/lib/types/SendState.js +2 -0
- package/lib/types/TelemetryMeasurementEvent.d.ts +31 -0
- package/lib/types/TelemetryMeasurementEvent.d.ts.map +1 -0
- package/lib/types/TelemetryMeasurementEvent.js +2 -0
- package/lib/types/ToastMiddleware.d.ts +11 -0
- package/lib/types/ToastMiddleware.d.ts.map +1 -0
- package/lib/types/ToastMiddleware.js +2 -0
- package/lib/types/Typing.d.ts +8 -0
- package/lib/types/Typing.d.ts.map +1 -0
- package/lib/types/Typing.js +2 -0
- package/lib/types/TypingIndicatorMiddleware.d.ts +17 -0
- package/lib/types/TypingIndicatorMiddleware.d.ts.map +1 -0
- package/lib/types/TypingIndicatorMiddleware.js +2 -0
- package/lib/types/WebSpeechPonyfill.d.ts +18 -0
- package/lib/types/WebSpeechPonyfill.d.ts.map +1 -0
- package/lib/types/WebSpeechPonyfill.js +2 -0
- package/lib/types/WebSpeechPonyfillFactory.d.ts +6 -0
- package/lib/types/WebSpeechPonyfillFactory.d.ts.map +1 -0
- package/lib/types/WebSpeechPonyfillFactory.js +2 -0
- package/lib/utils/createCustomEvent.d.ts +4 -0
- package/lib/utils/createCustomEvent.d.ts.map +1 -0
- package/lib/utils/createCustomEvent.js +2 -2
- package/lib/utils/findMin.d.ts +7 -0
- package/lib/utils/findMin.d.ts.map +1 -0
- package/lib/utils/findMin.js +2 -2
- package/lib/utils/isObject.js +1 -1
- package/lib/utils/mapMap.d.ts +6 -0
- package/lib/utils/mapMap.d.ts.map +1 -0
- package/lib/utils/mapMap.js +2 -2
- package/lib/utils/normalizeLanguage.d.ts +2 -0
- package/lib/utils/normalizeLanguage.d.ts.map +1 -0
- package/lib/utils/normalizeLanguage.js +1 -1
- package/lib/utils/randomId.d.ts +2 -0
- package/lib/utils/randomId.d.ts.map +1 -0
- package/lib/utils/randomId.js +1 -1
- package/lib/utils/warnOnce.js +17 -0
- package/package.json +32 -31
- package/scripts/createPrecompiledGlobalize.mjs +44 -0
- package/src/StyleOptions.ts +39 -3
- package/src/defaultStyleOptions.ts +4 -2
- package/src/hooks/Composer.tsx +141 -99
- package/src/hooks/{index.js → index.ts} +2 -0
- package/src/hooks/internal/WebChatAPIContext.ts +68 -3
- package/src/hooks/internal/{useCreateActivityRendererInternal.js → useCreateActivityRendererInternal.ts} +6 -2
- package/src/hooks/middleware/applyMiddleware.js +2 -3
- package/src/hooks/middleware/concatMiddleware.spec.js +4 -6
- package/src/hooks/middleware/{concatMiddleware.js → concatMiddleware.ts} +7 -1
- package/src/hooks/middleware/{createDefaultCardActionMiddleware.js → createDefaultCardActionMiddleware.ts} +8 -4
- package/src/hooks/middleware/{createDefaultGroupActivitiesMiddleware.js → createDefaultGroupActivitiesMiddleware.ts} +20 -12
- package/src/hooks/{useActiveTyping.js → useActiveTyping.ts} +13 -9
- package/src/hooks/useActivities.ts +7 -0
- package/src/hooks/{useAvatarForBot.js → useAvatarForBot.ts} +1 -1
- package/src/hooks/{useAvatarForUser.js → useAvatarForUser.ts} +1 -1
- package/src/hooks/{useByteFormatter.js → useByteFormatter.ts} +1 -1
- package/src/hooks/{useConnectivityStatus.js → useConnectivityStatus.ts} +1 -1
- package/src/hooks/{useCreateActivityRenderer.js → useCreateActivityRenderer.ts} +2 -3
- package/src/hooks/{useCreateActivityStatusRenderer.js → useCreateActivityStatusRenderer.tsx} +24 -5
- package/src/hooks/{useCreateAvatarRenderer.js → useCreateAvatarRenderer.ts} +6 -3
- package/src/hooks/useCreateScrollToEndButtonRenderer.ts +6 -0
- package/src/hooks/{useDateFormatter.js → useDateFormatter.ts} +1 -1
- package/src/hooks/useDebouncedNotifications.spec.js +2 -0
- package/src/hooks/{useDebouncedNotifications.js → useDebouncedNotifications.ts} +10 -2
- package/src/hooks/{useDictateInterims.js → useDictateInterims.ts} +1 -1
- package/src/hooks/{useDictateState.js → useDictateState.ts} +1 -1
- package/src/hooks/{useDirection.js → useDirection.ts} +1 -1
- package/src/hooks/{useDisabled.js → useDisabled.ts} +1 -1
- package/src/hooks/{useDismissNotification.js → useDismissNotification.ts} +1 -1
- package/src/hooks/{useEmitTypingIndicator.js → useEmitTypingIndicator.ts} +1 -1
- package/src/hooks/{useGetSendTimeoutForActivity.js → useGetSendTimeoutForActivity.ts} +2 -1
- package/src/hooks/{useGrammars.js → useGrammars.ts} +1 -1
- package/src/hooks/useGroupActivities.ts +14 -0
- package/src/hooks/{useGroupTimestamp.js → useGroupTimestamp.ts} +1 -1
- package/src/hooks/{useLanguage.js → useLanguage.ts} +1 -1
- package/src/hooks/{useLastTypingAt.js → useLastTypingAt.ts} +2 -1
- package/src/hooks/{useLocalize.js → useLocalize.ts} +3 -1
- package/src/hooks/{useLocalizeDate.js → useLocalizeDate.ts} +2 -1
- package/src/hooks/{useLocalizer.js → useLocalizer.ts} +19 -6
- package/src/hooks/{useMarkActivityAsSpoken.js → useMarkActivityAsSpoken.ts} +2 -1
- package/src/hooks/{useNotifications.js → useNotifications.ts} +2 -1
- package/src/hooks/usePerformCardAction.ts +7 -0
- package/src/hooks/usePostActivity.ts +8 -0
- package/src/hooks/{useReferenceGrammarID.js → useReferenceGrammarID.ts} +1 -1
- package/src/hooks/{useRelativeTimeFormatter.js → useRelativeTimeFormatter.ts} +1 -1
- package/src/hooks/useRenderActivity.js +12 -10
- package/src/hooks/useRenderActivityStatus.js +1 -0
- package/src/hooks/useRenderAvatar.js +1 -0
- package/src/hooks/{useRenderToast.js → useRenderToast.ts} +2 -1
- package/src/hooks/useRenderTypingIndicator.ts +6 -0
- package/src/hooks/{useSendBoxValue.js → useSendBoxValue.ts} +1 -1
- package/src/hooks/{useSendEvent.js → useSendEvent.ts} +1 -1
- package/src/hooks/{useSendFiles.js → useSendFiles.ts} +1 -1
- package/src/hooks/useSendMessage.ts +9 -0
- package/src/hooks/{useSendMessageBack.js → useSendMessageBack.ts} +1 -1
- package/src/hooks/{useSendPostBack.js → useSendPostBack.ts} +1 -1
- package/src/hooks/{useSendTimeoutForActivity.js → useSendTimeoutForActivity.ts} +4 -1
- package/src/hooks/{useSendTypingIndicator.js → useSendTypingIndicator.ts} +1 -1
- package/src/hooks/useSetNotification.ts +6 -0
- package/src/hooks/{useShouldSpeakIncomingActivity.js → useShouldSpeakIncomingActivity.ts} +1 -1
- package/src/hooks/{useStartDictate.js → useStartDictate.ts} +1 -1
- package/src/hooks/{useStopDictate.js → useStopDictate.ts} +1 -1
- package/src/hooks/useStyleOptions.ts +6 -0
- package/src/hooks/{useSubmitSendBox.js → useSubmitSendBox.ts} +1 -1
- package/src/hooks/{useSuggestedActions.js → useSuggestedActions.ts} +5 -1
- package/src/hooks/useTimeoutForSend.ts +9 -0
- package/src/hooks/{useTrackDimension.js → useTrackDimension.ts} +1 -1
- package/src/hooks/{useTrackEvent.js → useTrackEvent.ts} +10 -2
- package/src/hooks/{useTrackException.js → useTrackException.ts} +1 -1
- package/src/hooks/{useTrackTiming.js → useTrackTiming.ts} +4 -1
- package/src/hooks/{useUserID.js → useUserID.ts} +1 -1
- package/src/hooks/{useUsername.js → useUsername.ts} +1 -1
- package/src/hooks/{useVoiceSelector.js → useVoiceSelector.ts} +4 -1
- package/src/hooks/utils/{observableToPromise.js → observableToPromise.ts} +5 -3
- package/src/index.ts +51 -0
- package/src/localization/Localize.spec.js +2 -0
- package/src/localization/{Localize.js → Localize.ts} +6 -6
- package/src/localization/ar-SA.json +1 -0
- package/src/localization/bg-BG.json +1 -0
- package/src/localization/ca-ES.json +1 -0
- package/src/localization/cs-CZ.json +1 -0
- package/src/localization/da-DK.json +1 -0
- package/src/localization/de-DE.json +1 -0
- package/src/localization/el-GR.json +1 -0
- package/src/localization/en-US.json +1 -0
- package/src/localization/es-ES.json +1 -0
- package/src/localization/et-EE.json +1 -0
- package/src/localization/eu-ES.json +1 -0
- package/src/localization/fi-FI.json +1 -0
- package/src/localization/fr-FR.json +1 -0
- package/src/localization/getAllLocalizedStrings.spec.js +3 -1
- package/src/localization/{getAllLocalizedStrings.js → getAllLocalizedStrings.ts} +2 -1
- package/src/localization/getLocaleString.spec.js +4 -2
- package/src/localization/{getLocaleString.js → getLocaleString.ts} +2 -2
- package/src/localization/{getRTLList.js → getRTLList.ts} +1 -1
- package/src/localization/gl-ES.json +1 -0
- package/src/localization/he-IL.json +1 -0
- package/src/localization/hi-IN.json +1 -0
- package/src/localization/hr-HR.json +1 -0
- package/src/localization/hu-HU.json +1 -0
- package/src/localization/id-ID.json +1 -0
- package/src/localization/it-IT.json +1 -0
- package/src/localization/ja-JP.json +1 -0
- package/src/localization/kk-KZ.json +1 -0
- package/src/localization/ko-KR.json +1 -0
- package/src/localization/lt-LT.json +1 -0
- package/src/localization/lv-LV.json +1 -0
- package/src/localization/{mergeLocalizedStrings.js → mergeLocalizedStrings.ts} +5 -1
- package/src/localization/ms-MY.json +1 -0
- package/src/localization/nb-NO.json +1 -0
- package/src/localization/nl-NL.json +1 -0
- package/src/localization/pl-PL.json +1 -0
- package/src/localization/pt-BR.json +1 -0
- package/src/localization/pt-PT.json +1 -0
- package/src/localization/ro-RO.json +1 -0
- package/src/localization/ru-RU.json +1 -0
- package/src/localization/sk-SK.json +1 -0
- package/src/localization/sl-SI.json +1 -0
- package/src/localization/sr-Cyrl-CS.json +1 -0
- package/src/localization/sr-Latn-CS.json +1 -0
- package/src/localization/sv-SE.json +1 -0
- package/src/localization/th-TH.json +1 -0
- package/src/localization/tr-TR.json +1 -0
- package/src/localization/uk-UA.json +1 -0
- package/src/localization/vi-VN.json +1 -0
- package/src/localization/yue.json +1 -0
- package/src/localization/zh-CN.json +1 -0
- package/src/localization/zh-HK.json +1 -0
- package/src/localization/zh-TW.json +1 -0
- package/src/normalizeStyleOptions.ts +43 -2
- package/src/tsconfig.json +3 -1
- package/src/types/ActivityMiddleware.ts +38 -0
- package/src/types/ActivityStatusMiddleware.ts +28 -0
- package/src/types/AttachmentForScreenReaderMiddleware.ts +24 -0
- package/src/types/AttachmentMiddleware.ts +16 -0
- package/src/types/AvatarMiddleware.ts +20 -0
- package/src/types/CardActionMiddleware.ts +21 -0
- package/src/types/ComponentMiddleware.ts +42 -0
- package/src/types/FunctionMiddleware.ts +13 -0
- package/src/types/GroupActivitiesMiddleware.ts +24 -0
- package/src/types/LocalizedStrings.ts +5 -0
- package/src/types/Notification.ts +10 -0
- package/src/types/PrecompiledGlobalize.ts +9 -0
- package/src/types/ScrollToEndButtonMiddleware.ts +34 -0
- package/src/types/SendState.ts +3 -0
- package/src/types/TelemetryMeasurementEvent.ts +44 -0
- package/src/types/ToastMiddleware.ts +16 -0
- package/src/types/Typing.ts +8 -0
- package/src/types/TypingIndicatorMiddleware.ts +18 -0
- package/src/types/WebSpeechPonyfill.ts +24 -0
- package/src/types/WebSpeechPonyfillFactory.ts +5 -0
- package/src/utils/{createCustomEvent.js → createCustomEvent.ts} +8 -3
- package/src/utils/findMin.spec.js +2 -0
- package/src/utils/{findMin.js → findMin.ts} +3 -3
- package/src/utils/mapMap.spec.js +2 -0
- package/src/utils/{mapMap.js → mapMap.ts} +4 -1
- package/src/utils/{normalizeLanguage.js → normalizeLanguage.ts} +1 -1
- package/src/utils/{randomId.js → randomId.ts} +1 -1
- package/src/utils/warnOnce.ts +10 -0
- package/lib/hooks/utils/singleToArray.js +0 -11
- package/scripts/createPrecompiledGlobalize.js +0 -41
- package/src/hooks/useActivities.js +0 -5
- package/src/hooks/useGroupActivities.js +0 -5
- package/src/hooks/usePerformCardAction.js +0 -5
- package/src/hooks/usePostActivity.js +0 -5
- package/src/hooks/useRenderTypingIndicator.js +0 -5
- package/src/hooks/useSendMessage.js +0 -5
- package/src/hooks/useSetNotification.js +0 -5
- package/src/hooks/useStyleOptions.js +0 -5
- package/src/hooks/useTimeoutForSend.js +0 -7
- package/src/hooks/utils/singleToArray.js +0 -3
- package/src/index.js +0 -10
- package/src/index.tsx +0 -10
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useSelector } from './internal/WebChatReduxContext';
|
|
4
|
+
import Typing from '../types/Typing';
|
|
4
5
|
import useForceRender from './internal/useForceRender';
|
|
5
6
|
import useStyleOptions from './useStyleOptions';
|
|
6
7
|
|
|
7
|
-
function useActiveTyping(expireAfter) {
|
|
8
|
+
function useActiveTyping(expireAfter?: number): [{ [userId: string]: Typing }] {
|
|
8
9
|
const now = Date.now();
|
|
9
10
|
|
|
10
11
|
const [{ typingAnimationDuration }] = useStyleOptions();
|
|
11
12
|
const forceRender = useForceRender();
|
|
12
|
-
const typing = useSelector(({ typing }) => typing);
|
|
13
|
+
const typing: { [userId: string]: { at: number; name: string; role: string } } = useSelector(({ typing }) => typing);
|
|
13
14
|
|
|
14
15
|
if (typeof expireAfter !== 'number') {
|
|
15
16
|
expireAfter = typingAnimationDuration;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
const activeTyping = Object.entries(typing).reduce(
|
|
19
|
-
|
|
19
|
+
const activeTyping: { [userId: string]: Typing } = Object.entries(typing).reduce(
|
|
20
|
+
(activeTyping, [id, { at, name, role }]) => {
|
|
21
|
+
const until = at + expireAfter;
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
if (until > now) {
|
|
24
|
+
return { ...activeTyping, [id]: { at, expireAt: until, name, role } };
|
|
25
|
+
}
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
return activeTyping;
|
|
28
|
+
},
|
|
29
|
+
{}
|
|
30
|
+
);
|
|
27
31
|
|
|
28
32
|
const earliestExpireAt = Math.min(...Object.values(activeTyping).map(({ expireAt }) => expireAt));
|
|
29
33
|
const timeToRender = earliestExpireAt && earliestExpireAt - now;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import useStyleOptions from './useStyleOptions';
|
|
2
2
|
|
|
3
|
-
export default function useAvatarForBot() {
|
|
3
|
+
export default function useAvatarForBot(): [{ image: string; initials: string }] {
|
|
4
4
|
const [{ botAvatarImage: image, botAvatarInitials: initials }] = useStyleOptions();
|
|
5
5
|
|
|
6
6
|
return [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import useStyleOptions from './useStyleOptions';
|
|
2
2
|
|
|
3
|
-
export default function useAvatarForUser() {
|
|
3
|
+
export default function useAvatarForUser(): [{ image: string; initials: string }] {
|
|
4
4
|
const [{ userAvatarImage: image, userAvatarInitials: initials }] = useStyleOptions();
|
|
5
5
|
|
|
6
6
|
return [
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ActivityComponentFactory } from '../types/ActivityMiddleware';
|
|
3
2
|
import useCreateActivityRendererInternal from './internal/useCreateActivityRendererInternal';
|
|
4
3
|
|
|
5
4
|
// The newer useCreateActivityRenderer() hook does not support override renderAttachment().
|
|
6
5
|
// Only the deprecated useRenderActivity() hook support overriding renderAttachment().
|
|
7
|
-
export default function useCreateActivityRenderer() {
|
|
6
|
+
export default function useCreateActivityRenderer(): ActivityComponentFactory {
|
|
8
7
|
return useCreateActivityRendererInternal();
|
|
9
8
|
}
|
package/src/hooks/{useCreateActivityStatusRenderer.js → useCreateActivityStatusRenderer.tsx}
RENAMED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
/* eslint react/prop-types: "off"*/
|
|
1
|
+
/* eslint react/prop-types: "off" */
|
|
2
|
+
/* eslint react/require-default-props: "off" */
|
|
2
3
|
|
|
3
|
-
import { Constants } from 'botframework-webchat-core';
|
|
4
|
-
import React, { useMemo } from 'react';
|
|
4
|
+
import { Constants, DirectLineActivity } from 'botframework-webchat-core';
|
|
5
|
+
import React, { ReactNode, useMemo } from 'react';
|
|
5
6
|
|
|
7
|
+
import SendState from '../types/SendState';
|
|
6
8
|
import useGetSendTimeoutForActivity from './useGetSendTimeoutForActivity';
|
|
7
9
|
import useTimePassed from './internal/useTimePassed';
|
|
8
10
|
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
@@ -20,6 +22,14 @@ const ActivityStatusContainer = ({ activity, hideTimestamp, nextVisibleActivity
|
|
|
20
22
|
const {
|
|
21
23
|
channelData: { clientTimestamp = 0, state } = {},
|
|
22
24
|
from: { role }
|
|
25
|
+
}: {
|
|
26
|
+
channelData: {
|
|
27
|
+
clientTimestamp?: number;
|
|
28
|
+
state?: SendState;
|
|
29
|
+
};
|
|
30
|
+
from: {
|
|
31
|
+
role: string;
|
|
32
|
+
};
|
|
23
33
|
} = activity;
|
|
24
34
|
|
|
25
35
|
const activitySent = state !== SENDING && state !== SEND_FAILED;
|
|
@@ -43,9 +53,18 @@ const ActivityStatusContainer = ({ activity, hideTimestamp, nextVisibleActivity
|
|
|
43
53
|
);
|
|
44
54
|
};
|
|
45
55
|
|
|
46
|
-
export default function useCreateActivityStatusRenderer() {
|
|
56
|
+
export default function useCreateActivityStatusRenderer(): (renderOptions: {
|
|
57
|
+
activity: DirectLineActivity;
|
|
58
|
+
nextVisibleActivity: DirectLineActivity;
|
|
59
|
+
}) => (props: { hideTimestamp?: boolean }) => ReactNode {
|
|
47
60
|
return useMemo(
|
|
48
|
-
() => ({
|
|
61
|
+
() => ({
|
|
62
|
+
activity,
|
|
63
|
+
nextVisibleActivity
|
|
64
|
+
}: {
|
|
65
|
+
activity: DirectLineActivity;
|
|
66
|
+
nextVisibleActivity: DirectLineActivity;
|
|
67
|
+
}) => ({ hideTimestamp }: { hideTimestamp?: boolean } = {}) => (
|
|
49
68
|
<ActivityStatusContainer
|
|
50
69
|
activity={activity}
|
|
51
70
|
hideTimestamp={hideTimestamp}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DirectLineActivity } from 'botframework-webchat-core';
|
|
2
|
+
import { ReactNode, useMemo } from 'react';
|
|
2
3
|
|
|
3
4
|
import useStyleOptions from './useStyleOptions';
|
|
4
5
|
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
5
6
|
|
|
6
|
-
export default function useCreateAvatarRenderer()
|
|
7
|
+
export default function useCreateAvatarRenderer(): (
|
|
8
|
+
activity: DirectLineActivity
|
|
9
|
+
) => (() => Exclude<ReactNode, boolean | null | undefined>) | false {
|
|
7
10
|
const [styleOptions] = useStyleOptions();
|
|
8
11
|
const { avatarRenderer } = useWebChatAPIContext();
|
|
9
12
|
|
|
10
13
|
return useMemo(
|
|
11
14
|
() => ({ activity }) => {
|
|
12
|
-
const { from: { role } = {} } = activity;
|
|
15
|
+
const { from: { role } = {} }: { from?: { role?: string } } = activity;
|
|
13
16
|
|
|
14
17
|
const result = avatarRenderer({
|
|
15
18
|
activity,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ScrollToEndButtonComponentFactory } from '../types/ScrollToEndButtonMiddleware';
|
|
2
|
+
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
3
|
+
|
|
4
|
+
export default function useCreateScrollToEndButtonRenderer(): ScrollToEndButtonComponentFactory {
|
|
5
|
+
return useWebChatAPIContext().scrollToEndButtonRenderer;
|
|
6
|
+
}
|
|
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import useLocalizedGlobalize from './internal/useLocalizedGlobalize';
|
|
4
4
|
|
|
5
|
-
export default function useDateFormatter() {
|
|
5
|
+
export default function useDateFormatter(): (date: number | Date) => string {
|
|
6
6
|
const [globalize] = useLocalizedGlobalize();
|
|
7
7
|
|
|
8
8
|
const formatDate = useMemo(() => date => globalize.dateFormatter({ skeleton: 'MMMMdhm' })(new Date(date)), [
|
|
@@ -2,12 +2,20 @@ import { useRef } from 'react';
|
|
|
2
2
|
import updateIn from 'simple-update-in';
|
|
3
3
|
|
|
4
4
|
import findMin from '../utils/findMin';
|
|
5
|
+
import Notification from '../types/Notification';
|
|
5
6
|
import useForceRender from './internal/useForceRender';
|
|
6
7
|
import useNotifications from './useNotifications';
|
|
7
8
|
import useStyleOptions from './useStyleOptions';
|
|
8
9
|
import useTimer from './internal/useTimer';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
type DebouncedNotification = Notification & {
|
|
12
|
+
outOfDate: boolean;
|
|
13
|
+
updateNotBefore: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type DebouncedNotifications = { [id: string]: DebouncedNotification };
|
|
17
|
+
|
|
18
|
+
function getEarliestUpdateNotBefore(notificationMap: DebouncedNotifications) {
|
|
11
19
|
return findMin(
|
|
12
20
|
Object.values(notificationMap)
|
|
13
21
|
.filter(({ outOfDate }) => outOfDate)
|
|
@@ -15,7 +23,7 @@ function getEarliestUpdateNotBefore(notificationMap) {
|
|
|
15
23
|
);
|
|
16
24
|
}
|
|
17
25
|
|
|
18
|
-
function useDebouncedNotifications() {
|
|
26
|
+
function useDebouncedNotifications(): [DebouncedNotifications] {
|
|
19
27
|
const now = Date.now();
|
|
20
28
|
|
|
21
29
|
const [{ notificationDebounceTimeout }] = useStyleOptions();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useSelector } from './internal/WebChatReduxContext';
|
|
2
2
|
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
3
3
|
|
|
4
|
-
export default function useDictateInterims() {
|
|
4
|
+
export default function useDictateInterims(): [string[], (interims: string[]) => void] {
|
|
5
5
|
return [useSelector(({ dictateInterims }) => dictateInterims) || [], useWebChatAPIContext().setDictateInterims];
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useSelector } from './internal/WebChatReduxContext';
|
|
2
2
|
|
|
3
3
|
// TODO: [P3] We should update this code to use core/src/selectors/dictateState.js
|
|
4
|
-
export default function useDictateState() {
|
|
4
|
+
export default function useDictateState(): [number] {
|
|
5
5
|
return [useSelector(({ dictateState }) => dictateState)];
|
|
6
6
|
}
|
|
@@ -14,7 +14,7 @@ function determineDirection(dir, language) {
|
|
|
14
14
|
return 'ltr';
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export default function useDirection() {
|
|
17
|
+
export default function useDirection(): ['auto' | 'ltr' | 'rtl'] {
|
|
18
18
|
const [dir] = useDirFromProps();
|
|
19
19
|
const [language] = useLanguage();
|
|
20
20
|
const determinedDirection = useMemo(() => determineDirection(dir, language), [dir, language]);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { DirectLineActivity } from 'botframework-webchat-core';
|
|
1
2
|
import { useMemo } from 'react';
|
|
2
3
|
|
|
3
4
|
import useStyleOptions from './useStyleOptions';
|
|
4
5
|
|
|
5
|
-
export default function useGetSendTimeoutForActivity() {
|
|
6
|
+
export default function useGetSendTimeoutForActivity(): ({ activity }: { activity: DirectLineActivity }) => number {
|
|
6
7
|
const [{ sendTimeout, sendTimeoutForAttachments }] = useStyleOptions();
|
|
7
8
|
|
|
8
9
|
return useMemo(
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DirectLineActivity } from 'botframework-webchat-core';
|
|
2
|
+
|
|
3
|
+
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
4
|
+
|
|
5
|
+
export default function useGroupActivities(): ({
|
|
6
|
+
activities
|
|
7
|
+
}: {
|
|
8
|
+
activities: DirectLineActivity[];
|
|
9
|
+
}) => {
|
|
10
|
+
sender: DirectLineActivity[][];
|
|
11
|
+
status: DirectLineActivity[][];
|
|
12
|
+
} {
|
|
13
|
+
return useWebChatAPIContext().groupActivities;
|
|
14
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import useLocalizedStrings from './internal/useLocalizedStrings';
|
|
2
2
|
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
3
3
|
|
|
4
|
-
export default function useLanguage(options) {
|
|
4
|
+
export default function useLanguage(options?: 'speech'): [string] {
|
|
5
5
|
const { language } = useWebChatAPIContext();
|
|
6
6
|
const localizedStrings = useLocalizedStrings();
|
|
7
7
|
|
|
@@ -2,7 +2,8 @@ import { useSelector } from './internal/WebChatReduxContext';
|
|
|
2
2
|
|
|
3
3
|
let showDeprecationNotes = true;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/** @deprecated Please use "useActiveTyping" instead. */
|
|
6
|
+
export default function useLastTypingAt(): [{ [userId: string]: number }] {
|
|
6
7
|
if (showDeprecationNotes) {
|
|
7
8
|
console.warn(
|
|
8
9
|
'botframework-webchat: "useLastTypingAt" is deprecated. Please use "useActiveTyping" instead. This hook will be removed on or after 2022-02-16.'
|
|
@@ -2,7 +2,9 @@ import useLanguage from './useLanguage';
|
|
|
2
2
|
|
|
3
3
|
import { localize } from '../localization/Localize';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// TODO: Remove on or after 2022-02-12.
|
|
6
|
+
/** @deprecated Please use "useLocalizer" instead. */
|
|
7
|
+
export default function useLocalize(text: string, ...args: string[]): boolean | string {
|
|
6
8
|
const [language] = useLanguage();
|
|
7
9
|
|
|
8
10
|
// TODO: [P3] Use useMemo to cache the result.
|
|
@@ -4,7 +4,8 @@ import getLocaleString from '../localization/getLocaleString';
|
|
|
4
4
|
|
|
5
5
|
let deprecationNotesShown;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/** @deprecated Please use useDateFormatter() instead. */
|
|
8
|
+
export default function useLocalizeDate(date: Date | number | string): string {
|
|
8
9
|
if (!deprecationNotesShown) {
|
|
9
10
|
console.warn(
|
|
10
11
|
'botframework-webchat: useLocalizeDate() is deprecated. Please use the useDateFormatter() hooks instead. This hook will be removed on or after 2022-02-12.'
|
|
@@ -7,16 +7,29 @@ import isObject from '../utils/isObject';
|
|
|
7
7
|
|
|
8
8
|
const DEFAULT_STRINGS = getAllLocalizedStrings()['en-US'];
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
type Plural = {
|
|
11
|
+
zero?: string;
|
|
12
|
+
one?: string;
|
|
13
|
+
two?: string;
|
|
14
|
+
few?: string;
|
|
15
|
+
many?: string;
|
|
16
|
+
other: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default function useLocalizer({ plural }: { plural?: keyof Plural } = {}) {
|
|
11
20
|
const [globalize] = useLocalizedGlobalize();
|
|
12
21
|
const localizedStrings = useLocalizedStrings();
|
|
13
22
|
|
|
14
23
|
return useCallback(
|
|
15
|
-
(id, ...args) => {
|
|
24
|
+
(id: string | Plural, ...args: [(number | string)?, ...string[]]) => {
|
|
25
|
+
let stringId = id as string;
|
|
26
|
+
|
|
16
27
|
if (plural) {
|
|
17
|
-
|
|
28
|
+
const pluralId = id as Plural;
|
|
29
|
+
|
|
30
|
+
if (!isObject(pluralId)) {
|
|
18
31
|
throw new Error('useLocalizer: Plural string must pass "id" as a map instead of string.');
|
|
19
|
-
} else if (typeof
|
|
32
|
+
} else if (typeof pluralId.other !== 'string') {
|
|
20
33
|
throw new Error('useLocalizer: Plural string must have "id.other" of string.');
|
|
21
34
|
} else if (typeof args[0] !== 'number') {
|
|
22
35
|
throw new Error('useLocalizer: Plural string must have first argument as a number.');
|
|
@@ -42,14 +55,14 @@ export default function useLocalizer({ plural } = {}) {
|
|
|
42
55
|
);
|
|
43
56
|
}
|
|
44
57
|
|
|
45
|
-
|
|
58
|
+
stringId = pluralId[globalize.plural(args[0])] || pluralId.other;
|
|
46
59
|
} else if (typeof id !== 'string') {
|
|
47
60
|
throw new Error('useLocalizer: "id" must be a string.');
|
|
48
61
|
}
|
|
49
62
|
|
|
50
63
|
return Object.entries(args).reduce(
|
|
51
64
|
(str, [index, arg]) => str.replace(`$${+index + 1}`, arg),
|
|
52
|
-
localizedStrings[
|
|
65
|
+
localizedStrings[stringId] || DEFAULT_STRINGS[stringId] || ''
|
|
53
66
|
);
|
|
54
67
|
},
|
|
55
68
|
[globalize, localizedStrings, plural]
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { DirectLineActivity } from 'botframework-webchat-core';
|
|
1
2
|
import { useCallback } from 'react';
|
|
2
3
|
|
|
3
4
|
import useMarkActivity from './internal/useMarkActivity';
|
|
4
5
|
|
|
5
|
-
export default function useMarkActivityAsSpoken() {
|
|
6
|
+
export default function useMarkActivityAsSpoken(): (activity: DirectLineActivity) => void {
|
|
6
7
|
const markActivity = useMarkActivity();
|
|
7
8
|
|
|
8
9
|
return useCallback(activity => markActivity(activity, 'speak', false), [markActivity]);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useSelector } from './internal/WebChatReduxContext';
|
|
2
|
+
import Notification from '../types/Notification';
|
|
2
3
|
|
|
3
|
-
export default function useNotifications() {
|
|
4
|
+
export default function useNotifications(): [Notification[]] {
|
|
4
5
|
return [useSelector(({ notifications }) => notifications)];
|
|
5
6
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DirectLineCardAction } from 'botframework-webchat-core';
|
|
2
|
+
|
|
3
|
+
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
4
|
+
|
|
5
|
+
export default function usePerformCardAction(): (cardAction: DirectLineCardAction) => void {
|
|
6
|
+
return useWebChatAPIContext().onCardAction;
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DirectLineActivity } from 'botframework-webchat-core';
|
|
2
|
+
import Observable from 'core-js/features/observable';
|
|
3
|
+
|
|
4
|
+
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
5
|
+
|
|
6
|
+
export default function usePostActivity(): (activity: DirectLineActivity) => Observable<string> {
|
|
7
|
+
return useWebChatAPIContext().postActivity;
|
|
8
|
+
}
|
|
@@ -6,7 +6,7 @@ import useDateFormatter from './useDateFormatter';
|
|
|
6
6
|
import useLocalizedGlobalize from './internal/useLocalizedGlobalize';
|
|
7
7
|
import useLocalizer from './useLocalizer';
|
|
8
8
|
|
|
9
|
-
export default function useRelativeTimeFormatter() {
|
|
9
|
+
export default function useRelativeTimeFormatter(): (dateOrString: Date | string) => string {
|
|
10
10
|
const formatDate = useDateFormatter();
|
|
11
11
|
const localize = useLocalizer();
|
|
12
12
|
const [globalize] = useLocalizedGlobalize();
|
|
@@ -17,6 +17,7 @@ import useCreateActivityRendererInternal from './internal/useCreateActivityRende
|
|
|
17
17
|
|
|
18
18
|
let showDeprecationNotes = true;
|
|
19
19
|
|
|
20
|
+
/** @deprecated Please use `useCreateActivityRenderer()` instead. */
|
|
20
21
|
export default function useRenderActivity(renderAttachment) {
|
|
21
22
|
if (showDeprecationNotes) {
|
|
22
23
|
console.warn(
|
|
@@ -33,19 +34,20 @@ export default function useRenderActivity(renderAttachment) {
|
|
|
33
34
|
const createActivityRenderer = useCreateActivityRendererInternal(renderAttachment);
|
|
34
35
|
|
|
35
36
|
return useMemo(
|
|
36
|
-
() =>
|
|
37
|
-
|
|
37
|
+
() =>
|
|
38
|
+
(renderActivityArg, renderOptions = {}) => {
|
|
39
|
+
const { activity } = renderActivityArg || {};
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
if (!activity) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
'botframework-webchat: First argument passed to the callback of useRenderActivity() must contain an "activity" property.'
|
|
44
|
+
);
|
|
45
|
+
}
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
const renderActivity = createActivityRenderer(renderActivityArg);
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
return !!renderActivity && renderActivity(renderOptions);
|
|
50
|
+
},
|
|
49
51
|
[createActivityRenderer]
|
|
50
52
|
);
|
|
51
53
|
}
|
|
@@ -16,6 +16,7 @@ import useCreateActivityStatusRenderer from './useCreateActivityStatusRenderer';
|
|
|
16
16
|
|
|
17
17
|
let showDeprecationNotes = true;
|
|
18
18
|
|
|
19
|
+
/** @deprecated Please use `useCreateActivityStatusRenderer()` instead. */
|
|
19
20
|
export default function useRenderActivityStatus({ activity, nextVisibleActivity }) {
|
|
20
21
|
if (showDeprecationNotes) {
|
|
21
22
|
console.warn(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { RenderToast } from '../types/ToastMiddleware';
|
|
1
2
|
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
2
3
|
|
|
3
|
-
export default function useRenderToast() {
|
|
4
|
+
export default function useRenderToast(): RenderToast {
|
|
4
5
|
return useWebChatAPIContext().toastRenderer;
|
|
5
6
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RenderTypingIndicator } from '../types/TypingIndicatorMiddleware';
|
|
2
|
+
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
3
|
+
|
|
4
|
+
export default function useRenderTypingIndicator(): RenderTypingIndicator {
|
|
5
|
+
return useWebChatAPIContext().typingIndicatorRenderer;
|
|
6
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useSelector } from './internal/WebChatReduxContext';
|
|
2
2
|
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
3
3
|
|
|
4
|
-
export default function useSendBoxValue() {
|
|
4
|
+
export default function useSendBoxValue(): [string, (value: string) => void] {
|
|
5
5
|
return [useSelector(({ sendBoxValue }) => sendBoxValue), useWebChatAPIContext().setSendBox];
|
|
6
6
|
}
|
|
@@ -5,7 +5,7 @@ import { useCallback } from 'react';
|
|
|
5
5
|
import useTrackEvent from './useTrackEvent';
|
|
6
6
|
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
7
7
|
|
|
8
|
-
export default function useSendFiles() {
|
|
8
|
+
export default function useSendFiles(): (files: File[]) => void {
|
|
9
9
|
const { sendFiles } = useWebChatAPIContext();
|
|
10
10
|
const trackEvent = useTrackEvent();
|
|
11
11
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import useWebChatAPIContext from './internal/useWebChatAPIContext';
|
|
2
2
|
|
|
3
|
-
export default function useSendMessageBack() {
|
|
3
|
+
export default function useSendMessageBack(): (value: any, text?: string, displayText?: string) => void {
|
|
4
4
|
return useWebChatAPIContext().sendMessageBack;
|
|
5
5
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { DirectLineActivity } from 'botframework-webchat-core';
|
|
2
|
+
|
|
1
3
|
import useGetSendTimeoutForActivity from './useGetSendTimeoutForActivity';
|
|
2
4
|
|
|
3
5
|
let showDeprecationNotes = true;
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
/** @deprecated Please use "useGetSendTimeoutForActivity()" instead. */
|
|
8
|
+
export default function useSendTimeoutForActivity(activity: DirectLineActivity) {
|
|
6
9
|
if (showDeprecationNotes) {
|
|
7
10
|
console.warn(
|
|
8
11
|
'botframework-webchat: "useSendTimeoutForActivity" is deprecated and will be removed on or after 2022-07-28. Please use "useGetSendTimeoutForActivity()" instead.'
|