@patternfly/chatbot 2.2.0-prerelease.1 → 2.2.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/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +19 -1
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +11 -11
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +39 -3
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.d.ts +17 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.js +14 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.d.ts +2 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.js +2 -2
- package/dist/cjs/ChatbotHeader/index.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/index.js +1 -0
- package/dist/cjs/CodeModal/CodeModal.js +2 -12
- package/dist/cjs/Compare/Compare.d.ts +17 -0
- package/dist/cjs/Compare/Compare.js +50 -0
- package/dist/cjs/Compare/Compare.test.d.ts +1 -0
- package/dist/cjs/Compare/Compare.test.js +20 -0
- package/dist/cjs/Compare/index.d.ts +2 -0
- package/dist/cjs/Compare/index.js +23 -0
- package/dist/cjs/Message/ListMessage/OrderedListMessage.d.ts +1 -1
- package/dist/cjs/Message/ListMessage/OrderedListMessage.js +2 -2
- package/dist/cjs/Message/Message.d.ts +16 -6
- package/dist/cjs/Message/Message.js +6 -6
- package/dist/cjs/Message/Message.test.js +51 -0
- package/dist/cjs/Message/QuickResponse/QuickResponse.d.ts +15 -0
- package/dist/cjs/Message/QuickResponse/QuickResponse.js +33 -0
- package/dist/cjs/Message/QuickStarts/FallbackImg.d.ts +13 -0
- package/dist/cjs/Message/QuickStarts/FallbackImg.js +34 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTile.d.ts +27 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTile.js +82 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTileDescription.d.ts +23 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTileDescription.js +64 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTileDescription.test.d.ts +1 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTileDescription.test.js +76 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTileHeader.d.ts +11 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTileHeader.js +30 -0
- package/dist/cjs/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.d.ts +30 -0
- package/dist/cjs/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.js +77 -0
- package/dist/cjs/Message/QuickStarts/monitor-sampleapp-quickstart.d.ts +30 -0
- package/dist/cjs/Message/QuickStarts/monitor-sampleapp-quickstart.js +77 -0
- package/dist/cjs/Message/QuickStarts/types.d.ts +132 -0
- package/dist/cjs/Message/QuickStarts/types.js +17 -0
- package/dist/cjs/ResponseActions/ResponseActionButton.d.ts +6 -0
- package/dist/cjs/ResponseActions/ResponseActionButton.js +10 -2
- package/dist/cjs/ResponseActions/ResponseActionButton.test.d.ts +1 -0
- package/dist/cjs/ResponseActions/ResponseActionButton.test.js +54 -0
- package/dist/cjs/ResponseActions/ResponseActions.d.ts +4 -0
- package/dist/cjs/ResponseActions/ResponseActions.js +26 -9
- package/dist/cjs/ResponseActions/ResponseActions.test.js +79 -5
- package/dist/cjs/Settings/SettingsForm.d.ts +13 -0
- package/dist/cjs/Settings/SettingsForm.js +27 -0
- package/dist/cjs/Settings/index.d.ts +2 -0
- package/dist/cjs/Settings/index.js +23 -0
- package/dist/cjs/TermsOfUse/TermsOfUse.d.ts +34 -0
- package/dist/cjs/TermsOfUse/TermsOfUse.js +49 -0
- package/dist/cjs/TermsOfUse/TermsOfUse.test.d.ts +1 -0
- package/dist/cjs/TermsOfUse/TermsOfUse.test.js +79 -0
- package/dist/cjs/TermsOfUse/index.d.ts +2 -0
- package/dist/cjs/TermsOfUse/index.js +23 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +10 -1
- package/dist/css/main.css +244 -18
- package/dist/css/main.css.map +1 -1
- package/dist/dynamic/Compare/package.json +1 -0
- package/dist/dynamic/Settings/package.json +1 -0
- package/dist/dynamic/TermsOfUse/package.json +1 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +19 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +11 -11
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +39 -3
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.d.ts +17 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.js +8 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.d.ts +2 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +2 -2
- package/dist/esm/ChatbotHeader/index.d.ts +1 -0
- package/dist/esm/ChatbotHeader/index.js +1 -0
- package/dist/esm/CodeModal/CodeModal.js +2 -12
- package/dist/esm/Compare/Compare.d.ts +17 -0
- package/dist/esm/Compare/Compare.js +43 -0
- package/dist/esm/Compare/Compare.test.d.ts +1 -0
- package/dist/esm/Compare/Compare.test.js +15 -0
- package/dist/esm/Compare/index.d.ts +2 -0
- package/dist/esm/Compare/index.js +2 -0
- package/dist/esm/Message/ListMessage/OrderedListMessage.d.ts +1 -1
- package/dist/esm/Message/ListMessage/OrderedListMessage.js +2 -2
- package/dist/esm/Message/Message.d.ts +16 -6
- package/dist/esm/Message/Message.js +7 -7
- package/dist/esm/Message/Message.test.js +51 -0
- package/dist/esm/Message/QuickResponse/QuickResponse.d.ts +15 -0
- package/dist/esm/Message/QuickResponse/QuickResponse.js +26 -0
- package/dist/esm/Message/QuickStarts/FallbackImg.d.ts +13 -0
- package/dist/esm/Message/QuickStarts/FallbackImg.js +9 -0
- package/dist/esm/Message/QuickStarts/QuickStartTile.d.ts +27 -0
- package/dist/esm/Message/QuickStarts/QuickStartTile.js +52 -0
- package/dist/esm/Message/QuickStarts/QuickStartTileDescription.d.ts +23 -0
- package/dist/esm/Message/QuickStarts/QuickStartTileDescription.js +35 -0
- package/dist/esm/Message/QuickStarts/QuickStartTileDescription.test.d.ts +1 -0
- package/dist/esm/Message/QuickStarts/QuickStartTileDescription.test.js +48 -0
- package/dist/esm/Message/QuickStarts/QuickStartTileHeader.d.ts +11 -0
- package/dist/esm/Message/QuickStarts/QuickStartTileHeader.js +5 -0
- package/dist/esm/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.d.ts +30 -0
- package/dist/esm/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.js +74 -0
- package/dist/esm/Message/QuickStarts/monitor-sampleapp-quickstart.d.ts +30 -0
- package/dist/esm/Message/QuickStarts/monitor-sampleapp-quickstart.js +74 -0
- package/dist/esm/Message/QuickStarts/types.d.ts +132 -0
- package/dist/esm/Message/QuickStarts/types.js +14 -0
- package/dist/esm/ResponseActions/ResponseActionButton.d.ts +6 -0
- package/dist/esm/ResponseActions/ResponseActionButton.js +10 -2
- package/dist/esm/ResponseActions/ResponseActionButton.test.d.ts +1 -0
- package/dist/esm/ResponseActions/ResponseActionButton.test.js +49 -0
- package/dist/esm/ResponseActions/ResponseActions.d.ts +4 -0
- package/dist/esm/ResponseActions/ResponseActions.js +26 -9
- package/dist/esm/ResponseActions/ResponseActions.test.js +79 -5
- package/dist/esm/Settings/SettingsForm.d.ts +13 -0
- package/dist/esm/Settings/SettingsForm.js +20 -0
- package/dist/esm/Settings/index.d.ts +2 -0
- package/dist/esm/Settings/index.js +2 -0
- package/dist/esm/TermsOfUse/TermsOfUse.d.ts +34 -0
- package/dist/esm/TermsOfUse/TermsOfUse.js +42 -0
- package/dist/esm/TermsOfUse/TermsOfUse.test.d.ts +1 -0
- package/dist/esm/TermsOfUse/TermsOfUse.test.js +74 -0
- package/dist/esm/TermsOfUse/index.d.ts +2 -0
- package/dist/esm/TermsOfUse/index.js +2 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +6 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -13
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithCustomResponseActions.tsx +4 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickStart.tsx +31 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +26 -4
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/explore-pipeline-quickstart.ts +65 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotFooter.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotFootnote.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerNavigation.tsx +67 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerResizable.tsx +94 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithSelection.tsx +78 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/PF-TermsAndConditionsHeader.svg +148 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/Settings.tsx +289 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/SquareChatbotToggle.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/UI/TermsOfUse.tsx +147 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +54 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +26 -3
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachment.tsx +20 -19
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachmentMenu.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedChatbot.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedComparisonChatbot.tsx +206 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +14 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +112 -3
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +46 -9
- package/src/ChatbotFooter/ChatbotFooter.scss +2 -1
- package/src/ChatbotHeader/ChatbotHeaderCloseButton.tsx +51 -0
- package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +5 -2
- package/src/ChatbotHeader/index.ts +1 -0
- package/src/CodeModal/CodeModal.scss +8 -0
- package/src/CodeModal/CodeModal.tsx +2 -13
- package/src/Compare/Compare.scss +72 -0
- package/src/Compare/Compare.test.tsx +31 -0
- package/src/Compare/Compare.tsx +98 -0
- package/src/Compare/index.ts +2 -0
- package/src/FileDropZone/__snapshots__/FileDropZone.test.tsx.snap +1 -1
- package/src/Message/ListMessage/OrderedListMessage.tsx +2 -2
- package/src/Message/Message.scss +0 -14
- package/src/Message/Message.test.tsx +76 -0
- package/src/Message/Message.tsx +35 -26
- package/src/Message/QuickResponse/QuickResponse.scss +33 -0
- package/src/Message/QuickResponse/QuickResponse.tsx +50 -0
- package/src/Message/QuickStarts/FallbackImg.tsx +24 -0
- package/src/Message/QuickStarts/QuickStartTile.scss +25 -0
- package/src/Message/QuickStarts/QuickStartTile.tsx +147 -0
- package/src/Message/QuickStarts/QuickStartTileDescription.test.tsx +57 -0
- package/src/Message/QuickStarts/QuickStartTileDescription.tsx +81 -0
- package/src/Message/QuickStarts/QuickStartTileHeader.tsx +21 -0
- package/src/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.ts +75 -0
- package/src/Message/QuickStarts/monitor-sampleapp-quickstart.ts +75 -0
- package/src/Message/QuickStarts/types.ts +154 -0
- package/src/ResponseActions/ResponseActionButton.test.tsx +52 -0
- package/src/ResponseActions/ResponseActionButton.tsx +46 -27
- package/src/ResponseActions/ResponseActions.scss +10 -8
- package/src/ResponseActions/ResponseActions.test.tsx +103 -5
- package/src/ResponseActions/ResponseActions.tsx +54 -7
- package/src/Settings/Settings.scss +34 -0
- package/src/Settings/SettingsForm.tsx +25 -0
- package/src/Settings/index.ts +3 -0
- package/src/TermsOfUse/TermsOfUse.scss +66 -0
- package/src/TermsOfUse/TermsOfUse.test.tsx +138 -0
- package/src/TermsOfUse/TermsOfUse.tsx +117 -0
- package/src/TermsOfUse/index.ts +3 -0
- package/src/index.ts +9 -0
- package/src/main.scss +5 -0
@@ -0,0 +1,289 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
|
3
|
+
import SettingsForm from '@patternfly/chatbot/dist/dynamic/Settings';
|
4
|
+
import {
|
5
|
+
Button,
|
6
|
+
Divider,
|
7
|
+
Dropdown,
|
8
|
+
DropdownGroup,
|
9
|
+
DropdownItem,
|
10
|
+
DropdownList,
|
11
|
+
MenuToggle,
|
12
|
+
MenuToggleElement,
|
13
|
+
Switch,
|
14
|
+
Title
|
15
|
+
} from '@patternfly/react-core';
|
16
|
+
import Chatbot, { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot';
|
17
|
+
import ChatbotHeader, {
|
18
|
+
ChatbotHeaderActions,
|
19
|
+
ChatbotHeaderCloseButton,
|
20
|
+
ChatbotHeaderMain,
|
21
|
+
ChatbotHeaderOptionsDropdown,
|
22
|
+
ChatbotHeaderTitle
|
23
|
+
} from '@patternfly/chatbot/dist/dynamic/ChatbotHeader';
|
24
|
+
import { CogIcon, ExpandIcon, OpenDrawerRightIcon, OutlinedWindowRestoreIcon } from '@patternfly/react-icons';
|
25
|
+
|
26
|
+
export const SettingsDemo: React.FunctionComponent = () => {
|
27
|
+
const [isChecked, setIsChecked] = React.useState<boolean>(true);
|
28
|
+
const [isThemeOpen, setIsThemeOpen] = React.useState(false);
|
29
|
+
const [isLanguageOpen, setIsLanguageOpen] = React.useState(false);
|
30
|
+
const [isVoiceOpen, setIsVoiceOpen] = React.useState(false);
|
31
|
+
const [displayMode, setDisplayMode] = React.useState(ChatbotDisplayMode.default);
|
32
|
+
const [areSettingsOpen, setAreSettingsOpen] = React.useState(true);
|
33
|
+
const chatbotVisible = true;
|
34
|
+
|
35
|
+
const onFocus = (id: string) => {
|
36
|
+
const element = document.getElementById(id);
|
37
|
+
(element as HTMLElement).focus();
|
38
|
+
};
|
39
|
+
|
40
|
+
const onThemeToggleClick = () => {
|
41
|
+
setIsThemeOpen(!isThemeOpen);
|
42
|
+
};
|
43
|
+
|
44
|
+
const onThemeSelect = (
|
45
|
+
_event: React.MouseEvent<Element, MouseEvent> | undefined,
|
46
|
+
value: string | number | undefined
|
47
|
+
) => {
|
48
|
+
// eslint-disable-next-line no-console
|
49
|
+
console.log('selected', value);
|
50
|
+
onFocus('theme');
|
51
|
+
setIsThemeOpen(false);
|
52
|
+
};
|
53
|
+
|
54
|
+
const onLanguageToggleClick = () => {
|
55
|
+
setIsLanguageOpen(!isLanguageOpen);
|
56
|
+
};
|
57
|
+
|
58
|
+
const onLanguageSelect = (
|
59
|
+
_event: React.MouseEvent<Element, MouseEvent> | undefined,
|
60
|
+
value: string | number | undefined
|
61
|
+
) => {
|
62
|
+
// eslint-disable-next-line no-console
|
63
|
+
console.log('selected', value);
|
64
|
+
onFocus('language');
|
65
|
+
setIsLanguageOpen(false);
|
66
|
+
};
|
67
|
+
|
68
|
+
const onVoiceToggleClick = () => {
|
69
|
+
onFocus('voice');
|
70
|
+
setIsVoiceOpen(!isVoiceOpen);
|
71
|
+
};
|
72
|
+
|
73
|
+
const onVoiceSelect = (
|
74
|
+
_event: React.MouseEvent<Element, MouseEvent> | undefined,
|
75
|
+
value: string | number | undefined
|
76
|
+
) => {
|
77
|
+
// eslint-disable-next-line no-console
|
78
|
+
console.log('selected', value);
|
79
|
+
setIsVoiceOpen(false);
|
80
|
+
};
|
81
|
+
|
82
|
+
const handleChange = (_event: React.FormEvent<HTMLInputElement>, checked: boolean) => {
|
83
|
+
setIsChecked(checked);
|
84
|
+
};
|
85
|
+
|
86
|
+
const themeDropdown = (
|
87
|
+
<Dropdown
|
88
|
+
isOpen={isThemeOpen}
|
89
|
+
onSelect={onThemeSelect}
|
90
|
+
onOpenChange={(isOpen: boolean) => setIsThemeOpen(isOpen)}
|
91
|
+
shouldFocusToggleOnSelect
|
92
|
+
shouldFocusFirstItemOnOpen
|
93
|
+
shouldPreventScrollOnItemFocus
|
94
|
+
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
|
95
|
+
// We want to add the id property here as well so the label is coupled
|
96
|
+
// with the button on screen readers.
|
97
|
+
<MenuToggle id="theme" ref={toggleRef} onClick={onThemeToggleClick} isExpanded={isThemeOpen}>
|
98
|
+
System
|
99
|
+
</MenuToggle>
|
100
|
+
)}
|
101
|
+
ouiaId="ThemeDropdown"
|
102
|
+
>
|
103
|
+
<DropdownList>
|
104
|
+
<DropdownItem value="System" key="system">
|
105
|
+
System
|
106
|
+
</DropdownItem>
|
107
|
+
</DropdownList>
|
108
|
+
</Dropdown>
|
109
|
+
);
|
110
|
+
|
111
|
+
const languageDropdown = (
|
112
|
+
<Dropdown
|
113
|
+
isOpen={isLanguageOpen}
|
114
|
+
onSelect={onLanguageSelect}
|
115
|
+
onOpenChange={(isOpen: boolean) => setIsLanguageOpen(isOpen)}
|
116
|
+
shouldFocusToggleOnSelect
|
117
|
+
shouldFocusFirstItemOnOpen
|
118
|
+
shouldPreventScrollOnItemFocus
|
119
|
+
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
|
120
|
+
// We want to add the id property here as well so the label is coupled
|
121
|
+
// with the button on screen readers.
|
122
|
+
<MenuToggle id="language" ref={toggleRef} onClick={onLanguageToggleClick} isExpanded={isLanguageOpen}>
|
123
|
+
Auto-detect
|
124
|
+
</MenuToggle>
|
125
|
+
)}
|
126
|
+
ouiaId="LanguageDropdown"
|
127
|
+
>
|
128
|
+
<DropdownList>
|
129
|
+
<DropdownItem value="Auto-detect" key="auto-detect">
|
130
|
+
Auto-detect
|
131
|
+
</DropdownItem>
|
132
|
+
</DropdownList>
|
133
|
+
</Dropdown>
|
134
|
+
);
|
135
|
+
const voiceDropdown = (
|
136
|
+
<Dropdown
|
137
|
+
isOpen={isVoiceOpen}
|
138
|
+
onSelect={onVoiceSelect}
|
139
|
+
onOpenChange={(isOpen: boolean) => setIsVoiceOpen(isOpen)}
|
140
|
+
shouldFocusToggleOnSelect
|
141
|
+
shouldFocusFirstItemOnOpen
|
142
|
+
shouldPreventScrollOnItemFocus
|
143
|
+
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
|
144
|
+
// We want to add the id property here as well so the label is coupled
|
145
|
+
// with the button on screen readers.
|
146
|
+
<MenuToggle id="voice" ref={toggleRef} onClick={onVoiceToggleClick} isExpanded={isVoiceOpen}>
|
147
|
+
Bot
|
148
|
+
</MenuToggle>
|
149
|
+
)}
|
150
|
+
ouiaId="VoiceDropdown"
|
151
|
+
>
|
152
|
+
<DropdownList>
|
153
|
+
<DropdownItem value="Bot" key="bot">
|
154
|
+
Bot
|
155
|
+
</DropdownItem>
|
156
|
+
</DropdownList>
|
157
|
+
</Dropdown>
|
158
|
+
);
|
159
|
+
const children = [
|
160
|
+
{ id: 'theme', label: 'Theme', field: themeDropdown },
|
161
|
+
{ id: 'language', label: 'Language', field: languageDropdown },
|
162
|
+
{ id: 'voice', label: 'Voice', field: voiceDropdown },
|
163
|
+
{
|
164
|
+
id: 'analytics',
|
165
|
+
label: 'Share analytics',
|
166
|
+
field: (
|
167
|
+
<Switch
|
168
|
+
// We want to add the id property here as well so the label is coupled
|
169
|
+
// with the button on screen readers.
|
170
|
+
id="analytics"
|
171
|
+
aria-label="Togglable option for whether to share analytics"
|
172
|
+
isChecked={isChecked}
|
173
|
+
onChange={handleChange}
|
174
|
+
/>
|
175
|
+
)
|
176
|
+
},
|
177
|
+
{
|
178
|
+
id: 'archived-chat',
|
179
|
+
label: 'Archive chat',
|
180
|
+
field: (
|
181
|
+
// We want to add the id property here as well so the label is coupled
|
182
|
+
// with the button on screen readers.
|
183
|
+
<Button id="archived-chat" variant="secondary">
|
184
|
+
Manage
|
185
|
+
</Button>
|
186
|
+
)
|
187
|
+
},
|
188
|
+
{
|
189
|
+
id: 'archive-all',
|
190
|
+
label: 'Archive all chat',
|
191
|
+
field: (
|
192
|
+
// We want to add the id property here as well so the label is coupled
|
193
|
+
// with the button on screen readers.
|
194
|
+
<Button id="archive-all" variant="secondary">
|
195
|
+
Archive all
|
196
|
+
</Button>
|
197
|
+
)
|
198
|
+
},
|
199
|
+
{
|
200
|
+
id: 'delete-all',
|
201
|
+
label: 'Delete all chats',
|
202
|
+
field: (
|
203
|
+
// We want to add the id property here as well so the label is coupled
|
204
|
+
// with the button on screen readers.
|
205
|
+
<Button id="delete-all" variant="danger">
|
206
|
+
Delete all
|
207
|
+
</Button>
|
208
|
+
)
|
209
|
+
}
|
210
|
+
];
|
211
|
+
|
212
|
+
const onSelectDropdownItem = (
|
213
|
+
_event: React.MouseEvent<Element, MouseEvent> | undefined,
|
214
|
+
value: string | number | undefined
|
215
|
+
) => {
|
216
|
+
if (value === 'Settings') {
|
217
|
+
setAreSettingsOpen(true);
|
218
|
+
} else {
|
219
|
+
setDisplayMode(value as ChatbotDisplayMode);
|
220
|
+
}
|
221
|
+
};
|
222
|
+
|
223
|
+
const regularChatbot = (
|
224
|
+
<ChatbotHeader>
|
225
|
+
<ChatbotHeaderActions>
|
226
|
+
<ChatbotHeaderOptionsDropdown onSelect={onSelectDropdownItem}>
|
227
|
+
<DropdownGroup label="Display mode">
|
228
|
+
<DropdownList>
|
229
|
+
<DropdownItem
|
230
|
+
value={ChatbotDisplayMode.default}
|
231
|
+
key="switchDisplayOverlay"
|
232
|
+
icon={<OutlinedWindowRestoreIcon aria-hidden />}
|
233
|
+
isSelected={displayMode === ChatbotDisplayMode.default}
|
234
|
+
>
|
235
|
+
<span>Overlay</span>
|
236
|
+
</DropdownItem>
|
237
|
+
<DropdownItem
|
238
|
+
value={ChatbotDisplayMode.docked}
|
239
|
+
key="switchDisplayDock"
|
240
|
+
icon={<OpenDrawerRightIcon aria-hidden />}
|
241
|
+
isSelected={displayMode === ChatbotDisplayMode.docked}
|
242
|
+
>
|
243
|
+
<span>Dock to window</span>
|
244
|
+
</DropdownItem>
|
245
|
+
<DropdownItem
|
246
|
+
value={ChatbotDisplayMode.fullscreen}
|
247
|
+
key="switchDisplayFullscreen"
|
248
|
+
icon={<ExpandIcon aria-hidden />}
|
249
|
+
isSelected={displayMode === ChatbotDisplayMode.fullscreen}
|
250
|
+
>
|
251
|
+
<span>Fullscreen</span>
|
252
|
+
</DropdownItem>
|
253
|
+
</DropdownList>
|
254
|
+
</DropdownGroup>
|
255
|
+
<Divider />
|
256
|
+
<DropdownList>
|
257
|
+
<DropdownItem value="Settings" key="switchSettings" icon={<CogIcon aria-hidden />}>
|
258
|
+
<span>Settings</span>
|
259
|
+
</DropdownItem>
|
260
|
+
</DropdownList>
|
261
|
+
</ChatbotHeaderOptionsDropdown>
|
262
|
+
</ChatbotHeaderActions>
|
263
|
+
</ChatbotHeader>
|
264
|
+
);
|
265
|
+
|
266
|
+
return (
|
267
|
+
<>
|
268
|
+
<Chatbot isVisible={chatbotVisible} displayMode={displayMode}>
|
269
|
+
{areSettingsOpen ? (
|
270
|
+
<>
|
271
|
+
<ChatbotHeader>
|
272
|
+
<ChatbotHeaderMain>
|
273
|
+
<ChatbotHeaderTitle>
|
274
|
+
<Title headingLevel="h1" size="2xl">
|
275
|
+
Settings
|
276
|
+
</Title>
|
277
|
+
</ChatbotHeaderTitle>
|
278
|
+
</ChatbotHeaderMain>
|
279
|
+
<ChatbotHeaderCloseButton onClick={() => setAreSettingsOpen(false)} />
|
280
|
+
</ChatbotHeader>
|
281
|
+
<SettingsForm fields={children} />
|
282
|
+
</>
|
283
|
+
) : (
|
284
|
+
<>{regularChatbot}</>
|
285
|
+
)}
|
286
|
+
</Chatbot>
|
287
|
+
</>
|
288
|
+
);
|
289
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import ChatbotToggle from '@patternfly/
|
2
|
+
import ChatbotToggle from '@patternfly/chatbot/dist/dynamic/ChatbotToggle';
|
3
3
|
|
4
4
|
export const SquareChatbotToggle: React.FunctionComponent = () => {
|
5
5
|
const [chatbotVisible, setChatbotVisible] = React.useState<boolean>(false);
|
@@ -0,0 +1,147 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Button, Checkbox, FormGroup, Radio, SkipToContent } from '@patternfly/react-core';
|
3
|
+
import TermsOfUse from '@patternfly/chatbot/dist/dynamic/TermsOfUse';
|
4
|
+
import Chatbot, { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot';
|
5
|
+
import termsAndConditionsHeader from './PF-TermsAndConditionsHeader.svg';
|
6
|
+
|
7
|
+
export const TermsOfUseExample: React.FunctionComponent = () => {
|
8
|
+
const [isModalOpen, setIsModalOpen] = React.useState(true);
|
9
|
+
const [displayMode, setDisplayMode] = React.useState(ChatbotDisplayMode.default);
|
10
|
+
const [hasImage, setHasImage] = React.useState(true);
|
11
|
+
const chatbotRef = React.useRef<HTMLDivElement>(null);
|
12
|
+
const termsRef = React.useRef<HTMLDivElement>(null);
|
13
|
+
|
14
|
+
const handleSkipToContent = (e) => {
|
15
|
+
e.preventDefault();
|
16
|
+
if (!isModalOpen && chatbotRef.current) {
|
17
|
+
chatbotRef.current.focus();
|
18
|
+
}
|
19
|
+
if (isModalOpen && termsRef.current) {
|
20
|
+
termsRef.current.focus();
|
21
|
+
}
|
22
|
+
};
|
23
|
+
|
24
|
+
const handleModalToggle = (_event: React.MouseEvent | MouseEvent | KeyboardEvent) => {
|
25
|
+
setIsModalOpen(!isModalOpen);
|
26
|
+
};
|
27
|
+
|
28
|
+
const onPrimaryAction = () => {
|
29
|
+
// eslint-disable-next-line no-console
|
30
|
+
console.log('Clicked primary action');
|
31
|
+
};
|
32
|
+
|
33
|
+
const onSecondaryAction = () => {
|
34
|
+
// eslint-disable-next-line no-console
|
35
|
+
console.log('Clicked secondary action');
|
36
|
+
};
|
37
|
+
|
38
|
+
const introduction = (
|
39
|
+
<>
|
40
|
+
<p>
|
41
|
+
Welcome to PatternFly! These terms and conditions outline the rules and regulations for the use of PatternFly's
|
42
|
+
website, located at <a href="https://patternfly.org">www.patternfly.org.</a>
|
43
|
+
</p>
|
44
|
+
<p>
|
45
|
+
By accessing this website, you are agreeing with our terms and conditions. If you do not agree to all of these
|
46
|
+
terms and conditions, do not continue to use PatternFly.
|
47
|
+
</p>
|
48
|
+
</>
|
49
|
+
);
|
50
|
+
|
51
|
+
const terminology = (
|
52
|
+
<>
|
53
|
+
<p>
|
54
|
+
The following terminology applies to these Terms and Conditions, Privacy Statement, Disclaimer Notice, and all
|
55
|
+
Agreements:
|
56
|
+
</p>
|
57
|
+
<ul>
|
58
|
+
<li>
|
59
|
+
"Client", "You", and "Your" refer to you, the person using this website who is compliant with the Company's
|
60
|
+
terms and conditions.
|
61
|
+
</li>
|
62
|
+
<li>
|
63
|
+
"The Company", "Ourselves", "We", "Our", and "Us", refer to our Company. "Party", "Parties", or "Us", refers
|
64
|
+
to both the Client and ourselves.
|
65
|
+
</li>
|
66
|
+
</ul>
|
67
|
+
</>
|
68
|
+
);
|
69
|
+
|
70
|
+
const body = (
|
71
|
+
<>
|
72
|
+
<h2>Introduction</h2>
|
73
|
+
{introduction}
|
74
|
+
<h2>Terminology</h2>
|
75
|
+
{terminology}
|
76
|
+
</>
|
77
|
+
);
|
78
|
+
|
79
|
+
return (
|
80
|
+
<>
|
81
|
+
<SkipToContent style={{ zIndex: '999' }} onClick={handleSkipToContent} href="#">
|
82
|
+
Skip to chatbot
|
83
|
+
</SkipToContent>
|
84
|
+
<div
|
85
|
+
style={{
|
86
|
+
position: 'fixed',
|
87
|
+
padding: 'var(--pf-t--global--spacer--lg)',
|
88
|
+
zIndex: '601',
|
89
|
+
boxShadow: 'var(--pf-t--global--box-shadow--lg)'
|
90
|
+
}}
|
91
|
+
>
|
92
|
+
<FormGroup role="radiogroup" isInline fieldId="basic-form-radio-group" label="Display mode">
|
93
|
+
<Radio
|
94
|
+
isChecked={displayMode === ChatbotDisplayMode.default}
|
95
|
+
onChange={() => setDisplayMode(ChatbotDisplayMode.default)}
|
96
|
+
name="basic-inline-radio"
|
97
|
+
label="Default"
|
98
|
+
id="default"
|
99
|
+
/>
|
100
|
+
<Radio
|
101
|
+
isChecked={displayMode === ChatbotDisplayMode.docked}
|
102
|
+
onChange={() => setDisplayMode(ChatbotDisplayMode.docked)}
|
103
|
+
name="basic-inline-radio"
|
104
|
+
label="Docked"
|
105
|
+
id="docked"
|
106
|
+
/>
|
107
|
+
<Radio
|
108
|
+
isChecked={displayMode === ChatbotDisplayMode.fullscreen}
|
109
|
+
onChange={() => setDisplayMode(ChatbotDisplayMode.fullscreen)}
|
110
|
+
name="basic-inline-radio"
|
111
|
+
label="Fullscreen"
|
112
|
+
id="fullscreen"
|
113
|
+
/>
|
114
|
+
<Radio
|
115
|
+
isChecked={displayMode === ChatbotDisplayMode.embedded}
|
116
|
+
onChange={() => setDisplayMode(ChatbotDisplayMode.embedded)}
|
117
|
+
name="basic-inline-radio"
|
118
|
+
label="Embedded"
|
119
|
+
id="embedded"
|
120
|
+
/>
|
121
|
+
</FormGroup>
|
122
|
+
<Checkbox
|
123
|
+
isChecked={hasImage}
|
124
|
+
aria-label="Toggle whether terms and conditions has a header image"
|
125
|
+
id="toggle-header-image"
|
126
|
+
name="toggle-header-image"
|
127
|
+
label="Has image in header"
|
128
|
+
onChange={(_event, checked) => setHasImage(checked)}
|
129
|
+
></Checkbox>
|
130
|
+
<Button onClick={handleModalToggle}>Launch modal</Button>
|
131
|
+
</div>
|
132
|
+
<Chatbot ref={chatbotRef} displayMode={displayMode} isVisible></Chatbot>
|
133
|
+
<TermsOfUse
|
134
|
+
ref={termsRef}
|
135
|
+
displayMode={displayMode}
|
136
|
+
isModalOpen={isModalOpen}
|
137
|
+
handleModalToggle={handleModalToggle}
|
138
|
+
onPrimaryAction={onPrimaryAction}
|
139
|
+
onSecondaryAction={onSecondaryAction}
|
140
|
+
image={hasImage ? termsAndConditionsHeader : undefined}
|
141
|
+
altText={hasImage ? 'Open book' : undefined}
|
142
|
+
>
|
143
|
+
{body}
|
144
|
+
</TermsOfUse>
|
145
|
+
</>
|
146
|
+
);
|
147
|
+
};
|
@@ -52,8 +52,10 @@ import FileDetailsLabel from '@patternfly/chatbot/dist/dynamic/FileDetailsLabel'
|
|
52
52
|
import FileDropZone from '@patternfly/chatbot/dist/dynamic/FileDropZone';
|
53
53
|
import { PreviewAttachment } from '@patternfly/chatbot/dist/dynamic/PreviewAttachment';
|
54
54
|
import ChatbotAlert from '@patternfly/chatbot/dist/dynamic/ChatbotAlert';
|
55
|
+
import TermsOfUse from '@patternfly/chatbot/dist/dynamic/TermsOfUse';
|
55
56
|
import {
|
56
57
|
ChatbotHeader,
|
58
|
+
ChatbotHeaderCloseButton,
|
57
59
|
ChatbotHeaderMain,
|
58
60
|
ChatbotHeaderMenu,
|
59
61
|
ChatbotHeaderActions,
|
@@ -65,6 +67,7 @@ import { ChatbotFooter, ChatbotFootnote } from '@patternfly/chatbot/dist/dynamic
|
|
65
67
|
import { MessageBar } from '@patternfly/chatbot/dist/dynamic/MessageBar';
|
66
68
|
import SourceDetailsMenuItem from '@patternfly/chatbot/dist/dynamic/SourceDetailsMenuItem';
|
67
69
|
import { ChatbotModal } from '@patternfly/chatbot/dist/dynamic/ChatbotModal';
|
70
|
+
import SettingsForm from '@patternfly/chatbot/dist/dynamic/Settings';
|
68
71
|
import { BellIcon, CalendarAltIcon, ClipboardIcon, CodeIcon, UploadIcon } from '@patternfly/react-icons';
|
69
72
|
import { useDropzone } from 'react-dropzone';
|
70
73
|
|
@@ -74,10 +77,13 @@ import { DropdownItem, DropdownList, Checkbox } from '@patternfly/react-core';
|
|
74
77
|
import OutlinedWindowRestoreIcon from '@patternfly/react-icons/dist/esm/icons/outlined-window-restore-icon';
|
75
78
|
import ExpandIcon from '@patternfly/react-icons/dist/esm/icons/expand-icon';
|
76
79
|
import OpenDrawerRightIcon from '@patternfly/react-icons/dist/esm/icons/open-drawer-right-icon';
|
80
|
+
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
77
81
|
import PFHorizontalLogoColor from './PF-HorizontalLogo-Color.svg';
|
78
82
|
import PFHorizontalLogoReverse from './PF-HorizontalLogo-Reverse.svg';
|
79
83
|
import userAvatar from '../Messages/user_avatar.svg';
|
80
84
|
import patternflyAvatar from '../Messages/patternfly_avatar.jpg';
|
85
|
+
import termsAndConditionsHeader from './PF-TermsAndConditionsHeader.svg';
|
86
|
+
import { CloseIcon } from '@patternfly/react-icons';
|
81
87
|
|
82
88
|
## Structure
|
83
89
|
|
@@ -357,6 +363,54 @@ Actions can be added to conversations with `menuItems`. Optionally, you can also
|
|
357
363
|
|
358
364
|
```
|
359
365
|
|
366
|
+
### Drawer with active conversation
|
367
|
+
|
368
|
+
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.
|
369
|
+
|
370
|
+
```js file="./ChatbotHeaderDrawerWithSelection.tsx"
|
371
|
+
|
372
|
+
```
|
373
|
+
|
374
|
+
### Resizable drawer
|
375
|
+
|
376
|
+
By default, the conversation history drawer has a fixed width (384px) and a focus trap. To provide users with more flexibility as they navigate their conversation history, or to better support embedded ChatBots on tablet-sized devices or smaller browser windows, you can instead make the drawer resizable. By default, even resizable drawers will still open to their full width on mobile devices.
|
377
|
+
|
378
|
+
In this example, the drawer can be resized up to the max size of the parent and resized down to 200px wide. To customize this behavior further (including width, style, and focus behavior) use PatternFly [`<Drawer>` props](/components/drawer#props), [`<DrawerPanelContent>` props](/components/drawer/#drawerpanelcontent), or any other drawer subcomponents.
|
379
|
+
|
380
|
+
```js file="./ChatbotHeaderDrawerResizable.tsx"
|
381
|
+
|
382
|
+
```
|
383
|
+
|
384
|
+
### Drawer with simple menu
|
385
|
+
|
386
|
+
The drawer can also be used to display a list of basic menu items.
|
387
|
+
|
388
|
+
```js file="./ChatbotHeaderDrawerNavigation.tsx"
|
389
|
+
|
390
|
+
```
|
391
|
+
|
392
|
+
### Terms of use
|
393
|
+
|
394
|
+
Based on the [PatternFly modal](/components/modal), this modal adapts to the ChatBot display mode and is meant to display terms and conditions for using a ChatBot in your project. The image in the header can be toggled on or off depending on whether the `image` and `altText` props are provided.
|
395
|
+
|
396
|
+
This example also includes an example of how to use [skip to content](/patternfly-ai/chatbot/ui#skip-to-content). When the terms of use modal is open, focus is placed on the terms of use container. When it is closed, focus is placed on the ChatBot. In a real example with a functioning ChatBot toggle, you would also want to place focus on the toggle when appropriate.
|
397
|
+
|
398
|
+
```js file="./TermsOfUse.tsx" isFullscreen
|
399
|
+
|
400
|
+
```
|
401
|
+
|
402
|
+
### Settings
|
403
|
+
|
404
|
+
To contain user preference controls and other ChatBot setting options, you can create a separate settings page that can accept any number of buttons, dropdown menus, toggles, labels, and so on. This settings page will render all components appropriately within all 4 display modes.
|
405
|
+
|
406
|
+
In this demo, you can toggle the settings page by clicking the "Settings" button in the display mode menu.
|
407
|
+
|
408
|
+
```js file="./Settings.tsx" isFullscreen
|
409
|
+
|
410
|
+
```
|
411
|
+
|
412
|
+
## Modals
|
413
|
+
|
360
414
|
### Modal
|
361
415
|
|
362
416
|
Based on the [PatternFly modal](/components/modal), this modal adapts to the ChatBot display mode and accepts components typically used in a modal. It is primarily used and tested in the context of the attachment modals, but you can customize this modal to adapt it to other use cases as needed. The modal will overlay the ChatBot in default and docked modes, and will behave more like a traditional PatternFly modal in fullscreen and embedded modes.
|
@@ -21,7 +21,8 @@ propComponents:
|
|
21
21
|
'ChatbotFootnote',
|
22
22
|
'MessageBox',
|
23
23
|
'Message',
|
24
|
-
'MessageBarWithAttachMenuProps'
|
24
|
+
'MessageBarWithAttachMenuProps',
|
25
|
+
'CompareProps'
|
25
26
|
]
|
26
27
|
sortValue: 2
|
27
28
|
---
|
@@ -34,6 +35,7 @@ import ChatbotFooter, { ChatbotFootnote } from '@patternfly/chatbot/dist/dynamic
|
|
34
35
|
import MessageBar from '@patternfly/chatbot/dist/dynamic/MessageBar';
|
35
36
|
import MessageBox from '@patternfly/chatbot/dist/dynamic/MessageBox';
|
36
37
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
38
|
+
import Compare from '@patternfly/chatbot/dist/dynamic/Compare';
|
37
39
|
import ChatbotConversationHistoryNav from '@patternfly/chatbot/dist/dynamic/ChatbotConversationHistoryNav';
|
38
40
|
|
39
41
|
import ChatbotHeader, {
|
@@ -66,7 +68,7 @@ This demo displays a basic ChatBot, which includes:
|
|
66
68
|
4. [`<ChatbotContent>` and `<MessageBox>`](/patternfly-ai/chatbot/ui#content-and-message-box) with:
|
67
69
|
|
68
70
|
- A `<ChatbotWelcomePrompt>`
|
69
|
-
- An initial [user `<Message>`](/patternfly-ai/chatbot/messages#user-messages) and an initial bot message with [message actions.](/patternfly-ai/chatbot/messages#
|
71
|
+
- An initial [user `<Message>`](/patternfly-ai/chatbot/messages#user-messages) and an initial bot message with [message actions.](/patternfly-ai/chatbot/messages#message-actions)
|
70
72
|
- Logic for enabling auto-scrolling to the most recent message whenever a new message is sent or received using a `scrollToBottomRef`
|
71
73
|
|
72
74
|
5. A [`<ChatbotFooter>`](/patternfly-ai/chatbot/ui#footer) with a [`<ChatbotFootNote>`](/patternfly-ai/chatbot/ui#footnote-with-popover) and a `<MessageBar>` that contains the abilities of:
|
@@ -92,7 +94,7 @@ This demo displays an embedded ChatBot. Embedded ChatBots are meant to be placed
|
|
92
94
|
3. A [`<ChatbotHeader>`](/patternfly-ai/chatbot/ui#header) with all built sub-components laid out, including a `<ChatbotHeaderTitle>`
|
93
95
|
4. [`<ChatbotContent>` and `<MessageBox>`](/patternfly-ai/chatbot/ui#content-and-message-box) with:
|
94
96
|
- A `<ChatbotWelcomePrompt>`
|
95
|
-
- An initial [user `<Message>`](/patternfly-ai/chatbot/messages#user-messages) and an initial bot message with [message actions.](/patternfly-ai/chatbot/messages/#
|
97
|
+
- An initial [user `<Message>`](/patternfly-ai/chatbot/messages#user-messages) and an initial bot message with [message actions.](/patternfly-ai/chatbot/messages/#message-actions)
|
96
98
|
- Logic for enabling auto-scrolling to the most recent message whenever a new message is sent or received using a `scrollToBottomRef`
|
97
99
|
5. A [`<ChatbotFooter>`](/patternfly-ai/chatbot/ui#footer) with a [`<ChatbotFootNote>`](/patternfly-ai/chatbot/ui#footnote-with-popover) and a `<MessageBar>` that contains the abilities of:
|
98
100
|
- [Speech to text.](/patternfly-ai/chatbot/ui#message-bar-with-speech-recognition-and-file-attachment)
|
@@ -103,3 +105,24 @@ This demo displays an embedded ChatBot. Embedded ChatBots are meant to be placed
|
|
103
105
|
```js file="./EmbeddedChatbot.tsx" isFullscreen
|
104
106
|
|
105
107
|
```
|
108
|
+
|
109
|
+
### Comparing ChatBots
|
110
|
+
|
111
|
+
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.
|
112
|
+
<br /><br />
|
113
|
+
Your code structure should look like this:
|
114
|
+
|
115
|
+
```noLive
|
116
|
+
<Page ... >
|
117
|
+
<div className="pf-chatbot__compare-container">
|
118
|
+
<Compare ... />
|
119
|
+
<ChatbotFooter ... >
|
120
|
+
<MessageBar ... />
|
121
|
+
</ChatbotFooter>
|
122
|
+
</div>
|
123
|
+
</Page>
|
124
|
+
```
|
125
|
+
|
126
|
+
```js file="./EmbeddedComparisonChatbot.tsx" isFullscreen
|
127
|
+
|
128
|
+
```
|
@@ -34,10 +34,10 @@ import userAvatar from '../Messages/user_avatar.svg';
|
|
34
34
|
import patternflyAvatar from '../Messages/patternfly_avatar.jpg';
|
35
35
|
|
36
36
|
const footnoteProps = {
|
37
|
-
label: '
|
37
|
+
label: 'ChatBot uses AI. Check for mistakes.',
|
38
38
|
popover: {
|
39
39
|
title: 'Verify accuracy',
|
40
|
-
description: `While
|
40
|
+
description: `While ChatBot strives for accuracy, there's always a possibility of errors. It's a good practice to verify critical information from reliable sources, especially if it's crucial for decision-making or actions.`,
|
41
41
|
bannerImage: {
|
42
42
|
src: 'https://cdn.dribbble.com/userupload/10651749/file/original-8a07b8e39d9e8bf002358c66fce1223e.gif',
|
43
43
|
alt: 'Example image for footnote popover'
|
@@ -36,18 +36,26 @@ interface ModalData {
|
|
36
36
|
}
|
37
37
|
|
38
38
|
export const BasicDemo: React.FunctionComponent = () => {
|
39
|
-
const onAttachmentClose = (
|
40
|
-
const index = messages.findIndex((message) => message.attachmentId === attachmentId);
|
39
|
+
const onAttachmentClose = (event, name, id) => {
|
41
40
|
const updatedMessages: MessageProps[] = [];
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
messages.map((message) => {
|
42
|
+
if (message.attachments) {
|
43
|
+
const filteredAttachments = message.attachments.filter((attachment) => attachment.id !== id);
|
44
|
+
message.attachments = filteredAttachments;
|
45
|
+
updatedMessages.push(message);
|
46
|
+
} else {
|
47
|
+
updatedMessages.push(message);
|
48
|
+
}
|
49
|
+
});
|
50
|
+
setMessages(updatedMessages);
|
50
51
|
};
|
52
|
+
|
53
|
+
const onAttachmentClick = () => {
|
54
|
+
setCurrentModalData({ fileName: 'auth-operator.yml', code: 'test' });
|
55
|
+
setIsEditModalOpen(false);
|
56
|
+
setIsPreviewModalOpen(true);
|
57
|
+
};
|
58
|
+
|
51
59
|
const initialMessages: MessageProps[] = [
|
52
60
|
{
|
53
61
|
role: 'user',
|
@@ -55,14 +63,7 @@ export const BasicDemo: React.FunctionComponent = () => {
|
|
55
63
|
name: 'User',
|
56
64
|
avatar: userAvatar,
|
57
65
|
avatarProps: { isBordered: true },
|
58
|
-
|
59
|
-
attachmentId: '1',
|
60
|
-
onAttachmentClose,
|
61
|
-
onAttachmentClick: () => {
|
62
|
-
setCurrentModalData({ fileName: 'auth-operator.yml', code: 'test' });
|
63
|
-
setIsEditModalOpen(false);
|
64
|
-
setIsPreviewModalOpen(true);
|
65
|
-
}
|
66
|
+
attachments: [{ name: 'auth-operator.yml', id: '1', onClick: onAttachmentClick, onClose: onAttachmentClose }]
|
66
67
|
},
|
67
68
|
{
|
68
69
|
role: 'bot',
|
@@ -243,7 +244,7 @@ export const BasicDemo: React.FunctionComponent = () => {
|
|
243
244
|
</div>
|
244
245
|
)}
|
245
246
|
<MessageBar onSendMessage={handleSend} hasAttachButton handleAttach={handleAttach} />
|
246
|
-
<ChatbotFootnote label="
|
247
|
+
<ChatbotFootnote label="ChatBot uses AI. Check for mistakes." />
|
247
248
|
</ChatbotFooter>
|
248
249
|
</FileDropZone>
|
249
250
|
</Chatbot>
|
@@ -259,7 +259,7 @@ export const AttachmentMenuDemo: React.FunctionComponent = () => {
|
|
259
259
|
onAttachMenuToggleClick: onToggleClick
|
260
260
|
}}
|
261
261
|
/>
|
262
|
-
<ChatbotFootnote label="
|
262
|
+
<ChatbotFootnote label="ChatBot uses AI. Check for mistakes." />
|
263
263
|
</ChatbotFooter>
|
264
264
|
</>
|
265
265
|
</FileDropZone>
|