@patternfly/chatbot 6.3.0 → 6.4.0-prerelease.2
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/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +5 -1
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +3 -3
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +17 -0
- package/dist/cjs/FileDropZone/FileDropZone.d.ts +1 -2
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +1 -10
- package/dist/cjs/Message/Message.d.ts +4 -2
- package/dist/cjs/Message/Message.js +4 -4
- package/dist/cjs/Message/Message.test.js +26 -0
- package/dist/cjs/Message/MessageInput.d.ts +3 -1
- package/dist/cjs/Message/MessageInput.js +2 -2
- package/dist/cjs/MessageBar/AttachButton.d.ts +2 -2
- package/dist/cjs/MessageBar/MessageBar.d.ts +2 -2
- package/dist/cjs/MessageBox/MessageBox.js +1 -1
- package/dist/cjs/MessageDivider/MessageDivider.d.ts +9 -0
- package/dist/cjs/MessageDivider/MessageDivider.js +23 -0
- package/dist/cjs/MessageDivider/MessageDivider.test.d.ts +1 -0
- package/dist/cjs/MessageDivider/MessageDivider.test.js +29 -0
- package/dist/cjs/MessageDivider/index.d.ts +2 -0
- package/dist/cjs/MessageDivider/index.js +23 -0
- package/dist/cjs/ResponseActions/ResponseActions.d.ts +1 -0
- package/dist/cjs/ResponseActions/ResponseActions.js +4 -4
- package/dist/cjs/ResponseActions/ResponseActions.test.js +6 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +4 -1
- package/dist/css/main.css +56 -55
- package/dist/css/main.css.map +1 -1
- package/dist/dynamic/MessageDivider/package.json +1 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +5 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +5 -5
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +17 -0
- package/dist/esm/FileDropZone/FileDropZone.d.ts +1 -2
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +1 -7
- package/dist/esm/Message/Message.d.ts +4 -2
- package/dist/esm/Message/Message.js +4 -4
- package/dist/esm/Message/Message.test.js +26 -0
- package/dist/esm/Message/MessageInput.d.ts +3 -1
- package/dist/esm/Message/MessageInput.js +2 -2
- package/dist/esm/MessageBar/AttachButton.d.ts +2 -2
- package/dist/esm/MessageBar/MessageBar.d.ts +2 -2
- package/dist/esm/MessageBox/MessageBox.js +1 -1
- package/dist/esm/MessageDivider/MessageDivider.d.ts +9 -0
- package/dist/esm/MessageDivider/MessageDivider.js +21 -0
- package/dist/esm/MessageDivider/MessageDivider.test.d.ts +1 -0
- package/dist/esm/MessageDivider/MessageDivider.test.js +24 -0
- package/dist/esm/MessageDivider/index.d.ts +2 -0
- package/dist/esm/MessageDivider/index.js +2 -0
- package/dist/esm/ResponseActions/ResponseActions.d.ts +1 -0
- package/dist/esm/ResponseActions/ResponseActions.js +5 -5
- package/dist/esm/ResponseActions/ResponseActions.test.js +6 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithDividers.tsx +24 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +15 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +39 -7
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +9 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithPin.tsx +196 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +9 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +33 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotDisplayMode.tsx +486 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotTranscripts.tsx +565 -0
- package/src/Chatbot/Chatbot.scss +1 -1
- package/src/ChatbotContent/ChatbotContent.scss +1 -1
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +14 -2
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +58 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +29 -12
- package/src/ChatbotFooter/ChatbotFooter.scss +1 -1
- package/src/ChatbotHeader/ChatbotHeader.scss +3 -3
- package/src/ChatbotToggle/ChatbotToggle.scss +2 -2
- package/src/FileDropZone/FileDropZone.tsx +2 -2
- package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +3 -27
- package/src/Message/Message.scss +9 -7
- package/src/Message/Message.test.tsx +35 -0
- package/src/Message/Message.tsx +8 -4
- package/src/Message/MessageInput.tsx +5 -1
- package/src/MessageBar/AttachButton.tsx +2 -2
- package/src/MessageBar/MessageBar.tsx +2 -2
- package/src/MessageBar/SendButton.scss +3 -3
- package/src/MessageBox/JumpButton.scss +1 -1
- package/src/MessageBox/MessageBox.tsx +1 -1
- package/src/MessageDivider/MessageDivider.scss +45 -0
- package/src/MessageDivider/MessageDivider.test.tsx +24 -0
- package/src/MessageDivider/MessageDivider.tsx +35 -0
- package/src/MessageDivider/index.ts +3 -0
- package/src/ResponseActions/ResponseActions.test.tsx +6 -1
- package/src/ResponseActions/ResponseActions.tsx +24 -3
- package/src/index.ts +3 -0
- package/src/main.scss +1 -52
- package/dist/cjs/Message/CodeBlockMessage/ExpandableSectionForSyntaxHighlighter.d.ts +0 -62
- package/dist/cjs/Message/CodeBlockMessage/ExpandableSectionForSyntaxHighlighter.js +0 -139
- package/dist/esm/Message/CodeBlockMessage/ExpandableSectionForSyntaxHighlighter.d.ts +0 -62
- package/dist/esm/Message/CodeBlockMessage/ExpandableSectionForSyntaxHighlighter.js +0 -133
- package/src/Message/CodeBlockMessage/ExpandableSectionForSyntaxHighlighter.tsx +0 -223
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// Assisted by: Cursor
|
|
2
|
+
import React, { FunctionComponent, useState } from 'react';
|
|
3
|
+
import { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot';
|
|
4
|
+
import ChatbotConversationHistoryNav, {
|
|
5
|
+
Conversation
|
|
6
|
+
} from '@patternfly/chatbot/dist/dynamic/ChatbotConversationHistoryNav';
|
|
7
|
+
import { Checkbox, DropdownItem, DropdownList } from '@patternfly/react-core';
|
|
8
|
+
import { ThumbtackIcon } from '@patternfly/react-icons';
|
|
9
|
+
|
|
10
|
+
// Sample conversations
|
|
11
|
+
const initialConversations: { [key: string]: Conversation[] } = {
|
|
12
|
+
Today: [
|
|
13
|
+
{
|
|
14
|
+
id: '1',
|
|
15
|
+
text: 'Red Hat products and services',
|
|
16
|
+
label: 'Conversation options for "Red Hat products and services"'
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
'This month': [
|
|
20
|
+
{
|
|
21
|
+
id: '2',
|
|
22
|
+
text: 'Enterprise Linux installation and setup',
|
|
23
|
+
label: 'Conversation options for "Enterprise Linux installation and setup"'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: '3',
|
|
27
|
+
text: 'Troubleshoot system crash',
|
|
28
|
+
label: 'Conversation options for "Troubleshoot system crash"'
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
March: [
|
|
32
|
+
{
|
|
33
|
+
id: '4',
|
|
34
|
+
text: 'Ansible security and updates',
|
|
35
|
+
label: 'Conversation options for "Ansible security and updates"'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: '5',
|
|
39
|
+
text: 'Red Hat certification',
|
|
40
|
+
label: 'Conversation options for "Red Hat certification"'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: '6',
|
|
44
|
+
text: 'Lightspeed user documentation',
|
|
45
|
+
label: 'Conversation options for "Lightspeed user documentation"'
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
February: [
|
|
49
|
+
{
|
|
50
|
+
id: '7',
|
|
51
|
+
text: 'Crashing pod assistance',
|
|
52
|
+
label: 'Conversation options for "Crashing pod assistance"'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: '8',
|
|
56
|
+
text: 'OpenShift AI pipelines',
|
|
57
|
+
label: 'Conversation options for "OpenShift AI pipelines"'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: '9',
|
|
61
|
+
text: 'Updating subscription plan',
|
|
62
|
+
label: 'Conversation options for "Updating subscription plan"'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: '10',
|
|
66
|
+
text: 'Red Hat licensing options',
|
|
67
|
+
label: 'Conversation options for "Red Hat licensing options"'
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
January: [
|
|
71
|
+
{
|
|
72
|
+
id: '11',
|
|
73
|
+
text: 'RHEL system performance',
|
|
74
|
+
label: 'Conversation options for "RHEL system performance"'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: '12',
|
|
78
|
+
text: 'Manage user accounts',
|
|
79
|
+
label: 'Conversation options for "Manage user accounts"'
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const ChatbotHeaderPinDemo: FunctionComponent = () => {
|
|
85
|
+
const [isDrawerOpen, setIsDrawerOpen] = useState(true);
|
|
86
|
+
const [isCompact, setIsCompact] = useState(false);
|
|
87
|
+
const [pinnedConversations, setPinnedConversations] = useState<Set<string>>(new Set());
|
|
88
|
+
const displayMode = ChatbotDisplayMode.embedded;
|
|
89
|
+
|
|
90
|
+
const handlePinToggle = (conversationId: string) => {
|
|
91
|
+
setPinnedConversations((prev) => {
|
|
92
|
+
const newPinned = new Set(prev);
|
|
93
|
+
if (newPinned.has(conversationId)) {
|
|
94
|
+
newPinned.delete(conversationId);
|
|
95
|
+
} else {
|
|
96
|
+
newPinned.add(conversationId);
|
|
97
|
+
}
|
|
98
|
+
return newPinned;
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const createMenuItems = (conversationId: string) => {
|
|
103
|
+
const isPinned = pinnedConversations.has(conversationId);
|
|
104
|
+
|
|
105
|
+
return [
|
|
106
|
+
<DropdownList key={`${conversationId}-menu`} aria-label="Conversation options">
|
|
107
|
+
<DropdownItem
|
|
108
|
+
value={isPinned ? 'Unpin' : 'Pin'}
|
|
109
|
+
id={isPinned ? 'Unpin' : 'Pin'}
|
|
110
|
+
onClick={() => handlePinToggle(conversationId)}
|
|
111
|
+
>
|
|
112
|
+
{isPinned ? 'Unpin' : 'Pin'}
|
|
113
|
+
</DropdownItem>
|
|
114
|
+
<DropdownItem value="Delete" id="Delete">
|
|
115
|
+
Delete
|
|
116
|
+
</DropdownItem>
|
|
117
|
+
<DropdownItem value="Rename" id="Rename">
|
|
118
|
+
Rename
|
|
119
|
+
</DropdownItem>
|
|
120
|
+
<DropdownItem value="Archive" id="Archive">
|
|
121
|
+
Archive
|
|
122
|
+
</DropdownItem>
|
|
123
|
+
</DropdownList>
|
|
124
|
+
];
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// Reorganize conversations to show pinned ones at the top
|
|
128
|
+
const organizeConversations = () => {
|
|
129
|
+
const organized: { [key: string]: Conversation[] } = {};
|
|
130
|
+
const pinnedItems: Conversation[] = [];
|
|
131
|
+
|
|
132
|
+
// Collect all pinned conversations first
|
|
133
|
+
Object.entries(initialConversations).forEach(([_period, conversations]) => {
|
|
134
|
+
conversations.forEach((conv) => {
|
|
135
|
+
if (pinnedConversations.has(conv.id)) {
|
|
136
|
+
pinnedItems.push({
|
|
137
|
+
...conv,
|
|
138
|
+
menuItems: createMenuItems(conv.id),
|
|
139
|
+
icon: <ThumbtackIcon />
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Add pinned section if there are pinned items
|
|
146
|
+
if (pinnedItems.length > 0) {
|
|
147
|
+
organized.Pinned = pinnedItems;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Add unpinned conversations
|
|
151
|
+
Object.entries(initialConversations).forEach(([period, conversations]) => {
|
|
152
|
+
const unpinnedConversations = conversations
|
|
153
|
+
.filter((conv) => !pinnedConversations.has(conv.id))
|
|
154
|
+
.map((conv) => ({
|
|
155
|
+
...conv,
|
|
156
|
+
menuItems: createMenuItems(conv.id)
|
|
157
|
+
}));
|
|
158
|
+
|
|
159
|
+
if (unpinnedConversations.length > 0) {
|
|
160
|
+
organized[period] = unpinnedConversations;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
return organized;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const conversations = organizeConversations();
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<>
|
|
171
|
+
<Checkbox
|
|
172
|
+
label="Display drawer"
|
|
173
|
+
isChecked={isDrawerOpen}
|
|
174
|
+
onChange={() => setIsDrawerOpen(!isDrawerOpen)}
|
|
175
|
+
id="drawer-pin-visible"
|
|
176
|
+
name="drawer-pin-visible"
|
|
177
|
+
></Checkbox>
|
|
178
|
+
<Checkbox
|
|
179
|
+
label="Show compact version"
|
|
180
|
+
isChecked={isCompact}
|
|
181
|
+
onChange={() => setIsCompact(!isCompact)}
|
|
182
|
+
id="drawer-pin-compact"
|
|
183
|
+
name="drawer-pin-compact"
|
|
184
|
+
></Checkbox>
|
|
185
|
+
<ChatbotConversationHistoryNav
|
|
186
|
+
displayMode={displayMode}
|
|
187
|
+
onDrawerToggle={() => setIsDrawerOpen(!isDrawerOpen)}
|
|
188
|
+
isDrawerOpen={isDrawerOpen}
|
|
189
|
+
setIsDrawerOpen={setIsDrawerOpen}
|
|
190
|
+
conversations={conversations}
|
|
191
|
+
drawerContent={<div>Drawer content</div>}
|
|
192
|
+
isCompact={isCompact}
|
|
193
|
+
/>
|
|
194
|
+
</>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
@@ -68,7 +68,7 @@ import { MessageBar } from '@patternfly/chatbot/dist/dynamic/MessageBar';
|
|
|
68
68
|
import SourceDetailsMenuItem from '@patternfly/chatbot/dist/dynamic/SourceDetailsMenuItem';
|
|
69
69
|
import { ChatbotModal } from '@patternfly/chatbot/dist/dynamic/ChatbotModal';
|
|
70
70
|
import SettingsForm from '@patternfly/chatbot/dist/dynamic/Settings';
|
|
71
|
-
import { BellIcon, CalendarAltIcon, ClipboardIcon, CodeIcon, UploadIcon } from '@patternfly/react-icons';
|
|
71
|
+
import { BellIcon, CalendarAltIcon, ClipboardIcon, CodeIcon, ThumbtackIcon, UploadIcon } from '@patternfly/react-icons';
|
|
72
72
|
import { useDropzone } from 'react-dropzone';
|
|
73
73
|
|
|
74
74
|
import ChatbotConversationHistoryNav from '@patternfly/chatbot/dist/dynamic/ChatbotConversationHistoryNav';
|
|
@@ -361,6 +361,14 @@ Actions can be added to conversations with `menuItems`. Optionally, you can also
|
|
|
361
361
|
|
|
362
362
|
```
|
|
363
363
|
|
|
364
|
+
### Pinning conversations
|
|
365
|
+
|
|
366
|
+
To help users track important conversations, add a "pin" option to the conversation action menus. This action moves a conversation to a dedicated "pinned" section at the top of the history drawer for quick access. Pinned items should contain an "unpin" option, so that users can remove pinned conversations as needed.
|
|
367
|
+
|
|
368
|
+
```js file="./ChatbotHeaderDrawerWithPin.tsx"
|
|
369
|
+
|
|
370
|
+
```
|
|
371
|
+
|
|
364
372
|
### Drawer with active conversation
|
|
365
373
|
|
|
366
374
|
If you're showing a conversation that is already active, you can set the `activeItemId` prop on your `<ChatbotConversationHistoryNav>` to apply an active visual state.
|
|
@@ -44,7 +44,8 @@ ChatbotHeaderMenu,
|
|
|
44
44
|
ChatbotHeaderTitle,
|
|
45
45
|
ChatbotHeaderActions,
|
|
46
46
|
ChatbotHeaderSelectorDropdown,
|
|
47
|
-
ChatbotHeaderOptionsDropdown
|
|
47
|
+
ChatbotHeaderOptionsDropdown,
|
|
48
|
+
ChatbotHeaderCloseButton
|
|
48
49
|
} from '@patternfly/chatbot/dist/dynamic/ChatbotHeader';
|
|
49
50
|
|
|
50
51
|
import ExpandIcon from '@patternfly/react-icons/dist/esm/icons/expand-icon';
|
|
@@ -59,6 +60,7 @@ import userAvatar from '../Messages/user_avatar.svg';
|
|
|
59
60
|
import patternflyAvatar from '../Messages/patternfly_avatar.jpg';
|
|
60
61
|
import { getTrackingProviders } from "@patternfly/chatbot/dist/dynamic/tracking";
|
|
61
62
|
import { useEffect,useCallback, useRef, useState, FunctionComponent, MouseEvent } from 'react';
|
|
63
|
+
import saveAs from 'file-saver';
|
|
62
64
|
|
|
63
65
|
### Basic ChatBot
|
|
64
66
|
|
|
@@ -129,6 +131,22 @@ This demo displays a ChatBot in a static, inline drawer. This demo includes:
|
|
|
129
131
|
|
|
130
132
|
```
|
|
131
133
|
|
|
134
|
+
### Display mode switcher
|
|
135
|
+
|
|
136
|
+
This demo showcases how the ChatBot can be rendered in different display modes to suit various application layouts. It demonstrates how to dynamically change the page structure in response to the user's selection. This demo includes:
|
|
137
|
+
|
|
138
|
+
1. The ability to switch between overlay, drawer, and fullscreen modes using the [`<ChatbotHeaderOptionsDropdown>`](/patternfly-ai/chatbot/ui#header-options) in the header.
|
|
139
|
+
2. A conditional page layout that renders the ChatBot for each display mode option:
|
|
140
|
+
- **Overlay:** As a floating window on top of the page content.
|
|
141
|
+
- **Drawer:** Inside an inline PatternFly `<Drawer>` as a side panel.
|
|
142
|
+
- **Fullscreen:** As a top-level component that covers the entire screen for an embedded experience.
|
|
143
|
+
3. Logic to show or hide the `<ChatbotToggle>` button, which is only present in the default overlay mode.
|
|
144
|
+
4. A [basic ChatBot](#basic-chatbot) with a header, welcome prompt, and message bar to populate the different layouts.
|
|
145
|
+
|
|
146
|
+
```js file="./ChatbotDisplayMode.tsx" isFullscreen
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
|
|
132
150
|
### Comparing ChatBots
|
|
133
151
|
|
|
134
152
|
To let users compare how different ChatBots respond to the same prompt, you can add multiple ChatBots within the same window. The following demo illustrates a comparison view pattern that allows users to toggle between different conversations in a single ChatBot window.
|
|
@@ -149,3 +167,17 @@ Your code structure should look like this:
|
|
|
149
167
|
```js file="./EmbeddedComparisonChatbot.tsx" isFullscreen
|
|
150
168
|
|
|
151
169
|
```
|
|
170
|
+
|
|
171
|
+
### Chat transcripts
|
|
172
|
+
|
|
173
|
+
This demo illustrates how you could add downloadable transcripts to your ChatBot, which outline conversation details in a Markdown file. This approach allows users to easily share information from a conversation with others.
|
|
174
|
+
|
|
175
|
+
A message transcript includes details from a single chat message. To download a sample message transcript in this demo, click the "Download" action under a bot message.
|
|
176
|
+
|
|
177
|
+
A conversation transcript includes details from the entirety of a ChatBot conversation. To download a sample conversation transcript in this demo, open the chat history menu and click "Download" in the options menu for the conversation.
|
|
178
|
+
|
|
179
|
+
In this example, file download is implemented with [file-saver](https://www.npmjs.com/package/file-saver).
|
|
180
|
+
|
|
181
|
+
```js file="./ChatbotTranscripts.tsx" isFullscreen
|
|
182
|
+
|
|
183
|
+
```
|