@patternfly/chatbot 6.4.0-prerelease.2 → 6.4.0-prerelease.21
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/Chatbot/Chatbot.js +1 -7
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.d.ts +2 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +2 -2
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +22 -2
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +15 -9
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +40 -2
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.js +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.js +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.d.ts +18 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.js +25 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +22 -0
- package/dist/cjs/ChatbotHeader/index.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/index.js +1 -0
- package/dist/cjs/DeepThinking/DeepThinking.d.ts +18 -0
- package/dist/cjs/DeepThinking/DeepThinking.js +18 -0
- package/dist/cjs/DeepThinking/DeepThinking.test.d.ts +1 -0
- package/dist/cjs/DeepThinking/DeepThinking.test.js +48 -0
- package/dist/cjs/DeepThinking/index.d.ts +2 -0
- package/dist/cjs/DeepThinking/index.js +23 -0
- package/dist/cjs/FileDetails/FileDetails.d.ts +22 -3
- package/dist/cjs/FileDetails/FileDetails.js +27 -912
- package/dist/cjs/FileDetails/FileDetails.test.js +16 -0
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.d.ts +8 -2
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.js +14 -2
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.test.js +19 -1
- package/dist/cjs/FilePreview/FilePreview.d.ts +26 -0
- package/dist/cjs/FilePreview/FilePreview.js +26 -0
- package/dist/cjs/FilePreview/FilePreview.test.d.ts +1 -0
- package/dist/cjs/FilePreview/FilePreview.test.js +97 -0
- package/dist/cjs/FilePreview/index.d.ts +2 -0
- package/dist/cjs/FilePreview/index.js +23 -0
- package/dist/cjs/ImagePreview/ImagePreview.d.ts +53 -0
- package/dist/cjs/ImagePreview/ImagePreview.js +47 -0
- package/dist/cjs/ImagePreview/ImagePreview.test.d.ts +1 -0
- package/dist/cjs/ImagePreview/ImagePreview.test.js +225 -0
- package/dist/cjs/ImagePreview/index.d.ts +2 -0
- package/dist/cjs/ImagePreview/index.js +23 -0
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +3 -3
- package/dist/cjs/Message/LinkMessage/LinkMessage.d.ts +2 -1
- package/dist/cjs/Message/LinkMessage/LinkMessage.js +7 -3
- package/dist/cjs/Message/ListMessage/ListItemMessage.d.ts +1 -1
- package/dist/cjs/Message/ListMessage/ListItemMessage.js +16 -1
- package/dist/cjs/Message/Message.d.ts +15 -0
- package/dist/cjs/Message/Message.js +129 -32
- package/dist/cjs/Message/Message.test.js +71 -0
- package/dist/cjs/Message/SuperscriptMessage/SuperscriptMessage.d.ts +3 -0
- package/dist/cjs/Message/SuperscriptMessage/SuperscriptMessage.js +5 -0
- package/dist/cjs/Message/UserFeedback/UserFeedback.d.ts +15 -1
- package/dist/cjs/Message/UserFeedback/UserFeedback.js +4 -4
- package/dist/cjs/Message/UserFeedback/UserFeedback.test.js +44 -0
- package/dist/cjs/MessageBar/MessageBar.js +19 -4
- package/dist/cjs/MessageBox/JumpButton.d.ts +5 -0
- package/dist/cjs/MessageBox/JumpButton.js +1 -1
- package/dist/cjs/MessageBox/JumpButton.test.js +4 -4
- package/dist/cjs/MessageBox/MessageBox.d.ts +9 -0
- package/dist/cjs/MessageBox/MessageBox.js +2 -2
- package/dist/cjs/MessageBox/MessageBox.test.js +2 -2
- package/dist/cjs/SourcesCard/SourcesCard.d.ts +13 -1
- package/dist/cjs/SourcesCard/SourcesCard.js +6 -6
- package/dist/cjs/SourcesCard/SourcesCard.test.js +49 -0
- package/dist/cjs/ToolResponse/ToolResponse.d.ts +30 -0
- package/dist/cjs/ToolResponse/ToolResponse.js +18 -0
- package/dist/cjs/ToolResponse/ToolResponse.test.d.ts +1 -0
- package/dist/cjs/ToolResponse/ToolResponse.test.js +60 -0
- package/dist/cjs/ToolResponse/index.d.ts +2 -0
- package/dist/cjs/ToolResponse/index.js +23 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.js +13 -1
- package/dist/css/main.css +339 -27
- package/dist/css/main.css.map +1 -1
- package/dist/dynamic/DeepThinking/package.json +1 -0
- package/dist/dynamic/FilePreview/package.json +1 -0
- package/dist/dynamic/ImagePreview/package.json +1 -0
- package/dist/dynamic/ToolResponse/package.json +1 -0
- package/dist/esm/Chatbot/Chatbot.js +1 -7
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.d.ts +2 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +2 -2
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +22 -2
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +17 -11
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +41 -3
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.js +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.d.ts +18 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.js +22 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +20 -0
- package/dist/esm/ChatbotHeader/index.d.ts +1 -0
- package/dist/esm/ChatbotHeader/index.js +1 -0
- package/dist/esm/DeepThinking/DeepThinking.d.ts +18 -0
- package/dist/esm/DeepThinking/DeepThinking.js +14 -0
- package/dist/esm/DeepThinking/DeepThinking.test.d.ts +1 -0
- package/dist/esm/DeepThinking/DeepThinking.test.js +43 -0
- package/dist/esm/DeepThinking/index.d.ts +2 -0
- package/dist/esm/DeepThinking/index.js +2 -0
- package/dist/esm/FileDetails/FileDetails.d.ts +22 -3
- package/dist/esm/FileDetails/FileDetails.js +27 -912
- package/dist/esm/FileDetails/FileDetails.test.js +16 -0
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.d.ts +8 -2
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.js +14 -2
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.test.js +19 -1
- package/dist/esm/FilePreview/FilePreview.d.ts +26 -0
- package/dist/esm/FilePreview/FilePreview.js +21 -0
- package/dist/esm/FilePreview/FilePreview.test.d.ts +1 -0
- package/dist/esm/FilePreview/FilePreview.test.js +92 -0
- package/dist/esm/FilePreview/index.d.ts +2 -0
- package/dist/esm/FilePreview/index.js +2 -0
- package/dist/esm/ImagePreview/ImagePreview.d.ts +53 -0
- package/dist/esm/ImagePreview/ImagePreview.js +42 -0
- package/dist/esm/ImagePreview/ImagePreview.test.d.ts +1 -0
- package/dist/esm/ImagePreview/ImagePreview.test.js +220 -0
- package/dist/esm/ImagePreview/index.d.ts +2 -0
- package/dist/esm/ImagePreview/index.js +2 -0
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +5 -5
- package/dist/esm/Message/LinkMessage/LinkMessage.d.ts +2 -1
- package/dist/esm/Message/LinkMessage/LinkMessage.js +7 -3
- package/dist/esm/Message/ListMessage/ListItemMessage.d.ts +1 -1
- package/dist/esm/Message/ListMessage/ListItemMessage.js +16 -1
- package/dist/esm/Message/Message.d.ts +15 -0
- package/dist/esm/Message/Message.js +129 -32
- package/dist/esm/Message/Message.test.js +71 -0
- package/dist/esm/Message/SuperscriptMessage/SuperscriptMessage.d.ts +3 -0
- package/dist/esm/Message/SuperscriptMessage/SuperscriptMessage.js +3 -0
- package/dist/esm/Message/UserFeedback/UserFeedback.d.ts +15 -1
- package/dist/esm/Message/UserFeedback/UserFeedback.js +4 -4
- package/dist/esm/Message/UserFeedback/UserFeedback.test.js +45 -1
- package/dist/esm/MessageBar/MessageBar.js +19 -4
- package/dist/esm/MessageBox/JumpButton.d.ts +5 -0
- package/dist/esm/MessageBox/JumpButton.js +1 -1
- package/dist/esm/MessageBox/JumpButton.test.js +4 -4
- package/dist/esm/MessageBox/MessageBox.d.ts +9 -0
- package/dist/esm/MessageBox/MessageBox.js +2 -2
- package/dist/esm/MessageBox/MessageBox.test.js +2 -2
- package/dist/esm/SourcesCard/SourcesCard.d.ts +13 -1
- package/dist/esm/SourcesCard/SourcesCard.js +6 -6
- package/dist/esm/SourcesCard/SourcesCard.test.js +50 -1
- package/dist/esm/ToolResponse/ToolResponse.d.ts +30 -0
- package/dist/esm/ToolResponse/ToolResponse.js +14 -0
- package/dist/esm/ToolResponse/ToolResponse.test.d.ts +1 -0
- package/dist/esm/ToolResponse/ToolResponse.test.js +55 -0
- package/dist/esm/ToolResponse/index.d.ts +2 -0
- package/dist/esm/ToolResponse/index.js +2 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachmentEdit.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +101 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/FilePreview.tsx +33 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/ImagePreview.tsx +53 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithDeepThinking.tsx +17 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithFeedback.tsx +111 -85
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +70 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithToolResponse.tsx +135 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +38 -4
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/PreviewAttachment.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +107 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessageWithExtraContent.tsx +616 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/file-preview.svg +9 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotConversationEditing.tsx +202 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderBasic.tsx +17 -3
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +36 -5
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithPin.tsx +12 -2
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +22 -3
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +1 -1
- package/patternfly-docs/patternfly-docs.config.js +1 -1
- package/src/Chatbot/Chatbot.scss +9 -2
- package/src/Chatbot/Chatbot.tsx +18 -31
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx +5 -1
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +16 -10
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +132 -3
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +80 -33
- package/src/ChatbotHeader/ChatbotHeaderMenu.test.tsx +1 -1
- package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +2 -2
- package/src/ChatbotHeader/ChatbotHeaderNewChatButton.test.tsx +25 -0
- package/src/ChatbotHeader/ChatbotHeaderNewChatButton.tsx +64 -0
- package/src/ChatbotHeader/index.ts +1 -0
- package/src/ChatbotModal/ChatbotModal.scss +1 -1
- package/src/DeepThinking/DeepThinking.scss +24 -0
- package/src/DeepThinking/DeepThinking.test.tsx +61 -0
- package/src/DeepThinking/DeepThinking.tsx +68 -0
- package/src/DeepThinking/index.ts +3 -0
- package/src/FileDetails/FileDetails.scss +10 -0
- package/src/FileDetails/FileDetails.test.tsx +16 -0
- package/src/FileDetails/FileDetails.tsx +89 -32
- package/src/FileDetails/__snapshots__/FileDetails.test.tsx.snap +20 -14
- package/src/FileDetailsLabel/FileDetailsLabel.test.tsx +21 -1
- package/src/FileDetailsLabel/FileDetailsLabel.tsx +16 -3
- package/src/FileDetailsLabel/__snapshots__/FileDetailsLabel.test.tsx.snap +20 -14
- package/src/FilePreview/FilePreview.scss +22 -0
- package/src/FilePreview/FilePreview.test.tsx +112 -0
- package/src/FilePreview/FilePreview.tsx +58 -0
- package/src/FilePreview/index.ts +3 -0
- package/src/ImagePreview/ImagePreview.scss +61 -0
- package/src/ImagePreview/ImagePreview.test.tsx +253 -0
- package/src/ImagePreview/ImagePreview.tsx +200 -0
- package/src/ImagePreview/index.ts +3 -0
- package/src/Message/CodeBlockMessage/CodeBlockMessage.scss +2 -1
- package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +6 -5
- package/src/Message/LinkMessage/LinkMessage.tsx +6 -2
- package/src/Message/ListMessage/ListItemMessage.tsx +5 -1
- package/src/Message/ListMessage/ListMessage.scss +17 -0
- package/src/Message/Message.scss +44 -0
- package/src/Message/Message.test.tsx +90 -0
- package/src/Message/Message.tsx +171 -46
- package/src/Message/SuperscriptMessage/SuperscriptMessage.scss +8 -0
- package/src/Message/SuperscriptMessage/SuperscriptMessage.tsx +13 -0
- package/src/Message/TextMessage/TextMessage.scss +46 -5
- package/src/Message/UserFeedback/UserFeedback.test.tsx +107 -0
- package/src/Message/UserFeedback/UserFeedback.tsx +41 -6
- package/src/MessageBar/MessageBar.tsx +23 -3
- package/src/MessageBox/JumpButton.test.tsx +4 -4
- package/src/MessageBox/JumpButton.tsx +20 -4
- package/src/MessageBox/MessageBox.scss +0 -12
- package/src/MessageBox/MessageBox.test.tsx +2 -2
- package/src/MessageBox/MessageBox.tsx +23 -2
- package/src/SourcesCard/SourcesCard.scss +17 -0
- package/src/SourcesCard/SourcesCard.test.tsx +93 -0
- package/src/SourcesCard/SourcesCard.tsx +116 -80
- package/src/ToolResponse/ToolResponse.scss +36 -0
- package/src/ToolResponse/ToolResponse.test.tsx +78 -0
- package/src/ToolResponse/ToolResponse.tsx +95 -0
- package/src/ToolResponse/index.ts +3 -0
- package/src/index.ts +12 -0
- package/src/main.scss +16 -0
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CSSProperties,
|
|
3
|
+
useState,
|
|
4
|
+
Fragment,
|
|
5
|
+
FunctionComponent,
|
|
6
|
+
MouseEvent as ReactMouseEvent,
|
|
7
|
+
KeyboardEvent as ReactKeyboardEvent,
|
|
8
|
+
Ref
|
|
9
|
+
} from 'react';
|
|
2
10
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
3
11
|
import patternflyAvatar from './patternfly_avatar.jpg';
|
|
4
12
|
import squareImg from './PF-social-color-square.svg';
|
|
@@ -44,6 +52,8 @@ export const BotMessageExample: FunctionComponent = () => {
|
|
|
44
52
|
return table;
|
|
45
53
|
case 'Image':
|
|
46
54
|
return image;
|
|
55
|
+
case 'Footnote':
|
|
56
|
+
return footnote;
|
|
47
57
|
default:
|
|
48
58
|
return;
|
|
49
59
|
}
|
|
@@ -150,6 +160,18 @@ _Italic text, formatted with single underscores_
|
|
|
150
160
|
|
|
151
161
|
const image = ``;
|
|
152
162
|
|
|
163
|
+
const footnote = `This is some text that has a short footnote[^1] and this is text with a longer footnote.[^bignote]
|
|
164
|
+
|
|
165
|
+
[^1]: This is a short footnote. To return the highlight to the original message, click the arrow.
|
|
166
|
+
|
|
167
|
+
[^bignote]: This is a long footnote with multiple paragraphs and formatting.
|
|
168
|
+
|
|
169
|
+
To break long footnotes into paragraphs, indent the text.
|
|
170
|
+
|
|
171
|
+
Add as many paragraphs as you like. You can include *italic text*, **bold text**, and \`code\`.
|
|
172
|
+
|
|
173
|
+
> You can even include blockquotes in footnotes!`;
|
|
174
|
+
|
|
153
175
|
const error = {
|
|
154
176
|
title: 'Could not load chat',
|
|
155
177
|
children: 'Wait a few minutes and check your network settings. If the issue persists: ',
|
|
@@ -165,8 +187,8 @@ _Italic text, formatted with single underscores_
|
|
|
165
187
|
)
|
|
166
188
|
};
|
|
167
189
|
|
|
168
|
-
const onSelect = (_event:
|
|
169
|
-
setVariant(value);
|
|
190
|
+
const onSelect = (_event: ReactMouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => {
|
|
191
|
+
setVariant(value as string);
|
|
170
192
|
setSelected(value as string);
|
|
171
193
|
setIsOpen(false);
|
|
172
194
|
if (value === 'Expandable code') {
|
|
@@ -196,6 +218,76 @@ _Italic text, formatted with single underscores_
|
|
|
196
218
|
</MenuToggle>
|
|
197
219
|
);
|
|
198
220
|
|
|
221
|
+
const handleFootnoteNavigation = (event: ReactMouseEvent<HTMLElement> | ReactKeyboardEvent<HTMLElement>) => {
|
|
222
|
+
const target = event.target as HTMLElement;
|
|
223
|
+
|
|
224
|
+
// Depending on whether it is a click event or keyboard event, target may be a link or something like a span
|
|
225
|
+
// Look for the closest anchor element (could be a parent)
|
|
226
|
+
const anchorElement = target.closest('a');
|
|
227
|
+
const href = anchorElement?.getAttribute('href');
|
|
228
|
+
|
|
229
|
+
// Check if this is a footnote link - we only have internal links in this example, so this is all we need here
|
|
230
|
+
if (href && href.startsWith('#')) {
|
|
231
|
+
// Prevent default behavior to avoid page re-render on click in PatternFly docs framework
|
|
232
|
+
event.preventDefault();
|
|
233
|
+
|
|
234
|
+
let targetElement: HTMLElement | null = null;
|
|
235
|
+
const targetId = href.replace('#', '');
|
|
236
|
+
targetElement = document.querySelector(`[id="${targetId}"]`);
|
|
237
|
+
|
|
238
|
+
if (targetElement) {
|
|
239
|
+
let focusTarget = targetElement;
|
|
240
|
+
|
|
241
|
+
// If we found a footnote definition container, focus on the parent li element
|
|
242
|
+
if (targetElement.id?.startsWith('bot-message-fn-')) {
|
|
243
|
+
// Find the parent li element that contains the footnote
|
|
244
|
+
const parentLi = targetElement.closest('li');
|
|
245
|
+
if (parentLi) {
|
|
246
|
+
focusTarget = parentLi as HTMLElement;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
focusTarget.focus();
|
|
251
|
+
|
|
252
|
+
let elementToHighlight = targetElement;
|
|
253
|
+
|
|
254
|
+
// If this is a backref link (going back to footnote reference),
|
|
255
|
+
// we want to highlight more of the ref line and not just the link itself
|
|
256
|
+
// since the target is so small
|
|
257
|
+
if (targetElement.id?.startsWith('bot-message-fnref-')) {
|
|
258
|
+
const refLink = targetElement;
|
|
259
|
+
|
|
260
|
+
// Walk up the DOM to find a meaningful container
|
|
261
|
+
let parent = refLink.parentElement;
|
|
262
|
+
while (parent && parent.tagName.toLowerCase() !== 'p' && parent !== document.body) {
|
|
263
|
+
parent = parent.parentElement;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Use if found, otherwise use the immediate parent or target as a fallback
|
|
267
|
+
elementToHighlight = parent || refLink.parentElement || targetElement;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Briefly highlight the target element for fun to show what you can do
|
|
271
|
+
const originalBackground = elementToHighlight.style.backgroundColor;
|
|
272
|
+
const originalTransition = elementToHighlight.style.transition;
|
|
273
|
+
|
|
274
|
+
elementToHighlight.style.transition = 'background-color 0.3s ease';
|
|
275
|
+
elementToHighlight.style.backgroundColor = 'var(--pf-t--global--background--color--tertiary--default)';
|
|
276
|
+
|
|
277
|
+
setTimeout(() => {
|
|
278
|
+
elementToHighlight.style.backgroundColor = originalBackground;
|
|
279
|
+
setTimeout(() => {
|
|
280
|
+
elementToHighlight.style.transition = originalTransition;
|
|
281
|
+
}, 300);
|
|
282
|
+
}, 1000);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const onClick = (event: ReactMouseEvent<HTMLElement> | ReactKeyboardEvent<HTMLElement>) => {
|
|
288
|
+
handleFootnoteNavigation(event);
|
|
289
|
+
};
|
|
290
|
+
|
|
199
291
|
return (
|
|
200
292
|
<>
|
|
201
293
|
<Message
|
|
@@ -248,6 +340,7 @@ _Italic text, formatted with single underscores_
|
|
|
248
340
|
<SelectOption value="More complex list">More complex list</SelectOption>
|
|
249
341
|
<SelectOption value="Table">Table</SelectOption>
|
|
250
342
|
<SelectOption value="Image">Image</SelectOption>
|
|
343
|
+
<SelectOption value="Footnote">Footnote</SelectOption>
|
|
251
344
|
<SelectOption value="Error">Error</SelectOption>
|
|
252
345
|
</SelectList>
|
|
253
346
|
</Select>
|
|
@@ -265,6 +358,11 @@ _Italic text, formatted with single underscores_
|
|
|
265
358
|
// The purpose of this plugin is to provide unique link names for the code blocks
|
|
266
359
|
// Because they are in the same message, this requires a custom plugin to parse the syntax tree
|
|
267
360
|
additionalRehypePlugins={[rehypeCodeBlockToggle]}
|
|
361
|
+
linkProps={{ onClick }}
|
|
362
|
+
// clobberPrefix controls the label ids
|
|
363
|
+
reactMarkdownProps={{
|
|
364
|
+
remarkRehypeOptions: { footnoteLabel: 'Bot message footnotes', clobberPrefix: 'bot-message-' }
|
|
365
|
+
}}
|
|
268
366
|
/>
|
|
269
367
|
</>
|
|
270
368
|
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState, FunctionComponent, MouseEvent as ReactMouseEvent } from 'react';
|
|
2
|
+
import { Button, Checkbox } from '@patternfly/react-core';
|
|
3
|
+
import FilePreview from '@patternfly/chatbot/dist/dynamic/FilePreview';
|
|
4
|
+
|
|
5
|
+
export const AttachmentEditModalExample: FunctionComponent = () => {
|
|
6
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
7
|
+
const [isCompact, setIsCompact] = useState(false);
|
|
8
|
+
|
|
9
|
+
const handleModalToggle = (_event: ReactMouseEvent | MouseEvent | KeyboardEvent) => {
|
|
10
|
+
setIsModalOpen(!isModalOpen);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<Checkbox
|
|
16
|
+
label="Show compact version"
|
|
17
|
+
isChecked={isCompact}
|
|
18
|
+
onChange={() => setIsCompact(!isCompact)}
|
|
19
|
+
id="modal-compact-no-preview"
|
|
20
|
+
name="modal-compact-no-preview"
|
|
21
|
+
></Checkbox>
|
|
22
|
+
<Button onClick={handleModalToggle}>Launch file preview modal</Button>
|
|
23
|
+
<FilePreview
|
|
24
|
+
isModalOpen={isModalOpen}
|
|
25
|
+
handleModalToggle={handleModalToggle}
|
|
26
|
+
fileName="compressed-file.zip"
|
|
27
|
+
isCompact={isCompact}
|
|
28
|
+
>
|
|
29
|
+
Preview unavailable
|
|
30
|
+
</FilePreview>
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useState, FunctionComponent, MouseEvent as ReactMouseEvent } from 'react';
|
|
2
|
+
import { Button, Checkbox } from '@patternfly/react-core';
|
|
3
|
+
import ImagePreview from '@patternfly/chatbot/dist/dynamic/ImagePreview';
|
|
4
|
+
import filePreview from './file-preview.svg';
|
|
5
|
+
|
|
6
|
+
export const AttachmentEditModalExample: FunctionComponent = () => {
|
|
7
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
8
|
+
const [isCompact, setIsCompact] = useState(false);
|
|
9
|
+
const [hasNav, setHasNav] = useState(false);
|
|
10
|
+
|
|
11
|
+
const handleModalToggle = (_event: ReactMouseEvent | MouseEvent | KeyboardEvent) => {
|
|
12
|
+
setIsModalOpen(!isModalOpen);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<Checkbox
|
|
18
|
+
label="Show multiple images"
|
|
19
|
+
isChecked={hasNav}
|
|
20
|
+
onChange={() => setHasNav(!hasNav)}
|
|
21
|
+
id="modal-compact-image-has-nav"
|
|
22
|
+
name="modal-compact-image-has-nav"
|
|
23
|
+
></Checkbox>
|
|
24
|
+
<Checkbox
|
|
25
|
+
label="Show compact version"
|
|
26
|
+
isChecked={isCompact}
|
|
27
|
+
onChange={() => setIsCompact(!isCompact)}
|
|
28
|
+
id="modal-compact-image-preview"
|
|
29
|
+
name="modal-compact-image-preview"
|
|
30
|
+
></Checkbox>
|
|
31
|
+
<Button onClick={handleModalToggle}>Launch image preview modal</Button>
|
|
32
|
+
<ImagePreview
|
|
33
|
+
isModalOpen={isModalOpen}
|
|
34
|
+
handleModalToggle={handleModalToggle}
|
|
35
|
+
isCompact={isCompact}
|
|
36
|
+
onCloseFileDetailsLabel={() => {
|
|
37
|
+
// eslint-disable-next-line no-console
|
|
38
|
+
console.log('Clicked close button');
|
|
39
|
+
}}
|
|
40
|
+
images={
|
|
41
|
+
hasNav
|
|
42
|
+
? /* eslint-disable indent */
|
|
43
|
+
[
|
|
44
|
+
{ fileName: 'image1.png', fileSize: '134KB', image: <img src={filePreview} alt="Preview one" /> },
|
|
45
|
+
{ fileName: 'image2.png', fileSize: '134KB', image: <img src={filePreview} alt="Preview two" /> }
|
|
46
|
+
]
|
|
47
|
+
: [{ fileName: 'image.png', fileSize: '134KB', image: <img src={filePreview} alt="One" /> }]
|
|
48
|
+
/* eslint-enable indent */
|
|
49
|
+
}
|
|
50
|
+
></ImagePreview>
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
};
|
package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithDeepThinking.tsx
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
3
|
+
import patternflyAvatar from './patternfly_avatar.jpg';
|
|
4
|
+
|
|
5
|
+
export const MessageWithDeepThinkingExample: FunctionComponent = () => (
|
|
6
|
+
<Message
|
|
7
|
+
name="Bot"
|
|
8
|
+
role="bot"
|
|
9
|
+
avatar={patternflyAvatar}
|
|
10
|
+
content="This example has a body description that's within the recommended limit of 2 lines."
|
|
11
|
+
deepThinking={{
|
|
12
|
+
toggleContent: 'Show thinking',
|
|
13
|
+
subheading: 'Thought for 3 seconds',
|
|
14
|
+
body: "Here's why I said this."
|
|
15
|
+
}}
|
|
16
|
+
/>
|
|
17
|
+
);
|
package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithFeedback.tsx
CHANGED
|
@@ -1,104 +1,130 @@
|
|
|
1
1
|
import { useState, FunctionComponent } from 'react';
|
|
2
2
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
3
3
|
import patternflyAvatar from './patternfly_avatar.jpg';
|
|
4
|
-
import { Checkbox, FormGroup,
|
|
4
|
+
import { Checkbox, FormGroup, Flex, FlexItem } from '@patternfly/react-core';
|
|
5
5
|
|
|
6
6
|
export const MessageWithFeedbackExample: FunctionComponent = () => {
|
|
7
7
|
const [hasCloseButton, setHasCloseButton] = useState(false);
|
|
8
8
|
const [hasTextArea, setHasTextArea] = useState(false);
|
|
9
|
+
const [hasChildren, setHasChildren] = useState(false);
|
|
10
|
+
|
|
11
|
+
const children = <>Do not share any personal or other sensitive information in your feedback.</>;
|
|
9
12
|
|
|
10
13
|
return (
|
|
11
14
|
<>
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
<Flex direction={{ default: 'column' }} spaceItems={{ default: 'spaceItemsMd' }}>
|
|
16
|
+
<FlexItem>
|
|
17
|
+
<FormGroup role="radiogroup" isInline isStack fieldId="feedback-card" label="Variant">
|
|
18
|
+
<Checkbox
|
|
19
|
+
isChecked={hasTextArea}
|
|
20
|
+
onChange={() => {
|
|
21
|
+
setHasTextArea(!hasTextArea);
|
|
22
|
+
}}
|
|
23
|
+
name="feedback-card-with-text-area"
|
|
24
|
+
label="Has text area"
|
|
25
|
+
id="has-text-area"
|
|
26
|
+
/>
|
|
27
|
+
<Checkbox
|
|
28
|
+
isChecked={hasChildren}
|
|
29
|
+
onChange={() => {
|
|
30
|
+
setHasChildren(!hasChildren);
|
|
31
|
+
}}
|
|
32
|
+
name="feedback-card-with-children"
|
|
33
|
+
label="Has additional content"
|
|
34
|
+
id="has-children"
|
|
35
|
+
/>
|
|
36
|
+
</FormGroup>
|
|
37
|
+
</FlexItem>
|
|
38
|
+
<FlexItem>
|
|
39
|
+
<Message
|
|
40
|
+
name="Bot"
|
|
41
|
+
role="bot"
|
|
42
|
+
avatar={patternflyAvatar}
|
|
43
|
+
content="This is a message with the feedback card:"
|
|
44
|
+
userFeedbackForm={{
|
|
45
|
+
quickResponses: [
|
|
46
|
+
{ id: '1', content: 'Helpful information' },
|
|
47
|
+
{ id: '2', content: 'Easy to understand' },
|
|
48
|
+
{ id: '3', content: 'Resolved my issue' }
|
|
49
|
+
],
|
|
50
|
+
onSubmit: (quickResponse, additionalFeedback) =>
|
|
51
|
+
alert(`Selected ${quickResponse} and received the additional feedback: ${additionalFeedback}`),
|
|
52
|
+
hasTextArea,
|
|
53
|
+
children: hasChildren ? children : undefined,
|
|
54
|
+
// eslint-disable-next-line no-console
|
|
55
|
+
onClose: () => console.log('closed feedback form'),
|
|
56
|
+
focusOnLoad: false
|
|
18
57
|
}}
|
|
19
|
-
name="basic-inline-radio"
|
|
20
|
-
label="Has text area"
|
|
21
|
-
id="has-text-area"
|
|
22
58
|
/>
|
|
23
|
-
</
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<Message
|
|
44
|
-
name="Bot"
|
|
45
|
-
role="bot"
|
|
46
|
-
avatar={patternflyAvatar}
|
|
47
|
-
content="This is a compact message with the feedback card:"
|
|
48
|
-
userFeedbackForm={{
|
|
49
|
-
quickResponses: [
|
|
50
|
-
{ id: '1', content: 'Helpful information' },
|
|
51
|
-
{ id: '2', content: 'Easy to understand' },
|
|
52
|
-
{ id: '3', content: 'Resolved my issue' }
|
|
53
|
-
],
|
|
54
|
-
onSubmit: (quickResponse, additionalFeedback) =>
|
|
55
|
-
alert(`Selected ${quickResponse} and received the additional feedback: ${additionalFeedback}`),
|
|
56
|
-
hasTextArea,
|
|
57
|
-
// eslint-disable-next-line no-console
|
|
58
|
-
onClose: () => console.log('closed feedback form'),
|
|
59
|
-
focusOnLoad: false
|
|
60
|
-
}}
|
|
61
|
-
isCompact
|
|
62
|
-
/>
|
|
63
|
-
</Stack>
|
|
64
|
-
<Stack hasGutter>
|
|
65
|
-
<FormGroup role="radiogroup" isInline fieldId="feedback-thank-you" label="Variant">
|
|
66
|
-
<Checkbox
|
|
67
|
-
isChecked={hasCloseButton}
|
|
68
|
-
onChange={() => {
|
|
69
|
-
setHasCloseButton(!hasCloseButton);
|
|
59
|
+
</FlexItem>
|
|
60
|
+
<FlexItem>
|
|
61
|
+
<Message
|
|
62
|
+
name="Bot"
|
|
63
|
+
role="bot"
|
|
64
|
+
avatar={patternflyAvatar}
|
|
65
|
+
content="This is a compact message with the feedback card:"
|
|
66
|
+
userFeedbackForm={{
|
|
67
|
+
quickResponses: [
|
|
68
|
+
{ id: '1', content: 'Helpful information' },
|
|
69
|
+
{ id: '2', content: 'Easy to understand' },
|
|
70
|
+
{ id: '3', content: 'Resolved my issue' }
|
|
71
|
+
],
|
|
72
|
+
onSubmit: (quickResponse, additionalFeedback) =>
|
|
73
|
+
alert(`Selected ${quickResponse} and received the additional feedback: ${additionalFeedback}`),
|
|
74
|
+
hasTextArea,
|
|
75
|
+
children: hasChildren ? children : undefined,
|
|
76
|
+
// eslint-disable-next-line no-console
|
|
77
|
+
onClose: () => console.log('closed feedback form'),
|
|
78
|
+
focusOnLoad: false
|
|
70
79
|
}}
|
|
71
|
-
|
|
72
|
-
label="Has close button"
|
|
73
|
-
id="has-close"
|
|
80
|
+
isCompact
|
|
74
81
|
/>
|
|
75
|
-
</
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
</FlexItem>
|
|
83
|
+
</Flex>
|
|
84
|
+
<Flex direction={{ default: 'column' }}>
|
|
85
|
+
<FlexItem>
|
|
86
|
+
<FormGroup role="radiogroup" isInline fieldId="feedback-thank-you" label="Variant">
|
|
87
|
+
<Checkbox
|
|
88
|
+
isChecked={hasCloseButton}
|
|
89
|
+
onChange={() => {
|
|
90
|
+
setHasCloseButton(!hasCloseButton);
|
|
91
|
+
}}
|
|
92
|
+
name="basic-inline-radio"
|
|
93
|
+
label="Has close button"
|
|
94
|
+
id="has-close"
|
|
95
|
+
/>
|
|
96
|
+
</FormGroup>
|
|
97
|
+
</FlexItem>
|
|
98
|
+
<FlexItem>
|
|
99
|
+
<Message
|
|
100
|
+
name="Bot"
|
|
101
|
+
role="bot"
|
|
102
|
+
avatar={patternflyAvatar}
|
|
103
|
+
content="This is a thank-you message, which is displayed once the feedback card is submitted:"
|
|
83
104
|
// eslint-disable-next-line no-console
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
105
|
+
userFeedbackComplete={{
|
|
106
|
+
// eslint-disable-next-line no-console
|
|
107
|
+
onClose: hasCloseButton ? () => console.log('closed completion message') : undefined,
|
|
108
|
+
focusOnLoad: false
|
|
109
|
+
}}
|
|
110
|
+
/>
|
|
111
|
+
</FlexItem>
|
|
112
|
+
<FlexItem>
|
|
113
|
+
<Message
|
|
114
|
+
name="Bot"
|
|
115
|
+
role="bot"
|
|
116
|
+
avatar={patternflyAvatar}
|
|
117
|
+
content="This is a compact thank-you message, which is displayed once the feedback card is submitted:"
|
|
95
118
|
// eslint-disable-next-line no-console
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
119
|
+
userFeedbackComplete={{
|
|
120
|
+
// eslint-disable-next-line no-console
|
|
121
|
+
onClose: hasCloseButton ? () => console.log('closed completion message') : undefined,
|
|
122
|
+
focusOnLoad: false
|
|
123
|
+
}}
|
|
124
|
+
isCompact
|
|
125
|
+
/>
|
|
126
|
+
</FlexItem>
|
|
127
|
+
</Flex>
|
|
102
128
|
</>
|
|
103
129
|
);
|
|
104
130
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FunctionComponent, MouseEvent as ReactMouseEvent, KeyboardEvent as ReactKeyboardEvent } from 'react';
|
|
2
2
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
3
3
|
import patternflyAvatar from './patternfly_avatar.jpg';
|
|
4
|
+
import { Button, Flex, FlexItem, Label, Popover } from '@patternfly/react-core';
|
|
5
|
+
import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons';
|
|
4
6
|
|
|
5
7
|
export const MessageWithSourcesExample: FunctionComponent = () => {
|
|
6
8
|
const onSetPage = (_event: ReactMouseEvent | ReactKeyboardEvent | MouseEvent, newPage: number) => {
|
|
@@ -8,8 +10,76 @@ export const MessageWithSourcesExample: FunctionComponent = () => {
|
|
|
8
10
|
console.log(`Page changed to ${newPage}`);
|
|
9
11
|
};
|
|
10
12
|
|
|
13
|
+
const date = new Date();
|
|
14
|
+
|
|
15
|
+
const datePart = date.toLocaleDateString('en', {
|
|
16
|
+
year: 'numeric',
|
|
17
|
+
month: 'short',
|
|
18
|
+
day: 'numeric'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const timePart = date.toLocaleTimeString('en', {
|
|
22
|
+
hour: '2-digit',
|
|
23
|
+
minute: '2-digit',
|
|
24
|
+
hour12: true
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const formattedDate = `${datePart}, ${timePart}`;
|
|
28
|
+
|
|
11
29
|
return (
|
|
12
30
|
<>
|
|
31
|
+
<Message
|
|
32
|
+
name="Bot"
|
|
33
|
+
role="bot"
|
|
34
|
+
avatar={patternflyAvatar}
|
|
35
|
+
content="This example has a custom subtitle and footer with no pagination"
|
|
36
|
+
sources={{
|
|
37
|
+
sources: [
|
|
38
|
+
{
|
|
39
|
+
title: 'Getting started with Red Hat OpenShift',
|
|
40
|
+
subtitle: 'Red Hat knowledge base',
|
|
41
|
+
link: '#',
|
|
42
|
+
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 ...',
|
|
43
|
+
isExternal: true,
|
|
44
|
+
footer: (
|
|
45
|
+
<Flex className="pf-chatbot__sources-card-subtle" gap={{ default: 'gapXs' }}>
|
|
46
|
+
<FlexItem alignSelf={{ default: 'alignSelfStretch' }}>
|
|
47
|
+
<Flex justifyContent={{ default: 'justifyContentSpaceBetween' }}>
|
|
48
|
+
<FlexItem>
|
|
49
|
+
<Label color="green">Confidence 93%</Label>
|
|
50
|
+
</FlexItem>
|
|
51
|
+
<FlexItem>
|
|
52
|
+
<Popover
|
|
53
|
+
headerContent={
|
|
54
|
+
<Flex gap={{ default: 'gapXs' }}>
|
|
55
|
+
<FlexItem>
|
|
56
|
+
<OutlinedQuestionCircleIcon />
|
|
57
|
+
</FlexItem>
|
|
58
|
+
<FlexItem>Why this confidence score?</FlexItem>
|
|
59
|
+
</Flex>
|
|
60
|
+
}
|
|
61
|
+
bodyContent={
|
|
62
|
+
<>
|
|
63
|
+
A high confidence score indicates a strong match. The system found significant overlap in
|
|
64
|
+
key data points, including text content, names, dates, and organizational details, with a
|
|
65
|
+
high degree of certainty. This match is highly reliable.
|
|
66
|
+
</>
|
|
67
|
+
}
|
|
68
|
+
>
|
|
69
|
+
<Button variant="link" icon={<OutlinedQuestionCircleIcon />}>
|
|
70
|
+
Learn about this score
|
|
71
|
+
</Button>
|
|
72
|
+
</Popover>
|
|
73
|
+
</FlexItem>
|
|
74
|
+
</Flex>
|
|
75
|
+
</FlexItem>
|
|
76
|
+
<FlexItem>{`Last updated: ${formattedDate}`}</FlexItem>
|
|
77
|
+
</Flex>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
13
83
|
<Message
|
|
14
84
|
name="Bot"
|
|
15
85
|
role="bot"
|