@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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_1 = require("@testing-library/react");
|
|
17
|
+
require("@testing-library/jest-dom");
|
|
18
|
+
const user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
19
|
+
const Onboarding_1 = __importDefault(require("./Onboarding"));
|
|
20
|
+
const handleModalToggle = jest.fn();
|
|
21
|
+
const onPrimaryAction = jest.fn();
|
|
22
|
+
const onSecondaryAction = jest.fn();
|
|
23
|
+
const body = 'Experience personalized assistance and seamless problem-solving, simplifying your journey with Red Hat every step of the way.';
|
|
24
|
+
describe('Onboarding', () => {
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
jest.clearAllMocks();
|
|
27
|
+
});
|
|
28
|
+
it('should render modal correctly', () => {
|
|
29
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, ouiaId: "Terms", children: body }));
|
|
30
|
+
expect(react_1.screen.getByRole('heading', { name: /Onboarding/i })).toBeTruthy();
|
|
31
|
+
expect(react_1.screen.getByRole('button', { name: /Continue/i })).toBeTruthy();
|
|
32
|
+
expect(react_1.screen.getByRole('button', { name: /Skip/i })).toBeTruthy();
|
|
33
|
+
expect(react_1.screen.getByText(body)).toBeTruthy();
|
|
34
|
+
expect(react_1.screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal');
|
|
35
|
+
expect(react_1.screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal--default');
|
|
36
|
+
});
|
|
37
|
+
it('should handle image and altText props', () => {
|
|
38
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, headerImage: "./image.png", headerImageAltText: "Test image", children: body }));
|
|
39
|
+
expect(react_1.screen.getByRole('img')).toBeTruthy();
|
|
40
|
+
expect(react_1.screen.getByRole('img')).toHaveAttribute('alt', 'Test image');
|
|
41
|
+
});
|
|
42
|
+
it('should handle className prop', () => {
|
|
43
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, className: "test", children: body }));
|
|
44
|
+
expect(react_1.screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal');
|
|
45
|
+
expect(react_1.screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal--default');
|
|
46
|
+
expect(react_1.screen.getByRole('dialog')).toHaveClass('test');
|
|
47
|
+
});
|
|
48
|
+
it('should handle title prop', () => {
|
|
49
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, title: "Updated title", children: body }));
|
|
50
|
+
expect(react_1.screen.getByRole('heading', { name: /Updated title/i })).toBeTruthy();
|
|
51
|
+
expect(react_1.screen.queryByRole('heading', { name: /Onboarding/i })).toBeFalsy();
|
|
52
|
+
});
|
|
53
|
+
it('should handle primary button prop', () => {
|
|
54
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, primaryActionBtn: "First", children: body }));
|
|
55
|
+
expect(react_1.screen.getByRole('button', { name: /First/i })).toBeTruthy();
|
|
56
|
+
expect(react_1.screen.queryByRole('button', { name: /Continue/i })).toBeFalsy();
|
|
57
|
+
});
|
|
58
|
+
it('should handle secondary button prop', () => {
|
|
59
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, secondaryActionBtn: "Second", children: body }));
|
|
60
|
+
expect(react_1.screen.getByRole('button', { name: /Second/i })).toBeTruthy();
|
|
61
|
+
expect(react_1.screen.queryByRole('button', { name: /Skip/i })).toBeFalsy();
|
|
62
|
+
});
|
|
63
|
+
it('should handle primary button click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onPrimaryAction: onPrimaryAction, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, children: body }));
|
|
65
|
+
yield user_event_1.default.click(react_1.screen.getByRole('button', { name: /Continue/i }));
|
|
66
|
+
expect(onPrimaryAction).toHaveBeenCalledTimes(1);
|
|
67
|
+
expect(handleModalToggle).toHaveBeenCalledTimes(1);
|
|
68
|
+
}));
|
|
69
|
+
it('should handle secondary button click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, children: body }));
|
|
71
|
+
yield user_event_1.default.click(react_1.screen.getByRole('button', { name: /Skip/i }));
|
|
72
|
+
expect(onSecondaryAction).toHaveBeenCalledTimes(1);
|
|
73
|
+
expect(handleModalToggle).not.toHaveBeenCalled();
|
|
74
|
+
}));
|
|
75
|
+
it('should handle isCompact prop', () => {
|
|
76
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Onboarding_1.default, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, isCompact: true, headerImage: "./image.png", headerImageAltText: "Test image", children: body }));
|
|
77
|
+
expect(react_1.screen.getByRole('dialog')).toHaveClass('pf-m-compact');
|
|
78
|
+
expect(react_1.screen.queryByRole('img')).toBeFalsy();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.default = void 0;
|
|
21
|
+
var Onboarding_1 = require("./Onboarding");
|
|
22
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Onboarding_1).default; } });
|
|
23
|
+
__exportStar(require("./Onboarding"), exports);
|
|
@@ -29,6 +29,10 @@ export interface ActionProps extends Omit<ButtonProps, 'ref'> {
|
|
|
29
29
|
type ExtendedActionProps = ActionProps & {
|
|
30
30
|
[key: string]: any;
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* The various actions that can be attached to a bot message for users to interact with.
|
|
34
|
+
* Use this component when passing children to Message to customize its structure.
|
|
35
|
+
*/
|
|
32
36
|
export interface ResponseActionProps {
|
|
33
37
|
/** Props for message actions, such as feedback (positive or negative), copy button, share, and listen */
|
|
34
38
|
actions: Record<string, ExtendedActionProps | undefined> & {
|
|
@@ -40,6 +44,9 @@ export interface ResponseActionProps {
|
|
|
40
44
|
listen?: ActionProps;
|
|
41
45
|
edit?: ActionProps;
|
|
42
46
|
};
|
|
47
|
+
/** When true, the selected action will persist even when clicking outside the component.
|
|
48
|
+
* When false (default), clicking outside or clicking another action will deselect the current selection. */
|
|
49
|
+
persistActionSelection?: boolean;
|
|
43
50
|
}
|
|
44
51
|
export declare const ResponseActions: FunctionComponent<ResponseActionProps>;
|
|
45
52
|
export default ResponseActions;
|
|
@@ -20,10 +20,11 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
20
20
|
const react_2 = require("react");
|
|
21
21
|
const react_icons_1 = require("@patternfly/react-icons");
|
|
22
22
|
const ResponseActionButton_1 = __importDefault(require("./ResponseActionButton"));
|
|
23
|
-
const ResponseActions = ({ actions }) => {
|
|
23
|
+
const ResponseActions = ({ actions, persistActionSelection = false }) => {
|
|
24
24
|
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;
|
|
25
25
|
const [activeButton, setActiveButton] = (0, react_2.useState)();
|
|
26
26
|
const [clickStatePersisted, setClickStatePersisted] = (0, react_2.useState)(false);
|
|
27
|
+
const { positive, negative, copy, edit, share, download, listen } = actions, additionalActions = __rest(actions, ["positive", "negative", "copy", "edit", "share", "download", "listen"]);
|
|
27
28
|
(0, react_2.useEffect)(() => {
|
|
28
29
|
// Define the order of precedence for checking initial `isClicked`
|
|
29
30
|
const actionPrecedence = ['positive', 'negative', 'copy', 'edit', 'share', 'download', 'listen'];
|
|
@@ -45,11 +46,18 @@ const ResponseActions = ({ actions }) => {
|
|
|
45
46
|
// Click state is explicitly controlled by consumer.
|
|
46
47
|
setClickStatePersisted(true);
|
|
47
48
|
}
|
|
49
|
+
// If persistActionSelection is true, all selections are persisted
|
|
50
|
+
if (persistActionSelection) {
|
|
51
|
+
setClickStatePersisted(true);
|
|
52
|
+
}
|
|
48
53
|
setActiveButton(initialActive);
|
|
49
|
-
}, [actions]);
|
|
50
|
-
const { positive, negative, copy, edit, share, download, listen } = actions, additionalActions = __rest(actions, ["positive", "negative", "copy", "edit", "share", "download", "listen"]);
|
|
54
|
+
}, [actions, persistActionSelection]);
|
|
51
55
|
const responseActions = (0, react_2.useRef)(null);
|
|
52
56
|
(0, react_2.useEffect)(() => {
|
|
57
|
+
// Only add click outside listener if not persisting selection
|
|
58
|
+
if (persistActionSelection) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
53
61
|
const handleClickOutside = (e) => {
|
|
54
62
|
if (responseActions.current && !responseActions.current.contains(e.target) && !clickStatePersisted) {
|
|
55
63
|
setActiveButton(undefined);
|
|
@@ -59,13 +67,26 @@ const ResponseActions = ({ actions }) => {
|
|
|
59
67
|
return () => {
|
|
60
68
|
window.removeEventListener('click', handleClickOutside);
|
|
61
69
|
};
|
|
62
|
-
}, [clickStatePersisted]);
|
|
70
|
+
}, [clickStatePersisted, persistActionSelection]);
|
|
63
71
|
const handleClick = (e, id, onClick) => {
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
if (persistActionSelection) {
|
|
73
|
+
if (activeButton === id) {
|
|
74
|
+
// Toggle off if clicking the same button
|
|
75
|
+
setActiveButton(undefined);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// Set new active button
|
|
79
|
+
setActiveButton(id);
|
|
80
|
+
}
|
|
81
|
+
setClickStatePersisted(true);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
setClickStatePersisted(false);
|
|
85
|
+
setActiveButton(id);
|
|
86
|
+
}
|
|
66
87
|
onClick && onClick(e);
|
|
67
88
|
};
|
|
68
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ref: responseActions, className: "pf-chatbot__response-actions", children: [positive && ((0, jsx_runtime_1.jsx)(ResponseActionButton_1.default, Object.assign({}, positive, { ariaLabel: (_a = positive.ariaLabel) !== null && _a !== void 0 ? _a : 'Good response', clickedAriaLabel: (_b = positive.ariaLabel) !== null && _b !== void 0 ? _b : '
|
|
89
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: responseActions, className: "pf-chatbot__response-actions", children: [positive && ((0, jsx_runtime_1.jsx)(ResponseActionButton_1.default, 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: (0, jsx_runtime_1.jsx)(react_icons_1.OutlinedThumbsUpIcon, {}), isClicked: activeButton === 'positive', ref: positive.ref, "aria-expanded": positive['aria-expanded'], "aria-controls": positive['aria-controls'] }))), negative && ((0, jsx_runtime_1.jsx)(ResponseActionButton_1.default, 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: (0, jsx_runtime_1.jsx)(react_icons_1.OutlinedThumbsDownIcon, {}), isClicked: activeButton === 'negative', ref: negative.ref, "aria-expanded": negative['aria-expanded'], "aria-controls": negative['aria-controls'] }))), copy && ((0, jsx_runtime_1.jsx)(ResponseActionButton_1.default, 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: (0, jsx_runtime_1.jsx)(react_icons_1.OutlinedCopyIcon, {}), isClicked: activeButton === 'copy', ref: copy.ref, "aria-expanded": copy['aria-expanded'], "aria-controls": copy['aria-controls'] }))), edit && ((0, jsx_runtime_1.jsx)(ResponseActionButton_1.default, 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: (0, jsx_runtime_1.jsx)(react_icons_1.PencilAltIcon, {}), isClicked: activeButton === 'edit', ref: edit.ref, "aria-expanded": edit['aria-expanded'], "aria-controls": edit['aria-controls'] }))), share && ((0, jsx_runtime_1.jsx)(ResponseActionButton_1.default, 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: (0, jsx_runtime_1.jsx)(react_icons_1.ExternalLinkAltIcon, {}), isClicked: activeButton === 'share', ref: share.ref, "aria-expanded": share['aria-expanded'], "aria-controls": share['aria-controls'] }))), download && ((0, jsx_runtime_1.jsx)(ResponseActionButton_1.default, 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: (0, jsx_runtime_1.jsx)(react_icons_1.DownloadIcon, {}), isClicked: activeButton === 'download', ref: download.ref, "aria-expanded": download['aria-expanded'], "aria-controls": download['aria-controls'] }))), listen && ((0, jsx_runtime_1.jsx)(ResponseActionButton_1.default, 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: (0, jsx_runtime_1.jsx)(react_icons_1.VolumeUpIcon, {}), isClicked: activeButton === 'listen', ref: listen.ref, "aria-expanded": listen['aria-expanded'], "aria-controls": listen['aria-controls'] }))), Object.keys(additionalActions).map((action) => {
|
|
69
90
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
70
91
|
return ((0, react_1.createElement)(ResponseActionButton_1.default, 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'] })));
|
|
71
92
|
})] }));
|
|
@@ -20,8 +20,8 @@ const user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
|
20
20
|
const react_icons_1 = require("@patternfly/react-icons");
|
|
21
21
|
const Message_1 = __importDefault(require("../Message"));
|
|
22
22
|
const ALL_ACTIONS = [
|
|
23
|
-
{ type: 'positive', label: 'Good response', clickedLabel: '
|
|
24
|
-
{ type: 'negative', label: 'Bad response', clickedLabel: '
|
|
23
|
+
{ type: 'positive', label: 'Good response', clickedLabel: 'Good response recorded' },
|
|
24
|
+
{ type: 'negative', label: 'Bad response', clickedLabel: 'Bad response recorded' },
|
|
25
25
|
{ type: 'copy', label: 'Copy', clickedLabel: 'Copied' },
|
|
26
26
|
{ type: 'edit', label: 'Edit', clickedLabel: 'Editing' },
|
|
27
27
|
{ type: 'share', label: 'Share', clickedLabel: 'Shared' },
|
|
@@ -88,13 +88,13 @@ describe('ResponseActions', () => {
|
|
|
88
88
|
expect(button).toBeTruthy();
|
|
89
89
|
});
|
|
90
90
|
yield user_event_1.default.click(goodBtn);
|
|
91
|
-
expect(react_1.screen.getByRole('button', { name: '
|
|
91
|
+
expect(react_1.screen.getByRole('button', { name: 'Good response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
92
92
|
let unclickedButtons = buttons.filter((button) => button !== goodBtn);
|
|
93
93
|
unclickedButtons.forEach((button) => {
|
|
94
94
|
expect(button).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
95
95
|
});
|
|
96
96
|
yield user_event_1.default.click(badBtn);
|
|
97
|
-
expect(react_1.screen.getByRole('button', { name: '
|
|
97
|
+
expect(react_1.screen.getByRole('button', { name: 'Bad response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
98
98
|
unclickedButtons = buttons.filter((button) => button !== badBtn);
|
|
99
99
|
unclickedButtons.forEach((button) => {
|
|
100
100
|
expect(button).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
@@ -111,10 +111,10 @@ describe('ResponseActions', () => {
|
|
|
111
111
|
expect(goodBtn).toBeTruthy();
|
|
112
112
|
expect(badBtn).toBeTruthy();
|
|
113
113
|
yield user_event_1.default.click(goodBtn);
|
|
114
|
-
expect(react_1.screen.getByRole('button', { name: '
|
|
114
|
+
expect(react_1.screen.getByRole('button', { name: 'Good response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
115
115
|
expect(badBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
116
116
|
yield user_event_1.default.click(badBtn);
|
|
117
|
-
expect(react_1.screen.getByRole('button', { name: '
|
|
117
|
+
expect(react_1.screen.getByRole('button', { name: 'Bad response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
118
118
|
expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
119
119
|
yield user_event_1.default.click(react_1.screen.getByText("I updated your account with those settings. You're ready to set up your first dashboard!"));
|
|
120
120
|
expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
@@ -187,28 +187,28 @@ describe('ResponseActions', () => {
|
|
|
187
187
|
});
|
|
188
188
|
});
|
|
189
189
|
it('should be able to call onClick correctly', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
190
|
-
|
|
190
|
+
for (const { type, label } of ALL_ACTIONS) {
|
|
191
191
|
const spy = jest.fn();
|
|
192
192
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(ResponseActions_1.default, { actions: { [type]: { onClick: spy } } }));
|
|
193
193
|
yield user_event_1.default.click(react_1.screen.getByRole('button', { name: label }));
|
|
194
194
|
expect(spy).toHaveBeenCalledTimes(1);
|
|
195
|
-
}
|
|
195
|
+
}
|
|
196
196
|
}));
|
|
197
197
|
it('should swap clicked and non-clicked aria labels on click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
198
|
-
|
|
198
|
+
for (const { type, label, clickedLabel } of ALL_ACTIONS) {
|
|
199
199
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(ResponseActions_1.default, { actions: { [type]: { onClick: jest.fn() } } }));
|
|
200
200
|
expect(react_1.screen.getByRole('button', { name: label })).toBeTruthy();
|
|
201
201
|
yield user_event_1.default.click(react_1.screen.getByRole('button', { name: label }));
|
|
202
202
|
expect(react_1.screen.getByRole('button', { name: clickedLabel })).toBeTruthy();
|
|
203
|
-
}
|
|
203
|
+
}
|
|
204
204
|
}));
|
|
205
205
|
it('should swap clicked and non-clicked tooltips on click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
206
|
-
|
|
206
|
+
for (const { type, label, clickedLabel } of ALL_ACTIONS) {
|
|
207
207
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(ResponseActions_1.default, { actions: { [type]: { onClick: jest.fn() } } }));
|
|
208
208
|
expect(react_1.screen.getByRole('button', { name: label })).toBeTruthy();
|
|
209
209
|
yield user_event_1.default.click(react_1.screen.getByRole('button', { name: label }));
|
|
210
210
|
expect(react_1.screen.getByRole('tooltip', { name: clickedLabel })).toBeTruthy();
|
|
211
|
-
}
|
|
211
|
+
}
|
|
212
212
|
}));
|
|
213
213
|
it('should be able to change aria labels', () => {
|
|
214
214
|
const actions = [
|
|
@@ -260,4 +260,59 @@ describe('ResponseActions', () => {
|
|
|
260
260
|
expect(react_1.screen.getByTestId(action[key])).toBeTruthy();
|
|
261
261
|
});
|
|
262
262
|
});
|
|
263
|
+
// we are testing for the reverse case already above
|
|
264
|
+
it('should not deselect when clicking outside when persistActionSelection is true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
265
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Message_1.default, { name: "Bot", role: "bot", avatar: "", content: "Test content", actions: {
|
|
266
|
+
positive: {},
|
|
267
|
+
negative: {}
|
|
268
|
+
}, persistActionSelection: true }));
|
|
269
|
+
const goodBtn = react_1.screen.getByRole('button', { name: 'Good response' });
|
|
270
|
+
yield user_event_1.default.click(goodBtn);
|
|
271
|
+
expect(react_1.screen.getByRole('button', { name: 'Good response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
272
|
+
yield user_event_1.default.click(react_1.screen.getByText('Test content'));
|
|
273
|
+
expect(react_1.screen.getByRole('button', { name: 'Good response recorded' })).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
274
|
+
}));
|
|
275
|
+
it('should switch selection to another button when persistActionSelection is true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
276
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Message_1.default, { name: "Bot", role: "bot", avatar: "", content: "Test content", actions: {
|
|
277
|
+
positive: {},
|
|
278
|
+
negative: {}
|
|
279
|
+
}, persistActionSelection: true }));
|
|
280
|
+
const goodBtn = react_1.screen.getByRole('button', { name: 'Good response' });
|
|
281
|
+
const badBtn = react_1.screen.getByRole('button', { name: 'Bad response' });
|
|
282
|
+
yield user_event_1.default.click(goodBtn);
|
|
283
|
+
expect(goodBtn).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
284
|
+
yield user_event_1.default.click(badBtn);
|
|
285
|
+
expect(badBtn).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
286
|
+
expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
287
|
+
}));
|
|
288
|
+
it('should toggle off when clicking the same button when persistActionSelection is true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
289
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Message_1.default, { name: "Bot", role: "bot", avatar: "", content: "Test content", actions: {
|
|
290
|
+
positive: {},
|
|
291
|
+
negative: {}
|
|
292
|
+
}, persistActionSelection: true }));
|
|
293
|
+
const goodBtn = react_1.screen.getByRole('button', { name: 'Good response' });
|
|
294
|
+
yield user_event_1.default.click(goodBtn);
|
|
295
|
+
expect(goodBtn).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
296
|
+
yield user_event_1.default.click(goodBtn);
|
|
297
|
+
expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
298
|
+
}));
|
|
299
|
+
it('should work with custom actions when persistActionSelection is true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
300
|
+
const actions = {
|
|
301
|
+
positive: { 'data-testid': 'positive', onClick: jest.fn() },
|
|
302
|
+
negative: { 'data-testid': 'negative', onClick: jest.fn() },
|
|
303
|
+
custom: {
|
|
304
|
+
'data-testid': 'custom',
|
|
305
|
+
onClick: jest.fn(),
|
|
306
|
+
ariaLabel: 'Custom',
|
|
307
|
+
tooltipContent: 'Custom action',
|
|
308
|
+
icon: (0, jsx_runtime_1.jsx)(react_icons_1.DownloadIcon, {})
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ResponseActions_1.default, { actions: actions, persistActionSelection: true }));
|
|
312
|
+
const customBtn = react_1.screen.getByTestId('custom');
|
|
313
|
+
yield user_event_1.default.click(customBtn);
|
|
314
|
+
expect(customBtn).toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
315
|
+
yield user_event_1.default.click(customBtn);
|
|
316
|
+
expect(customBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
|
317
|
+
}));
|
|
263
318
|
});
|
|
@@ -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,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.ResponseActionsGroups = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_styles_1 = require("@patternfly/react-styles");
|
|
17
|
+
const ResponseActionsGroups = (_a) => {
|
|
18
|
+
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, react_styles_1.css)('pf-chatbot__response-actions-groups', className) }, props, { children: children })));
|
|
20
|
+
};
|
|
21
|
+
exports.ResponseActionsGroups = ResponseActionsGroups;
|
|
22
|
+
exports.default = exports.ResponseActionsGroups;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
const react_1 = require("@testing-library/react");
|
|
9
|
+
const ResponseActionsGroups_1 = __importDefault(require("./ResponseActionsGroups"));
|
|
10
|
+
test('Renders with children', () => {
|
|
11
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ResponseActionsGroups_1.default, { children: "Test content" }));
|
|
12
|
+
expect(react_1.screen.getByText('Test content')).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
test('Renders with pf-chatbot__response-actions-groups class by default', () => {
|
|
15
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ResponseActionsGroups_1.default, { children: "Test content" }));
|
|
16
|
+
expect(react_1.screen.getByText('Test content')).toHaveClass('pf-chatbot__response-actions-groups', { exact: true });
|
|
17
|
+
});
|
|
18
|
+
test('Renders with custom className', () => {
|
|
19
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ResponseActionsGroups_1.default, { className: "custom-class", children: "Test content" }));
|
|
20
|
+
expect(react_1.screen.getByText('Test content')).toHaveClass('custom-class');
|
|
21
|
+
});
|
|
22
|
+
test('Spreads additional props', () => {
|
|
23
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ResponseActionsGroups_1.default, { id: "test-id", children: "Test content" }));
|
|
24
|
+
expect(react_1.screen.getByText('Test content')).toHaveAttribute('id', 'test-id');
|
|
25
|
+
});
|
|
@@ -21,3 +21,4 @@ exports.default = void 0;
|
|
|
21
21
|
var ResponseActions_1 = require("./ResponseActions");
|
|
22
22
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(ResponseActions_1).default; } });
|
|
23
23
|
__exportStar(require("./ResponseActions"), exports);
|
|
24
|
+
__exportStar(require("./ResponseActionsGroups"), exports);
|
|
@@ -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,14 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ToolCall = void 0;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
5
9
|
const react_core_1 = require("@patternfly/react-core");
|
|
6
|
-
const
|
|
7
|
-
|
|
10
|
+
const MarkdownContent_1 = __importDefault(require("../MarkdownContent"));
|
|
11
|
+
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 }) => {
|
|
12
|
+
const [isExpanded, setIsExpanded] = (0, react_1.useState)(isDefaultExpanded);
|
|
13
|
+
const onToggle = (_event, isExpanded) => {
|
|
14
|
+
setIsExpanded(isExpanded);
|
|
15
|
+
};
|
|
16
|
+
const renderTitle = () => {
|
|
17
|
+
if (isTitleMarkdown) {
|
|
18
|
+
return (0, jsx_runtime_1.jsx)(MarkdownContent_1.default, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: titleText }, markdownContentProps));
|
|
19
|
+
}
|
|
20
|
+
return titleText;
|
|
21
|
+
};
|
|
22
|
+
const titleContent = ((0, jsx_runtime_1.jsx)("span", { className: `pf-chatbot__tool-call-title-content`, children: isLoading ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Spinner, Object.assign({ diameter: "1em" }, spinnerProps)), ' ', (0, jsx_runtime_1.jsx)("span", { className: "pf-chatbot__tool-call-title-text", children: loadingText })] })) : ((0, jsx_runtime_1.jsx)("span", { className: "pf-chatbot__tool-call-title-text", children: renderTitle() })) }));
|
|
23
|
+
const renderExpandableContent = () => {
|
|
24
|
+
if (isExpandableContentMarkdown && typeof expandableContent === 'string') {
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(MarkdownContent_1.default, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: expandableContent }, markdownContentProps)));
|
|
26
|
+
}
|
|
27
|
+
return expandableContent;
|
|
28
|
+
};
|
|
8
29
|
const defaultActions = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_core_1.ActionListItem, Object.assign({}, actionListItemProps, cancelActionItemProps, { children: (0, jsx_runtime_1.jsx)(react_core_1.Button, Object.assign({ variant: "link" }, cancelButtonProps, { children: cancelButtonText })) })), (0, jsx_runtime_1.jsx)(react_core_1.ActionListItem, Object.assign({}, actionListItemProps, runActionItemProps, { children: (0, jsx_runtime_1.jsx)(react_core_1.Button, Object.assign({ variant: "secondary" }, runButtonProps, { children: runButtonText })) }))] }));
|
|
9
30
|
const customActions = actions &&
|
|
10
31
|
actions.map((action, index) => ((0, jsx_runtime_1.jsx)(react_core_1.ActionListItem, Object.assign({}, actionListItemProps, { children: action }), index)));
|
|
11
|
-
return ((0, jsx_runtime_1.jsxs)(react_core_1.Card, Object.assign({ isCompact: true, className: "pf-chatbot__tool-call" }, cardProps, { children: [(0, jsx_runtime_1.jsx)(react_core_1.CardBody, Object.assign({ className: "pf-chatbot__tool-call-title" }, cardBodyProps, { children: expandableContent && !isLoading ? ((0, jsx_runtime_1.jsx)(react_core_1.ExpandableSection, Object.assign({ className: "pf-chatbot__tool-call-expandable-section", toggleContent: titleContent, isIndented: true }, expandableSectionProps, { children:
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)(react_core_1.Card, Object.assign({ isCompact: true, className: "pf-chatbot__tool-call" }, cardProps, { children: [(0, jsx_runtime_1.jsx)(react_core_1.CardBody, Object.assign({ className: "pf-chatbot__tool-call-title" }, cardBodyProps, { children: expandableContent && !isLoading ? ((0, jsx_runtime_1.jsx)(react_core_1.ExpandableSection, Object.assign({ className: "pf-chatbot__tool-call-expandable-section", toggleContent: titleContent, onToggle: onToggle, isExpanded: isExpanded, isIndented: true }, expandableSectionProps, { children: renderExpandableContent() }))) : (titleContent) })), !isLoading && ((0, jsx_runtime_1.jsx)(react_core_1.CardFooter, Object.assign({}, cardFooterProps, { children: (0, jsx_runtime_1.jsx)(react_core_1.ActionList, Object.assign({ className: "pf-chatbot__tool-call-action-list" }, actionListProps, { children: (0, jsx_runtime_1.jsx)(react_core_1.ActionListGroup, Object.assign({}, actionListGroupProps, { children: customActions || defaultActions })) })) })))] })));
|
|
12
33
|
};
|
|
13
34
|
exports.ToolCall = ToolCall;
|
|
14
35
|
exports.default = exports.ToolCall;
|
|
@@ -141,4 +141,61 @@ describe('ToolCall', () => {
|
|
|
141
141
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(ToolCall_1.default, Object.assign({}, defaultProps, { cardFooterProps: { id: 'card-footer-test-id' } })));
|
|
142
142
|
expect(react_1.screen.getByRole('button', { name: 'Run tool' }).closest('#card-footer-test-id')).toBeVisible();
|
|
143
143
|
});
|
|
144
|
+
it('Renders collapsed by default when expandableContent is provided', () => {
|
|
145
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ToolCall_1.default, Object.assign({}, defaultProps, { expandableContent: "Expandable Content" })));
|
|
146
|
+
expect(react_1.screen.getByRole('button', { name: defaultProps.titleText })).toHaveAttribute('aria-expanded', 'false');
|
|
147
|
+
expect(react_1.screen.queryByText('Expandable Content')).not.toBeVisible();
|
|
148
|
+
});
|
|
149
|
+
it('Renders expanded when isDefaultExpanded is true', () => {
|
|
150
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ToolCall_1.default, Object.assign({}, defaultProps, { isDefaultExpanded: true, expandableContent: "Expandable Content" })));
|
|
151
|
+
expect(react_1.screen.getByRole('button', { name: defaultProps.titleText })).toHaveAttribute('aria-expanded', 'true');
|
|
152
|
+
expect(react_1.screen.getByText('Expandable Content')).toBeVisible();
|
|
153
|
+
});
|
|
154
|
+
it('expandableSectionProps.isExpanded overrides isDefaultExpanded', () => {
|
|
155
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ToolCall_1.default, Object.assign({}, defaultProps, { isDefaultExpanded: false, expandableContent: "Expandable Content", expandableSectionProps: { isExpanded: true } })));
|
|
156
|
+
expect(react_1.screen.getByRole('button', { name: defaultProps.titleText })).toHaveAttribute('aria-expanded', 'true');
|
|
157
|
+
expect(react_1.screen.getByText('Expandable Content')).toBeVisible();
|
|
158
|
+
});
|
|
159
|
+
it('expandableSectionProps.onToggle overrides internal onToggle behavior', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
160
|
+
const user = user_event_1.default.setup();
|
|
161
|
+
const customOnToggle = jest.fn();
|
|
162
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ToolCall_1.default, Object.assign({}, defaultProps, { isDefaultExpanded: false, expandableContent: "Expandable Content", expandableSectionProps: { onToggle: customOnToggle } })));
|
|
163
|
+
const toggleButton = react_1.screen.getByRole('button', { name: defaultProps.titleText });
|
|
164
|
+
expect(toggleButton).toHaveAttribute('aria-expanded', 'false');
|
|
165
|
+
yield user.click(toggleButton);
|
|
166
|
+
expect(customOnToggle).toHaveBeenCalledTimes(1);
|
|
167
|
+
expect(toggleButton).toHaveAttribute('aria-expanded', 'false');
|
|
168
|
+
expect(react_1.screen.queryByText('Expandable Content')).not.toBeVisible();
|
|
169
|
+
}));
|
|
170
|
+
it('should render titleText as markdown when isTitleMarkdown is true', () => {
|
|
171
|
+
const titleText = '**Bold title**';
|
|
172
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(ToolCall_1.default, { titleText: titleText, isTitleMarkdown: true }));
|
|
173
|
+
expect(container.querySelector('strong')).toBeTruthy();
|
|
174
|
+
expect(react_1.screen.getByText('Bold title')).toBeTruthy();
|
|
175
|
+
});
|
|
176
|
+
it('should not render titleText as markdown when isTitleMarkdown is false', () => {
|
|
177
|
+
const titleText = '**Bold title**';
|
|
178
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ToolCall_1.default, { titleText: titleText }));
|
|
179
|
+
expect(react_1.screen.getByText('**Bold title**')).toBeTruthy();
|
|
180
|
+
});
|
|
181
|
+
it('should render expandableContent as markdown when isExpandableContentMarkdown is true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
182
|
+
const user = user_event_1.default.setup();
|
|
183
|
+
const expandableContent = '**Bold expandable content**';
|
|
184
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(ToolCall_1.default, Object.assign({}, defaultProps, { expandableContent: expandableContent, isExpandableContentMarkdown: true })));
|
|
185
|
+
yield user.click(react_1.screen.getByRole('button', { name: defaultProps.titleText }));
|
|
186
|
+
expect(container.querySelector('strong')).toBeTruthy();
|
|
187
|
+
expect(react_1.screen.getByText('Bold expandable content')).toBeTruthy();
|
|
188
|
+
}));
|
|
189
|
+
it('should not render expandableContent as markdown when isExpandableContentMarkdown is false', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
190
|
+
const user = user_event_1.default.setup();
|
|
191
|
+
const expandableContent = '**Bold expandable content**';
|
|
192
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ToolCall_1.default, Object.assign({}, defaultProps, { expandableContent: expandableContent })));
|
|
193
|
+
yield user.click(react_1.screen.getByRole('button', { name: defaultProps.titleText }));
|
|
194
|
+
expect(react_1.screen.getByText('**Bold expandable content**')).toBeTruthy();
|
|
195
|
+
}));
|
|
196
|
+
it('should pass markdownContentProps to MarkdownContent component', () => {
|
|
197
|
+
const titleText = '**Bold title**';
|
|
198
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(ToolCall_1.default, { titleText: titleText, isTitleMarkdown: true, markdownContentProps: { isPrimary: true } }));
|
|
199
|
+
expect(container.querySelector('.pf-m-primary')).toBeTruthy();
|
|
200
|
+
});
|
|
144
201
|
});
|
|
@@ -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;
|