@patternfly/chatbot 6.3.0-prerelease.1 → 6.3.0-prerelease.11
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 +2 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +3 -3
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +4 -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/CodeBlockMessage/CodeBlockMessage.js +1 -1
- package/dist/cjs/Message/Message.d.ts +2 -0
- package/dist/cjs/Message/Message.js +6 -6
- package/dist/cjs/Message/Message.test.js +15 -3
- 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 +11 -7
- package/dist/cjs/MessageBar/MessageBar.d.ts +5 -0
- package/dist/cjs/MessageBar/MessageBar.js +14 -13
- package/dist/cjs/MessageBar/MessageBar.test.js +41 -28
- package/dist/cjs/MessageBar/MicrophoneButton.d.ts +1 -0
- package/dist/cjs/MessageBar/MicrophoneButton.js +3 -3
- package/dist/cjs/MessageBar/SendButton.d.ts +1 -0
- package/dist/cjs/MessageBar/SendButton.js +3 -3
- package/dist/cjs/MessageBar/SendButton.test.js +9 -5
- package/dist/cjs/MessageBar/StopButton.d.ts +1 -0
- package/dist/cjs/MessageBar/StopButton.js +3 -3
- package/dist/cjs/MessageBar/StopButton.test.js +9 -5
- package/dist/cjs/MessageBox/JumpButton.js +1 -1
- package/dist/cjs/MessageBox/JumpButton.test.js +4 -4
- package/dist/cjs/MessageBox/MessageBox.d.ts +4 -0
- package/dist/cjs/MessageBox/MessageBox.js +16 -2
- 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.js +2 -2
- package/dist/cjs/TermsOfUse/TermsOfUse.d.ts +2 -0
- package/dist/cjs/TermsOfUse/TermsOfUse.js +5 -5
- package/dist/css/main.css +218 -15
- 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 +2 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +3 -3
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +4 -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/CodeBlockMessage/CodeBlockMessage.js +1 -1
- package/dist/esm/Message/Message.d.ts +2 -0
- package/dist/esm/Message/Message.js +6 -6
- package/dist/esm/Message/Message.test.js +15 -3
- 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 +11 -7
- package/dist/esm/MessageBar/MessageBar.d.ts +5 -0
- package/dist/esm/MessageBar/MessageBar.js +14 -13
- package/dist/esm/MessageBar/MessageBar.test.js +41 -28
- package/dist/esm/MessageBar/MicrophoneButton.d.ts +1 -0
- package/dist/esm/MessageBar/MicrophoneButton.js +3 -3
- package/dist/esm/MessageBar/SendButton.d.ts +1 -0
- package/dist/esm/MessageBar/SendButton.js +3 -3
- package/dist/esm/MessageBar/SendButton.test.js +9 -5
- package/dist/esm/MessageBar/StopButton.d.ts +1 -0
- package/dist/esm/MessageBar/StopButton.js +3 -3
- package/dist/esm/MessageBar/StopButton.test.js +9 -5
- package/dist/esm/MessageBox/JumpButton.js +1 -1
- package/dist/esm/MessageBox/JumpButton.test.js +4 -4
- package/dist/esm/MessageBox/MessageBox.d.ts +4 -0
- package/dist/esm/MessageBox/MessageBox.js +16 -2
- 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.js +2 -2
- package/dist/esm/TermsOfUse/TermsOfUse.d.ts +2 -0
- package/dist/esm/TermsOfUse/TermsOfUse.js +5 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachmentEdit.tsx +10 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithFeedback.tsx +33 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx +24 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickStart.tsx +11 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +21 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/PreviewAttachment.tsx +10 -1
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +9 -0
- 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 +14 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +8 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotCompact.tsx +481 -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 +18 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +9 -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/CodeBlockMessage/CodeBlockMessage.tsx +1 -1
- package/src/Message/Message.scss +27 -0
- package/src/Message/Message.test.tsx +24 -3
- package/src/Message/Message.tsx +10 -3
- 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 +11 -7
- package/src/MessageBar/AttachButton.tsx +6 -3
- package/src/MessageBar/MessageBar.scss +17 -0
- package/src/MessageBar/MessageBar.test.tsx +41 -28
- package/src/MessageBar/MessageBar.tsx +23 -8
- package/src/MessageBar/MicrophoneButton.scss +10 -0
- package/src/MessageBar/MicrophoneButton.tsx +7 -3
- package/src/MessageBar/SendButton.scss +10 -0
- package/src/MessageBar/SendButton.test.tsx +10 -6
- package/src/MessageBar/SendButton.tsx +6 -3
- package/src/MessageBar/StopButton.scss +10 -0
- package/src/MessageBar/StopButton.test.tsx +10 -6
- package/src/MessageBar/StopButton.tsx +6 -3
- package/src/MessageBox/JumpButton.test.tsx +4 -4
- package/src/MessageBox/JumpButton.tsx +1 -1
- package/src/MessageBox/MessageBox.scss +6 -0
- package/src/MessageBox/MessageBox.test.tsx +45 -1
- package/src/MessageBox/MessageBox.tsx +11 -1
- 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 +8 -0
- package/src/SourcesCard/SourcesCard.tsx +2 -1
- package/src/TermsOfUse/TermsOfUse.scss +20 -0
- package/src/TermsOfUse/TermsOfUse.tsx +9 -4
@@ -0,0 +1,481 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
|
3
|
+
import { Bullseye, Brand, DropdownList, DropdownItem, DropdownGroup, SkipToContent } from '@patternfly/react-core';
|
4
|
+
|
5
|
+
import ChatbotToggle from '@patternfly/chatbot/dist/dynamic/ChatbotToggle';
|
6
|
+
import Chatbot, { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot';
|
7
|
+
import ChatbotContent from '@patternfly/chatbot/dist/dynamic/ChatbotContent';
|
8
|
+
import ChatbotWelcomePrompt from '@patternfly/chatbot/dist/dynamic/ChatbotWelcomePrompt';
|
9
|
+
import ChatbotFooter, { ChatbotFootnote } from '@patternfly/chatbot/dist/dynamic/ChatbotFooter';
|
10
|
+
import MessageBar from '@patternfly/chatbot/dist/dynamic/MessageBar';
|
11
|
+
import MessageBox from '@patternfly/chatbot/dist/dynamic/MessageBox';
|
12
|
+
import Message, { MessageProps } from '@patternfly/chatbot/dist/dynamic/Message';
|
13
|
+
import ChatbotConversationHistoryNav, {
|
14
|
+
Conversation
|
15
|
+
} from '@patternfly/chatbot/dist/dynamic/ChatbotConversationHistoryNav';
|
16
|
+
import ChatbotHeader, {
|
17
|
+
ChatbotHeaderMenu,
|
18
|
+
ChatbotHeaderMain,
|
19
|
+
ChatbotHeaderTitle,
|
20
|
+
ChatbotHeaderActions,
|
21
|
+
ChatbotHeaderSelectorDropdown,
|
22
|
+
ChatbotHeaderOptionsDropdown
|
23
|
+
} from '@patternfly/chatbot/dist/dynamic/ChatbotHeader';
|
24
|
+
|
25
|
+
import ExpandIcon from '@patternfly/react-icons/dist/esm/icons/expand-icon';
|
26
|
+
import OpenDrawerRightIcon from '@patternfly/react-icons/dist/esm/icons/open-drawer-right-icon';
|
27
|
+
import OutlinedWindowRestoreIcon from '@patternfly/react-icons/dist/esm/icons/outlined-window-restore-icon';
|
28
|
+
|
29
|
+
import PFHorizontalLogoColor from '../UI/PF-HorizontalLogo-Color.svg';
|
30
|
+
import PFHorizontalLogoReverse from '../UI/PF-HorizontalLogo-Reverse.svg';
|
31
|
+
import PFIconLogoColor from '../UI/PF-IconLogo-Color.svg';
|
32
|
+
import PFIconLogoReverse from '../UI/PF-IconLogo-Reverse.svg';
|
33
|
+
import userAvatar from '../Messages/user_avatar.svg';
|
34
|
+
import patternflyAvatar from '../Messages/patternfly_avatar.jpg';
|
35
|
+
|
36
|
+
const footnoteProps = {
|
37
|
+
label: 'ChatBot uses AI. Check for mistakes.',
|
38
|
+
popover: {
|
39
|
+
title: 'Verify information',
|
40
|
+
description: `While ChatBot strives for accuracy, AI is experimental and can make mistakes. We cannot guarantee that all information provided by ChatBot is up to date or without error. You should always verify responses using reliable sources, especially for crucial information and decision making.`,
|
41
|
+
bannerImage: {
|
42
|
+
src: 'https://cdn.dribbble.com/userupload/10651749/file/original-8a07b8e39d9e8bf002358c66fce1223e.gif',
|
43
|
+
alt: 'Example image for footnote popover'
|
44
|
+
},
|
45
|
+
cta: {
|
46
|
+
label: 'Dismiss',
|
47
|
+
onClick: () => {
|
48
|
+
alert('Do something!');
|
49
|
+
}
|
50
|
+
},
|
51
|
+
link: {
|
52
|
+
label: 'View AI policy',
|
53
|
+
url: 'https://www.redhat.com/'
|
54
|
+
}
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
const markdown = `A paragraph with *emphasis* and **strong importance**.
|
59
|
+
|
60
|
+
> A block quote with ~strikethrough~ and a URL: https://reactjs.org.
|
61
|
+
|
62
|
+
Here is an inline code - \`() => void\`
|
63
|
+
|
64
|
+
Here is some YAML code:
|
65
|
+
|
66
|
+
~~~yaml
|
67
|
+
apiVersion: helm.openshift.io/v1beta1/
|
68
|
+
kind: HelmChartRepository
|
69
|
+
metadata:
|
70
|
+
name: azure-sample-repo0oooo00ooo
|
71
|
+
spec:
|
72
|
+
connectionConfig:
|
73
|
+
url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs
|
74
|
+
~~~
|
75
|
+
|
76
|
+
Here is some JavaScript code:
|
77
|
+
|
78
|
+
~~~js
|
79
|
+
import React from 'react';
|
80
|
+
|
81
|
+
const MessageLoading = () => (
|
82
|
+
<div className="pf-chatbot__message-loading">
|
83
|
+
<span className="pf-chatbot__message-loading-dots">
|
84
|
+
<span className="pf-v6-screen-reader">Loading message</span>
|
85
|
+
</span>
|
86
|
+
</div>
|
87
|
+
);
|
88
|
+
|
89
|
+
export default MessageLoading;
|
90
|
+
|
91
|
+
~~~
|
92
|
+
`;
|
93
|
+
|
94
|
+
// It's important to set a date and timestamp prop since the Message components re-render.
|
95
|
+
// The timestamps re-render with them.
|
96
|
+
const date = new Date();
|
97
|
+
|
98
|
+
const initialMessages: MessageProps[] = [
|
99
|
+
{
|
100
|
+
id: '1',
|
101
|
+
role: 'user',
|
102
|
+
content: 'Hello, can you give me an example of what you can do?',
|
103
|
+
name: 'User',
|
104
|
+
avatar: userAvatar,
|
105
|
+
timestamp: date.toLocaleString(),
|
106
|
+
avatarProps: { isBordered: true }
|
107
|
+
},
|
108
|
+
{
|
109
|
+
id: '2',
|
110
|
+
role: 'bot',
|
111
|
+
content: markdown,
|
112
|
+
name: 'Bot',
|
113
|
+
avatar: patternflyAvatar,
|
114
|
+
timestamp: date.toLocaleString(),
|
115
|
+
actions: {
|
116
|
+
// eslint-disable-next-line no-console
|
117
|
+
positive: { onClick: () => console.log('Good response') },
|
118
|
+
// eslint-disable-next-line no-console
|
119
|
+
negative: { onClick: () => console.log('Bad response') },
|
120
|
+
// eslint-disable-next-line no-console
|
121
|
+
copy: { onClick: () => console.log('Copy') },
|
122
|
+
// eslint-disable-next-line no-console
|
123
|
+
share: { onClick: () => console.log('Share') },
|
124
|
+
// eslint-disable-next-line no-console
|
125
|
+
listen: { onClick: () => console.log('Listen') }
|
126
|
+
}
|
127
|
+
}
|
128
|
+
];
|
129
|
+
|
130
|
+
const welcomePrompts = [
|
131
|
+
{
|
132
|
+
title: 'Set up account',
|
133
|
+
message: 'Choose the necessary settings and preferences for your account.'
|
134
|
+
},
|
135
|
+
{
|
136
|
+
title: 'Troubleshoot issue',
|
137
|
+
message: 'Find documentation and instructions to resolve your issue.'
|
138
|
+
}
|
139
|
+
];
|
140
|
+
|
141
|
+
const initialConversations = {
|
142
|
+
Today: [{ id: '1', text: 'Hello, can you give me an example of what you can do?' }],
|
143
|
+
'This month': [
|
144
|
+
{
|
145
|
+
id: '2',
|
146
|
+
text: 'Enterprise Linux installation and setup'
|
147
|
+
},
|
148
|
+
{ id: '3', text: 'Troubleshoot system crash' }
|
149
|
+
],
|
150
|
+
March: [
|
151
|
+
{ id: '4', text: 'Ansible security and updates' },
|
152
|
+
{ id: '5', text: 'Red Hat certification' },
|
153
|
+
{ id: '6', text: 'Lightspeed user documentation' }
|
154
|
+
],
|
155
|
+
February: [
|
156
|
+
{ id: '7', text: 'Crashing pod assistance' },
|
157
|
+
{ id: '8', text: 'OpenShift AI pipelines' },
|
158
|
+
{ id: '9', text: 'Updating subscription plan' },
|
159
|
+
{ id: '10', text: 'Red Hat licensing options' }
|
160
|
+
],
|
161
|
+
January: [
|
162
|
+
{ id: '11', text: 'RHEL system performance' },
|
163
|
+
{ id: '12', text: 'Manage user accounts' }
|
164
|
+
]
|
165
|
+
};
|
166
|
+
|
167
|
+
export const ChatbotDemo: React.FunctionComponent = () => {
|
168
|
+
const [chatbotVisible, setChatbotVisible] = React.useState<boolean>(true);
|
169
|
+
const [displayMode, setDisplayMode] = React.useState<ChatbotDisplayMode>(ChatbotDisplayMode.default);
|
170
|
+
const [messages, setMessages] = React.useState<MessageProps[]>(initialMessages);
|
171
|
+
const [selectedModel, setSelectedModel] = React.useState('Granite 7B');
|
172
|
+
const [isSendButtonDisabled, setIsSendButtonDisabled] = React.useState(false);
|
173
|
+
const [isDrawerOpen, setIsDrawerOpen] = React.useState(false);
|
174
|
+
const [conversations, setConversations] = React.useState<Conversation[] | { [key: string]: Conversation[] }>(
|
175
|
+
initialConversations
|
176
|
+
);
|
177
|
+
const [announcement, setAnnouncement] = React.useState<string>();
|
178
|
+
const scrollToBottomRef = React.useRef<HTMLDivElement>(null);
|
179
|
+
const toggleRef = React.useRef<HTMLButtonElement>(null);
|
180
|
+
const chatbotRef = React.useRef<HTMLDivElement>(null);
|
181
|
+
const historyRef = React.useRef<HTMLButtonElement>(null);
|
182
|
+
|
183
|
+
// Auto-scrolls to the latest message
|
184
|
+
React.useEffect(() => {
|
185
|
+
// don't scroll the first load - in this demo, we know we start with two messages
|
186
|
+
if (messages.length > 2) {
|
187
|
+
scrollToBottomRef.current?.scrollIntoView({ behavior: 'smooth' });
|
188
|
+
}
|
189
|
+
}, [messages]);
|
190
|
+
|
191
|
+
const onSelectModel = (
|
192
|
+
_event: React.MouseEvent<Element, MouseEvent> | undefined,
|
193
|
+
value: string | number | undefined
|
194
|
+
) => {
|
195
|
+
setSelectedModel(value as string);
|
196
|
+
};
|
197
|
+
|
198
|
+
const onSelectDisplayMode = (
|
199
|
+
_event: React.MouseEvent<Element, MouseEvent> | undefined,
|
200
|
+
value: string | number | undefined
|
201
|
+
) => {
|
202
|
+
setDisplayMode(value as ChatbotDisplayMode);
|
203
|
+
};
|
204
|
+
|
205
|
+
// you will likely want to come up with your own unique id function; this is for demo purposes only
|
206
|
+
const generateId = () => {
|
207
|
+
const id = Date.now() + Math.random();
|
208
|
+
return id.toString();
|
209
|
+
};
|
210
|
+
|
211
|
+
const handleSend = (message: string) => {
|
212
|
+
setIsSendButtonDisabled(true);
|
213
|
+
const newMessages: MessageProps[] = [];
|
214
|
+
// We can't use structuredClone since messages contains functions, but we can't mutate
|
215
|
+
// items that are going into state or the UI won't update correctly
|
216
|
+
messages.forEach((message) => newMessages.push(message));
|
217
|
+
// It's important to set a timestamp prop since the Message components re-render.
|
218
|
+
// The timestamps re-render with them.
|
219
|
+
const date = new Date();
|
220
|
+
newMessages.push({
|
221
|
+
id: generateId(),
|
222
|
+
role: 'user',
|
223
|
+
content: message,
|
224
|
+
name: 'User',
|
225
|
+
avatar: userAvatar,
|
226
|
+
timestamp: date.toLocaleString(),
|
227
|
+
avatarProps: { isBordered: true }
|
228
|
+
});
|
229
|
+
newMessages.push({
|
230
|
+
id: generateId(),
|
231
|
+
role: 'bot',
|
232
|
+
content: 'API response goes here',
|
233
|
+
name: 'Bot',
|
234
|
+
isLoading: true,
|
235
|
+
avatar: patternflyAvatar,
|
236
|
+
timestamp: date.toLocaleString()
|
237
|
+
});
|
238
|
+
setMessages(newMessages);
|
239
|
+
// make announcement to assistive devices that new messages have been added
|
240
|
+
setAnnouncement(`Message from User: ${message}. Message from Bot is loading.`);
|
241
|
+
|
242
|
+
// this is for demo purposes only; in a real situation, there would be an API response we would wait for
|
243
|
+
setTimeout(() => {
|
244
|
+
const loadedMessages: MessageProps[] = [];
|
245
|
+
// We can't use structuredClone since messages contains functions, but we can't mutate
|
246
|
+
// items that are going into state or the UI won't update correctly
|
247
|
+
newMessages.forEach((message) => loadedMessages.push(message));
|
248
|
+
loadedMessages.pop();
|
249
|
+
loadedMessages.push({
|
250
|
+
id: generateId(),
|
251
|
+
role: 'bot',
|
252
|
+
content: 'API response goes here',
|
253
|
+
name: 'Bot',
|
254
|
+
isLoading: false,
|
255
|
+
avatar: patternflyAvatar,
|
256
|
+
timestamp: date.toLocaleString(),
|
257
|
+
actions: {
|
258
|
+
// eslint-disable-next-line no-console
|
259
|
+
positive: { onClick: () => console.log('Good response') },
|
260
|
+
// eslint-disable-next-line no-console
|
261
|
+
negative: { onClick: () => console.log('Bad response') },
|
262
|
+
// eslint-disable-next-line no-console
|
263
|
+
copy: { onClick: () => console.log('Copy') },
|
264
|
+
// eslint-disable-next-line no-console
|
265
|
+
share: { onClick: () => console.log('Share') },
|
266
|
+
// eslint-disable-next-line no-console
|
267
|
+
listen: { onClick: () => console.log('Listen') }
|
268
|
+
}
|
269
|
+
});
|
270
|
+
setMessages(loadedMessages);
|
271
|
+
// make announcement to assistive devices that new message has loaded
|
272
|
+
setAnnouncement(`Message from Bot: API response goes here`);
|
273
|
+
setIsSendButtonDisabled(false);
|
274
|
+
}, 5000);
|
275
|
+
};
|
276
|
+
|
277
|
+
const findMatchingItems = (targetValue: string) => {
|
278
|
+
let filteredConversations = Object.entries(initialConversations).reduce((acc, [key, items]) => {
|
279
|
+
const filteredItems = items.filter((item) => item.text.toLowerCase().includes(targetValue.toLowerCase()));
|
280
|
+
if (filteredItems.length > 0) {
|
281
|
+
acc[key] = filteredItems;
|
282
|
+
}
|
283
|
+
return acc;
|
284
|
+
}, {});
|
285
|
+
|
286
|
+
// append message if no items are found
|
287
|
+
if (Object.keys(filteredConversations).length === 0) {
|
288
|
+
filteredConversations = [{ id: '13', noIcon: true, text: 'No results found' }];
|
289
|
+
}
|
290
|
+
return filteredConversations;
|
291
|
+
};
|
292
|
+
|
293
|
+
const horizontalLogo = (
|
294
|
+
<Bullseye>
|
295
|
+
<Brand className="show-light" src={PFHorizontalLogoColor} alt="PatternFly" />
|
296
|
+
<Brand className="show-dark" src={PFHorizontalLogoReverse} alt="PatternFly" />
|
297
|
+
</Bullseye>
|
298
|
+
);
|
299
|
+
|
300
|
+
const iconLogo = (
|
301
|
+
<>
|
302
|
+
<Brand className="show-light" src={PFIconLogoColor} alt="PatternFly" />
|
303
|
+
<Brand className="show-dark" src={PFIconLogoReverse} alt="PatternFly" />
|
304
|
+
</>
|
305
|
+
);
|
306
|
+
|
307
|
+
const handleSkipToContent = (e) => {
|
308
|
+
e.preventDefault();
|
309
|
+
/* eslint-disable indent */
|
310
|
+
switch (displayMode) {
|
311
|
+
case ChatbotDisplayMode.default:
|
312
|
+
if (!chatbotVisible && toggleRef.current) {
|
313
|
+
toggleRef.current.focus();
|
314
|
+
}
|
315
|
+
if (chatbotVisible && chatbotRef.current) {
|
316
|
+
chatbotRef.current.focus();
|
317
|
+
}
|
318
|
+
break;
|
319
|
+
|
320
|
+
case ChatbotDisplayMode.docked:
|
321
|
+
if (chatbotRef.current) {
|
322
|
+
chatbotRef.current.focus();
|
323
|
+
}
|
324
|
+
break;
|
325
|
+
default:
|
326
|
+
if (historyRef.current) {
|
327
|
+
historyRef.current.focus();
|
328
|
+
}
|
329
|
+
break;
|
330
|
+
}
|
331
|
+
/* eslint-enable indent */
|
332
|
+
};
|
333
|
+
|
334
|
+
return (
|
335
|
+
<>
|
336
|
+
<SkipToContent onClick={handleSkipToContent} href="#">
|
337
|
+
Skip to chatbot
|
338
|
+
</SkipToContent>
|
339
|
+
<ChatbotToggle
|
340
|
+
tooltipLabel="Chatbot"
|
341
|
+
isChatbotVisible={chatbotVisible}
|
342
|
+
onToggleChatbot={function () {
|
343
|
+
setChatbotVisible(!chatbotVisible);
|
344
|
+
}}
|
345
|
+
id="chatbot-toggle"
|
346
|
+
ref={toggleRef}
|
347
|
+
/>
|
348
|
+
<Chatbot isCompact isVisible={chatbotVisible} displayMode={displayMode} ref={chatbotRef}>
|
349
|
+
<ChatbotConversationHistoryNav
|
350
|
+
displayMode={displayMode}
|
351
|
+
onDrawerToggle={() => {
|
352
|
+
setIsDrawerOpen(!isDrawerOpen);
|
353
|
+
setConversations(initialConversations);
|
354
|
+
}}
|
355
|
+
isDrawerOpen={isDrawerOpen}
|
356
|
+
setIsDrawerOpen={setIsDrawerOpen}
|
357
|
+
activeItemId="1"
|
358
|
+
// eslint-disable-next-line no-console
|
359
|
+
onSelectActiveItem={(e, selectedItem) => console.log(`Selected history item with id ${selectedItem}`)}
|
360
|
+
conversations={conversations}
|
361
|
+
onNewChat={() => {
|
362
|
+
setIsDrawerOpen(!isDrawerOpen);
|
363
|
+
setMessages([]);
|
364
|
+
setConversations(initialConversations);
|
365
|
+
}}
|
366
|
+
handleTextInputChange={(value: string) => {
|
367
|
+
if (value === '') {
|
368
|
+
setConversations(initialConversations);
|
369
|
+
}
|
370
|
+
// this is where you would perform search on the items in the drawer
|
371
|
+
// and update the state
|
372
|
+
const newConversations: { [key: string]: Conversation[] } = findMatchingItems(value);
|
373
|
+
setConversations(newConversations);
|
374
|
+
}}
|
375
|
+
isCompact
|
376
|
+
drawerContent={
|
377
|
+
<>
|
378
|
+
<ChatbotHeader>
|
379
|
+
<ChatbotHeaderMain>
|
380
|
+
<ChatbotHeaderMenu
|
381
|
+
ref={historyRef}
|
382
|
+
aria-expanded={isDrawerOpen}
|
383
|
+
onMenuToggle={() => setIsDrawerOpen(!isDrawerOpen)}
|
384
|
+
isCompact
|
385
|
+
/>
|
386
|
+
<ChatbotHeaderTitle
|
387
|
+
displayMode={displayMode}
|
388
|
+
showOnFullScreen={horizontalLogo}
|
389
|
+
showOnDefault={iconLogo}
|
390
|
+
></ChatbotHeaderTitle>
|
391
|
+
</ChatbotHeaderMain>
|
392
|
+
<ChatbotHeaderActions>
|
393
|
+
<ChatbotHeaderSelectorDropdown value={selectedModel} onSelect={onSelectModel} isCompact>
|
394
|
+
<DropdownList>
|
395
|
+
<DropdownItem value="Granite 7B" key="granite">
|
396
|
+
Granite 7B
|
397
|
+
</DropdownItem>
|
398
|
+
<DropdownItem value="Llama 3.0" key="llama">
|
399
|
+
Llama 3.0
|
400
|
+
</DropdownItem>
|
401
|
+
<DropdownItem value="Mistral 3B" key="mistral">
|
402
|
+
Mistral 3B
|
403
|
+
</DropdownItem>
|
404
|
+
</DropdownList>
|
405
|
+
</ChatbotHeaderSelectorDropdown>
|
406
|
+
<ChatbotHeaderOptionsDropdown onSelect={onSelectDisplayMode} isCompact>
|
407
|
+
<DropdownGroup label="Display mode">
|
408
|
+
<DropdownList>
|
409
|
+
<DropdownItem
|
410
|
+
value={ChatbotDisplayMode.default}
|
411
|
+
key="switchDisplayOverlay"
|
412
|
+
icon={<OutlinedWindowRestoreIcon aria-hidden />}
|
413
|
+
isSelected={displayMode === ChatbotDisplayMode.default}
|
414
|
+
>
|
415
|
+
<span>Overlay</span>
|
416
|
+
</DropdownItem>
|
417
|
+
<DropdownItem
|
418
|
+
value={ChatbotDisplayMode.docked}
|
419
|
+
key="switchDisplayDock"
|
420
|
+
icon={<OpenDrawerRightIcon aria-hidden />}
|
421
|
+
isSelected={displayMode === ChatbotDisplayMode.docked}
|
422
|
+
>
|
423
|
+
<span>Dock to window</span>
|
424
|
+
</DropdownItem>
|
425
|
+
<DropdownItem
|
426
|
+
value={ChatbotDisplayMode.fullscreen}
|
427
|
+
key="switchDisplayFullscreen"
|
428
|
+
icon={<ExpandIcon aria-hidden />}
|
429
|
+
isSelected={displayMode === ChatbotDisplayMode.fullscreen}
|
430
|
+
>
|
431
|
+
<span>Fullscreen</span>
|
432
|
+
</DropdownItem>
|
433
|
+
</DropdownList>
|
434
|
+
</DropdownGroup>
|
435
|
+
</ChatbotHeaderOptionsDropdown>
|
436
|
+
</ChatbotHeaderActions>
|
437
|
+
</ChatbotHeader>
|
438
|
+
<ChatbotContent>
|
439
|
+
{/* Update the announcement prop on MessageBox whenever a new message is sent
|
440
|
+
so that users of assistive devices receive sufficient context */}
|
441
|
+
<MessageBox announcement={announcement}>
|
442
|
+
<ChatbotWelcomePrompt
|
443
|
+
title="Hi, ChatBot User!"
|
444
|
+
description="How can I help you today?"
|
445
|
+
prompts={welcomePrompts}
|
446
|
+
isCompact
|
447
|
+
/>
|
448
|
+
{/* This code block enables scrolling to the top of the last message.
|
449
|
+
You can instead choose to move the div with scrollToBottomRef on it below
|
450
|
+
the map of messages, so that users are forced to scroll to the bottom.
|
451
|
+
If you are using streaming, you will want to take a different approach;
|
452
|
+
see: https://github.com/patternfly/chatbot/issues/201#issuecomment-2400725173 */}
|
453
|
+
{messages.map((message, index) => {
|
454
|
+
if (index === messages.length - 1) {
|
455
|
+
return (
|
456
|
+
<>
|
457
|
+
<div ref={scrollToBottomRef}></div>
|
458
|
+
<Message key={message.id} {...message} />
|
459
|
+
</>
|
460
|
+
);
|
461
|
+
}
|
462
|
+
return <Message key={message.id} {...message} />;
|
463
|
+
})}
|
464
|
+
</MessageBox>
|
465
|
+
</ChatbotContent>
|
466
|
+
<ChatbotFooter isCompact>
|
467
|
+
<MessageBar
|
468
|
+
onSendMessage={handleSend}
|
469
|
+
hasMicrophoneButton
|
470
|
+
isSendButtonDisabled={isSendButtonDisabled}
|
471
|
+
isCompact
|
472
|
+
/>
|
473
|
+
<ChatbotFootnote {...footnoteProps} />
|
474
|
+
</ChatbotFooter>
|
475
|
+
</>
|
476
|
+
}
|
477
|
+
></ChatbotConversationHistoryNav>
|
478
|
+
</Chatbot>
|
479
|
+
</>
|
480
|
+
);
|
481
|
+
};
|
@@ -22,6 +22,8 @@ export interface AttachmentEditProps {
|
|
22
22
|
title?: string;
|
23
23
|
/** Display mode for the Chatbot parent; this influences the styles applied */
|
24
24
|
displayMode?: ChatbotDisplayMode;
|
25
|
+
/** Sets modal to compact styling. */
|
26
|
+
isCompact?: boolean;
|
25
27
|
}
|
26
28
|
|
27
29
|
export const AttachmentEdit: React.FunctionComponent<AttachmentEditProps> = ({
|
@@ -32,7 +34,8 @@ export const AttachmentEdit: React.FunctionComponent<AttachmentEditProps> = ({
|
|
32
34
|
onCancel,
|
33
35
|
onSave,
|
34
36
|
title = 'Edit attachment',
|
35
|
-
displayMode = ChatbotDisplayMode.default
|
37
|
+
displayMode = ChatbotDisplayMode.default,
|
38
|
+
isCompact
|
36
39
|
}: AttachmentEditProps) => {
|
37
40
|
const handleSave = (_event: React.MouseEvent | MouseEvent | KeyboardEvent, code) => {
|
38
41
|
handleModalToggle(_event);
|
@@ -56,6 +59,7 @@ export const AttachmentEdit: React.FunctionComponent<AttachmentEditProps> = ({
|
|
56
59
|
secondaryActionBtn="Cancel"
|
57
60
|
title={title}
|
58
61
|
displayMode={displayMode}
|
62
|
+
isCompact={isCompact}
|
59
63
|
/>
|
60
64
|
);
|
61
65
|
};
|
package/src/Chatbot/Chatbot.scss
CHANGED
@@ -125,3 +125,10 @@
|
|
125
125
|
border-radius: var(--pf-t--global--border--radius--sharp);
|
126
126
|
}
|
127
127
|
}
|
128
|
+
|
129
|
+
// ============================================================================
|
130
|
+
// Information density styles
|
131
|
+
// ============================================================================
|
132
|
+
.pf-chatbot.pf-m-compact {
|
133
|
+
font-size: var(--pf-t--global--font--size--sm);
|
134
|
+
}
|
@@ -28,4 +28,13 @@ describe('Chatbot', () => {
|
|
28
28
|
render(<Chatbot isVisible={false}>Chatbot Content</Chatbot>);
|
29
29
|
expect(screen.queryByLabelText('Chatbot')).toBeFalsy();
|
30
30
|
});
|
31
|
+
|
32
|
+
it('should handle isCompact', () => {
|
33
|
+
render(
|
34
|
+
<Chatbot data-testid="chatbot" isVisible={true} isCompact>
|
35
|
+
Chatbot Content
|
36
|
+
</Chatbot>
|
37
|
+
);
|
38
|
+
expect(screen.getByTestId('chatbot')).toHaveClass('pf-m-compact');
|
39
|
+
});
|
31
40
|
});
|
package/src/Chatbot/Chatbot.tsx
CHANGED
@@ -17,6 +17,8 @@ export interface ChatbotProps {
|
|
17
17
|
innerRef?: React.Ref<HTMLDivElement>;
|
18
18
|
/** Custom aria label applied to focusable container */
|
19
19
|
ariaLabel?: string;
|
20
|
+
/** Density of information within the ChatBot */
|
21
|
+
isCompact?: boolean;
|
20
22
|
}
|
21
23
|
|
22
24
|
export enum ChatbotDisplayMode {
|
@@ -34,6 +36,7 @@ const ChatbotBase: React.FunctionComponent<ChatbotProps> = ({
|
|
34
36
|
className,
|
35
37
|
innerRef,
|
36
38
|
ariaLabel,
|
39
|
+
isCompact,
|
37
40
|
...props
|
38
41
|
}: ChatbotProps) => {
|
39
42
|
// Configure animations
|
@@ -44,7 +47,7 @@ const ChatbotBase: React.FunctionComponent<ChatbotProps> = ({
|
|
44
47
|
|
45
48
|
return (
|
46
49
|
<motion.div
|
47
|
-
className={`pf-chatbot pf-chatbot--${displayMode} ${!isVisible ? 'pf-chatbot--hidden' : ''} ${className ?? ''}`}
|
50
|
+
className={`pf-chatbot pf-chatbot--${displayMode} ${!isVisible ? 'pf-chatbot--hidden' : ''} ${isCompact ? 'pf-m-compact' : ''} ${className ?? ''}`}
|
48
51
|
variants={motionChatbot}
|
49
52
|
initial="hidden"
|
50
53
|
animate={isVisible ? 'visible' : 'hidden'}
|
@@ -9,8 +9,8 @@
|
|
9
9
|
// Drawer input
|
10
10
|
// ----------------------------------------------------------------------------
|
11
11
|
.pf-chatbot__input {
|
12
|
-
padding-inline-start: var(--pf-t--global--spacer--
|
13
|
-
padding-inline-end: var(--pf-t--global--spacer--
|
12
|
+
padding-inline-start: var(--pf-t--global--spacer--lg);
|
13
|
+
padding-inline-end: var(--pf-t--global--spacer--lg);
|
14
14
|
}
|
15
15
|
|
16
16
|
// Drawer menu
|
@@ -118,7 +118,6 @@
|
|
118
118
|
border-radius: var(--pf-t--global--border--radius--pill);
|
119
119
|
justify-content: center;
|
120
120
|
align-items: center;
|
121
|
-
border-radius: var(--pf-t--global--border--radius--small);
|
122
121
|
}
|
123
122
|
}
|
124
123
|
|
@@ -205,3 +204,39 @@
|
|
205
204
|
gap: var(--pf-t--global--spacer--sm);
|
206
205
|
align-self: stretch;
|
207
206
|
}
|
207
|
+
|
208
|
+
.pf-chatbot__history.pf-m-compact {
|
209
|
+
.pf-v6-c-drawer__main {
|
210
|
+
.pf-v6-c-drawer__panel {
|
211
|
+
--pf-v6-c-drawer__panel--PaddingBlockStart: var(--pf-t--global--spacer--sm);
|
212
|
+
--pf-v6-c-drawer__panel--PaddingBlockEnd: var(--pf-t--global--spacer--sm);
|
213
|
+
--pf-v6-c-drawer__head--PaddingInlineStart: var(--pf-t--global--spacer--md);
|
214
|
+
--pf-v6-c-drawer__head--PaddingInlineEnd: var(--pf-t--global--spacer--md);
|
215
|
+
--pf-v6-c-drawer__panel--RowGap: var(--pf-t--global--spacer--md);
|
216
|
+
}
|
217
|
+
|
218
|
+
.pf-v6-c-drawer__body {
|
219
|
+
--pf-v6-c-drawer__panel__body--PaddingInlineStart: var(--pf-t--global--spacer--md);
|
220
|
+
--pf-v6-c-drawer__panel__body--PaddingInlineEnd: var(--pf-t--global--spacer--md);
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
.pf-chatbot__menu-item {
|
225
|
+
font-size: var(--pf-t--global--font--size--body--md);
|
226
|
+
}
|
227
|
+
|
228
|
+
.pf-v6-c-drawer__head {
|
229
|
+
--pf-v6-c-drawer__head--PaddingInlineStart: var(--pf-t--global--spacer--lg);
|
230
|
+
--pf-v6-c-drawer__head--PaddingInlineEnd: var(--pf-t--global--spacer--lg);
|
231
|
+
}
|
232
|
+
.pf-v6-c-drawer__close {
|
233
|
+
.pf-v6-c-button {
|
234
|
+
width: 2rem;
|
235
|
+
height: 2rem;
|
236
|
+
--pf-v6-c-button--m-plain--PaddingInlineEnd: var(--pf-t--global--spacer--xs);
|
237
|
+
--pf-v6-c-button--m-plain--PaddingInlineStart: var(--pf-t--global--spacer--xs);
|
238
|
+
--pf-v6-c-button--PaddingBlockStart: var(--pf-t--global--spacer--xs);
|
239
|
+
--pf-v6-c-button--PaddingBlockEnd: var(--pf-t--global--spacer--xs);
|
240
|
+
}
|
241
|
+
}
|
242
|
+
}
|
@@ -415,4 +415,22 @@ describe('ChatbotConversationHistoryNav', () => {
|
|
415
415
|
})
|
416
416
|
).toBeTruthy();
|
417
417
|
});
|
418
|
+
|
419
|
+
it('should handle isCompact', () => {
|
420
|
+
render(
|
421
|
+
<ChatbotConversationHistoryNav
|
422
|
+
onDrawerToggle={onDrawerToggle}
|
423
|
+
isDrawerOpen={true}
|
424
|
+
displayMode={ChatbotDisplayMode.fullscreen}
|
425
|
+
setIsDrawerOpen={jest.fn()}
|
426
|
+
reverseButtonOrder={false}
|
427
|
+
handleTextInputChange={jest.fn()}
|
428
|
+
conversations={initialConversations}
|
429
|
+
noResultsState={NO_RESULTS}
|
430
|
+
isCompact
|
431
|
+
data-testid="drawer"
|
432
|
+
/>
|
433
|
+
);
|
434
|
+
expect(screen.getByTestId('drawer')).toHaveClass('pf-m-compact');
|
435
|
+
});
|
418
436
|
});
|
@@ -116,6 +116,8 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
|
|
116
116
|
emptyState?: HistoryEmptyStateProps;
|
117
117
|
/** Content to show in no results state. No results state will appear once content is passed in. */
|
118
118
|
noResultsState?: HistoryEmptyStateProps;
|
119
|
+
/** Sets drawer to compact styling. */
|
120
|
+
isCompact?: boolean;
|
119
121
|
}
|
120
122
|
|
121
123
|
export const ChatbotConversationHistoryNav: React.FunctionComponent<ChatbotConversationHistoryNavProps> = ({
|
@@ -147,6 +149,7 @@ export const ChatbotConversationHistoryNav: React.FunctionComponent<ChatbotConve
|
|
147
149
|
errorState,
|
148
150
|
emptyState,
|
149
151
|
noResultsState,
|
152
|
+
isCompact,
|
150
153
|
...props
|
151
154
|
}: ChatbotConversationHistoryNavProps) => {
|
152
155
|
const drawerRef = React.useRef<HTMLDivElement>(null);
|
@@ -256,7 +259,11 @@ export const ChatbotConversationHistoryNav: React.FunctionComponent<ChatbotConve
|
|
256
259
|
{...drawerActionsProps}
|
257
260
|
>
|
258
261
|
<DrawerCloseButton onClick={onDrawerToggle} {...drawerCloseButtonProps} />
|
259
|
-
{onNewChat &&
|
262
|
+
{onNewChat && (
|
263
|
+
<Button size={isCompact ? 'sm' : undefined} onClick={onNewChat}>
|
264
|
+
{newChatButtonText}
|
265
|
+
</Button>
|
266
|
+
)}
|
260
267
|
</DrawerActions>
|
261
268
|
</DrawerHead>
|
262
269
|
{isLoading ? <LoadingState {...loadingState} /> : renderDrawerContent()}
|
@@ -287,7 +294,7 @@ export const ChatbotConversationHistoryNav: React.FunctionComponent<ChatbotConve
|
|
287
294
|
|
288
295
|
return (
|
289
296
|
<Drawer
|
290
|
-
className=
|
297
|
+
className={`pf-chatbot__history ${isCompact ? 'pf-m-compact' : ''}`}
|
291
298
|
isExpanded={isDrawerOpen}
|
292
299
|
onExpand={onExpand}
|
293
300
|
position="start"
|
@@ -57,3 +57,8 @@
|
|
57
57
|
padding: var(--pf-t--global--spacer--sm) var(--pf-t--global--spacer--lg);
|
58
58
|
}
|
59
59
|
}
|
60
|
+
|
61
|
+
.pf-chatbot__footer.pf-m-compact .pf-chatbot__footer-container {
|
62
|
+
padding: 0 var(--pf-t--global--spacer--sm) var(--pf-t--global--spacer--sm) var(--pf-t--global--spacer--sm);
|
63
|
+
row-gap: var(--pf-t--global--spacer--sm);
|
64
|
+
}
|