@patternfly/chatbot 6.8.0-prerelease.7 → 6.8.0-prerelease.9
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/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +46 -5
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +125 -16
- package/dist/cjs/CodeModal/CodeModal.js +5 -0
- package/dist/cjs/MarkdownContent/MarkdownContent.d.ts +26 -7
- package/dist/cjs/MarkdownContent/MarkdownContent.js +79 -166
- package/dist/cjs/MarkdownContent/MarkdownRenderer.d.ts +6 -0
- package/dist/cjs/MarkdownContent/MarkdownRenderer.js +187 -0
- package/dist/cjs/Message/Message.d.ts +3 -4
- package/dist/cjs/Message/Message.js +0 -2
- package/dist/cjs/MessageBox/MessageBox.d.ts +2 -0
- package/dist/cjs/MessageBox/MessageBox.js +7 -2
- package/dist/cjs/index.d.ts +0 -8
- package/dist/cjs/index.js +1 -13
- package/dist/css/main.css +77 -10
- package/dist/css/main.css.map +1 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +46 -5
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +128 -19
- package/dist/esm/CodeModal/CodeModal.js +5 -0
- package/dist/esm/MarkdownContent/MarkdownContent.d.ts +26 -7
- package/dist/esm/MarkdownContent/MarkdownContent.js +52 -165
- package/dist/esm/MarkdownContent/MarkdownRenderer.d.ts +6 -0
- package/dist/esm/MarkdownContent/MarkdownRenderer.js +182 -0
- package/dist/esm/Message/Message.d.ts +3 -4
- package/dist/esm/Message/Message.js +0 -2
- package/dist/esm/MessageBox/MessageBox.d.ts +2 -0
- package/dist/esm/MessageBox/MessageBox.js +7 -2
- package/dist/esm/index.d.ts +0 -8
- package/dist/esm/index.js +0 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/generate-index.js +41 -16
- package/generate-index.test.js +68 -0
- package/monaco-environment.js +45 -0
- package/package.json +20 -2
- package/patternfly-docs/content/extensions/chatbot/chatbot.md +1 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickStart.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/monitor-sampleapp-quickstart.ts +1 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithExpandableGroups.tsx +104 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +12 -1
- package/patternfly-docs/content/extensions/chatbot/tree-shaking.md +124 -0
- package/patternfly-docs/monaco-environment.js +45 -0
- package/patternfly-docs/patternfly-docs.css.js +6 -0
- package/src/Chatbot/Chatbot.scss +4 -0
- package/src/ChatbotContent/ChatbotContent.scss +1 -1
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +52 -6
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +551 -3
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +350 -49
- package/src/ChatbotFooter/ChatbotFooter.scss +2 -2
- package/src/ChatbotHeader/ChatbotHeader.scss +4 -0
- package/src/ChatbotModal/ChatbotModal.scss +10 -0
- package/src/ChatbotToggle/ChatbotToggle.scss +6 -0
- package/src/CodeModal/CodeModal.tsx +6 -0
- package/src/DeepThinking/DeepThinking.test.tsx +10 -12
- package/src/MarkdownContent/MarkdownContent.test.tsx +52 -5
- package/src/MarkdownContent/MarkdownContent.tsx +77 -220
- package/src/MarkdownContent/MarkdownRenderer.tsx +235 -0
- package/src/Message/Message.scss +5 -0
- package/src/Message/Message.test.tsx +5 -0
- package/src/Message/Message.tsx +3 -5
- package/src/MessageBox/MessageBox.scss +15 -1
- package/src/MessageBox/MessageBox.tsx +23 -2
- package/src/ResponseActions/ResponseActions.test.tsx +42 -48
- package/src/ToolCall/ToolCall.test.tsx +6 -9
- package/src/ToolResponse/ToolResponse.test.tsx +16 -22
- package/src/index.ts +0 -12
- package/src/test-utils/markdownTestUtils.ts +21 -0
- package/tsconfig.json +6 -1
- package/dist/cjs/AttachmentEdit/AttachmentEdit.test.d.ts +0 -1
- package/dist/cjs/AttachmentEdit/AttachmentEdit.test.js +0 -77
- package/dist/cjs/Chatbot/Chatbot.test.d.ts +0 -1
- package/dist/cjs/Chatbot/Chatbot.test.js +0 -32
- package/dist/cjs/ChatbotAlert/ChatbotAlert.test.d.ts +0 -1
- package/dist/cjs/ChatbotAlert/ChatbotAlert.test.js +0 -27
- package/dist/cjs/ChatbotContent/ChatbotContent.test.d.ts +0 -1
- package/dist/cjs/ChatbotContent/ChatbotContent.test.js +0 -22
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.d.ts +0 -1
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +0 -75
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.d.ts +0 -1
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +0 -277
- package/dist/cjs/ChatbotFooter/ChatbotFooter.test.d.ts +0 -1
- package/dist/cjs/ChatbotFooter/ChatbotFooter.test.js +0 -27
- package/dist/cjs/ChatbotFooter/ChatbotFooternote.test.d.ts +0 -1
- package/dist/cjs/ChatbotFooter/ChatbotFooternote.test.js +0 -87
- package/dist/cjs/ChatbotHeader/ChatbotHeader.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeader.test.js +0 -18
- package/dist/cjs/ChatbotHeader/ChatbotHeaderActions.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderActions.test.js +0 -18
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.js +0 -22
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.test.js +0 -18
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.js +0 -22
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +0 -22
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +0 -46
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +0 -44
- package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.test.js +0 -55
- package/dist/cjs/ChatbotModal/ChatbotModal.test.d.ts +0 -1
- package/dist/cjs/ChatbotModal/ChatbotModal.test.js +0 -16
- package/dist/cjs/ChatbotToggle/ChatbotToggle.test.d.ts +0 -1
- package/dist/cjs/ChatbotToggle/ChatbotToggle.test.js +0 -64
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.d.ts +0 -1
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +0 -61
- package/dist/cjs/CodeModal/CodeModal.test.d.ts +0 -1
- package/dist/cjs/CodeModal/CodeModal.test.js +0 -34
- package/dist/cjs/Compare/Compare.test.d.ts +0 -1
- package/dist/cjs/Compare/Compare.test.js +0 -18
- package/dist/cjs/DeepThinking/DeepThinking.test.d.ts +0 -1
- package/dist/cjs/DeepThinking/DeepThinking.test.js +0 -146
- package/dist/cjs/FileDetails/FileDetails.test.d.ts +0 -1
- package/dist/cjs/FileDetails/FileDetails.test.js +0 -42
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.test.d.ts +0 -1
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.test.js +0 -79
- package/dist/cjs/FileDropZone/FileDropZone.test.d.ts +0 -1
- package/dist/cjs/FileDropZone/FileDropZone.test.js +0 -100
- package/dist/cjs/FilePreview/FilePreview.test.d.ts +0 -1
- package/dist/cjs/FilePreview/FilePreview.test.js +0 -97
- package/dist/cjs/ImagePreview/ImagePreview.test.d.ts +0 -1
- package/dist/cjs/ImagePreview/ImagePreview.test.js +0 -225
- package/dist/cjs/MarkdownContent/MarkdownContent.test.d.ts +0 -1
- package/dist/cjs/MarkdownContent/MarkdownContent.test.js +0 -192
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.test.d.ts +0 -1
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.test.js +0 -131
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.test.d.ts +0 -1
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.test.js +0 -30
- package/dist/cjs/Message/Message.test.d.ts +0 -1
- package/dist/cjs/Message/Message.test.js +0 -1128
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.test.d.ts +0 -1
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.test.js +0 -25
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.test.d.ts +0 -1
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.test.js +0 -25
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.test.d.ts +0 -1
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.test.js +0 -25
- package/dist/cjs/Message/MessageLoading.test.d.ts +0 -1
- package/dist/cjs/Message/MessageLoading.test.js +0 -25
- package/dist/cjs/Message/QuickResponse/QuickResponse.test.d.ts +0 -1
- package/dist/cjs/Message/QuickResponse/QuickResponse.test.js +0 -109
- package/dist/cjs/Message/QuickStarts/QuickStartTileDescription.test.d.ts +0 -1
- package/dist/cjs/Message/QuickStarts/QuickStartTileDescription.test.js +0 -76
- package/dist/cjs/Message/UserFeedback/UserFeedback.test.d.ts +0 -1
- package/dist/cjs/Message/UserFeedback/UserFeedback.test.js +0 -181
- package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.test.d.ts +0 -1
- package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.test.js +0 -243
- package/dist/cjs/MessageBar/AttachButton.test.d.ts +0 -1
- package/dist/cjs/MessageBar/AttachButton.test.js +0 -152
- package/dist/cjs/MessageBar/MessageBar.test.d.ts +0 -1
- package/dist/cjs/MessageBar/MessageBar.test.js +0 -338
- package/dist/cjs/MessageBar/SendButton.test.d.ts +0 -1
- package/dist/cjs/MessageBar/SendButton.test.js +0 -58
- package/dist/cjs/MessageBar/StopButton.test.d.ts +0 -1
- package/dist/cjs/MessageBar/StopButton.test.js +0 -58
- package/dist/cjs/MessageBox/JumpButton.test.d.ts +0 -1
- package/dist/cjs/MessageBox/JumpButton.test.js +0 -39
- package/dist/cjs/MessageBox/MessageBox.test.d.ts +0 -1
- package/dist/cjs/MessageBox/MessageBox.test.js +0 -294
- package/dist/cjs/MessageDivider/MessageDivider.test.d.ts +0 -1
- package/dist/cjs/MessageDivider/MessageDivider.test.js +0 -29
- package/dist/cjs/Onboarding/Onboarding.test.d.ts +0 -1
- package/dist/cjs/Onboarding/Onboarding.test.js +0 -80
- package/dist/cjs/PreviewAttachment/PreviewAttachment.test.d.ts +0 -1
- package/dist/cjs/PreviewAttachment/PreviewAttachment.test.js +0 -50
- package/dist/cjs/ResponseActions/ResponseActionButton.test.d.ts +0 -1
- package/dist/cjs/ResponseActions/ResponseActionButton.test.js +0 -54
- package/dist/cjs/ResponseActions/ResponseActions.test.d.ts +0 -1
- package/dist/cjs/ResponseActions/ResponseActions.test.js +0 -455
- package/dist/cjs/ResponseActions/ResponseActionsGroups.test.d.ts +0 -1
- package/dist/cjs/ResponseActions/ResponseActionsGroups.test.js +0 -25
- package/dist/cjs/Settings/SettingsForm.test.d.ts +0 -1
- package/dist/cjs/Settings/SettingsForm.test.js +0 -35
- package/dist/cjs/SourcesCard/SourcesCard.test.d.ts +0 -1
- package/dist/cjs/SourcesCard/SourcesCard.test.js +0 -39
- package/dist/cjs/SourcesCardBase/SourcesCardBase.test.d.ts +0 -1
- package/dist/cjs/SourcesCardBase/SourcesCardBase.test.js +0 -199
- package/dist/cjs/TermsOfUse/TermsOfUse.test.d.ts +0 -1
- package/dist/cjs/TermsOfUse/TermsOfUse.test.js +0 -77
- package/dist/cjs/ToolCall/ToolCall.test.d.ts +0 -1
- package/dist/cjs/ToolCall/ToolCall.test.js +0 -201
- package/dist/cjs/ToolResponse/ToolResponse.test.d.ts +0 -1
- package/dist/cjs/ToolResponse/ToolResponse.test.js +0 -184
- package/dist/cjs/__mocks__/monaco-editor.d.ts +0 -11
- package/dist/cjs/__mocks__/monaco-editor.js +0 -18
- package/dist/cjs/__mocks__/rehype-external-links.d.ts +0 -2
- package/dist/cjs/__mocks__/rehype-external-links.js +0 -4
- package/dist/cjs/__mocks__/rehype-highlight.d.ts +0 -2
- package/dist/cjs/__mocks__/rehype-highlight.js +0 -4
- package/dist/cjs/__mocks__/rehype-sanitize.d.ts +0 -2
- package/dist/cjs/__mocks__/rehype-sanitize.js +0 -4
- package/dist/cjs/__mocks__/rehype-unwrap-images.d.ts +0 -2
- package/dist/cjs/__mocks__/rehype-unwrap-images.js +0 -4
- package/dist/esm/AttachmentEdit/AttachmentEdit.test.d.ts +0 -1
- package/dist/esm/AttachmentEdit/AttachmentEdit.test.js +0 -72
- package/dist/esm/Chatbot/Chatbot.test.d.ts +0 -1
- package/dist/esm/Chatbot/Chatbot.test.js +0 -27
- package/dist/esm/ChatbotAlert/ChatbotAlert.test.d.ts +0 -1
- package/dist/esm/ChatbotAlert/ChatbotAlert.test.js +0 -22
- package/dist/esm/ChatbotContent/ChatbotContent.test.d.ts +0 -1
- package/dist/esm/ChatbotContent/ChatbotContent.test.js +0 -17
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.d.ts +0 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +0 -70
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.d.ts +0 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +0 -272
- package/dist/esm/ChatbotFooter/ChatbotFooter.test.d.ts +0 -1
- package/dist/esm/ChatbotFooter/ChatbotFooter.test.js +0 -22
- package/dist/esm/ChatbotFooter/ChatbotFooternote.test.d.ts +0 -1
- package/dist/esm/ChatbotFooter/ChatbotFooternote.test.js +0 -82
- package/dist/esm/ChatbotHeader/ChatbotHeader.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeader.test.js +0 -13
- package/dist/esm/ChatbotHeader/ChatbotHeaderActions.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderActions.test.js +0 -13
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.js +0 -20
- package/dist/esm/ChatbotHeader/ChatbotHeaderMain.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderMain.test.js +0 -13
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.js +0 -20
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +0 -20
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +0 -44
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +0 -42
- package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.test.js +0 -50
- package/dist/esm/ChatbotModal/ChatbotModal.test.d.ts +0 -1
- package/dist/esm/ChatbotModal/ChatbotModal.test.js +0 -11
- package/dist/esm/ChatbotToggle/ChatbotToggle.test.d.ts +0 -1
- package/dist/esm/ChatbotToggle/ChatbotToggle.test.js +0 -59
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.d.ts +0 -1
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +0 -56
- package/dist/esm/CodeModal/CodeModal.test.d.ts +0 -1
- package/dist/esm/CodeModal/CodeModal.test.js +0 -29
- package/dist/esm/Compare/Compare.test.d.ts +0 -1
- package/dist/esm/Compare/Compare.test.js +0 -13
- package/dist/esm/DeepThinking/DeepThinking.test.d.ts +0 -1
- package/dist/esm/DeepThinking/DeepThinking.test.js +0 -141
- package/dist/esm/FileDetails/FileDetails.test.d.ts +0 -1
- package/dist/esm/FileDetails/FileDetails.test.js +0 -37
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.test.d.ts +0 -1
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.test.js +0 -74
- package/dist/esm/FileDropZone/FileDropZone.test.d.ts +0 -1
- package/dist/esm/FileDropZone/FileDropZone.test.js +0 -95
- package/dist/esm/FilePreview/FilePreview.test.d.ts +0 -1
- package/dist/esm/FilePreview/FilePreview.test.js +0 -92
- package/dist/esm/ImagePreview/ImagePreview.test.d.ts +0 -1
- package/dist/esm/ImagePreview/ImagePreview.test.js +0 -220
- package/dist/esm/MarkdownContent/MarkdownContent.test.d.ts +0 -1
- package/dist/esm/MarkdownContent/MarkdownContent.test.js +0 -187
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.test.d.ts +0 -1
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.test.js +0 -126
- package/dist/esm/Message/ErrorMessage/ErrorMessage.test.d.ts +0 -1
- package/dist/esm/Message/ErrorMessage/ErrorMessage.test.js +0 -25
- package/dist/esm/Message/Message.test.d.ts +0 -1
- package/dist/esm/Message/Message.test.js +0 -1123
- package/dist/esm/Message/MessageAndActions/MessageAndActions.test.d.ts +0 -1
- package/dist/esm/Message/MessageAndActions/MessageAndActions.test.js +0 -20
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.test.d.ts +0 -1
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.test.js +0 -20
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.test.d.ts +0 -1
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.test.js +0 -20
- package/dist/esm/Message/MessageLoading.test.d.ts +0 -1
- package/dist/esm/Message/MessageLoading.test.js +0 -20
- package/dist/esm/Message/QuickResponse/QuickResponse.test.d.ts +0 -1
- package/dist/esm/Message/QuickResponse/QuickResponse.test.js +0 -104
- package/dist/esm/Message/QuickStarts/QuickStartTileDescription.test.d.ts +0 -1
- package/dist/esm/Message/QuickStarts/QuickStartTileDescription.test.js +0 -48
- package/dist/esm/Message/UserFeedback/UserFeedback.test.d.ts +0 -1
- package/dist/esm/Message/UserFeedback/UserFeedback.test.js +0 -176
- package/dist/esm/Message/UserFeedback/UserFeedbackComplete.test.d.ts +0 -1
- package/dist/esm/Message/UserFeedback/UserFeedbackComplete.test.js +0 -238
- package/dist/esm/MessageBar/AttachButton.test.d.ts +0 -1
- package/dist/esm/MessageBar/AttachButton.test.js +0 -147
- package/dist/esm/MessageBar/MessageBar.test.d.ts +0 -1
- package/dist/esm/MessageBar/MessageBar.test.js +0 -333
- package/dist/esm/MessageBar/SendButton.test.d.ts +0 -1
- package/dist/esm/MessageBar/SendButton.test.js +0 -53
- package/dist/esm/MessageBar/StopButton.test.d.ts +0 -1
- package/dist/esm/MessageBar/StopButton.test.js +0 -53
- package/dist/esm/MessageBox/JumpButton.test.d.ts +0 -1
- package/dist/esm/MessageBox/JumpButton.test.js +0 -34
- package/dist/esm/MessageBox/MessageBox.test.d.ts +0 -1
- package/dist/esm/MessageBox/MessageBox.test.js +0 -289
- package/dist/esm/MessageDivider/MessageDivider.test.d.ts +0 -1
- package/dist/esm/MessageDivider/MessageDivider.test.js +0 -24
- package/dist/esm/Onboarding/Onboarding.test.d.ts +0 -1
- package/dist/esm/Onboarding/Onboarding.test.js +0 -75
- package/dist/esm/PreviewAttachment/PreviewAttachment.test.d.ts +0 -1
- package/dist/esm/PreviewAttachment/PreviewAttachment.test.js +0 -48
- package/dist/esm/ResponseActions/ResponseActionButton.test.d.ts +0 -1
- package/dist/esm/ResponseActions/ResponseActionButton.test.js +0 -49
- package/dist/esm/ResponseActions/ResponseActions.test.d.ts +0 -1
- package/dist/esm/ResponseActions/ResponseActions.test.js +0 -450
- package/dist/esm/ResponseActions/ResponseActionsGroups.test.d.ts +0 -1
- package/dist/esm/ResponseActions/ResponseActionsGroups.test.js +0 -20
- package/dist/esm/Settings/SettingsForm.test.d.ts +0 -1
- package/dist/esm/Settings/SettingsForm.test.js +0 -33
- package/dist/esm/SourcesCard/SourcesCard.test.d.ts +0 -1
- package/dist/esm/SourcesCard/SourcesCard.test.js +0 -34
- package/dist/esm/SourcesCardBase/SourcesCardBase.test.d.ts +0 -1
- package/dist/esm/SourcesCardBase/SourcesCardBase.test.js +0 -194
- package/dist/esm/TermsOfUse/TermsOfUse.test.d.ts +0 -1
- package/dist/esm/TermsOfUse/TermsOfUse.test.js +0 -72
- package/dist/esm/ToolCall/ToolCall.test.d.ts +0 -1
- package/dist/esm/ToolCall/ToolCall.test.js +0 -196
- package/dist/esm/ToolResponse/ToolResponse.test.d.ts +0 -1
- package/dist/esm/ToolResponse/ToolResponse.test.js +0 -179
- package/dist/esm/__mocks__/monaco-editor.d.ts +0 -11
- package/dist/esm/__mocks__/monaco-editor.js +0 -18
- package/dist/esm/__mocks__/rehype-external-links.d.ts +0 -2
- package/dist/esm/__mocks__/rehype-external-links.js +0 -2
- package/dist/esm/__mocks__/rehype-highlight.d.ts +0 -2
- package/dist/esm/__mocks__/rehype-highlight.js +0 -2
- package/dist/esm/__mocks__/rehype-sanitize.d.ts +0 -2
- package/dist/esm/__mocks__/rehype-sanitize.js +0 -2
- package/dist/esm/__mocks__/rehype-unwrap-images.d.ts +0 -2
- package/dist/esm/__mocks__/rehype-unwrap-images.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FunctionComponent } from 'react';
|
|
2
|
-
import { ButtonProps, DrawerProps, DrawerPanelContentProps, DrawerContentProps, DrawerContentBodyProps, DrawerHeadProps, DrawerActionsProps, DrawerCloseButtonProps, DrawerPanelBodyProps, SkeletonProps, TitleProps, SearchInputProps, MenuProps, MenuListProps, MenuItemProps, MenuGroupProps, MenuContentProps } from '@patternfly/react-core';
|
|
1
|
+
import type { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
import { ButtonProps, DrawerProps, DrawerPanelContentProps, DrawerContentProps, DrawerContentBodyProps, DrawerHeadProps, DrawerActionsProps, DrawerCloseButtonProps, DrawerPanelBodyProps, SkeletonProps, TitleProps, SearchInputProps, MenuProps, MenuListProps, MenuItemProps, MenuGroupProps, MenuContentProps, ExpandableSectionProps, ExpandableSectionToggleProps } from '@patternfly/react-core';
|
|
3
3
|
import { ChatbotDisplayMode } from '../Chatbot/Chatbot';
|
|
4
4
|
import { HistoryEmptyStateProps } from './EmptyState';
|
|
5
5
|
export interface Conversation {
|
|
@@ -24,6 +24,49 @@ export interface Conversation {
|
|
|
24
24
|
/** Custom dropdown ID to ensure uniqueness across demo instances */
|
|
25
25
|
dropdownId?: string;
|
|
26
26
|
}
|
|
27
|
+
export interface ConversationGroupShowAll {
|
|
28
|
+
/** Number of items visible when collapsed */
|
|
29
|
+
visibleCount: number;
|
|
30
|
+
/** Whether all items are shown */
|
|
31
|
+
isExpanded: boolean;
|
|
32
|
+
/** Callback when show all / show less is toggled */
|
|
33
|
+
onToggle: (isExpanded: boolean) => void;
|
|
34
|
+
/** Custom content rendered in the show all / show less toggle. Defaults to "Show all" when collapsed and "Show less" when expanded. */
|
|
35
|
+
label?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
export interface ConversationGroupExpandable {
|
|
38
|
+
/** Whether the group content is expanded */
|
|
39
|
+
isExpanded: boolean;
|
|
40
|
+
/** Callback when the group is toggled */
|
|
41
|
+
onToggle: (isExpanded: boolean) => void;
|
|
42
|
+
/** Additional props applied to ExpandableSection */
|
|
43
|
+
expandableSectionProps?: Omit<ExpandableSectionProps, 'ref'>;
|
|
44
|
+
/** Additional props applied to ExpandableSectionToggle */
|
|
45
|
+
expandableSectionToggleProps?: ExpandableSectionToggleProps;
|
|
46
|
+
}
|
|
47
|
+
export interface ConversationGroup {
|
|
48
|
+
/** Unique group id */
|
|
49
|
+
id: string;
|
|
50
|
+
/** Group label rendered as a MenuGroup heading or expandable toggle label */
|
|
51
|
+
label: ReactNode;
|
|
52
|
+
/** Conversation items or custom menu content such as a "Show all" action */
|
|
53
|
+
items: (Conversation | ReactNode)[];
|
|
54
|
+
/** Content rendered after the group's menu list */
|
|
55
|
+
footer?: ReactNode;
|
|
56
|
+
/** Custom group header that replaces the default label or expandable toggle */
|
|
57
|
+
header?: ReactNode;
|
|
58
|
+
/** When set, the group renders as an expandable section */
|
|
59
|
+
expandable?: ConversationGroupExpandable;
|
|
60
|
+
/** When set, truncates the list with an expandable show all / show less section */
|
|
61
|
+
showAll?: ConversationGroupShowAll;
|
|
62
|
+
/** Additional props applied to the conversation menu group */
|
|
63
|
+
menuGroupProps?: MenuGroupProps;
|
|
64
|
+
/** Additional props applied to the conversation list */
|
|
65
|
+
menuListProps?: Omit<MenuListProps, 'children'>;
|
|
66
|
+
}
|
|
67
|
+
export type Conversations = (Conversation | ReactNode)[] | ConversationGroup[] | {
|
|
68
|
+
[key: string]: (Conversation | ReactNode)[];
|
|
69
|
+
};
|
|
27
70
|
export interface ChatbotConversationHistoryNavProps extends DrawerProps {
|
|
28
71
|
/** Function called to toggle drawer */
|
|
29
72
|
onDrawerToggle: (event: React.KeyboardEvent | React.MouseEvent | React.TransitionEvent) => void;
|
|
@@ -35,9 +78,7 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
|
|
|
35
78
|
/** Callback function for when an item is selected */
|
|
36
79
|
onSelectActiveItem?: (event?: React.MouseEvent, itemId?: string | number) => void;
|
|
37
80
|
/** Items shown in chat history */
|
|
38
|
-
conversations:
|
|
39
|
-
[key: string]: Conversation[];
|
|
40
|
-
};
|
|
81
|
+
conversations: Conversations;
|
|
41
82
|
/** Additional button props for new chat button. */
|
|
42
83
|
newChatButtonProps?: ButtonProps;
|
|
43
84
|
/** Additional props applied to conversation menu group. If conversations is an object, you should pass an object of MenuGroupProps for each group. */
|
|
@@ -9,44 +9,153 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx,
|
|
13
|
-
import { useRef, Fragment } from 'react';
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { useEffect, useRef, Fragment, isValidElement } from 'react';
|
|
14
14
|
// Import PatternFly components
|
|
15
|
-
import { Button, Divider, Drawer, DrawerPanelContent, DrawerContent, DrawerPanelBody, DrawerHead, DrawerActions, DrawerCloseButton, DrawerContentBody, InputGroup, InputGroupItem, SearchInput, Title, Icon, MenuList, MenuGroup, MenuItem, Menu, MenuContent } from '@patternfly/react-core';
|
|
15
|
+
import { Button, Divider, Drawer, DrawerPanelContent, DrawerContent, DrawerPanelBody, DrawerHead, DrawerActions, DrawerCloseButton, DrawerContentBody, InputGroup, InputGroupItem, SearchInput, Title, Icon, MenuList, MenuGroup, MenuItem, Menu, MenuContent, ExpandableSection, ExpandableSectionToggle } from '@patternfly/react-core';
|
|
16
16
|
import { RhUiClockIcon, RhUiCommentIcon, RhUiEditFillIcon } from '@patternfly/react-icons';
|
|
17
17
|
import { ChatbotDisplayMode } from '../Chatbot/Chatbot';
|
|
18
18
|
import ConversationHistoryDropdown from './ChatbotConversationHistoryDropdown';
|
|
19
19
|
import LoadingState from './LoadingState';
|
|
20
20
|
import HistoryEmptyState from './EmptyState';
|
|
21
|
+
const isConversation = (item) => Boolean(item && typeof item === 'object' && 'id' in item && 'text' in item && !('items' in item));
|
|
22
|
+
const isConversationGroup = (item) => Boolean(item && typeof item === 'object' && 'id' in item && 'label' in item && 'items' in item);
|
|
23
|
+
const isConversationGroupArray = (items) => items.length > 0 && isConversationGroup(items[0]);
|
|
24
|
+
const getExpandableGroupContentId = (groupId) => `chatbot-nav-group-${groupId}-content`;
|
|
25
|
+
const getGroupLabelId = (groupId) => `chatbot-nav-group-${groupId}-label`;
|
|
26
|
+
const getExpandableGroupToggleId = (groupId) => `chatbot-nav-group-${groupId}-toggle`;
|
|
27
|
+
const getShowAllToggleId = (groupId) => `chatbot-nav-group-${groupId}-show-all-toggle`;
|
|
28
|
+
const getStaticMenuLabelId = (group) => { var _a, _b; return (_b = (_a = group.menuGroupProps) === null || _a === void 0 ? void 0 : _a.titleId) !== null && _b !== void 0 ? _b : getGroupLabelId(group.id); };
|
|
29
|
+
const getMenuListLabelledBy = (group) => {
|
|
30
|
+
var _a, _b, _c, _d;
|
|
31
|
+
if (group.expandable) {
|
|
32
|
+
return (_b = (_a = group.menuGroupProps) === null || _a === void 0 ? void 0 : _a['aria-labelledby']) !== null && _b !== void 0 ? _b : getExpandableGroupToggleId(group.id);
|
|
33
|
+
}
|
|
34
|
+
return (_d = (_c = group.menuGroupProps) === null || _c === void 0 ? void 0 : _c['aria-labelledby']) !== null && _d !== void 0 ? _d : getStaticMenuLabelId(group);
|
|
35
|
+
};
|
|
36
|
+
const getMenuListProps = (group) => {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
return (Object.assign(Object.assign({}, group.menuListProps), { 'aria-labelledby': (_b = (_a = group.menuListProps) === null || _a === void 0 ? void 0 : _a['aria-labelledby']) !== null && _b !== void 0 ? _b : getMenuListLabelledBy(group) }));
|
|
39
|
+
};
|
|
40
|
+
const focusElementById = (id) => {
|
|
41
|
+
var _a;
|
|
42
|
+
(_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
43
|
+
};
|
|
44
|
+
// Matches PatternFly's Menu "view more" example: expanding moves focus to the first
|
|
45
|
+
// newly revealed item; collapsing keeps focus on the toggle as it updates to "Show all".
|
|
46
|
+
const useShowAllFocusManagement = (isExpanded, toggleId, firstOverflowItemRef, hasOverflowItems) => {
|
|
47
|
+
const wasExpandedRef = useRef(isExpanded);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
var _a;
|
|
50
|
+
if (hasOverflowItems && isExpanded !== wasExpandedRef.current) {
|
|
51
|
+
if (isExpanded) {
|
|
52
|
+
(_a = firstOverflowItemRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
focusElementById(toggleId);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
wasExpandedRef.current = isExpanded;
|
|
59
|
+
}, [isExpanded, toggleId, firstOverflowItemRef, hasOverflowItems]);
|
|
60
|
+
};
|
|
61
|
+
// The toggle is rendered as a real MenuItem (rather than a standalone button) so it
|
|
62
|
+
// participates in the Menu's built-in roving tabindex and arrow-key navigation just
|
|
63
|
+
// like any other conversation item, instead of being skipped over or interrupting
|
|
64
|
+
// arrow-key handling. Since it keeps a stable key and DOM position regardless of how
|
|
65
|
+
// many overflow items are shown, it also keeps focus across clicks without being
|
|
66
|
+
// unmounted or recreated.
|
|
67
|
+
const ShowAllGroupBody = ({ group, getNavItem }) => {
|
|
68
|
+
const { visibleCount, isExpanded, onToggle, label } = group.showAll;
|
|
69
|
+
const conversationItems = group.items.filter(isConversation);
|
|
70
|
+
const alwaysVisibleItems = conversationItems.slice(0, visibleCount);
|
|
71
|
+
const overflowItems = conversationItems.slice(visibleCount);
|
|
72
|
+
const hasOverflowItems = overflowItems.length > 0;
|
|
73
|
+
const toggleId = getShowAllToggleId(group.id);
|
|
74
|
+
const firstOverflowItemRef = useRef(null);
|
|
75
|
+
const toggleLabel = label !== null && label !== void 0 ? label : (isExpanded ? 'Show less' : 'Show all');
|
|
76
|
+
useShowAllFocusManagement(isExpanded, toggleId, firstOverflowItemRef, hasOverflowItems);
|
|
77
|
+
return (_jsxs(_Fragment, { children: [_jsxs(MenuList, Object.assign({}, getMenuListProps(group), { children: [alwaysVisibleItems.map((chat) => (_jsx(Fragment, { children: getNavItem(chat) }, chat.id))), isExpanded &&
|
|
78
|
+
overflowItems.map((chat, index) => (_jsx(Fragment, { children: getNavItem(chat, undefined, index === 0 ? firstOverflowItemRef : undefined) }, chat.id))), hasOverflowItems && (_jsx(MenuItem, { id: toggleId, itemId: toggleId, className: "pf-chatbot__menu-show-all-toggle", onClick: () => onToggle(!isExpanded), children: toggleLabel }, "show-all-toggle"))] })), group.footer] }));
|
|
79
|
+
};
|
|
80
|
+
const ExpandableConversationGroup = ({ group, children }) => {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
const toggleId = getExpandableGroupToggleId(group.id);
|
|
83
|
+
const contentId = getExpandableGroupContentId(group.id);
|
|
84
|
+
const { isExpanded, onToggle, expandableSectionProps, expandableSectionToggleProps } = group.expandable;
|
|
85
|
+
return (_jsxs("div", { className: `pf-chatbot__menu-item-header pf-chatbot__menu-item-header--expandable ${(_b = (_a = group.menuGroupProps) === null || _a === void 0 ? void 0 : _a.className) !== null && _b !== void 0 ? _b : ''}`, children: [_jsx(ExpandableSectionToggle, Object.assign({ toggleId: toggleId, contentId: contentId, isExpanded: isExpanded, onToggle: onToggle, toggleWrapper: "h3", className: "pf-chatbot__menu-group-toggle" }, expandableSectionToggleProps, { children: group.label })), _jsx(ExpandableSection, Object.assign({ isDetached: true, isExpanded: isExpanded, toggleId: toggleId, contentId: contentId }, expandableSectionProps, { children: isExpanded && children }))] }));
|
|
86
|
+
};
|
|
87
|
+
const buildConversationMenuSegments = (groups) => groups.reduce((segments, group) => {
|
|
88
|
+
if (group.expandable) {
|
|
89
|
+
return [...segments, { type: 'expandable', group }];
|
|
90
|
+
}
|
|
91
|
+
const last = segments[segments.length - 1];
|
|
92
|
+
if ((last === null || last === void 0 ? void 0 : last.type) === 'static') {
|
|
93
|
+
last.groups.push(group);
|
|
94
|
+
return segments;
|
|
95
|
+
}
|
|
96
|
+
return [...segments, { type: 'static', groups: [group] }];
|
|
97
|
+
}, []);
|
|
21
98
|
export const ChatbotConversationHistoryNav = (_a) => {
|
|
22
99
|
var { onDrawerToggle, isDrawerOpen, setIsDrawerOpen, activeItemId, onSelectActiveItem, conversations, menuListProps, newChatButtonText = 'New chat', drawerContent, onNewChat, newChatButtonProps, searchInputPlaceholder = 'Search previous conversations...', searchInputAriaLabel = 'Search previous conversations', searchInputProps, handleTextInputChange, displayMode, reverseButtonOrder = false, drawerActionsTestId = 'chatbot-nav-drawer-actions', drawerPanelContentProps, drawerContentProps, drawerContentBodyProps, drawerHeadProps, drawerActionsProps, drawerCloseButtonProps, drawerPanelBodyProps, hasDrawerHeadDivider, isLoading, loadingState, errorState, emptyState, noResultsState, isCompact, title = 'Chat history', navTitleProps, navTitleIcon = _jsx(RhUiClockIcon, {}), searchInputScreenReaderText, searchActionStart, searchActionEnd, searchToolbar, menuProps, menuGroupProps, menuContentProps } = _a, props = __rest(_a, ["onDrawerToggle", "isDrawerOpen", "setIsDrawerOpen", "activeItemId", "onSelectActiveItem", "conversations", "menuListProps", "newChatButtonText", "drawerContent", "onNewChat", "newChatButtonProps", "searchInputPlaceholder", "searchInputAriaLabel", "searchInputProps", "handleTextInputChange", "displayMode", "reverseButtonOrder", "drawerActionsTestId", "drawerPanelContentProps", "drawerContentProps", "drawerContentBodyProps", "drawerHeadProps", "drawerActionsProps", "drawerCloseButtonProps", "drawerPanelBodyProps", "hasDrawerHeadDivider", "isLoading", "loadingState", "errorState", "emptyState", "noResultsState", "isCompact", "title", "navTitleProps", "navTitleIcon", "searchInputScreenReaderText", "searchActionStart", "searchActionEnd", "searchToolbar", "menuProps", "menuGroupProps", "menuContentProps"]);
|
|
23
100
|
const drawerRef = useRef(null);
|
|
24
101
|
const onExpand = () => {
|
|
25
102
|
drawerRef.current && drawerRef.current.focus();
|
|
26
103
|
};
|
|
27
|
-
const
|
|
28
|
-
const getNavItem = (conversation) => {
|
|
104
|
+
const getNavItem = (conversation, itemOverrides, itemRef) => {
|
|
29
105
|
var _a;
|
|
30
|
-
return (_jsx(MenuItem, Object.assign({ className: `pf-chatbot__menu-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__menu-item--active' : ''}`, itemId: conversation.id }, (conversation.noIcon ? {} : { icon: (_a = conversation.icon) !== null && _a !== void 0 ? _a : _jsx(RhUiCommentIcon, {}) }), (conversation.menuItems
|
|
106
|
+
return (_jsx(MenuItem, Object.assign({ className: `pf-chatbot__menu-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__menu-item--active' : ''}`, itemId: conversation.id, ref: itemRef }, (conversation.noIcon ? {} : { icon: (_a = conversation.icon) !== null && _a !== void 0 ? _a : _jsx(RhUiCommentIcon, {}) }), (conversation.menuItems
|
|
31
107
|
? {
|
|
32
108
|
actions: (_jsx(ConversationHistoryDropdown, { menuClassName: conversation.menuClassName, onSelect: conversation.onSelect, menuItems: conversation.menuItems, label: conversation.label }))
|
|
33
109
|
}
|
|
34
|
-
: {}), conversation.additionalProps, { children: conversation.text })));
|
|
110
|
+
: {}), conversation.additionalProps, itemOverrides, { children: conversation.text })));
|
|
35
111
|
};
|
|
112
|
+
const renderConversationItems = (items, keyPrefix = '') => items.map((item, index) => {
|
|
113
|
+
if (isConversation(item)) {
|
|
114
|
+
return _jsx(Fragment, { children: getNavItem(item) }, item.id);
|
|
115
|
+
}
|
|
116
|
+
const key = isValidElement(item) && item.key != null ? String(item.key) : `${keyPrefix}-${index}`;
|
|
117
|
+
return _jsx(Fragment, { children: item }, key);
|
|
118
|
+
});
|
|
119
|
+
const renderGroupBody = (group) => {
|
|
120
|
+
if (group.showAll) {
|
|
121
|
+
return _jsx(ShowAllGroupBody, { group: group, getNavItem: getNavItem });
|
|
122
|
+
}
|
|
123
|
+
return (_jsxs(_Fragment, { children: [_jsx(MenuList, Object.assign({}, getMenuListProps(group), { children: renderConversationItems(group.items, group.id) })), group.footer] }));
|
|
124
|
+
};
|
|
125
|
+
const renderConversationGroup = (group) => {
|
|
126
|
+
var _a, _b, _c, _d;
|
|
127
|
+
if (group.header) {
|
|
128
|
+
return (_jsxs("div", { className: `pf-chatbot__menu-item-header ${(_b = (_a = group.menuGroupProps) === null || _a === void 0 ? void 0 : _a.className) !== null && _b !== void 0 ? _b : ''}`, children: [group.header, renderGroupBody(group)] }, group.id));
|
|
129
|
+
}
|
|
130
|
+
const labelId = getStaticMenuLabelId(group);
|
|
131
|
+
return (_jsx(MenuGroup, Object.assign({ className: "pf-chatbot__menu-item-header", label: group.label, labelHeadingLevel: "h3" }, group.menuGroupProps, { titleId: labelId, "aria-labelledby": (_d = (_c = group.menuGroupProps) === null || _c === void 0 ? void 0 : _c['aria-labelledby']) !== null && _d !== void 0 ? _d : labelId, children: renderGroupBody(group) }), group.id));
|
|
132
|
+
};
|
|
133
|
+
const renderConversationMenu = (content, key) => (_jsx(Menu, Object.assign({ className: "pf-chatbot__history-menu", isPlain: true, onSelect: onSelectActiveItem, activeItemId: activeItemId }, menuProps, { children: _jsx(MenuContent, Object.assign({}, menuContentProps, { children: content })) }), key));
|
|
134
|
+
const renderConversationMenuSegment = (segment) => {
|
|
135
|
+
if (segment.type === 'static') {
|
|
136
|
+
return renderConversationMenu(_jsx(_Fragment, { children: segment.groups.map(renderConversationGroup) }), segment.groups.map((group) => group.id).join('-'));
|
|
137
|
+
}
|
|
138
|
+
return (_jsx(ExpandableConversationGroup, { group: segment.group, children: renderConversationMenu(renderGroupBody(segment.group)) }, segment.group.id));
|
|
139
|
+
};
|
|
140
|
+
const normalizeObjectGroups = (groupedConversations) => Object.keys(groupedConversations).map((groupKey) => ({
|
|
141
|
+
id: groupKey,
|
|
142
|
+
label: groupKey,
|
|
143
|
+
items: groupedConversations[groupKey],
|
|
144
|
+
menuGroupProps: menuGroupProps && typeof menuGroupProps === 'object' && groupKey in menuGroupProps
|
|
145
|
+
? menuGroupProps[groupKey]
|
|
146
|
+
: undefined,
|
|
147
|
+
menuListProps: menuListProps && typeof menuListProps === 'object' && groupKey in menuListProps
|
|
148
|
+
? menuListProps[groupKey]
|
|
149
|
+
: undefined
|
|
150
|
+
}));
|
|
36
151
|
const buildConversations = () => {
|
|
37
152
|
if (Array.isArray(conversations)) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
else {
|
|
43
|
-
return conversation;
|
|
44
|
-
}
|
|
45
|
-
}) })));
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return (_jsx(_Fragment, { children: Object.keys(conversations).map((navGroup) => (_jsx(MenuGroup, Object.assign({ className: "pf-chatbot__menu-item-header", label: navGroup, labelHeadingLevel: "h3" }, menuGroupProps === null || menuGroupProps === void 0 ? void 0 : menuGroupProps[navGroup], { children: _jsx(MenuList, Object.assign({}, menuListProps === null || menuListProps === void 0 ? void 0 : menuListProps[navGroup], { children: conversations[navGroup].map((conversation) => (_jsx(Fragment, { children: getNavItem(conversation) }, conversation.id))) })) }), navGroup))) }));
|
|
153
|
+
if (isConversationGroupArray(conversations)) {
|
|
154
|
+
return _jsx(_Fragment, { children: buildConversationMenuSegments(conversations).map(renderConversationMenuSegment) });
|
|
155
|
+
}
|
|
156
|
+
return renderConversationMenu(_jsx(MenuList, Object.assign({}, menuListProps, { children: renderConversationItems(conversations) })));
|
|
49
157
|
}
|
|
158
|
+
return (_jsx(_Fragment, { children: buildConversationMenuSegments(normalizeObjectGroups(conversations)).map(renderConversationMenuSegment) }));
|
|
50
159
|
};
|
|
51
160
|
// Menu Content
|
|
52
161
|
// - Consumers should pass an array to <Chatbot> of the list of conversations
|
|
@@ -61,7 +170,7 @@ export const ChatbotConversationHistoryNav = (_a) => {
|
|
|
61
170
|
if (noResultsState) {
|
|
62
171
|
return _jsx(HistoryEmptyState, Object.assign({}, noResultsState));
|
|
63
172
|
}
|
|
64
|
-
return
|
|
173
|
+
return buildConversations();
|
|
65
174
|
};
|
|
66
175
|
const renderDrawerContent = () => (_jsx(_Fragment, { children: _jsx(DrawerPanelBody, Object.assign({}, drawerPanelBodyProps, { children: renderMenuContent() })) }));
|
|
67
176
|
const searchInputContainer = handleTextInputChange && (_jsxs("div", { className: "pf-chatbot__input", children: [_jsx(SearchInput, Object.assign({ "aria-label": searchInputAriaLabel, onChange: (_event, value) => handleTextInputChange(value), placeholder: searchInputPlaceholder }, searchInputProps)), searchInputScreenReaderText && (_jsx("div", { className: "pf-chatbot__filter-announcement pf-chatbot-m-hidden", children: searchInputScreenReaderText }))] }));
|
|
@@ -30,7 +30,12 @@ import ChatbotModal from '../ChatbotModal/ChatbotModal';
|
|
|
30
30
|
// Try to lazy load - some consumers need to be below a certain bundle size, but can't use the CDN and don't have webpack
|
|
31
31
|
let monacoInstance = null;
|
|
32
32
|
const loadMonaco = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
var _a, _b;
|
|
33
34
|
if (!monacoInstance) {
|
|
35
|
+
if (!((_a = globalThis.MonacoEnvironment) === null || _a === void 0 ? void 0 : _a.getWorker) && !((_b = globalThis.MonacoEnvironment) === null || _b === void 0 ? void 0 : _b.getWorkerUrl)) {
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.error('Monaco web workers are not configured. Import @patternfly/chatbot/monaco-environment before using CodeModal.');
|
|
38
|
+
}
|
|
34
39
|
const [monaco, { loader }] = yield Promise.all([import('monaco-editor'), import('@monaco-editor/react')]);
|
|
35
40
|
monacoInstance = monaco;
|
|
36
41
|
loader.config({ monaco });
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
import { type FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
import { Options } from 'react-markdown';
|
|
3
|
-
import { CodeBlockMessageProps } from '../Message/CodeBlockMessage/CodeBlockMessage';
|
|
4
|
-
import { TableProps } from '@patternfly/react-table';
|
|
5
|
-
import '
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { type FunctionComponent, type ReactNode } from 'react';
|
|
2
|
+
import type { Options } from 'react-markdown';
|
|
3
|
+
import type { CodeBlockMessageProps } from '../Message/CodeBlockMessage/CodeBlockMessage';
|
|
4
|
+
import type { TableProps } from '@patternfly/react-table';
|
|
5
|
+
import type { PluggableList } from 'unified';
|
|
6
|
+
import type { ButtonProps } from '@patternfly/react-core';
|
|
7
|
+
type MarkdownRendererModule = typeof import('./MarkdownRenderer');
|
|
8
|
+
/**
|
|
9
|
+
* Whether the lazy-loaded markdown renderer chunk has finished loading.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useIsMarkdownRendererReady: () => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* When provided by `MessageBox`, defers markdown rendering until the shared chunk is ready
|
|
14
|
+
* so existing messages don't each flash an individual loading state.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MarkdownRendererReadyContext: import("react").Context<boolean | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Eagerly fetches the markdown renderer chunk so the first rendered message
|
|
19
|
+
* doesn't flash a loading state while the chunk downloads. Safe to call repeatedly
|
|
20
|
+
* (the dynamic import is cached).
|
|
21
|
+
*/
|
|
22
|
+
export declare const preloadMarkdownRenderer: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Resolves when the markdown renderer chunk has loaded.
|
|
25
|
+
*/
|
|
26
|
+
export declare const whenMarkdownRendererReady: () => Promise<MarkdownRendererModule>;
|
|
8
27
|
/**
|
|
9
28
|
* MarkdownContent renders content either as plain text or with content with markdown support.
|
|
10
29
|
*
|
|
@@ -10,179 +10,66 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Markdown Content - Shared component for rendering markdown
|
|
15
|
+
// ============================================================================
|
|
16
|
+
import { createContext, useContext, useSyncExternalStore } from 'react';
|
|
15
17
|
import { ContentVariants } from '@patternfly/react-core';
|
|
16
|
-
import CodeBlockMessage from '../Message/CodeBlockMessage/CodeBlockMessage';
|
|
17
18
|
import TextMessage from '../Message/TextMessage/TextMessage';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
import rehypeExternalLinks from 'rehype-external-links';
|
|
30
|
-
import rehypeSanitize from 'rehype-sanitize';
|
|
31
|
-
import rehypeHighlight from 'rehype-highlight';
|
|
32
|
-
import 'highlight.js/styles/vs2015.css';
|
|
33
|
-
import LinkMessage from '../Message/LinkMessage/LinkMessage';
|
|
34
|
-
import { rehypeMoveImagesOutOfParagraphs } from '../Message/Plugins/rehypeMoveImagesOutOfParagraphs';
|
|
35
|
-
import SuperscriptMessage from '../Message/SuperscriptMessage/SuperscriptMessage';
|
|
36
|
-
import { css } from '@patternfly/react-styles';
|
|
37
|
-
export const MarkdownContent = ({ content, isMarkdownDisabled, codeBlockProps, tableProps, openLinkInNewTab = true, additionalRehypePlugins = [], additionalRemarkPlugins = [], linkProps, reactMarkdownProps, remarkGfmProps, hasNoImages = false, isPrimary, textComponent, shouldRetainStyles }) => {
|
|
38
|
-
let rehypePlugins = [rehypeUnwrapImages, rehypeMoveImagesOutOfParagraphs, rehypeHighlight];
|
|
39
|
-
if (openLinkInNewTab) {
|
|
40
|
-
rehypePlugins = rehypePlugins.concat([[rehypeExternalLinks, { target: '_blank' }, rehypeSanitize]]);
|
|
41
|
-
}
|
|
42
|
-
if (additionalRehypePlugins) {
|
|
43
|
-
rehypePlugins.push(...additionalRehypePlugins);
|
|
44
|
-
}
|
|
45
|
-
const disallowedElements = hasNoImages ? ['img'] : [];
|
|
46
|
-
if (reactMarkdownProps && reactMarkdownProps.disallowedElements) {
|
|
47
|
-
disallowedElements.push(...reactMarkdownProps.disallowedElements);
|
|
19
|
+
let markdownRendererPromise = null;
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
let ResolvedMarkdownRenderer = null;
|
|
22
|
+
const markdownRendererListeners = new Set();
|
|
23
|
+
const importMarkdownRenderer = () => {
|
|
24
|
+
if (!markdownRendererPromise) {
|
|
25
|
+
markdownRendererPromise = import('./MarkdownRenderer').then((module) => {
|
|
26
|
+
ResolvedMarkdownRenderer = module.default;
|
|
27
|
+
markdownRendererListeners.forEach((listener) => listener());
|
|
28
|
+
return module;
|
|
29
|
+
});
|
|
48
30
|
}
|
|
31
|
+
return markdownRendererPromise;
|
|
32
|
+
};
|
|
33
|
+
const subscribeToMarkdownRendererReady = (listener) => {
|
|
34
|
+
markdownRendererListeners.add(listener);
|
|
35
|
+
void importMarkdownRenderer();
|
|
36
|
+
return () => markdownRendererListeners.delete(listener);
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Whether the lazy-loaded markdown renderer chunk has finished loading.
|
|
40
|
+
*/
|
|
41
|
+
export const useIsMarkdownRendererReady = () => useSyncExternalStore(subscribeToMarkdownRendererReady, () => ResolvedMarkdownRenderer !== null, () => true);
|
|
42
|
+
/**
|
|
43
|
+
* When provided by `MessageBox`, defers markdown rendering until the shared chunk is ready
|
|
44
|
+
* so existing messages don't each flash an individual loading state.
|
|
45
|
+
*/
|
|
46
|
+
export const MarkdownRendererReadyContext = createContext(null);
|
|
47
|
+
/**
|
|
48
|
+
* Eagerly fetches the markdown renderer chunk so the first rendered message
|
|
49
|
+
* doesn't flash a loading state while the chunk downloads. Safe to call repeatedly
|
|
50
|
+
* (the dynamic import is cached).
|
|
51
|
+
*/
|
|
52
|
+
export const preloadMarkdownRenderer = () => {
|
|
53
|
+
void importMarkdownRenderer();
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Resolves when the markdown renderer chunk has loaded.
|
|
57
|
+
*/
|
|
58
|
+
export const whenMarkdownRendererReady = () => importMarkdownRenderer();
|
|
59
|
+
export const MarkdownContent = (_a) => {
|
|
60
|
+
var { content, isMarkdownDisabled, isPrimary, textComponent } = _a, markdownProps = __rest(_a, ["content", "isMarkdownDisabled", "isPrimary", "textComponent"]);
|
|
61
|
+
const contextReady = useContext(MarkdownRendererReadyContext);
|
|
62
|
+
const storeReady = useIsMarkdownRendererReady();
|
|
63
|
+
const isMarkdownRendererReady = contextReady !== null && contextReady !== void 0 ? contextReady : storeReady;
|
|
49
64
|
if (isMarkdownDisabled) {
|
|
50
65
|
if (textComponent) {
|
|
51
66
|
return _jsx(_Fragment, { children: textComponent });
|
|
52
67
|
}
|
|
53
68
|
return (_jsx(TextMessage, { component: ContentVariants.p, isPrimary: isPrimary, children: content }));
|
|
54
69
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return (_jsx("section", Object.assign({}, rest, { className: css('pf-chatbot__message-text', shouldRetainStyles && 'pf-m-markdown', rest === null || rest === void 0 ? void 0 : rest.className) })));
|
|
60
|
-
},
|
|
61
|
-
p: (props) => {
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
63
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
64
|
-
return (_jsx(TextMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles, component: ContentVariants.p }, rest, { isPrimary: isPrimary })));
|
|
65
|
-
},
|
|
66
|
-
code: (_a) => {
|
|
67
|
-
var { children } = _a, props = __rest(_a, ["children"]);
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
69
|
-
const { node } = props, codeProps = __rest(props, ["node"]);
|
|
70
|
-
return (_jsx(CodeBlockMessage, Object.assign({}, codeProps, codeBlockProps, { isPrimary: isPrimary, shouldRetainStyles: shouldRetainStyles, children: children })));
|
|
71
|
-
},
|
|
72
|
-
h1: (props) => {
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
74
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
75
|
-
return _jsx(TextMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles, component: ContentVariants.h1 }, rest));
|
|
76
|
-
},
|
|
77
|
-
h2: (props) => {
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
80
|
-
return _jsx(TextMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles, component: ContentVariants.h2 }, rest));
|
|
81
|
-
},
|
|
82
|
-
h3: (props) => {
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
84
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
85
|
-
return _jsx(TextMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles, component: ContentVariants.h3 }, rest));
|
|
86
|
-
},
|
|
87
|
-
h4: (props) => {
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
89
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
90
|
-
return _jsx(TextMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles, component: ContentVariants.h4 }, rest));
|
|
91
|
-
},
|
|
92
|
-
h5: (props) => {
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
94
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
95
|
-
return _jsx(TextMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles, component: ContentVariants.h5 }, rest));
|
|
96
|
-
},
|
|
97
|
-
h6: (props) => {
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
99
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
100
|
-
return _jsx(TextMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles, component: ContentVariants.h6 }, rest));
|
|
101
|
-
},
|
|
102
|
-
blockquote: (props) => {
|
|
103
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
104
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
105
|
-
return (_jsx(TextMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles, component: ContentVariants.blockquote }, rest)));
|
|
106
|
-
},
|
|
107
|
-
ul: (props) => {
|
|
108
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
109
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
110
|
-
return _jsx(UnorderedListMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles }, rest));
|
|
111
|
-
},
|
|
112
|
-
ol: (props) => {
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
114
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
115
|
-
return _jsx(OrderedListMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles }, rest));
|
|
116
|
-
},
|
|
117
|
-
li: (props) => {
|
|
118
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
119
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
120
|
-
return _jsx(ListItemMessage, Object.assign({}, rest));
|
|
121
|
-
},
|
|
122
|
-
// table requires node attribute for calculating headers for mobile breakpoint
|
|
123
|
-
table: (props) => (_jsx(TableMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles }, props, tableProps, { isPrimary: isPrimary }))),
|
|
124
|
-
tbody: (props) => {
|
|
125
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
126
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
127
|
-
return _jsx(TbodyMessage, Object.assign({}, rest));
|
|
128
|
-
},
|
|
129
|
-
thead: (props) => {
|
|
130
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
131
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
132
|
-
return _jsx(TheadMessage, Object.assign({}, rest));
|
|
133
|
-
},
|
|
134
|
-
tr: (props) => {
|
|
135
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
136
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
137
|
-
return _jsx(TrMessage, Object.assign({}, rest));
|
|
138
|
-
},
|
|
139
|
-
td: (props) => {
|
|
140
|
-
// Conflicts with Td type
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
142
|
-
const { node, width } = props, rest = __rest(props, ["node", "width"]);
|
|
143
|
-
return _jsx(TdMessage, Object.assign({}, rest));
|
|
144
|
-
},
|
|
145
|
-
th: (props) => {
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
147
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
148
|
-
return _jsx(ThMessage, Object.assign({}, rest));
|
|
149
|
-
},
|
|
150
|
-
img: (props) => {
|
|
151
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
152
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
153
|
-
return _jsx(ImageMessage, Object.assign({}, rest));
|
|
154
|
-
},
|
|
155
|
-
a: (props) => {
|
|
156
|
-
// node is just the details of the document structure - not needed
|
|
157
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
158
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
159
|
-
return (
|
|
160
|
-
// some a types conflict with ButtonProps, but it's ok because we are using an a tag
|
|
161
|
-
// there are too many to handle manually
|
|
162
|
-
_jsx(LinkMessage, Object.assign({ shouldRetainStyles: shouldRetainStyles }, rest, linkProps, { children: props.children })));
|
|
163
|
-
},
|
|
164
|
-
// used for footnotes
|
|
165
|
-
sup: (props) => {
|
|
166
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
167
|
-
const { node } = props, rest = __rest(props, ["node"]);
|
|
168
|
-
return _jsx(SuperscriptMessage, Object.assign({}, rest));
|
|
169
|
-
}
|
|
170
|
-
}, remarkPlugins: [[remarkGfm, Object.assign({}, remarkGfmProps)], ...additionalRemarkPlugins], rehypePlugins: rehypePlugins }, reactMarkdownProps, { remarkRehypeOptions: Object.assign({
|
|
171
|
-
// removes sr-only class from footnote labels applied by default
|
|
172
|
-
footnoteLabelProperties: { className: [''] },
|
|
173
|
-
// omit default ↩ text; backref icon is rendered in LinkMessage
|
|
174
|
-
footnoteBackContent: (_referenceIndex, rereferenceIndex) => {
|
|
175
|
-
if (rereferenceIndex > 1) {
|
|
176
|
-
return [
|
|
177
|
-
{
|
|
178
|
-
type: 'element',
|
|
179
|
-
tagName: 'sup',
|
|
180
|
-
properties: {},
|
|
181
|
-
children: [{ type: 'text', value: String(rereferenceIndex) }]
|
|
182
|
-
}
|
|
183
|
-
];
|
|
184
|
-
}
|
|
185
|
-
return [];
|
|
186
|
-
} }, reactMarkdownProps === null || reactMarkdownProps === void 0 ? void 0 : reactMarkdownProps.remarkRehypeOptions), disallowedElements: disallowedElements, children: content })));
|
|
70
|
+
if (!isMarkdownRendererReady || !ResolvedMarkdownRenderer) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return _jsx(ResolvedMarkdownRenderer, Object.assign({}, markdownProps, { content: content, isPrimary: isPrimary }));
|
|
187
74
|
};
|
|
188
75
|
export default MarkdownContent;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type FunctionComponent } from 'react';
|
|
2
|
+
import 'highlight.js/styles/vs2015.css';
|
|
3
|
+
import type { MarkdownContentProps } from './MarkdownContent';
|
|
4
|
+
export type MarkdownRendererProps = Omit<MarkdownContentProps, 'isMarkdownDisabled' | 'textComponent'>;
|
|
5
|
+
declare const MarkdownRenderer: FunctionComponent<MarkdownRendererProps>;
|
|
6
|
+
export default MarkdownRenderer;
|