@patternfly/chatbot 2.2.1 → 6.3.0-prerelease.10
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/AttachmentEdit/AttachmentEdit.d.ts +2 -0
- package/dist/cjs/AttachmentEdit/AttachmentEdit.js +2 -2
- package/dist/cjs/Chatbot/Chatbot.d.ts +2 -0
- package/dist/cjs/Chatbot/Chatbot.js +2 -2
- package/dist/cjs/Chatbot/Chatbot.test.js +4 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +6 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +9 -3
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +27 -0
- package/dist/cjs/ChatbotFooter/ChatbotFooter.d.ts +1 -0
- package/dist/cjs/ChatbotFooter/ChatbotFooter.js +2 -2
- package/dist/cjs/ChatbotFooter/ChatbotFooter.test.d.ts +1 -1
- package/dist/cjs/ChatbotFooter/ChatbotFooter.test.js +5 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeader.js +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.d.ts +4 -2
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.js +20 -6
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.js +5 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.js +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.d.ts +3 -2
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.js +20 -6
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.js +5 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.js +3 -3
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +5 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.js +2 -2
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +5 -0
- package/dist/cjs/ChatbotModal/ChatbotModal.d.ts +3 -0
- package/dist/cjs/ChatbotModal/ChatbotModal.js +2 -2
- package/dist/cjs/ChatbotModal/ChatbotModal.test.d.ts +1 -0
- package/dist/cjs/ChatbotModal/ChatbotModal.test.js +28 -0
- package/dist/cjs/ChatbotPopover/ChatbotPopover.js +1 -1
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.d.ts +1 -0
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.js +3 -3
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +4 -0
- package/dist/cjs/CodeModal/CodeModal.d.ts +2 -0
- package/dist/cjs/CodeModal/CodeModal.js +3 -3
- package/dist/cjs/CodeModal/CodeModal.test.d.ts +1 -0
- package/dist/cjs/CodeModal/CodeModal.test.js +15 -0
- package/dist/cjs/FileDetails/FileDetails.js +1 -1
- package/dist/cjs/Message/Message.d.ts +19 -1
- package/dist/cjs/Message/Message.js +58 -39
- package/dist/cjs/Message/Message.test.js +64 -0
- package/dist/cjs/Message/MessageInput.d.ts +18 -0
- package/dist/cjs/Message/MessageInput.js +34 -0
- package/dist/cjs/Message/QuickResponse/QuickResponse.d.ts +2 -0
- package/dist/cjs/Message/QuickResponse/QuickResponse.js +2 -2
- package/dist/cjs/Message/QuickStarts/QuickStartTile.d.ts +2 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTile.js +2 -2
- package/dist/cjs/Message/UserFeedback/UserFeedback.js +4 -4
- package/dist/cjs/Message/UserFeedback/UserFeedback.test.js +4 -0
- package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.js +4 -4
- package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.test.js +4 -0
- package/dist/cjs/MessageBar/AttachButton.d.ts +1 -0
- package/dist/cjs/MessageBar/AttachButton.js +3 -3
- package/dist/cjs/MessageBar/AttachButton.test.js +4 -0
- package/dist/cjs/MessageBar/MessageBar.d.ts +5 -0
- package/dist/cjs/MessageBar/MessageBar.js +14 -13
- package/dist/cjs/MessageBar/MessageBar.test.js +13 -0
- package/dist/cjs/MessageBar/MicrophoneButton.d.ts +1 -0
- package/dist/cjs/MessageBar/MicrophoneButton.js +4 -4
- package/dist/cjs/MessageBar/SendButton.d.ts +1 -0
- package/dist/cjs/MessageBar/SendButton.js +3 -3
- package/dist/cjs/MessageBar/SendButton.test.js +4 -0
- package/dist/cjs/MessageBar/StopButton.d.ts +1 -0
- package/dist/cjs/MessageBar/StopButton.js +3 -3
- package/dist/cjs/MessageBar/StopButton.test.js +4 -0
- package/dist/cjs/MessageBox/MessageBox.d.ts +4 -0
- package/dist/cjs/MessageBox/MessageBox.js +21 -7
- package/dist/cjs/MessageBox/MessageBox.test.js +43 -0
- package/dist/cjs/PreviewAttachment/PreviewAttachment.d.ts +2 -0
- package/dist/cjs/PreviewAttachment/PreviewAttachment.js +2 -2
- package/dist/cjs/Settings/SettingsForm.d.ts +2 -0
- package/dist/cjs/Settings/SettingsForm.js +2 -2
- package/dist/cjs/Settings/SettingsForm.test.d.ts +1 -1
- package/dist/cjs/Settings/SettingsForm.test.js +12 -0
- package/dist/cjs/SourcesCard/SourcesCard.d.ts +7 -1
- package/dist/cjs/SourcesCard/SourcesCard.js +17 -11
- package/dist/cjs/SourcesCard/SourcesCard.test.js +25 -15
- package/dist/cjs/TermsOfUse/TermsOfUse.d.ts +2 -0
- package/dist/cjs/TermsOfUse/TermsOfUse.js +5 -5
- package/dist/cjs/tracking/console_tracking_provider.d.ts +4 -5
- package/dist/cjs/tracking/console_tracking_provider.js +22 -15
- package/dist/cjs/tracking/posthog_tracking_provider.d.ts +2 -2
- package/dist/cjs/tracking/posthog_tracking_provider.js +21 -12
- package/dist/cjs/tracking/segment_tracking_provider.d.ts +2 -2
- package/dist/cjs/tracking/segment_tracking_provider.js +21 -12
- package/dist/cjs/tracking/trackingProviderProxy.d.ts +1 -1
- package/dist/cjs/tracking/trackingProviderProxy.js +2 -2
- package/dist/cjs/tracking/tracking_api.d.ts +1 -1
- package/dist/cjs/tracking/tracking_registry.js +46 -12
- package/dist/cjs/tracking/tracking_spi.d.ts +15 -5
- package/dist/cjs/tracking/tracking_spi.js +9 -0
- package/dist/cjs/tracking/umami_tracking_provider.d.ts +6 -2
- package/dist/cjs/tracking/umami_tracking_provider.js +66 -22
- package/dist/css/main.css +225 -22
- package/dist/css/main.css.map +1 -1
- package/dist/esm/AttachmentEdit/AttachmentEdit.d.ts +2 -0
- package/dist/esm/AttachmentEdit/AttachmentEdit.js +2 -2
- package/dist/esm/Chatbot/Chatbot.d.ts +2 -0
- package/dist/esm/Chatbot/Chatbot.js +2 -2
- package/dist/esm/Chatbot/Chatbot.test.js +4 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +6 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +9 -3
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +27 -0
- package/dist/esm/ChatbotFooter/ChatbotFooter.d.ts +1 -0
- package/dist/esm/ChatbotFooter/ChatbotFooter.js +2 -2
- package/dist/esm/ChatbotFooter/ChatbotFooter.test.d.ts +1 -1
- package/dist/esm/ChatbotFooter/ChatbotFooter.test.js +5 -0
- package/dist/esm/ChatbotHeader/ChatbotHeader.js +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.d.ts +4 -2
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.js +20 -6
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.js +5 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMain.js +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.d.ts +3 -2
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +20 -6
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.js +5 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.js +3 -3
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +5 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.js +2 -2
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +5 -0
- package/dist/esm/ChatbotModal/ChatbotModal.d.ts +3 -0
- package/dist/esm/ChatbotModal/ChatbotModal.js +2 -2
- package/dist/esm/ChatbotModal/ChatbotModal.test.d.ts +1 -0
- package/dist/esm/ChatbotModal/ChatbotModal.test.js +23 -0
- package/dist/esm/ChatbotPopover/ChatbotPopover.js +1 -1
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.d.ts +1 -0
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.js +3 -3
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +4 -0
- package/dist/esm/CodeModal/CodeModal.d.ts +2 -0
- package/dist/esm/CodeModal/CodeModal.js +3 -3
- package/dist/esm/CodeModal/CodeModal.test.d.ts +1 -0
- package/dist/esm/CodeModal/CodeModal.test.js +10 -0
- package/dist/esm/FileDetails/FileDetails.js +1 -1
- package/dist/esm/Message/Message.d.ts +19 -1
- package/dist/esm/Message/Message.js +58 -39
- package/dist/esm/Message/Message.test.js +64 -0
- package/dist/esm/Message/MessageInput.d.ts +18 -0
- package/dist/esm/Message/MessageInput.js +29 -0
- package/dist/esm/Message/QuickResponse/QuickResponse.d.ts +2 -0
- package/dist/esm/Message/QuickResponse/QuickResponse.js +2 -2
- package/dist/esm/Message/QuickStarts/QuickStartTile.d.ts +2 -0
- package/dist/esm/Message/QuickStarts/QuickStartTile.js +2 -2
- package/dist/esm/Message/UserFeedback/UserFeedback.js +4 -4
- package/dist/esm/Message/UserFeedback/UserFeedback.test.js +4 -0
- package/dist/esm/Message/UserFeedback/UserFeedbackComplete.js +4 -4
- package/dist/esm/Message/UserFeedback/UserFeedbackComplete.test.js +4 -0
- package/dist/esm/MessageBar/AttachButton.d.ts +1 -0
- package/dist/esm/MessageBar/AttachButton.js +3 -3
- package/dist/esm/MessageBar/AttachButton.test.js +4 -0
- package/dist/esm/MessageBar/MessageBar.d.ts +5 -0
- package/dist/esm/MessageBar/MessageBar.js +14 -13
- package/dist/esm/MessageBar/MessageBar.test.js +13 -0
- package/dist/esm/MessageBar/MicrophoneButton.d.ts +1 -0
- package/dist/esm/MessageBar/MicrophoneButton.js +4 -4
- package/dist/esm/MessageBar/SendButton.d.ts +1 -0
- package/dist/esm/MessageBar/SendButton.js +3 -3
- package/dist/esm/MessageBar/SendButton.test.js +4 -0
- package/dist/esm/MessageBar/StopButton.d.ts +1 -0
- package/dist/esm/MessageBar/StopButton.js +3 -3
- package/dist/esm/MessageBar/StopButton.test.js +4 -0
- package/dist/esm/MessageBox/MessageBox.d.ts +4 -0
- package/dist/esm/MessageBox/MessageBox.js +21 -7
- package/dist/esm/MessageBox/MessageBox.test.js +44 -1
- package/dist/esm/PreviewAttachment/PreviewAttachment.d.ts +2 -0
- package/dist/esm/PreviewAttachment/PreviewAttachment.js +2 -2
- package/dist/esm/Settings/SettingsForm.d.ts +2 -0
- package/dist/esm/Settings/SettingsForm.js +2 -2
- package/dist/esm/Settings/SettingsForm.test.d.ts +1 -1
- package/dist/esm/Settings/SettingsForm.test.js +12 -0
- package/dist/esm/SourcesCard/SourcesCard.d.ts +7 -1
- package/dist/esm/SourcesCard/SourcesCard.js +18 -12
- package/dist/esm/SourcesCard/SourcesCard.test.js +25 -15
- package/dist/esm/TermsOfUse/TermsOfUse.d.ts +2 -0
- package/dist/esm/TermsOfUse/TermsOfUse.js +5 -5
- package/dist/esm/tracking/console_tracking_provider.d.ts +4 -5
- package/dist/esm/tracking/console_tracking_provider.js +22 -15
- package/dist/esm/tracking/posthog_tracking_provider.d.ts +2 -2
- package/dist/esm/tracking/posthog_tracking_provider.js +21 -12
- package/dist/esm/tracking/segment_tracking_provider.d.ts +2 -2
- package/dist/esm/tracking/segment_tracking_provider.js +21 -12
- package/dist/esm/tracking/trackingProviderProxy.d.ts +1 -1
- package/dist/esm/tracking/trackingProviderProxy.js +2 -2
- package/dist/esm/tracking/tracking_api.d.ts +1 -1
- package/dist/esm/tracking/tracking_registry.js +46 -12
- package/dist/esm/tracking/tracking_spi.d.ts +15 -5
- package/dist/esm/tracking/tracking_spi.js +8 -1
- package/dist/esm/tracking/umami_tracking_provider.d.ts +6 -2
- package/dist/esm/tracking/umami_tracking_provider.js +66 -22
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Analytics/Analytics.md +18 -14
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachmentEdit.tsx +10 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +74 -104
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/FileDetailsLabel.tsx +48 -37
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithFeedback.tsx +33 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx +34 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickStart.tsx +11 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +71 -13
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +3 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/PreviewAttachment.tsx +10 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +80 -104
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +44 -2
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerResizable.tsx +13 -2
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithActions.tsx +9 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithSelection.tsx +11 -2
- package/patternfly-docs/content/extensions/chatbot/examples/UI/CompactSettings.tsx +289 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/TermsOfUseCompact.tsx +136 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +15 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +8 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.tsx +6 -3
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachment.tsx +2 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachmentMenu.tsx +2 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotCompact.tsx +481 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotInDrawer.tsx +2 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedChatbot.tsx +2 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedComparisonChatbot.tsx +62 -57
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Feedback.tsx +2 -0
- package/src/AttachmentEdit/AttachmentEdit.tsx +5 -1
- package/src/Chatbot/Chatbot.scss +7 -0
- package/src/Chatbot/Chatbot.test.tsx +9 -0
- package/src/Chatbot/Chatbot.tsx +4 -1
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +38 -3
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +71 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +23 -2
- package/src/ChatbotFooter/ChatbotFooter.scss +5 -0
- package/src/ChatbotFooter/ChatbotFooter.test.tsx +10 -0
- package/src/ChatbotFooter/ChatbotFooter.tsx +3 -1
- package/src/ChatbotHeader/ChatbotHeader.scss +25 -0
- package/src/ChatbotHeader/ChatbotHeader.tsx +1 -1
- package/src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx +6 -0
- package/src/ChatbotHeader/ChatbotHeaderCloseButton.tsx +12 -6
- package/src/ChatbotHeader/ChatbotHeaderMain.tsx +3 -1
- package/src/ChatbotHeader/ChatbotHeaderMenu.test.tsx +8 -0
- package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +10 -5
- package/src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx +6 -0
- package/src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx +5 -2
- package/src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx +10 -0
- package/src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx +4 -0
- package/src/ChatbotModal/ChatbotModal.scss +15 -4
- package/src/ChatbotModal/ChatbotModal.test.tsx +59 -0
- package/src/ChatbotModal/ChatbotModal.tsx +5 -1
- package/src/ChatbotPopover/ChatbotPopover.scss +9 -5
- package/src/ChatbotPopover/ChatbotPopover.tsx +1 -1
- package/src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.scss +9 -1
- package/src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx +13 -0
- package/src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx +13 -2
- package/src/ChatbotWelcomePrompt/__snapshots__/ChatbotWelcomePrompt.test.tsx.snap +1 -1
- package/src/CodeModal/CodeModal.scss +11 -3
- package/src/CodeModal/CodeModal.test.tsx +24 -0
- package/src/CodeModal/CodeModal.tsx +6 -2
- package/src/FileDetails/FileDetails.tsx +1 -1
- package/src/FileDetails/__snapshots__/FileDetails.test.tsx.snap +1 -1
- package/src/FileDetailsLabel/__snapshots__/FileDetailsLabel.test.tsx.snap +1 -1
- package/src/Message/Message.scss +31 -0
- package/src/Message/Message.test.tsx +83 -0
- package/src/Message/Message.tsx +121 -56
- package/src/Message/MessageInput.tsx +59 -0
- package/src/Message/QuickResponse/QuickResponse.tsx +5 -1
- package/src/Message/QuickStarts/QuickStartTile.tsx +5 -1
- package/src/Message/TextMessage/TextMessage.scss +25 -0
- package/src/Message/UserFeedback/UserFeedback.scss +24 -3
- package/src/Message/UserFeedback/UserFeedback.test.tsx +13 -0
- package/src/Message/UserFeedback/UserFeedback.tsx +4 -2
- package/src/Message/UserFeedback/UserFeedbackComplete.test.tsx +4 -0
- package/src/Message/UserFeedback/UserFeedbackComplete.tsx +10 -2
- package/src/MessageBar/AttachButton.scss +10 -0
- package/src/MessageBar/AttachButton.test.tsx +4 -0
- package/src/MessageBar/AttachButton.tsx +5 -2
- package/src/MessageBar/MessageBar.scss +17 -0
- package/src/MessageBar/MessageBar.test.tsx +13 -0
- package/src/MessageBar/MessageBar.tsx +23 -8
- package/src/MessageBar/MicrophoneButton.scss +10 -0
- package/src/MessageBar/MicrophoneButton.tsx +6 -3
- package/src/MessageBar/SendButton.scss +10 -0
- package/src/MessageBar/SendButton.test.tsx +5 -1
- package/src/MessageBar/SendButton.tsx +5 -2
- package/src/MessageBar/StopButton.scss +10 -0
- package/src/MessageBar/StopButton.test.tsx +5 -1
- package/src/MessageBar/StopButton.tsx +5 -2
- package/src/MessageBox/MessageBox.scss +6 -0
- package/src/MessageBox/MessageBox.test.tsx +45 -1
- package/src/MessageBox/MessageBox.tsx +16 -6
- package/src/PreviewAttachment/PreviewAttachment.tsx +5 -1
- package/src/Settings/Settings.scss +11 -0
- package/src/Settings/SettingsForm.test.tsx +17 -0
- package/src/Settings/SettingsForm.tsx +12 -2
- package/src/SourcesCard/SourcesCard.scss +11 -7
- package/src/SourcesCard/SourcesCard.test.tsx +30 -22
- package/src/SourcesCard/SourcesCard.tsx +56 -13
- package/src/TermsOfUse/TermsOfUse.scss +20 -0
- package/src/TermsOfUse/TermsOfUse.tsx +9 -4
- package/src/tracking/console_tracking_provider.ts +21 -17
- package/src/tracking/posthog_tracking_provider.ts +20 -13
- package/src/tracking/segment_tracking_provider.ts +20 -13
- package/src/tracking/trackingProviderProxy.ts +2 -2
- package/src/tracking/tracking_api.ts +1 -1
- package/src/tracking/tracking_registry.ts +46 -13
- package/src/tracking/tracking_spi.ts +18 -7
- package/src/tracking/umami_tracking_provider.ts +76 -20
- package/src/SourcesCard/__snapshots__/SourcesCard.test.tsx.snap +0 -34
@@ -28,10 +28,14 @@ export interface MessageBarProps extends TextAreaProps {
|
|
28
28
|
className?: string;
|
29
29
|
/** Flag to always to show the send button. By default send button is shown when there is a message in the input field */
|
30
30
|
alwayShowSendButton?: boolean;
|
31
|
+
/** Placeholder for message input */
|
32
|
+
placeholder?: string;
|
31
33
|
/** Flag to disable/enable the Attach button */
|
32
34
|
hasAttachButton?: boolean;
|
33
35
|
/** Flag to enable the Microphone button */
|
34
36
|
hasMicrophoneButton?: boolean;
|
37
|
+
/** Placeholder text when listening */
|
38
|
+
listeningText?: string;
|
35
39
|
/** Flag to enable the Stop button, used for streaming content */
|
36
40
|
hasStopButton?: boolean;
|
37
41
|
/** Callback function for when stop button is clicked */
|
@@ -74,6 +78,7 @@ export interface MessageBarProps extends TextAreaProps {
|
|
74
78
|
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>, value: string | number) => void;
|
75
79
|
/** Display mode of chatbot, if you want to message bar to resize when the display mode changes */
|
76
80
|
displayMode?: ChatbotDisplayMode;
|
81
|
+
isCompact?: boolean;
|
77
82
|
}
|
78
83
|
export declare const MessageBar: React.FunctionComponent<MessageBarProps>;
|
79
84
|
export default MessageBar;
|
@@ -24,7 +24,7 @@ const AttachButton_1 = require("./AttachButton");
|
|
24
24
|
const AttachMenu_1 = __importDefault(require("../AttachMenu"));
|
25
25
|
const StopButton_1 = __importDefault(require("./StopButton"));
|
26
26
|
const MessageBar = (_a) => {
|
27
|
-
var { onSendMessage, className, alwayShowSendButton, hasAttachButton = true, hasMicrophoneButton, handleAttach, attachMenuProps, isSendButtonDisabled, handleStopButton, hasStopButton, buttonProps, onChange, displayMode, value } = _a, props = __rest(_a, ["onSendMessage", "className", "alwayShowSendButton", "hasAttachButton", "hasMicrophoneButton", "handleAttach", "attachMenuProps", "isSendButtonDisabled", "handleStopButton", "hasStopButton", "buttonProps", "onChange", "displayMode", "value"]);
|
27
|
+
var { onSendMessage, className, alwayShowSendButton, placeholder = 'Send a message...', hasAttachButton = true, hasMicrophoneButton, listeningText = 'Listening', handleAttach, attachMenuProps, isSendButtonDisabled, handleStopButton, hasStopButton, buttonProps, onChange, displayMode, value, isCompact = false } = _a, props = __rest(_a, ["onSendMessage", "className", "alwayShowSendButton", "placeholder", "hasAttachButton", "hasMicrophoneButton", "listeningText", "handleAttach", "attachMenuProps", "isSendButtonDisabled", "handleStopButton", "hasStopButton", "buttonProps", "onChange", "displayMode", "value", "isCompact"]);
|
28
28
|
// Text Input
|
29
29
|
// --------------------------------------------------------------------------
|
30
30
|
const [message, setMessage] = react_1.default.useState(value !== null && value !== void 0 ? value : '');
|
@@ -32,11 +32,12 @@ const MessageBar = (_a) => {
|
|
32
32
|
const [hasSentMessage, setHasSentMessage] = react_1.default.useState(false);
|
33
33
|
const textareaRef = react_1.default.useRef(null);
|
34
34
|
const attachButtonRef = react_1.default.useRef(null);
|
35
|
+
const topMargin = '1rem';
|
35
36
|
const setInitialLineHeight = (field) => {
|
36
37
|
field.style.setProperty('line-height', '1rem');
|
37
38
|
const parent = field.parentElement;
|
38
39
|
if (parent) {
|
39
|
-
parent.style.setProperty('margin-top',
|
40
|
+
parent.style.setProperty('margin-top', topMargin);
|
40
41
|
parent.style.setProperty('margin-bottom', `0rem`);
|
41
42
|
parent.style.setProperty('height', 'inherit');
|
42
43
|
const grandparent = parent.parentElement;
|
@@ -58,8 +59,8 @@ const MessageBar = (_a) => {
|
|
58
59
|
parseInt(computed.getPropertyValue('border-bottom-width'));
|
59
60
|
parent.style.setProperty('height', `${height}px`);
|
60
61
|
if (height > 32 || window.innerWidth <= 507) {
|
61
|
-
parent.style.setProperty('margin-bottom',
|
62
|
-
parent.style.setProperty('margin-top',
|
62
|
+
parent.style.setProperty('margin-bottom', topMargin);
|
63
|
+
parent.style.setProperty('margin-top', topMargin);
|
63
64
|
}
|
64
65
|
}
|
65
66
|
};
|
@@ -80,8 +81,8 @@ const MessageBar = (_a) => {
|
|
80
81
|
const handleNewLine = (field) => {
|
81
82
|
const parent = field.parentElement;
|
82
83
|
if (parent) {
|
83
|
-
parent.style.setProperty('margin-bottom',
|
84
|
-
parent.style.setProperty('margin-top',
|
84
|
+
parent.style.setProperty('margin-bottom', topMargin);
|
85
|
+
parent.style.setProperty('margin-top', topMargin);
|
85
86
|
}
|
86
87
|
};
|
87
88
|
react_1.default.useEffect(() => {
|
@@ -176,17 +177,17 @@ const MessageBar = (_a) => {
|
|
176
177
|
const renderButtons = () => {
|
177
178
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
178
179
|
if (hasStopButton && handleStopButton) {
|
179
|
-
return (react_1.default.createElement(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 }, (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.stop) === null || _b === void 0 ? void 0 : _b.props)));
|
180
|
+
return (react_1.default.createElement(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 }, (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.stop) === null || _b === void 0 ? void 0 : _b.props)));
|
180
181
|
}
|
181
182
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
182
|
-
attachMenuProps && (react_1.default.createElement(AttachButton_1.AttachButton, Object.assign({ ref: attachButtonRef, onClick: handleAttachMenuToggle, isDisabled: isListeningMessage, tooltipContent: (_c = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _c === void 0 ? void 0 : _c.tooltipContent }, (_d = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _d === void 0 ? void 0 : _d.props))),
|
183
|
-
!attachMenuProps && hasAttachButton && (react_1.default.createElement(AttachButton_1.AttachButton, Object.assign({ onAttachAccepted: handleAttach, isDisabled: isListeningMessage, tooltipContent: (_e = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _e === void 0 ? void 0 : _e.tooltipContent, inputTestId: (_f = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _f === void 0 ? void 0 : _f.inputTestId }, (_g = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _g === void 0 ? void 0 : _g.props))),
|
184
|
-
hasMicrophoneButton && (react_1.default.createElement(MicrophoneButton_1.default, Object.assign({ isListening: isListeningMessage, onIsListeningChange: setIsListeningMessage, onSpeechRecognition: handleSpeechRecognition, tooltipContent: (_h = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _h === void 0 ? void 0 : _h.tooltipContent, language: (_j = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _j === void 0 ? void 0 : _j.language }, (_k = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _k === void 0 ? void 0 : _k.props))),
|
185
|
-
(alwayShowSendButton || message) && (react_1.default.createElement(SendButton_1.default, Object.assign({ value: message, onClick: () => handleSend(message), isDisabled: isSendButtonDisabled, tooltipContent: (_l = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.send) === null || _l === void 0 ? void 0 : _l.tooltipContent }, (_m = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.send) === null || _m === void 0 ? void 0 : _m.props)))));
|
183
|
+
attachMenuProps && (react_1.default.createElement(AttachButton_1.AttachButton, Object.assign({ ref: attachButtonRef, onClick: handleAttachMenuToggle, isDisabled: isListeningMessage, tooltipContent: (_c = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _c === void 0 ? void 0 : _c.tooltipContent, isCompact: isCompact }, (_d = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _d === void 0 ? void 0 : _d.props))),
|
184
|
+
!attachMenuProps && hasAttachButton && (react_1.default.createElement(AttachButton_1.AttachButton, Object.assign({ onAttachAccepted: handleAttach, isDisabled: isListeningMessage, tooltipContent: (_e = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _e === void 0 ? void 0 : _e.tooltipContent, inputTestId: (_f = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _f === void 0 ? void 0 : _f.inputTestId, isCompact: isCompact }, (_g = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _g === void 0 ? void 0 : _g.props))),
|
185
|
+
hasMicrophoneButton && (react_1.default.createElement(MicrophoneButton_1.default, Object.assign({ isListening: isListeningMessage, onIsListeningChange: setIsListeningMessage, onSpeechRecognition: handleSpeechRecognition, tooltipContent: (_h = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _h === void 0 ? void 0 : _h.tooltipContent, language: (_j = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _j === void 0 ? void 0 : _j.language, isCompact: isCompact }, (_k = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _k === void 0 ? void 0 : _k.props))),
|
186
|
+
(alwayShowSendButton || message) && (react_1.default.createElement(SendButton_1.default, Object.assign({ value: message, onClick: () => handleSend(message), isDisabled: isSendButtonDisabled, tooltipContent: (_l = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.send) === null || _l === void 0 ? void 0 : _l.tooltipContent, isCompact: isCompact }, (_m = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.send) === null || _m === void 0 ? void 0 : _m.props)))));
|
186
187
|
};
|
187
188
|
const messageBarContents = (react_1.default.createElement(react_1.default.Fragment, null,
|
188
|
-
react_1.default.createElement("div", { className:
|
189
|
-
react_1.default.createElement(react_core_1.TextArea, Object.assign({ className: "pf-chatbot__message-textarea", value: message, onChange: handleChange, "aria-label": isListeningMessage ?
|
189
|
+
react_1.default.createElement("div", { className: `pf-chatbot__message-bar-input ${isCompact ? 'pf-m-compact' : ''}` },
|
190
|
+
react_1.default.createElement(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 }, props))),
|
190
191
|
react_1.default.createElement("div", { className: "pf-chatbot__message-bar-actions" }, renderButtons())));
|
191
192
|
if (attachMenuProps) {
|
192
193
|
return (react_1.default.createElement(AttachMenu_1.default, Object.assign({ toggle: (toggleRef) => (react_1.default.createElement("div", { ref: toggleRef, className: `pf-chatbot__message-bar ${className !== null && className !== void 0 ? className : ''}` }, messageBarContents)), filteredItems: attachMenuProps === null || attachMenuProps === void 0 ? void 0 : attachMenuProps.attachMenuItems }, (attachMenuProps && { isOpen: attachMenuProps.isAttachMenuOpen }), { onOpenChange: (isAttachMenuOpen) => {
|
@@ -76,6 +76,12 @@ describe('Message bar', () => {
|
|
76
76
|
expect(spy).toHaveBeenCalledTimes(1);
|
77
77
|
expect(spy).toHaveBeenCalledWith(expect.any(Object), 'A');
|
78
78
|
}));
|
79
|
+
it('can use specified placeholder text', () => __awaiter(void 0, void 0, void 0, function* () {
|
80
|
+
(0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, placeholder: "test placeholder" }));
|
81
|
+
const input = react_2.screen.getByRole('textbox', { name: /test placeholder/i });
|
82
|
+
yield user_event_1.default.type(input, 'Hello world');
|
83
|
+
expect(input).toHaveTextContent('Hello world');
|
84
|
+
}));
|
79
85
|
// Send button
|
80
86
|
// --------------------------------------------------------------------------
|
81
87
|
it('shows send button when text is input', () => __awaiter(void 0, void 0, void 0, function* () {
|
@@ -229,6 +235,13 @@ describe('Message bar', () => {
|
|
229
235
|
yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Microphone button' }));
|
230
236
|
expect(react_2.screen.getByRole('tooltip', { name: 'Not currently listening' })).toBeTruthy();
|
231
237
|
}));
|
238
|
+
it('can customize the listening placeholder', () => __awaiter(void 0, void 0, void 0, function* () {
|
239
|
+
mockSpeechRecognition();
|
240
|
+
(0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasMicrophoneButton: true, listeningText: "I am listening" }));
|
241
|
+
yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Microphone button' }));
|
242
|
+
const input = react_2.screen.getByRole('textbox', { name: /I am listening/i });
|
243
|
+
expect(input).toBeTruthy();
|
244
|
+
}));
|
232
245
|
it('can handle buttonProps props appropriately for microphone', () => __awaiter(void 0, void 0, void 0, function* () {
|
233
246
|
mockSpeechRecognition();
|
234
247
|
(0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasMicrophoneButton: true, buttonProps: { microphone: { props: { 'aria-label': 'Test' } } } }));
|
@@ -18,6 +18,7 @@ export interface MicrophoneButtonProps extends ButtonProps {
|
|
18
18
|
};
|
19
19
|
/** Locale code for language speech recognition is conducted in. This should be in the format 'en-US', a.k.a. the ISO 639-1 code, a dash, and the ISO_3166-1 code. */
|
20
20
|
language?: string;
|
21
|
+
isCompact?: boolean;
|
21
22
|
}
|
22
23
|
export declare const MicrophoneButton: React.FunctionComponent<MicrophoneButtonProps>;
|
23
24
|
export default MicrophoneButton;
|
@@ -24,7 +24,7 @@ const react_core_1 = require("@patternfly/react-core");
|
|
24
24
|
// Import FontAwesome icons
|
25
25
|
const microphone_icon_1 = require("@patternfly/react-icons/dist/esm/icons/microphone-icon");
|
26
26
|
const MicrophoneButton = (_a) => {
|
27
|
-
var { isListening, onIsListeningChange, onSpeechRecognition, className, tooltipProps, tooltipContent = { active: 'Stop listening', inactive: 'Use microphone' }, language = 'en-US' } = _a, props = __rest(_a, ["isListening", "onIsListeningChange", "onSpeechRecognition", "className", "tooltipProps", "tooltipContent", "language"]);
|
27
|
+
var { isListening, onIsListeningChange, onSpeechRecognition, className, tooltipProps, tooltipContent = { active: 'Stop listening', inactive: 'Use microphone' }, language = 'en-US', isCompact } = _a, props = __rest(_a, ["isListening", "onIsListeningChange", "onSpeechRecognition", "className", "tooltipProps", "tooltipContent", "language", "isCompact"]);
|
28
28
|
// Microphone
|
29
29
|
// --------------------------------------------------------------------------
|
30
30
|
const [speechRecognition, setSpeechRecognition] = react_1.default.useState();
|
@@ -64,13 +64,13 @@ const MicrophoneButton = (_a) => {
|
|
64
64
|
};
|
65
65
|
setSpeechRecognition(recognition);
|
66
66
|
}
|
67
|
-
}, [onSpeechRecognition]);
|
67
|
+
}, [onSpeechRecognition, language, onIsListeningChange]);
|
68
68
|
if (!speechRecognition) {
|
69
69
|
return null;
|
70
70
|
}
|
71
71
|
return (react_1.default.createElement(react_core_1.Tooltip, Object.assign({ aria: "none", "aria-live": "polite", id: "pf-chatbot__tooltip--use-microphone", content: isListening ? tooltipContent.active : tooltipContent.inactive, position: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.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 }, tooltipProps),
|
72
|
-
react_1.default.createElement(react_core_1.Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--microphone ${isListening ? 'pf-chatbot__button--microphone--active' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Microphone button', onClick: isListening ? stopListening : startListening, icon: react_1.default.createElement(react_core_1.Icon, { iconSize:
|
73
|
-
react_1.default.createElement(microphone_icon_1.MicrophoneIcon, null)) }, props))));
|
72
|
+
react_1.default.createElement(react_core_1.Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--microphone ${isListening ? 'pf-chatbot__button--microphone--active' : ''} ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Microphone button', onClick: isListening ? stopListening : startListening, icon: react_1.default.createElement(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
|
73
|
+
react_1.default.createElement(microphone_icon_1.MicrophoneIcon, null)), size: isCompact ? 'sm' : undefined }, props))));
|
74
74
|
};
|
75
75
|
exports.MicrophoneButton = MicrophoneButton;
|
76
76
|
exports.default = exports.MicrophoneButton;
|
@@ -9,6 +9,7 @@ export interface SendButtonProps extends ButtonProps {
|
|
9
9
|
tooltipProps?: Omit<TooltipProps, 'content'>;
|
10
10
|
/** English text "Send" used in the tooltip */
|
11
11
|
tooltipContent?: string;
|
12
|
+
isCompact?: boolean;
|
12
13
|
}
|
13
14
|
export declare const SendButton: React.FunctionComponent<SendButtonProps>;
|
14
15
|
export default SendButton;
|
@@ -23,12 +23,12 @@ const react_1 = __importDefault(require("react"));
|
|
23
23
|
const react_core_1 = require("@patternfly/react-core");
|
24
24
|
const paper_plane_icon_1 = require("@patternfly/react-icons/dist/esm/icons/paper-plane-icon");
|
25
25
|
const SendButton = (_a) => {
|
26
|
-
var { className, onClick, tooltipProps, tooltipContent = 'Send' } = _a, props = __rest(_a, ["className", "onClick", "tooltipProps", "tooltipContent"]);
|
26
|
+
var { className, onClick, tooltipProps, tooltipContent = 'Send', isCompact } = _a, props = __rest(_a, ["className", "onClick", "tooltipProps", "tooltipContent", "isCompact"]);
|
27
27
|
return (react_1.default.createElement(react_core_1.Tooltip, Object.assign({ id: "pf-chatbot__tooltip--send", content: tooltipContent, position: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.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,
|
28
28
|
// prevents VO announcements of both aria label and tooltip
|
29
29
|
aria: "none" }, tooltipProps),
|
30
|
-
react_1.default.createElement(react_core_1.Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--send ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Send button', onClick: onClick, icon: react_1.default.createElement(react_core_1.Icon, { iconSize:
|
31
|
-
react_1.default.createElement(paper_plane_icon_1.PaperPlaneIcon, null)) }, props))));
|
30
|
+
react_1.default.createElement(react_core_1.Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--send ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Send button', onClick: onClick, icon: react_1.default.createElement(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
|
31
|
+
react_1.default.createElement(paper_plane_icon_1.PaperPlaneIcon, null)), size: isCompact ? 'sm' : undefined }, props))));
|
32
32
|
};
|
33
33
|
exports.SendButton = SendButton;
|
34
34
|
exports.default = exports.SendButton;
|
@@ -51,4 +51,8 @@ describe('Send button', () => {
|
|
51
51
|
yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send button' }));
|
52
52
|
expect(react_2.screen.getByRole('tooltip', { name: 'Send' })).toHaveAttribute('id', 'test');
|
53
53
|
}));
|
54
|
+
it('should handle isCompact', () => {
|
55
|
+
renderSend({ 'data-testid': 'button', isCompact: true });
|
56
|
+
expect(react_2.screen.getByTestId('button')).toHaveClass('pf-m-compact');
|
57
|
+
});
|
54
58
|
});
|
@@ -9,6 +9,7 @@ export interface StopButtonProps extends ButtonProps {
|
|
9
9
|
tooltipProps?: Omit<TooltipProps, 'content'>;
|
10
10
|
/** English text "Stop" used in the tooltip */
|
11
11
|
tooltipContent?: string;
|
12
|
+
isCompact?: boolean;
|
12
13
|
}
|
13
14
|
export declare const StopButton: React.FunctionComponent<StopButtonProps>;
|
14
15
|
export default StopButton;
|
@@ -22,13 +22,13 @@ const react_1 = __importDefault(require("react"));
|
|
22
22
|
// Import PatternFly components
|
23
23
|
const react_core_1 = require("@patternfly/react-core");
|
24
24
|
const StopButton = (_a) => {
|
25
|
-
var { className, onClick, tooltipProps, tooltipContent = 'Stop' } = _a, props = __rest(_a, ["className", "onClick", "tooltipProps", "tooltipContent"]);
|
25
|
+
var { className, onClick, tooltipProps, tooltipContent = 'Stop', isCompact } = _a, props = __rest(_a, ["className", "onClick", "tooltipProps", "tooltipContent", "isCompact"]);
|
26
26
|
return (react_1.default.createElement(react_core_1.Tooltip, Object.assign({ id: "pf-chatbot__tooltip--stop", content: tooltipContent, position: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.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
28
|
aria: "none" }, tooltipProps),
|
29
|
-
react_1.default.createElement(react_core_1.Button, Object.assign({ className: `pf-chatbot__button--stop ${className !== null && className !== void 0 ? className : ''}`, variant: "link", "aria-label": props['aria-label'] || 'Stop button', onClick: onClick, icon: react_1.default.createElement(react_core_1.Icon, { iconSize:
|
29
|
+
react_1.default.createElement(react_core_1.Button, Object.assign({ className: `pf-chatbot__button--stop ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, variant: "link", "aria-label": props['aria-label'] || 'Stop button', onClick: onClick, icon: react_1.default.createElement(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
|
30
30
|
react_1.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
31
|
-
react_1.default.createElement("path", { d: "M0.5 3C0.5 1.62109 1.62109 0.5 3 0.5H13C14.3789 0.5 15.5 1.62109 15.5 3V13C15.5 14.3789 14.3789 15.5 13 15.5H3C1.62109 15.5 0.5 14.3789 0.5 13V3Z", fill: "currentColor" }))) }, props))));
|
31
|
+
react_1.default.createElement("path", { d: "M0.5 3C0.5 1.62109 1.62109 0.5 3 0.5H13C14.3789 0.5 15.5 1.62109 15.5 3V13C15.5 14.3789 14.3789 15.5 13 15.5H3C1.62109 15.5 0.5 14.3789 0.5 13V3Z", fill: "currentColor" }))), size: isCompact ? 'sm' : undefined }, props))));
|
32
32
|
};
|
33
33
|
exports.StopButton = StopButton;
|
34
34
|
exports.default = exports.StopButton;
|
@@ -51,4 +51,8 @@ describe('Stop button', () => {
|
|
51
51
|
yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop button' }));
|
52
52
|
expect(react_2.screen.getByRole('tooltip', { name: 'Stop' })).toHaveAttribute('id', 'test');
|
53
53
|
}));
|
54
|
+
it('should handle isCompact', () => {
|
55
|
+
renderStop({ 'data-testid': 'button', isCompact: true });
|
56
|
+
expect(react_2.screen.getByTestId('button')).toHaveClass('pf-m-compact');
|
57
|
+
});
|
54
58
|
});
|
@@ -12,6 +12,10 @@ export interface MessageBoxProps extends React.HTMLProps<HTMLDivElement> {
|
|
12
12
|
innerRef?: React.Ref<HTMLDivElement>;
|
13
13
|
/** Modifier that controls how content in MessageBox is positioned within the container */
|
14
14
|
position?: 'top' | 'bottom';
|
15
|
+
/** Click handler for additional logic for when scroll to top jump button is clicked */
|
16
|
+
onScrollToTopClick?: () => void;
|
17
|
+
/** Click handler for additional logic for when scroll to bottom jump button is clicked */
|
18
|
+
onScrollToBottomClick?: () => void;
|
15
19
|
}
|
16
20
|
export declare const MessageBox: React.ForwardRefExoticComponent<Omit<MessageBoxProps, "ref"> & React.RefAttributes<any>>;
|
17
21
|
export default MessageBox;
|
@@ -1,4 +1,15 @@
|
|
1
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
|
+
};
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
15
|
};
|
@@ -9,7 +20,8 @@ exports.MessageBox = void 0;
|
|
9
20
|
// ============================================================================
|
10
21
|
const react_1 = __importDefault(require("react"));
|
11
22
|
const JumpButton_1 = __importDefault(require("./JumpButton"));
|
12
|
-
const MessageBoxBase = (
|
23
|
+
const MessageBoxBase = (_a) => {
|
24
|
+
var { announcement, ariaLabel = 'Scrollable message log', children, innerRef, className, position = 'top', onScrollToTopClick, onScrollToBottomClick } = _a, props = __rest(_a, ["announcement", "ariaLabel", "children", "innerRef", "className", "position", "onScrollToTopClick", "onScrollToBottomClick"]);
|
13
25
|
const [atTop, setAtTop] = react_1.default.useState(false);
|
14
26
|
const [atBottom, setAtBottom] = react_1.default.useState(true);
|
15
27
|
const [isOverflowing, setIsOverflowing] = react_1.default.useState(false);
|
@@ -29,26 +41,28 @@ const MessageBoxBase = ({ announcement, ariaLabel = 'Scrollable message log', ch
|
|
29
41
|
setAtTop(scrollTop === 0);
|
30
42
|
setAtBottom(Math.round(scrollTop) + Math.round(clientHeight) >= Math.round(scrollHeight) - 1); // rounding means it could be within a pixel of the bottom
|
31
43
|
}
|
32
|
-
}, []);
|
44
|
+
}, [messageBoxRef]);
|
33
45
|
const checkOverflow = react_1.default.useCallback(() => {
|
34
46
|
const element = messageBoxRef.current;
|
35
47
|
if (element) {
|
36
48
|
const { scrollHeight, clientHeight } = element;
|
37
49
|
setIsOverflowing(scrollHeight >= clientHeight);
|
38
50
|
}
|
39
|
-
}, []);
|
51
|
+
}, [messageBoxRef]);
|
40
52
|
const scrollToTop = react_1.default.useCallback(() => {
|
41
53
|
const element = messageBoxRef.current;
|
42
54
|
if (element) {
|
43
55
|
element.scrollTo({ top: 0, behavior: 'smooth' });
|
44
56
|
}
|
45
|
-
|
57
|
+
onScrollToTopClick && onScrollToTopClick();
|
58
|
+
}, [messageBoxRef]);
|
46
59
|
const scrollToBottom = react_1.default.useCallback(() => {
|
47
60
|
const element = messageBoxRef.current;
|
48
61
|
if (element) {
|
49
62
|
element.scrollTo({ top: element.scrollHeight, behavior: 'smooth' });
|
50
63
|
}
|
51
|
-
|
64
|
+
onScrollToBottomClick && onScrollToBottomClick();
|
65
|
+
}, [messageBoxRef]);
|
52
66
|
// Detect scroll position
|
53
67
|
react_1.default.useEffect(() => {
|
54
68
|
const element = messageBoxRef.current;
|
@@ -62,10 +76,10 @@ const MessageBoxBase = ({ announcement, ariaLabel = 'Scrollable message log', ch
|
|
62
76
|
element.removeEventListener('scroll', handleScroll);
|
63
77
|
};
|
64
78
|
}
|
65
|
-
}, [checkOverflow, handleScroll]);
|
79
|
+
}, [checkOverflow, handleScroll, messageBoxRef]);
|
66
80
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
67
81
|
react_1.default.createElement(JumpButton_1.default, { position: "top", isHidden: isOverflowing && atTop, onClick: scrollToTop }),
|
68
|
-
react_1.default.createElement("div", { role: "region", tabIndex: 0, "aria-label": ariaLabel, className: `pf-chatbot__messagebox ${position === 'bottom' && 'pf-chatbot__messagebox--bottom'} ${className !== null && className !== void 0 ? className : ''}`, ref: innerRef !== null && innerRef !== void 0 ? innerRef : messageBoxRef },
|
82
|
+
react_1.default.createElement("div", Object.assign({ role: "region", tabIndex: 0, "aria-label": ariaLabel, className: `pf-chatbot__messagebox ${position === 'bottom' && 'pf-chatbot__messagebox--bottom'} ${className !== null && className !== void 0 ? className : ''}`, ref: innerRef !== null && innerRef !== void 0 ? innerRef : messageBoxRef }, props),
|
69
83
|
children,
|
70
84
|
react_1.default.createElement("div", { className: "pf-chatbot__messagebox-announcement", "aria-live": "polite" }, announcement)),
|
71
85
|
react_1.default.createElement(JumpButton_1.default, { position: "bottom", isHidden: isOverflowing && atBottom, onClick: scrollToBottom })));
|
@@ -1,4 +1,13 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
13
|
};
|
@@ -6,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
15
|
const react_1 = __importDefault(require("react"));
|
7
16
|
const react_2 = require("@testing-library/react");
|
8
17
|
const MessageBox_1 = require("./MessageBox");
|
18
|
+
const user_event_1 = __importDefault(require("@testing-library/user-event"));
|
9
19
|
describe('MessageBox', () => {
|
10
20
|
it('should render Message box', () => {
|
11
21
|
(0, react_2.render)(react_1.default.createElement(MessageBox_1.MessageBox, null,
|
@@ -19,4 +29,37 @@ describe('MessageBox', () => {
|
|
19
29
|
expect(ref.current).not.toBeNull();
|
20
30
|
expect(ref.current).toBeInstanceOf(HTMLDivElement);
|
21
31
|
});
|
32
|
+
it('should call onScrollToBottomClick when scroll to top button is clicked', () => __awaiter(void 0, void 0, void 0, function* () {
|
33
|
+
const spy = jest.fn();
|
34
|
+
(0, react_2.render)(react_1.default.createElement(MessageBox_1.MessageBox, { onScrollToBottomClick: spy },
|
35
|
+
react_1.default.createElement("div", null, "Test message content")));
|
36
|
+
// this forces button to show
|
37
|
+
const region = react_2.screen.getByRole('region');
|
38
|
+
Object.defineProperty(region, 'scrollHeight', { configurable: true, value: 1000 });
|
39
|
+
Object.defineProperty(region, 'clientHeight', { configurable: true, value: 500 });
|
40
|
+
Object.defineProperty(region, 'scrollTop', { configurable: true, value: 0 });
|
41
|
+
region.dispatchEvent(new Event('scroll'));
|
42
|
+
yield (0, react_2.waitFor)(() => {
|
43
|
+
user_event_1.default.click(react_2.screen.getByRole('button', { name: /Jump bottom button/i }));
|
44
|
+
expect(spy).toHaveBeenCalled();
|
45
|
+
});
|
46
|
+
}));
|
47
|
+
it('should call onScrollToTopClick when scroll to top button is clicked', () => __awaiter(void 0, void 0, void 0, function* () {
|
48
|
+
const spy = jest.fn();
|
49
|
+
(0, react_2.render)(react_1.default.createElement(MessageBox_1.MessageBox, { onScrollToTopClick: spy },
|
50
|
+
react_1.default.createElement("div", null, "Test message content")));
|
51
|
+
// this forces button to show
|
52
|
+
const region = react_2.screen.getByRole('region');
|
53
|
+
Object.defineProperty(region, 'scrollHeight', { configurable: true, value: 1000 });
|
54
|
+
Object.defineProperty(region, 'clientHeight', { configurable: true, value: 500 });
|
55
|
+
Object.defineProperty(region, 'scrollTop', {
|
56
|
+
configurable: true,
|
57
|
+
value: 500
|
58
|
+
});
|
59
|
+
region.dispatchEvent(new Event('scroll'));
|
60
|
+
yield (0, react_2.waitFor)(() => {
|
61
|
+
user_event_1.default.click(react_2.screen.getByRole('button', { name: /Jump top button/i }));
|
62
|
+
expect(spy).toHaveBeenCalled();
|
63
|
+
});
|
64
|
+
}));
|
22
65
|
});
|
@@ -17,6 +17,8 @@ export interface PreviewAttachmentProps {
|
|
17
17
|
title?: string;
|
18
18
|
/** Display mode for the Chatbot parent; this influences the styles applied */
|
19
19
|
displayMode?: ChatbotDisplayMode;
|
20
|
+
/** Sets modal to compact styling. */
|
21
|
+
isCompact?: boolean;
|
20
22
|
}
|
21
23
|
export declare const PreviewAttachment: React.FunctionComponent<PreviewAttachmentProps>;
|
22
24
|
export default PreviewAttachment;
|
@@ -10,7 +10,7 @@ exports.PreviewAttachment = void 0;
|
|
10
10
|
const react_1 = __importDefault(require("react"));
|
11
11
|
const CodeModal_1 = __importDefault(require("../CodeModal"));
|
12
12
|
const Chatbot_1 = require("../Chatbot");
|
13
|
-
const PreviewAttachment = ({ fileName, code, handleModalToggle, isModalOpen, onDismiss = undefined, onEdit, title = 'Preview attachment', displayMode = Chatbot_1.ChatbotDisplayMode.default }) => {
|
13
|
+
const PreviewAttachment = ({ fileName, code, handleModalToggle, isModalOpen, onDismiss = undefined, onEdit, title = 'Preview attachment', displayMode = Chatbot_1.ChatbotDisplayMode.default, isCompact }) => {
|
14
14
|
const handleEdit = (_event) => {
|
15
15
|
handleModalToggle(_event);
|
16
16
|
onEdit(_event);
|
@@ -19,7 +19,7 @@ const PreviewAttachment = ({ fileName, code, handleModalToggle, isModalOpen, onD
|
|
19
19
|
handleModalToggle(_event);
|
20
20
|
onDismiss && onDismiss(_event);
|
21
21
|
};
|
22
|
-
return (react_1.default.createElement(CodeModal_1.default, { codeEditorControlClassName: "pf-chatbot__code-modal--controls", code: code, fileName: fileName, handleModalToggle: handleModalToggle, isCopyEnabled: true, isLineNumbersVisible: false, isModalOpen: isModalOpen, onPrimaryAction: handleEdit, onSecondaryAction: handleDismiss, primaryActionBtn: "Edit", secondaryActionBtn: "Dismiss", title: title, isReadOnly: true, displayMode: displayMode }));
|
22
|
+
return (react_1.default.createElement(CodeModal_1.default, { codeEditorControlClassName: "pf-chatbot__code-modal--controls", code: code, fileName: fileName, handleModalToggle: handleModalToggle, isCopyEnabled: true, isLineNumbersVisible: false, isModalOpen: isModalOpen, onPrimaryAction: handleEdit, onSecondaryAction: handleDismiss, primaryActionBtn: "Edit", secondaryActionBtn: "Dismiss", title: title, isReadOnly: true, displayMode: displayMode, isCompact: isCompact }));
|
23
23
|
};
|
24
24
|
exports.PreviewAttachment = PreviewAttachment;
|
25
25
|
exports.default = exports.PreviewAttachment;
|
@@ -8,6 +8,8 @@ export interface SettingsFormProps {
|
|
8
8
|
label: string;
|
9
9
|
field: React.ReactElement;
|
10
10
|
}[];
|
11
|
+
/** Sets form to compact styling. */
|
12
|
+
isCompact?: boolean;
|
11
13
|
}
|
12
14
|
export declare const SettingsForm: React.FunctionComponent<SettingsFormProps>;
|
13
15
|
export default SettingsForm;
|
@@ -17,8 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.SettingsForm = void 0;
|
18
18
|
const react_1 = __importDefault(require("react"));
|
19
19
|
const SettingsForm = (_a) => {
|
20
|
-
var { className, fields = [] } = _a, props = __rest(_a, ["className", "fields"]);
|
21
|
-
return (react_1.default.createElement("div", Object.assign({ className: `pf-chatbot__settings-form-container ${className}` }, props),
|
20
|
+
var { className, fields = [], isCompact } = _a, props = __rest(_a, ["className", "fields", "isCompact"]);
|
21
|
+
return (react_1.default.createElement("div", Object.assign({ className: `pf-chatbot__settings-form-container ${isCompact ? 'pf-m-compact' : ''} ${className ? ` ${className}` : ''}` }, props),
|
22
22
|
react_1.default.createElement("form", { className: "pf-chatbot__settings-form" }, fields.map((field) => (react_1.default.createElement("div", { className: "pf-chatbot__settings-form-row", key: field.label },
|
23
23
|
react_1.default.createElement("label", { className: "pf-chatbot__settings-label", htmlFor: field.id }, field.label),
|
24
24
|
field.field))))));
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import '@testing-library/jest-dom';
|
@@ -7,6 +7,7 @@ const react_1 = __importDefault(require("react"));
|
|
7
7
|
const react_core_1 = require("@patternfly/react-core");
|
8
8
|
const react_2 = require("@testing-library/react");
|
9
9
|
const SettingsForm_1 = require("./SettingsForm");
|
10
|
+
require("@testing-library/jest-dom");
|
10
11
|
describe('SettingsForm', () => {
|
11
12
|
it('should render settingsForm with custom classname', () => {
|
12
13
|
const { container } = (0, react_2.render)(react_1.default.createElement(SettingsForm_1.SettingsForm, { className: "custom-settings" }));
|
@@ -23,4 +24,15 @@ describe('SettingsForm', () => {
|
|
23
24
|
(0, react_2.render)(react_1.default.createElement(SettingsForm_1.SettingsForm, { fields: fields }));
|
24
25
|
expect(react_2.screen.getByRole('button', { name: 'Archive chat' })).toBeTruthy();
|
25
26
|
});
|
27
|
+
it('should render settingsForm with isCompact', () => {
|
28
|
+
const fields = [
|
29
|
+
{
|
30
|
+
id: 'archived-chat',
|
31
|
+
label: 'Archive chat',
|
32
|
+
field: (react_1.default.createElement(react_core_1.Button, { id: "archived-chat", variant: "secondary" }, "Archive chat"))
|
33
|
+
}
|
34
|
+
];
|
35
|
+
(0, react_2.render)(react_1.default.createElement(SettingsForm_1.SettingsForm, { "data-testid": "settings-form", fields: fields, isCompact: true }));
|
36
|
+
expect(react_2.screen.getByTestId('settings-form')).toHaveClass('pf-m-compact');
|
37
|
+
});
|
26
38
|
});
|
@@ -5,7 +5,7 @@ export interface SourcesCardProps extends CardProps {
|
|
5
5
|
className?: string;
|
6
6
|
/** Flag indicating if the pagination is disabled. */
|
7
7
|
isDisabled?: boolean;
|
8
|
-
/** Label for the English word "of"
|
8
|
+
/** @deprecated ofWord has been deprecated. Label for the English word "of." */
|
9
9
|
ofWord?: string;
|
10
10
|
/** Accessible label for the pagination component. */
|
11
11
|
paginationAriaLabel?: string;
|
@@ -14,6 +14,8 @@ export interface SourcesCardProps extends CardProps {
|
|
14
14
|
title?: string;
|
15
15
|
link: string;
|
16
16
|
body?: React.ReactNode | string;
|
17
|
+
isExternal?: boolean;
|
18
|
+
hasShowMore?: boolean;
|
17
19
|
}[];
|
18
20
|
/** Label for the English word "source" */
|
19
21
|
sourceWord?: string;
|
@@ -29,6 +31,10 @@ export interface SourcesCardProps extends CardProps {
|
|
29
31
|
onPreviousClick?: (event: React.SyntheticEvent<HTMLButtonElement>, page: number) => void;
|
30
32
|
/** Function called when page is changed. */
|
31
33
|
onSetPage?: (event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => void;
|
34
|
+
/** Label for English words "show more" */
|
35
|
+
showMoreWords?: string;
|
36
|
+
/** Label for English words "show less" */
|
37
|
+
showLessWords?: string;
|
32
38
|
}
|
33
39
|
declare const SourcesCard: React.FunctionComponent<SourcesCardProps>;
|
34
40
|
export default SourcesCard;
|
@@ -20,9 +20,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
const react_1 = __importDefault(require("react"));
|
21
21
|
// Import PatternFly components
|
22
22
|
const react_core_1 = require("@patternfly/react-core");
|
23
|
+
const react_icons_1 = require("@patternfly/react-icons");
|
23
24
|
const SourcesCard = (_a) => {
|
24
|
-
var { className, isDisabled,
|
25
|
+
var { className, isDisabled, paginationAriaLabel = 'Pagination', sources, sourceWord = 'source', sourceWordPlural = 'sources', toNextPageAriaLabel = 'Go to next page', toPreviousPageAriaLabel = 'Go to previous page', onNextClick, onPreviousClick, onSetPage, showMoreWords = 'show more', showLessWords = 'show less', isCompact } = _a, props = __rest(_a, ["className", "isDisabled", "paginationAriaLabel", "sources", "sourceWord", "sourceWordPlural", "toNextPageAriaLabel", "toPreviousPageAriaLabel", "onNextClick", "onPreviousClick", "onSetPage", "showMoreWords", "showLessWords", "isCompact"]);
|
25
26
|
const [page, setPage] = react_1.default.useState(1);
|
27
|
+
const [isExpanded, setIsExpanded] = react_1.default.useState(false);
|
28
|
+
const onToggle = (_event, isExpanded) => {
|
29
|
+
setIsExpanded(isExpanded);
|
30
|
+
};
|
26
31
|
const handleNewPage = (_evt, newPage) => {
|
27
32
|
setPage(newPage);
|
28
33
|
onSetPage && onSetPage(_evt, newPage);
|
@@ -35,10 +40,13 @@ const SourcesCard = (_a) => {
|
|
35
40
|
};
|
36
41
|
return (react_1.default.createElement("div", { className: "pf-chatbot__source" },
|
37
42
|
react_1.default.createElement("span", null, (0, react_core_1.pluralize)(sources.length, sourceWord, sourceWordPlural)),
|
38
|
-
react_1.default.createElement(react_core_1.Card, Object.assign({ className: "pf-chatbot__sources-card" }, props),
|
43
|
+
react_1.default.createElement(react_core_1.Card, Object.assign({ isCompact: isCompact, className: "pf-chatbot__sources-card" }, props),
|
39
44
|
react_1.default.createElement(react_core_1.CardTitle, { className: "pf-chatbot__sources-card-title" },
|
40
|
-
react_1.default.createElement("a",
|
41
|
-
sources[page - 1].body && (react_1.default.createElement(react_core_1.CardBody, { className: `pf-chatbot__sources-card-body
|
45
|
+
react_1.default.createElement(react_core_1.Button, { component: "a", variant: react_core_1.ButtonVariant.link, href: sources[page - 1].link, icon: sources[page - 1].isExternal ? react_1.default.createElement(react_icons_1.ExternalLinkSquareAltIcon, null) : undefined, iconPosition: "end", isInline: true, rel: sources[page - 1].isExternal ? 'noreferrer' : undefined, target: sources[page - 1].isExternal ? '_blank' : undefined }, renderTitle(sources[page - 1].title))),
|
46
|
+
sources[page - 1].body && (react_1.default.createElement(react_core_1.CardBody, { className: `pf-chatbot__sources-card-body` }, sources[page - 1].hasShowMore ? (
|
47
|
+
// prevents extra VO announcements of button text - parent Message has aria-live
|
48
|
+
react_1.default.createElement("div", { "aria-live": "off" },
|
49
|
+
react_1.default.createElement(react_core_1.ExpandableSection, { variant: react_core_1.ExpandableSectionVariant.truncate, toggleText: isExpanded ? showLessWords : showMoreWords, onToggle: onToggle, isExpanded: isExpanded, truncateMaxLines: 2 }, sources[page - 1].body))) : (react_1.default.createElement("div", { className: "pf-chatbot__sources-card-body-text" }, sources[page - 1].body)))),
|
42
50
|
sources.length > 1 && (react_1.default.createElement(react_core_1.CardFooter, { className: "pf-chatbot__sources-card-footer-container" },
|
43
51
|
react_1.default.createElement("div", { className: "pf-chatbot__sources-card-footer" },
|
44
52
|
react_1.default.createElement("nav", { className: `pf-chatbot__sources-card-footer-buttons ${className}`, "aria-label": paginationAriaLabel },
|
@@ -50,6 +58,10 @@ const SourcesCard = (_a) => {
|
|
50
58
|
react_1.default.createElement(react_core_1.Icon, { iconSize: "lg" },
|
51
59
|
react_1.default.createElement("svg", { className: "pf-v6-svg", viewBox: "0 0 280 500", fill: "currentColor", "aria-hidden": "true", role: "img", width: "1em", height: "1em" },
|
52
60
|
react_1.default.createElement("path", { d: "M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z" })))),
|
61
|
+
react_1.default.createElement("span", { "aria-hidden": "true" },
|
62
|
+
page,
|
63
|
+
"/",
|
64
|
+
sources.length),
|
53
65
|
react_1.default.createElement(react_core_1.Button, { variant: react_core_1.ButtonVariant.plain, isDisabled: isDisabled || page === sources.length, "aria-label": toNextPageAriaLabel, "data-action": "next", onClick: (event) => {
|
54
66
|
const newPage = page + 1 <= sources.length ? page + 1 : sources.length;
|
55
67
|
onNextClick && onNextClick(event, newPage);
|
@@ -57,12 +69,6 @@ const SourcesCard = (_a) => {
|
|
57
69
|
} },
|
58
70
|
react_1.default.createElement(react_core_1.Icon, { isInline: true, iconSize: "lg" },
|
59
71
|
react_1.default.createElement("svg", { className: "pf-v6-svg", viewBox: "0 0 180 500", fill: "currentColor", "aria-hidden": "true", role: "img", width: "1em", height: "1em" },
|
60
|
-
react_1.default.createElement("path", { d: "M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z" })))))
|
61
|
-
react_1.default.createElement("span", { "aria-hidden": "true" },
|
62
|
-
page,
|
63
|
-
" ",
|
64
|
-
ofWord,
|
65
|
-
" ",
|
66
|
-
sources.length)))))));
|
72
|
+
react_1.default.createElement("path", { d: "M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z" })))))))))));
|
67
73
|
};
|
68
74
|
exports.default = SourcesCard;
|