|
| 1 | +import createEmotion from '@emotion/css/create-instance'; |
1 | 2 | import { Composer as APIComposer, hooks, WebSpeechPonyfillFactory } from 'botframework-webchat-api'; |
2 | | -import { Composer as SayComposer } from 'react-say'; |
3 | 3 | import { singleToArray } from 'botframework-webchat-core'; |
4 | 4 | import classNames from 'classnames'; |
5 | | -import createEmotion from '@emotion/css/create-instance'; |
6 | | -import createStyleSet from './Styles/createStyleSet'; |
7 | 5 | import MarkdownIt from 'markdown-it'; |
8 | 6 | import PropTypes from 'prop-types'; |
9 | 7 | import React, { memo, useCallback, useMemo, useRef, useState } from 'react'; |
| 8 | +import { Composer as SayComposer } from 'react-say'; |
| 9 | +import createStyleSet from './Styles/createStyleSet'; |
10 | 10 |
|
| 11 | +import createDefaultAttachmentMiddleware from './Attachment/createMiddleware'; |
| 12 | +import Dictation from './Dictation'; |
| 13 | +import ErrorBox from './ErrorBox'; |
11 | 14 | import { |
12 | 15 | speechSynthesis as bypassSpeechSynthesis, |
13 | 16 | SpeechSynthesisUtterance as BypassSpeechSynthesisUtterance |
14 | 17 | } from './hooks/internal/BypassSpeechSynthesisPonyfill'; |
15 | | -import ActivityTreeComposer from './providers/ActivityTree/ActivityTreeComposer'; |
16 | | -import addTargetBlankToHyperlinksMarkdown from './Utils/addTargetBlankToHyperlinksMarkdown'; |
17 | | -import createCSSKey from './Utils/createCSSKey'; |
| 18 | +import UITracker from './hooks/internal/UITracker'; |
| 19 | +import WebChatUIContext from './hooks/internal/WebChatUIContext'; |
| 20 | +import useStyleSet from './hooks/useStyleSet'; |
18 | 21 | import createDefaultActivityMiddleware from './Middleware/Activity/createCoreMiddleware'; |
19 | 22 | import createDefaultActivityStatusMiddleware from './Middleware/ActivityStatus/createCoreMiddleware'; |
20 | 23 | import createDefaultAttachmentForScreenReaderMiddleware from './Middleware/AttachmentForScreenReader/createCoreMiddleware'; |
21 | | -import createDefaultAttachmentMiddleware from './Attachment/createMiddleware'; |
22 | 24 | import createDefaultAvatarMiddleware from './Middleware/Avatar/createCoreMiddleware'; |
23 | 25 | import createDefaultCardActionMiddleware from './Middleware/CardAction/createCoreMiddleware'; |
24 | 26 | import createDefaultScrollToEndButtonMiddleware from './Middleware/ScrollToEndButton/createScrollToEndButtonMiddleware'; |
25 | 27 | import createDefaultToastMiddleware from './Middleware/Toast/createCoreMiddleware'; |
26 | 28 | import createDefaultTypingIndicatorMiddleware from './Middleware/TypingIndicator/createCoreMiddleware'; |
27 | | -import Dictation from './Dictation'; |
| 29 | +import ActivityTreeComposer from './providers/ActivityTree/ActivityTreeComposer'; |
| 30 | +import SendBoxComposer from './providers/internal/SendBox/SendBoxComposer'; |
| 31 | +import ModalDialogComposer from './providers/ModalDialog/ModalDialogComposer'; |
| 32 | +import addTargetBlankToHyperlinksMarkdown from './Utils/addTargetBlankToHyperlinksMarkdown'; |
| 33 | +import createCSSKey from './Utils/createCSSKey'; |
28 | 34 | import downscaleImageToDataURL from './Utils/downscaleImageToDataURL'; |
29 | | -import ErrorBox from './ErrorBox'; |
30 | 35 | import mapMap from './Utils/mapMap'; |
31 | | -import ModalDialogComposer from './providers/ModalDialog/ModalDialogComposer'; |
32 | | -import SendBoxComposer from './providers/internal/SendBox/SendBoxComposer'; |
33 | | -import UITracker from './hooks/internal/UITracker'; |
34 | | -import useStyleSet from './hooks/useStyleSet'; |
35 | | -import WebChatUIContext from './hooks/internal/WebChatUIContext'; |
36 | 36 |
|
37 | 37 | import type { ComposerProps as APIComposerProps } from 'botframework-webchat-api'; |
38 | 38 | import type { FC, ReactNode } from 'react'; |
| 39 | +import type { ContextOf } from './types/ContextOf'; |
| 40 | +import { type FocusSendBoxInit } from './types/internal/FocusSendBoxInit'; |
| 41 | +import { type FocusTranscriptInit } from './types/internal/FocusTranscriptInit'; |
39 | 42 |
|
40 | 43 | const { useGetActivityByKey, useReferenceGrammarID, useStyleOptions } = hooks; |
41 | 44 |
|
@@ -97,8 +100,8 @@ const ComposerCore: FC<ComposerCoreProps> = ({ |
97 | 100 | const [dictateAbortable, setDictateAbortable] = useState(); |
98 | 101 | const [referenceGrammarID] = useReferenceGrammarID(); |
99 | 102 | const [styleOptions] = useStyleOptions(); |
100 | | - const focusSendBoxCallbacksRef = useRef([]); |
101 | | - const focusTranscriptCallbacksRef = useRef([]); |
| 103 | + const focusSendBoxCallbacksRef = useRef<((init: FocusSendBoxInit) => Promise<void>)[]>([]); |
| 104 | + const focusTranscriptCallbacksRef = useRef<((init: FocusTranscriptInit) => Promise<void>)[]>([]); |
102 | 105 | const internalMarkdownIt = useMemo(() => new MarkdownIt(), []); |
103 | 106 | const scrollToCallbacksRef = useRef([]); |
104 | 107 | const scrollToEndCallbacksRef = useRef([]); |
@@ -202,7 +205,7 @@ const ComposerCore: FC<ComposerCoreProps> = ({ |
202 | 205 | [transcriptFocusObserversRef, setNumTranscriptFocusObservers] |
203 | 206 | ); |
204 | 207 |
|
205 | | - const context = useMemo( |
| 208 | + const context = useMemo<ContextOf<typeof WebChatUIContext>>( |
206 | 209 | () => ({ |
207 | 210 | dictateAbortable, |
208 | 211 | dispatchScrollPosition, |
|
0 commit comments