@patternfly/chatbot 6.5.0-prerelease.3 → 6.5.0-prerelease.30
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/AttachMenu/AttachMenu.d.ts +8 -2
- package/dist/cjs/AttachMenu/AttachMenu.js +2 -2
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +9 -1
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +9 -2
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +38 -0
- package/dist/cjs/ChatbotFooter/ChatbotFooter.d.ts +5 -2
- package/dist/cjs/ChatbotFooter/ChatbotFooter.js +2 -2
- package/dist/cjs/ChatbotFooter/ChatbotFooter.test.js +5 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.js +29 -2
- package/dist/cjs/CodeModal/CodeModal.d.ts +2 -0
- package/dist/cjs/CodeModal/CodeModal.js +53 -8
- package/dist/cjs/DeepThinking/DeepThinking.d.ts +13 -0
- package/dist/cjs/DeepThinking/DeepThinking.js +31 -3
- package/dist/cjs/DeepThinking/DeepThinking.test.js +80 -0
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.d.ts +2 -1
- package/dist/cjs/MarkdownContent/MarkdownContent.d.ts +44 -0
- package/dist/cjs/MarkdownContent/MarkdownContent.js +181 -0
- package/dist/cjs/MarkdownContent/MarkdownContent.test.d.ts +1 -0
- package/dist/cjs/MarkdownContent/MarkdownContent.test.js +192 -0
- package/dist/cjs/MarkdownContent/index.d.ts +2 -0
- package/dist/cjs/MarkdownContent/index.js +23 -0
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.d.ts +5 -1
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +16 -5
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.test.d.ts +1 -0
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.test.js +131 -0
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.d.ts +15 -1
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.js +5 -3
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.test.d.ts +1 -0
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.test.js +30 -0
- package/dist/cjs/Message/LinkMessage/LinkMessage.d.ts +5 -1
- package/dist/cjs/Message/LinkMessage/LinkMessage.js +4 -3
- package/dist/cjs/Message/ListMessage/OrderedListMessage.d.ts +9 -1
- package/dist/cjs/Message/ListMessage/OrderedListMessage.js +2 -1
- package/dist/cjs/Message/ListMessage/UnorderedListMessage.d.ts +7 -1
- package/dist/cjs/Message/ListMessage/UnorderedListMessage.js +2 -1
- package/dist/cjs/Message/Message.d.ts +22 -3
- package/dist/cjs/Message/Message.js +8 -161
- package/dist/cjs/Message/Message.test.js +161 -2
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.d.ts +14 -0
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.js +22 -0
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.test.d.ts +1 -0
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.test.js +25 -0
- package/dist/cjs/Message/MessageAndActions/index.d.ts +1 -0
- package/dist/cjs/Message/MessageAndActions/index.js +17 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.d.ts +13 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.js +22 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.test.d.ts +1 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.test.js +25 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.d.ts +13 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.js +22 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.test.d.ts +1 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.test.js +25 -0
- package/dist/cjs/Message/MessageAttachments/index.d.ts +2 -0
- package/dist/cjs/Message/MessageAttachments/index.js +18 -0
- package/dist/cjs/Message/MessageInput.d.ts +1 -1
- package/dist/cjs/Message/MessageInput.js +3 -1
- package/dist/cjs/Message/MessageLoading.d.ts +13 -3
- package/dist/cjs/Message/MessageLoading.js +19 -5
- package/dist/cjs/Message/MessageLoading.test.d.ts +1 -0
- package/dist/cjs/Message/MessageLoading.test.js +25 -0
- package/dist/cjs/Message/QuickResponse/QuickResponse.js +3 -2
- package/dist/cjs/Message/QuickResponse/QuickResponse.test.d.ts +1 -0
- package/dist/cjs/Message/QuickResponse/QuickResponse.test.js +109 -0
- package/dist/cjs/Message/QuickResponse/index.d.ts +1 -0
- package/dist/cjs/Message/QuickResponse/index.js +17 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTile.d.ts +1 -1
- package/dist/cjs/Message/QuickStarts/QuickStartTile.js +3 -2
- package/dist/cjs/Message/QuickStarts/index.d.ts +2 -0
- package/dist/cjs/Message/QuickStarts/index.js +18 -0
- package/dist/cjs/Message/TableMessage/TableMessage.d.ts +9 -1
- package/dist/cjs/Message/TableMessage/TableMessage.js +3 -2
- package/dist/cjs/Message/TextMessage/TextMessage.d.ts +11 -1
- package/dist/cjs/Message/TextMessage/TextMessage.js +3 -2
- package/dist/cjs/Message/UserFeedback/UserFeedback.d.ts +3 -1
- package/dist/cjs/Message/UserFeedback/UserFeedback.js +8 -6
- package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.d.ts +1 -1
- package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.js +3 -2
- package/dist/cjs/Message/UserFeedback/index.d.ts +2 -0
- package/dist/cjs/Message/UserFeedback/index.js +18 -0
- package/dist/cjs/Message/index.d.ts +8 -0
- package/dist/cjs/Message/index.js +8 -0
- package/dist/cjs/MessageBar/AttachButton.d.ts +2 -0
- package/dist/cjs/MessageBar/AttachButton.js +2 -2
- package/dist/cjs/MessageBar/AttachButton.test.js +4 -0
- package/dist/cjs/MessageBar/MessageBar.d.ts +22 -6
- package/dist/cjs/MessageBar/MessageBar.js +43 -11
- package/dist/cjs/MessageBar/MessageBar.test.js +74 -0
- package/dist/cjs/Onboarding/Onboarding.d.ts +36 -0
- package/dist/cjs/Onboarding/Onboarding.js +37 -0
- package/dist/cjs/Onboarding/Onboarding.test.d.ts +1 -0
- package/dist/cjs/Onboarding/Onboarding.test.js +80 -0
- package/dist/cjs/Onboarding/index.d.ts +2 -0
- package/dist/cjs/Onboarding/index.js +23 -0
- package/dist/cjs/ResponseActions/ResponseActions.d.ts +7 -0
- package/dist/cjs/ResponseActions/ResponseActions.js +28 -7
- package/dist/cjs/ResponseActions/ResponseActions.test.js +67 -12
- package/dist/cjs/ResponseActions/ResponseActionsGroups.d.ts +13 -0
- package/dist/cjs/ResponseActions/ResponseActionsGroups.js +22 -0
- package/dist/cjs/ResponseActions/ResponseActionsGroups.test.d.ts +1 -0
- package/dist/cjs/ResponseActions/ResponseActionsGroups.test.js +25 -0
- package/dist/cjs/ResponseActions/index.d.ts +1 -0
- package/dist/cjs/ResponseActions/index.js +1 -0
- package/dist/cjs/ToolCall/ToolCall.d.ts +11 -0
- package/dist/cjs/ToolCall/ToolCall.js +24 -3
- package/dist/cjs/ToolCall/ToolCall.test.js +57 -0
- package/dist/cjs/ToolResponse/ToolResponse.d.ts +17 -0
- package/dist/cjs/ToolResponse/ToolResponse.js +49 -3
- package/dist/cjs/ToolResponse/ToolResponse.test.js +100 -0
- package/dist/cjs/__mocks__/monaco-editor.d.ts +11 -0
- package/dist/cjs/__mocks__/monaco-editor.js +18 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +7 -1
- package/dist/css/main.css +336 -30
- package/dist/css/main.css.map +1 -1
- package/dist/dynamic/MarkdownContent/package.json +1 -0
- package/dist/dynamic/Onboarding/package.json +1 -0
- package/dist/esm/AttachMenu/AttachMenu.d.ts +8 -2
- package/dist/esm/AttachMenu/AttachMenu.js +2 -2
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +9 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +10 -3
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +38 -0
- package/dist/esm/ChatbotFooter/ChatbotFooter.d.ts +5 -2
- package/dist/esm/ChatbotFooter/ChatbotFooter.js +2 -2
- package/dist/esm/ChatbotFooter/ChatbotFooter.test.js +5 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +30 -3
- package/dist/esm/CodeModal/CodeModal.d.ts +2 -0
- package/dist/esm/CodeModal/CodeModal.js +54 -9
- package/dist/esm/DeepThinking/DeepThinking.d.ts +13 -0
- package/dist/esm/DeepThinking/DeepThinking.js +28 -3
- package/dist/esm/DeepThinking/DeepThinking.test.js +80 -0
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.d.ts +2 -1
- package/dist/esm/MarkdownContent/MarkdownContent.d.ts +44 -0
- package/dist/esm/MarkdownContent/MarkdownContent.js +174 -0
- package/dist/esm/MarkdownContent/MarkdownContent.test.d.ts +1 -0
- package/dist/esm/MarkdownContent/MarkdownContent.test.js +187 -0
- package/dist/esm/MarkdownContent/index.d.ts +2 -0
- package/dist/esm/MarkdownContent/index.js +2 -0
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.d.ts +5 -1
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +16 -5
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.test.d.ts +1 -0
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.test.js +126 -0
- package/dist/esm/Message/ErrorMessage/ErrorMessage.d.ts +15 -1
- package/dist/esm/Message/ErrorMessage/ErrorMessage.js +3 -3
- package/dist/esm/Message/ErrorMessage/ErrorMessage.test.d.ts +1 -0
- package/dist/esm/Message/ErrorMessage/ErrorMessage.test.js +25 -0
- package/dist/esm/Message/LinkMessage/LinkMessage.d.ts +5 -1
- package/dist/esm/Message/LinkMessage/LinkMessage.js +4 -3
- package/dist/esm/Message/ListMessage/OrderedListMessage.d.ts +9 -1
- package/dist/esm/Message/ListMessage/OrderedListMessage.js +2 -1
- package/dist/esm/Message/ListMessage/UnorderedListMessage.d.ts +7 -1
- package/dist/esm/Message/ListMessage/UnorderedListMessage.js +2 -1
- package/dist/esm/Message/Message.d.ts +22 -3
- package/dist/esm/Message/Message.js +9 -162
- package/dist/esm/Message/Message.test.js +161 -2
- package/dist/esm/Message/MessageAndActions/MessageAndActions.d.ts +14 -0
- package/dist/esm/Message/MessageAndActions/MessageAndActions.js +18 -0
- package/dist/esm/Message/MessageAndActions/MessageAndActions.test.d.ts +1 -0
- package/dist/esm/Message/MessageAndActions/MessageAndActions.test.js +20 -0
- package/dist/esm/Message/MessageAndActions/index.d.ts +1 -0
- package/dist/esm/Message/MessageAndActions/index.js +1 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.d.ts +13 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.js +18 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.test.d.ts +1 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.test.js +20 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.d.ts +13 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.js +18 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.test.d.ts +1 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.test.js +20 -0
- package/dist/esm/Message/MessageAttachments/index.d.ts +2 -0
- package/dist/esm/Message/MessageAttachments/index.js +2 -0
- package/dist/esm/Message/MessageInput.d.ts +1 -1
- package/dist/esm/Message/MessageInput.js +1 -1
- package/dist/esm/Message/MessageLoading.d.ts +13 -3
- package/dist/esm/Message/MessageLoading.js +16 -4
- package/dist/esm/Message/MessageLoading.test.d.ts +1 -0
- package/dist/esm/Message/MessageLoading.test.js +20 -0
- package/dist/esm/Message/QuickResponse/QuickResponse.js +3 -2
- package/dist/esm/Message/QuickResponse/QuickResponse.test.d.ts +1 -0
- package/dist/esm/Message/QuickResponse/QuickResponse.test.js +104 -0
- package/dist/esm/Message/QuickResponse/index.d.ts +1 -0
- package/dist/esm/Message/QuickResponse/index.js +1 -0
- package/dist/esm/Message/QuickStarts/QuickStartTile.d.ts +1 -1
- package/dist/esm/Message/QuickStarts/QuickStartTile.js +1 -1
- package/dist/esm/Message/QuickStarts/index.d.ts +2 -0
- package/dist/esm/Message/QuickStarts/index.js +2 -0
- package/dist/esm/Message/TableMessage/TableMessage.d.ts +9 -1
- package/dist/esm/Message/TableMessage/TableMessage.js +3 -2
- package/dist/esm/Message/TextMessage/TextMessage.d.ts +11 -1
- package/dist/esm/Message/TextMessage/TextMessage.js +3 -2
- package/dist/esm/Message/UserFeedback/UserFeedback.d.ts +3 -1
- package/dist/esm/Message/UserFeedback/UserFeedback.js +7 -7
- package/dist/esm/Message/UserFeedback/UserFeedbackComplete.d.ts +1 -1
- package/dist/esm/Message/UserFeedback/UserFeedbackComplete.js +1 -2
- package/dist/esm/Message/UserFeedback/index.d.ts +2 -0
- package/dist/esm/Message/UserFeedback/index.js +2 -0
- package/dist/esm/Message/index.d.ts +8 -0
- package/dist/esm/Message/index.js +8 -0
- package/dist/esm/MessageBar/AttachButton.d.ts +2 -0
- package/dist/esm/MessageBar/AttachButton.js +2 -2
- package/dist/esm/MessageBar/AttachButton.test.js +4 -0
- package/dist/esm/MessageBar/MessageBar.d.ts +22 -6
- package/dist/esm/MessageBar/MessageBar.js +43 -11
- package/dist/esm/MessageBar/MessageBar.test.js +74 -0
- package/dist/esm/Onboarding/Onboarding.d.ts +36 -0
- package/dist/esm/Onboarding/Onboarding.js +30 -0
- package/dist/esm/Onboarding/Onboarding.test.d.ts +1 -0
- package/dist/esm/Onboarding/Onboarding.test.js +75 -0
- package/dist/esm/Onboarding/index.d.ts +2 -0
- package/dist/esm/Onboarding/index.js +2 -0
- package/dist/esm/ResponseActions/ResponseActions.d.ts +7 -0
- package/dist/esm/ResponseActions/ResponseActions.js +28 -7
- package/dist/esm/ResponseActions/ResponseActions.test.js +67 -12
- package/dist/esm/ResponseActions/ResponseActionsGroups.d.ts +13 -0
- package/dist/esm/ResponseActions/ResponseActionsGroups.js +18 -0
- package/dist/esm/ResponseActions/ResponseActionsGroups.test.d.ts +1 -0
- package/dist/esm/ResponseActions/ResponseActionsGroups.test.js +20 -0
- package/dist/esm/ResponseActions/index.d.ts +1 -0
- package/dist/esm/ResponseActions/index.js +1 -0
- package/dist/esm/ToolCall/ToolCall.d.ts +11 -0
- package/dist/esm/ToolCall/ToolCall.js +21 -3
- package/dist/esm/ToolCall/ToolCall.test.js +57 -0
- package/dist/esm/ToolResponse/ToolResponse.d.ts +17 -0
- package/dist/esm/ToolResponse/ToolResponse.js +46 -3
- package/dist/esm/ToolResponse/ToolResponse.test.js +100 -0
- package/dist/esm/__mocks__/monaco-editor.d.ts +11 -0
- package/dist/esm/__mocks__/monaco-editor.js +18 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -2
- package/patternfly-docs/content/extensions/chatbot/chatbot.md +57 -0
- package/patternfly-docs/content/extensions/chatbot/design-guidelines.md +12 -12
- package/patternfly-docs/content/extensions/chatbot/examples/Analytics/Analytics.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Customizing Messages/Customizing Messages.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +1 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithCustomStructure.tsx +102 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithDeepThinking.tsx +25 -11
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithFeedback.tsx +14 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithMarkdownDeepThinking.tsx +26 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithMarkdownToolCall.tsx +29 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithMarkdownToolResponse.tsx +200 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithMultipleActionGroups.tsx +61 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithPersistedActions.tsx +22 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx +11 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithToolCall.tsx +14 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithToolResponse.tsx +222 -105
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +123 -14
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +1 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessageWithExtraContent.tsx +3 -1
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithSearchActions.tsx +198 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotMessageBarCustomActions.tsx +190 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotMessageBarIndicatorThinking.tsx +15 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/CompactOnboarding.tsx +141 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/Onboarding.tsx +151 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/RH-Hat-Image.svg +9 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/Settings.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +81 -30
- package/patternfly-docs/content/extensions/chatbot/examples/demos/AttachmentDemos.md +18 -18
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +44 -22
- package/patternfly-docs/content/extensions/chatbot/examples/demos/WhiteEmbeddedChatbot.tsx +451 -0
- package/patternfly-docs/patternfly-docs.config.js +1 -1
- package/patternfly-docs/patternfly-docs.source.js +1 -1
- package/src/AttachMenu/AttachMenu.tsx +26 -11
- package/src/Chatbot/Chatbot.scss +23 -1
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +43 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +95 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +51 -15
- package/src/ChatbotFooter/ChatbotFooter.scss +21 -0
- package/src/ChatbotFooter/ChatbotFooter.test.tsx +10 -1
- package/src/ChatbotFooter/ChatbotFooter.tsx +10 -3
- package/src/ChatbotHeader/ChatbotHeader.scss +19 -0
- package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +56 -14
- package/src/ChatbotModal/ChatbotModal.scss +3 -0
- package/src/CodeModal/CodeModal.tsx +72 -23
- package/src/DeepThinking/DeepThinking.scss +1 -1
- package/src/DeepThinking/DeepThinking.test.tsx +109 -0
- package/src/DeepThinking/DeepThinking.tsx +54 -5
- package/src/FileDetailsLabel/FileDetailsLabel.tsx +2 -2
- package/src/MarkdownContent/MarkdownContent.test.tsx +207 -0
- package/src/MarkdownContent/MarkdownContent.tsx +269 -0
- package/src/MarkdownContent/index.ts +2 -0
- package/src/Message/CodeBlockMessage/CodeBlockMessage.scss +17 -0
- package/src/Message/CodeBlockMessage/CodeBlockMessage.test.tsx +171 -0
- package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +21 -5
- package/src/Message/ErrorMessage/ErrorMessage.test.tsx +38 -0
- package/src/Message/ErrorMessage/ErrorMessage.tsx +17 -2
- package/src/Message/LinkMessage/LinkMessage.scss +5 -0
- package/src/Message/LinkMessage/LinkMessage.tsx +24 -2
- package/src/Message/ListMessage/ListMessage.scss +8 -0
- package/src/Message/ListMessage/OrderedListMessage.tsx +16 -2
- package/src/Message/ListMessage/UnorderedListMessage.tsx +12 -2
- package/src/Message/Message.scss +11 -7
- package/src/Message/Message.test.tsx +239 -2
- package/src/Message/Message.tsx +133 -241
- package/src/Message/MessageAndActions/MessageAndActions.test.tsx +23 -0
- package/src/Message/MessageAndActions/MessageAndActions.tsx +22 -0
- package/src/Message/MessageAndActions/index.ts +1 -0
- package/src/Message/MessageAttachments/MessageAttachmentItem.test.tsx +23 -0
- package/src/Message/MessageAttachments/MessageAttachmentItem.tsx +25 -0
- package/src/Message/MessageAttachments/MessageAttachmentsContainer.test.tsx +23 -0
- package/src/Message/MessageAttachments/MessageAttachmentsContainer.tsx +25 -0
- package/src/Message/MessageAttachments/index.ts +2 -0
- package/src/Message/MessageInput.tsx +1 -1
- package/src/Message/MessageLoading.scss +7 -0
- package/src/Message/MessageLoading.test.tsx +23 -0
- package/src/Message/MessageLoading.tsx +17 -2
- package/src/Message/QuickResponse/QuickResponse.scss +3 -1
- package/src/Message/QuickResponse/QuickResponse.test.tsx +131 -0
- package/src/Message/QuickResponse/QuickResponse.tsx +3 -2
- package/src/Message/QuickResponse/index.ts +1 -0
- package/src/Message/QuickStarts/QuickStartTile.tsx +1 -1
- package/src/Message/QuickStarts/index.ts +2 -0
- package/src/Message/TableMessage/TableMessage.scss +17 -1
- package/src/Message/TableMessage/TableMessage.tsx +22 -2
- package/src/Message/TextMessage/TextMessage.scss +18 -0
- package/src/Message/TextMessage/TextMessage.tsx +39 -3
- package/src/Message/UserFeedback/UserFeedback.scss +30 -2
- package/src/Message/UserFeedback/UserFeedback.tsx +23 -13
- package/src/Message/UserFeedback/UserFeedbackComplete.tsx +1 -4
- package/src/Message/UserFeedback/index.ts +2 -0
- package/src/Message/index.ts +8 -0
- package/src/MessageBar/AttachButton.scss +0 -1
- package/src/MessageBar/AttachButton.test.tsx +4 -0
- package/src/MessageBar/AttachButton.tsx +4 -1
- package/src/MessageBar/MessageBar.scss +66 -6
- package/src/MessageBar/MessageBar.test.tsx +129 -1
- package/src/MessageBar/MessageBar.tsx +150 -56
- package/src/MessageBar/MicrophoneButton.scss +0 -1
- package/src/MessageBar/SendButton.scss +0 -1
- package/src/MessageBar/StopButton.scss +0 -1
- package/src/Onboarding/Onboarding.scss +101 -0
- package/src/Onboarding/Onboarding.test.tsx +148 -0
- package/src/Onboarding/Onboarding.tsx +126 -0
- package/src/Onboarding/index.ts +3 -0
- package/src/ResponseActions/ResponseActions.scss +12 -1
- package/src/ResponseActions/ResponseActions.test.tsx +111 -12
- package/src/ResponseActions/ResponseActions.tsx +44 -10
- package/src/ResponseActions/ResponseActionsGroups.test.tsx +23 -0
- package/src/ResponseActions/ResponseActionsGroups.tsx +28 -0
- package/src/ResponseActions/index.ts +1 -0
- package/src/ToolCall/ToolCall.scss +1 -1
- package/src/ToolCall/ToolCall.test.tsx +91 -0
- package/src/ToolCall/ToolCall.tsx +49 -4
- package/src/ToolResponse/ToolResponse.scss +13 -3
- package/src/ToolResponse/ToolResponse.test.tsx +119 -0
- package/src/ToolResponse/ToolResponse.tsx +82 -7
- package/src/__mocks__/monaco-editor.ts +19 -0
- package/src/index.ts +6 -0
- package/src/main.scss +2 -0
- package/tsconfig.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/about-chatbot.md +0 -44
|
@@ -14,10 +14,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
import { useEffect, useRef, useState } from 'react';
|
|
15
15
|
import { ExternalLinkAltIcon, VolumeUpIcon, OutlinedThumbsUpIcon, OutlinedThumbsDownIcon, OutlinedCopyIcon, DownloadIcon, PencilAltIcon } from '@patternfly/react-icons';
|
|
16
16
|
import ResponseActionButton from './ResponseActionButton';
|
|
17
|
-
export const ResponseActions = ({ actions }) => {
|
|
17
|
+
export const ResponseActions = ({ actions, persistActionSelection = false }) => {
|
|
18
18
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
19
19
|
const [activeButton, setActiveButton] = useState();
|
|
20
20
|
const [clickStatePersisted, setClickStatePersisted] = useState(false);
|
|
21
|
+
const { positive, negative, copy, edit, share, download, listen } = actions, additionalActions = __rest(actions, ["positive", "negative", "copy", "edit", "share", "download", "listen"]);
|
|
21
22
|
useEffect(() => {
|
|
22
23
|
// Define the order of precedence for checking initial `isClicked`
|
|
23
24
|
const actionPrecedence = ['positive', 'negative', 'copy', 'edit', 'share', 'download', 'listen'];
|
|
@@ -39,11 +40,18 @@ export const ResponseActions = ({ actions }) => {
|
|
|
39
40
|
// Click state is explicitly controlled by consumer.
|
|
40
41
|
setClickStatePersisted(true);
|
|
41
42
|
}
|
|
43
|
+
// If persistActionSelection is true, all selections are persisted
|
|
44
|
+
if (persistActionSelection) {
|
|
45
|
+
setClickStatePersisted(true);
|
|
46
|
+
}
|
|
42
47
|
setActiveButton(initialActive);
|
|
43
|
-
}, [actions]);
|
|
44
|
-
const { positive, negative, copy, edit, share, download, listen } = actions, additionalActions = __rest(actions, ["positive", "negative", "copy", "edit", "share", "download", "listen"]);
|
|
48
|
+
}, [actions, persistActionSelection]);
|
|
45
49
|
const responseActions = useRef(null);
|
|
46
50
|
useEffect(() => {
|
|
51
|
+
// Only add click outside listener if not persisting selection
|
|
52
|
+
if (persistActionSelection) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
47
55
|
const handleClickOutside = (e) => {
|
|
48
56
|
if (responseActions.current && !responseActions.current.contains(e.target) && !clickStatePersisted) {
|
|
49
57
|
setActiveButton(undefined);
|
|
@@ -53,13 +61,26 @@ export const ResponseActions = ({ actions }) => {
|
|
|
53
61
|
return () => {
|
|
54
62
|
window.removeEventListener('click', handleClickOutside);
|
|
55
63
|
};
|
|
56
|
-
}, [clickStatePersisted]);
|
|
64
|
+
}, [clickStatePersisted, persistActionSelection]);
|
|
57
65
|
const handleClick = (e, id, onClick) => {
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
if (persistActionSelection) {
|
|
67
|
+
if (activeButton === id) {
|
|
68
|
+
// Toggle off if clicking the same button
|
|
69
|
+
setActiveButton(undefined);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Set new active button
|
|
73
|
+
setActiveButton(id);
|
|
74
|
+
}
|
|
75
|
+
setClickStatePersisted(true);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
setClickStatePersisted(false);
|
|
79
|
+
setActiveButton(id);
|
|
80
|
+
}
|
|
60
81
|
onClick && onClick(e);
|
|
61
82
|
};
|
|
62
|
-
return (_jsxs("div", { ref: responseActions, className: "pf-chatbot__response-actions", children: [positive && (_jsx(ResponseActionButton, Object.assign({}, positive, { ariaLabel: (_a = positive.ariaLabel) !== null && _a !== void 0 ? _a : 'Good response', clickedAriaLabel: (_b = positive.ariaLabel) !== null && _b !== void 0 ? _b : '
|
|
83
|
+
return (_jsxs("div", { ref: responseActions, className: "pf-chatbot__response-actions", children: [positive && (_jsx(ResponseActionButton, Object.assign({}, positive, { ariaLabel: (_a = positive.ariaLabel) !== null && _a !== void 0 ? _a : 'Good response', clickedAriaLabel: (_b = positive.ariaLabel) !== null && _b !== void 0 ? _b : 'Good response recorded', onClick: (e) => handleClick(e, 'positive', positive.onClick), className: positive.className, isDisabled: positive.isDisabled, tooltipContent: (_c = positive.tooltipContent) !== null && _c !== void 0 ? _c : 'Good response', clickedTooltipContent: (_d = positive.clickedTooltipContent) !== null && _d !== void 0 ? _d : 'Good response recorded', tooltipProps: positive.tooltipProps, icon: _jsx(OutlinedThumbsUpIcon, {}), isClicked: activeButton === 'positive', ref: positive.ref, "aria-expanded": positive['aria-expanded'], "aria-controls": positive['aria-controls'] }))), negative && (_jsx(ResponseActionButton, Object.assign({}, negative, { ariaLabel: (_e = negative.ariaLabel) !== null && _e !== void 0 ? _e : 'Bad response', clickedAriaLabel: (_f = negative.ariaLabel) !== null && _f !== void 0 ? _f : 'Bad response recorded', onClick: (e) => handleClick(e, 'negative', negative.onClick), className: negative.className, isDisabled: negative.isDisabled, tooltipContent: (_g = negative.tooltipContent) !== null && _g !== void 0 ? _g : 'Bad response', clickedTooltipContent: (_h = negative.clickedTooltipContent) !== null && _h !== void 0 ? _h : 'Bad response recorded', tooltipProps: negative.tooltipProps, icon: _jsx(OutlinedThumbsDownIcon, {}), isClicked: activeButton === 'negative', ref: negative.ref, "aria-expanded": negative['aria-expanded'], "aria-controls": negative['aria-controls'] }))), copy && (_jsx(ResponseActionButton, Object.assign({}, copy, { ariaLabel: (_j = copy.ariaLabel) !== null && _j !== void 0 ? _j : 'Copy', clickedAriaLabel: (_k = copy.ariaLabel) !== null && _k !== void 0 ? _k : 'Copied', onClick: (e) => handleClick(e, 'copy', copy.onClick), className: copy.className, isDisabled: copy.isDisabled, tooltipContent: (_l = copy.tooltipContent) !== null && _l !== void 0 ? _l : 'Copy', clickedTooltipContent: (_m = copy.clickedTooltipContent) !== null && _m !== void 0 ? _m : 'Copied', tooltipProps: copy.tooltipProps, icon: _jsx(OutlinedCopyIcon, {}), isClicked: activeButton === 'copy', ref: copy.ref, "aria-expanded": copy['aria-expanded'], "aria-controls": copy['aria-controls'] }))), edit && (_jsx(ResponseActionButton, Object.assign({}, edit, { ariaLabel: (_o = edit.ariaLabel) !== null && _o !== void 0 ? _o : 'Edit', clickedAriaLabel: (_p = edit.ariaLabel) !== null && _p !== void 0 ? _p : 'Editing', onClick: (e) => handleClick(e, 'edit', edit.onClick), className: edit.className, isDisabled: edit.isDisabled, tooltipContent: (_q = edit.tooltipContent) !== null && _q !== void 0 ? _q : 'Edit ', clickedTooltipContent: (_r = edit.clickedTooltipContent) !== null && _r !== void 0 ? _r : 'Editing', tooltipProps: edit.tooltipProps, icon: _jsx(PencilAltIcon, {}), isClicked: activeButton === 'edit', ref: edit.ref, "aria-expanded": edit['aria-expanded'], "aria-controls": edit['aria-controls'] }))), share && (_jsx(ResponseActionButton, Object.assign({}, share, { ariaLabel: (_s = share.ariaLabel) !== null && _s !== void 0 ? _s : 'Share', clickedAriaLabel: (_t = share.ariaLabel) !== null && _t !== void 0 ? _t : 'Shared', onClick: (e) => handleClick(e, 'share', share.onClick), className: share.className, isDisabled: share.isDisabled, tooltipContent: (_u = share.tooltipContent) !== null && _u !== void 0 ? _u : 'Share', clickedTooltipContent: (_v = share.clickedTooltipContent) !== null && _v !== void 0 ? _v : 'Shared', tooltipProps: share.tooltipProps, icon: _jsx(ExternalLinkAltIcon, {}), isClicked: activeButton === 'share', ref: share.ref, "aria-expanded": share['aria-expanded'], "aria-controls": share['aria-controls'] }))), download && (_jsx(ResponseActionButton, Object.assign({}, download, { ariaLabel: (_w = download.ariaLabel) !== null && _w !== void 0 ? _w : 'Download', clickedAriaLabel: (_x = download.ariaLabel) !== null && _x !== void 0 ? _x : 'Downloaded', onClick: (e) => handleClick(e, 'download', download.onClick), className: download.className, isDisabled: download.isDisabled, tooltipContent: (_y = download.tooltipContent) !== null && _y !== void 0 ? _y : 'Download', clickedTooltipContent: (_z = download.clickedTooltipContent) !== null && _z !== void 0 ? _z : 'Downloaded', tooltipProps: download.tooltipProps, icon: _jsx(DownloadIcon, {}), isClicked: activeButton === 'download', ref: download.ref, "aria-expanded": download['aria-expanded'], "aria-controls": download['aria-controls'] }))), listen && (_jsx(ResponseActionButton, Object.assign({}, listen, { ariaLabel: (_0 = listen.ariaLabel) !== null && _0 !== void 0 ? _0 : 'Listen', clickedAriaLabel: (_1 = listen.ariaLabel) !== null && _1 !== void 0 ? _1 : 'Listening', onClick: (e) => handleClick(e, 'listen', listen.onClick), className: listen.className, isDisabled: listen.isDisabled, tooltipContent: (_2 = listen.tooltipContent) !== null && _2 !== void 0 ? _2 : 'Listen', clickedTooltipContent: (_3 = listen.clickedTooltipContent) !== null && _3 !== void 0 ? _3 : 'Listening', tooltipProps: listen.tooltipProps, icon: _jsx(VolumeUpIcon, {}), isClicked: activeButton === 'listen', ref: listen.ref, "aria-expanded": listen['aria-expanded'], "aria-controls": listen['aria-controls'] }))), Object.keys(additionalActions).map((action) => {
|
|
63
84
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
64
85
|
return (_createElement(ResponseActionButton, Object.assign({}, additionalActions[action], { key: action, ariaLabel: (_a = additionalActions[action]) === null || _a === void 0 ? void 0 : _a.ariaLabel, clickedAriaLabel: (_b = additionalActions[action]) === null || _b === void 0 ? void 0 : _b.clickedAriaLabel, onClick: (e) => { var _a; return handleClick(e, action, (_a = additionalActions[action]) === null || _a === void 0 ? void 0 : _a.onClick); }, className: (_c = additionalActions[action]) === null || _c === void 0 ? void 0 : _c.className, isDisabled: (_d = additionalActions[action]) === null || _d === void 0 ? void 0 : _d.isDisabled, tooltipContent: (_e = additionalActions[action]) === null || _e === void 0 ? void 0 : _e.tooltipContent, tooltipProps: (_f = additionalActions[action]) === null || _f === void 0 ? void 0 : _f.tooltipProps, clickedTooltipContent: (_g = additionalActions[action]) === null || _g === void 0 ? void 0 : _g.clickedTooltipContent, icon: (_h = additionalActions[action]) === null || _h === void 0 ? void 0 : _h.icon, isClicked: activeButton === action, ref: (_j = additionalActions[action]) === null || _j === void 0 ? void 0 : _j.ref, "aria-expanded": (_k = additionalActions[action]) === null || _k === void 0 ? void 0 : _k['aria-expanded'], "aria-controls": (_l = additionalActions[action]) === null || _l === void 0 ? void 0 : _l['aria-controls'] })));
|
|
65
86
|
})] }));
|
|
@@ -15,8 +15,8 @@ import userEvent from '@testing-library/user-event';
|
|
|
15
15
|
import { DownloadIcon, InfoCircleIcon, RedoIcon } from '@patternfly/react-icons';
|
|
16
16
|
import Message from '../Message';
|
|
17
17
|
const ALL_ACTIONS = [
|
|
18
|
-
{ type: 'positive', label: 'Good response', clickedLabel: '
|
|
19
|
-
{ type: 'negative', label: 'Bad response', clickedLabel: '
|
|
18
|
+
{ type: 'positive', label: 'Good response', clickedLabel: 'Good response recorded' },
|
|
19
|
+
{ type: 'negative', label: 'Bad response', clickedLabel: 'Bad response recorded' },
|
|
20
20
|
{ type: 'copy', label: 'Copy', clickedLabel: 'Copied' },
|
|
21
21
|
{ type: 'edit', label: 'Edit', clickedLabel: 'Editing' },
|
|
22
22
|
{ type: 'share', label: 'Share', clickedLabel: 'Shared' },
|
|
@@ -83,13 +83,13 @@ describe('ResponseActions', () => {
|
|
|
83
83
|
expect(button).toBeTruthy();
|
|
84
84
|
});
|
|
85
85
|
yield userEvent.click(goodBtn);
|
|
86
|
-
expect(screen.getByRole('button', { name: '
|
|
86
|
+
expect(screen.getByRole('button', { name: 'Good response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
87
87
|
let unclickedButtons = buttons.filter((button) => button !== goodBtn);
|
|
88
88
|
unclickedButtons.forEach((button) => {
|
|
89
89
|
expect(button).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
90
90
|
});
|
|
91
91
|
yield userEvent.click(badBtn);
|
|
92
|
-
expect(screen.getByRole('button', { name: '
|
|
92
|
+
expect(screen.getByRole('button', { name: 'Bad response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
93
93
|
unclickedButtons = buttons.filter((button) => button !== badBtn);
|
|
94
94
|
unclickedButtons.forEach((button) => {
|
|
95
95
|
expect(button).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
@@ -106,10 +106,10 @@ describe('ResponseActions', () => {
|
|
|
106
106
|
expect(goodBtn).toBeTruthy();
|
|
107
107
|
expect(badBtn).toBeTruthy();
|
|
108
108
|
yield userEvent.click(goodBtn);
|
|
109
|
-
expect(screen.getByRole('button', { name: '
|
|
109
|
+
expect(screen.getByRole('button', { name: 'Good response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
110
110
|
expect(badBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
111
111
|
yield userEvent.click(badBtn);
|
|
112
|
-
expect(screen.getByRole('button', { name: '
|
|
112
|
+
expect(screen.getByRole('button', { name: 'Bad response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
113
113
|
expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
114
114
|
yield userEvent.click(screen.getByText("I updated your account with those settings. You're ready to set up your first dashboard!"));
|
|
115
115
|
expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
@@ -182,28 +182,28 @@ describe('ResponseActions', () => {
|
|
|
182
182
|
});
|
|
183
183
|
});
|
|
184
184
|
it('should be able to call onClick correctly', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
185
|
-
|
|
185
|
+
for (const { type, label } of ALL_ACTIONS) {
|
|
186
186
|
const spy = jest.fn();
|
|
187
187
|
render(_jsx(ResponseActions, { actions: { [type]: { onClick: spy } } }));
|
|
188
188
|
yield userEvent.click(screen.getByRole('button', { name: label }));
|
|
189
189
|
expect(spy).toHaveBeenCalledTimes(1);
|
|
190
|
-
}
|
|
190
|
+
}
|
|
191
191
|
}));
|
|
192
192
|
it('should swap clicked and non-clicked aria labels on click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
193
|
-
|
|
193
|
+
for (const { type, label, clickedLabel } of ALL_ACTIONS) {
|
|
194
194
|
render(_jsx(ResponseActions, { actions: { [type]: { onClick: jest.fn() } } }));
|
|
195
195
|
expect(screen.getByRole('button', { name: label })).toBeTruthy();
|
|
196
196
|
yield userEvent.click(screen.getByRole('button', { name: label }));
|
|
197
197
|
expect(screen.getByRole('button', { name: clickedLabel })).toBeTruthy();
|
|
198
|
-
}
|
|
198
|
+
}
|
|
199
199
|
}));
|
|
200
200
|
it('should swap clicked and non-clicked tooltips on click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
201
|
-
|
|
201
|
+
for (const { type, label, clickedLabel } of ALL_ACTIONS) {
|
|
202
202
|
render(_jsx(ResponseActions, { actions: { [type]: { onClick: jest.fn() } } }));
|
|
203
203
|
expect(screen.getByRole('button', { name: label })).toBeTruthy();
|
|
204
204
|
yield userEvent.click(screen.getByRole('button', { name: label }));
|
|
205
205
|
expect(screen.getByRole('tooltip', { name: clickedLabel })).toBeTruthy();
|
|
206
|
-
}
|
|
206
|
+
}
|
|
207
207
|
}));
|
|
208
208
|
it('should be able to change aria labels', () => {
|
|
209
209
|
const actions = [
|
|
@@ -255,4 +255,59 @@ describe('ResponseActions', () => {
|
|
|
255
255
|
expect(screen.getByTestId(action[key])).toBeTruthy();
|
|
256
256
|
});
|
|
257
257
|
});
|
|
258
|
+
// we are testing for the reverse case already above
|
|
259
|
+
it('should not deselect when clicking outside when persistActionSelection is true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
260
|
+
render(_jsx(Message, { name: "Bot", role: "bot", avatar: "", content: "Test content", actions: {
|
|
261
|
+
positive: {},
|
|
262
|
+
negative: {}
|
|
263
|
+
}, persistActionSelection: true }));
|
|
264
|
+
const goodBtn = screen.getByRole('button', { name: 'Good response' });
|
|
265
|
+
yield userEvent.click(goodBtn);
|
|
266
|
+
expect(screen.getByRole('button', { name: 'Good response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
267
|
+
yield userEvent.click(screen.getByText('Test content'));
|
|
268
|
+
expect(screen.getByRole('button', { name: 'Good response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
269
|
+
}));
|
|
270
|
+
it('should switch selection to another button when persistActionSelection is true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
271
|
+
render(_jsx(Message, { name: "Bot", role: "bot", avatar: "", content: "Test content", actions: {
|
|
272
|
+
positive: {},
|
|
273
|
+
negative: {}
|
|
274
|
+
}, persistActionSelection: true }));
|
|
275
|
+
const goodBtn = screen.getByRole('button', { name: 'Good response' });
|
|
276
|
+
const badBtn = screen.getByRole('button', { name: 'Bad response' });
|
|
277
|
+
yield userEvent.click(goodBtn);
|
|
278
|
+
expect(goodBtn).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
279
|
+
yield userEvent.click(badBtn);
|
|
280
|
+
expect(badBtn).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
281
|
+
expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
282
|
+
}));
|
|
283
|
+
it('should toggle off when clicking the same button when persistActionSelection is true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
284
|
+
render(_jsx(Message, { name: "Bot", role: "bot", avatar: "", content: "Test content", actions: {
|
|
285
|
+
positive: {},
|
|
286
|
+
negative: {}
|
|
287
|
+
}, persistActionSelection: true }));
|
|
288
|
+
const goodBtn = screen.getByRole('button', { name: 'Good response' });
|
|
289
|
+
yield userEvent.click(goodBtn);
|
|
290
|
+
expect(goodBtn).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
291
|
+
yield userEvent.click(goodBtn);
|
|
292
|
+
expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
293
|
+
}));
|
|
294
|
+
it('should work with custom actions when persistActionSelection is true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
295
|
+
const actions = {
|
|
296
|
+
positive: { 'data-testid': 'positive', onClick: jest.fn() },
|
|
297
|
+
negative: { 'data-testid': 'negative', onClick: jest.fn() },
|
|
298
|
+
custom: {
|
|
299
|
+
'data-testid': 'custom',
|
|
300
|
+
onClick: jest.fn(),
|
|
301
|
+
ariaLabel: 'Custom',
|
|
302
|
+
tooltipContent: 'Custom action',
|
|
303
|
+
icon: _jsx(DownloadIcon, {})
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
render(_jsx(ResponseActions, { actions: actions, persistActionSelection: true }));
|
|
307
|
+
const customBtn = screen.getByTestId('custom');
|
|
308
|
+
yield userEvent.click(customBtn);
|
|
309
|
+
expect(customBtn).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
310
|
+
yield userEvent.click(customBtn);
|
|
311
|
+
expect(customBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
312
|
+
}));
|
|
258
313
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FunctionComponent, HTMLProps, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The container for grouping multiple related ResponseActions components, typically used for having different persistence states amongst groups.
|
|
4
|
+
* Use this component when passing children to Message to customize its structure.
|
|
5
|
+
*/
|
|
6
|
+
export interface ResponseActionsGroupsProps extends HTMLProps<HTMLDivElement> {
|
|
7
|
+
/** Content to render inside the response actions groups container */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Additional classes applied to the response actions groups container. */
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const ResponseActionsGroups: FunctionComponent<ResponseActionsGroupsProps>;
|
|
13
|
+
export default ResponseActionsGroups;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { css } from '@patternfly/react-styles';
|
|
14
|
+
export const ResponseActionsGroups = (_a) => {
|
|
15
|
+
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
16
|
+
return (_jsx("div", Object.assign({ className: css('pf-chatbot__response-actions-groups', className) }, props, { children: children })));
|
|
17
|
+
};
|
|
18
|
+
export default ResponseActionsGroups;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import ResponseActionsGroups from './ResponseActionsGroups';
|
|
5
|
+
test('Renders with children', () => {
|
|
6
|
+
render(_jsx(ResponseActionsGroups, { children: "Test content" }));
|
|
7
|
+
expect(screen.getByText('Test content')).toBeInTheDocument();
|
|
8
|
+
});
|
|
9
|
+
test('Renders with pf-chatbot__response-actions-groups class by default', () => {
|
|
10
|
+
render(_jsx(ResponseActionsGroups, { children: "Test content" }));
|
|
11
|
+
expect(screen.getByText('Test content')).toHaveClass('pf-chatbot__response-actions-groups', { exact: true });
|
|
12
|
+
});
|
|
13
|
+
test('Renders with custom className', () => {
|
|
14
|
+
render(_jsx(ResponseActionsGroups, { className: "custom-class", children: "Test content" }));
|
|
15
|
+
expect(screen.getByText('Test content')).toHaveClass('custom-class');
|
|
16
|
+
});
|
|
17
|
+
test('Spreads additional props', () => {
|
|
18
|
+
render(_jsx(ResponseActionsGroups, { id: "test-id", children: "Test content" }));
|
|
19
|
+
expect(screen.getByText('Test content')).toHaveAttribute('id', 'test-id');
|
|
20
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type FunctionComponent } from 'react';
|
|
2
2
|
import { ActionListProps, ActionListGroupProps, ActionListItemProps, ButtonProps, CardProps, CardBodyProps, CardFooterProps, ExpandableSectionProps, SpinnerProps } from '@patternfly/react-core';
|
|
3
|
+
import type { MarkdownContentProps } from '../MarkdownContent';
|
|
3
4
|
export interface ToolCallProps {
|
|
4
5
|
/** Title text for the tool call. */
|
|
5
6
|
titleText: string;
|
|
@@ -11,6 +12,8 @@ export interface ToolCallProps {
|
|
|
11
12
|
spinnerProps?: SpinnerProps;
|
|
12
13
|
/** Content to render within an expandable section. */
|
|
13
14
|
expandableContent?: React.ReactNode;
|
|
15
|
+
/** Flag indicating whether the expandable content is expanded by default. */
|
|
16
|
+
isDefaultExpanded?: boolean;
|
|
14
17
|
/** Text content for the "run" action button. */
|
|
15
18
|
runButtonText?: string;
|
|
16
19
|
/** Additional props for the "run" action button. */
|
|
@@ -39,6 +42,14 @@ export interface ToolCallProps {
|
|
|
39
42
|
cardFooterProps?: CardFooterProps;
|
|
40
43
|
/** Additional props for the expandable section when expandableContent is passed. */
|
|
41
44
|
expandableSectionProps?: Omit<ExpandableSectionProps, 'ref'>;
|
|
45
|
+
/** Whether to enable markdown rendering for titleText. When true, titleText will be parsed as markdown. */
|
|
46
|
+
isTitleMarkdown?: boolean;
|
|
47
|
+
/** Whether to enable markdown rendering for expandableContent. When true and expandableContent is a string, it will be parsed as markdown. */
|
|
48
|
+
isExpandableContentMarkdown?: boolean;
|
|
49
|
+
/** Props passed to MarkdownContent component when markdown is enabled */
|
|
50
|
+
markdownContentProps?: Omit<MarkdownContentProps, 'content'>;
|
|
51
|
+
/** Whether to retain styles in the MarkdownContent component. Defaults to false. */
|
|
52
|
+
shouldRetainStyles?: boolean;
|
|
42
53
|
}
|
|
43
54
|
export declare const ToolCall: FunctionComponent<ToolCallProps>;
|
|
44
55
|
export default ToolCall;
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import { ActionList, ActionListGroup, ActionListItem, Button, Card, CardBody, CardFooter, ExpandableSection, Spinner } from '@patternfly/react-core';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import MarkdownContent from '../MarkdownContent';
|
|
5
|
+
export const ToolCall = ({ titleText, loadingText, isLoading, expandableContent, isDefaultExpanded = false, runButtonText = 'Run tool', runButtonProps, runActionItemProps, cancelButtonText = 'Cancel', cancelButtonProps, cancelActionItemProps, actions, actionListProps, actionListGroupProps, actionListItemProps, cardProps, cardBodyProps, cardFooterProps, expandableSectionProps, spinnerProps, isTitleMarkdown, isExpandableContentMarkdown, markdownContentProps, shouldRetainStyles = false }) => {
|
|
6
|
+
const [isExpanded, setIsExpanded] = useState(isDefaultExpanded);
|
|
7
|
+
const onToggle = (_event, isExpanded) => {
|
|
8
|
+
setIsExpanded(isExpanded);
|
|
9
|
+
};
|
|
10
|
+
const renderTitle = () => {
|
|
11
|
+
if (isTitleMarkdown) {
|
|
12
|
+
return _jsx(MarkdownContent, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: titleText }, markdownContentProps));
|
|
13
|
+
}
|
|
14
|
+
return titleText;
|
|
15
|
+
};
|
|
16
|
+
const titleContent = (_jsx("span", { className: `pf-chatbot__tool-call-title-content`, children: isLoading ? (_jsxs(_Fragment, { children: [_jsx(Spinner, Object.assign({ diameter: "1em" }, spinnerProps)), ' ', _jsx("span", { className: "pf-chatbot__tool-call-title-text", children: loadingText })] })) : (_jsx("span", { className: "pf-chatbot__tool-call-title-text", children: renderTitle() })) }));
|
|
17
|
+
const renderExpandableContent = () => {
|
|
18
|
+
if (isExpandableContentMarkdown && typeof expandableContent === 'string') {
|
|
19
|
+
return (_jsx(MarkdownContent, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: expandableContent }, markdownContentProps)));
|
|
20
|
+
}
|
|
21
|
+
return expandableContent;
|
|
22
|
+
};
|
|
5
23
|
const defaultActions = (_jsxs(_Fragment, { children: [_jsx(ActionListItem, Object.assign({}, actionListItemProps, cancelActionItemProps, { children: _jsx(Button, Object.assign({ variant: "link" }, cancelButtonProps, { children: cancelButtonText })) })), _jsx(ActionListItem, Object.assign({}, actionListItemProps, runActionItemProps, { children: _jsx(Button, Object.assign({ variant: "secondary" }, runButtonProps, { children: runButtonText })) }))] }));
|
|
6
24
|
const customActions = actions &&
|
|
7
25
|
actions.map((action, index) => (_jsx(ActionListItem, Object.assign({}, actionListItemProps, { children: action }), index)));
|
|
8
|
-
return (_jsxs(Card, Object.assign({ isCompact: true, className: "pf-chatbot__tool-call" }, cardProps, { children: [_jsx(CardBody, Object.assign({ className: "pf-chatbot__tool-call-title" }, cardBodyProps, { children: expandableContent && !isLoading ? (_jsx(ExpandableSection, Object.assign({ className: "pf-chatbot__tool-call-expandable-section", toggleContent: titleContent, isIndented: true }, expandableSectionProps, { children:
|
|
26
|
+
return (_jsxs(Card, Object.assign({ isCompact: true, className: "pf-chatbot__tool-call" }, cardProps, { children: [_jsx(CardBody, Object.assign({ className: "pf-chatbot__tool-call-title" }, cardBodyProps, { children: expandableContent && !isLoading ? (_jsx(ExpandableSection, Object.assign({ className: "pf-chatbot__tool-call-expandable-section", toggleContent: titleContent, onToggle: onToggle, isExpanded: isExpanded, isIndented: true }, expandableSectionProps, { children: renderExpandableContent() }))) : (titleContent) })), !isLoading && (_jsx(CardFooter, Object.assign({}, cardFooterProps, { children: _jsx(ActionList, Object.assign({ className: "pf-chatbot__tool-call-action-list" }, actionListProps, { children: _jsx(ActionListGroup, Object.assign({}, actionListGroupProps, { children: customActions || defaultActions })) })) })))] })));
|
|
9
27
|
};
|
|
10
28
|
export default ToolCall;
|
|
@@ -136,4 +136,61 @@ describe('ToolCall', () => {
|
|
|
136
136
|
render(_jsx(ToolCall, Object.assign({}, defaultProps, { cardFooterProps: { id: 'card-footer-test-id' } })));
|
|
137
137
|
expect(screen.getByRole('button', { name: 'Run tool' }).closest('#card-footer-test-id')).toBeVisible();
|
|
138
138
|
});
|
|
139
|
+
it('Renders collapsed by default when expandableContent is provided', () => {
|
|
140
|
+
render(_jsx(ToolCall, Object.assign({}, defaultProps, { expandableContent: "Expandable Content" })));
|
|
141
|
+
expect(screen.getByRole('button', { name: defaultProps.titleText })).toHaveAttribute('aria-expanded', 'false');
|
|
142
|
+
expect(screen.queryByText('Expandable Content')).not.toBeVisible();
|
|
143
|
+
});
|
|
144
|
+
it('Renders expanded when isDefaultExpanded is true', () => {
|
|
145
|
+
render(_jsx(ToolCall, Object.assign({}, defaultProps, { isDefaultExpanded: true, expandableContent: "Expandable Content" })));
|
|
146
|
+
expect(screen.getByRole('button', { name: defaultProps.titleText })).toHaveAttribute('aria-expanded', 'true');
|
|
147
|
+
expect(screen.getByText('Expandable Content')).toBeVisible();
|
|
148
|
+
});
|
|
149
|
+
it('expandableSectionProps.isExpanded overrides isDefaultExpanded', () => {
|
|
150
|
+
render(_jsx(ToolCall, Object.assign({}, defaultProps, { isDefaultExpanded: false, expandableContent: "Expandable Content", expandableSectionProps: { isExpanded: true } })));
|
|
151
|
+
expect(screen.getByRole('button', { name: defaultProps.titleText })).toHaveAttribute('aria-expanded', 'true');
|
|
152
|
+
expect(screen.getByText('Expandable Content')).toBeVisible();
|
|
153
|
+
});
|
|
154
|
+
it('expandableSectionProps.onToggle overrides internal onToggle behavior', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
+
const user = userEvent.setup();
|
|
156
|
+
const customOnToggle = jest.fn();
|
|
157
|
+
render(_jsx(ToolCall, Object.assign({}, defaultProps, { isDefaultExpanded: false, expandableContent: "Expandable Content", expandableSectionProps: { onToggle: customOnToggle } })));
|
|
158
|
+
const toggleButton = screen.getByRole('button', { name: defaultProps.titleText });
|
|
159
|
+
expect(toggleButton).toHaveAttribute('aria-expanded', 'false');
|
|
160
|
+
yield user.click(toggleButton);
|
|
161
|
+
expect(customOnToggle).toHaveBeenCalledTimes(1);
|
|
162
|
+
expect(toggleButton).toHaveAttribute('aria-expanded', 'false');
|
|
163
|
+
expect(screen.queryByText('Expandable Content')).not.toBeVisible();
|
|
164
|
+
}));
|
|
165
|
+
it('should render titleText as markdown when isTitleMarkdown is true', () => {
|
|
166
|
+
const titleText = '**Bold title**';
|
|
167
|
+
const { container } = render(_jsx(ToolCall, { titleText: titleText, isTitleMarkdown: true }));
|
|
168
|
+
expect(container.querySelector('strong')).toBeTruthy();
|
|
169
|
+
expect(screen.getByText('Bold title')).toBeTruthy();
|
|
170
|
+
});
|
|
171
|
+
it('should not render titleText as markdown when isTitleMarkdown is false', () => {
|
|
172
|
+
const titleText = '**Bold title**';
|
|
173
|
+
render(_jsx(ToolCall, { titleText: titleText }));
|
|
174
|
+
expect(screen.getByText('**Bold title**')).toBeTruthy();
|
|
175
|
+
});
|
|
176
|
+
it('should render expandableContent as markdown when isExpandableContentMarkdown is true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
177
|
+
const user = userEvent.setup();
|
|
178
|
+
const expandableContent = '**Bold expandable content**';
|
|
179
|
+
const { container } = render(_jsx(ToolCall, Object.assign({}, defaultProps, { expandableContent: expandableContent, isExpandableContentMarkdown: true })));
|
|
180
|
+
yield user.click(screen.getByRole('button', { name: defaultProps.titleText }));
|
|
181
|
+
expect(container.querySelector('strong')).toBeTruthy();
|
|
182
|
+
expect(screen.getByText('Bold expandable content')).toBeTruthy();
|
|
183
|
+
}));
|
|
184
|
+
it('should not render expandableContent as markdown when isExpandableContentMarkdown is false', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
185
|
+
const user = userEvent.setup();
|
|
186
|
+
const expandableContent = '**Bold expandable content**';
|
|
187
|
+
render(_jsx(ToolCall, Object.assign({}, defaultProps, { expandableContent: expandableContent })));
|
|
188
|
+
yield user.click(screen.getByRole('button', { name: defaultProps.titleText }));
|
|
189
|
+
expect(screen.getByText('**Bold expandable content**')).toBeTruthy();
|
|
190
|
+
}));
|
|
191
|
+
it('should pass markdownContentProps to MarkdownContent component', () => {
|
|
192
|
+
const titleText = '**Bold title**';
|
|
193
|
+
const { container } = render(_jsx(ToolCall, { titleText: titleText, isTitleMarkdown: true, markdownContentProps: { isPrimary: true } }));
|
|
194
|
+
expect(container.querySelector('.pf-m-primary')).toBeTruthy();
|
|
195
|
+
});
|
|
139
196
|
});
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { CardBodyProps, CardProps, CardTitleProps, DividerProps, ExpandableSectionProps } from '@patternfly/react-core';
|
|
2
2
|
import { type FunctionComponent } from 'react';
|
|
3
|
+
import type { MarkdownContentProps } from '../MarkdownContent';
|
|
3
4
|
export interface ToolResponseProps {
|
|
4
5
|
/** Toggle content shown for expandable section */
|
|
5
6
|
toggleContent: React.ReactNode;
|
|
7
|
+
/** Flag indicating whether the expandable content is expanded by default. */
|
|
8
|
+
isDefaultExpanded?: boolean;
|
|
6
9
|
/** Additional props passed to expandable section */
|
|
7
10
|
expandableSectionProps?: Omit<ExpandableSectionProps, 'ref'>;
|
|
8
11
|
/** Subheading rendered inside expandable section */
|
|
@@ -25,6 +28,20 @@ export interface ToolResponseProps {
|
|
|
25
28
|
toolResponseCardDividerProps?: DividerProps;
|
|
26
29
|
/** Additional props passed to tool response card title */
|
|
27
30
|
toolResponseCardTitleProps?: CardTitleProps;
|
|
31
|
+
/** Whether to enable markdown rendering for toggleContent. When true and toggleContent is a string, it will be parsed as markdown. */
|
|
32
|
+
isToggleContentMarkdown?: boolean;
|
|
33
|
+
/** Whether to enable markdown rendering for subheading. When true, subheading will be parsed as markdown. */
|
|
34
|
+
isSubheadingMarkdown?: boolean;
|
|
35
|
+
/** Whether to enable markdown rendering for body. When true and body is a string, it will be parsed as markdown. */
|
|
36
|
+
isBodyMarkdown?: boolean;
|
|
37
|
+
/** Whether to enable markdown rendering for cardBody. When true and cardBody is a string, it will be parsed as markdown. */
|
|
38
|
+
isCardBodyMarkdown?: boolean;
|
|
39
|
+
/** Whether to enable markdown rendering for cardTitle. When true and cardTitle is a string, it will be parsed as markdown. */
|
|
40
|
+
isCardTitleMarkdown?: boolean;
|
|
41
|
+
/** Props passed to MarkdownContent component when markdown is enabled */
|
|
42
|
+
markdownContentProps?: Omit<MarkdownContentProps, 'content'>;
|
|
43
|
+
/** Whether to retain styles in the MarkdownContent component. Defaults to false. */
|
|
44
|
+
shouldRetainStyles?: boolean;
|
|
28
45
|
}
|
|
29
46
|
export declare const ToolResponse: FunctionComponent<ToolResponseProps>;
|
|
30
47
|
export default ToolResponse;
|
|
@@ -4,11 +4,54 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
// ============================================================================
|
|
5
5
|
import { Card, CardBody, CardTitle, Divider, ExpandableSection } from '@patternfly/react-core';
|
|
6
6
|
import { useState } from 'react';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import MarkdownContent from '../MarkdownContent';
|
|
8
|
+
export const ToolResponse = ({ body, cardProps, expandableSectionProps, subheading, cardBody, cardTitle, cardBodyProps, toggleContent, isDefaultExpanded = true, toolResponseCardBodyProps, toolResponseCardDividerProps, toolResponseCardProps, toolResponseCardTitleProps, isToggleContentMarkdown, isSubheadingMarkdown, isBodyMarkdown, isCardBodyMarkdown, isCardTitleMarkdown, markdownContentProps, shouldRetainStyles = false }) => {
|
|
9
|
+
const [isExpanded, setIsExpanded] = useState(isDefaultExpanded);
|
|
9
10
|
const onToggle = (_event, isExpanded) => {
|
|
10
11
|
setIsExpanded(isExpanded);
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
+
const renderToggleContent = () => {
|
|
14
|
+
if (isToggleContentMarkdown && typeof toggleContent === 'string') {
|
|
15
|
+
return (_jsx(MarkdownContent, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: toggleContent }, markdownContentProps)));
|
|
16
|
+
}
|
|
17
|
+
return toggleContent;
|
|
18
|
+
};
|
|
19
|
+
const renderSubheading = () => {
|
|
20
|
+
if (!subheading) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
if (isSubheadingMarkdown) {
|
|
24
|
+
return _jsx(MarkdownContent, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: subheading }, markdownContentProps));
|
|
25
|
+
}
|
|
26
|
+
return subheading;
|
|
27
|
+
};
|
|
28
|
+
const renderBody = () => {
|
|
29
|
+
if (!body) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (isBodyMarkdown && typeof body === 'string') {
|
|
33
|
+
return _jsx(MarkdownContent, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: body }, markdownContentProps));
|
|
34
|
+
}
|
|
35
|
+
return body;
|
|
36
|
+
};
|
|
37
|
+
const renderCardTitle = () => {
|
|
38
|
+
if (!cardTitle) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (isCardTitleMarkdown && typeof cardTitle === 'string') {
|
|
42
|
+
return _jsx(MarkdownContent, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: cardTitle }, markdownContentProps));
|
|
43
|
+
}
|
|
44
|
+
return cardTitle;
|
|
45
|
+
};
|
|
46
|
+
const renderCardBody = () => {
|
|
47
|
+
if (!cardBody) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if (isCardBodyMarkdown && typeof cardBody === 'string') {
|
|
51
|
+
return _jsx(MarkdownContent, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: cardBody }, markdownContentProps));
|
|
52
|
+
}
|
|
53
|
+
return cardBody;
|
|
54
|
+
};
|
|
55
|
+
return (_jsx(Card, Object.assign({ isCompact: true, className: "pf-chatbot__tool-response" }, cardProps, { children: _jsx(CardBody, Object.assign({}, cardBodyProps, { children: _jsx(ExpandableSection, Object.assign({ toggleContent: renderToggleContent(), onToggle: onToggle, isExpanded: isExpanded, isIndented: true, className: "pf-chatbot__tool-response-expandable-section" }, expandableSectionProps, { children: _jsxs("div", { className: "pf-chatbot__tool-response-section", children: [subheading && (_jsx("div", { className: "pf-chatbot__tool-response-subheading", children: _jsx("span", { children: renderSubheading() }) })), body && _jsx("div", { className: "pf-chatbot__tool-response-body", children: renderBody() }), (cardTitle || cardBody) && (_jsxs(Card, Object.assign({ isCompact: true, className: "pf-chatbot__tool-response-card" }, toolResponseCardProps, { children: [cardTitle && _jsx(CardTitle, Object.assign({}, toolResponseCardTitleProps, { children: renderCardTitle() })), cardTitle && cardBody && _jsx(Divider, Object.assign({}, toolResponseCardDividerProps)), cardBody && _jsx(CardBody, Object.assign({}, toolResponseCardBodyProps, { children: renderCardBody() }))] })))] }) })) })) })));
|
|
13
56
|
};
|
|
14
57
|
export default ToolResponse;
|