@patternfly/chatbot 6.3.0 → 6.4.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.d.ts +5 -1
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +3 -3
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +17 -0
- 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/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/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/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 +6 -4
- 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/ChatbotHeaderBasic.tsx +17 -3
- 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 +16 -3
- 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 +34 -12
- package/src/ChatbotFooter/ChatbotFooter.scss +1 -1
- package/src/ChatbotHeader/ChatbotHeader.scss +3 -3
- package/src/ChatbotHeader/ChatbotHeaderNewChatButton.test.tsx +25 -0
- package/src/ChatbotHeader/ChatbotHeaderNewChatButton.tsx +64 -0
- package/src/ChatbotHeader/index.ts +1 -0
- package/src/ChatbotToggle/ChatbotToggle.scss +2 -2
- package/src/FileDetails/__snapshots__/FileDetails.test.tsx.snap +6 -9
- package/src/FileDetailsLabel/__snapshots__/FileDetailsLabel.test.tsx.snap +6 -9
- 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
|
@@ -45,7 +45,7 @@ import ErrorMessage from './ErrorMessage/ErrorMessage';
|
|
|
45
45
|
import MessageInput from './MessageInput';
|
|
46
46
|
import { rehypeMoveImagesOutOfParagraphs } from './Plugins/rehypeMoveImagesOutOfParagraphs';
|
|
47
47
|
export const MessageBase = (_a) => {
|
|
48
|
-
var { role, content, extraContent, name, avatar, timestamp, isLoading, actions, sources, botWord = 'AI', loadingWord = 'Loading message', codeBlockProps, quickResponses, quickResponseContainerProps = { numLabels: 5 }, attachments, hasRoundAvatar = true, avatarProps, quickStarts, userFeedbackForm, userFeedbackComplete, isLiveRegion = true, innerRef, tableProps, openLinkInNewTab = true, additionalRehypePlugins = [], linkProps, error, isEditable, editPlaceholder = 'Edit prompt message...', updateWord = 'Update', cancelWord = 'Cancel', onEditUpdate, onEditCancel, editFormProps, isCompact } = _a, props = __rest(_a, ["role", "content", "extraContent", "name", "avatar", "timestamp", "isLoading", "actions", "sources", "botWord", "loadingWord", "codeBlockProps", "quickResponses", "quickResponseContainerProps", "attachments", "hasRoundAvatar", "avatarProps", "quickStarts", "userFeedbackForm", "userFeedbackComplete", "isLiveRegion", "innerRef", "tableProps", "openLinkInNewTab", "additionalRehypePlugins", "linkProps", "error", "isEditable", "editPlaceholder", "updateWord", "cancelWord", "onEditUpdate", "onEditCancel", "editFormProps", "isCompact"]);
|
|
48
|
+
var { role, content, extraContent, name, avatar, timestamp, isLoading, actions, sources, botWord = 'AI', loadingWord = 'Loading message', codeBlockProps, quickResponses, quickResponseContainerProps = { numLabels: 5 }, attachments, hasRoundAvatar = true, avatarProps, quickStarts, userFeedbackForm, userFeedbackComplete, isLiveRegion = true, innerRef, tableProps, openLinkInNewTab = true, additionalRehypePlugins = [], linkProps, error, isEditable, editPlaceholder = 'Edit prompt message...', updateWord = 'Update', cancelWord = 'Cancel', onEditUpdate, onEditCancel, inputRef, editFormProps, isCompact } = _a, props = __rest(_a, ["role", "content", "extraContent", "name", "avatar", "timestamp", "isLoading", "actions", "sources", "botWord", "loadingWord", "codeBlockProps", "quickResponses", "quickResponseContainerProps", "attachments", "hasRoundAvatar", "avatarProps", "quickStarts", "userFeedbackForm", "userFeedbackComplete", "isLiveRegion", "innerRef", "tableProps", "openLinkInNewTab", "additionalRehypePlugins", "linkProps", "error", "isEditable", "editPlaceholder", "updateWord", "cancelWord", "onEditUpdate", "onEditCancel", "inputRef", "editFormProps", "isCompact"]);
|
|
49
49
|
const [messageText, setMessageText] = useState(content);
|
|
50
50
|
useEffect(() => {
|
|
51
51
|
setMessageText(content);
|
|
@@ -72,10 +72,10 @@ export const MessageBase = (_a) => {
|
|
|
72
72
|
return _jsx(MessageLoading, { loadingWord: loadingWord });
|
|
73
73
|
}
|
|
74
74
|
if (isEditable) {
|
|
75
|
-
return (_jsxs(_Fragment, { children: [beforeMainContent && _jsx(_Fragment, { children: beforeMainContent }), _jsx(MessageInput, Object.assign({ content:
|
|
75
|
+
return (_jsxs(_Fragment, { children: [beforeMainContent && _jsx(_Fragment, { children: beforeMainContent }), _jsx(MessageInput, Object.assign({ content: messageText, editPlaceholder: editPlaceholder, updateWord: updateWord, cancelWord: cancelWord, onEditUpdate: (event, value) => {
|
|
76
76
|
onEditUpdate && onEditUpdate(event);
|
|
77
77
|
setMessageText(value);
|
|
78
|
-
}, onEditCancel: onEditCancel }, editFormProps))] }));
|
|
78
|
+
}, onEditCancel: onEditCancel, inputRef: inputRef }, editFormProps))] }));
|
|
79
79
|
}
|
|
80
80
|
return (_jsxs(_Fragment, { children: [beforeMainContent && _jsx(_Fragment, { children: beforeMainContent }), error ? (_jsx(ErrorMessage, Object.assign({}, error))) : (_jsx(Markdown, { components: {
|
|
81
81
|
p: (props) => _jsx(TextMessage, Object.assign({ component: ContentVariants.p }, props)),
|
|
@@ -108,7 +108,7 @@ export const MessageBase = (_a) => {
|
|
|
108
108
|
a: (props) => (_jsx(LinkMessage, Object.assign({ href: props.href, rel: props.rel, target: props.target }, linkProps, { children: props.children })))
|
|
109
109
|
}, remarkPlugins: [remarkGfm], rehypePlugins: rehypePlugins, children: messageText }))] }));
|
|
110
110
|
};
|
|
111
|
-
return (_jsxs("section", Object.assign({ "aria-label": `Message from ${role} - ${dateString}`, className: `pf-chatbot__message pf-chatbot__message--${role}`, "aria-live": isLiveRegion ? 'polite' : undefined, "aria-atomic": isLiveRegion ? false : undefined, ref: innerRef }, props, { children: [_jsx(Avatar, Object.assign({ className: `pf-chatbot__message-avatar ${hasRoundAvatar ? 'pf-chatbot__message-avatar--round' : ''} ${avatarClassName ? avatarClassName : ''}`, src: avatar, alt: "" }, avatarProps)), _jsxs("div", { className: "pf-chatbot__message-contents", children: [_jsxs("div", { className: "pf-chatbot__message-meta", children: [name && (_jsx("span", { className: "pf-chatbot__message-name", children: _jsx(Truncate, { content: name }) })), role === 'bot' && (_jsx(Label, { variant: "outline", isCompact: true, children: botWord })), _jsx(Timestamp, { date: date, children: timestamp })] }), _jsxs("div", { className: "pf-chatbot__message-response", children: [_jsxs("div", { className: "pf-chatbot__message-and-actions", children: [renderMessage(), afterMainContent && _jsx(_Fragment, { children: afterMainContent }), !isLoading && sources && _jsx(SourcesCard, Object.assign({}, sources, { isCompact: isCompact })), quickStarts && quickStarts.quickStart && (_jsx(QuickStartTile, { quickStart: quickStarts.quickStart, onSelectQuickStart: quickStarts.onSelectQuickStart, minuteWord: quickStarts.minuteWord, minuteWordPlural: quickStarts.minuteWordPlural, prerequisiteWord: quickStarts.prerequisiteWord, prerequisiteWordPlural: quickStarts.prerequisiteWordPlural, quickStartButtonAriaLabel: quickStarts.quickStartButtonAriaLabel, isCompact: isCompact })), !isLoading && actions && _jsx(ResponseActions, { actions: actions }), userFeedbackForm && _jsx(UserFeedback, Object.assign({}, userFeedbackForm, { timestamp: dateString, isCompact: isCompact })), userFeedbackComplete && (_jsx(UserFeedbackComplete, Object.assign({}, userFeedbackComplete, { timestamp: dateString, isCompact: isCompact }))), !isLoading && quickResponses && (_jsx(QuickResponse, { quickResponses: quickResponses, quickResponseContainerProps: quickResponseContainerProps, isCompact: isCompact }))] }), attachments && (_jsx("div", { className: "pf-chatbot__message-attachments-container", children: attachments.map((attachment) => {
|
|
111
|
+
return (_jsxs("section", Object.assign({ "aria-label": `Message from ${role} - ${dateString}`, className: `pf-chatbot__message pf-chatbot__message--${role}`, "aria-live": isLiveRegion ? 'polite' : undefined, "aria-atomic": isLiveRegion ? false : undefined, ref: innerRef }, props, { children: [_jsx(Avatar, Object.assign({ className: `pf-chatbot__message-avatar ${hasRoundAvatar ? 'pf-chatbot__message-avatar--round' : ''} ${avatarClassName ? avatarClassName : ''}`, src: avatar, alt: "" }, avatarProps)), _jsxs("div", { className: "pf-chatbot__message-contents", children: [_jsxs("div", { className: "pf-chatbot__message-meta", children: [name && (_jsx("span", { className: "pf-chatbot__message-name", children: _jsx(Truncate, { content: name }) })), role === 'bot' && (_jsx(Label, { variant: "outline", isCompact: true, children: botWord })), _jsx(Timestamp, { date: date, children: timestamp })] }), _jsxs("div", { className: "pf-chatbot__message-response", children: [_jsxs("div", { className: "pf-chatbot__message-and-actions", children: [renderMessage(), afterMainContent && _jsx(_Fragment, { children: afterMainContent }), !isLoading && sources && _jsx(SourcesCard, Object.assign({}, sources, { isCompact: isCompact })), quickStarts && quickStarts.quickStart && (_jsx(QuickStartTile, { quickStart: quickStarts.quickStart, onSelectQuickStart: quickStarts.onSelectQuickStart, minuteWord: quickStarts.minuteWord, minuteWordPlural: quickStarts.minuteWordPlural, prerequisiteWord: quickStarts.prerequisiteWord, prerequisiteWordPlural: quickStarts.prerequisiteWordPlural, quickStartButtonAriaLabel: quickStarts.quickStartButtonAriaLabel, isCompact: isCompact })), !isLoading && !isEditable && actions && _jsx(ResponseActions, { actions: actions }), userFeedbackForm && _jsx(UserFeedback, Object.assign({}, userFeedbackForm, { timestamp: dateString, isCompact: isCompact })), userFeedbackComplete && (_jsx(UserFeedbackComplete, Object.assign({}, userFeedbackComplete, { timestamp: dateString, isCompact: isCompact }))), !isLoading && quickResponses && (_jsx(QuickResponse, { quickResponses: quickResponses, quickResponseContainerProps: quickResponseContainerProps, isCompact: isCompact }))] }), attachments && (_jsx("div", { className: "pf-chatbot__message-attachments-container", children: attachments.map((attachment) => {
|
|
112
112
|
var _a;
|
|
113
113
|
return (_jsx("div", { className: "pf-chatbot__message-attachment", children: _jsx(FileDetailsLabel, { fileName: attachment.name, fileId: attachment.id, onClose: attachment.onClose, onClick: attachment.onClick, isLoading: attachment.isLoading, closeButtonAriaLabel: attachment.closeButtonAriaLabel, languageTestId: attachment.languageTestId, spinnerTestId: attachment.spinnerTestId }) }, (_a = attachment.id) !== null && _a !== void 0 ? _a : attachment.name));
|
|
114
114
|
}) })), !isLoading && endContent && _jsx(_Fragment, { children: endContent })] })] })] })));
|
|
@@ -21,6 +21,7 @@ const ALL_ACTIONS = [
|
|
|
21
21
|
{ label: /Good response/i },
|
|
22
22
|
{ label: /Bad response/i },
|
|
23
23
|
{ label: /Copy/i },
|
|
24
|
+
{ label: /Edit/i },
|
|
24
25
|
{ label: /Share/i },
|
|
25
26
|
{ label: /Listen/i }
|
|
26
27
|
];
|
|
@@ -341,6 +342,8 @@ describe('Message', () => {
|
|
|
341
342
|
// eslint-disable-next-line no-console
|
|
342
343
|
copy: { onClick: () => console.log('Copy') },
|
|
343
344
|
// eslint-disable-next-line no-console
|
|
345
|
+
edit: { onClick: () => console.log('Edit') },
|
|
346
|
+
// eslint-disable-next-line no-console
|
|
344
347
|
share: { onClick: () => console.log('Share') },
|
|
345
348
|
// eslint-disable-next-line no-console
|
|
346
349
|
download: { onClick: () => console.log('Download') },
|
|
@@ -360,6 +363,8 @@ describe('Message', () => {
|
|
|
360
363
|
// eslint-disable-next-line no-console
|
|
361
364
|
copy: { onClick: () => console.log('Copy') },
|
|
362
365
|
// eslint-disable-next-line no-console
|
|
366
|
+
edit: { onClick: () => console.log('Edit') },
|
|
367
|
+
// eslint-disable-next-line no-console
|
|
363
368
|
share: { onClick: () => console.log('Share') },
|
|
364
369
|
// eslint-disable-next-line no-console
|
|
365
370
|
download: { onClick: () => console.log('Download') },
|
|
@@ -371,6 +376,27 @@ describe('Message', () => {
|
|
|
371
376
|
expect(screen.queryByRole('button', { name: label })).toBeFalsy();
|
|
372
377
|
});
|
|
373
378
|
}));
|
|
379
|
+
it('should not show actions if isEditable is true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
380
|
+
render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", isEditable: true, actions: {
|
|
381
|
+
// eslint-disable-next-line no-console
|
|
382
|
+
positive: { onClick: () => console.log('Good response') },
|
|
383
|
+
// eslint-disable-next-line no-console
|
|
384
|
+
negative: { onClick: () => console.log('Bad response') },
|
|
385
|
+
// eslint-disable-next-line no-console
|
|
386
|
+
copy: { onClick: () => console.log('Copy') },
|
|
387
|
+
// eslint-disable-next-line no-console
|
|
388
|
+
edit: { onClick: () => console.log('Edit') },
|
|
389
|
+
// eslint-disable-next-line no-console
|
|
390
|
+
share: { onClick: () => console.log('Share') },
|
|
391
|
+
// eslint-disable-next-line no-console
|
|
392
|
+
download: { onClick: () => console.log('Download') },
|
|
393
|
+
// eslint-disable-next-line no-console
|
|
394
|
+
listen: { onClick: () => console.log('Listen') }
|
|
395
|
+
} }));
|
|
396
|
+
ALL_ACTIONS.forEach(({ label }) => {
|
|
397
|
+
expect(screen.queryByRole('button', { name: label })).toBeFalsy();
|
|
398
|
+
});
|
|
399
|
+
}));
|
|
374
400
|
it('should render unordered lists correctly', () => {
|
|
375
401
|
render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: UNORDERED_LIST }));
|
|
376
402
|
expect(screen.getByText('Here is an unordered list:')).toBeTruthy();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FunctionComponent } from 'react';
|
|
1
|
+
import type { FunctionComponent, Ref } from 'react';
|
|
2
2
|
import { FormProps } from '@patternfly/react-core';
|
|
3
3
|
export interface MessageInputProps extends FormProps {
|
|
4
4
|
/** Placeholder for edit input */
|
|
@@ -11,6 +11,8 @@ export interface MessageInputProps extends FormProps {
|
|
|
11
11
|
onEditUpdate?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>, value: string) => void;
|
|
12
12
|
/** Callback functionf or when edit cancel update button is clicked */
|
|
13
13
|
onEditCancel?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
14
|
+
/** Ref applied to editable message input */
|
|
15
|
+
inputRef?: Ref<HTMLTextAreaElement>;
|
|
14
16
|
/** Message text */
|
|
15
17
|
content?: string;
|
|
16
18
|
}
|
|
@@ -13,11 +13,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { useState } from 'react';
|
|
14
14
|
import { ActionGroup, Button, Form, TextArea } from '@patternfly/react-core';
|
|
15
15
|
const MessageInput = (_a) => {
|
|
16
|
-
var { editPlaceholder = 'Edit prompt message...', updateWord = 'Update', cancelWord = 'Cancel', onEditUpdate, onEditCancel, content } = _a, props = __rest(_a, ["editPlaceholder", "updateWord", "cancelWord", "onEditUpdate", "onEditCancel", "content"]);
|
|
16
|
+
var { editPlaceholder = 'Edit prompt message...', updateWord = 'Update', cancelWord = 'Cancel', onEditUpdate, onEditCancel, inputRef, content } = _a, props = __rest(_a, ["editPlaceholder", "updateWord", "cancelWord", "onEditUpdate", "onEditCancel", "inputRef", "content"]);
|
|
17
17
|
const [messageText, setMessageText] = useState(content !== null && content !== void 0 ? content : '');
|
|
18
18
|
const onChange = (_event, value) => {
|
|
19
19
|
setMessageText(value);
|
|
20
20
|
};
|
|
21
|
-
return (_jsxs(Form, Object.assign({}, props, { children: [_jsx(TextArea, { placeholder: editPlaceholder, value: messageText, onChange: onChange, "aria-label": editPlaceholder, autoResize: true }), _jsxs(ActionGroup, { className: "pf-chatbot__message-edit-buttons", children: [_jsx(Button, { variant: "primary", onClick: (event) => onEditUpdate && onEditUpdate(event, messageText), children: updateWord }), _jsx(Button, { variant: "secondary", onClick: onEditCancel, children: cancelWord })] })] })));
|
|
21
|
+
return (_jsxs(Form, Object.assign({}, props, { children: [_jsx(TextArea, { placeholder: editPlaceholder, value: messageText, onChange: onChange, "aria-label": editPlaceholder, autoResize: true, ref: inputRef }), _jsxs(ActionGroup, { className: "pf-chatbot__message-edit-buttons", children: [_jsx(Button, { variant: "primary", onClick: (event) => onEditUpdate && onEditUpdate(event, messageText), children: updateWord }), _jsx(Button, { variant: "secondary", onClick: onEditCancel, children: cancelWord })] })] })));
|
|
22
22
|
};
|
|
23
23
|
export default MessageInput;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ButtonProps,
|
|
2
|
-
import { Accept, DropzoneOptions, FileError, FileRejection } from 'react-dropzone';
|
|
1
|
+
import { ButtonProps, TooltipProps } from '@patternfly/react-core';
|
|
2
|
+
import { Accept, DropEvent, DropzoneOptions, FileError, FileRejection } from 'react-dropzone';
|
|
3
3
|
export interface AttachButtonProps extends ButtonProps {
|
|
4
4
|
/** Callback for when button is clicked */
|
|
5
5
|
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FunctionComponent } from 'react';
|
|
2
|
-
import { Accept, DropzoneOptions, FileError, FileRejection } from 'react-dropzone
|
|
3
|
-
import { ButtonProps,
|
|
2
|
+
import { Accept, DropEvent, DropzoneOptions, FileError, FileRejection } from 'react-dropzone';
|
|
3
|
+
import { ButtonProps, TextAreaProps, TooltipProps } from '@patternfly/react-core';
|
|
4
4
|
import { ChatbotDisplayMode } from '../Chatbot';
|
|
5
5
|
export interface MessageBarWithAttachMenuProps {
|
|
6
6
|
/** Flag to enable whether attach menu is open */
|
|
@@ -200,6 +200,6 @@ export const MessageBox = forwardRef((_a, ref) => {
|
|
|
200
200
|
onTouchMove,
|
|
201
201
|
onTouchEnd
|
|
202
202
|
};
|
|
203
|
-
return (_jsxs(_Fragment, { children: [_jsx(JumpButton, { position: "top", isHidden: isOverflowing && atTop, onClick: scrollToTop }), _jsxs("div", Object.assign({ role: "region", tabIndex: 0, "aria-label": ariaLabel, className: `pf-chatbot__messagebox ${position === 'bottom'
|
|
203
|
+
return (_jsxs(_Fragment, { children: [_jsx(JumpButton, { position: "top", isHidden: isOverflowing && atTop, onClick: scrollToTop }), _jsxs("div", Object.assign({ role: "region", tabIndex: 0, "aria-label": ariaLabel, className: `pf-chatbot__messagebox ${position === 'bottom' ? 'pf-chatbot__messagebox--bottom' : ''} ${className !== null && className !== void 0 ? className : ''}`, ref: messageBoxRef }, props, (enableSmartScroll ? Object.assign({}, smartScrollHandlers) : {}), { children: [children, _jsx("div", { className: "pf-chatbot__messagebox-announcement", "aria-live": "polite", children: announcement })] })), _jsx(JumpButton, { position: "bottom", isHidden: isOverflowing && atBottom, onClick: () => scrollToBottom({ resumeSmartScroll: true }) })] }));
|
|
204
204
|
});
|
|
205
205
|
export default MessageBox;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
export interface MessageDividerProps {
|
|
3
|
+
/** Variant of the divider */
|
|
4
|
+
variant?: 'inset' | 'fullWidth';
|
|
5
|
+
/** Content of the message divider */
|
|
6
|
+
content?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const MessageDivider: FunctionComponent<MessageDividerProps>;
|
|
9
|
+
export default MessageDivider;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Divider, Label } from '@patternfly/react-core';
|
|
14
|
+
const MessageDivider = (_a) => {
|
|
15
|
+
var { variant = 'inset', content = new Date().toLocaleDateString() } = _a, props = __rest(_a, ["variant", "content"]);
|
|
16
|
+
if (variant === 'inset') {
|
|
17
|
+
return (_jsxs("div", Object.assign({ className: "pf-chatbot__message-divider pf-m-divider pf-m-wrap" }, props, { children: [_jsx(Divider, {}), _jsx(Label, { variant: "outline", children: content })] })));
|
|
18
|
+
}
|
|
19
|
+
return (_jsx("div", Object.assign({ className: "pf-chatbot__message-divider pf-m-wrap" }, props, { children: _jsx(Label, { children: content }) })));
|
|
20
|
+
};
|
|
21
|
+
export default MessageDivider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import MessageDivider from './MessageDivider';
|
|
5
|
+
describe('MessageDivider', () => {
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
jest.clearAllMocks();
|
|
8
|
+
});
|
|
9
|
+
it('should render default correctly with variant = date and content = new Date().toLocaleDateString()', () => {
|
|
10
|
+
render(_jsx(MessageDivider, { "data-testid": "message-divider" }));
|
|
11
|
+
expect(screen.getByText(new Date().toLocaleDateString())).toBeInTheDocument();
|
|
12
|
+
expect(screen.getByTestId('message-divider')).toHaveClass('pf-m-divider');
|
|
13
|
+
});
|
|
14
|
+
it('should render inset variant correctly', () => {
|
|
15
|
+
render(_jsx(MessageDivider, { variant: "inset", content: "test", "data-testid": "message-divider" }));
|
|
16
|
+
expect(screen.getByText('test')).toBeInTheDocument();
|
|
17
|
+
expect(screen.getByTestId('message-divider')).toHaveClass('pf-m-divider');
|
|
18
|
+
});
|
|
19
|
+
it('should render fullWidth variant correctly', () => {
|
|
20
|
+
render(_jsx(MessageDivider, { variant: "fullWidth", content: "test", "data-testid": "message-divider" }));
|
|
21
|
+
expect(screen.getByText('test')).toBeInTheDocument();
|
|
22
|
+
expect(screen.getByTestId('message-divider')).not.toHaveClass('pf-m-divider');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -12,15 +12,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { createElement as _createElement } from "react";
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { useEffect, useRef, useState } from 'react';
|
|
15
|
-
import { ExternalLinkAltIcon, VolumeUpIcon, OutlinedThumbsUpIcon, OutlinedThumbsDownIcon, OutlinedCopyIcon, DownloadIcon } from '@patternfly/react-icons';
|
|
15
|
+
import { ExternalLinkAltIcon, VolumeUpIcon, OutlinedThumbsUpIcon, OutlinedThumbsDownIcon, OutlinedCopyIcon, DownloadIcon, PencilAltIcon } from '@patternfly/react-icons';
|
|
16
16
|
import ResponseActionButton from './ResponseActionButton';
|
|
17
17
|
export const ResponseActions = ({ actions }) => {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
19
19
|
const [activeButton, setActiveButton] = useState();
|
|
20
20
|
const [clickStatePersisted, setClickStatePersisted] = useState(false);
|
|
21
21
|
useEffect(() => {
|
|
22
22
|
// Define the order of precedence for checking initial `isClicked`
|
|
23
|
-
const actionPrecedence = ['positive', 'negative', 'copy', 'share', 'download', 'listen'];
|
|
23
|
+
const actionPrecedence = ['positive', 'negative', 'copy', 'edit', 'share', 'download', 'listen'];
|
|
24
24
|
let initialActive;
|
|
25
25
|
// Check predefined actions first based on precedence
|
|
26
26
|
for (const actionName of actionPrecedence) {
|
|
@@ -41,7 +41,7 @@ export const ResponseActions = ({ actions }) => {
|
|
|
41
41
|
}
|
|
42
42
|
setActiveButton(initialActive);
|
|
43
43
|
}, [actions]);
|
|
44
|
-
const { positive, negative, copy, share, download, listen } = actions, additionalActions = __rest(actions, ["positive", "negative", "copy", "share", "download", "listen"]);
|
|
44
|
+
const { positive, negative, copy, edit, share, download, listen } = actions, additionalActions = __rest(actions, ["positive", "negative", "copy", "edit", "share", "download", "listen"]);
|
|
45
45
|
const responseActions = useRef(null);
|
|
46
46
|
useEffect(() => {
|
|
47
47
|
const handleClickOutside = (e) => {
|
|
@@ -59,7 +59,7 @@ export const ResponseActions = ({ actions }) => {
|
|
|
59
59
|
setActiveButton(id);
|
|
60
60
|
onClick && onClick(e);
|
|
61
61
|
};
|
|
62
|
-
return (_jsxs("div", { ref: responseActions, className: "pf-chatbot__response-actions", children: [positive && (_jsx(ResponseActionButton, Object.assign({}, positive, { ariaLabel: (_a = positive.ariaLabel) !== null && _a !== void 0 ? _a : 'Good response', clickedAriaLabel: (_b = positive.ariaLabel) !== null && _b !== void 0 ? _b : 'Response recorded', onClick: (e) => handleClick(e, 'positive', positive.onClick), className: positive.className, isDisabled: positive.isDisabled, tooltipContent: (_c = positive.tooltipContent) !== null && _c !== void 0 ? _c : 'Good response', clickedTooltipContent: (_d = positive.clickedTooltipContent) !== null && _d !== void 0 ? _d : 'Response recorded', tooltipProps: positive.tooltipProps, icon: _jsx(OutlinedThumbsUpIcon, {}), isClicked: activeButton === 'positive', ref: positive.ref, "aria-expanded": positive['aria-expanded'], "aria-controls": positive['aria-controls'] }))), negative && (_jsx(ResponseActionButton, Object.assign({}, negative, { ariaLabel: (_e = negative.ariaLabel) !== null && _e !== void 0 ? _e : 'Bad response', clickedAriaLabel: (_f = negative.ariaLabel) !== null && _f !== void 0 ? _f : 'Response recorded', onClick: (e) => handleClick(e, 'negative', negative.onClick), className: negative.className, isDisabled: negative.isDisabled, tooltipContent: (_g = negative.tooltipContent) !== null && _g !== void 0 ? _g : 'Bad response', clickedTooltipContent: (_h = negative.clickedTooltipContent) !== null && _h !== void 0 ? _h : 'Response recorded', tooltipProps: negative.tooltipProps, icon: _jsx(OutlinedThumbsDownIcon, {}), isClicked: activeButton === 'negative', ref: negative.ref, "aria-expanded": negative['aria-expanded'], "aria-controls": negative['aria-controls'] }))), copy && (_jsx(ResponseActionButton, Object.assign({}, copy, { ariaLabel: (_j = copy.ariaLabel) !== null && _j !== void 0 ? _j : 'Copy', clickedAriaLabel: (_k = copy.ariaLabel) !== null && _k !== void 0 ? _k : 'Copied', onClick: (e) => handleClick(e, 'copy', copy.onClick), className: copy.className, isDisabled: copy.isDisabled, tooltipContent: (_l = copy.tooltipContent) !== null && _l !== void 0 ? _l : 'Copy', clickedTooltipContent: (_m = copy.clickedTooltipContent) !== null && _m !== void 0 ? _m : 'Copied', tooltipProps: copy.tooltipProps, icon: _jsx(OutlinedCopyIcon, {}), isClicked: activeButton === 'copy', ref: copy.ref, "aria-expanded": copy['aria-expanded'], "aria-controls": copy['aria-controls'] }))),
|
|
62
|
+
return (_jsxs("div", { ref: responseActions, className: "pf-chatbot__response-actions", children: [positive && (_jsx(ResponseActionButton, Object.assign({}, positive, { ariaLabel: (_a = positive.ariaLabel) !== null && _a !== void 0 ? _a : 'Good response', clickedAriaLabel: (_b = positive.ariaLabel) !== null && _b !== void 0 ? _b : 'Response recorded', onClick: (e) => handleClick(e, 'positive', positive.onClick), className: positive.className, isDisabled: positive.isDisabled, tooltipContent: (_c = positive.tooltipContent) !== null && _c !== void 0 ? _c : 'Good response', clickedTooltipContent: (_d = positive.clickedTooltipContent) !== null && _d !== void 0 ? _d : 'Response recorded', tooltipProps: positive.tooltipProps, icon: _jsx(OutlinedThumbsUpIcon, {}), isClicked: activeButton === 'positive', ref: positive.ref, "aria-expanded": positive['aria-expanded'], "aria-controls": positive['aria-controls'] }))), negative && (_jsx(ResponseActionButton, Object.assign({}, negative, { ariaLabel: (_e = negative.ariaLabel) !== null && _e !== void 0 ? _e : 'Bad response', clickedAriaLabel: (_f = negative.ariaLabel) !== null && _f !== void 0 ? _f : 'Response recorded', onClick: (e) => handleClick(e, 'negative', negative.onClick), className: negative.className, isDisabled: negative.isDisabled, tooltipContent: (_g = negative.tooltipContent) !== null && _g !== void 0 ? _g : 'Bad response', clickedTooltipContent: (_h = negative.clickedTooltipContent) !== null && _h !== void 0 ? _h : 'Response recorded', tooltipProps: negative.tooltipProps, icon: _jsx(OutlinedThumbsDownIcon, {}), isClicked: activeButton === 'negative', ref: negative.ref, "aria-expanded": negative['aria-expanded'], "aria-controls": negative['aria-controls'] }))), copy && (_jsx(ResponseActionButton, Object.assign({}, copy, { ariaLabel: (_j = copy.ariaLabel) !== null && _j !== void 0 ? _j : 'Copy', clickedAriaLabel: (_k = copy.ariaLabel) !== null && _k !== void 0 ? _k : 'Copied', onClick: (e) => handleClick(e, 'copy', copy.onClick), className: copy.className, isDisabled: copy.isDisabled, tooltipContent: (_l = copy.tooltipContent) !== null && _l !== void 0 ? _l : 'Copy', clickedTooltipContent: (_m = copy.clickedTooltipContent) !== null && _m !== void 0 ? _m : 'Copied', tooltipProps: copy.tooltipProps, icon: _jsx(OutlinedCopyIcon, {}), isClicked: activeButton === 'copy', ref: copy.ref, "aria-expanded": copy['aria-expanded'], "aria-controls": copy['aria-controls'] }))), edit && (_jsx(ResponseActionButton, Object.assign({}, edit, { ariaLabel: (_o = edit.ariaLabel) !== null && _o !== void 0 ? _o : 'Edit', clickedAriaLabel: (_p = edit.ariaLabel) !== null && _p !== void 0 ? _p : 'Editing', onClick: (e) => handleClick(e, 'edit', edit.onClick), className: edit.className, isDisabled: edit.isDisabled, tooltipContent: (_q = edit.tooltipContent) !== null && _q !== void 0 ? _q : 'Edit ', clickedTooltipContent: (_r = edit.clickedTooltipContent) !== null && _r !== void 0 ? _r : 'Editing', tooltipProps: edit.tooltipProps, icon: _jsx(PencilAltIcon, {}), isClicked: activeButton === 'edit', ref: edit.ref, "aria-expanded": edit['aria-expanded'], "aria-controls": edit['aria-controls'] }))), share && (_jsx(ResponseActionButton, Object.assign({}, share, { ariaLabel: (_s = share.ariaLabel) !== null && _s !== void 0 ? _s : 'Share', clickedAriaLabel: (_t = share.ariaLabel) !== null && _t !== void 0 ? _t : 'Shared', onClick: (e) => handleClick(e, 'share', share.onClick), className: share.className, isDisabled: share.isDisabled, tooltipContent: (_u = share.tooltipContent) !== null && _u !== void 0 ? _u : 'Share', clickedTooltipContent: (_v = share.clickedTooltipContent) !== null && _v !== void 0 ? _v : 'Shared', tooltipProps: share.tooltipProps, icon: _jsx(ExternalLinkAltIcon, {}), isClicked: activeButton === 'share', ref: share.ref, "aria-expanded": share['aria-expanded'], "aria-controls": share['aria-controls'] }))), download && (_jsx(ResponseActionButton, Object.assign({}, download, { ariaLabel: (_w = download.ariaLabel) !== null && _w !== void 0 ? _w : 'Download', clickedAriaLabel: (_x = download.ariaLabel) !== null && _x !== void 0 ? _x : 'Downloaded', onClick: (e) => handleClick(e, 'download', download.onClick), className: download.className, isDisabled: download.isDisabled, tooltipContent: (_y = download.tooltipContent) !== null && _y !== void 0 ? _y : 'Download', clickedTooltipContent: (_z = download.clickedTooltipContent) !== null && _z !== void 0 ? _z : 'Downloaded', tooltipProps: download.tooltipProps, icon: _jsx(DownloadIcon, {}), isClicked: activeButton === 'download', ref: download.ref, "aria-expanded": download['aria-expanded'], "aria-controls": download['aria-controls'] }))), listen && (_jsx(ResponseActionButton, Object.assign({}, listen, { ariaLabel: (_0 = listen.ariaLabel) !== null && _0 !== void 0 ? _0 : 'Listen', clickedAriaLabel: (_1 = listen.ariaLabel) !== null && _1 !== void 0 ? _1 : 'Listening', onClick: (e) => handleClick(e, 'listen', listen.onClick), className: listen.className, isDisabled: listen.isDisabled, tooltipContent: (_2 = listen.tooltipContent) !== null && _2 !== void 0 ? _2 : 'Listen', clickedTooltipContent: (_3 = listen.clickedTooltipContent) !== null && _3 !== void 0 ? _3 : 'Listening', tooltipProps: listen.tooltipProps, icon: _jsx(VolumeUpIcon, {}), isClicked: activeButton === 'listen', ref: listen.ref, "aria-expanded": listen['aria-expanded'], "aria-controls": listen['aria-controls'] }))), Object.keys(additionalActions).map((action) => {
|
|
63
63
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
64
64
|
return (_createElement(ResponseActionButton, Object.assign({}, additionalActions[action], { key: action, ariaLabel: (_a = additionalActions[action]) === null || _a === void 0 ? void 0 : _a.ariaLabel, clickedAriaLabel: (_b = additionalActions[action]) === null || _b === void 0 ? void 0 : _b.clickedAriaLabel, onClick: (e) => { var _a; return handleClick(e, action, (_a = additionalActions[action]) === null || _a === void 0 ? void 0 : _a.onClick); }, className: (_c = additionalActions[action]) === null || _c === void 0 ? void 0 : _c.className, isDisabled: (_d = additionalActions[action]) === null || _d === void 0 ? void 0 : _d.isDisabled, tooltipContent: (_e = additionalActions[action]) === null || _e === void 0 ? void 0 : _e.tooltipContent, tooltipProps: (_f = additionalActions[action]) === null || _f === void 0 ? void 0 : _f.tooltipProps, clickedTooltipContent: (_g = additionalActions[action]) === null || _g === void 0 ? void 0 : _g.clickedTooltipContent, icon: (_h = additionalActions[action]) === null || _h === void 0 ? void 0 : _h.icon, isClicked: activeButton === action, ref: (_j = additionalActions[action]) === null || _j === void 0 ? void 0 : _j.ref, "aria-expanded": (_k = additionalActions[action]) === null || _k === void 0 ? void 0 : _k['aria-expanded'], "aria-controls": (_l = additionalActions[action]) === null || _l === void 0 ? void 0 : _l['aria-controls'] })));
|
|
65
65
|
})] }));
|
|
@@ -18,6 +18,7 @@ const ALL_ACTIONS = [
|
|
|
18
18
|
{ type: 'positive', label: 'Good response', clickedLabel: 'Response recorded' },
|
|
19
19
|
{ type: 'negative', label: 'Bad response', clickedLabel: 'Response recorded' },
|
|
20
20
|
{ type: 'copy', label: 'Copy', clickedLabel: 'Copied' },
|
|
21
|
+
{ type: 'edit', label: 'Edit', clickedLabel: 'Editing' },
|
|
21
22
|
{ type: 'share', label: 'Share', clickedLabel: 'Shared' },
|
|
22
23
|
{ type: 'listen', label: 'Listen', clickedLabel: 'Listening' }
|
|
23
24
|
];
|
|
@@ -51,6 +52,7 @@ const ALL_ACTIONS_DATA_TEST = [
|
|
|
51
52
|
{ type: 'positive', label: 'Good response', dataTestId: 'positive' },
|
|
52
53
|
{ type: 'negative', label: 'Bad response', dataTestId: 'negative' },
|
|
53
54
|
{ type: 'copy', label: 'Copy', dataTestId: 'copy' },
|
|
55
|
+
{ type: 'edit', label: 'Edit', dataTestId: 'edit' },
|
|
54
56
|
{ type: 'share', label: 'Share', dataTestId: 'share' },
|
|
55
57
|
{ type: 'download', label: 'Download', dataTestId: 'download' },
|
|
56
58
|
{ type: 'listen', label: 'Listen', dataTestId: 'listen' }
|
|
@@ -64,6 +66,7 @@ describe('ResponseActions', () => {
|
|
|
64
66
|
positive: { onClick: jest.fn() },
|
|
65
67
|
negative: { onClick: jest.fn() },
|
|
66
68
|
copy: { onClick: jest.fn() },
|
|
69
|
+
edit: { onClick: jest.fn() },
|
|
67
70
|
share: { onClick: jest.fn() },
|
|
68
71
|
download: { onClick: jest.fn() },
|
|
69
72
|
listen: { onClick: jest.fn() }
|
|
@@ -71,10 +74,11 @@ describe('ResponseActions', () => {
|
|
|
71
74
|
const goodBtn = screen.getByRole('button', { name: 'Good response' });
|
|
72
75
|
const badBtn = screen.getByRole('button', { name: 'Bad response' });
|
|
73
76
|
const copyBtn = screen.getByRole('button', { name: 'Copy' });
|
|
77
|
+
const editBtn = screen.getByRole('button', { name: 'Edit' });
|
|
74
78
|
const shareBtn = screen.getByRole('button', { name: 'Share' });
|
|
75
79
|
const downloadBtn = screen.getByRole('button', { name: 'Download' });
|
|
76
80
|
const listenBtn = screen.getByRole('button', { name: 'Listen' });
|
|
77
|
-
const buttons = [goodBtn, badBtn, copyBtn, shareBtn, downloadBtn, listenBtn];
|
|
81
|
+
const buttons = [goodBtn, badBtn, copyBtn, editBtn, shareBtn, downloadBtn, listenBtn];
|
|
78
82
|
buttons.forEach((button) => {
|
|
79
83
|
expect(button).toBeTruthy();
|
|
80
84
|
});
|
|
@@ -206,6 +210,7 @@ describe('ResponseActions', () => {
|
|
|
206
210
|
{ type: 'positive', ariaLabel: 'Thumbs up' },
|
|
207
211
|
{ type: 'negative', ariaLabel: 'Thumbs down' },
|
|
208
212
|
{ type: 'copy', ariaLabel: 'Copy the message' },
|
|
213
|
+
{ type: 'edit', ariaLabel: 'Edit this message' },
|
|
209
214
|
{ type: 'share', ariaLabel: 'Share it with friends' },
|
|
210
215
|
{ type: 'download', ariaLabel: 'Download your cool message' },
|
|
211
216
|
{ type: 'listen', ariaLabel: 'Listen up' }
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export { default as MessageBar } from './MessageBar';
|
|
|
40
40
|
export * from './MessageBar';
|
|
41
41
|
export { default as MessageBox } from './MessageBox';
|
|
42
42
|
export * from './MessageBox';
|
|
43
|
+
export { default as MessageDivider } from './MessageDivider';
|
|
44
|
+
export * from './MessageDivider';
|
|
43
45
|
export { default as PreviewAttachment } from './PreviewAttachment';
|
|
44
46
|
export * from './PreviewAttachment';
|
|
45
47
|
export { default as ResponseActions } from './ResponseActions';
|
package/dist/esm/index.js
CHANGED
|
@@ -41,6 +41,8 @@ export { default as MessageBar } from './MessageBar';
|
|
|
41
41
|
export * from './MessageBar';
|
|
42
42
|
export { default as MessageBox } from './MessageBox';
|
|
43
43
|
export * from './MessageBox';
|
|
44
|
+
export { default as MessageDivider } from './MessageDivider';
|
|
45
|
+
export * from './MessageDivider';
|
|
44
46
|
export { default as PreviewAttachment } from './PreviewAttachment';
|
|
45
47
|
export * from './PreviewAttachment';
|
|
46
48
|
export { default as ResponseActions } from './ResponseActions';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/AttachMenu/AttachMenu.tsx","../src/AttachMenu/index.ts","../src/AttachmentEdit/AttachmentEdit.test.tsx","../src/AttachmentEdit/AttachmentEdit.tsx","../src/AttachmentEdit/index.ts","../src/Chatbot/Chatbot.test.tsx","../src/Chatbot/Chatbot.tsx","../src/Chatbot/index.ts","../src/ChatbotAlert/ChatbotAlert.test.tsx","../src/ChatbotAlert/ChatbotAlert.tsx","../src/ChatbotAlert/index.ts","../src/ChatbotContent/ChatbotContent.test.tsx","../src/ChatbotContent/ChatbotContent.tsx","../src/ChatbotContent/index.ts","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx","../src/ChatbotConversationHistoryNav/EmptyState.tsx","../src/ChatbotConversationHistoryNav/LoadingState.tsx","../src/ChatbotConversationHistoryNav/index.ts","../src/ChatbotFooter/ChatbotFooter.test.tsx","../src/ChatbotFooter/ChatbotFooter.tsx","../src/ChatbotFooter/ChatbotFooternote.test.tsx","../src/ChatbotFooter/ChatbotFootnote.tsx","../src/ChatbotFooter/index.ts","../src/ChatbotHeader/ChatbotHeader.test.tsx","../src/ChatbotHeader/ChatbotHeader.tsx","../src/ChatbotHeader/ChatbotHeaderActions.test.tsx","../src/ChatbotHeader/ChatbotHeaderActions.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.tsx","../src/ChatbotHeader/ChatbotHeaderMain.test.tsx","../src/ChatbotHeader/ChatbotHeaderMain.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.test.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.test.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.tsx","../src/ChatbotHeader/index.ts","../src/ChatbotModal/ChatbotModal.test.tsx","../src/ChatbotModal/ChatbotModal.tsx","../src/ChatbotModal/index.ts","../src/ChatbotPopover/ChatbotPopover.tsx","../src/ChatbotPopover/index.ts","../src/ChatbotToggle/ChatbotToggle.test.tsx","../src/ChatbotToggle/ChatbotToggle.tsx","../src/ChatbotToggle/index.ts","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx","../src/ChatbotWelcomePrompt/index.ts","../src/CodeModal/CodeModal.test.tsx","../src/CodeModal/CodeModal.tsx","../src/CodeModal/index.ts","../src/Compare/Compare.test.tsx","../src/Compare/Compare.tsx","../src/Compare/index.ts","../src/FileDetails/FileDetails.test.tsx","../src/FileDetails/FileDetails.tsx","../src/FileDetails/index.ts","../src/FileDetailsLabel/FileDetailsLabel.test.tsx","../src/FileDetailsLabel/FileDetailsLabel.tsx","../src/FileDetailsLabel/index.ts","../src/FileDropZone/FileDropZone.test.tsx","../src/FileDropZone/FileDropZone.tsx","../src/FileDropZone/index.ts","../src/LoadingMessage/LoadingMessage.test.tsx","../src/LoadingMessage/LoadingMessage.tsx","../src/LoadingMessage/index.ts","../src/Message/Message.test.tsx","../src/Message/Message.tsx","../src/Message/MessageInput.tsx","../src/Message/MessageLoading.tsx","../src/Message/index.ts","../src/Message/CodeBlockMessage/CodeBlockMessage.tsx","../src/Message/
|
|
1
|
+
{"root":["../src/index.ts","../src/AttachMenu/AttachMenu.tsx","../src/AttachMenu/index.ts","../src/AttachmentEdit/AttachmentEdit.test.tsx","../src/AttachmentEdit/AttachmentEdit.tsx","../src/AttachmentEdit/index.ts","../src/Chatbot/Chatbot.test.tsx","../src/Chatbot/Chatbot.tsx","../src/Chatbot/index.ts","../src/ChatbotAlert/ChatbotAlert.test.tsx","../src/ChatbotAlert/ChatbotAlert.tsx","../src/ChatbotAlert/index.ts","../src/ChatbotContent/ChatbotContent.test.tsx","../src/ChatbotContent/ChatbotContent.tsx","../src/ChatbotContent/index.ts","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx","../src/ChatbotConversationHistoryNav/EmptyState.tsx","../src/ChatbotConversationHistoryNav/LoadingState.tsx","../src/ChatbotConversationHistoryNav/index.ts","../src/ChatbotFooter/ChatbotFooter.test.tsx","../src/ChatbotFooter/ChatbotFooter.tsx","../src/ChatbotFooter/ChatbotFooternote.test.tsx","../src/ChatbotFooter/ChatbotFootnote.tsx","../src/ChatbotFooter/index.ts","../src/ChatbotHeader/ChatbotHeader.test.tsx","../src/ChatbotHeader/ChatbotHeader.tsx","../src/ChatbotHeader/ChatbotHeaderActions.test.tsx","../src/ChatbotHeader/ChatbotHeaderActions.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.tsx","../src/ChatbotHeader/ChatbotHeaderMain.test.tsx","../src/ChatbotHeader/ChatbotHeaderMain.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.test.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.tsx","../src/ChatbotHeader/ChatbotHeaderNewChatButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderNewChatButton.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.test.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.tsx","../src/ChatbotHeader/index.ts","../src/ChatbotModal/ChatbotModal.test.tsx","../src/ChatbotModal/ChatbotModal.tsx","../src/ChatbotModal/index.ts","../src/ChatbotPopover/ChatbotPopover.tsx","../src/ChatbotPopover/index.ts","../src/ChatbotToggle/ChatbotToggle.test.tsx","../src/ChatbotToggle/ChatbotToggle.tsx","../src/ChatbotToggle/index.ts","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx","../src/ChatbotWelcomePrompt/index.ts","../src/CodeModal/CodeModal.test.tsx","../src/CodeModal/CodeModal.tsx","../src/CodeModal/index.ts","../src/Compare/Compare.test.tsx","../src/Compare/Compare.tsx","../src/Compare/index.ts","../src/FileDetails/FileDetails.test.tsx","../src/FileDetails/FileDetails.tsx","../src/FileDetails/index.ts","../src/FileDetailsLabel/FileDetailsLabel.test.tsx","../src/FileDetailsLabel/FileDetailsLabel.tsx","../src/FileDetailsLabel/index.ts","../src/FileDropZone/FileDropZone.test.tsx","../src/FileDropZone/FileDropZone.tsx","../src/FileDropZone/index.ts","../src/LoadingMessage/LoadingMessage.test.tsx","../src/LoadingMessage/LoadingMessage.tsx","../src/LoadingMessage/index.ts","../src/Message/Message.test.tsx","../src/Message/Message.tsx","../src/Message/MessageInput.tsx","../src/Message/MessageLoading.tsx","../src/Message/index.ts","../src/Message/CodeBlockMessage/CodeBlockMessage.tsx","../src/Message/ErrorMessage/ErrorMessage.tsx","../src/Message/ImageMessage/ImageMessage.tsx","../src/Message/LinkMessage/LinkMessage.tsx","../src/Message/ListMessage/ListItemMessage.tsx","../src/Message/ListMessage/OrderedListMessage.tsx","../src/Message/ListMessage/UnorderedListMessage.tsx","../src/Message/Plugins/index.ts","../src/Message/Plugins/rehypeCodeBlockToggle.ts","../src/Message/Plugins/rehypeMoveImagesOutOfParagraphs.ts","../src/Message/QuickResponse/QuickResponse.tsx","../src/Message/QuickStarts/FallbackImg.tsx","../src/Message/QuickStarts/QuickStartTile.tsx","../src/Message/QuickStarts/QuickStartTileDescription.test.tsx","../src/Message/QuickStarts/QuickStartTileDescription.tsx","../src/Message/QuickStarts/QuickStartTileHeader.tsx","../src/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.ts","../src/Message/QuickStarts/monitor-sampleapp-quickstart.ts","../src/Message/QuickStarts/types.ts","../src/Message/TableMessage/TableMessage.tsx","../src/Message/TableMessage/TbodyMessage.tsx","../src/Message/TableMessage/TdMessage.tsx","../src/Message/TableMessage/ThMessage.tsx","../src/Message/TableMessage/TheadMessage.tsx","../src/Message/TableMessage/TrMessage.tsx","../src/Message/TextMessage/TextMessage.tsx","../src/Message/UserFeedback/CloseButton.tsx","../src/Message/UserFeedback/UserFeedback.test.tsx","../src/Message/UserFeedback/UserFeedback.tsx","../src/Message/UserFeedback/UserFeedbackComplete.test.tsx","../src/Message/UserFeedback/UserFeedbackComplete.tsx","../src/MessageBar/AttachButton.test.tsx","../src/MessageBar/AttachButton.tsx","../src/MessageBar/MessageBar.test.tsx","../src/MessageBar/MessageBar.tsx","../src/MessageBar/MicrophoneButton.tsx","../src/MessageBar/SendButton.test.tsx","../src/MessageBar/SendButton.tsx","../src/MessageBar/StopButton.test.tsx","../src/MessageBar/StopButton.tsx","../src/MessageBar/index.ts","../src/MessageBox/JumpButton.test.tsx","../src/MessageBox/JumpButton.tsx","../src/MessageBox/MessageBox.test.tsx","../src/MessageBox/MessageBox.tsx","../src/MessageBox/index.ts","../src/MessageDivider/MessageDivider.test.tsx","../src/MessageDivider/MessageDivider.tsx","../src/MessageDivider/index.ts","../src/PreviewAttachment/PreviewAttachment.test.tsx","../src/PreviewAttachment/PreviewAttachment.tsx","../src/PreviewAttachment/index.ts","../src/ResponseActions/ResponseActionButton.test.tsx","../src/ResponseActions/ResponseActionButton.tsx","../src/ResponseActions/ResponseActions.test.tsx","../src/ResponseActions/ResponseActions.tsx","../src/ResponseActions/index.ts","../src/Settings/SettingsForm.test.tsx","../src/Settings/SettingsForm.tsx","../src/Settings/index.ts","../src/SourceDetailsMenuItem/SourceDetailsMenuItem.tsx","../src/SourceDetailsMenuItem/index.ts","../src/SourcesCard/SourcesCard.test.tsx","../src/SourcesCard/SourcesCard.tsx","../src/SourcesCard/index.ts","../src/TermsOfUse/TermsOfUse.test.tsx","../src/TermsOfUse/TermsOfUse.tsx","../src/TermsOfUse/index.ts","../src/__mocks__/rehype-external-links.ts","../src/__mocks__/rehype-sanitize.ts","../src/__mocks__/rehype-unwrap-images.tsx","../src/tracking/console_tracking_provider.ts","../src/tracking/index.ts","../src/tracking/posthog_tracking_provider.ts","../src/tracking/segment_tracking_provider.ts","../src/tracking/trackingProviderProxy.ts","../src/tracking/tracking_api.ts","../src/tracking/tracking_registry.ts","../src/tracking/tracking_spi.ts","../src/tracking/umami_tracking_provider.ts"],"version":"5.6.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/chatbot",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.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",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"clsx": "^2.1.0",
|
|
41
41
|
"framer-motion": "^11.3.28",
|
|
42
42
|
"react-markdown": "^9.0.1",
|
|
43
|
-
"react-syntax-highlighter": "^15.5.0",
|
|
44
43
|
"remark-gfm": "^4.0.0",
|
|
45
44
|
"rehype-unwrap-images": "^1.0.0",
|
|
46
45
|
"rehype-external-links": "^3.0.0",
|
|
@@ -53,7 +52,7 @@
|
|
|
53
52
|
"react-dom": "^17 || ^18 || ^19"
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
|
-
"@patternfly/documentation-framework": "6.
|
|
55
|
+
"@patternfly/documentation-framework": "6.16.0",
|
|
57
56
|
"@patternfly/patternfly": "^6.1.0",
|
|
58
57
|
"@patternfly/patternfly-a11y": "^5.0.0",
|
|
59
58
|
"@types/dom-speech-recognition": "^0.0.4",
|
|
@@ -72,7 +71,10 @@
|
|
|
72
71
|
"victory-create-container": "^37.1.1",
|
|
73
72
|
"victory-cursor-container": "^37.1.1",
|
|
74
73
|
"victory-tooltip": "^37.1.1",
|
|
75
|
-
"victory-bar": "^37.1.1"
|
|
74
|
+
"victory-bar": "^37.1.1",
|
|
75
|
+
"file-saver": "^2.0.5",
|
|
76
|
+
"unified": "^11.0.5",
|
|
77
|
+
"estree-util-is-identifier-name": "^3.0.0"
|
|
76
78
|
},
|
|
77
79
|
"overrides": {
|
|
78
80
|
"puppeteer": "^23.6.1",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
3
|
+
import patternflyAvatar from './patternfly_avatar.jpg';
|
|
4
|
+
import MessageDivider from '@patternfly/chatbot/dist/dynamic/MessageDivider';
|
|
5
|
+
|
|
6
|
+
export const MessageWithDividersExample: FunctionComponent = () => (
|
|
7
|
+
<>
|
|
8
|
+
<Message
|
|
9
|
+
name="Bot"
|
|
10
|
+
role="bot"
|
|
11
|
+
avatar={patternflyAvatar}
|
|
12
|
+
content={`This is a text-based message from a bot named "Bot."`}
|
|
13
|
+
/>
|
|
14
|
+
<MessageDivider variant="inset" content="1 hour ago" />
|
|
15
|
+
<Message
|
|
16
|
+
name="Bot"
|
|
17
|
+
role="bot"
|
|
18
|
+
avatar={patternflyAvatar}
|
|
19
|
+
content={`This is a text-based message from "Bot," with an updated timestamp.`}
|
|
20
|
+
timestamp="1 hour ago"
|
|
21
|
+
/>
|
|
22
|
+
<MessageDivider variant="fullWidth" content="Agent joined the chat" />
|
|
23
|
+
</>
|
|
24
|
+
);
|
|
@@ -31,6 +31,7 @@ sortValue: 3
|
|
|
31
31
|
---
|
|
32
32
|
|
|
33
33
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
34
|
+
import MessageDivider from '@patternfly/chatbot/dist/dynamic/MessageDivider';
|
|
34
35
|
import { rehypeCodeBlockToggle } from '@patternfly/chatbot/dist/esm/Message/Plugins/rehypeCodeBlockToggle';
|
|
35
36
|
import SourcesCard from '@patternfly/chatbot/dist/dynamic/SourcesCard';
|
|
36
37
|
import { RobotIcon } from '@patternfly/react-icons/dist/esm/icons/robot-icon';
|
|
@@ -48,7 +49,7 @@ import { explorePipelinesQuickStart } from './explore-pipeline-quickstart.ts';
|
|
|
48
49
|
import { monitorSampleAppQuickStart } from '@patternfly/chatbot/src/Message/QuickStarts/monitor-sampleapp-quickstart.ts';
|
|
49
50
|
import userAvatar from './user_avatar.svg';
|
|
50
51
|
import squareImg from './PF-social-color-square.svg';
|
|
51
|
-
import { CSSProperties, useState, Fragment, FunctionComponent, MouseEvent as ReactMouseEvent, KeyboardEvent as ReactKeyboardEvent, Ref, isValidElement, cloneElement, Children, ReactNode } from 'react';
|
|
52
|
+
import { CSSProperties, useState, Fragment, FunctionComponent, MouseEvent as ReactMouseEvent, KeyboardEvent as ReactKeyboardEvent, Ref, isValidElement, cloneElement, Children, ReactNode, useRef, useEffect } from 'react';
|
|
52
53
|
|
|
53
54
|
The `content` prop of the `<Message>` component is passed to a `<Markdown>` component (from [react-markdown](https://remarkjs.github.io/react-markdown/)), which is configured to translate plain text strings into PatternFly [`<Content>` components](/components/content) and code blocks into PatternFly [`<CodeBlock>` components.](/components/code-block)
|
|
54
55
|
|
|
@@ -66,12 +67,23 @@ You can further customize the avatar by applying an additional class or passing
|
|
|
66
67
|
|
|
67
68
|
```
|
|
68
69
|
|
|
70
|
+
### Message dividers
|
|
71
|
+
|
|
72
|
+
To provide users with important contextual updates, you can add dividers between messages.
|
|
73
|
+
|
|
74
|
+
For example, you can use the default divider to display a "timestamp" for more significant gaps in the conversation, or you can pass `variant="fullWidth"` to a divider to announce that an agent has joined the chat.
|
|
75
|
+
|
|
76
|
+
```js file="./MessageWithDividers.tsx"
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
|
|
69
80
|
### Message actions
|
|
70
81
|
|
|
71
82
|
You can add actions to a message, to allow users to interact with the message content. These actions can include:
|
|
72
83
|
|
|
73
84
|
- Feedback responses that allow users to rate a message as "good" or "bad".
|
|
74
85
|
- Copy and share controls that allow users to share the message content with others.
|
|
86
|
+
- An edit action to allow users to edit a message they previously sent. This should only be applied to user messages - see the [user messages example](#user-messages) for details on how to implement this action.
|
|
75
87
|
- A listen action, that will read the message content out loud.
|
|
76
88
|
|
|
77
89
|
**Note:** The logic for the actions is not built into the component and must be implemented by the consuming application.
|
|
@@ -183,6 +195,8 @@ The quick start tile displayed below the message is based on the tile included i
|
|
|
183
195
|
|
|
184
196
|
Messages from users have a different background color to differentiate them from bot messages. You can also display a custom avatar that is uploaded by the user. You can further customize the avatar by applying an additional class or passing [PatternFly avatar props](/components/avatar) to the `<Message>` component via `avatarProps`.
|
|
185
197
|
|
|
198
|
+
User messages can also be made editable by passing an "edit" object to the `actions` property. When editing is enabled focus should be placed on the text area. When editing is completed or canceled the focus should be moved back to the edit button.
|
|
199
|
+
|
|
186
200
|
```js file="./UserMessage.tsx"
|
|
187
201
|
|
|
188
202
|
```
|