@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
|
@@ -13,8 +13,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
15
|
const react_core_1 = require("@patternfly/react-core");
|
|
16
|
+
const react_styles_1 = require("@patternfly/react-styles");
|
|
16
17
|
const TextMessage = (_a) => {
|
|
17
|
-
var { component, children } = _a, props = __rest(_a, ["component", "children"]);
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)("span", { className:
|
|
18
|
+
var { component, children, isPrimary, shouldRetainStyles } = _a, props = __rest(_a, ["component", "children", "isPrimary", "shouldRetainStyles"]);
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("span", { className: (0, react_styles_1.css)('pf-chatbot__message-text', isPrimary && 'pf-m-primary', shouldRetainStyles && 'pf-m-markdown'), children: (0, jsx_runtime_1.jsx)(react_core_1.Content, Object.assign({ component: component }, props, { className: (0, react_styles_1.css)(props === null || props === void 0 ? void 0 : props.className), children: children })) }));
|
|
19
20
|
};
|
|
20
21
|
exports.default = TextMessage;
|
|
@@ -48,6 +48,8 @@ export interface UserFeedbackProps extends Omit<CardProps, 'onSubmit'>, OUIAProp
|
|
|
48
48
|
textAreaProps?: TextAreaProps;
|
|
49
49
|
/** Additional props passed to action group */
|
|
50
50
|
actionGroupProps?: ActionGroupProps;
|
|
51
|
+
/** Optional privacy statement text displayed under text area */
|
|
52
|
+
privacyStatement?: string;
|
|
51
53
|
}
|
|
52
|
-
declare const UserFeedback: FunctionComponent<UserFeedbackProps>;
|
|
54
|
+
export declare const UserFeedback: FunctionComponent<UserFeedbackProps>;
|
|
53
55
|
export default UserFeedback;
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.UserFeedback = void 0;
|
|
17
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
19
|
const react_1 = require("react");
|
|
19
20
|
// Import PatternFly components
|
|
@@ -21,7 +22,7 @@ const react_core_1 = require("@patternfly/react-core");
|
|
|
21
22
|
const QuickResponse_1 = __importDefault(require("../QuickResponse/QuickResponse"));
|
|
22
23
|
const CloseButton_1 = __importDefault(require("./CloseButton"));
|
|
23
24
|
const UserFeedback = (_a) => {
|
|
24
|
-
var { className, timestamp, title = 'Why did you choose this rating?', hasTextArea, textAreaAriaLabel = `Provide optional additional feedback for message received at ${timestamp}`, textAreaPlaceholder = 'Provide optional additional feedback', onTextAreaChange, submitWord = 'Submit', quickResponses, quickResponseContainerProps = { 'aria-label': `Quick feedback for message received at ${timestamp}` }, onSubmit, onClose, closeButtonAriaLabel = `Close feedback for message received at ${timestamp}`, id, headingLevel: HeadingLevel = 'h1', focusOnLoad = true, isCompact, children, cardHeaderProps, cardBodyProps, headingLevelProps, formProps, textAreaProps, actionGroupProps, submitButtonProps } = _a, props = __rest(_a, ["className", "timestamp", "title", "hasTextArea", "textAreaAriaLabel", "textAreaPlaceholder", "onTextAreaChange", "submitWord", "quickResponses", "quickResponseContainerProps", "onSubmit", "onClose", "closeButtonAriaLabel", "id", "headingLevel", "focusOnLoad", "isCompact", "children", "cardHeaderProps", "cardBodyProps", "headingLevelProps", "formProps", "textAreaProps", "actionGroupProps", "submitButtonProps"]);
|
|
25
|
+
var { className, timestamp, title = 'Why did you choose this rating?', hasTextArea, textAreaAriaLabel = `Provide optional additional feedback for message received at ${timestamp}`, textAreaPlaceholder = 'Provide optional additional feedback', onTextAreaChange, submitWord = 'Submit', quickResponses, quickResponseContainerProps = { 'aria-label': `Quick feedback for message received at ${timestamp}` }, onSubmit, onClose, closeButtonAriaLabel = `Close feedback for message received at ${timestamp}`, id, headingLevel: HeadingLevel = 'h1', focusOnLoad = true, isCompact, children, cardHeaderProps, cardBodyProps, headingLevelProps, formProps, textAreaProps, actionGroupProps, submitButtonProps, privacyStatement } = _a, props = __rest(_a, ["className", "timestamp", "title", "hasTextArea", "textAreaAriaLabel", "textAreaPlaceholder", "onTextAreaChange", "submitWord", "quickResponses", "quickResponseContainerProps", "onSubmit", "onClose", "closeButtonAriaLabel", "id", "headingLevel", "focusOnLoad", "isCompact", "children", "cardHeaderProps", "cardBodyProps", "headingLevelProps", "formProps", "textAreaProps", "actionGroupProps", "submitButtonProps", "privacyStatement"]);
|
|
25
26
|
const [selectedResponse, setSelectedResponse] = (0, react_1.useState)();
|
|
26
27
|
const [value, setValue] = (0, react_1.useState)('');
|
|
27
28
|
const divRef = (0, react_1.useRef)(null);
|
|
@@ -35,9 +36,10 @@ const UserFeedback = (_a) => {
|
|
|
35
36
|
/* card does not have ref forwarding; hence wrapper div */
|
|
36
37
|
(0, jsx_runtime_1.jsx)("div", { ref: divRef, id: id, tabIndex: 0, "aria-label": title, children: (0, jsx_runtime_1.jsxs)(react_core_1.Card, Object.assign({ isCompact: isCompact, className: `pf-chatbot__feedback-card ${className ? className : ''}` }, props, { children: [(0, jsx_runtime_1.jsx)(react_core_1.CardHeader, Object.assign({ actions: {
|
|
37
38
|
actions: (0, jsx_runtime_1.jsx)(CloseButton_1.default, { onClose: onClose, ariaLabel: closeButtonAriaLabel })
|
|
38
|
-
} }, cardHeaderProps, { children: (0, jsx_runtime_1.jsx)(HeadingLevel, Object.assign({ className: "pf-chatbot__feedback-card-title" }, headingLevelProps, { children: title })) })), (0, jsx_runtime_1.jsx)(react_core_1.CardBody, Object.assign({}, cardBodyProps, { children: (0, jsx_runtime_1.jsxs)(react_core_1.Form, Object.assign({ className: `pf-chatbot__feedback-card-form ${isCompact ? 'pf-m-compact' : ''}` }, formProps, { children: [quickResponses && ((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses, quickResponseContainerProps: quickResponseContainerProps, onSelect: (id) => setSelectedResponse(id), isCompact: isCompact })), hasTextArea && ((0, jsx_runtime_1.jsx)(react_core_1.TextArea, Object.assign({ value: value, onChange: (_event, value) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
} }, cardHeaderProps, { children: (0, jsx_runtime_1.jsx)(HeadingLevel, Object.assign({ className: "pf-chatbot__feedback-card-title" }, headingLevelProps, { children: title })) })), (0, jsx_runtime_1.jsx)(react_core_1.CardBody, Object.assign({}, cardBodyProps, { children: (0, jsx_runtime_1.jsxs)(react_core_1.Form, Object.assign({ className: `pf-chatbot__feedback-card-form ${isCompact ? 'pf-m-compact' : ''}` }, formProps, { children: [quickResponses && ((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses, quickResponseContainerProps: quickResponseContainerProps, onSelect: (id) => setSelectedResponse(id), isCompact: isCompact })), hasTextArea && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(react_core_1.TextArea, Object.assign({ value: value, onChange: (_event, value) => {
|
|
40
|
+
setValue(value);
|
|
41
|
+
onTextAreaChange && onTextAreaChange(_event, value);
|
|
42
|
+
}, placeholder: textAreaPlaceholder, "aria-label": textAreaAriaLabel, resizeOrientation: "vertical" }, textAreaProps)) })), privacyStatement && (0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__feedback-card-privacy", children: privacyStatement }), children, (0, jsx_runtime_1.jsx)(react_core_1.ActionGroup, Object.assign({}, actionGroupProps, { children: (0, jsx_runtime_1.jsx)(react_core_1.Button, Object.assign({ onClick: () => onSubmit(selectedResponse, value), size: isCompact ? 'sm' : undefined }, submitButtonProps, { children: submitWord })) }))] })) }))] })) }));
|
|
42
43
|
};
|
|
43
|
-
exports.
|
|
44
|
+
exports.UserFeedback = UserFeedback;
|
|
45
|
+
exports.default = exports.UserFeedback;
|
|
@@ -38,5 +38,5 @@ export interface UserFeedbackCompleteProps extends Omit<CardProps, 'ref'>, OUIAP
|
|
|
38
38
|
/** Timestamp passed in by Message for more context in aria announcements */
|
|
39
39
|
timestamp?: string;
|
|
40
40
|
}
|
|
41
|
-
declare const UserFeedbackComplete: FunctionComponent<UserFeedbackCompleteProps>;
|
|
41
|
+
export declare const UserFeedbackComplete: FunctionComponent<UserFeedbackCompleteProps>;
|
|
42
42
|
export default UserFeedbackComplete;
|
|
@@ -14,9 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.UserFeedbackComplete = void 0;
|
|
17
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
19
|
const react_1 = require("react");
|
|
19
|
-
// Import PatternFly components
|
|
20
20
|
const react_core_1 = require("@patternfly/react-core");
|
|
21
21
|
const CloseButton_1 = __importDefault(require("./CloseButton"));
|
|
22
22
|
const UserFeedbackComplete = (_a) => {
|
|
@@ -90,4 +90,5 @@ const UserFeedbackComplete = (_a) => {
|
|
|
90
90
|
}
|
|
91
91
|
: undefined }), (0, jsx_runtime_1.jsxs)("div", { className: "pf-chatbot__feedback-complete-body", children: [(0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__feedback-complete-image", children: (0, jsx_runtime_1.jsxs)("svg", { width: "60", height: "64", viewBox: "0 0 60 64", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M53.0555 21.5975H6.94323C3.57013 21.5975 0.835693 24.3319 0.835693 27.705V57.8925C0.835693 61.2656 3.57013 64 6.94323 64H53.0555C56.4286 64 59.1631 61.2656 59.1631 57.8925V27.705C59.1631 24.3319 56.4286 21.5975 53.0555 21.5975Z", fill: "#F8AE54" }), (0, jsx_runtime_1.jsx)("path", { d: "M55.8973 19.8247C52.5894 15.7926 29.9992 0 29.9992 0C29.9992 0 7.40996 15.7926 4.10102 19.8247C0.79312 23.8568 0.835476 25.7184 0.835476 27.8899H59.1629C59.1629 25.7184 59.2052 23.8578 55.8973 19.8257V19.8247Z", fill: "#FFCC17" }), (0, jsx_runtime_1.jsx)("g", { children: (0, jsx_runtime_1.jsx)("path", { d: "M53.0567 8.48981H6.94336V61.8388H53.0567V8.48981Z", fill: "#F2F2F2" }) }), (0, jsx_runtime_1.jsx)("path", { d: "M51.6589 7.49908H8.34204V60.8481H51.6589V7.49908Z", fill: "white" }), (0, jsx_runtime_1.jsx)("path", { d: "M0.835693 29.1296V57.8925C0.835693 59.2375 1.27165 60.4803 2.00823 61.4896L23.0303 43.5462L0.835693 29.1296Z", fill: "#FFCC17" }), (0, jsx_runtime_1.jsx)("path", { d: "M36.9695 43.5472L57.9905 61.4907C58.7271 60.4813 59.1631 59.2386 59.1631 57.8935V29.1306L36.9685 43.5472H36.9695Z", fill: "#FFF4CC" }), (0, jsx_runtime_1.jsx)("path", { d: "M0.835693 57.8925V57.8067L22.4146 42.7992L29.9994 37.5244L37.5842 42.7992L59.1641 57.8067V57.8925C59.1641 61.2665 56.4296 64 53.0566 64H6.94323C3.57024 64 0.835693 61.2665 0.835693 57.8925Z", fill: "#FFE072" }), (0, jsx_runtime_1.jsx)("g", { children: (0, jsx_runtime_1.jsx)("path", { d: "M22.1563 42.978L0.835693 57.8067V56.6993L22.1563 42.978Z", fill: "#FEF07C" }) }), (0, jsx_runtime_1.jsx)("g", { children: (0, jsx_runtime_1.jsx)("path", { d: "M37.8425 42.978L59.1631 57.8067V56.6993L37.8425 42.978Z", fill: "#FEF07C" }) }), (0, jsx_runtime_1.jsx)("path", { d: "M37.8037 32.2373C42.1136 27.9273 42.1136 20.9395 37.8037 16.6295C33.4937 12.3196 26.5059 12.3196 22.196 16.6295C17.886 20.9395 17.886 27.9273 22.196 32.2373C26.5059 36.5472 33.4937 36.5472 37.8037 32.2373Z", fill: "#0066CC" }), (0, jsx_runtime_1.jsx)("path", { d: "M27.7803 30.1276C27.6098 30.1276 27.4497 30.0614 27.3298 29.9406L22.9465 25.5562C22.8267 25.4364 22.7595 25.2762 22.7595 25.1068C22.7595 24.9374 22.8256 24.7762 22.9465 24.6554L24.2379 23.364C24.3577 23.2442 24.5178 23.177 24.6883 23.177C24.8587 23.177 25.0168 23.2431 25.1377 23.363L27.7803 26.0056L34.861 18.9259C34.9808 18.8061 35.1409 18.7389 35.3103 18.7389C35.4798 18.7389 35.6389 18.8051 35.7597 18.9239L37.0531 20.2173C37.173 20.3361 37.2401 20.4962 37.2401 20.6677C37.2401 20.8392 37.174 20.9983 37.0531 21.1181L28.2317 29.9406C28.1119 30.0604 27.9518 30.1265 27.7823 30.1265L27.7803 30.1276Z", fill: "white" })] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "pf-chatbot__feedback-complete-text", children: [(0, jsx_runtime_1.jsx)(react_core_1.CardTitle, { className: "pf-chatbot__feedback-complete-title", children: title }), (0, jsx_runtime_1.jsx)(react_core_1.CardBody, { className: `pf-chatbot__feedback-complete-card-body`, children: body })] })] })] })) })));
|
|
92
92
|
};
|
|
93
|
-
exports.
|
|
93
|
+
exports.UserFeedbackComplete = UserFeedbackComplete;
|
|
94
|
+
exports.default = exports.UserFeedbackComplete;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./UserFeedback"), exports);
|
|
18
|
+
__exportStar(require("./UserFeedbackComplete"), exports);
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
export { default } from './Message';
|
|
2
2
|
export { rehypeCodeBlockToggle } from './Plugins/rehypeCodeBlockToggle';
|
|
3
|
+
export * from './ErrorMessage/ErrorMessage';
|
|
4
|
+
export * from './MessageAndActions';
|
|
5
|
+
export * from './MessageAttachments';
|
|
3
6
|
export * from './Message';
|
|
7
|
+
export * from './MessageLoading';
|
|
8
|
+
export * from './MessageInput';
|
|
9
|
+
export * from './QuickResponse';
|
|
10
|
+
export * from './QuickStarts';
|
|
11
|
+
export * from './UserFeedback';
|
|
@@ -22,4 +22,12 @@ var Message_1 = require("./Message");
|
|
|
22
22
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Message_1).default; } });
|
|
23
23
|
var rehypeCodeBlockToggle_1 = require("./Plugins/rehypeCodeBlockToggle");
|
|
24
24
|
Object.defineProperty(exports, "rehypeCodeBlockToggle", { enumerable: true, get: function () { return rehypeCodeBlockToggle_1.rehypeCodeBlockToggle; } });
|
|
25
|
+
__exportStar(require("./ErrorMessage/ErrorMessage"), exports);
|
|
26
|
+
__exportStar(require("./MessageAndActions"), exports);
|
|
27
|
+
__exportStar(require("./MessageAttachments"), exports);
|
|
25
28
|
__exportStar(require("./Message"), exports);
|
|
29
|
+
__exportStar(require("./MessageLoading"), exports);
|
|
30
|
+
__exportStar(require("./MessageInput"), exports);
|
|
31
|
+
__exportStar(require("./QuickResponse"), exports);
|
|
32
|
+
__exportStar(require("./QuickStarts"), exports);
|
|
33
|
+
__exportStar(require("./UserFeedback"), exports);
|
|
@@ -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>>;
|
|
@@ -19,12 +19,12 @@ const react_core_1 = require("@patternfly/react-core");
|
|
|
19
19
|
const react_dropzone_1 = require("react-dropzone");
|
|
20
20
|
const paperclip_icon_1 = require("@patternfly/react-icons/dist/esm/icons/paperclip-icon");
|
|
21
21
|
const AttachButtonBase = (_a) => {
|
|
22
|
-
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"]);
|
|
22
|
+
var { onAttachAccepted, onClick, isDisabled, className, tooltipProps, innerRef, tooltipContent = 'Attach', inputTestId, isCompact, allowedFileTypes, minSize, maxSize, maxFiles, isAttachmentDisabled, onAttach, onAttachRejected, validator, dropzoneProps, icon = (0, jsx_runtime_1.jsx)(paperclip_icon_1.PaperclipIcon, {}) } = _a, props = __rest(_a, ["onAttachAccepted", "onClick", "isDisabled", "className", "tooltipProps", "innerRef", "tooltipContent", "inputTestId", "isCompact", "allowedFileTypes", "minSize", "maxSize", "maxFiles", "isAttachmentDisabled", "onAttach", "onAttachRejected", "validator", "dropzoneProps", "icon"]);
|
|
23
23
|
const { open, getInputProps } = (0, react_dropzone_1.useDropzone)(Object.assign({ multiple: true, onDropAccepted: onAttachAccepted, accept: allowedFileTypes, minSize,
|
|
24
24
|
maxSize,
|
|
25
25
|
maxFiles, disabled: isAttachmentDisabled, onDrop: onAttach, onDropRejected: onAttachRejected, validator }, dropzoneProps));
|
|
26
26
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("input", Object.assign({ "data-testid": inputTestId }, getInputProps(), { hidden: true })), (0, jsx_runtime_1.jsx)(react_core_1.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,
|
|
27
27
|
// prevents VO announcements of both aria label and tooltip
|
|
28
|
-
aria: "none" }, tooltipProps, { children: (0, jsx_runtime_1.jsx)(react_core_1.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: (0, jsx_runtime_1.jsx)(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true, children:
|
|
28
|
+
aria: "none" }, tooltipProps, { children: (0, jsx_runtime_1.jsx)(react_core_1.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: (0, jsx_runtime_1.jsx)(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true, children: icon }), size: isCompact ? 'sm' : undefined }, props)) }))] }));
|
|
29
29
|
};
|
|
30
30
|
exports.AttachButton = (0, react_1.forwardRef)((props, ref) => ((0, jsx_runtime_1.jsx)(AttachButtonBase, Object.assign({ innerRef: ref }, props))));
|
|
@@ -145,4 +145,8 @@ describe('Attach button', () => {
|
|
|
145
145
|
expect(validator).toHaveBeenCalledWith(file);
|
|
146
146
|
expect(onAttachRejected).toHaveBeenCalled();
|
|
147
147
|
}));
|
|
148
|
+
it('should handle icon prop', () => {
|
|
149
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(AttachButton_1.AttachButton, { icon: (0, jsx_runtime_1.jsx)("img", { alt: "", src: "" }) }));
|
|
150
|
+
expect(react_1.screen.getByRole('img')).toBeVisible();
|
|
151
|
+
});
|
|
148
152
|
});
|
|
@@ -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>>;
|
|
@@ -18,6 +18,7 @@ exports.MessageBar = exports.MessageBarBase = void 0;
|
|
|
18
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
const react_1 = require("react");
|
|
20
20
|
const react_core_1 = require("@patternfly/react-core");
|
|
21
|
+
const react_styles_1 = require("@patternfly/react-styles");
|
|
21
22
|
// Import Chatbot components
|
|
22
23
|
const SendButton_1 = __importDefault(require("./SendButton"));
|
|
23
24
|
const MicrophoneButton_1 = __importDefault(require("./MicrophoneButton"));
|
|
@@ -26,17 +27,24 @@ const AttachMenu_1 = __importDefault(require("../AttachMenu"));
|
|
|
26
27
|
const StopButton_1 = __importDefault(require("./StopButton"));
|
|
27
28
|
const MessageBarBase = (_a) => {
|
|
28
29
|
var _b;
|
|
29
|
-
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"]);
|
|
30
|
+
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"]);
|
|
30
31
|
// Text Input
|
|
31
32
|
// --------------------------------------------------------------------------
|
|
32
33
|
const [message, setMessage] = (0, react_1.useState)(value !== null && value !== void 0 ? value : '');
|
|
33
34
|
const [isListeningMessage, setIsListeningMessage] = (0, react_1.useState)(false);
|
|
34
35
|
const [hasSentMessage, setHasSentMessage] = (0, react_1.useState)(false);
|
|
35
36
|
const [isComposing, setIsComposing] = (0, react_1.useState)(false);
|
|
37
|
+
const shouldForceMultiline = forceMultilineLayout || additionalActions;
|
|
38
|
+
const [isMultiline, setIsMultiline] = (0, react_1.useState)(shouldForceMultiline);
|
|
36
39
|
const inputRef = (0, react_1.useRef)(null);
|
|
37
40
|
const textareaRef = (_b = innerRef) !== null && _b !== void 0 ? _b : inputRef;
|
|
38
41
|
const attachButtonRef = (0, react_1.useRef)(null);
|
|
39
42
|
const topMargin = '1rem';
|
|
43
|
+
(0, react_1.useEffect)(() => {
|
|
44
|
+
if (value !== undefined && value !== message) {
|
|
45
|
+
setMessage(value);
|
|
46
|
+
}
|
|
47
|
+
}, [value, message]);
|
|
40
48
|
const setInitialLineHeight = (field) => {
|
|
41
49
|
field.style.setProperty('line-height', '1rem');
|
|
42
50
|
const parent = field.parentElement;
|
|
@@ -46,7 +54,7 @@ const MessageBarBase = (_a) => {
|
|
|
46
54
|
parent.style.setProperty('height', 'inherit');
|
|
47
55
|
const grandparent = parent.parentElement;
|
|
48
56
|
if (grandparent) {
|
|
49
|
-
grandparent.style.setProperty('flex-basis', 'auto');
|
|
57
|
+
grandparent.style.setProperty('flex-basis', shouldForceMultiline ? '100%' : 'auto');
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
};
|
|
@@ -73,11 +81,20 @@ const MessageBarBase = (_a) => {
|
|
|
73
81
|
const lines = field.scrollHeight / lineHeight;
|
|
74
82
|
return lines > 2;
|
|
75
83
|
};
|
|
84
|
+
const checkIfMultiline = (0, react_1.useCallback)((field) => {
|
|
85
|
+
const parent = field.parentElement;
|
|
86
|
+
const grandparent = parent === null || parent === void 0 ? void 0 : parent.parentElement;
|
|
87
|
+
if (grandparent) {
|
|
88
|
+
const containerHeight = grandparent.offsetHeight;
|
|
89
|
+
const threshold = isCompact ? 56 : 70;
|
|
90
|
+
setIsMultiline(containerHeight > threshold);
|
|
91
|
+
}
|
|
92
|
+
}, [isCompact]);
|
|
76
93
|
const setAutoWidth = (0, react_1.useCallback)((field) => {
|
|
77
94
|
const parent = field.parentElement;
|
|
78
95
|
if (parent) {
|
|
79
96
|
const grandparent = parent.parentElement;
|
|
80
|
-
if (textIsLongerThan2Lines(field) && grandparent) {
|
|
97
|
+
if ((textIsLongerThan2Lines(field) || shouldForceMultiline) && grandparent) {
|
|
81
98
|
grandparent.style.setProperty('flex-basis', `100%`);
|
|
82
99
|
}
|
|
83
100
|
}
|
|
@@ -125,13 +142,15 @@ const MessageBarBase = (_a) => {
|
|
|
125
142
|
if (field) {
|
|
126
143
|
if (field.value === '') {
|
|
127
144
|
setInitialLineHeight(field);
|
|
145
|
+
!shouldForceMultiline && setIsMultiline(false);
|
|
128
146
|
}
|
|
129
147
|
else {
|
|
130
148
|
setAutoHeight(field);
|
|
131
149
|
setAutoWidth(field);
|
|
150
|
+
!shouldForceMultiline && checkIfMultiline(field);
|
|
132
151
|
}
|
|
133
152
|
}
|
|
134
|
-
}, [displayMode, message, setAutoWidth]);
|
|
153
|
+
}, [displayMode, message, setAutoWidth, shouldForceMultiline, checkIfMultiline]);
|
|
135
154
|
(0, react_1.useEffect)(() => {
|
|
136
155
|
const field = textareaRef.current;
|
|
137
156
|
if (field) {
|
|
@@ -144,13 +163,15 @@ const MessageBarBase = (_a) => {
|
|
|
144
163
|
if (textareaRef.current) {
|
|
145
164
|
if (event.target.value === '') {
|
|
146
165
|
setInitialLineHeight(textareaRef.current);
|
|
166
|
+
!shouldForceMultiline && setIsMultiline(false);
|
|
147
167
|
}
|
|
148
168
|
else {
|
|
149
169
|
setAutoHeight(textareaRef.current);
|
|
170
|
+
!shouldForceMultiline && checkIfMultiline(textareaRef.current);
|
|
150
171
|
}
|
|
151
172
|
}
|
|
152
173
|
setMessage(event.target.value);
|
|
153
|
-
}, [onChange]);
|
|
174
|
+
}, [onChange, checkIfMultiline]);
|
|
154
175
|
// Handle sending message
|
|
155
176
|
const handleSend = (0, react_1.useCallback)((newMessage) => {
|
|
156
177
|
onSendMessage(newMessage);
|
|
@@ -192,23 +213,34 @@ const MessageBarBase = (_a) => {
|
|
|
192
213
|
setMessage(message);
|
|
193
214
|
onChange && onChange({}, message);
|
|
194
215
|
};
|
|
216
|
+
const renderAttachButton = () => {
|
|
217
|
+
var _a, _b, _c, _d, _e, _f;
|
|
218
|
+
if (!attachMenuProps && hasAttachButton) {
|
|
219
|
+
return ((0, jsx_runtime_1.jsx)(AttachButton_1.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)));
|
|
220
|
+
}
|
|
221
|
+
if (attachMenuProps) {
|
|
222
|
+
return ((0, jsx_runtime_1.jsx)(AttachButton_1.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)));
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const isAttachButtonAtStart = attachButtonPosition === 'start';
|
|
195
226
|
const renderButtons = () => {
|
|
196
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
227
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
197
228
|
if (hasStopButton && handleStopButton) {
|
|
198
229
|
return ((0, jsx_runtime_1.jsx)(StopButton_1.default, 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)));
|
|
199
230
|
}
|
|
200
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [
|
|
231
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [!isAttachButtonAtStart && renderAttachButton(), hasMicrophoneButton && ((0, jsx_runtime_1.jsx)(MicrophoneButton_1.default, 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) && ((0, jsx_runtime_1.jsx)(SendButton_1.default, 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)))] }));
|
|
201
232
|
};
|
|
202
|
-
const
|
|
233
|
+
const hasGroupedActions = additionalActions || (isAttachButtonAtStart && isMultiline);
|
|
234
|
+
const messageBarContents = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isAttachButtonAtStart && !isMultiline && ((0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__message-bar-actions test", children: renderAttachButton() })), (0, jsx_runtime_1.jsx)("div", { className: `pf-chatbot__message-bar-input ${isCompact ? 'pf-m-compact' : ''}`, children: (0, jsx_runtime_1.jsx)(react_core_1.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)) }), (0, jsx_runtime_1.jsx)("div", { className: (0, react_styles_1.css)('pf-chatbot__message-bar-actions', hasGroupedActions && 'pf-m-grouped'), children: hasGroupedActions ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, react_styles_1.css)('pf-chatbot__message-bar-actions-group'), children: [isAttachButtonAtStart && renderAttachButton(), additionalActions] }), (0, jsx_runtime_1.jsx)("div", { className: (0, react_styles_1.css)('pf-chatbot__message-bar-actions-group'), children: renderButtons() })] })) : (renderButtons()) })] }));
|
|
203
235
|
if (attachMenuProps) {
|
|
204
|
-
return ((0, jsx_runtime_1.jsx)(AttachMenu_1.default, Object.assign({ toggle: (toggleRef) => ((0, jsx_runtime_1.jsx)("div", { ref: toggleRef, className:
|
|
236
|
+
return ((0, jsx_runtime_1.jsx)(AttachMenu_1.default, Object.assign({ toggle: (toggleRef) => ((0, jsx_runtime_1.jsx)("div", { ref: toggleRef, className: (0, react_styles_1.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) => {
|
|
205
237
|
var _a;
|
|
206
238
|
(_a = attachButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
207
239
|
attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.setIsAttachMenuOpen(isAttachMenuOpen);
|
|
208
240
|
(attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.onAttachMenuOpenChange) && (attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.onAttachMenuOpenChange(isAttachMenuOpen));
|
|
209
|
-
}, 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 })));
|
|
241
|
+
}, 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)));
|
|
210
242
|
}
|
|
211
|
-
return (0, jsx_runtime_1.jsx)("div", { className:
|
|
243
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, react_styles_1.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 }));
|
|
212
244
|
};
|
|
213
245
|
exports.MessageBarBase = MessageBarBase;
|
|
214
246
|
const MessageBar = (0, react_1.forwardRef)((props, ref) => ((0, jsx_runtime_1.jsx)(exports.MessageBarBase, Object.assign({ innerRef: ref }, props))));
|
|
@@ -159,6 +159,48 @@ describe('Message bar', () => {
|
|
|
159
159
|
yield user_event_1.default.click(attachButton);
|
|
160
160
|
expect(attachToggleClickSpy).toHaveBeenCalledTimes(1);
|
|
161
161
|
}));
|
|
162
|
+
it('can pass searchInputProps to search input in AttachMenu', () => {
|
|
163
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { onSendMessage: jest.fn, value: "test", attachMenuProps: {
|
|
164
|
+
isAttachMenuOpen: true,
|
|
165
|
+
setIsAttachMenuOpen: jest.fn(),
|
|
166
|
+
onAttachMenuToggleClick: jest.fn(),
|
|
167
|
+
onAttachMenuInputChange: jest.fn(),
|
|
168
|
+
attachMenuItems: ATTACH_MENU_ITEMS,
|
|
169
|
+
searchInputProps: { isDisabled: true }
|
|
170
|
+
} }));
|
|
171
|
+
expect(react_1.screen.getByRole('textbox', { name: /Filter menu items/i })).toBeDisabled();
|
|
172
|
+
});
|
|
173
|
+
it('can pass menuSearchProps to search input in AttachMenu', () => {
|
|
174
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { onSendMessage: jest.fn, value: "test", attachMenuProps: {
|
|
175
|
+
isAttachMenuOpen: true,
|
|
176
|
+
setIsAttachMenuOpen: jest.fn(),
|
|
177
|
+
onAttachMenuToggleClick: jest.fn(),
|
|
178
|
+
onAttachMenuInputChange: jest.fn(),
|
|
179
|
+
attachMenuItems: ATTACH_MENU_ITEMS,
|
|
180
|
+
menuSearchProps: { 'data-testid': 'menu-search' }
|
|
181
|
+
} }));
|
|
182
|
+
expect(react_1.screen.getByTestId('menu-search')).toBeTruthy();
|
|
183
|
+
});
|
|
184
|
+
it('can pass menuSearchInputProps to search input in AttachMenu', () => {
|
|
185
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { onSendMessage: jest.fn, value: "test", attachMenuProps: {
|
|
186
|
+
isAttachMenuOpen: true,
|
|
187
|
+
setIsAttachMenuOpen: jest.fn(),
|
|
188
|
+
onAttachMenuToggleClick: jest.fn(),
|
|
189
|
+
onAttachMenuInputChange: jest.fn(),
|
|
190
|
+
attachMenuItems: ATTACH_MENU_ITEMS,
|
|
191
|
+
menuSearchInputProps: { 'data-testid': 'menu-search-input' }
|
|
192
|
+
} }));
|
|
193
|
+
expect(react_1.screen.getByTestId('menu-search-input')).toBeTruthy();
|
|
194
|
+
});
|
|
195
|
+
it('can remove input from attach menu', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
196
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { onSendMessage: jest.fn, attachMenuProps: {
|
|
197
|
+
isAttachMenuOpen: true,
|
|
198
|
+
setIsAttachMenuOpen: jest.fn(),
|
|
199
|
+
onAttachMenuToggleClick: jest.fn(),
|
|
200
|
+
attachMenuItems: ATTACH_MENU_ITEMS
|
|
201
|
+
} }));
|
|
202
|
+
expect(react_1.screen.queryByRole('textbox', { name: /Filter menu items/i })).not.toBeInTheDocument();
|
|
203
|
+
}));
|
|
162
204
|
it('can hide attach button', () => {
|
|
163
205
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasAttachButton: false }));
|
|
164
206
|
expect(react_1.screen.queryByRole('button', { name: 'Attach' })).toBeFalsy();
|
|
@@ -190,6 +232,14 @@ describe('Message bar', () => {
|
|
|
190
232
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasAttachButton: true, buttonProps: { attach: { props: { 'aria-label': 'Test' } } } }));
|
|
191
233
|
yield user_event_1.default.click(react_1.screen.getByRole('button', { name: 'Test' }));
|
|
192
234
|
}));
|
|
235
|
+
it('can change attach button icon', () => {
|
|
236
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasAttachButton: true, buttonProps: {
|
|
237
|
+
attach: {
|
|
238
|
+
icon: (0, jsx_runtime_1.jsx)("img", { alt: "", src: "" })
|
|
239
|
+
}
|
|
240
|
+
} }));
|
|
241
|
+
expect(react_1.screen.getByRole('img')).toBeVisible();
|
|
242
|
+
});
|
|
193
243
|
// Stop button
|
|
194
244
|
// --------------------------------------------------------------------------
|
|
195
245
|
it('can show stop button', () => {
|
|
@@ -269,4 +319,28 @@ describe('Message bar', () => {
|
|
|
269
319
|
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
270
320
|
expect(document.activeElement).toBe(react_1.screen.getByRole('textbox'));
|
|
271
321
|
});
|
|
322
|
+
it('should handle isPrimary', () => {
|
|
323
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { isPrimary: true, onSendMessage: jest.fn }));
|
|
324
|
+
expect(container.querySelector('.pf-m-primary')).toBeTruthy();
|
|
325
|
+
});
|
|
326
|
+
it('Renders with class pf-v6-m-ai-indicator when hasAiIndicator is true', () => {
|
|
327
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasAiIndicator: true }));
|
|
328
|
+
expect(react_1.screen.getByRole('textbox').closest('.pf-chatbot__message-bar')).toHaveClass('pf-v6-m-ai-indicator');
|
|
329
|
+
});
|
|
330
|
+
it('Renders with class pf-v6-m-thinking when isThinking is true', () => {
|
|
331
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { onSendMessage: jest.fn, isThinking: true }));
|
|
332
|
+
expect(react_1.screen.getByRole('textbox').closest('.pf-chatbot__message-bar')).toHaveClass('pf-v6-m-thinking');
|
|
333
|
+
});
|
|
334
|
+
it('Renders with flex-basis of auto by default', () => {
|
|
335
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { onSendMessage: jest.fn }));
|
|
336
|
+
expect(react_1.screen.getByRole('textbox').closest('.pf-chatbot__message-bar-input')).toHaveAttribute('style', 'flex-basis: auto;');
|
|
337
|
+
});
|
|
338
|
+
it('Renders with flex-basis of 100% when forceMultilineLayout is true', () => {
|
|
339
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { forceMultilineLayout: true, onSendMessage: jest.fn }));
|
|
340
|
+
expect(react_1.screen.getByRole('textbox').closest('.pf-chatbot__message-bar-input')).toHaveAttribute('style', 'flex-basis: 100%;');
|
|
341
|
+
});
|
|
342
|
+
it('Renders with flex-basis of 100% when additionalActions is truthy', () => {
|
|
343
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageBar_1.MessageBar, { additionalActions: "actions", onSendMessage: jest.fn }));
|
|
344
|
+
expect(react_1.screen.getByRole('textbox').closest('.pf-chatbot__message-bar-input')).toHaveAttribute('style', 'flex-basis: 100%;');
|
|
345
|
+
});
|
|
272
346
|
});
|
|
@@ -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,37 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.OnboardingBase = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const react_core_1 = require("@patternfly/react-core");
|
|
21
|
+
const Chatbot_1 = require("../Chatbot");
|
|
22
|
+
const ChatbotModal_1 = __importDefault(require("../ChatbotModal/ChatbotModal"));
|
|
23
|
+
const OnboardingBase = (_a) => {
|
|
24
|
+
var { handleModalToggle, isModalOpen, onPrimaryAction, onSecondaryAction, primaryActionBtn = 'Continue', secondaryActionBtn = 'Skip', title = 'Onboarding', headerImage, headerImageAltText = '', displayMode = Chatbot_1.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"]);
|
|
25
|
+
const handlePrimaryAction = (_event) => {
|
|
26
|
+
handleModalToggle(_event);
|
|
27
|
+
onPrimaryAction && onPrimaryAction(_event);
|
|
28
|
+
};
|
|
29
|
+
const handleSecondaryAction = (_event) => {
|
|
30
|
+
onSecondaryAction(_event);
|
|
31
|
+
};
|
|
32
|
+
const modal = ((0, jsx_runtime_1.jsx)(ChatbotModal_1.default, 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: (0, jsx_runtime_1.jsx)("section", { className: `pf-chatbot__onboarding--section`, "aria-label": title, tabIndex: -1, ref: innerRef, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_core_1.ModalBody, { className: "pf-chatbot__onboarding--modal-body", children: [!isCompact && headerImage && ((0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__onboarding--header", children: (0, jsx_runtime_1.jsx)("img", { src: headerImage, className: "pf-chatbot__onboarding--image", alt: headerImageAltText }) })), (0, jsx_runtime_1.jsxs)("div", { className: "pf-chatbot__onboarding--modal-text", children: [(0, jsx_runtime_1.jsx)("h1", { className: "pf-chatbot__onboarding--title", children: title }), (0, jsx_runtime_1.jsx)(react_core_1.Content, { children: children })] })] }), (0, jsx_runtime_1.jsxs)(react_core_1.ModalFooter, { className: "pf-chatbot__onboarding--footer", children: [(0, jsx_runtime_1.jsx)(react_core_1.Button, { isBlock: true, variant: "primary", onClick: handlePrimaryAction, form: "onboarding-form", size: "lg", children: primaryActionBtn }, "onboarding-modal-primary"), (0, jsx_runtime_1.jsx)(react_core_1.Button, { isBlock: true, variant: "secondary", onClick: handleSecondaryAction, size: "lg", children: secondaryActionBtn }, "onboarding-modal-secondary")] })] }) }) })));
|
|
33
|
+
return modal;
|
|
34
|
+
};
|
|
35
|
+
exports.OnboardingBase = OnboardingBase;
|
|
36
|
+
const Onboarding = (0, react_1.forwardRef)((props, ref) => ((0, jsx_runtime_1.jsx)(exports.OnboardingBase, Object.assign({ innerRef: ref }, props))));
|
|
37
|
+
exports.default = Onboarding;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|