diff --git a/.eslintrc.json b/.eslintrc.json index f49171291..1cb82549f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -223,7 +223,34 @@ "asc", { "caseSensitive": false, "natural": true } ], - "valid-typeof": 2 + "valid-typeof": 2, + "@typescript-eslint/no-restricted-imports": [ + "error", + { + "paths": [ + { + "name": "../../context", + "message": "Importing from top-level barrel files is not allowed. Import from specific files instead.", + "allowTypeImports": true + }, + { + "name": "../../../context", + "message": "Importing from top-level barrel files is not allowed. Import from specific files instead.", + "allowTypeImports": true + }, + { + "name": "../../components", + "message": "Importing from top-level barrel files is not allowed. Import from specific files instead.", + "allowTypeImports": true + }, + { + "name": "../../../components", + "message": "Importing from top-level barrel files is not allowed. Import from specific files instead.", + "allowTypeImports": true + } + ] + } + ] } } ] diff --git a/package.json b/package.json index 2ad4fbdc2..77210296d 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,18 @@ }, "default": "./dist/index.js" }, + "./dist/*": { + "types": "./dist/*", + "node": { + "require": "./dist/*", + "import": "./dist/*" + }, + "browser": { + "require": "./dist/*", + "import": "./dist/*" + }, + "default": "./dist/*" + }, "./emojis": { "types": "./dist/plugins/Emojis/index.d.ts", "node": { @@ -279,4 +291,4 @@ "not op_mini all" ], "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72" -} +} \ No newline at end of file diff --git a/src/components/Attachment/AttachmentActions.tsx b/src/components/Attachment/AttachmentActions.tsx index 72fef6982..16f866bb7 100644 --- a/src/components/Attachment/AttachmentActions.tsx +++ b/src/components/Attachment/AttachmentActions.tsx @@ -1,7 +1,7 @@ import React from 'react'; import type { Action, Attachment } from 'stream-chat'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; import type { ActionHandlerReturnType } from '../Message/hooks/useActionHandler'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/Attachment/Audio.tsx b/src/components/Attachment/Audio.tsx index baff2d7ef..139b52a7a 100644 --- a/src/components/Attachment/Audio.tsx +++ b/src/components/Attachment/Audio.tsx @@ -2,7 +2,10 @@ import React from 'react'; import type { Attachment } from 'stream-chat'; -import { DownloadButton, FileSizeIndicator, PlayButton, ProgressBar } from './components'; +import { DownloadButton } from './components/DownloadButton'; +import { FileSizeIndicator } from './components/FileSizeIndicator'; +import { PlayButton } from './components/PlayButton'; +import { ProgressBar } from './components/ProgressBar'; import { useAudioController } from './hooks/useAudioController'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/Attachment/Card.tsx b/src/components/Attachment/Card.tsx index 93d7e39aa..2882cbd73 100644 --- a/src/components/Attachment/Card.tsx +++ b/src/components/Attachment/Card.tsx @@ -5,7 +5,8 @@ import ReactPlayer from 'react-player'; import { AudioProps } from './Audio'; import { ImageComponent } from '../Gallery'; import { SafeAnchor } from '../SafeAnchor'; -import { PlayButton, ProgressBar } from './components'; +import { PlayButton } from './components/PlayButton'; +import { ProgressBar } from './components/ProgressBar'; import { useAudioController } from './hooks/useAudioController'; import { useChannelStateContext } from '../../context/ChannelStateContext'; import { useTranslationContext } from '../../context/TranslationContext'; diff --git a/src/components/Attachment/FileAttachment.tsx b/src/components/Attachment/FileAttachment.tsx index 0e66e74a7..689ee3031 100644 --- a/src/components/Attachment/FileAttachment.tsx +++ b/src/components/Attachment/FileAttachment.tsx @@ -2,7 +2,8 @@ import React from 'react'; import { FileIcon } from '../ReactFileUtilities'; import type { Attachment } from 'stream-chat'; -import { DownloadButton, FileSizeIndicator } from './components'; +import { DownloadButton } from './components/DownloadButton'; +import { FileSizeIndicator } from './components/FileSizeIndicator'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/Attachment/UnsupportedAttachment.tsx b/src/components/Attachment/UnsupportedAttachment.tsx index e738ec8fe..c2e49fabc 100644 --- a/src/components/Attachment/UnsupportedAttachment.tsx +++ b/src/components/Attachment/UnsupportedAttachment.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { FileIcon } from '../ReactFileUtilities'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; import type { Attachment } from 'stream-chat'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/Attachment/VoiceRecording.tsx b/src/components/Attachment/VoiceRecording.tsx index 2b1d62fe6..4dc5aa6ff 100644 --- a/src/components/Attachment/VoiceRecording.tsx +++ b/src/components/Attachment/VoiceRecording.tsx @@ -1,11 +1,14 @@ import React from 'react'; import type { Attachment } from 'stream-chat'; -import { FileSizeIndicator, PlaybackRateButton, PlayButton, WaveProgressBar } from './components'; +import { FileSizeIndicator } from './components/FileSizeIndicator'; +import { PlaybackRateButton } from './components/PlaybackRateButton'; +import { WaveProgressBar } from './components/WaveProgressBar'; +import { PlayButton } from './components/PlayButton'; import { useAudioController } from './hooks/useAudioController'; import { displayDuration } from './utils'; import { FileIcon } from '../ReactFileUtilities'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; import type { DefaultStreamChatGenerics } from '../../types'; diff --git a/src/components/Attachment/hooks/useAudioController.ts b/src/components/Attachment/hooks/useAudioController.ts index c453e7e44..48f7f316a 100644 --- a/src/components/Attachment/hooks/useAudioController.ts +++ b/src/components/Attachment/hooks/useAudioController.ts @@ -1,6 +1,7 @@ import throttle from 'lodash.throttle'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { useChannelActionContext, useTranslationContext } from '../../../context'; +import { useTranslationContext } from '../../../context/TranslationContext'; +import { useChannelActionContext } from '../../../context/ChannelActionContext'; const isSeekable = (audioElement: HTMLAudioElement) => !(audioElement.duration === Infinity || isNaN(audioElement.duration)); diff --git a/src/components/ChannelHeader/icons.tsx b/src/components/ChannelHeader/icons.tsx index bce53f030..5f22e3e04 100644 --- a/src/components/ChannelHeader/icons.tsx +++ b/src/components/ChannelHeader/icons.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; export const MenuIcon = ({ title }: { title?: string }) => { const { t } = useTranslationContext('MenuIcon'); diff --git a/src/components/ChannelList/ChannelList.tsx b/src/components/ChannelList/ChannelList.tsx index 00193d336..185fedb9d 100644 --- a/src/components/ChannelList/ChannelList.tsx +++ b/src/components/ChannelList/ChannelList.tsx @@ -31,7 +31,7 @@ import { LoadingChannels } from '../Loading/LoadingChannels'; import { LoadMorePaginator, LoadMorePaginatorProps } from '../LoadMore/LoadMorePaginator'; import { NullComponent } from '../UtilityComponents'; -import { ChannelListContextProvider } from '../../context'; +import { ChannelListContextProvider } from '../../context/ChannelListContext'; import { useChatContext } from '../../context/ChatContext'; import type { Channel, ChannelFilters, ChannelOptions, ChannelSort, Event } from 'stream-chat'; diff --git a/src/components/ChannelList/ChannelListMessenger.tsx b/src/components/ChannelList/ChannelListMessenger.tsx index 234222bcc..b7d686bfb 100644 --- a/src/components/ChannelList/ChannelListMessenger.tsx +++ b/src/components/ChannelList/ChannelListMessenger.tsx @@ -2,7 +2,7 @@ import React, { PropsWithChildren } from 'react'; import { LoadingChannels } from '../Loading/LoadingChannels'; import { NullComponent } from '../UtilityComponents'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; import type { APIErrorResponse, Channel, ErrorFromResponse } from 'stream-chat'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/ChannelPreview/hooks/useChannelPreviewInfo.ts b/src/components/ChannelPreview/hooks/useChannelPreviewInfo.ts index bd179fd21..50c034551 100644 --- a/src/components/ChannelPreview/hooks/useChannelPreviewInfo.ts +++ b/src/components/ChannelPreview/hooks/useChannelPreviewInfo.ts @@ -4,7 +4,7 @@ import type { Channel } from 'stream-chat'; import { getDisplayImage, getDisplayTitle } from '../utils'; import type { DefaultStreamChatGenerics } from '../../../types/types'; -import { useChatContext } from '../../../context'; +import { useChatContext } from '../../../context/ChatContext'; export type ChannelPreviewInfoParams = { channel: Channel; diff --git a/src/components/ChannelPreview/hooks/useMessageDeliveryStatus.ts b/src/components/ChannelPreview/hooks/useMessageDeliveryStatus.ts index d7c63aa34..247722292 100644 --- a/src/components/ChannelPreview/hooks/useMessageDeliveryStatus.ts +++ b/src/components/ChannelPreview/hooks/useMessageDeliveryStatus.ts @@ -1,7 +1,7 @@ import { useCallback, useEffect, useState } from 'react'; import type { Channel, Event } from 'stream-chat'; -import { useChatContext } from '../../../context'; +import { useChatContext } from '../../../context/ChatContext'; import type { DefaultStreamChatGenerics } from '../../../types/types'; import type { StreamMessage } from '../../../context'; diff --git a/src/components/ChannelSearch/SearchResults.tsx b/src/components/ChannelSearch/SearchResults.tsx index ea03d8246..d6ddc4a64 100644 --- a/src/components/ChannelSearch/SearchResults.tsx +++ b/src/components/ChannelSearch/SearchResults.tsx @@ -6,7 +6,7 @@ import { ChannelPreview } from '../ChannelPreview'; import { ChannelOrUserResponse, isChannel } from './utils'; import { Avatar } from '../Avatar'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/Gallery/Image.tsx b/src/components/Gallery/Image.tsx index d3d23f7fc..d7d9d9b29 100644 --- a/src/components/Gallery/Image.tsx +++ b/src/components/Gallery/Image.tsx @@ -4,7 +4,7 @@ import { sanitizeUrl } from '@braintree/sanitize-url'; import { BaseImage as DefaultBaseImage } from './BaseImage'; import { Modal } from '../Modal'; import { ModalGallery as DefaultModalGallery } from './ModalGallery'; -import { useComponentContext } from '../../context'; +import { useComponentContext } from '../../context/ComponentContext'; import type { Attachment } from 'stream-chat'; import type { DefaultStreamChatGenerics, Dimensions } from '../../types/types'; diff --git a/src/components/Gallery/ModalGallery.tsx b/src/components/Gallery/ModalGallery.tsx index dd55e040f..08bf7d22c 100644 --- a/src/components/Gallery/ModalGallery.tsx +++ b/src/components/Gallery/ModalGallery.tsx @@ -1,7 +1,7 @@ import React, { useMemo } from 'react'; import ImageGallery, { ReactImageGalleryItem } from 'react-image-gallery'; import { BaseImage } from './BaseImage'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; import type { Attachment } from 'stream-chat'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/LoadMore/LoadMoreButton.tsx b/src/components/LoadMore/LoadMoreButton.tsx index c2ad3274b..96cd89d29 100644 --- a/src/components/LoadMore/LoadMoreButton.tsx +++ b/src/components/LoadMore/LoadMoreButton.tsx @@ -1,7 +1,7 @@ import React, { PropsWithChildren, useEffect } from 'react'; import { LoadingIndicator } from '../Loading'; import { deprecationAndReplacementWarning } from '../../utils/deprecationWarning'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; export type LoadMoreButtonProps = { /** onClick handler load more button. Pagination logic should be executed in this handler. */ diff --git a/src/components/MediaRecorder/AudioRecorder/AudioRecorder.tsx b/src/components/MediaRecorder/AudioRecorder/AudioRecorder.tsx index bea727757..a4ba7d53b 100644 --- a/src/components/MediaRecorder/AudioRecorder/AudioRecorder.tsx +++ b/src/components/MediaRecorder/AudioRecorder/AudioRecorder.tsx @@ -10,7 +10,7 @@ import { PauseIcon, SendIcon, } from '../../MessageInput'; -import { useMessageInputContext } from '../../../context'; +import { useMessageInputContext } from '../../../context/MessageInputContext'; export const AudioRecorder = () => { const { diff --git a/src/components/MediaRecorder/AudioRecorder/AudioRecordingInProgress.tsx b/src/components/MediaRecorder/AudioRecorder/AudioRecordingInProgress.tsx index 776b78744..e9496eb79 100644 --- a/src/components/MediaRecorder/AudioRecorder/AudioRecordingInProgress.tsx +++ b/src/components/MediaRecorder/AudioRecorder/AudioRecordingInProgress.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import { useTimeElapsed } from '../../MessageInput/hooks/useTimeElapsed'; -import { useMessageInputContext } from '../../../context'; +import { useMessageInputContext } from '../../../context/MessageInputContext'; import { RecordingTimer } from './RecordingTimer'; type WaveformProps = { diff --git a/src/components/MediaRecorder/RecordingPermissionDeniedNotification.tsx b/src/components/MediaRecorder/RecordingPermissionDeniedNotification.tsx index 935535649..484ddcfb9 100644 --- a/src/components/MediaRecorder/RecordingPermissionDeniedNotification.tsx +++ b/src/components/MediaRecorder/RecordingPermissionDeniedNotification.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; import { RecordingPermission } from './classes/BrowserPermission'; diff --git a/src/components/MediaRecorder/classes/MediaRecorderController.ts b/src/components/MediaRecorder/classes/MediaRecorderController.ts index 13533c52a..f7d130cba 100644 --- a/src/components/MediaRecorder/classes/MediaRecorderController.ts +++ b/src/components/MediaRecorder/classes/MediaRecorderController.ts @@ -15,8 +15,8 @@ import { getRecordedMediaTypeFromMimeType, RecordedMediaType, } from '../../ReactFileUtilities'; -import { TranslationContextValue } from '../../../context'; -import { defaultTranslatorFunction } from '../../../i18n'; +import { TranslationContextValue } from '../../../context/TranslationContext'; +import { defaultTranslatorFunction } from '../../../i18n/utils'; import { isSafari } from '../../../utils/browsers'; import { mergeDeepUndefined } from '../../../utils/mergeDeep'; diff --git a/src/components/MediaRecorder/classes/__tests__/MediaRecorderController.test.js b/src/components/MediaRecorder/classes/__tests__/MediaRecorderController.test.js index ce89e1593..5e6caec98 100644 --- a/src/components/MediaRecorder/classes/__tests__/MediaRecorderController.test.js +++ b/src/components/MediaRecorder/classes/__tests__/MediaRecorderController.test.js @@ -9,7 +9,7 @@ import { RecordingAttachmentType, } from '../MediaRecorderController'; import { AmplitudeRecorderState, DEFAULT_AMPLITUDE_RECORDER_CONFIG } from '../AmplitudeRecorder'; -import { defaultTranslatorFunction } from '../../../../i18n'; +import { defaultTranslatorFunction } from '../../../../i18n/utils'; import * as audioSampling from '../../../Attachment/audioSampling'; import * as reactFileUtils from '../../../ReactFileUtilities/utils'; import { generateVoiceRecordingAttachment } from '../../../../mock-builders'; diff --git a/src/components/MediaRecorder/hooks/useMediaRecorder.ts b/src/components/MediaRecorder/hooks/useMediaRecorder.ts index a1550d633..cccb8d32e 100644 --- a/src/components/MediaRecorder/hooks/useMediaRecorder.ts +++ b/src/components/MediaRecorder/hooks/useMediaRecorder.ts @@ -1,5 +1,6 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; -import { MessageInputContextValue, useTranslationContext } from '../../../context'; +import { useTranslationContext } from '../../../context/TranslationContext'; +import type { MessageInputContextValue } from '../../../context/MessageInputContext'; import { CustomAudioRecordingConfig, MediaRecorderController, diff --git a/src/components/Message/Message.tsx b/src/components/Message/Message.tsx index 3b6ce5e6a..074dddf6f 100644 --- a/src/components/Message/Message.tsx +++ b/src/components/Message/Message.tsx @@ -19,14 +19,11 @@ import { } from './hooks'; import { areMessagePropsEqual, getMessageActions, MESSAGE_ACTIONS } from './utils'; -import { - MessageContextValue, - MessageProvider, - useChannelActionContext, - useChannelStateContext, - useChatContext, - useComponentContext, -} from '../../context'; +import { useComponentContext } from '../../context/ComponentContext'; +import { useChatContext } from '../../context/ChatContext'; +import { useChannelStateContext } from '../../context/ChannelStateContext'; +import { useChannelActionContext } from '../../context/ChannelActionContext'; +import { MessageContextValue, MessageProvider } from '../../context/MessageContext'; import type { MessageProps } from './types'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/Message/MessageEditedTimestamp.tsx b/src/components/Message/MessageEditedTimestamp.tsx index 87db8539f..af6e70653 100644 --- a/src/components/Message/MessageEditedTimestamp.tsx +++ b/src/components/Message/MessageEditedTimestamp.tsx @@ -1,7 +1,9 @@ import React from 'react'; import clsx from 'clsx'; -import { useComponentContext, useMessageContext, useTranslationContext } from '../../context'; +import { useComponentContext } from '../../context/ComponentContext'; +import { useMessageContext } from '../../context/MessageContext'; +import { useTranslationContext } from '../../context/TranslationContext'; import { Timestamp as DefaultTimestamp } from './Timestamp'; import { isMessageEdited } from './utils'; diff --git a/src/components/Message/MessageErrorText.tsx b/src/components/Message/MessageErrorText.tsx index fd4f7a137..b41877ee9 100644 --- a/src/components/Message/MessageErrorText.tsx +++ b/src/components/Message/MessageErrorText.tsx @@ -1,6 +1,7 @@ import React from 'react'; -import { StreamMessage, useTranslationContext } from '../../context'; +import type { StreamMessage } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; import { DefaultStreamChatGenerics } from '../../types/types'; import { isMessageBounced } from './utils'; diff --git a/src/components/Message/MessageOptions.tsx b/src/components/Message/MessageOptions.tsx index 9f87ea780..5f6a464c3 100644 --- a/src/components/Message/MessageOptions.tsx +++ b/src/components/Message/MessageOptions.tsx @@ -12,7 +12,7 @@ import { MessageActions } from '../MessageActions'; import { MessageContextValue, useMessageContext } from '../../context/MessageContext'; import type { DefaultStreamChatGenerics, IconProps } from '../../types/types'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; export type MessageOptionsProps< StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics diff --git a/src/components/Message/MessageSimple.tsx b/src/components/Message/MessageSimple.tsx index ecee1ef85..1e2af0dd5 100644 --- a/src/components/Message/MessageSimple.tsx +++ b/src/components/Message/MessageSimple.tsx @@ -33,7 +33,7 @@ import { MessageContextValue, useMessageContext } from '../../context/MessageCon import type { MessageUIComponentProps } from './types'; import type { DefaultStreamChatGenerics } from '../../types/types'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; import { MessageEditedTimestamp } from './MessageEditedTimestamp'; type MessageSimpleWithContextProps< diff --git a/src/components/Message/MessageText.tsx b/src/components/Message/MessageText.tsx index cb7919d76..036790387 100644 --- a/src/components/Message/MessageText.tsx +++ b/src/components/Message/MessageText.tsx @@ -4,7 +4,9 @@ import React, { useMemo } from 'react'; import { QuotedMessage as DefaultQuotedMessage } from './QuotedMessage'; import { isOnlyEmojis, messageHasAttachments } from './utils'; -import { useComponentContext, useMessageContext, useTranslationContext } from '../../context'; +import { useComponentContext } from '../../context/ComponentContext'; +import { useMessageContext } from '../../context/MessageContext'; +import { useTranslationContext } from '../../context/TranslationContext'; import { renderText as defaultRenderText } from './renderText'; import { MessageErrorText } from './MessageErrorText'; diff --git a/src/components/Message/MessageTimestamp.tsx b/src/components/Message/MessageTimestamp.tsx index e4f68bc45..db69d428c 100644 --- a/src/components/Message/MessageTimestamp.tsx +++ b/src/components/Message/MessageTimestamp.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useMessageContext } from '../../context/MessageContext'; import { Timestamp as DefaultTimestamp } from './Timestamp'; -import { useComponentContext } from '../../context'; +import { useComponentContext } from '../../context/ComponentContext'; import type { StreamMessage } from '../../context/ChannelStateContext'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/Message/__tests__/MessageTimestamp.test.js b/src/components/Message/__tests__/MessageTimestamp.test.js index 38ec51244..d8775f1c2 100644 --- a/src/components/Message/__tests__/MessageTimestamp.test.js +++ b/src/components/Message/__tests__/MessageTimestamp.test.js @@ -10,7 +10,6 @@ import { notValidDateWarning } from '../../../i18n/utils'; import { Chat } from '../../Chat'; import { getTestClient } from '../../../mock-builders'; import { Streami18n } from '../../../i18n'; - Dayjs.extend(calendar); const calendarFormats = { @@ -124,7 +123,7 @@ describe('', () => { }), }, }); - expect(container).toHaveTextContent('2019-04-03T14:42:47+00:00'); + expect(container).toHaveTextContent('2019-04-03T14:42:47Z'); }); it('should render with custom format provided via i18n service', async () => { @@ -172,7 +171,7 @@ describe('', () => { }, props: { calendarFormats }, }); - expect(container).toHaveTextContent('2019-04-03T14:42:47+00:00'); + expect(container).toHaveTextContent('2019-04-03T14:42:47Z'); }); it('should reflect the custom calendarFormats if calendar is enabled', async () => { diff --git a/src/components/Message/hooks/useMarkUnreadHandler.ts b/src/components/Message/hooks/useMarkUnreadHandler.ts index 943187efa..5e801d1ea 100644 --- a/src/components/Message/hooks/useMarkUnreadHandler.ts +++ b/src/components/Message/hooks/useMarkUnreadHandler.ts @@ -1,5 +1,6 @@ import { validateAndGetMessage } from '../utils'; -import { useChannelStateContext, useTranslationContext } from '../../../context'; +import { useChannelStateContext } from '../../../context/ChannelStateContext'; +import { useTranslationContext } from '../../../context/TranslationContext'; import type { StreamMessage } from '../../../context'; import type { ReactEventHandler } from '../types'; diff --git a/src/components/Message/hooks/useReactionsFetcher.ts b/src/components/Message/hooks/useReactionsFetcher.ts index cbd50036c..7749b6055 100644 --- a/src/components/Message/hooks/useReactionsFetcher.ts +++ b/src/components/Message/hooks/useReactionsFetcher.ts @@ -1,4 +1,6 @@ -import { StreamMessage, useChatContext, useTranslationContext } from '../../../context'; +import { useChatContext } from '../../../context/ChatContext'; +import { useTranslationContext } from '../../../context/TranslationContext'; +import type { StreamMessage } from '../../../context'; import { DefaultStreamChatGenerics } from '../../../types/types'; import { ReactionResponse, ReactionSort, StreamChat } from 'stream-chat'; import { ReactionType } from '../../Reactions/types'; diff --git a/src/components/MessageActions/MessageActions.tsx b/src/components/MessageActions/MessageActions.tsx index 194313dde..cea2166d7 100644 --- a/src/components/MessageActions/MessageActions.tsx +++ b/src/components/MessageActions/MessageActions.tsx @@ -17,7 +17,7 @@ import { MessageContextValue, useMessageContext } from '../../context/MessageCon import type { DefaultStreamChatGenerics, IconProps } from '../../types/types'; import { useMessageActionsBoxPopper } from './hooks'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; type MessageContextPropsToPick = | 'getMessageActions' diff --git a/src/components/MessageActions/MessageActionsBox.tsx b/src/components/MessageActions/MessageActionsBox.tsx index a19b252ad..51dc1ca0b 100644 --- a/src/components/MessageActions/MessageActionsBox.tsx +++ b/src/components/MessageActions/MessageActionsBox.tsx @@ -3,13 +3,10 @@ import clsx from 'clsx'; import { MESSAGE_ACTIONS } from '../Message/utils'; -import { - MessageContextValue, - useChannelActionContext, - useComponentContext, - useMessageContext, - useTranslationContext, -} from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; +import { MessageContextValue, useMessageContext } from '../../context/MessageContext'; +import { useComponentContext } from '../../context/ComponentContext'; +import { useChannelActionContext } from '../../context/ChannelActionContext'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/MessageBounce/MessageBounceModal.tsx b/src/components/MessageBounce/MessageBounceModal.tsx index 7cf33b34f..7c266181d 100644 --- a/src/components/MessageBounce/MessageBounceModal.tsx +++ b/src/components/MessageBounce/MessageBounceModal.tsx @@ -1,6 +1,6 @@ import React, { ComponentType, PropsWithChildren } from 'react'; import { Modal, ModalProps } from '../Modal'; -import { MessageBounceProvider } from '../../context'; +import { MessageBounceProvider } from '../../context/MessageBounceContext'; import { MessageBouncePromptProps } from './MessageBouncePrompt'; export type MessageBounceModalProps = PropsWithChildren< diff --git a/src/components/MessageBounce/MessageBouncePrompt.tsx b/src/components/MessageBounce/MessageBouncePrompt.tsx index 805dcb156..7cb11f4d5 100644 --- a/src/components/MessageBounce/MessageBouncePrompt.tsx +++ b/src/components/MessageBounce/MessageBouncePrompt.tsx @@ -1,5 +1,6 @@ import React from 'react'; -import { useMessageBounceContext, useTranslationContext } from '../../context'; +import { useMessageBounceContext } from '../../context/MessageBounceContext'; +import { useTranslationContext } from '../../context/TranslationContext'; import type { MouseEventHandler, PropsWithChildren } from 'react'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/MessageInput/AttachmentPreviewList/AttachmentPreviewList.tsx b/src/components/MessageInput/AttachmentPreviewList/AttachmentPreviewList.tsx index 682244973..170aeaab8 100644 --- a/src/components/MessageInput/AttachmentPreviewList/AttachmentPreviewList.tsx +++ b/src/components/MessageInput/AttachmentPreviewList/AttachmentPreviewList.tsx @@ -24,7 +24,7 @@ import { isLocalVoiceRecordingAttachment, isScrapedContent, } from '../../Attachment'; -import { useMessageInputContext } from '../../../context'; +import { useMessageInputContext } from '../../../context/MessageInputContext'; import type { DefaultStreamChatGenerics } from '../../../types'; diff --git a/src/components/MessageInput/AttachmentPreviewList/FileAttachmentPreview.tsx b/src/components/MessageInput/AttachmentPreviewList/FileAttachmentPreview.tsx index 3f7853bbd..f879d1752 100644 --- a/src/components/MessageInput/AttachmentPreviewList/FileAttachmentPreview.tsx +++ b/src/components/MessageInput/AttachmentPreviewList/FileAttachmentPreview.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { FileIcon } from '../../ReactFileUtilities'; import { CloseIcon, DownloadIcon, LoadingIndicatorIcon, RetryIcon } from '../icons'; -import { useTranslationContext } from '../../../context'; +import { useTranslationContext } from '../../../context/TranslationContext'; import type { AttachmentPreviewProps } from './types'; import { LocalAttachmentCast, LocalAttachmentUploadMetadata } from '../types'; diff --git a/src/components/MessageInput/AttachmentPreviewList/ImageAttachmentPreview.tsx b/src/components/MessageInput/AttachmentPreviewList/ImageAttachmentPreview.tsx index 6c7186933..255c77d59 100644 --- a/src/components/MessageInput/AttachmentPreviewList/ImageAttachmentPreview.tsx +++ b/src/components/MessageInput/AttachmentPreviewList/ImageAttachmentPreview.tsx @@ -2,7 +2,8 @@ import clsx from 'clsx'; import { CloseIcon, LoadingIndicatorIcon, RetryIcon } from '../icons'; import React, { useCallback, useState } from 'react'; import { BaseImage as DefaultBaseImage } from '../../Gallery'; -import { useComponentContext, useTranslationContext } from '../../../context'; +import { useTranslationContext } from '../../../context/TranslationContext'; +import { useComponentContext } from '../../../context/ComponentContext'; import type { AttachmentPreviewProps } from './types'; import type { LocalImageAttachment } from '../types'; import type { DefaultStreamChatGenerics } from '../../../types'; diff --git a/src/components/MessageInput/AttachmentPreviewList/UnsupportedAttachmentPreview.tsx b/src/components/MessageInput/AttachmentPreviewList/UnsupportedAttachmentPreview.tsx index 1f7f12a4d..e7fe66572 100644 --- a/src/components/MessageInput/AttachmentPreviewList/UnsupportedAttachmentPreview.tsx +++ b/src/components/MessageInput/AttachmentPreviewList/UnsupportedAttachmentPreview.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { CloseIcon, DownloadIcon, LoadingIndicatorIcon, RetryIcon } from '../icons'; import { FileIcon } from '../../ReactFileUtilities'; -import { useTranslationContext } from '../../../context'; +import { useTranslationContext } from '../../../context/TranslationContext'; import type { AttachmentPreviewProps } from './types'; import type { AnyLocalAttachment } from '../types'; import type { DefaultStreamChatGenerics } from '../../../types'; diff --git a/src/components/MessageInput/EditMessageForm.tsx b/src/components/MessageInput/EditMessageForm.tsx index 847e73053..10a053a77 100644 --- a/src/components/MessageInput/EditMessageForm.tsx +++ b/src/components/MessageInput/EditMessageForm.tsx @@ -1,7 +1,8 @@ import React, { useEffect } from 'react'; import { MessageInputFlat } from './MessageInputFlat'; -import { useMessageInputContext, useTranslationContext } from '../../context'; +import { useMessageInputContext } from '../../context/MessageInputContext'; +import { useTranslationContext } from '../../context/TranslationContext'; import type { CustomTrigger, DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/components/MessageInput/LinkPreviewList.tsx b/src/components/MessageInput/LinkPreviewList.tsx index ec311d861..0b1b6593e 100644 --- a/src/components/MessageInput/LinkPreviewList.tsx +++ b/src/components/MessageInput/LinkPreviewList.tsx @@ -1,6 +1,7 @@ import clsx from 'clsx'; import React, { useState } from 'react'; -import { useChannelStateContext, useMessageInputContext } from '../../context'; +import { useMessageInputContext } from '../../context/MessageInputContext'; +import { useChannelStateContext } from '../../context/ChannelStateContext'; import type { LinkPreview } from './types'; import { LinkPreviewState } from './types'; import { CloseIcon, LinkIcon } from './icons'; diff --git a/src/components/MessageInput/hooks/useAttachments.ts b/src/components/MessageInput/hooks/useAttachments.ts index a9e279fb7..6c7866db1 100644 --- a/src/components/MessageInput/hooks/useAttachments.ts +++ b/src/components/MessageInput/hooks/useAttachments.ts @@ -6,12 +6,10 @@ import { isLocalAttachment, isLocalImageAttachment } from '../../Attachment'; import type { FileLike } from '../../ReactFileUtilities'; import { createFileFromBlobs, generateFileName, isBlobButNotFile } from '../../ReactFileUtilities'; -import { - useChannelActionContext, - useChannelStateContext, - useChatContext, - useTranslationContext, -} from '../../../context'; +import { useChannelActionContext } from '../../../context/ChannelActionContext'; +import { useTranslationContext } from '../../../context/TranslationContext'; +import { useChatContext } from '../../../context/ChatContext'; +import { useChannelStateContext } from '../../../context/ChannelStateContext'; import type { Attachment, SendFileAPIResponse } from 'stream-chat'; import type { MessageInputReducerAction, MessageInputState } from './useMessageInputState'; diff --git a/src/components/MessageInput/hooks/useCommandTrigger.ts b/src/components/MessageInput/hooks/useCommandTrigger.ts index c87eff808..0e8eb8ba7 100644 --- a/src/components/MessageInput/hooks/useCommandTrigger.ts +++ b/src/components/MessageInput/hooks/useCommandTrigger.ts @@ -1,7 +1,7 @@ import { CommandItem } from '../../CommandItem/CommandItem'; import { useChannelStateContext } from '../../../context/ChannelStateContext'; -import { useTranslationContext } from '../../../context'; +import { useTranslationContext } from '../../../context/TranslationContext'; import type { CommandResponse } from 'stream-chat'; diff --git a/src/components/MessageInput/hooks/useCooldownTimer.tsx b/src/components/MessageInput/hooks/useCooldownTimer.tsx index a86207ee3..3299d7593 100644 --- a/src/components/MessageInput/hooks/useCooldownTimer.tsx +++ b/src/components/MessageInput/hooks/useCooldownTimer.tsx @@ -1,7 +1,8 @@ import React, { useEffect, useMemo, useState } from 'react'; import type { ChannelResponse } from 'stream-chat'; -import { useChannelStateContext, useChatContext } from '../../../context'; +import { useChatContext } from '../../../context/ChatContext'; +import { useChannelStateContext } from '../../../context/ChannelStateContext'; import type { DefaultStreamChatGenerics } from '../../../types/types'; diff --git a/src/components/MessageInput/hooks/useLinkPreviews.ts b/src/components/MessageInput/hooks/useLinkPreviews.ts index 5f37dd2d6..25717c148 100644 --- a/src/components/MessageInput/hooks/useLinkPreviews.ts +++ b/src/components/MessageInput/hooks/useLinkPreviews.ts @@ -1,7 +1,9 @@ import { find } from 'linkifyjs'; import { Dispatch, useCallback, useEffect, useRef } from 'react'; import debounce from 'lodash.debounce'; -import { useChannelStateContext, useChatContext } from '../../../context'; +import { useChannelStateContext } from '../../../context/ChannelStateContext'; +import { useChatContext } from '../../../context/ChatContext'; + import type { MessageInputReducerAction, MessageInputState } from './useMessageInputState'; import type { DefaultStreamChatGenerics } from '../../../types/types'; import type { LinkPreview, LinkPreviewMap } from '../types'; diff --git a/src/components/MessageList/ConnectionStatus.tsx b/src/components/MessageList/ConnectionStatus.tsx index 8099baa62..883a16499 100644 --- a/src/components/MessageList/ConnectionStatus.tsx +++ b/src/components/MessageList/ConnectionStatus.tsx @@ -3,7 +3,8 @@ import React, { useEffect, useState } from 'react'; import type { Event } from 'stream-chat'; import { CustomNotification } from './CustomNotification'; -import { useChatContext, useTranslationContext } from '../../context'; +import { useChatContext } from '../../context/ChatContext'; +import { useTranslationContext } from '../../context/TranslationContext'; import type { DefaultStreamChatGenerics } from '../../types/types'; const UnMemoizedConnectionStatus = < diff --git a/src/components/MessageList/ScrollToBottomButton.tsx b/src/components/MessageList/ScrollToBottomButton.tsx index 0daf248d5..c9b5e12b1 100644 --- a/src/components/MessageList/ScrollToBottomButton.tsx +++ b/src/components/MessageList/ScrollToBottomButton.tsx @@ -3,7 +3,8 @@ import clsx from 'clsx'; import { ArrowDown } from './icons'; -import { useChannelStateContext, useChatContext } from '../../context'; +import { useChannelStateContext } from '../../context/ChannelStateContext'; +import { useChatContext } from '../../context/ChatContext'; import type { Event } from 'stream-chat'; import type { MessageNotificationProps } from './MessageNotification'; diff --git a/src/components/MessageList/UnreadMessagesNotification.tsx b/src/components/MessageList/UnreadMessagesNotification.tsx index 3f3117e76..82c4e6082 100644 --- a/src/components/MessageList/UnreadMessagesNotification.tsx +++ b/src/components/MessageList/UnreadMessagesNotification.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { CloseIcon } from './icons'; -import { useChannelActionContext, useTranslationContext } from '../../context'; +import { useChannelActionContext } from '../../context/ChannelActionContext'; +import { useTranslationContext } from '../../context/TranslationContext'; export type UnreadMessagesNotificationProps = { /** diff --git a/src/components/MessageList/UnreadMessagesSeparator.tsx b/src/components/MessageList/UnreadMessagesSeparator.tsx index 0ea91c7f2..5c28034f0 100644 --- a/src/components/MessageList/UnreadMessagesSeparator.tsx +++ b/src/components/MessageList/UnreadMessagesSeparator.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; export const UNREAD_MESSAGE_SEPARATOR_CLASS = 'str-chat__unread-messages-separator'; diff --git a/src/components/MessageList/VirtualizedMessageListComponents.tsx b/src/components/MessageList/VirtualizedMessageListComponents.tsx index 232cfb7e5..0f80db287 100644 --- a/src/components/MessageList/VirtualizedMessageListComponents.tsx +++ b/src/components/MessageList/VirtualizedMessageListComponents.tsx @@ -7,7 +7,8 @@ import { EmptyStateIndicator as DefaultEmptyStateIndicator } from '../EmptyState import { LoadingIndicator as DefaultLoadingIndicator } from '../Loading'; import { isMessageEdited, Message } from '../Message'; -import { StreamMessage, useComponentContext } from '../../context'; +import { useComponentContext } from '../../context/ComponentContext'; +import type { StreamMessage } from '../../context/ChannelStateContext'; import { isDateSeparatorMessage } from './utils'; import type { GroupStyle } from './utils'; diff --git a/src/components/MessageList/hooks/MessageList/useUnreadMessagesNotification.ts b/src/components/MessageList/hooks/MessageList/useUnreadMessagesNotification.ts index bbf474904..e6e9db90a 100644 --- a/src/components/MessageList/hooks/MessageList/useUnreadMessagesNotification.ts +++ b/src/components/MessageList/hooks/MessageList/useUnreadMessagesNotification.ts @@ -1,4 +1,4 @@ -import { useChannelStateContext } from '../../../../context'; +import { useChannelStateContext } from '../../../../context/ChannelStateContext'; import { useEffect, useRef, useState } from 'react'; import { MESSAGE_LIST_MAIN_PANEL_CLASS } from '../../MessageListMainPanel'; import { UNREAD_MESSAGE_SEPARATOR_CLASS } from '../../UnreadMessagesSeparator'; diff --git a/src/components/MessageList/hooks/VirtualizedMessageList/useMessageSetKey.ts b/src/components/MessageList/hooks/VirtualizedMessageList/useMessageSetKey.ts index 584ba1a18..16db6a534 100644 --- a/src/components/MessageList/hooks/VirtualizedMessageList/useMessageSetKey.ts +++ b/src/components/MessageList/hooks/VirtualizedMessageList/useMessageSetKey.ts @@ -1,5 +1,5 @@ import { useEffect, useRef, useState } from 'react'; -import { StreamMessage } from '../../../../context'; +import type { StreamMessage } from '../../../../context'; import { DefaultStreamChatGenerics } from '../../../../types/types'; type UseMessageSetKeyParams< diff --git a/src/components/MessageList/hooks/VirtualizedMessageList/useScrollToBottomOnNewMessage.ts b/src/components/MessageList/hooks/VirtualizedMessageList/useScrollToBottomOnNewMessage.ts index b1f14d79e..c5b6969b0 100644 --- a/src/components/MessageList/hooks/VirtualizedMessageList/useScrollToBottomOnNewMessage.ts +++ b/src/components/MessageList/hooks/VirtualizedMessageList/useScrollToBottomOnNewMessage.ts @@ -1,5 +1,5 @@ import React, { useCallback, useEffect } from 'react'; -import { StreamMessage } from '../../../../context'; +import type { StreamMessage } from '../../../../context'; import { DefaultStreamChatGenerics } from '../../../../types/types'; type UseScrollToBottomOnNewMessageParams< diff --git a/src/components/MessageList/hooks/VirtualizedMessageList/useUnreadMessagesNotificationVirtualized.ts b/src/components/MessageList/hooks/VirtualizedMessageList/useUnreadMessagesNotificationVirtualized.ts index f86f9395e..5b7a5ee9b 100644 --- a/src/components/MessageList/hooks/VirtualizedMessageList/useUnreadMessagesNotificationVirtualized.ts +++ b/src/components/MessageList/hooks/VirtualizedMessageList/useUnreadMessagesNotificationVirtualized.ts @@ -1,5 +1,5 @@ import { useCallback, useEffect, useState } from 'react'; -import { StreamMessage } from '../../../../context'; +import type { StreamMessage } from '../../../../context'; import type { DefaultStreamChatGenerics } from '../../../../types/types'; export type UseUnreadMessagesNotificationParams = { diff --git a/src/components/MessageList/hooks/useMarkRead.ts b/src/components/MessageList/hooks/useMarkRead.ts index 311f64fc3..0cf657bb3 100644 --- a/src/components/MessageList/hooks/useMarkRead.ts +++ b/src/components/MessageList/hooks/useMarkRead.ts @@ -1,10 +1,7 @@ import { useEffect, useRef } from 'react'; -import { - StreamMessage, - useChannelActionContext, - useChannelStateContext, - useChatContext, -} from '../../../context'; +import { useChatContext } from '../../../context/ChatContext'; +import { StreamMessage, useChannelStateContext } from '../../../context/ChannelStateContext'; +import { useChannelActionContext } from '../../../context/ChannelActionContext'; import { Event, MessageResponse } from 'stream-chat'; import { DefaultStreamChatGenerics } from '../../../types'; diff --git a/src/components/MessageList/renderMessages.tsx b/src/components/MessageList/renderMessages.tsx index 85948ffe4..4674c325d 100644 --- a/src/components/MessageList/renderMessages.tsx +++ b/src/components/MessageList/renderMessages.tsx @@ -2,7 +2,7 @@ import React, { Fragment, ReactNode } from 'react'; import { GroupStyle, isDateSeparatorMessage } from './utils'; import { Message, MessageProps } from '../Message'; -import { ComponentContextValue, CustomClasses } from '../../context'; +import type { ComponentContextValue, CustomClasses } from '../../context'; import { CUSTOM_MESSAGE_TYPE } from '../../constants/messageTypes'; import type { UserResponse } from 'stream-chat'; diff --git a/src/components/Modal/Modal.tsx b/src/components/Modal/Modal.tsx index f1e21c7ec..3af39d16b 100644 --- a/src/components/Modal/Modal.tsx +++ b/src/components/Modal/Modal.tsx @@ -4,7 +4,7 @@ import { FocusScope } from '@react-aria/focus'; import { CloseIconRound } from './icons'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; export type ModalProps = { /** If true, modal is opened or visible. */ diff --git a/src/components/ReactFileUtilities/ImageDropzone.tsx b/src/components/ReactFileUtilities/ImageDropzone.tsx index dd3c1696f..9cd2a0e85 100644 --- a/src/components/ReactFileUtilities/ImageDropzone.tsx +++ b/src/components/ReactFileUtilities/ImageDropzone.tsx @@ -1,7 +1,7 @@ import clsx from 'clsx'; import React, { PropsWithChildren, useCallback, useMemo } from 'react'; import { useDropzone } from 'react-dropzone'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; export type ImageDropzoneProps = { /** diff --git a/src/components/Reactions/ReactionsList.tsx b/src/components/Reactions/ReactionsList.tsx index 22c6c6182..6e2e739b3 100644 --- a/src/components/Reactions/ReactionsList.tsx +++ b/src/components/Reactions/ReactionsList.tsx @@ -10,7 +10,8 @@ import type { DefaultStreamChatGenerics } from '../../types/types'; import type { ReactionOptions } from './reactionOptions'; import type { ReactionDetailsComparator, ReactionsComparator, ReactionType } from './types'; import { ReactionsListModal } from './ReactionsListModal'; -import { MessageContextValue, useTranslationContext } from '../../context'; +import { MessageContextValue } from '../../context/MessageContext'; +import { useTranslationContext } from '../../context/TranslationContext'; import { MAX_MESSAGE_REACTIONS_TO_FETCH } from '../Message/hooks'; export type ReactionsListProps< diff --git a/src/components/Reactions/ReactionsListModal.tsx b/src/components/Reactions/ReactionsListModal.tsx index bdeb91c7e..7a5edb700 100644 --- a/src/components/Reactions/ReactionsListModal.tsx +++ b/src/components/Reactions/ReactionsListModal.tsx @@ -7,7 +7,8 @@ import { Modal, ModalProps } from '../Modal'; import { useFetchReactions } from './hooks/useFetchReactions'; import { LoadingIndicator } from '../Loading'; import { Avatar } from '../Avatar'; -import { MessageContextValue, useMessageContext } from '../../context'; +import { MessageContextValue } from '../../context/MessageContext'; +import { useMessageContext } from '../../context/MessageContext'; import { DefaultStreamChatGenerics } from '../../types/types'; import { ReactionSort } from 'stream-chat'; diff --git a/src/components/Reactions/hooks/useFetchReactions.ts b/src/components/Reactions/hooks/useFetchReactions.ts index 0070ce91c..e0f1f2e78 100644 --- a/src/components/Reactions/hooks/useFetchReactions.ts +++ b/src/components/Reactions/hooks/useFetchReactions.ts @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import { ReactionResponse, ReactionSort } from 'stream-chat'; -import { MessageContextValue, useMessageContext } from '../../../context'; +import { MessageContextValue, useMessageContext } from '../../../context/MessageContext'; import { DefaultStreamChatGenerics } from '../../../types/types'; import { ReactionType } from '../types'; diff --git a/src/components/Reactions/hooks/useProcessReactions.tsx b/src/components/Reactions/hooks/useProcessReactions.tsx index d84e70a1c..0499224fd 100644 --- a/src/components/Reactions/hooks/useProcessReactions.tsx +++ b/src/components/Reactions/hooks/useProcessReactions.tsx @@ -1,7 +1,7 @@ import { useCallback, useMemo } from 'react'; -import { useComponentContext, useMessageContext } from '../../../context'; - +import { useMessageContext } from '../../../context/MessageContext'; +import { useComponentContext } from '../../../context/ComponentContext'; import type { ReactionsListProps } from '../ReactionsList'; import type { DefaultStreamChatGenerics } from '../../../types/types'; import type { ReactionsComparator, ReactionSummary } from '../types'; diff --git a/src/components/SafeAnchor/SafeAnchor.tsx b/src/components/SafeAnchor/SafeAnchor.tsx index 146dbdd58..4d1f19b91 100644 --- a/src/components/SafeAnchor/SafeAnchor.tsx +++ b/src/components/SafeAnchor/SafeAnchor.tsx @@ -1,6 +1,6 @@ import React, { PropsWithChildren } from 'react'; import { sanitizeUrl } from '@braintree/sanitize-url'; -import { useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; /** * Similar to a regular anchor tag, but it sanitizes the href value and prevents XSS diff --git a/src/components/Thread/Thread.tsx b/src/components/Thread/Thread.tsx index 8970f180c..5a65c0664 100644 --- a/src/components/Thread/Thread.tsx +++ b/src/components/Thread/Thread.tsx @@ -12,12 +12,10 @@ import { import { ThreadHeader as DefaultThreadHeader } from './ThreadHeader'; import { ThreadHead as DefaultThreadHead } from '../Thread/ThreadHead'; -import { - useChannelActionContext, - useChannelStateContext, - useChatContext, - useComponentContext, -} from '../../context'; +import { useChannelActionContext } from '../../context/ChannelActionContext'; +import { useChannelStateContext } from '../../context/ChannelStateContext'; +import { useChatContext } from '../../context/ChatContext'; +import { useComponentContext } from '../../context/ComponentContext'; import type { MessageProps, MessageUIComponentProps } from '../Message/types'; import type { MessageActionsArray } from '../Message/utils'; diff --git a/src/components/Thread/ThreadHead.tsx b/src/components/Thread/ThreadHead.tsx index edb14884a..5c1e2bd8f 100644 --- a/src/components/Thread/ThreadHead.tsx +++ b/src/components/Thread/ThreadHead.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { Message, MessageProps } from '../Message'; import { ThreadStart as DefaultThreadStart } from './ThreadStart'; -import { useComponentContext } from '../../context'; +import { useComponentContext } from '../../context/ComponentContext'; import type { DefaultStreamChatGenerics } from '../../types/types'; diff --git a/src/context/ComponentContext.tsx b/src/context/ComponentContext.tsx index 1ee599b79..33ee4a8a6 100644 --- a/src/context/ComponentContext.tsx +++ b/src/context/ComponentContext.tsx @@ -35,7 +35,7 @@ import type { TypingIndicatorProps } from '../components/TypingIndicator/TypingI import type { CustomTrigger, DefaultStreamChatGenerics, UnknownType } from '../types/types'; import type { RecordingPermissionDeniedNotificationProps } from '../components'; -import { +import type { BaseImageProps, CooldownTimerProps, CustomMessageActionsListProps, diff --git a/src/context/MessageBounceContext.tsx b/src/context/MessageBounceContext.tsx index 7bd50e32e..db100640a 100644 --- a/src/context/MessageBounceContext.tsx +++ b/src/context/MessageBounceContext.tsx @@ -3,7 +3,7 @@ import { useMessageContext } from './MessageContext'; import { DefaultStreamChatGenerics, PropsWithChildrenOnly } from '../types/types'; import { StreamMessage } from './ChannelStateContext'; import { useChannelActionContext } from './ChannelActionContext'; -import { isMessageBounced } from '../components'; +import { isMessageBounced } from '../components/Message/utils'; export interface MessageBounceContextValue< StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics diff --git a/src/context/TranslationContext.tsx b/src/context/TranslationContext.tsx index 61fdba334..f2386db82 100644 --- a/src/context/TranslationContext.tsx +++ b/src/context/TranslationContext.tsx @@ -10,7 +10,7 @@ import type { Moment } from 'moment-timezone'; import type { TranslationLanguages } from 'stream-chat'; import type { UnknownType } from '../types/types'; -import { defaultTranslatorFunction } from '../i18n'; +import { defaultTranslatorFunction } from '../i18n/utils'; Dayjs.extend(calendar); Dayjs.extend(localizedFormat); diff --git a/src/i18n/Streami18n.ts b/src/i18n/Streami18n.ts index 3f55a4035..83b954b6d 100644 --- a/src/i18n/Streami18n.ts +++ b/src/i18n/Streami18n.ts @@ -7,7 +7,7 @@ import localeData from 'dayjs/plugin/localeData'; import relativeTime from 'dayjs/plugin/relativeTime'; import utc from 'dayjs/plugin/utc'; import timezone from 'dayjs/plugin/timezone'; -import { predefinedFormatters } from './utils'; +import { defaultTranslatorFunction, predefinedFormatters } from './utils'; import type momentTimezone from 'moment-timezone'; import type { TranslationLanguages } from 'stream-chat'; @@ -418,8 +418,6 @@ const defaultStreami18nOptions = { logger: (message?: string) => console.warn(message), }; -export const defaultTranslatorFunction: TFunction = (key: tResult) => key; - export class Streami18n { i18nInstance = i18n.createInstance(); Dayjs = null; diff --git a/src/i18n/utils.ts b/src/i18n/utils.ts index a271de7ae..5d27319b3 100644 --- a/src/i18n/utils.ts +++ b/src/i18n/utils.ts @@ -145,3 +145,5 @@ export const predefinedFormatters: PredefinedFormatters = { return result; }, }; + +export const defaultTranslatorFunction: TFunction = (key: tResult) => key; diff --git a/src/plugins/Emojis/EmojiPicker.tsx b/src/plugins/Emojis/EmojiPicker.tsx index 4146e0e91..96c2e2bc6 100644 --- a/src/plugins/Emojis/EmojiPicker.tsx +++ b/src/plugins/Emojis/EmojiPicker.tsx @@ -5,7 +5,8 @@ import Picker from '@emoji-mart/react'; import type { Options } from '@popperjs/core'; -import { useMessageInputContext, useTranslationContext } from '../../context'; +import { useTranslationContext } from '../../context/TranslationContext'; +import { useMessageInputContext } from '../../context/MessageInputContext'; import { EmojiPickerIcon } from './icons'; const isShadowRoot = (node: Node): node is ShadowRoot => !!(node as ShadowRoot).host; diff --git a/src/stories/utils.tsx b/src/stories/utils.tsx index 226baf2a4..539d23ba8 100644 --- a/src/stories/utils.tsx +++ b/src/stories/utils.tsx @@ -1,5 +1,5 @@ import React, { PropsWithChildren, useEffect, useState } from 'react'; -import { Chat } from '../'; +import { Chat } from '../components/Chat/Chat'; import { DefaultGenerics, ExtendableGenerics,