@patternfly/chatbot 6.9.0-prerelease.1 → 6.9.0-prerelease.3
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.js +1 -1
- package/dist/cjs/MessageBar/MessageBar.js +1 -1
- package/dist/cjs/MessageBar/SendButton.js +2 -2
- package/dist/cjs/SourcesCard/SourcesCard.d.ts +2 -0
- package/dist/cjs/SourcesCardBase/SourcesCardBase.d.ts +2 -0
- package/dist/cjs/SourcesCardBase/SourcesCardBase.js +2 -2
- package/dist/css/main.css +163 -57
- package/dist/css/main.css.map +1 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +1 -1
- package/dist/esm/MessageBar/MessageBar.js +1 -1
- package/dist/esm/MessageBar/SendButton.js +2 -2
- package/dist/esm/SourcesCard/SourcesCard.d.ts +2 -0
- package/dist/esm/SourcesCardBase/SourcesCardBase.d.ts +2 -0
- package/dist/esm/SourcesCardBase/SourcesCardBase.js +2 -2
- package/package.json +3 -3
- package/patternfly-docs/content/extensions/chatbot/chatbot.md +1 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Analytics/Analytics.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +31 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +2 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Canvas.md +110 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Canvas.tsx +609 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +25 -3
- package/patternfly-docs/patternfly-docs.config.js +1 -1
- package/src/Canvas/Canvas.scss +138 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +91 -77
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +13 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +1 -0
- package/src/MessageBar/AttachButton.scss +4 -21
- package/src/MessageBar/MessageBar.test.tsx +3 -0
- package/src/MessageBar/MessageBar.tsx +2 -0
- package/src/MessageBar/SendButton.scss +1 -32
- package/src/MessageBar/SendButton.tsx +2 -2
- package/src/SourcesCard/SourcesCard.scss +6 -0
- package/src/SourcesCard/SourcesCard.test.tsx +16 -0
- package/src/SourcesCard/SourcesCard.tsx +2 -0
- package/src/SourcesCardBase/SourcesCardBase.test.tsx +62 -0
- package/src/SourcesCardBase/SourcesCardBase.tsx +8 -0
- package/src/main.scss +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/chatbot",
|
|
3
|
-
"version": "6.9.0-prerelease.
|
|
3
|
+
"version": "6.9.0-prerelease.3",
|
|
4
4
|
"description": "This library provides React components based on PatternFly 6 that can be used to build chatbots.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@patternfly/react-code-editor": "^6.6.0",
|
|
37
37
|
"@patternfly/react-core": "^6.6.0",
|
|
38
|
-
"@patternfly/react-icons": "
|
|
38
|
+
"@patternfly/react-icons": "6.6.1-prerelease.2",
|
|
39
39
|
"@patternfly/react-styles": "^6.6.0",
|
|
40
40
|
"@patternfly/react-table": "^6.6.0",
|
|
41
41
|
"@segment/analytics-next": "^1.76.0",
|
|
42
42
|
"clsx": "^2.1.0",
|
|
43
43
|
"path-browserify": "^1.0.1",
|
|
44
|
-
"posthog-js": "^1.
|
|
44
|
+
"posthog-js": "^1.298.0",
|
|
45
45
|
"react-markdown": "^9.0.1",
|
|
46
46
|
"rehype-external-links": "^3.0.0",
|
|
47
47
|
"rehype-highlight": "^7.0.0",
|
|
@@ -49,6 +49,7 @@ Explore our documentation, which covers both the components you'll need to build
|
|
|
49
49
|
- [Primary color background](/extensions/chatbot/overview/demo#primary-color-background)
|
|
50
50
|
- [Display mode switcher](/extensions/chatbot/overview/demo#display-mode-switcher)
|
|
51
51
|
- [Chat transcripts](/extensions/chatbot/overview/demo#chat-transcripts)
|
|
52
|
+
- [Canvas](/patterns/canvas/demo)
|
|
52
53
|
- [Analytics](/extensions/chatbot/analytics): Tracking for ChatBot interactions
|
|
53
54
|
- [Customizing messages](/extensions/chatbot/customizing-messages): Details for the implementation of custom messages
|
|
54
55
|
- [Tree-shaking](/extensions/chatbot/tree-shaking): Bundle size optimization and import best practices
|
|
@@ -98,7 +98,7 @@ When using the providers, you might need to add additional dependencies to your
|
|
|
98
98
|
```nolive
|
|
99
99
|
"dependencies": {
|
|
100
100
|
"@segment/analytics-next": "^1.76.0",
|
|
101
|
-
"posthog-js": "^1.
|
|
101
|
+
"posthog-js": "^1.298.0"
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
Depending on your local setup, this might not be necessary. For example, if you pull the ChatBot codebase as a dependency into your project, you don't need to add it as an additional dependency in your package.json.
|
|
@@ -78,6 +78,37 @@ export const MessageWithSourcesExample: FunctionComponent = () => {
|
|
|
78
78
|
]
|
|
79
79
|
}}
|
|
80
80
|
/>
|
|
81
|
+
<Message
|
|
82
|
+
name="Bot"
|
|
83
|
+
role="bot"
|
|
84
|
+
content="This example has a PatternFly label above the title:"
|
|
85
|
+
sources={{
|
|
86
|
+
sources: [
|
|
87
|
+
{
|
|
88
|
+
title: 'Getting started with Red Hat OpenShift',
|
|
89
|
+
link: '#',
|
|
90
|
+
body: 'Red Hat OpenShift on IBM Cloud is a managed offering to create your own cluster of compute hosts where you can deploy and manage containerized apps on IBM Cloud ...',
|
|
91
|
+
isExternal: true,
|
|
92
|
+
headerContent: <Label>Documentation</Label>
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
title: 'Azure Red Hat OpenShift documentation',
|
|
96
|
+
link: '#',
|
|
97
|
+
body: 'Microsoft Azure Red Hat OpenShift allows you to deploy a production ready Red Hat OpenShift cluster in Azure ...',
|
|
98
|
+
isExternal: true,
|
|
99
|
+
headerContent: <Label>Knowledge base</Label>
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
title: 'OKD Documentation: Home',
|
|
103
|
+
link: '#',
|
|
104
|
+
body: 'OKD is a distribution of Kubernetes optimized for continuous application development and multi-tenant deployment. OKD also serves as the upstream code base upon ...',
|
|
105
|
+
isExternal: true,
|
|
106
|
+
headerContent: <Label>Tutorial</Label>
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
onSetPage
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
81
112
|
<Message
|
|
82
113
|
name="Bot"
|
|
83
114
|
role="bot"
|
|
@@ -237,6 +237,8 @@ If a source will open outside of the ChatBot window, add an external link icon v
|
|
|
237
237
|
|
|
238
238
|
The API for a source requires a link at minimum, but we strongly recommend providing a more descriptive title and body description so users have enough context. For the best clarity and readability, we strongly recommend limiting the title to 1 line and the body to 2 lines. If the body description is more than 2 lines, use the "long sources" or "very long sources" variant.
|
|
239
239
|
|
|
240
|
+
To display extra content above a source title, such as a [PatternFly label](/components/label), pass `headerContent`.
|
|
241
|
+
|
|
240
242
|
```js file="./MessageWithSources.tsx"
|
|
241
243
|
|
|
242
244
|
```
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Canvas
|
|
3
|
+
section: patterns
|
|
4
|
+
source: demo
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { useState, useRef, useCallback, useEffect, FunctionComponent, ReactNode } from 'react';
|
|
8
|
+
import {
|
|
9
|
+
Brand,
|
|
10
|
+
Divider,
|
|
11
|
+
Drawer,
|
|
12
|
+
DrawerActions,
|
|
13
|
+
DrawerCloseButton,
|
|
14
|
+
DrawerContent,
|
|
15
|
+
DrawerContentBody,
|
|
16
|
+
DrawerHead,
|
|
17
|
+
DrawerPanelContent,
|
|
18
|
+
DropdownItem,
|
|
19
|
+
DropdownList,
|
|
20
|
+
Flex,
|
|
21
|
+
FlexItem,
|
|
22
|
+
Label,
|
|
23
|
+
MenuToggle,
|
|
24
|
+
Popover,
|
|
25
|
+
Select,
|
|
26
|
+
SelectList,
|
|
27
|
+
SelectOption,
|
|
28
|
+
Title,
|
|
29
|
+
Tooltip
|
|
30
|
+
} from '@patternfly/react-core';
|
|
31
|
+
import { CodeEditor, CodeEditorControl, Language } from '@patternfly/react-code-editor';
|
|
32
|
+
import Chatbot, { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot';
|
|
33
|
+
import ChatbotContent from '@patternfly/chatbot/dist/dynamic/ChatbotContent';
|
|
34
|
+
import ChatbotFooter, { ChatbotFootnote } from '@patternfly/chatbot/dist/dynamic/ChatbotFooter';
|
|
35
|
+
import MessageBar from '@patternfly/chatbot/dist/dynamic/MessageBar';
|
|
36
|
+
import MessageBox from '@patternfly/chatbot/dist/dynamic/MessageBox';
|
|
37
|
+
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
38
|
+
import ChatbotConversationHistoryNav from '@patternfly/chatbot/dist/dynamic/ChatbotConversationHistoryNav';
|
|
39
|
+
import ChatbotHeader, {
|
|
40
|
+
ChatbotHeaderActions,
|
|
41
|
+
ChatbotHeaderCloseButton,
|
|
42
|
+
ChatbotHeaderMain,
|
|
43
|
+
ChatbotHeaderMenu,
|
|
44
|
+
ChatbotHeaderTitle
|
|
45
|
+
} from '@patternfly/chatbot/dist/dynamic/ChatbotHeader';
|
|
46
|
+
import RhUiImageFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-image-fill-icon';
|
|
47
|
+
import RhUiAddIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-add-icon';
|
|
48
|
+
import RhUiTaskFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-task-fill-icon';
|
|
49
|
+
import RhUiNotificationFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-notification-fill-icon';
|
|
50
|
+
import RhUiCalendarFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-calendar-fill-icon';
|
|
51
|
+
import RhUiExportIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-export-icon';
|
|
52
|
+
import RhUiRedoIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-redo-icon';
|
|
53
|
+
import RhUiUndoIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-undo-icon';
|
|
54
|
+
import RhUiServerUploadFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-server-upload-fill-icon';
|
|
55
|
+
import RhUiAiEditIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-ai-edit-icon';
|
|
56
|
+
import RhUiAiInfoIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-ai-info-icon';
|
|
57
|
+
import { useDropzone } from 'react-dropzone';
|
|
58
|
+
import PFIconLogoColor from '../UI/PF-IconLogo-Color.svg';
|
|
59
|
+
import PFIconLogoReverse from '../UI/PF-IconLogo-Reverse.svg';
|
|
60
|
+
import userAvatar from '../Messages/user_avatar.svg';
|
|
61
|
+
|
|
62
|
+
**Canvas** lets users work with generated or editable content alongside a conversation. Canvas content is fully flexible, allowing you to render any content suitable for your use case. It is recommended to only utilize canvas mode with a fullscreen Chatbot.
|
|
63
|
+
|
|
64
|
+
## Composable structure
|
|
65
|
+
|
|
66
|
+
When utilizing a canvas layout, it's recommended to use a PatternFly [drawer](/components/drawer). You must apply the `pf-chatbot__canvas*` classes from `@patternfly/chatbot` so the drawer matches ChatBot backgrounds and fills the fullscreen layout.
|
|
67
|
+
|
|
68
|
+
The general recommended structure is as follows:
|
|
69
|
+
|
|
70
|
+
```noLive
|
|
71
|
+
<Chatbot displayMode={ChatbotDisplayMode.fullscreen}>
|
|
72
|
+
<div className="pf-chatbot__canvas">
|
|
73
|
+
<Drawer className="pf-chatbot__canvas-drawer" isExpanded={...} isInline position="end">
|
|
74
|
+
<DrawerContent panelContent={/* CodeEditor or other canvas content */}>
|
|
75
|
+
<DrawerContentBody className="pf-chatbot__canvas-body">
|
|
76
|
+
<div className="pf-chatbot__canvas-column">
|
|
77
|
+
<ChatbotHeader .../>
|
|
78
|
+
<ChatbotContent ... />
|
|
79
|
+
<ChatbotFooter ... >
|
|
80
|
+
</div>
|
|
81
|
+
</DrawerContentBody>
|
|
82
|
+
</DrawerContent>
|
|
83
|
+
</Drawer>
|
|
84
|
+
</div>
|
|
85
|
+
</Chatbot>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Class names
|
|
89
|
+
|
|
90
|
+
| Class name | Purpose |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| `pf-chatbot__canvas` | Container for the fullscreen canvas layout and its background. |
|
|
93
|
+
| `pf-chatbot__canvas-drawer` | Styles the drawer that contains the canvas panel. |
|
|
94
|
+
| `pf-chatbot__canvas-section` | Styles the section used within the drawer for focus. |
|
|
95
|
+
| `pf-chatbot__canvas-body` | Ensures the drawer content body fills the available height. |
|
|
96
|
+
| `pf-chatbot__canvas-column` | Arranges the canvas header, content, and footer vertically. |
|
|
97
|
+
| `pf-chatbot__canvas-panel` | Styles the canvas drawer panel and removes the default panel spacing. |
|
|
98
|
+
| `pf-chatbot__canvas-panel-body` | Provides the canvas panel content area and its spacing. |
|
|
99
|
+
| `pf-chatbot__canvas-head` | Styles and positions the canvas panel header and close action. |
|
|
100
|
+
| `pf-chatbot__canvas-editor` | Makes the code editor fill the available canvas space. |
|
|
101
|
+
|
|
102
|
+
## Demos
|
|
103
|
+
|
|
104
|
+
### With code editor
|
|
105
|
+
|
|
106
|
+
This demo shows canvas mode being used to render a PatternFly [code editor](/components/code-editor). Canvas mode is launched by clicking a file chip below a message or the "Canvas" label below the message bar. You can also enable or disable canvas mode from the attach menu and dismiss the label to exit canvas mode.
|
|
107
|
+
|
|
108
|
+
```js file="./Canvas.tsx" isFullscreen
|
|
109
|
+
|
|
110
|
+
```
|