@carbon/ai-chat 0.4.0-rc.2 → 0.4.0-rc.3
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/dist/es/aiChatEntry.js +220 -14
- package/dist/es/chat.AppContainer.js +6491 -0
- package/dist/es/chat.AppState.js +40 -0
- package/dist/es/{chat/shared/components/BasePanelComponent.js → chat.BasePanelComponent.js} +3 -3
- package/dist/es/{chat/shared/components/panels/BodyAndFooterPanelComponent.js → chat.BodyAndFooterPanelComponent.js} +92 -9
- package/dist/es/chat.BodyWithFooterComponent.js +140 -0
- package/dist/es/{chat/shared/components/header/BotHeader.js → chat.BotHeader.js} +7 -9
- package/dist/es/{chat/shared/components/responseTypes/carousel/Carousel.js → chat.Carousel.js} +3 -3
- package/dist/es/chat.CatastrophicError.js +381 -0
- package/dist/es/chat.Chat.js +2009 -0
- package/dist/es/chat.Disclaimer.js +553 -0
- package/dist/es/chat.Header.js +1025 -0
- package/dist/es/{chat/shared/components/util/HideComponent.js → chat.HideComponent.js} +9 -2
- package/dist/es/{types/config/HomeScreenConfig.js → chat.HomeScreenConfig.js} +1 -1
- package/dist/es/{chat/shared/components/homeScreen/HomeScreen.js → chat.HomeScreenContainer.js} +159 -14
- package/dist/es/{chat/shared/components/homeScreen/HomeScreenHeader.js → chat.HomeScreenHeader.js} +3 -3
- package/dist/es/{chat/shared/services/haa/HumanAgentServiceImpl.js → chat.HumanAgentServiceImpl.js} +215 -17
- package/dist/es/{chat/shared/components/responseTypes/iframe/IFrameComponent.js → chat.IFrameComponent.js} +4 -8
- package/dist/es/chat.IFramePanel.js +151 -0
- package/dist/es/{chat/shared/components/input/Input.js → chat.Input.js} +214 -18
- package/dist/es/{types/config/ServiceDeskConfig.js → chat.LocalMessageItem.js} +17 -1
- package/dist/es/chat.MessageTypeComponent.js +3580 -0
- package/dist/es/{types/messaging/Messages.js → chat.Messages.js} +1 -1
- package/dist/es/chat.MountChildrenOnDelay.js +97 -0
- package/dist/es/{chat/shared/components/OverlayPanel.js → chat.PageObjectId.js} +70 -4
- package/dist/es/{chat/web-components/components/markdownText/src/markdownText.scss.js → chat.RichText.js} +347 -1
- package/dist/es/chat.TourContainer.js +524 -0
- package/dist/es/{chat/languages/en.json.js → chat.VideoComponent.js} +561 -1
- package/dist/es/chat.ViewSourcePanel.js +187 -0
- package/dist/es/{chat/shared/store/actions.js → chat.actions.js} +2 -2
- package/dist/es/{chat/shared/utils/browserUtils.js → chat.browserUtils.js} +1 -1
- package/dist/es/{types/utilities/carbonTypes.js → chat.carbonTypes.js} +2 -2
- package/dist/es/{chat/web-components/components/codeElement/src/codeElement.scss.js → chat.cds-aichat-code.js} +64 -1
- package/dist/es/{chat/shared/utils/constants.js → chat.constants.js} +4 -7
- package/dist/es/{types/events/eventBusTypes.js → chat.customElement.js} +32 -1
- package/dist/es/chat.dynamic-imports.js +192 -0
- package/dist/es/{chat/shared/utils/htmlUtils.js → chat.htmlUtils.js} +16 -2
- package/dist/es/{chat/shared/utils/messageUtils.js → chat.messageUtils.js} +54 -7
- package/dist/es/{chat/shared/utils/miscUtils.js → chat.miscUtils.js} +24 -5
- package/dist/es/chat.resolvablePromise.js +315 -0
- package/dist/es/{chat/shared/store/selectors.js → chat.selectors.js} +1 -1
- package/dist/es/{chat/shared/utils/lang/stringUtils.js → chat.stringUtils.js} +2 -2
- package/dist/es/{chat/shared/hooks/useCounter.js → chat.useCounter.js} +1 -1
- package/dist/es/{chat/shared/hooks/useOnMount.js → chat.useOnMount.js} +1 -1
- package/dist/es/{chat/shared/utils/domUtils.js → chat.usePrevious.js} +47 -1
- package/dist/es/{chat/shared/utils/lang/UUIDType.js → chat.uuid.js} +15 -3
- package/dist/es/web-components/cds-aichat-container/index.js +73 -4
- package/dist/es/web-components/cds-aichat-custom-element/index.js +1 -3
- package/package.json +2 -2
- package/dist/es/chat/dynamic-imports/dynamic-imports.js +0 -96
- package/dist/es/chat/react/components/AppContainer.js +0 -197
- package/dist/es/chat/react/components/UserDefinedResponsePortalsContainer.js +0 -31
- package/dist/es/chat/react/components/WriteableElementsPortalsContainer.js +0 -28
- package/dist/es/chat/react/components/chainOfThought/ChainOfThought.js +0 -20
- package/dist/es/chat/react/components/chatHeader/ChatHeaderAvatar.js +0 -20
- package/dist/es/chat/react/components/chatHeader/ChatHeaderLink.js +0 -22
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenu.js +0 -27
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuButton.js +0 -60
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuItem.js +0 -24
- package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuItemRadioGroup.js +0 -28
- package/dist/es/chat/react/components/chatHeader/ChatHeaderOverflowMenu.js +0 -69
- package/dist/es/chat/react/components/chatHeader/ChatHeaderTitle.js +0 -22
- package/dist/es/chat/react/components/feedback/FeedbackButtonsComponent.js +0 -20
- package/dist/es/chat/react/components/feedback/FeedbackComponent.js +0 -20
- package/dist/es/chat/react/components/inlineLoading/InlineLoadingComponent.js +0 -20
- package/dist/es/chat/react/components/markdownText/MarkdownText.js +0 -20
- package/dist/es/chat/react/components/stopStreamingButton/StopStreamingButton.js +0 -20
- package/dist/es/chat/react/components/table/Table.js +0 -20
- package/dist/es/chat/shared/Chat.js +0 -115
- package/dist/es/chat/shared/ChatInstanceImpl.js +0 -360
- package/dist/es/chat/shared/chatEntryFunctions.js +0 -46
- package/dist/es/chat/shared/components/Avatar.js +0 -286
- package/dist/es/chat/shared/components/BodyWithFooterComponent.js +0 -56
- package/dist/es/chat/shared/components/CatastrophicError.js +0 -77
- package/dist/es/chat/shared/components/Chat.js +0 -244
- package/dist/es/chat/shared/components/ChatBubbleDark.js +0 -124
- package/dist/es/chat/shared/components/ChatBubbleLight.js +0 -216
- package/dist/es/chat/shared/components/Disclaimer.js +0 -86
- package/dist/es/chat/shared/components/ErrorIcon.js +0 -20
- package/dist/es/chat/shared/components/ErrorMessageDark.js +0 -89
- package/dist/es/chat/shared/components/ErrorMessageLight.js +0 -135
- package/dist/es/chat/shared/components/HydrationPanel.js +0 -58
- package/dist/es/chat/shared/components/LatestWelcomeNodes.js +0 -26
- package/dist/es/chat/shared/components/ResponseStopped.js +0 -19
- package/dist/es/chat/shared/components/SkeletonPicker.js +0 -32
- package/dist/es/chat/shared/components/WriteableElement.js +0 -22
- package/dist/es/chat/shared/components/agent/AgentAvatar.js +0 -54
- package/dist/es/chat/shared/components/agent/AgentBanner.js +0 -109
- package/dist/es/chat/shared/components/agent/AgentBannerContainer.js +0 -28
- package/dist/es/chat/shared/components/agent/AvailabilityMessage.js +0 -49
- package/dist/es/chat/shared/components/aria/AriaAnnouncerComponent.js +0 -122
- package/dist/es/chat/shared/components/aria/AriaAnnouncerProvider.js +0 -48
- package/dist/es/chat/shared/components/aria/AriaLiveMessage.js +0 -22
- package/dist/es/chat/shared/components/header/AISlug.js +0 -22
- package/dist/es/chat/shared/components/header/Header.js +0 -460
- package/dist/es/chat/shared/components/header/SimpleHeader.js +0 -27
- package/dist/es/chat/shared/components/homeScreen/HomeScreenContainer.js +0 -68
- package/dist/es/chat/shared/components/launcher/Launcher.js +0 -88
- package/dist/es/chat/shared/components/launcher/LauncherComplex.js +0 -63
- package/dist/es/chat/shared/components/launcher/LauncherContainer.js +0 -73
- package/dist/es/chat/shared/components/launcher/LauncherDesktopContainer.js +0 -221
- package/dist/es/chat/shared/components/launcher/LauncherExtended.js +0 -244
- package/dist/es/chat/shared/components/launcher/LauncherMobileContainer.js +0 -175
- package/dist/es/chat/shared/components/launcher/launcherUtils.js +0 -16
- package/dist/es/chat/shared/components/modals/ConfirmModal.js +0 -67
- package/dist/es/chat/shared/components/modals/EndAgentChatModal.js +0 -46
- package/dist/es/chat/shared/components/modals/RequestScreenShareModal.js +0 -43
- package/dist/es/chat/shared/components/notifications/Notifications.js +0 -58
- package/dist/es/chat/shared/components/panels/CustomPanel.js +0 -136
- package/dist/es/chat/shared/components/responseTypes/agent/ConnectToAgent.js +0 -30
- package/dist/es/chat/shared/components/responseTypes/agent/RealConnectToAgent.js +0 -102
- package/dist/es/chat/shared/components/responseTypes/audio/AudioComponent.js +0 -26
- package/dist/es/chat/shared/components/responseTypes/buttonItem/BaseButtonItemComponent.js +0 -69
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemComponent.js +0 -48
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemCustomEventComponent.js +0 -42
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemPostBackComponent.js +0 -54
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemShowPanelComponent.js +0 -36
- package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemURLComponent.js +0 -42
- package/dist/es/chat/shared/components/responseTypes/card/CardItemComponent.js +0 -34
- package/dist/es/chat/shared/components/responseTypes/carousel/CarouselItemComponent.js +0 -39
- package/dist/es/chat/shared/components/responseTypes/conversationalSearch/ConversationalSearch.js +0 -92
- package/dist/es/chat/shared/components/responseTypes/conversationalSearch/ConversationalSearchText.js +0 -158
- package/dist/es/chat/shared/components/responseTypes/custom/UserDefinedResponse.js +0 -33
- package/dist/es/chat/shared/components/responseTypes/datePicker/DatePickerComponent.js +0 -176
- package/dist/es/chat/shared/components/responseTypes/error/InlineError.js +0 -32
- package/dist/es/chat/shared/components/responseTypes/grid/GridItemComponent.js +0 -109
- package/dist/es/chat/shared/components/responseTypes/iframe/IFrameMessage.js +0 -32
- package/dist/es/chat/shared/components/responseTypes/iframe/IFramePanel.js +0 -51
- package/dist/es/chat/shared/components/responseTypes/iframe/IFramePreviewCard.js +0 -64
- package/dist/es/chat/shared/components/responseTypes/iframe/InlineIFrame.js +0 -55
- package/dist/es/chat/shared/components/responseTypes/image/Image.js +0 -120
- package/dist/es/chat/shared/components/responseTypes/options/OptionComponent.js +0 -83
- package/dist/es/chat/shared/components/responseTypes/options/SelectComponent.js +0 -84
- package/dist/es/chat/shared/components/responseTypes/table/TableContainer.js +0 -96
- package/dist/es/chat/shared/components/responseTypes/text/TextArea.js +0 -68
- package/dist/es/chat/shared/components/responseTypes/tour/TourCard.js +0 -73
- package/dist/es/chat/shared/components/responseTypes/util/BodyMessageComponents.js +0 -65
- package/dist/es/chat/shared/components/responseTypes/util/ClickableImage.js +0 -36
- package/dist/es/chat/shared/components/responseTypes/util/Description.js +0 -21
- package/dist/es/chat/shared/components/responseTypes/util/FooterButtonComponents.js +0 -36
- package/dist/es/chat/shared/components/responseTypes/util/MediaPlayer.js +0 -157
- package/dist/es/chat/shared/components/responseTypes/util/Metablock.js +0 -27
- package/dist/es/chat/shared/components/responseTypes/util/RichText.js +0 -31
- package/dist/es/chat/shared/components/responseTypes/util/SearchResultBody.js +0 -53
- package/dist/es/chat/shared/components/responseTypes/util/StreamingRichText.js +0 -38
- package/dist/es/chat/shared/components/responseTypes/util/TextHolderTile.js +0 -35
- package/dist/es/chat/shared/components/responseTypes/util/citations/CitationCard.js +0 -65
- package/dist/es/chat/shared/components/responseTypes/util/citations/CitationCardContent.js +0 -62
- package/dist/es/chat/shared/components/responseTypes/util/citations/CitationClickableCard.js +0 -23
- package/dist/es/chat/shared/components/responseTypes/util/citations/ExpandToPanelCard.js +0 -50
- package/dist/es/chat/shared/components/responseTypes/util/citations/ViewSourcePanel.js +0 -57
- package/dist/es/chat/shared/components/responseTypes/video/VideoComponent.js +0 -23
- package/dist/es/chat/shared/components/tour/TourCloseMinimizeComponent.js +0 -44
- package/dist/es/chat/shared/components/tour/TourContainer.js +0 -212
- package/dist/es/chat/shared/components/tour/TourControlsComponent.js +0 -98
- package/dist/es/chat/shared/components/tour/TourStepContentComponent.js +0 -156
- package/dist/es/chat/shared/components/tour/TourStepSkeletonComponent.js +0 -20
- package/dist/es/chat/shared/components/util/AnnounceOnMountComponent.js +0 -42
- package/dist/es/chat/shared/components/util/IconHolder.js +0 -16
- package/dist/es/chat/shared/components/util/ImageWithFallback.js +0 -31
- package/dist/es/chat/shared/components/util/MaybeDangerouslySetInnerHTML.js +0 -42
- package/dist/es/chat/shared/components/util/MountChildrenOnDelay.js +0 -40
- package/dist/es/chat/shared/components/util/VisuallyHidden.js +0 -18
- package/dist/es/chat/shared/containers/App.js +0 -181
- package/dist/es/chat/shared/containers/MessageComponent.js +0 -465
- package/dist/es/chat/shared/containers/MessageTypeComponent.js +0 -496
- package/dist/es/chat/shared/containers/MessagesComponent.js +0 -469
- package/dist/es/chat/shared/containers/ModalPortal.js +0 -53
- package/dist/es/chat/shared/containers/main/MainWindow.js +0 -708
- package/dist/es/chat/shared/contexts/AriaAnnouncerContext.js +0 -12
- package/dist/es/chat/shared/contexts/HideComponentContext.js +0 -12
- package/dist/es/chat/shared/contexts/LanguagePackContext.js +0 -12
- package/dist/es/chat/shared/contexts/ModalPortalRootContext.js +0 -12
- package/dist/es/chat/shared/contexts/ServiceManagerContext.js +0 -12
- package/dist/es/chat/shared/contexts/WindowSizeContext.js +0 -12
- package/dist/es/chat/shared/environmentVariables.js +0 -13
- package/dist/es/chat/shared/events/ChatActionsImpl.js +0 -783
- package/dist/es/chat/shared/events/EventBus.js +0 -161
- package/dist/es/chat/shared/hocs/withAriaAnnouncer.js +0 -25
- package/dist/es/chat/shared/hocs/withServiceManager.js +0 -25
- package/dist/es/chat/shared/hooks/useAriaAnnouncer.js +0 -16
- package/dist/es/chat/shared/hooks/useCSSCustomProperties.js +0 -21
- package/dist/es/chat/shared/hooks/useCallbackOnChange.js +0 -24
- package/dist/es/chat/shared/hooks/useEffectDidUpdate.js +0 -21
- package/dist/es/chat/shared/hooks/useLanguagePack.js +0 -16
- package/dist/es/chat/shared/hooks/usePrevious.js +0 -18
- package/dist/es/chat/shared/hooks/useServiceManager.js +0 -16
- package/dist/es/chat/shared/hooks/useShouldSanitizeHTML.js +0 -15
- package/dist/es/chat/shared/hooks/useUUID.js +0 -22
- package/dist/es/chat/shared/hooks/useWindowSize.js +0 -16
- package/dist/es/chat/shared/loadServices.js +0 -72
- package/dist/es/chat/shared/schema/historyToMessages.js +0 -231
- package/dist/es/chat/shared/schema/inputItemToLocalItem.js +0 -30
- package/dist/es/chat/shared/schema/outputItemToLocalItem.js +0 -124
- package/dist/es/chat/shared/services/CustomPanelInstance.js +0 -26
- package/dist/es/chat/shared/services/CustomPanelManager.js +0 -23
- package/dist/es/chat/shared/services/HistoryService.js +0 -59
- package/dist/es/chat/shared/services/MessageService.js +0 -351
- package/dist/es/chat/shared/services/NamespaceService.js +0 -26
- package/dist/es/chat/shared/services/ServiceManager.js +0 -19
- package/dist/es/chat/shared/services/UserSessionStorageService.js +0 -89
- package/dist/es/chat/shared/services/haa/agentStatusMessage.js +0 -108
- package/dist/es/chat/shared/services/haa/humanAgentUtils.js +0 -114
- package/dist/es/chat/shared/services/mockStorage.js +0 -30
- package/dist/es/chat/shared/store/agentActions.js +0 -125
- package/dist/es/chat/shared/store/agentReducers.js +0 -215
- package/dist/es/chat/shared/store/doCreateStore.js +0 -142
- package/dist/es/chat/shared/store/reducerUtils.js +0 -320
- package/dist/es/chat/shared/store/reducers.js +0 -871
- package/dist/es/chat/shared/store/subscriptions.js +0 -55
- package/dist/es/chat/shared/store/tourReducerUtils.js +0 -51
- package/dist/es/chat/shared/utils/ListenerList.js +0 -26
- package/dist/es/chat/shared/utils/PageObjectId.js +0 -25
- package/dist/es/chat/shared/utils/animationUtils.js +0 -77
- package/dist/es/chat/shared/utils/colors.js +0 -71
- package/dist/es/chat/shared/utils/customizers.js +0 -16
- package/dist/es/chat/shared/utils/dateUtils.js +0 -38
- package/dist/es/chat/shared/utils/homeScreenUtils.js +0 -27
- package/dist/es/chat/shared/utils/intlUtils.js +0 -21
- package/dist/es/chat/shared/utils/lang/arrayUtils.js +0 -53
- package/dist/es/chat/shared/utils/lang/langUtils.js +0 -13
- package/dist/es/chat/shared/utils/lang/objectUtils.js +0 -19
- package/dist/es/chat/shared/utils/lang/promiseUtils.js +0 -25
- package/dist/es/chat/shared/utils/lang/uuid.js +0 -16
- package/dist/es/chat/shared/utils/languages.js +0 -156
- package/dist/es/chat/shared/utils/memoizerUtils.js +0 -38
- package/dist/es/chat/shared/utils/messageServiceUtils.js +0 -36
- package/dist/es/chat/shared/utils/resolvablePromise.js +0 -32
- package/dist/es/chat/shared/utils/styleUtils.js +0 -231
- package/dist/es/chat/shared/utils/timeUtils.js +0 -14
- package/dist/es/chat/shared/utils/viewStateUtils.js +0 -38
- package/dist/es/chat/web-components/components/chainOfThought/cds-aichat-chain-of-thought.js +0 -26
- package/dist/es/chat/web-components/components/chainOfThought/src/ChainOfThoughtElement.js +0 -130
- package/dist/es/chat/web-components/components/chainOfThought/src/chainOfThoughtElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/chainOfThought/src/chainOfThoughtElement.template.js +0 -186
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/cds-aichat-chat-header-avatar.js +0 -26
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatar.template.js +0 -32
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatarElement.js +0 -52
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatarElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderLink/cds-aichat-chat-header-link.js +0 -44
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderLink/src/chatHeaderLinkElement.template.js +0 -28
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/cds-aichat-chat-header-title.js +0 -42
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/src/chatHeaderTitle.scss.js +0 -3
- package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/src/chatHeaderTitle.template.js +0 -20
- package/dist/es/chat/web-components/components/codeElement/cds-aichat-code.js +0 -66
- package/dist/es/chat/web-components/components/feedbackButtonsElement/cds-aichat-feedback-buttons.js +0 -26
- package/dist/es/chat/web-components/components/feedbackButtonsElement/src/FeedbackButtonsElement.js +0 -93
- package/dist/es/chat/web-components/components/feedbackButtonsElement/src/feedbackButtonsElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/feedbackButtonsElement/src/feedbackButtonsElement.template.js +0 -84
- package/dist/es/chat/web-components/components/feedbackElement/cds-aichat-feedback.js +0 -30
- package/dist/es/chat/web-components/components/feedbackElement/src/FeedbackElement.js +0 -157
- package/dist/es/chat/web-components/components/feedbackElement/src/feedbackElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/feedbackElement/src/feedbackElement.template.js +0 -95
- package/dist/es/chat/web-components/components/inlineLoadingElement/cds-aichat-inline-loading.js +0 -85
- package/dist/es/chat/web-components/components/inlineLoadingElement/src/styles.scss.js +0 -3
- package/dist/es/chat/web-components/components/markdownText/cds-aichat-markdown-text.js +0 -32
- package/dist/es/chat/web-components/components/markdownText/markdown/markdownToHTML.js +0 -28
- package/dist/es/chat/web-components/components/markdownText/markdown/utils/renderTokenTree.js +0 -191
- package/dist/es/chat/web-components/components/markdownText/markdown/workers/workerManager.js +0 -16
- package/dist/es/chat/web-components/components/markdownText/src/MarkdownElement.js +0 -70
- package/dist/es/chat/web-components/components/markdownText/src/markdownElement.template.js +0 -19
- package/dist/es/chat/web-components/components/roundedButton/cds-aichat-rounded-button.js +0 -29
- package/dist/es/chat/web-components/components/stopStreamingButton/cds-aichat-stop-streaming-button.js +0 -26
- package/dist/es/chat/web-components/components/stopStreamingButton/src/StopStreamingButtonElement.js +0 -49
- package/dist/es/chat/web-components/components/stopStreamingButton/src/stopStreamingButton.scss.js +0 -3
- package/dist/es/chat/web-components/components/stopStreamingButton/src/stopStreamingButton.template.js +0 -44
- package/dist/es/chat/web-components/components/table/cds-aichat-table.js +0 -229
- package/dist/es/chat/web-components/components/table/src/table.scss.js +0 -3
- package/dist/es/chat/web-components/components/table/src/table.template.js +0 -81
- package/dist/es/chat/web-components/components/table/src/tablePagination.template.js +0 -43
- package/dist/es/chat/web-components/components/table/src/tableSkeleton.template.js +0 -17
- package/dist/es/chat/web-components/components/tagListElement/cds-aichat-tag-list.js +0 -28
- package/dist/es/chat/web-components/components/tagListElement/src/TagListElement.js +0 -70
- package/dist/es/chat/web-components/components/tagListElement/src/tagListElement.scss.js +0 -3
- package/dist/es/chat/web-components/components/tagListElement/src/tagListElement.template.js +0 -40
- package/dist/es/chat/web-components/decorators/customElement.js +0 -33
- package/dist/es/chat/web-components/internal/cds-aichat-internal.js +0 -78
- package/dist/es/chat/web-components/settings.js +0 -13
- package/dist/es/node_modules/@carbon/colors/es/index.js +0 -11
- package/dist/es/react/ChatContainer.js +0 -162
- package/dist/es/react/ChatCustomElement.js +0 -58
- package/dist/es/types/config/ChatHeaderConfig.js +0 -18
- package/dist/es/types/config/CornersType.js +0 -16
- package/dist/es/types/config/LauncherConfig.js +0 -19
- package/dist/es/types/config/PublicConfig.js +0 -36
- package/dist/es/types/instance/ChatInstance.js +0 -31
- package/dist/es/types/instance/apiTypes.js +0 -33
- package/dist/es/types/messaging/LocalMessageItem.js +0 -18
- package/dist/es/types/state/AppState.js +0 -18
- package/dist/es/types/utilities/Animation.js +0 -31
- package/dist/es/types/utilities/HasAddRemoveClassName.js +0 -27
- /package/dist/es/{chat/shared/styles/export.carbon.scss.js → chat.export.carbon.js} +0 -0
- /package/dist/es/{chat/shared/styles/export.scss.js → chat.export.js} +0 -0
- /package/dist/es/{chat/web-components/components/markdownText/markdown/utils/markdown.js → chat.markdown.js} +0 -0
- /package/dist/es/{chat/web-components/components/markdownText/markdown/utils/tokenTree.js → chat.tokenTree.js} +0 -0
|
@@ -0,0 +1,1025 @@
|
|
|
1
|
+
import "@carbon/web-components/es-custom/components/slug/index.js";
|
|
2
|
+
|
|
3
|
+
import Close from "@carbon/icons-react/es/Close.js";
|
|
4
|
+
|
|
5
|
+
import CloseLarge from "@carbon/icons-react/es/CloseLarge.js";
|
|
6
|
+
|
|
7
|
+
import DownToBottom from "@carbon/icons-react/es/DownToBottom.js";
|
|
8
|
+
|
|
9
|
+
import Menu$1 from "@carbon/icons-react/es/Menu.js";
|
|
10
|
+
|
|
11
|
+
import Restart from "@carbon/icons-react/es/Restart.js";
|
|
12
|
+
|
|
13
|
+
import SidePanelClose from "@carbon/icons-react/es/SidePanelClose.js";
|
|
14
|
+
|
|
15
|
+
import SubtractLarge from "@carbon/icons-react/es/SubtractLarge.js";
|
|
16
|
+
|
|
17
|
+
import { Button, Menu, MenuItem, MenuItemRadioGroup, MenuItemDivider } from "@carbon/react";
|
|
18
|
+
|
|
19
|
+
import { AI_LABEL_SIZE } from "@carbon/web-components/es-custom/components/ai-label/defs.js";
|
|
20
|
+
|
|
21
|
+
import { POPOVER_ALIGNMENT } from "@carbon/web-components/es-custom/components/popover/defs.js";
|
|
22
|
+
|
|
23
|
+
import cx from "classnames";
|
|
24
|
+
|
|
25
|
+
import React, { useContext, useEffect, Component, useRef, useState, forwardRef, useCallback, useImperativeHandle, Fragment } from "react";
|
|
26
|
+
|
|
27
|
+
import { useSelector } from "react-redux";
|
|
28
|
+
|
|
29
|
+
import { m as makeTestId, P as PageObjectId, C as ChatHeaderObjectType } from "./chat.PageObjectId.js";
|
|
30
|
+
|
|
31
|
+
import { createComponent } from "@lit/react";
|
|
32
|
+
|
|
33
|
+
import { __decorate } from "tslib";
|
|
34
|
+
|
|
35
|
+
import { c as carbonElement } from "./chat.customElement.js";
|
|
36
|
+
|
|
37
|
+
import "@carbon/web-components/es-custom/components/skeleton-icon/index.js";
|
|
38
|
+
|
|
39
|
+
import { html, LitElement, unsafeCSS, css } from "lit";
|
|
40
|
+
|
|
41
|
+
import { a as CornersType, M as MinimizeButtonIconType, W as WriteableElementName } from "./chat.dynamic-imports.js";
|
|
42
|
+
|
|
43
|
+
import { bind } from "bind-decorator";
|
|
44
|
+
|
|
45
|
+
import { property, state } from "lit/decorators.js";
|
|
46
|
+
|
|
47
|
+
import "@carbon/web-components/es-custom/components/button/index.js";
|
|
48
|
+
|
|
49
|
+
import "@carbon/web-components/es-custom/components/overflow-menu/index.js";
|
|
50
|
+
|
|
51
|
+
import { a as ButtonKindEnum, B as ButtonSizeEnum } from "./chat.carbonTypes.js";
|
|
52
|
+
|
|
53
|
+
import ChevronDown from "@carbon/icons-react/es/ChevronDown.js";
|
|
54
|
+
|
|
55
|
+
import ChevronUp from "@carbon/icons-react/es/ChevronUp.js";
|
|
56
|
+
|
|
57
|
+
import { useFloating, useInteractions, useClick, useDismiss } from "@floating-ui/react";
|
|
58
|
+
|
|
59
|
+
import { u as uuid, U as UUIDType } from "./chat.uuid.js";
|
|
60
|
+
|
|
61
|
+
import { a as HideComponentContext } from "./chat.HideComponent.js";
|
|
62
|
+
|
|
63
|
+
import { u as useLanguagePack, C as ChatWidthBreakpoint } from "./chat.AppState.js";
|
|
64
|
+
|
|
65
|
+
import { A as AriaAnnouncerContext, u as useServiceManager, b as usePrevious, d as doFocusRef } from "./chat.usePrevious.js";
|
|
66
|
+
|
|
67
|
+
import { a as actions } from "./chat.actions.js";
|
|
68
|
+
|
|
69
|
+
import "./chat.constants.js";
|
|
70
|
+
|
|
71
|
+
import FocusTrap from "focus-trap-react";
|
|
72
|
+
|
|
73
|
+
import ReactDOM from "react-dom";
|
|
74
|
+
|
|
75
|
+
import "@carbon/web-components/es-custom/components/ai-label/ai-label-action-button.js";
|
|
76
|
+
|
|
77
|
+
import CDSAILabel from "@carbon/web-components/es-custom/components/ai-label/ai-label.js";
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
* Copyright IBM Corp. 2025
|
|
81
|
+
*
|
|
82
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
83
|
+
* LICENSE file in the root directory of this source tree.
|
|
84
|
+
*
|
|
85
|
+
* @license
|
|
86
|
+
*/ const CSS_CLASS_PREFIX = "cds--aichat";
|
|
87
|
+
|
|
88
|
+
const WEB_COMPONENT_PREFIX = "cds-aichat";
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* Copyright IBM Corp. 2025
|
|
92
|
+
*
|
|
93
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
94
|
+
* LICENSE file in the root directory of this source tree.
|
|
95
|
+
*
|
|
96
|
+
* @license
|
|
97
|
+
*/ function AriaLiveMessage(props) {
|
|
98
|
+
const ariaAnnouncer = useContext(AriaAnnouncerContext);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
ariaAnnouncer(props.message);
|
|
101
|
+
}, [ ariaAnnouncer, props.message ]);
|
|
102
|
+
return React.createElement("div", null);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const AriaLiveMessageExport = React.memo(AriaLiveMessage);
|
|
106
|
+
|
|
107
|
+
/*
|
|
108
|
+
* Copyright IBM Corp. 2025
|
|
109
|
+
*
|
|
110
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
111
|
+
* LICENSE file in the root directory of this source tree.
|
|
112
|
+
*
|
|
113
|
+
* @license
|
|
114
|
+
*/ function WriteableElement({slotName: slotName, id: id, className: className}) {
|
|
115
|
+
return React.createElement("div", {
|
|
116
|
+
className: className,
|
|
117
|
+
id: id,
|
|
118
|
+
"data-floating-menu-container": true
|
|
119
|
+
}, React.createElement("slot", {
|
|
120
|
+
name: slotName
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var WriteableElement$1 = React.memo(WriteableElement);
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
* Copyright IBM Corp. 2025
|
|
128
|
+
*
|
|
129
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
130
|
+
* LICENSE file in the root directory of this source tree.
|
|
131
|
+
*
|
|
132
|
+
* @license
|
|
133
|
+
*/ const ModalPortalRootContext = React.createContext(null);
|
|
134
|
+
|
|
135
|
+
/*
|
|
136
|
+
* Copyright IBM Corp. 2025
|
|
137
|
+
*
|
|
138
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
139
|
+
* LICENSE file in the root directory of this source tree.
|
|
140
|
+
*
|
|
141
|
+
* @license
|
|
142
|
+
*/ class ModalPortal extends Component {
|
|
143
|
+
constructor() {
|
|
144
|
+
super(...arguments);
|
|
145
|
+
this.state = {
|
|
146
|
+
attachedToHost: null
|
|
147
|
+
};
|
|
148
|
+
this.modalElement = document.createElement("div");
|
|
149
|
+
}
|
|
150
|
+
componentDidMount() {
|
|
151
|
+
this.attachIfNeeded();
|
|
152
|
+
}
|
|
153
|
+
componentDidUpdate() {
|
|
154
|
+
this.attachIfNeeded();
|
|
155
|
+
}
|
|
156
|
+
componentWillUnmount() {
|
|
157
|
+
if (this.state.attachedToHost) {
|
|
158
|
+
this.state.attachedToHost.removeChild(this.modalElement);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
attachIfNeeded() {
|
|
162
|
+
const hostElement = this.context;
|
|
163
|
+
if (hostElement && !this.state.attachedToHost) {
|
|
164
|
+
this.setState({
|
|
165
|
+
attachedToHost: hostElement
|
|
166
|
+
});
|
|
167
|
+
hostElement.appendChild(this.modalElement);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
render() {
|
|
171
|
+
if (!this.state.attachedToHost) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
return ReactDOM.createPortal(this.props.children, this.modalElement);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
ModalPortal.contextType = ModalPortalRootContext;
|
|
179
|
+
|
|
180
|
+
/*
|
|
181
|
+
* Copyright IBM Corp. 2025
|
|
182
|
+
*
|
|
183
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
184
|
+
* LICENSE file in the root directory of this source tree.
|
|
185
|
+
*
|
|
186
|
+
* @license
|
|
187
|
+
*/ class ConfirmModal extends Component {
|
|
188
|
+
constructor() {
|
|
189
|
+
super(...arguments);
|
|
190
|
+
this.onYesClick = () => {
|
|
191
|
+
this.props.onConfirm();
|
|
192
|
+
};
|
|
193
|
+
this.onNoClick = () => {
|
|
194
|
+
this.props.onCancel();
|
|
195
|
+
};
|
|
196
|
+
this.onKeyDown = event => {
|
|
197
|
+
if (event.key === "Escape") {
|
|
198
|
+
this.props.onCancel();
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
render() {
|
|
203
|
+
const {title: title, message: message, cancelButtonLabel: cancelButtonLabel, confirmButtonLabel: confirmButtonLabel, modalAnnounceMessage: modalAnnounceMessage, serviceManager: serviceManager} = this.props;
|
|
204
|
+
return React.createElement(ModalPortal, null, React.createElement(FocusTrap, null, React.createElement("div", {
|
|
205
|
+
className: "WACConfirmModal",
|
|
206
|
+
role: "dialog",
|
|
207
|
+
"aria-labelledby": `WACConfirmModal__title${serviceManager.namespace.suffix}`,
|
|
208
|
+
"aria-describedby": `WACConfirmModal__message${serviceManager.namespace.suffix}`
|
|
209
|
+
}, React.createElement("div", {
|
|
210
|
+
className: "WACConfirmModal__container"
|
|
211
|
+
}, React.createElement(AriaLiveMessageExport, {
|
|
212
|
+
message: modalAnnounceMessage
|
|
213
|
+
}), React.createElement("div", {
|
|
214
|
+
className: "WACConfirmModal__title",
|
|
215
|
+
id: `WACConfirmModal__title${serviceManager.namespace.suffix}`
|
|
216
|
+
}, title), React.createElement("div", {
|
|
217
|
+
className: "WACConfirmModal__message",
|
|
218
|
+
id: `WACConfirmModal__message${serviceManager.namespace.suffix}`
|
|
219
|
+
}, message), React.createElement("div", {
|
|
220
|
+
className: "WACConfirmModal__buttonContainer"
|
|
221
|
+
}, React.createElement(Button, {
|
|
222
|
+
className: "WACConfirmModal__NoButton",
|
|
223
|
+
kind: "secondary",
|
|
224
|
+
onClick: this.onNoClick,
|
|
225
|
+
onKeyDown: this.onKeyDown,
|
|
226
|
+
size: "md"
|
|
227
|
+
}, cancelButtonLabel), React.createElement(Button, {
|
|
228
|
+
className: "WACConfirmModal__YesButton",
|
|
229
|
+
onClick: this.onYesClick,
|
|
230
|
+
onKeyDown: this.onKeyDown,
|
|
231
|
+
size: "md"
|
|
232
|
+
}, confirmButtonLabel))))));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/*
|
|
237
|
+
* Copyright IBM Corp. 2025
|
|
238
|
+
*
|
|
239
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
240
|
+
* LICENSE file in the root directory of this source tree.
|
|
241
|
+
*
|
|
242
|
+
* @license
|
|
243
|
+
*/ function useUUID() {
|
|
244
|
+
const ref = useRef();
|
|
245
|
+
if (ref.current === undefined) {
|
|
246
|
+
ref.current = uuid(UUIDType.COMPONENT);
|
|
247
|
+
}
|
|
248
|
+
return ref.current;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/*
|
|
252
|
+
* Copyright IBM Corp. 2025
|
|
253
|
+
*
|
|
254
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
255
|
+
* LICENSE file in the root directory of this source tree.
|
|
256
|
+
*
|
|
257
|
+
* @license
|
|
258
|
+
*/ function chatHeaderAvatarTemplate(classElement) {
|
|
259
|
+
const {url: url, corners: corners, alt: alt, onError: onError} = classElement;
|
|
260
|
+
return html`
|
|
261
|
+
<img
|
|
262
|
+
class="${cx(`${CSS_CLASS_PREFIX}-chat-header-avatar`, {
|
|
263
|
+
[`${CSS_CLASS_PREFIX}-chat-header-avatar--round`]: corners === CornersType.ROUND
|
|
264
|
+
})}"
|
|
265
|
+
src="${url}"
|
|
266
|
+
alt="${alt}"
|
|
267
|
+
@error="${onError}"
|
|
268
|
+
/>
|
|
269
|
+
`;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
var css_248z$1 = ".cds--aichat-chat-header-avatar{\n display:block;\n block-size:20px;\n max-block-size:20px;\n}\n\n.cds--aichat-chat-header-avatar--round{\n border-radius:10px;\n}";
|
|
273
|
+
|
|
274
|
+
/*
|
|
275
|
+
* Copyright IBM Corp. 2025
|
|
276
|
+
*
|
|
277
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
278
|
+
* LICENSE file in the root directory of this source tree.
|
|
279
|
+
*
|
|
280
|
+
* @license
|
|
281
|
+
*/ class ChatHeaderAvatarElement extends LitElement {
|
|
282
|
+
constructor() {
|
|
283
|
+
super(...arguments);
|
|
284
|
+
this.isLoaded = false;
|
|
285
|
+
}
|
|
286
|
+
_handleOnError() {
|
|
287
|
+
this.onError?.();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
ChatHeaderAvatarElement.styles = css`
|
|
292
|
+
${unsafeCSS(css_248z$1)}
|
|
293
|
+
`;
|
|
294
|
+
|
|
295
|
+
__decorate([ property({
|
|
296
|
+
type: String
|
|
297
|
+
}) ], ChatHeaderAvatarElement.prototype, "url", void 0);
|
|
298
|
+
|
|
299
|
+
__decorate([ property({
|
|
300
|
+
type: String
|
|
301
|
+
}) ], ChatHeaderAvatarElement.prototype, "corners", void 0);
|
|
302
|
+
|
|
303
|
+
__decorate([ property({
|
|
304
|
+
type: String
|
|
305
|
+
}) ], ChatHeaderAvatarElement.prototype, "alt", void 0);
|
|
306
|
+
|
|
307
|
+
__decorate([ property({
|
|
308
|
+
type: Object
|
|
309
|
+
}) ], ChatHeaderAvatarElement.prototype, "onError", void 0);
|
|
310
|
+
|
|
311
|
+
__decorate([ state() ], ChatHeaderAvatarElement.prototype, "isLoaded", void 0);
|
|
312
|
+
|
|
313
|
+
__decorate([ bind ], ChatHeaderAvatarElement.prototype, "_handleOnError", null);
|
|
314
|
+
|
|
315
|
+
/*
|
|
316
|
+
* Copyright IBM Corp. 2025
|
|
317
|
+
*
|
|
318
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
319
|
+
* LICENSE file in the root directory of this source tree.
|
|
320
|
+
*
|
|
321
|
+
* @license
|
|
322
|
+
*/ const CHAT_HEADER_AVATAR_TAG_NAME = "cds-aichat-chat-header-avatar";
|
|
323
|
+
|
|
324
|
+
let CDSChatHeaderAvatarElement = class CDSChatHeaderAvatarElement extends ChatHeaderAvatarElement {
|
|
325
|
+
render() {
|
|
326
|
+
return chatHeaderAvatarTemplate(this);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
CDSChatHeaderAvatarElement = __decorate([ carbonElement(CHAT_HEADER_AVATAR_TAG_NAME) ], CDSChatHeaderAvatarElement);
|
|
331
|
+
|
|
332
|
+
/*
|
|
333
|
+
* Copyright IBM Corp. 2025
|
|
334
|
+
*
|
|
335
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
336
|
+
* LICENSE file in the root directory of this source tree.
|
|
337
|
+
*
|
|
338
|
+
* @license
|
|
339
|
+
*/ const ChatHeaderAvatar = createComponent({
|
|
340
|
+
tagName: CHAT_HEADER_AVATAR_TAG_NAME,
|
|
341
|
+
elementClass: CDSChatHeaderAvatarElement,
|
|
342
|
+
react: React
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
/*
|
|
346
|
+
* Copyright IBM Corp. 2025
|
|
347
|
+
*
|
|
348
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
349
|
+
* LICENSE file in the root directory of this source tree.
|
|
350
|
+
*
|
|
351
|
+
* @license
|
|
352
|
+
*/ function chatHeaderLinkTemplate(customElementClass) {
|
|
353
|
+
const {label: label, url: url, isNewTab: isNewTab} = customElementClass;
|
|
354
|
+
return html`<cds-custom-button
|
|
355
|
+
class="WACChatHeaderLink"
|
|
356
|
+
href="${url}"
|
|
357
|
+
target="${isNewTab ? "_blank" : "_self"}"
|
|
358
|
+
kind="${ButtonKindEnum.GHOST}"
|
|
359
|
+
size="md"
|
|
360
|
+
>${label}</cds-custom-button
|
|
361
|
+
>`;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/*
|
|
365
|
+
* Copyright IBM Corp. 2025
|
|
366
|
+
*
|
|
367
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
368
|
+
* LICENSE file in the root directory of this source tree.
|
|
369
|
+
*
|
|
370
|
+
* @license
|
|
371
|
+
*/ let ChatHeaderLinkElement = class ChatHeaderLinkElement extends LitElement {
|
|
372
|
+
constructor() {
|
|
373
|
+
super(...arguments);
|
|
374
|
+
this.isNewTab = true;
|
|
375
|
+
}
|
|
376
|
+
render() {
|
|
377
|
+
return chatHeaderLinkTemplate(this);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
__decorate([ property({
|
|
382
|
+
type: String
|
|
383
|
+
}) ], ChatHeaderLinkElement.prototype, "url", void 0);
|
|
384
|
+
|
|
385
|
+
__decorate([ property({
|
|
386
|
+
type: String
|
|
387
|
+
}) ], ChatHeaderLinkElement.prototype, "label", void 0);
|
|
388
|
+
|
|
389
|
+
__decorate([ property({
|
|
390
|
+
type: Boolean
|
|
391
|
+
}) ], ChatHeaderLinkElement.prototype, "isNewTab", void 0);
|
|
392
|
+
|
|
393
|
+
ChatHeaderLinkElement = __decorate([ carbonElement(`${WEB_COMPONENT_PREFIX}-chat-header-link`) ], ChatHeaderLinkElement);
|
|
394
|
+
|
|
395
|
+
/*
|
|
396
|
+
* Copyright IBM Corp. 2025
|
|
397
|
+
*
|
|
398
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
399
|
+
* LICENSE file in the root directory of this source tree.
|
|
400
|
+
*
|
|
401
|
+
* @license
|
|
402
|
+
*/ const ChatHeaderLink = createComponent({
|
|
403
|
+
tagName: `${WEB_COMPONENT_PREFIX}-chat-header-link`,
|
|
404
|
+
elementClass: ChatHeaderLinkElement,
|
|
405
|
+
react: React
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
/*
|
|
409
|
+
* Copyright IBM Corp. 2025
|
|
410
|
+
*
|
|
411
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
412
|
+
* LICENSE file in the root directory of this source tree.
|
|
413
|
+
*
|
|
414
|
+
* @license
|
|
415
|
+
*/ function ChatHeaderMenu({id: id, className: className, label: label, isOpen: isOpen, target: target, children: children, menuAlignment: menuAlignment, containerRef: containerRef}) {
|
|
416
|
+
return React.createElement(Menu, {
|
|
417
|
+
id: id,
|
|
418
|
+
className: className,
|
|
419
|
+
open: isOpen,
|
|
420
|
+
target: target,
|
|
421
|
+
label: label,
|
|
422
|
+
size: "md",
|
|
423
|
+
menuAlignment: menuAlignment,
|
|
424
|
+
mode: "full",
|
|
425
|
+
legacyAutoalign: false,
|
|
426
|
+
containerRef: containerRef
|
|
427
|
+
}, children);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/*
|
|
431
|
+
* Copyright IBM Corp. 2025
|
|
432
|
+
*
|
|
433
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
434
|
+
* LICENSE file in the root directory of this source tree.
|
|
435
|
+
*
|
|
436
|
+
* @license
|
|
437
|
+
*/ function ChatHeaderMenuButton(props) {
|
|
438
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
439
|
+
const {refs: menuRefs, context: menuContext} = useFloating({
|
|
440
|
+
open: isOpen,
|
|
441
|
+
onOpenChange: setIsOpen
|
|
442
|
+
});
|
|
443
|
+
const {getReferenceProps: getMenuReferenceProps, getFloatingProps: getMenuFloatingProps} = useInteractions([ useClick(menuContext), useDismiss(menuContext) ]);
|
|
444
|
+
const id = useUUID();
|
|
445
|
+
return React.createElement("div", {
|
|
446
|
+
ref: menuRefs.setReference,
|
|
447
|
+
"aria-owns": id,
|
|
448
|
+
...getMenuReferenceProps()
|
|
449
|
+
}, React.createElement(Button, {
|
|
450
|
+
size: ButtonSizeEnum.MEDIUM,
|
|
451
|
+
kind: ButtonKindEnum.GHOST,
|
|
452
|
+
onClick: () => setIsOpen(!isOpen),
|
|
453
|
+
renderIcon: isOpen ? ChevronUp : ChevronDown,
|
|
454
|
+
onMouseDown: event => event.preventDefault(),
|
|
455
|
+
"aria-label": props.ariaLabel,
|
|
456
|
+
"aria-haspopup": true,
|
|
457
|
+
"aria-expanded": isOpen,
|
|
458
|
+
"aria-controls": id
|
|
459
|
+
}, props.label), React.createElement(ChatHeaderMenu, {
|
|
460
|
+
id: id,
|
|
461
|
+
isOpen: isOpen,
|
|
462
|
+
target: menuRefs.floating.current,
|
|
463
|
+
label: props.label,
|
|
464
|
+
containerRef: props.containerRef,
|
|
465
|
+
menuAlignment: props.menuAlignment
|
|
466
|
+
}, props.children), React.createElement("div", {
|
|
467
|
+
ref: menuRefs.setFloating,
|
|
468
|
+
className: "WAChatHeaderMenuButton_HostElement",
|
|
469
|
+
...getMenuFloatingProps()
|
|
470
|
+
}));
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/*
|
|
474
|
+
* Copyright IBM Corp. 2025
|
|
475
|
+
*
|
|
476
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
477
|
+
* LICENSE file in the root directory of this source tree.
|
|
478
|
+
*
|
|
479
|
+
* @license
|
|
480
|
+
*/ function ChatHeaderMenuItem({label: label, url: url, isNewTab: isNewTab = true, onClick: onClick, children: children}) {
|
|
481
|
+
return React.createElement(MenuItem, {
|
|
482
|
+
label: label,
|
|
483
|
+
onClick: () => {
|
|
484
|
+
onClick?.();
|
|
485
|
+
if (url) {
|
|
486
|
+
window.open(url, isNewTab ? "_blank" : "_self");
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}, children);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/*
|
|
493
|
+
* Copyright IBM Corp. 2025
|
|
494
|
+
*
|
|
495
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
496
|
+
* LICENSE file in the root directory of this source tree.
|
|
497
|
+
*
|
|
498
|
+
* @license
|
|
499
|
+
*/ function ChatHeaderMenuItemRadioGroup(props) {
|
|
500
|
+
const {label: label, items: items, defaultSelectedItem: defaultSelectedItem, selectedItem: selectedItem, onChange: onChange} = props;
|
|
501
|
+
return React.createElement(MenuItemRadioGroup, {
|
|
502
|
+
label: label,
|
|
503
|
+
items: items,
|
|
504
|
+
defaultSelectedItem: defaultSelectedItem,
|
|
505
|
+
selectedItem: selectedItem,
|
|
506
|
+
onChange: selectedItem => {
|
|
507
|
+
if (!selectedItem.preventDefault) {
|
|
508
|
+
onChange(selectedItem);
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
itemToString: menuItem => typeof menuItem === "string" ? menuItem : menuItem.label || menuItem.value
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/*
|
|
516
|
+
* Copyright IBM Corp. 2025
|
|
517
|
+
*
|
|
518
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
519
|
+
* LICENSE file in the root directory of this source tree.
|
|
520
|
+
*
|
|
521
|
+
* @license
|
|
522
|
+
*/ function ChatHeaderOverflowMenu(props) {
|
|
523
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
524
|
+
const {refs: menuRefs, context: menuContext} = useFloating({
|
|
525
|
+
open: isOpen,
|
|
526
|
+
onOpenChange: isOpen => {
|
|
527
|
+
setIsOpen(isOpen);
|
|
528
|
+
if (isOpen) {
|
|
529
|
+
props.onOpen?.();
|
|
530
|
+
} else {
|
|
531
|
+
props.onClose?.();
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
const {getReferenceProps: getMenuReferenceProps, getFloatingProps: getMenuFloatingProps} = useInteractions([ useClick(menuContext), useDismiss(menuContext) ]);
|
|
536
|
+
const id = useUUID();
|
|
537
|
+
return React.createElement("div", {
|
|
538
|
+
ref: menuRefs.setReference,
|
|
539
|
+
"aria-owns": id,
|
|
540
|
+
...getMenuReferenceProps()
|
|
541
|
+
}, React.createElement(Button, {
|
|
542
|
+
className: cx("WACChatHeaderOverflowMenu__Button", props.className),
|
|
543
|
+
size: ButtonSizeEnum.MEDIUM,
|
|
544
|
+
kind: ButtonKindEnum.GHOST,
|
|
545
|
+
onClick: () => setIsOpen(!isOpen),
|
|
546
|
+
tooltipPosition: props.tooltipPosition,
|
|
547
|
+
renderIcon: props.renderIcon,
|
|
548
|
+
onMouseDown: event => event.preventDefault(),
|
|
549
|
+
iconDescription: props.iconDescription,
|
|
550
|
+
hasIconOnly: true,
|
|
551
|
+
"aria-label": props.ariaLabel,
|
|
552
|
+
"aria-haspopup": true,
|
|
553
|
+
"aria-expanded": isOpen,
|
|
554
|
+
"aria-controls": id
|
|
555
|
+
}), React.createElement(ChatHeaderMenu, {
|
|
556
|
+
id: id,
|
|
557
|
+
label: props.ariaLabel,
|
|
558
|
+
isOpen: isOpen,
|
|
559
|
+
target: menuRefs.floating.current,
|
|
560
|
+
containerRef: props.containerRef,
|
|
561
|
+
menuAlignment: props.menuAlignment
|
|
562
|
+
}, props.children), React.createElement("div", {
|
|
563
|
+
ref: menuRefs.setFloating,
|
|
564
|
+
className: "WACChatHeaderOverflowMenu__HostElement",
|
|
565
|
+
...getMenuFloatingProps()
|
|
566
|
+
}));
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
var css_248z = "cds-chat-header-title{\n text-align:center;\n}\n\n.WACChatHeaderTitle{\n overflow:hidden;\n font-size:var(--cds-chat-BASE-font-size-med);\n font-weight:400;\n line-height:var(--cds-chat-BASE-line-height-med);\n overflow-wrap:break-word;\n text-overflow:ellipsis;\n white-space:nowrap;\n word-wrap:break-word;\n}\n\n.WACChatHeaderTitle .WACChatHeaderTitle__Title:only-child{\n padding-inline-end:0.25rem;\n}\n\n.WACChatHeaderTitle__Name{\n font-weight:var(--cds-chat-BASE-weight-semibold);\n}";
|
|
570
|
+
|
|
571
|
+
/*
|
|
572
|
+
* Copyright IBM Corp. 2025
|
|
573
|
+
*
|
|
574
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
575
|
+
* LICENSE file in the root directory of this source tree.
|
|
576
|
+
*
|
|
577
|
+
* @license
|
|
578
|
+
*/ function chatHeaderTitleTemplate(customElementClass) {
|
|
579
|
+
const {title: title, name: name} = customElementClass;
|
|
580
|
+
return html`<div class="WACChatHeaderTitle">
|
|
581
|
+
<span className="WACChatHeaderTitle__Title" ?hidden="${!title}"
|
|
582
|
+
>${title}</span
|
|
583
|
+
>
|
|
584
|
+
<span class="WACChatHeaderTitle__Name">${name}</span>
|
|
585
|
+
</div>`;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/*
|
|
589
|
+
* Copyright IBM Corp. 2025
|
|
590
|
+
*
|
|
591
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
592
|
+
* LICENSE file in the root directory of this source tree.
|
|
593
|
+
*
|
|
594
|
+
* @license
|
|
595
|
+
*/ let ChatHeaderTitleElement = class ChatHeaderTitleElement extends LitElement {
|
|
596
|
+
render() {
|
|
597
|
+
return chatHeaderTitleTemplate(this);
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
ChatHeaderTitleElement.styles = css`
|
|
602
|
+
${unsafeCSS(css_248z)}
|
|
603
|
+
`;
|
|
604
|
+
|
|
605
|
+
__decorate([ property({
|
|
606
|
+
type: String
|
|
607
|
+
}) ], ChatHeaderTitleElement.prototype, "title", void 0);
|
|
608
|
+
|
|
609
|
+
__decorate([ property({
|
|
610
|
+
type: String
|
|
611
|
+
}) ], ChatHeaderTitleElement.prototype, "name", void 0);
|
|
612
|
+
|
|
613
|
+
ChatHeaderTitleElement = __decorate([ carbonElement(`${WEB_COMPONENT_PREFIX}-chat-header-title`) ], ChatHeaderTitleElement);
|
|
614
|
+
|
|
615
|
+
/*
|
|
616
|
+
* Copyright IBM Corp. 2025
|
|
617
|
+
*
|
|
618
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
619
|
+
* LICENSE file in the root directory of this source tree.
|
|
620
|
+
*
|
|
621
|
+
* @license
|
|
622
|
+
*/ const ChatHeaderTitle = createComponent({
|
|
623
|
+
tagName: `${WEB_COMPONENT_PREFIX}-chat-header-title`,
|
|
624
|
+
elementClass: ChatHeaderTitleElement,
|
|
625
|
+
react: React
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
/*
|
|
629
|
+
* Copyright IBM Corp. 2025
|
|
630
|
+
*
|
|
631
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
632
|
+
* LICENSE file in the root directory of this source tree.
|
|
633
|
+
*
|
|
634
|
+
* @license
|
|
635
|
+
*/ const AISlug = createComponent({
|
|
636
|
+
tagName: "cds-custom-ai-label",
|
|
637
|
+
elementClass: CDSAILabel,
|
|
638
|
+
react: React
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
/*
|
|
642
|
+
* Copyright IBM Corp. 2025
|
|
643
|
+
*
|
|
644
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
645
|
+
* LICENSE file in the root directory of this source tree.
|
|
646
|
+
*
|
|
647
|
+
* @license
|
|
648
|
+
*/ const HEADER_OBJECTS_GAP_MIN_SIZE = 100;
|
|
649
|
+
|
|
650
|
+
function Header(props, ref) {
|
|
651
|
+
const {displayName: displayName, backContent: backContent, showRestartButton: showRestartButton, showBackButton: showBackButton, useAITheme: useAITheme, labelBackButton: labelBackButton, onClickClose: onClickClose, onClickRestart: onClickRestart, onCloseAndRestart: onCloseAndRestart, onClickBack: onClickBack, overflowItems: overflowItems, overflowClicked: overflowClicked, backButtonType: backButtonType, showCenter: showCenter, hideCloseButton: hideCloseButton, hideCloseAndRestartButton: hideCloseAndRestartButton, brandColor: brandColor = "primary", enableChatHeaderConfig: enableChatHeaderConfig, headerAvatarConfig: headerAvatarConfig, testIdPrefix: testIdPrefix} = props;
|
|
652
|
+
const backButtonRef = useRef();
|
|
653
|
+
const restartButtonRef = useRef();
|
|
654
|
+
const closeAndRestartButtonRef = useRef();
|
|
655
|
+
const closeButtonRef = useRef();
|
|
656
|
+
const centerObjectsRef = useRef();
|
|
657
|
+
const centerGapRef = useRef();
|
|
658
|
+
const overflowRef = useRef();
|
|
659
|
+
const serviceManager = useServiceManager();
|
|
660
|
+
const languagePack = useLanguagePack();
|
|
661
|
+
const publicConfig = useSelector(state => state.config.public);
|
|
662
|
+
const chatHeaderConfig = useSelector(state => state.chatHeaderState.config);
|
|
663
|
+
const chatWidthBreakpoint = useSelector(state => state.chatWidthBreakpoint);
|
|
664
|
+
const maxVisibleHeaderObjects = useSelector(state => state.chatHeaderState.maxVisibleHeaderObjects);
|
|
665
|
+
const [overflowIsOpen, setOverflowIsOpen] = useState(false);
|
|
666
|
+
const [confirmModelOpen, setConfirmModelOpen] = useState(false);
|
|
667
|
+
const [selectedGroupMenuitems, setSelectedGroupMenuItems] = useState({});
|
|
668
|
+
const [isImageError, setIsImageError] = useState(false);
|
|
669
|
+
const hasHeaderAvatar = Boolean(headerAvatarConfig) && !isImageError;
|
|
670
|
+
const isHidden = useContext(HideComponentContext);
|
|
671
|
+
const prevChatHeaderAvatarURL = usePrevious(headerAvatarConfig?.url);
|
|
672
|
+
const {headerConfig: headerConfig} = publicConfig;
|
|
673
|
+
const isWideWidth = chatWidthBreakpoint === ChatWidthBreakpoint.WIDE;
|
|
674
|
+
const chatHeaderTitle = enableChatHeaderConfig ? chatHeaderConfig?.headerTitle?.title : undefined;
|
|
675
|
+
const chatHeaderName = enableChatHeaderConfig ? chatHeaderConfig?.headerTitle?.name : undefined;
|
|
676
|
+
const chatHeaderDisplayName = chatHeaderName || displayName;
|
|
677
|
+
const closeConfirmModel = useCallback(() => {
|
|
678
|
+
setConfirmModelOpen(false);
|
|
679
|
+
}, []);
|
|
680
|
+
const showCloseAndRestartButton = headerConfig?.showCloseAndRestartButton && !hideCloseAndRestartButton && onCloseAndRestart;
|
|
681
|
+
const useHideCloseButton = headerConfig?.hideMinimizeButton || hideCloseButton;
|
|
682
|
+
let closeIcon;
|
|
683
|
+
let closeReverseIcon = false;
|
|
684
|
+
let closeIsReversible = true;
|
|
685
|
+
const minimizeButtonIconType = headerConfig?.minimizeButtonIconType;
|
|
686
|
+
switch (minimizeButtonIconType) {
|
|
687
|
+
case MinimizeButtonIconType.CLOSE:
|
|
688
|
+
closeIcon = React.createElement(CloseLarge, {
|
|
689
|
+
className: "WACIcon__Close",
|
|
690
|
+
size: 16
|
|
691
|
+
});
|
|
692
|
+
break;
|
|
693
|
+
|
|
694
|
+
case MinimizeButtonIconType.MINIMIZE:
|
|
695
|
+
closeIcon = React.createElement(SubtractLarge, {
|
|
696
|
+
className: "WACIcon__Subtract",
|
|
697
|
+
size: 16
|
|
698
|
+
});
|
|
699
|
+
break;
|
|
700
|
+
|
|
701
|
+
case MinimizeButtonIconType.SIDE_PANEL_LEFT:
|
|
702
|
+
closeIsReversible = false;
|
|
703
|
+
closeIcon = React.createElement(SidePanelClose, {
|
|
704
|
+
className: "WACIcon__SidePanelClose"
|
|
705
|
+
});
|
|
706
|
+
break;
|
|
707
|
+
|
|
708
|
+
case MinimizeButtonIconType.SIDE_PANEL_RIGHT:
|
|
709
|
+
closeIsReversible = false;
|
|
710
|
+
closeReverseIcon = true;
|
|
711
|
+
closeIcon = React.createElement(SidePanelClose, {
|
|
712
|
+
className: "WACIcon__SidePanelClose"
|
|
713
|
+
});
|
|
714
|
+
break;
|
|
715
|
+
|
|
716
|
+
default:
|
|
717
|
+
{
|
|
718
|
+
closeIcon = React.createElement(SubtractLarge, {
|
|
719
|
+
className: "WACIcon__Subtract",
|
|
720
|
+
size: 16
|
|
721
|
+
});
|
|
722
|
+
break;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (showCloseAndRestartButton && showRestartButton) {
|
|
726
|
+
throw new Error("You cannot enable both the restart button and the close-and-restart buttons.");
|
|
727
|
+
}
|
|
728
|
+
const onConfirm = useCallback(() => {
|
|
729
|
+
setConfirmModelOpen(false);
|
|
730
|
+
onCloseAndRestart();
|
|
731
|
+
}, [ onCloseAndRestart ]);
|
|
732
|
+
useImperativeHandle(ref, () => ({
|
|
733
|
+
requestFocus: () => {
|
|
734
|
+
if (closeButtonRef.current) {
|
|
735
|
+
doFocusRef(closeButtonRef, false, true);
|
|
736
|
+
return true;
|
|
737
|
+
}
|
|
738
|
+
if (backButtonRef.current) {
|
|
739
|
+
doFocusRef(backButtonRef, false, true);
|
|
740
|
+
return true;
|
|
741
|
+
}
|
|
742
|
+
if (restartButtonRef.current) {
|
|
743
|
+
doFocusRef(restartButtonRef, false, true);
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
746
|
+
return false;
|
|
747
|
+
}
|
|
748
|
+
}));
|
|
749
|
+
function getComponentInMenu(item, index, list) {
|
|
750
|
+
switch (item.type) {
|
|
751
|
+
case ChatHeaderObjectType.LINK:
|
|
752
|
+
return React.createElement(ChatHeaderMenuItem, {
|
|
753
|
+
key: index,
|
|
754
|
+
label: item.label,
|
|
755
|
+
url: item.url,
|
|
756
|
+
isNewTab: item.isNewTab,
|
|
757
|
+
onClick: () => {
|
|
758
|
+
doFocusRef(overflowRef);
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
case ChatHeaderObjectType.BUTTON:
|
|
763
|
+
return React.createElement(ChatHeaderMenuItem, {
|
|
764
|
+
key: index,
|
|
765
|
+
label: item.label,
|
|
766
|
+
onClick: () => {
|
|
767
|
+
item.onClick?.();
|
|
768
|
+
doFocusRef(overflowRef);
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
case ChatHeaderObjectType.RADIO_GROUP:
|
|
773
|
+
{
|
|
774
|
+
const nextObject = list[index + 1];
|
|
775
|
+
return React.createElement(Fragment, {
|
|
776
|
+
key: index
|
|
777
|
+
}, index !== 0 && React.createElement(MenuItemDivider, null), React.createElement(ChatHeaderMenuItemRadioGroup, {
|
|
778
|
+
label: item.label,
|
|
779
|
+
items: item.items,
|
|
780
|
+
defaultSelectedItem: item.defaultSelectedItem,
|
|
781
|
+
selectedItem: selectedGroupMenuitems[item.label],
|
|
782
|
+
onChange: selectedItem => {
|
|
783
|
+
setSelectedGroupMenuItems(prevState => ({
|
|
784
|
+
...prevState,
|
|
785
|
+
[item.label]: selectedItem
|
|
786
|
+
}));
|
|
787
|
+
item.onChange?.(selectedItem);
|
|
788
|
+
}
|
|
789
|
+
}), Boolean(nextObject) && nextObject.type !== ChatHeaderObjectType.RADIO_GROUP && React.createElement(MenuItemDivider, null));
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
case ChatHeaderObjectType.MENU:
|
|
793
|
+
return React.createElement(ChatHeaderMenuItem, {
|
|
794
|
+
key: index,
|
|
795
|
+
label: item.label
|
|
796
|
+
}, item.items.filter(menuItem => menuItem.type !== ChatHeaderObjectType.MENU).map(getComponentInMenu));
|
|
797
|
+
|
|
798
|
+
default:
|
|
799
|
+
return null;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
function getComponentInChatHeader(headerObject, index) {
|
|
803
|
+
switch (headerObject.type) {
|
|
804
|
+
case ChatHeaderObjectType.LINK:
|
|
805
|
+
return React.createElement(ChatHeaderLink, {
|
|
806
|
+
key: index,
|
|
807
|
+
label: headerObject.label,
|
|
808
|
+
url: headerObject.url,
|
|
809
|
+
isNewTab: headerObject.isNewTab
|
|
810
|
+
});
|
|
811
|
+
|
|
812
|
+
case ChatHeaderObjectType.MENU:
|
|
813
|
+
return React.createElement(ChatHeaderMenuButton, {
|
|
814
|
+
key: index,
|
|
815
|
+
label: headerObject.label,
|
|
816
|
+
menuAlignment: "bottom-start"
|
|
817
|
+
}, headerObject.items.map(getComponentInMenu));
|
|
818
|
+
|
|
819
|
+
case ChatHeaderObjectType.BUTTON:
|
|
820
|
+
return React.createElement(Button, {
|
|
821
|
+
key: index,
|
|
822
|
+
kind: ButtonKindEnum.GHOST,
|
|
823
|
+
size: ButtonSizeEnum.MEDIUM,
|
|
824
|
+
onClick: headerObject.onClick
|
|
825
|
+
}, headerObject.label);
|
|
826
|
+
|
|
827
|
+
default:
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
let leftObjectsLength = 0;
|
|
832
|
+
let rightObjectsLength = 0;
|
|
833
|
+
if (enableChatHeaderConfig) {
|
|
834
|
+
leftObjectsLength = chatHeaderConfig?.left?.length ?? 0;
|
|
835
|
+
rightObjectsLength = chatHeaderConfig?.right?.length ?? 0;
|
|
836
|
+
}
|
|
837
|
+
const isLeftObjectsInOverflow = leftObjectsLength > maxVisibleHeaderObjects;
|
|
838
|
+
const isRightObjectsInOverflow = rightObjectsLength > maxVisibleHeaderObjects;
|
|
839
|
+
const hasChatHeaderObjects = leftObjectsLength || rightObjectsLength;
|
|
840
|
+
const renderChatHeaderObjectsInOverflow = hasChatHeaderObjects && (!isWideWidth || isLeftObjectsInOverflow || isRightObjectsInOverflow);
|
|
841
|
+
const hasOverflow = Boolean(overflowItems?.length) || renderChatHeaderObjectsInOverflow;
|
|
842
|
+
const isRTL = document.dir === "rtl";
|
|
843
|
+
let leftChatHeaderComponents = null;
|
|
844
|
+
let rightChatHeaderComponents = null;
|
|
845
|
+
let leftChatHeaderMenuComponents = null;
|
|
846
|
+
let rightChatHeaderMenuComponents = null;
|
|
847
|
+
if (enableChatHeaderConfig) {
|
|
848
|
+
leftChatHeaderComponents = chatHeaderConfig?.left?.slice(0, isLeftObjectsInOverflow ? maxVisibleHeaderObjects : undefined).map(getComponentInChatHeader);
|
|
849
|
+
rightChatHeaderComponents = chatHeaderConfig?.right?.slice(0, isRightObjectsInOverflow ? maxVisibleHeaderObjects : undefined).map(getComponentInChatHeader);
|
|
850
|
+
leftChatHeaderMenuComponents = isLeftObjectsInOverflow && chatHeaderConfig?.left?.slice(maxVisibleHeaderObjects).map(getComponentInMenu);
|
|
851
|
+
rightChatHeaderMenuComponents = isRightObjectsInOverflow && chatHeaderConfig?.right?.slice(maxVisibleHeaderObjects).map(getComponentInMenu);
|
|
852
|
+
}
|
|
853
|
+
let leftContent;
|
|
854
|
+
if (hasOverflow) {
|
|
855
|
+
leftContent = React.createElement(ChatHeaderOverflowMenu, {
|
|
856
|
+
className: "WACHeader__OverflowMenu",
|
|
857
|
+
renderIcon: overflowIsOpen ? Close : Menu$1,
|
|
858
|
+
iconDescription: languagePack.header_overflowMenu_options,
|
|
859
|
+
ariaLabel: languagePack.components_overflow_ariaLabel,
|
|
860
|
+
containerRef: overflowRef,
|
|
861
|
+
tooltipPosition: isRTL ? "left" : "right",
|
|
862
|
+
menuAlignment: "bottom-start",
|
|
863
|
+
onOpen: () => {
|
|
864
|
+
setTimeout(() => {
|
|
865
|
+
setOverflowIsOpen(true);
|
|
866
|
+
});
|
|
867
|
+
},
|
|
868
|
+
onClose: () => {
|
|
869
|
+
setOverflowIsOpen(false);
|
|
870
|
+
}
|
|
871
|
+
}, overflowItems?.map((item, index) => React.createElement(MenuItem, {
|
|
872
|
+
key: item,
|
|
873
|
+
label: item,
|
|
874
|
+
onClick: () => {
|
|
875
|
+
doFocusRef(overflowRef);
|
|
876
|
+
overflowClicked(index);
|
|
877
|
+
}
|
|
878
|
+
})), leftChatHeaderMenuComponents, rightChatHeaderMenuComponents);
|
|
879
|
+
} else if (showBackButton) {
|
|
880
|
+
leftContent = React.createElement(HeaderButton, {
|
|
881
|
+
className: "WACHeader__BackButton",
|
|
882
|
+
label: labelBackButton,
|
|
883
|
+
onClick: onClickBack,
|
|
884
|
+
buttonRef: backButtonRef,
|
|
885
|
+
buttonKind: backButtonType,
|
|
886
|
+
tooltipPosition: isRTL ? "left" : "right"
|
|
887
|
+
}, backContent || React.createElement(DownToBottom, null));
|
|
888
|
+
}
|
|
889
|
+
useEffect(() => {
|
|
890
|
+
if (!isWideWidth) {
|
|
891
|
+
serviceManager.store.dispatch(actions.setMaxVisibleHeaderObjects(0));
|
|
892
|
+
return undefined;
|
|
893
|
+
}
|
|
894
|
+
if (!enableChatHeaderConfig) {
|
|
895
|
+
return undefined;
|
|
896
|
+
}
|
|
897
|
+
const centerResizeObserver = new ResizeObserver(() => {
|
|
898
|
+
const centerGapElement = centerGapRef.current;
|
|
899
|
+
if (centerGapElement) {
|
|
900
|
+
if (centerGapElement.offsetWidth > HEADER_OBJECTS_GAP_MIN_SIZE || centerGapElement.offsetWidth === 0) {
|
|
901
|
+
let newTotal = Math.floor((centerObjectsRef.current.offsetWidth - HEADER_OBJECTS_GAP_MIN_SIZE) / (HEADER_OBJECTS_GAP_MIN_SIZE * 2));
|
|
902
|
+
if (newTotal < 0) {
|
|
903
|
+
newTotal = 0;
|
|
904
|
+
}
|
|
905
|
+
setTimeout(() => {
|
|
906
|
+
serviceManager.store.dispatch(actions.setMaxVisibleHeaderObjects(newTotal));
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
centerResizeObserver.observe(centerObjectsRef.current);
|
|
912
|
+
return () => {
|
|
913
|
+
centerResizeObserver.disconnect();
|
|
914
|
+
};
|
|
915
|
+
}, [ isWideWidth, enableChatHeaderConfig, serviceManager ]);
|
|
916
|
+
useEffect(() => {
|
|
917
|
+
if (isImageError && prevChatHeaderAvatarURL !== headerAvatarConfig?.url) {
|
|
918
|
+
setIsImageError(false);
|
|
919
|
+
}
|
|
920
|
+
}, [ prevChatHeaderAvatarURL, headerAvatarConfig?.url, isImageError ]);
|
|
921
|
+
return React.createElement("div", {
|
|
922
|
+
className: cx("WACHeader", `WAC--${brandColor}Color`, {
|
|
923
|
+
"WACHeader--withAvatar": hasHeaderAvatar
|
|
924
|
+
})
|
|
925
|
+
}, React.createElement("div", {
|
|
926
|
+
className: cx("WACHeader--content", `WAC--${brandColor}Color`),
|
|
927
|
+
"data-floating-menu-container": true
|
|
928
|
+
}, leftContent && React.createElement("div", {
|
|
929
|
+
className: "WACHeader__Buttons WACHeader__LeftButtons"
|
|
930
|
+
}, leftContent), showCenter && React.createElement("div", {
|
|
931
|
+
className: "WACHeader__CenterContainer"
|
|
932
|
+
}, hasHeaderAvatar && React.createElement(ChatHeaderAvatar, {
|
|
933
|
+
url: headerAvatarConfig.url,
|
|
934
|
+
corners: headerAvatarConfig.corners,
|
|
935
|
+
alt: languagePack.header_ariaBotAvatar,
|
|
936
|
+
onError: () => setIsImageError(true)
|
|
937
|
+
}), (chatHeaderTitle || chatHeaderDisplayName) && React.createElement("div", {
|
|
938
|
+
className: "WACHeader__TitleContainer"
|
|
939
|
+
}, React.createElement(ChatHeaderTitle, {
|
|
940
|
+
title: chatHeaderTitle,
|
|
941
|
+
name: chatHeaderDisplayName
|
|
942
|
+
})), isWideWidth && Boolean(leftObjectsLength) && React.createElement("div", {
|
|
943
|
+
className: "WACHeader__Separator"
|
|
944
|
+
}), React.createElement("div", {
|
|
945
|
+
ref: centerObjectsRef,
|
|
946
|
+
className: "WACHeader__HeaderObjects"
|
|
947
|
+
}, isWideWidth && Boolean(leftObjectsLength) && React.createElement("div", {
|
|
948
|
+
className: "WACHeader__LeftItems"
|
|
949
|
+
}, leftChatHeaderComponents), React.createElement("div", {
|
|
950
|
+
ref: centerGapRef,
|
|
951
|
+
className: "WACHeader__CenterGap"
|
|
952
|
+
}), isWideWidth && Boolean(rightObjectsLength) && React.createElement("div", {
|
|
953
|
+
className: "WACHeader__RightItems"
|
|
954
|
+
}, rightChatHeaderComponents))), React.createElement("div", {
|
|
955
|
+
className: "WACHeader__Buttons WACHeader__RightButtons"
|
|
956
|
+
}, useAITheme && React.createElement(AISlug, {
|
|
957
|
+
className: "WACHeader__Slug",
|
|
958
|
+
size: AI_LABEL_SIZE.EXTRA_SMALL,
|
|
959
|
+
alignment: isRTL ? POPOVER_ALIGNMENT.BOTTOM_LEFT : POPOVER_ALIGNMENT.BOTTOM_RIGHT
|
|
960
|
+
}, React.createElement("div", {
|
|
961
|
+
slot: "body-text"
|
|
962
|
+
}, React.createElement("h4", {
|
|
963
|
+
className: "WACHeader__Slug-title"
|
|
964
|
+
}, languagePack.ai_slug_title), React.createElement("div", {
|
|
965
|
+
className: "WACHeader__Slug-description"
|
|
966
|
+
}, React.createElement("div", null, languagePack.ai_slug_description), !isHidden && React.createElement(WriteableElement$1, {
|
|
967
|
+
slotName: WriteableElementName.AI_TOOLTIP_AFTER_DESCRIPTION_ELEMENT,
|
|
968
|
+
id: `aiTooltipAfterDescription${serviceManager.namespace.suffix}`
|
|
969
|
+
})))), showRestartButton && React.createElement(HeaderButton, {
|
|
970
|
+
className: "WACHeader__RestartButton",
|
|
971
|
+
label: languagePack.buttons_restart,
|
|
972
|
+
onClick: onClickRestart,
|
|
973
|
+
buttonRef: restartButtonRef,
|
|
974
|
+
tooltipPosition: isRTL ? "right" : "left"
|
|
975
|
+
}, React.createElement(Restart, null)), !useHideCloseButton && React.createElement(HeaderButton, {
|
|
976
|
+
className: cx("WACHeader__CloseButton", {
|
|
977
|
+
WACReverseIcon: closeReverseIcon
|
|
978
|
+
}),
|
|
979
|
+
isReversible: closeIsReversible,
|
|
980
|
+
label: languagePack.launcher_isOpen,
|
|
981
|
+
onClick: async () => {
|
|
982
|
+
onClickClose();
|
|
983
|
+
},
|
|
984
|
+
buttonRef: closeButtonRef,
|
|
985
|
+
tooltipPosition: isRTL ? "right" : "left",
|
|
986
|
+
testId: makeTestId(PageObjectId.CLOSE_CHAT, testIdPrefix)
|
|
987
|
+
}, closeIcon), showCloseAndRestartButton && React.createElement(HeaderButton, {
|
|
988
|
+
className: "WACHeader__CloseAndRestartButton",
|
|
989
|
+
label: languagePack.header_ariaCloseRestart,
|
|
990
|
+
onClick: () => setConfirmModelOpen(true),
|
|
991
|
+
buttonRef: closeAndRestartButtonRef,
|
|
992
|
+
tooltipPosition: isRTL ? "right" : "left"
|
|
993
|
+
}, React.createElement(CloseLarge, {
|
|
994
|
+
className: "WACIcon__Close"
|
|
995
|
+
}))), confirmModelOpen && React.createElement(ConfirmModal, {
|
|
996
|
+
title: languagePack.closeAndRestartModal_title,
|
|
997
|
+
message: languagePack.closeAndRestartModal_message,
|
|
998
|
+
onConfirm: onConfirm,
|
|
999
|
+
onCancel: closeConfirmModel,
|
|
1000
|
+
cancelButtonLabel: languagePack.closeAndRestartModal_cancel,
|
|
1001
|
+
confirmButtonLabel: languagePack.closeAndRestartModal_confirm,
|
|
1002
|
+
modalAnnounceMessage: languagePack.closeAndRestartModal_message,
|
|
1003
|
+
serviceManager: serviceManager
|
|
1004
|
+
})));
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
function HeaderButton({onClick: onClick, buttonRef: buttonRef, label: label, className: className, children: children, buttonKind: buttonKind, isReversible: isReversible = true, tooltipPosition: tooltipPosition, testId: testId}) {
|
|
1008
|
+
return React.createElement(Button, {
|
|
1009
|
+
ref: buttonRef,
|
|
1010
|
+
className: cx(className, {
|
|
1011
|
+
WACDirectionHasReversibleSVG: isReversible
|
|
1012
|
+
}),
|
|
1013
|
+
onClick: onClick,
|
|
1014
|
+
hasIconOnly: true,
|
|
1015
|
+
iconDescription: label,
|
|
1016
|
+
size: ButtonSizeEnum.MEDIUM,
|
|
1017
|
+
kind: buttonKind || ButtonKindEnum.GHOST,
|
|
1018
|
+
tooltipPosition: tooltipPosition,
|
|
1019
|
+
"data-testid": testId
|
|
1020
|
+
}, children);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
const HeaderExport = React.memo(forwardRef(Header));
|
|
1024
|
+
|
|
1025
|
+
export { AriaLiveMessageExport as A, ConfirmModal as C, HeaderExport as H, ModalPortalRootContext as M, WEB_COMPONENT_PREFIX as W, WriteableElement$1 as a, CSS_CLASS_PREFIX as b, useUUID as u };
|