@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
|
@@ -41,5 +41,7 @@ export interface AttachButtonProps extends ButtonProps {
|
|
|
41
41
|
validator?: <T extends File>(file: T) => FileError | readonly FileError[] | null;
|
|
42
42
|
/** Additional props passed to react-dropzone */
|
|
43
43
|
dropzoneProps?: DropzoneOptions;
|
|
44
|
+
/** Icon displayed in attach button */
|
|
45
|
+
icon?: React.ReactNode;
|
|
44
46
|
}
|
|
45
47
|
export declare const AttachButton: import("react").ForwardRefExoticComponent<AttachButtonProps & import("react").RefAttributes<any>>;
|
|
@@ -16,12 +16,12 @@ import { Button, Icon, Tooltip } from '@patternfly/react-core';
|
|
|
16
16
|
import { useDropzone } from 'react-dropzone';
|
|
17
17
|
import { PaperclipIcon } from '@patternfly/react-icons/dist/esm/icons/paperclip-icon';
|
|
18
18
|
const AttachButtonBase = (_a) => {
|
|
19
|
-
var { onAttachAccepted, onClick, isDisabled, className, tooltipProps, innerRef, tooltipContent = 'Attach', inputTestId, isCompact, allowedFileTypes, minSize, maxSize, maxFiles, isAttachmentDisabled, onAttach, onAttachRejected, validator, dropzoneProps } = _a, props = __rest(_a, ["onAttachAccepted", "onClick", "isDisabled", "className", "tooltipProps", "innerRef", "tooltipContent", "inputTestId", "isCompact", "allowedFileTypes", "minSize", "maxSize", "maxFiles", "isAttachmentDisabled", "onAttach", "onAttachRejected", "validator", "dropzoneProps"]);
|
|
19
|
+
var { onAttachAccepted, onClick, isDisabled, className, tooltipProps, innerRef, tooltipContent = 'Attach', inputTestId, isCompact, allowedFileTypes, minSize, maxSize, maxFiles, isAttachmentDisabled, onAttach, onAttachRejected, validator, dropzoneProps, icon = _jsx(PaperclipIcon, {}) } = _a, props = __rest(_a, ["onAttachAccepted", "onClick", "isDisabled", "className", "tooltipProps", "innerRef", "tooltipContent", "inputTestId", "isCompact", "allowedFileTypes", "minSize", "maxSize", "maxFiles", "isAttachmentDisabled", "onAttach", "onAttachRejected", "validator", "dropzoneProps", "icon"]);
|
|
20
20
|
const { open, getInputProps } = useDropzone(Object.assign({ multiple: true, onDropAccepted: onAttachAccepted, accept: allowedFileTypes, minSize,
|
|
21
21
|
maxSize,
|
|
22
22
|
maxFiles, disabled: isAttachmentDisabled, onDrop: onAttach, onDropRejected: onAttachRejected, validator }, dropzoneProps));
|
|
23
23
|
return (_jsxs(_Fragment, { children: [_jsx("input", Object.assign({ "data-testid": inputTestId }, getInputProps(), { hidden: true })), _jsx(Tooltip, Object.assign({ id: "pf-chatbot__tooltip--attach", content: tooltipContent, position: "top", entryDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.entryDelay) || 0, exitDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.exitDelay) || 0, distance: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.distance) || 8, animationDuration: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.animationDuration) || 0,
|
|
24
24
|
// prevents VO announcements of both aria label and tooltip
|
|
25
|
-
aria: "none" }, tooltipProps, { children: _jsx(Button, Object.assign({ variant: "plain", ref: innerRef, className: `pf-chatbot__button--attach ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Attach', isDisabled: isDisabled, onClick: onClick !== null && onClick !== void 0 ? onClick : open, icon: _jsx(Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true, children:
|
|
25
|
+
aria: "none" }, tooltipProps, { children: _jsx(Button, Object.assign({ variant: "plain", ref: innerRef, className: `pf-chatbot__button--attach ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Attach', isDisabled: isDisabled, onClick: onClick !== null && onClick !== void 0 ? onClick : open, icon: _jsx(Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true, children: icon }), size: isCompact ? 'sm' : undefined }, props)) }))] }));
|
|
26
26
|
};
|
|
27
27
|
export const AttachButton = forwardRef((props, ref) => (_jsx(AttachButtonBase, Object.assign({ innerRef: ref }, props))));
|
|
@@ -140,4 +140,8 @@ describe('Attach button', () => {
|
|
|
140
140
|
expect(validator).toHaveBeenCalledWith(file);
|
|
141
141
|
expect(onAttachRejected).toHaveBeenCalled();
|
|
142
142
|
}));
|
|
143
|
+
it('should handle icon prop', () => {
|
|
144
|
+
render(_jsx(AttachButton, { icon: _jsx("img", { alt: "", src: "" }) }));
|
|
145
|
+
expect(screen.getByRole('img')).toBeVisible();
|
|
146
|
+
});
|
|
143
147
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FunctionComponent } from 'react';
|
|
2
2
|
import { Accept, DropEvent, DropzoneOptions, FileError, FileRejection } from 'react-dropzone';
|
|
3
|
-
import { ButtonProps, TextAreaProps, TooltipProps } from '@patternfly/react-core';
|
|
3
|
+
import { ButtonProps, MenuSearchInputProps, MenuSearchProps, SearchInputProps, TextAreaProps, TooltipProps } from '@patternfly/react-core';
|
|
4
|
+
import { AttachButtonProps } from './AttachButton';
|
|
4
5
|
import { ChatbotDisplayMode } from '../Chatbot';
|
|
5
6
|
export interface MessageBarWithAttachMenuProps {
|
|
6
7
|
/** Flag to enable whether attach menu is open */
|
|
@@ -12,7 +13,7 @@ export interface MessageBarWithAttachMenuProps {
|
|
|
12
13
|
/** A callback for when the attachment menu toggle is clicked */
|
|
13
14
|
onAttachMenuToggleClick: () => void;
|
|
14
15
|
/** A callback for when the input value in the menu changes. */
|
|
15
|
-
onAttachMenuInputChange
|
|
16
|
+
onAttachMenuInputChange?: (value: string) => void;
|
|
16
17
|
/** Function callback called when user selects item in menu. */
|
|
17
18
|
onAttachMenuSelect?: (event?: React.MouseEvent<Element, MouseEvent>, value?: string | number) => void;
|
|
18
19
|
/** Placeholder for search input */
|
|
@@ -21,6 +22,12 @@ export interface MessageBarWithAttachMenuProps {
|
|
|
21
22
|
onAttachMenuOnOpenChangeKeys?: string[];
|
|
22
23
|
/** Callback to change the open state of the menu. Triggered by clicking outside of the menu. */
|
|
23
24
|
onAttachMenuOpenChange?: (isOpen: boolean) => void;
|
|
25
|
+
/** Additional props passed to MenuSearch component in attach menu */
|
|
26
|
+
menuSearchProps?: Omit<MenuSearchProps, 'ref'>;
|
|
27
|
+
/** Additional props passed to MenuSearchInput component in attach menu */
|
|
28
|
+
menuSearchInputProps?: Omit<MenuSearchInputProps, 'ref'>;
|
|
29
|
+
/** Additional props passed to SearchInput component in attach menu */
|
|
30
|
+
searchInputProps?: SearchInputProps;
|
|
24
31
|
}
|
|
25
32
|
export interface MessageBarProps extends Omit<TextAreaProps, 'innerRef'> {
|
|
26
33
|
/** Callback to get the value of input message by user */
|
|
@@ -33,6 +40,8 @@ export interface MessageBarProps extends Omit<TextAreaProps, 'innerRef'> {
|
|
|
33
40
|
placeholder?: string;
|
|
34
41
|
/** Flag to disable/enable the Attach button */
|
|
35
42
|
hasAttachButton?: boolean;
|
|
43
|
+
/** Whether the attach button is rendered before or after the message input. */
|
|
44
|
+
attachButtonPosition?: 'start' | 'end';
|
|
36
45
|
/** Flag to enable the Microphone button */
|
|
37
46
|
hasMicrophoneButton?: boolean;
|
|
38
47
|
/** Placeholder text when listening */
|
|
@@ -71,11 +80,8 @@ export interface MessageBarProps extends Omit<TextAreaProps, 'innerRef'> {
|
|
|
71
80
|
isSendButtonDisabled?: boolean;
|
|
72
81
|
/** Prop to allow passage of additional props to buttons */
|
|
73
82
|
buttonProps?: {
|
|
74
|
-
attach?: {
|
|
75
|
-
tooltipContent?: string;
|
|
83
|
+
attach?: AttachButtonProps & {
|
|
76
84
|
props?: ButtonProps;
|
|
77
|
-
inputTestId?: string;
|
|
78
|
-
tooltipProps?: Omit<TooltipProps, 'content'>;
|
|
79
85
|
};
|
|
80
86
|
stop?: {
|
|
81
87
|
tooltipContent?: string;
|
|
@@ -105,6 +111,16 @@ export interface MessageBarProps extends Omit<TextAreaProps, 'innerRef'> {
|
|
|
105
111
|
isCompact?: boolean;
|
|
106
112
|
/** Ref applied to message bar textarea, for use with focus or other custom behaviors */
|
|
107
113
|
innerRef?: React.Ref<HTMLTextAreaElement>;
|
|
114
|
+
/** Sets background color to primary */
|
|
115
|
+
isPrimary?: boolean;
|
|
116
|
+
/** Additional actions to render for the message bar. This will force a multiline layout, and the actions will render at the start of the container. */
|
|
117
|
+
additionalActions?: React.ReactNode;
|
|
118
|
+
/** Flag indicating whether a multiline layout for the message input and actions should be forced. This can be used to always render actions below the message input. */
|
|
119
|
+
forceMultilineLayout?: boolean;
|
|
120
|
+
/** @beta Flag indicating whether the message bar has an AI indicator border. */
|
|
121
|
+
hasAiIndicator?: boolean;
|
|
122
|
+
/** @beta Flag indicating whether the chatbot is thinking in response to a query, adding an animation to the message bar. */
|
|
123
|
+
isThinking?: boolean;
|
|
108
124
|
}
|
|
109
125
|
export declare const MessageBarBase: FunctionComponent<MessageBarProps>;
|
|
110
126
|
declare const MessageBar: import("react").ForwardRefExoticComponent<MessageBarProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -12,6 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
14
14
|
import { TextArea } from '@patternfly/react-core';
|
|
15
|
+
import { css } from '@patternfly/react-styles';
|
|
15
16
|
// Import Chatbot components
|
|
16
17
|
import SendButton from './SendButton';
|
|
17
18
|
import MicrophoneButton from './MicrophoneButton';
|
|
@@ -20,17 +21,24 @@ import AttachMenu from '../AttachMenu';
|
|
|
20
21
|
import StopButton from './StopButton';
|
|
21
22
|
export const MessageBarBase = (_a) => {
|
|
22
23
|
var _b;
|
|
23
|
-
var { onSendMessage, className, alwayShowSendButton, placeholder = 'Send a message...', hasAttachButton = true, hasMicrophoneButton, listeningText = 'Listening', handleAttach, attachMenuProps, isSendButtonDisabled, handleStopButton, hasStopButton, buttonProps, onChange, displayMode, value, isCompact = false, allowedFileTypes, minSize, maxSize, maxFiles, isAttachmentDisabled, onAttach, onAttachRejected, validator, dropzoneProps, innerRef } = _a, props = __rest(_a, ["onSendMessage", "className", "alwayShowSendButton", "placeholder", "hasAttachButton", "hasMicrophoneButton", "listeningText", "handleAttach", "attachMenuProps", "isSendButtonDisabled", "handleStopButton", "hasStopButton", "buttonProps", "onChange", "displayMode", "value", "isCompact", "allowedFileTypes", "minSize", "maxSize", "maxFiles", "isAttachmentDisabled", "onAttach", "onAttachRejected", "validator", "dropzoneProps", "innerRef"]);
|
|
24
|
+
var { onSendMessage, className, alwayShowSendButton, placeholder = 'Send a message...', hasAttachButton = true, attachButtonPosition = 'end', hasMicrophoneButton, listeningText = 'Listening', handleAttach, attachMenuProps, isSendButtonDisabled, handleStopButton, hasStopButton, buttonProps, onChange, displayMode, value, isCompact = false, allowedFileTypes, minSize, maxSize, maxFiles, isAttachmentDisabled, onAttach, onAttachRejected, validator, dropzoneProps, innerRef, isPrimary, additionalActions, forceMultilineLayout = false, hasAiIndicator, isThinking } = _a, props = __rest(_a, ["onSendMessage", "className", "alwayShowSendButton", "placeholder", "hasAttachButton", "attachButtonPosition", "hasMicrophoneButton", "listeningText", "handleAttach", "attachMenuProps", "isSendButtonDisabled", "handleStopButton", "hasStopButton", "buttonProps", "onChange", "displayMode", "value", "isCompact", "allowedFileTypes", "minSize", "maxSize", "maxFiles", "isAttachmentDisabled", "onAttach", "onAttachRejected", "validator", "dropzoneProps", "innerRef", "isPrimary", "additionalActions", "forceMultilineLayout", "hasAiIndicator", "isThinking"]);
|
|
24
25
|
// Text Input
|
|
25
26
|
// --------------------------------------------------------------------------
|
|
26
27
|
const [message, setMessage] = useState(value !== null && value !== void 0 ? value : '');
|
|
27
28
|
const [isListeningMessage, setIsListeningMessage] = useState(false);
|
|
28
29
|
const [hasSentMessage, setHasSentMessage] = useState(false);
|
|
29
30
|
const [isComposing, setIsComposing] = useState(false);
|
|
31
|
+
const shouldForceMultiline = forceMultilineLayout || additionalActions;
|
|
32
|
+
const [isMultiline, setIsMultiline] = useState(shouldForceMultiline);
|
|
30
33
|
const inputRef = useRef(null);
|
|
31
34
|
const textareaRef = (_b = innerRef) !== null && _b !== void 0 ? _b : inputRef;
|
|
32
35
|
const attachButtonRef = useRef(null);
|
|
33
36
|
const topMargin = '1rem';
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (value !== undefined && value !== message) {
|
|
39
|
+
setMessage(value);
|
|
40
|
+
}
|
|
41
|
+
}, [value, message]);
|
|
34
42
|
const setInitialLineHeight = (field) => {
|
|
35
43
|
field.style.setProperty('line-height', '1rem');
|
|
36
44
|
const parent = field.parentElement;
|
|
@@ -40,7 +48,7 @@ export const MessageBarBase = (_a) => {
|
|
|
40
48
|
parent.style.setProperty('height', 'inherit');
|
|
41
49
|
const grandparent = parent.parentElement;
|
|
42
50
|
if (grandparent) {
|
|
43
|
-
grandparent.style.setProperty('flex-basis', 'auto');
|
|
51
|
+
grandparent.style.setProperty('flex-basis', shouldForceMultiline ? '100%' : 'auto');
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
54
|
};
|
|
@@ -67,11 +75,20 @@ export const MessageBarBase = (_a) => {
|
|
|
67
75
|
const lines = field.scrollHeight / lineHeight;
|
|
68
76
|
return lines > 2;
|
|
69
77
|
};
|
|
78
|
+
const checkIfMultiline = useCallback((field) => {
|
|
79
|
+
const parent = field.parentElement;
|
|
80
|
+
const grandparent = parent === null || parent === void 0 ? void 0 : parent.parentElement;
|
|
81
|
+
if (grandparent) {
|
|
82
|
+
const containerHeight = grandparent.offsetHeight;
|
|
83
|
+
const threshold = isCompact ? 56 : 70;
|
|
84
|
+
setIsMultiline(containerHeight > threshold);
|
|
85
|
+
}
|
|
86
|
+
}, [isCompact]);
|
|
70
87
|
const setAutoWidth = useCallback((field) => {
|
|
71
88
|
const parent = field.parentElement;
|
|
72
89
|
if (parent) {
|
|
73
90
|
const grandparent = parent.parentElement;
|
|
74
|
-
if (textIsLongerThan2Lines(field) && grandparent) {
|
|
91
|
+
if ((textIsLongerThan2Lines(field) || shouldForceMultiline) && grandparent) {
|
|
75
92
|
grandparent.style.setProperty('flex-basis', `100%`);
|
|
76
93
|
}
|
|
77
94
|
}
|
|
@@ -119,13 +136,15 @@ export const MessageBarBase = (_a) => {
|
|
|
119
136
|
if (field) {
|
|
120
137
|
if (field.value === '') {
|
|
121
138
|
setInitialLineHeight(field);
|
|
139
|
+
!shouldForceMultiline && setIsMultiline(false);
|
|
122
140
|
}
|
|
123
141
|
else {
|
|
124
142
|
setAutoHeight(field);
|
|
125
143
|
setAutoWidth(field);
|
|
144
|
+
!shouldForceMultiline && checkIfMultiline(field);
|
|
126
145
|
}
|
|
127
146
|
}
|
|
128
|
-
}, [displayMode, message, setAutoWidth]);
|
|
147
|
+
}, [displayMode, message, setAutoWidth, shouldForceMultiline, checkIfMultiline]);
|
|
129
148
|
useEffect(() => {
|
|
130
149
|
const field = textareaRef.current;
|
|
131
150
|
if (field) {
|
|
@@ -138,13 +157,15 @@ export const MessageBarBase = (_a) => {
|
|
|
138
157
|
if (textareaRef.current) {
|
|
139
158
|
if (event.target.value === '') {
|
|
140
159
|
setInitialLineHeight(textareaRef.current);
|
|
160
|
+
!shouldForceMultiline && setIsMultiline(false);
|
|
141
161
|
}
|
|
142
162
|
else {
|
|
143
163
|
setAutoHeight(textareaRef.current);
|
|
164
|
+
!shouldForceMultiline && checkIfMultiline(textareaRef.current);
|
|
144
165
|
}
|
|
145
166
|
}
|
|
146
167
|
setMessage(event.target.value);
|
|
147
|
-
}, [onChange]);
|
|
168
|
+
}, [onChange, checkIfMultiline]);
|
|
148
169
|
// Handle sending message
|
|
149
170
|
const handleSend = useCallback((newMessage) => {
|
|
150
171
|
onSendMessage(newMessage);
|
|
@@ -186,23 +207,34 @@ export const MessageBarBase = (_a) => {
|
|
|
186
207
|
setMessage(message);
|
|
187
208
|
onChange && onChange({}, message);
|
|
188
209
|
};
|
|
210
|
+
const renderAttachButton = () => {
|
|
211
|
+
var _a, _b, _c, _d, _e, _f;
|
|
212
|
+
if (!attachMenuProps && hasAttachButton) {
|
|
213
|
+
return (_jsx(AttachButton, Object.assign({ onAttachAccepted: handleAttach, isDisabled: isListeningMessage, tooltipContent: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _a === void 0 ? void 0 : _a.tooltipContent, inputTestId: (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _b === void 0 ? void 0 : _b.inputTestId, isCompact: isCompact, tooltipProps: (_c = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _c === void 0 ? void 0 : _c.tooltipProps, allowedFileTypes: allowedFileTypes, minSize: minSize, maxSize: maxSize, maxFiles: maxFiles, isAttachmentDisabled: isAttachmentDisabled, onAttach: onAttach, onAttachRejected: onAttachRejected, validator: validator, dropzoneProps: dropzoneProps }, buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach, (_d = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _d === void 0 ? void 0 : _d.props)));
|
|
214
|
+
}
|
|
215
|
+
if (attachMenuProps) {
|
|
216
|
+
return (_jsx(AttachButton, Object.assign({ ref: attachButtonRef, onClick: handleAttachMenuToggle, isDisabled: isListeningMessage, tooltipContent: (_e = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _e === void 0 ? void 0 : _e.tooltipContent, isCompact: isCompact, tooltipProps: (_f = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _f === void 0 ? void 0 : _f.tooltipProps, allowedFileTypes: allowedFileTypes, minSize: minSize, maxSize: maxSize, maxFiles: maxFiles, isAttachmentDisabled: isAttachmentDisabled, onAttach: onAttach, onAttachRejected: onAttachRejected, validator: validator, dropzoneProps: dropzoneProps }, buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach)));
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const isAttachButtonAtStart = attachButtonPosition === 'start';
|
|
189
220
|
const renderButtons = () => {
|
|
190
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
221
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
191
222
|
if (hasStopButton && handleStopButton) {
|
|
192
223
|
return (_jsx(StopButton, Object.assign({ onClick: handleStopButton, tooltipContent: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.stop) === null || _a === void 0 ? void 0 : _a.tooltipContent, isCompact: isCompact, tooltipProps: (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.stop) === null || _b === void 0 ? void 0 : _b.tooltipProps }, (_c = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.stop) === null || _c === void 0 ? void 0 : _c.props)));
|
|
193
224
|
}
|
|
194
|
-
return (_jsxs(_Fragment, { children: [
|
|
225
|
+
return (_jsxs(_Fragment, { children: [!isAttachButtonAtStart && renderAttachButton(), hasMicrophoneButton && (_jsx(MicrophoneButton, Object.assign({ isListening: isListeningMessage, onIsListeningChange: setIsListeningMessage, onSpeechRecognition: handleSpeechRecognition, tooltipContent: (_d = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _d === void 0 ? void 0 : _d.tooltipContent, language: (_e = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _e === void 0 ? void 0 : _e.language, isCompact: isCompact, tooltipProps: (_f = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _f === void 0 ? void 0 : _f.tooltipProps }, (_g = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _g === void 0 ? void 0 : _g.props))), (alwayShowSendButton || message) && (_jsx(SendButton, Object.assign({ value: message, onClick: () => handleSend(message), isDisabled: isSendButtonDisabled, tooltipContent: (_h = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.send) === null || _h === void 0 ? void 0 : _h.tooltipContent, isCompact: isCompact, tooltipProps: (_j = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.send) === null || _j === void 0 ? void 0 : _j.tooltipProps }, (_k = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.send) === null || _k === void 0 ? void 0 : _k.props)))] }));
|
|
195
226
|
};
|
|
196
|
-
const
|
|
227
|
+
const hasGroupedActions = additionalActions || (isAttachButtonAtStart && isMultiline);
|
|
228
|
+
const messageBarContents = (_jsxs(_Fragment, { children: [isAttachButtonAtStart && !isMultiline && (_jsx("div", { className: "pf-chatbot__message-bar-actions test", children: renderAttachButton() })), _jsx("div", { className: `pf-chatbot__message-bar-input ${isCompact ? 'pf-m-compact' : ''}`, children: _jsx(TextArea, Object.assign({ className: "pf-chatbot__message-textarea", value: message, onChange: handleChange, "aria-label": isListeningMessage ? listeningText : placeholder, placeholder: isListeningMessage ? listeningText : placeholder, ref: textareaRef, onKeyDown: handleKeyDown, onCompositionStart: handleCompositionStart, onCompositionEnd: handleCompositionEnd }, props)) }), _jsx("div", { className: css('pf-chatbot__message-bar-actions', hasGroupedActions && 'pf-m-grouped'), children: hasGroupedActions ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: css('pf-chatbot__message-bar-actions-group'), children: [isAttachButtonAtStart && renderAttachButton(), additionalActions] }), _jsx("div", { className: css('pf-chatbot__message-bar-actions-group'), children: renderButtons() })] })) : (renderButtons()) })] }));
|
|
197
229
|
if (attachMenuProps) {
|
|
198
|
-
return (_jsx(AttachMenu, Object.assign({ toggle: (toggleRef) => (_jsx("div", { ref: toggleRef, className:
|
|
230
|
+
return (_jsx(AttachMenu, Object.assign({ toggle: (toggleRef) => (_jsx("div", { ref: toggleRef, className: css('pf-chatbot__message-bar', isMultiline && 'pf-m-multiline', className), children: messageBarContents })), filteredItems: attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.attachMenuItems }, (attachMenuProps && { isOpen: attachMenuProps.isAttachMenuOpen }), { onOpenChange: (isAttachMenuOpen) => {
|
|
199
231
|
var _a;
|
|
200
232
|
(_a = attachButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
201
233
|
attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.setIsAttachMenuOpen(isAttachMenuOpen);
|
|
202
234
|
(attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.onAttachMenuOpenChange) && (attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.onAttachMenuOpenChange(isAttachMenuOpen));
|
|
203
|
-
}, onOpenChangeKeys: attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.onAttachMenuOnOpenChangeKeys, onSelect: attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.onAttachMenuSelect }, (attachMenuProps && { handleTextInputChange: attachMenuProps.onAttachMenuInputChange }), { popperProps: { direction: 'up', distance: 8 }, searchInputPlaceholder: attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.attachMenuInputPlaceholder })));
|
|
235
|
+
}, onOpenChangeKeys: attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.onAttachMenuOnOpenChangeKeys, onSelect: attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.onAttachMenuSelect }, (attachMenuProps && { handleTextInputChange: attachMenuProps.onAttachMenuInputChange }), { popperProps: { direction: 'up', distance: 8 }, searchInputPlaceholder: attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.attachMenuInputPlaceholder }, attachMenuProps)));
|
|
204
236
|
}
|
|
205
|
-
return _jsx("div", { className:
|
|
237
|
+
return (_jsx("div", { className: css('pf-chatbot__message-bar', isPrimary && 'pf-m-primary', hasAiIndicator && 'pf-v6-m-ai-indicator', isThinking && 'pf-v6-m-thinking', isMultiline && 'pf-m-multiline', className), children: messageBarContents }));
|
|
206
238
|
};
|
|
207
239
|
const MessageBar = forwardRef((props, ref) => (_jsx(MessageBarBase, Object.assign({ innerRef: ref }, props))));
|
|
208
240
|
export { MessageBar };
|
|
@@ -154,6 +154,48 @@ describe('Message bar', () => {
|
|
|
154
154
|
yield userEvent.click(attachButton);
|
|
155
155
|
expect(attachToggleClickSpy).toHaveBeenCalledTimes(1);
|
|
156
156
|
}));
|
|
157
|
+
it('can pass searchInputProps to search input in AttachMenu', () => {
|
|
158
|
+
render(_jsx(MessageBar, { onSendMessage: jest.fn, value: "test", attachMenuProps: {
|
|
159
|
+
isAttachMenuOpen: true,
|
|
160
|
+
setIsAttachMenuOpen: jest.fn(),
|
|
161
|
+
onAttachMenuToggleClick: jest.fn(),
|
|
162
|
+
onAttachMenuInputChange: jest.fn(),
|
|
163
|
+
attachMenuItems: ATTACH_MENU_ITEMS,
|
|
164
|
+
searchInputProps: { isDisabled: true }
|
|
165
|
+
} }));
|
|
166
|
+
expect(screen.getByRole('textbox', { name: /Filter menu items/i })).toBeDisabled();
|
|
167
|
+
});
|
|
168
|
+
it('can pass menuSearchProps to search input in AttachMenu', () => {
|
|
169
|
+
render(_jsx(MessageBar, { onSendMessage: jest.fn, value: "test", attachMenuProps: {
|
|
170
|
+
isAttachMenuOpen: true,
|
|
171
|
+
setIsAttachMenuOpen: jest.fn(),
|
|
172
|
+
onAttachMenuToggleClick: jest.fn(),
|
|
173
|
+
onAttachMenuInputChange: jest.fn(),
|
|
174
|
+
attachMenuItems: ATTACH_MENU_ITEMS,
|
|
175
|
+
menuSearchProps: { 'data-testid': 'menu-search' }
|
|
176
|
+
} }));
|
|
177
|
+
expect(screen.getByTestId('menu-search')).toBeTruthy();
|
|
178
|
+
});
|
|
179
|
+
it('can pass menuSearchInputProps to search input in AttachMenu', () => {
|
|
180
|
+
render(_jsx(MessageBar, { onSendMessage: jest.fn, value: "test", attachMenuProps: {
|
|
181
|
+
isAttachMenuOpen: true,
|
|
182
|
+
setIsAttachMenuOpen: jest.fn(),
|
|
183
|
+
onAttachMenuToggleClick: jest.fn(),
|
|
184
|
+
onAttachMenuInputChange: jest.fn(),
|
|
185
|
+
attachMenuItems: ATTACH_MENU_ITEMS,
|
|
186
|
+
menuSearchInputProps: { 'data-testid': 'menu-search-input' }
|
|
187
|
+
} }));
|
|
188
|
+
expect(screen.getByTestId('menu-search-input')).toBeTruthy();
|
|
189
|
+
});
|
|
190
|
+
it('can remove input from attach menu', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
191
|
+
render(_jsx(MessageBar, { onSendMessage: jest.fn, attachMenuProps: {
|
|
192
|
+
isAttachMenuOpen: true,
|
|
193
|
+
setIsAttachMenuOpen: jest.fn(),
|
|
194
|
+
onAttachMenuToggleClick: jest.fn(),
|
|
195
|
+
attachMenuItems: ATTACH_MENU_ITEMS
|
|
196
|
+
} }));
|
|
197
|
+
expect(screen.queryByRole('textbox', { name: /Filter menu items/i })).not.toBeInTheDocument();
|
|
198
|
+
}));
|
|
157
199
|
it('can hide attach button', () => {
|
|
158
200
|
render(_jsx(MessageBar, { onSendMessage: jest.fn, hasAttachButton: false }));
|
|
159
201
|
expect(screen.queryByRole('button', { name: 'Attach' })).toBeFalsy();
|
|
@@ -185,6 +227,14 @@ describe('Message bar', () => {
|
|
|
185
227
|
render(_jsx(MessageBar, { onSendMessage: jest.fn, hasAttachButton: true, buttonProps: { attach: { props: { 'aria-label': 'Test' } } } }));
|
|
186
228
|
yield userEvent.click(screen.getByRole('button', { name: 'Test' }));
|
|
187
229
|
}));
|
|
230
|
+
it('can change attach button icon', () => {
|
|
231
|
+
render(_jsx(MessageBar, { onSendMessage: jest.fn, hasAttachButton: true, buttonProps: {
|
|
232
|
+
attach: {
|
|
233
|
+
icon: _jsx("img", { alt: "", src: "" })
|
|
234
|
+
}
|
|
235
|
+
} }));
|
|
236
|
+
expect(screen.getByRole('img')).toBeVisible();
|
|
237
|
+
});
|
|
188
238
|
// Stop button
|
|
189
239
|
// --------------------------------------------------------------------------
|
|
190
240
|
it('can show stop button', () => {
|
|
@@ -264,4 +314,28 @@ describe('Message bar', () => {
|
|
|
264
314
|
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
265
315
|
expect(document.activeElement).toBe(screen.getByRole('textbox'));
|
|
266
316
|
});
|
|
317
|
+
it('should handle isPrimary', () => {
|
|
318
|
+
const { container } = render(_jsx(MessageBar, { isPrimary: true, onSendMessage: jest.fn }));
|
|
319
|
+
expect(container.querySelector('.pf-m-primary')).toBeTruthy();
|
|
320
|
+
});
|
|
321
|
+
it('Renders with class pf-v6-m-ai-indicator when hasAiIndicator is true', () => {
|
|
322
|
+
render(_jsx(MessageBar, { onSendMessage: jest.fn, hasAiIndicator: true }));
|
|
323
|
+
expect(screen.getByRole('textbox').closest('.pf-chatbot__message-bar')).toHaveClass('pf-v6-m-ai-indicator');
|
|
324
|
+
});
|
|
325
|
+
it('Renders with class pf-v6-m-thinking when isThinking is true', () => {
|
|
326
|
+
render(_jsx(MessageBar, { onSendMessage: jest.fn, isThinking: true }));
|
|
327
|
+
expect(screen.getByRole('textbox').closest('.pf-chatbot__message-bar')).toHaveClass('pf-v6-m-thinking');
|
|
328
|
+
});
|
|
329
|
+
it('Renders with flex-basis of auto by default', () => {
|
|
330
|
+
render(_jsx(MessageBar, { onSendMessage: jest.fn }));
|
|
331
|
+
expect(screen.getByRole('textbox').closest('.pf-chatbot__message-bar-input')).toHaveAttribute('style', 'flex-basis: auto;');
|
|
332
|
+
});
|
|
333
|
+
it('Renders with flex-basis of 100% when forceMultilineLayout is true', () => {
|
|
334
|
+
render(_jsx(MessageBar, { forceMultilineLayout: true, onSendMessage: jest.fn }));
|
|
335
|
+
expect(screen.getByRole('textbox').closest('.pf-chatbot__message-bar-input')).toHaveAttribute('style', 'flex-basis: 100%;');
|
|
336
|
+
});
|
|
337
|
+
it('Renders with flex-basis of 100% when additionalActions is truthy', () => {
|
|
338
|
+
render(_jsx(MessageBar, { additionalActions: "actions", onSendMessage: jest.fn }));
|
|
339
|
+
expect(screen.getByRole('textbox').closest('.pf-chatbot__message-bar-input')).toHaveAttribute('style', 'flex-basis: 100%;');
|
|
340
|
+
});
|
|
267
341
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import { ModalProps } from '@patternfly/react-core';
|
|
3
|
+
import { ChatbotDisplayMode } from '../Chatbot';
|
|
4
|
+
export interface OnboardingProps extends ModalProps {
|
|
5
|
+
/** Class applied to modal */
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Action assigned to primary modal button */
|
|
8
|
+
onPrimaryAction?: (event: React.MouseEvent | MouseEvent | KeyboardEvent) => void;
|
|
9
|
+
/** Action assigned to secondary modal button */
|
|
10
|
+
onSecondaryAction: (event: React.MouseEvent | MouseEvent | KeyboardEvent) => void;
|
|
11
|
+
/** Name of primary modal button */
|
|
12
|
+
primaryActionBtn?: string;
|
|
13
|
+
/** Name of secondary modal button */
|
|
14
|
+
secondaryActionBtn?: string;
|
|
15
|
+
/** Function that handles modal toggle */
|
|
16
|
+
handleModalToggle: (event: React.MouseEvent | MouseEvent | KeyboardEvent) => void;
|
|
17
|
+
/** Whether modal is open */
|
|
18
|
+
isModalOpen: boolean;
|
|
19
|
+
/** Title of modal */
|
|
20
|
+
title?: string;
|
|
21
|
+
/** Display mode for the Chatbot parent; this influences the styles applied */
|
|
22
|
+
displayMode?: ChatbotDisplayMode;
|
|
23
|
+
/** Optional image displayed in header */
|
|
24
|
+
headerImage?: string;
|
|
25
|
+
/** Alt text for optional image displayed in header */
|
|
26
|
+
headerImageAltText?: string;
|
|
27
|
+
/** Ref applied to modal */
|
|
28
|
+
innerRef?: React.Ref<HTMLDivElement>;
|
|
29
|
+
/** OuiaID applied to modal */
|
|
30
|
+
ouiaId?: string;
|
|
31
|
+
/** Sets modal to compact styling. */
|
|
32
|
+
isCompact?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare const OnboardingBase: FunctionComponent<OnboardingProps>;
|
|
35
|
+
declare const Onboarding: import("react").ForwardRefExoticComponent<Omit<OnboardingProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
36
|
+
export default Onboarding;
|
|
@@ -0,0 +1,30 @@
|
|
|
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, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { forwardRef } from 'react';
|
|
14
|
+
import { Button, Content, ModalBody, ModalFooter } from '@patternfly/react-core';
|
|
15
|
+
import { ChatbotDisplayMode } from '../Chatbot';
|
|
16
|
+
import ChatbotModal from '../ChatbotModal/ChatbotModal';
|
|
17
|
+
export const OnboardingBase = (_a) => {
|
|
18
|
+
var { handleModalToggle, isModalOpen, onPrimaryAction, onSecondaryAction, primaryActionBtn = 'Continue', secondaryActionBtn = 'Skip', title = 'Onboarding', headerImage, headerImageAltText = '', displayMode = ChatbotDisplayMode.default, className, children, innerRef, ouiaId = 'Onboarding', isCompact } = _a, props = __rest(_a, ["handleModalToggle", "isModalOpen", "onPrimaryAction", "onSecondaryAction", "primaryActionBtn", "secondaryActionBtn", "title", "headerImage", "headerImageAltText", "displayMode", "className", "children", "innerRef", "ouiaId", "isCompact"]);
|
|
19
|
+
const handlePrimaryAction = (_event) => {
|
|
20
|
+
handleModalToggle(_event);
|
|
21
|
+
onPrimaryAction && onPrimaryAction(_event);
|
|
22
|
+
};
|
|
23
|
+
const handleSecondaryAction = (_event) => {
|
|
24
|
+
onSecondaryAction(_event);
|
|
25
|
+
};
|
|
26
|
+
const modal = (_jsx(ChatbotModal, Object.assign({ isOpen: isModalOpen, ouiaId: ouiaId, "aria-labelledby": "onboarding-title", "aria-describedby": "onboarding-modal", className: `pf-chatbot__onboarding-modal pf-chatbot__onboarding-modal--${displayMode} ${isCompact ? 'pf-m-compact' : ''} ${className ? className : ''}`, displayMode: displayMode, onClose: handleModalToggle }, props, { children: _jsx("section", { className: `pf-chatbot__onboarding--section`, "aria-label": title, tabIndex: -1, ref: innerRef, children: _jsxs(_Fragment, { children: [_jsxs(ModalBody, { className: "pf-chatbot__onboarding--modal-body", children: [!isCompact && headerImage && (_jsx("div", { className: "pf-chatbot__onboarding--header", children: _jsx("img", { src: headerImage, className: "pf-chatbot__onboarding--image", alt: headerImageAltText }) })), _jsxs("div", { className: "pf-chatbot__onboarding--modal-text", children: [_jsx("h1", { className: "pf-chatbot__onboarding--title", children: title }), _jsx(Content, { children: children })] })] }), _jsxs(ModalFooter, { className: "pf-chatbot__onboarding--footer", children: [_jsx(Button, { isBlock: true, variant: "primary", onClick: handlePrimaryAction, form: "onboarding-form", size: "lg", children: primaryActionBtn }, "onboarding-modal-primary"), _jsx(Button, { isBlock: true, variant: "secondary", onClick: handleSecondaryAction, size: "lg", children: secondaryActionBtn }, "onboarding-modal-secondary")] })] }) }) })));
|
|
27
|
+
return modal;
|
|
28
|
+
};
|
|
29
|
+
const Onboarding = forwardRef((props, ref) => (_jsx(OnboardingBase, Object.assign({ innerRef: ref }, props))));
|
|
30
|
+
export default Onboarding;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { render, screen } from '@testing-library/react';
|
|
12
|
+
import '@testing-library/jest-dom';
|
|
13
|
+
import userEvent from '@testing-library/user-event';
|
|
14
|
+
import Onboarding from './Onboarding';
|
|
15
|
+
const handleModalToggle = jest.fn();
|
|
16
|
+
const onPrimaryAction = jest.fn();
|
|
17
|
+
const onSecondaryAction = jest.fn();
|
|
18
|
+
const body = 'Experience personalized assistance and seamless problem-solving, simplifying your journey with Red Hat every step of the way.';
|
|
19
|
+
describe('Onboarding', () => {
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
jest.clearAllMocks();
|
|
22
|
+
});
|
|
23
|
+
it('should render modal correctly', () => {
|
|
24
|
+
render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, ouiaId: "Terms", children: body }));
|
|
25
|
+
expect(screen.getByRole('heading', { name: /Onboarding/i })).toBeTruthy();
|
|
26
|
+
expect(screen.getByRole('button', { name: /Continue/i })).toBeTruthy();
|
|
27
|
+
expect(screen.getByRole('button', { name: /Skip/i })).toBeTruthy();
|
|
28
|
+
expect(screen.getByText(body)).toBeTruthy();
|
|
29
|
+
expect(screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal');
|
|
30
|
+
expect(screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal--default');
|
|
31
|
+
});
|
|
32
|
+
it('should handle image and altText props', () => {
|
|
33
|
+
render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, headerImage: "./image.png", headerImageAltText: "Test image", children: body }));
|
|
34
|
+
expect(screen.getByRole('img')).toBeTruthy();
|
|
35
|
+
expect(screen.getByRole('img')).toHaveAttribute('alt', 'Test image');
|
|
36
|
+
});
|
|
37
|
+
it('should handle className prop', () => {
|
|
38
|
+
render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, className: "test", children: body }));
|
|
39
|
+
expect(screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal');
|
|
40
|
+
expect(screen.getByRole('dialog')).toHaveClass('pf-chatbot__onboarding-modal--default');
|
|
41
|
+
expect(screen.getByRole('dialog')).toHaveClass('test');
|
|
42
|
+
});
|
|
43
|
+
it('should handle title prop', () => {
|
|
44
|
+
render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, title: "Updated title", children: body }));
|
|
45
|
+
expect(screen.getByRole('heading', { name: /Updated title/i })).toBeTruthy();
|
|
46
|
+
expect(screen.queryByRole('heading', { name: /Onboarding/i })).toBeFalsy();
|
|
47
|
+
});
|
|
48
|
+
it('should handle primary button prop', () => {
|
|
49
|
+
render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, primaryActionBtn: "First", children: body }));
|
|
50
|
+
expect(screen.getByRole('button', { name: /First/i })).toBeTruthy();
|
|
51
|
+
expect(screen.queryByRole('button', { name: /Continue/i })).toBeFalsy();
|
|
52
|
+
});
|
|
53
|
+
it('should handle secondary button prop', () => {
|
|
54
|
+
render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, secondaryActionBtn: "Second", children: body }));
|
|
55
|
+
expect(screen.getByRole('button', { name: /Second/i })).toBeTruthy();
|
|
56
|
+
expect(screen.queryByRole('button', { name: /Skip/i })).toBeFalsy();
|
|
57
|
+
});
|
|
58
|
+
it('should handle primary button click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
render(_jsx(Onboarding, { isModalOpen: true, onPrimaryAction: onPrimaryAction, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, children: body }));
|
|
60
|
+
yield userEvent.click(screen.getByRole('button', { name: /Continue/i }));
|
|
61
|
+
expect(onPrimaryAction).toHaveBeenCalledTimes(1);
|
|
62
|
+
expect(handleModalToggle).toHaveBeenCalledTimes(1);
|
|
63
|
+
}));
|
|
64
|
+
it('should handle secondary button click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, children: body }));
|
|
66
|
+
yield userEvent.click(screen.getByRole('button', { name: /Skip/i }));
|
|
67
|
+
expect(onSecondaryAction).toHaveBeenCalledTimes(1);
|
|
68
|
+
expect(handleModalToggle).not.toHaveBeenCalled();
|
|
69
|
+
}));
|
|
70
|
+
it('should handle isCompact prop', () => {
|
|
71
|
+
render(_jsx(Onboarding, { isModalOpen: true, onSecondaryAction: onSecondaryAction, handleModalToggle: handleModalToggle, isCompact: true, headerImage: "./image.png", headerImageAltText: "Test image", children: body }));
|
|
72
|
+
expect(screen.getByRole('dialog')).toHaveClass('pf-m-compact');
|
|
73
|
+
expect(screen.queryByRole('img')).toBeFalsy();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -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;
|