@patternfly/chatbot 6.5.0-prerelease.26 → 6.5.0-prerelease.28
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/MarkdownContent/MarkdownContent.d.ts +7 -2
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.d.ts +15 -1
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.js +5 -3
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.test.d.ts +1 -0
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.test.js +30 -0
- package/dist/cjs/Message/Message.d.ts +2 -0
- package/dist/cjs/Message/Message.js +5 -5
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.d.ts +14 -0
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.js +22 -0
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.test.d.ts +1 -0
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.test.js +25 -0
- package/dist/cjs/Message/MessageAndActions/index.d.ts +1 -0
- package/dist/cjs/Message/MessageAndActions/index.js +17 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.d.ts +13 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.js +22 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.test.d.ts +1 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.test.js +25 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.d.ts +13 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.js +22 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.test.d.ts +1 -0
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.test.js +25 -0
- package/dist/cjs/Message/MessageAttachments/index.d.ts +2 -0
- package/dist/cjs/Message/MessageAttachments/index.js +18 -0
- package/dist/cjs/Message/MessageInput.d.ts +1 -1
- package/dist/cjs/Message/MessageInput.js +3 -1
- package/dist/cjs/Message/MessageLoading.d.ts +13 -4
- package/dist/cjs/Message/MessageLoading.js +19 -5
- package/dist/cjs/Message/MessageLoading.test.d.ts +1 -0
- package/dist/cjs/Message/MessageLoading.test.js +25 -0
- package/dist/cjs/Message/QuickResponse/QuickResponse.js +3 -2
- package/dist/cjs/Message/QuickResponse/QuickResponse.test.d.ts +1 -0
- package/dist/cjs/Message/QuickResponse/QuickResponse.test.js +109 -0
- package/dist/cjs/Message/QuickResponse/index.d.ts +1 -0
- package/dist/cjs/Message/QuickResponse/index.js +17 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTile.d.ts +1 -1
- package/dist/cjs/Message/QuickStarts/QuickStartTile.js +3 -2
- package/dist/cjs/Message/QuickStarts/index.d.ts +2 -0
- package/dist/cjs/Message/QuickStarts/index.js +18 -0
- package/dist/cjs/Message/UserFeedback/UserFeedback.d.ts +1 -1
- package/dist/cjs/Message/UserFeedback/UserFeedback.js +3 -1
- package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.d.ts +1 -1
- package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.js +3 -2
- package/dist/cjs/Message/UserFeedback/index.d.ts +2 -0
- package/dist/cjs/Message/UserFeedback/index.js +18 -0
- package/dist/cjs/Message/index.d.ts +8 -0
- package/dist/cjs/Message/index.js +8 -0
- package/dist/cjs/ResponseActions/ResponseActions.d.ts +4 -0
- package/dist/cjs/ResponseActions/ResponseActionsGroups.d.ts +13 -0
- package/dist/cjs/ResponseActions/ResponseActionsGroups.js +22 -0
- package/dist/cjs/ResponseActions/ResponseActionsGroups.test.d.ts +1 -0
- package/dist/cjs/ResponseActions/ResponseActionsGroups.test.js +25 -0
- package/dist/cjs/ResponseActions/index.d.ts +1 -0
- package/dist/cjs/ResponseActions/index.js +1 -0
- package/dist/css/main.css +2 -0
- package/dist/css/main.css.map +1 -1
- package/dist/esm/MarkdownContent/MarkdownContent.d.ts +7 -2
- package/dist/esm/Message/ErrorMessage/ErrorMessage.d.ts +15 -1
- package/dist/esm/Message/ErrorMessage/ErrorMessage.js +3 -3
- package/dist/esm/Message/ErrorMessage/ErrorMessage.test.d.ts +1 -0
- package/dist/esm/Message/ErrorMessage/ErrorMessage.test.js +25 -0
- package/dist/esm/Message/Message.d.ts +2 -0
- package/dist/esm/Message/Message.js +5 -5
- package/dist/esm/Message/MessageAndActions/MessageAndActions.d.ts +14 -0
- package/dist/esm/Message/MessageAndActions/MessageAndActions.js +18 -0
- package/dist/esm/Message/MessageAndActions/MessageAndActions.test.d.ts +1 -0
- package/dist/esm/Message/MessageAndActions/MessageAndActions.test.js +20 -0
- package/dist/esm/Message/MessageAndActions/index.d.ts +1 -0
- package/dist/esm/Message/MessageAndActions/index.js +1 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.d.ts +13 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.js +18 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.test.d.ts +1 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.test.js +20 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.d.ts +13 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.js +18 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.test.d.ts +1 -0
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.test.js +20 -0
- package/dist/esm/Message/MessageAttachments/index.d.ts +2 -0
- package/dist/esm/Message/MessageAttachments/index.js +2 -0
- package/dist/esm/Message/MessageInput.d.ts +1 -1
- package/dist/esm/Message/MessageInput.js +1 -1
- package/dist/esm/Message/MessageLoading.d.ts +13 -4
- package/dist/esm/Message/MessageLoading.js +16 -4
- package/dist/esm/Message/MessageLoading.test.d.ts +1 -0
- package/dist/esm/Message/MessageLoading.test.js +20 -0
- package/dist/esm/Message/QuickResponse/QuickResponse.js +3 -2
- package/dist/esm/Message/QuickResponse/QuickResponse.test.d.ts +1 -0
- package/dist/esm/Message/QuickResponse/QuickResponse.test.js +104 -0
- package/dist/esm/Message/QuickResponse/index.d.ts +1 -0
- package/dist/esm/Message/QuickResponse/index.js +1 -0
- package/dist/esm/Message/QuickStarts/QuickStartTile.d.ts +1 -1
- package/dist/esm/Message/QuickStarts/QuickStartTile.js +1 -1
- package/dist/esm/Message/QuickStarts/index.d.ts +2 -0
- package/dist/esm/Message/QuickStarts/index.js +2 -0
- package/dist/esm/Message/UserFeedback/UserFeedback.d.ts +1 -1
- package/dist/esm/Message/UserFeedback/UserFeedback.js +1 -1
- package/dist/esm/Message/UserFeedback/UserFeedbackComplete.d.ts +1 -1
- package/dist/esm/Message/UserFeedback/UserFeedbackComplete.js +1 -2
- package/dist/esm/Message/UserFeedback/index.d.ts +2 -0
- package/dist/esm/Message/UserFeedback/index.js +2 -0
- package/dist/esm/Message/index.d.ts +8 -0
- package/dist/esm/Message/index.js +8 -0
- package/dist/esm/ResponseActions/ResponseActions.d.ts +4 -0
- package/dist/esm/ResponseActions/ResponseActionsGroups.d.ts +13 -0
- package/dist/esm/ResponseActions/ResponseActionsGroups.js +18 -0
- package/dist/esm/ResponseActions/ResponseActionsGroups.test.d.ts +1 -0
- package/dist/esm/ResponseActions/ResponseActionsGroups.test.js +20 -0
- package/dist/esm/ResponseActions/index.d.ts +1 -0
- package/dist/esm/ResponseActions/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithCustomStructure.tsx +102 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +55 -10
- package/src/MarkdownContent/MarkdownContent.tsx +7 -2
- package/src/Message/CodeBlockMessage/CodeBlockMessage.scss +1 -0
- package/src/Message/ErrorMessage/ErrorMessage.test.tsx +38 -0
- package/src/Message/ErrorMessage/ErrorMessage.tsx +17 -2
- package/src/Message/Message.tsx +75 -64
- package/src/Message/MessageAndActions/MessageAndActions.test.tsx +23 -0
- package/src/Message/MessageAndActions/MessageAndActions.tsx +22 -0
- package/src/Message/MessageAndActions/index.ts +1 -0
- package/src/Message/MessageAttachments/MessageAttachmentItem.test.tsx +23 -0
- package/src/Message/MessageAttachments/MessageAttachmentItem.tsx +25 -0
- package/src/Message/MessageAttachments/MessageAttachmentsContainer.test.tsx +23 -0
- package/src/Message/MessageAttachments/MessageAttachmentsContainer.tsx +25 -0
- package/src/Message/MessageAttachments/index.ts +2 -0
- package/src/Message/MessageInput.tsx +1 -1
- package/src/Message/MessageLoading.test.tsx +23 -0
- package/src/Message/MessageLoading.tsx +17 -2
- package/src/Message/QuickResponse/QuickResponse.test.tsx +131 -0
- package/src/Message/QuickResponse/QuickResponse.tsx +3 -2
- package/src/Message/QuickResponse/index.ts +1 -0
- package/src/Message/QuickStarts/QuickStartTile.tsx +1 -1
- package/src/Message/QuickStarts/index.ts +2 -0
- package/src/Message/UserFeedback/UserFeedback.tsx +1 -1
- package/src/Message/UserFeedback/UserFeedbackComplete.tsx +1 -4
- package/src/Message/UserFeedback/index.ts +2 -0
- package/src/Message/index.ts +8 -0
- package/src/ResponseActions/ResponseActions.tsx +6 -0
- package/src/ResponseActions/ResponseActionsGroups.test.tsx +23 -0
- package/src/ResponseActions/ResponseActionsGroups.tsx +28 -0
- package/src/ResponseActions/index.ts +1 -0
|
@@ -5,10 +5,15 @@ import { TableProps } from '@patternfly/react-table';
|
|
|
5
5
|
import 'highlight.js/styles/vs2015.css';
|
|
6
6
|
import { PluggableList } from 'unified';
|
|
7
7
|
import { ButtonProps } from '@patternfly/react-core';
|
|
8
|
+
/**
|
|
9
|
+
* MarkdownContent renders content either as plain text or with content with markdown support.
|
|
10
|
+
*
|
|
11
|
+
* Use this component when passing children to Message to customize its structure.
|
|
12
|
+
*/
|
|
8
13
|
export interface MarkdownContentProps {
|
|
9
|
-
/** The
|
|
14
|
+
/** The content to render. Supports markdown formatting by default, or plain text when isMarkdownDisabled is true. */
|
|
10
15
|
content?: string;
|
|
11
|
-
/** Disables markdown parsing, allowing only text input */
|
|
16
|
+
/** Disables markdown parsing, allowing only plain text input */
|
|
12
17
|
isMarkdownDisabled?: boolean;
|
|
13
18
|
/** Props for code blocks */
|
|
14
19
|
codeBlockProps?: CodeBlockMessageProps;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
import { AlertProps } from '@patternfly/react-core';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* ErrorMessage displays an inline danger alert for error states in messages.
|
|
4
|
+
* Use this component when passing children to Message to display error information.
|
|
5
|
+
*/
|
|
6
|
+
export interface ErrorMessageProps extends Partial<AlertProps> {
|
|
7
|
+
/** Content to display in the error alert body */
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
/** Additional classes for the error alert */
|
|
10
|
+
className?: string;
|
|
11
|
+
/** Title of the error alert */
|
|
12
|
+
title?: React.ReactNode;
|
|
13
|
+
/** Action links to display in the alert footer */
|
|
14
|
+
actionLinks?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare const ErrorMessage: ({ title, actionLinks, children, className, ...props }: ErrorMessageProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
17
|
export default ErrorMessage;
|
|
@@ -11,13 +11,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.ErrorMessage = void 0;
|
|
14
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
16
|
// ============================================================================
|
|
16
17
|
// Chatbot Main - Message - Content - Error
|
|
17
18
|
// ============================================================================
|
|
18
19
|
const react_core_1 = require("@patternfly/react-core");
|
|
19
20
|
const ErrorMessage = (_a) => {
|
|
20
|
-
var { title, actionLinks, children } = _a, props = __rest(_a, ["title", "actionLinks", "children"]);
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)(react_core_1.Alert, Object.assign({ isInline: true, variant: "danger", title: title, actionLinks: actionLinks }, props, { children: children })));
|
|
21
|
+
var { title, actionLinks, children, className } = _a, props = __rest(_a, ["title", "actionLinks", "children", "className"]);
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(react_core_1.Alert, Object.assign({ isInline: true, variant: "danger", title: title, actionLinks: actionLinks, className: className }, props, { children: children })));
|
|
22
23
|
};
|
|
23
|
-
exports.
|
|
24
|
+
exports.ErrorMessage = ErrorMessage;
|
|
25
|
+
exports.default = exports.ErrorMessage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("@testing-library/react");
|
|
8
|
+
require("@testing-library/jest-dom");
|
|
9
|
+
const ErrorMessage_1 = __importDefault(require("./ErrorMessage"));
|
|
10
|
+
test('Renders with title', () => {
|
|
11
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { title: "Error occurred" }));
|
|
12
|
+
expect(react_1.screen.getByText('Error occurred')).toBeVisible();
|
|
13
|
+
});
|
|
14
|
+
test('Renders with children', () => {
|
|
15
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { title: "Error occurred", children: "This is the error message body" }));
|
|
16
|
+
expect(react_1.screen.getByText('This is the error message body')).toBeVisible();
|
|
17
|
+
});
|
|
18
|
+
test('Renders with action links', () => {
|
|
19
|
+
const actionLinks = ((0, jsx_runtime_1.jsx)("a", { href: "#retry", "data-testid": "retry-link", children: "Retry action link" }));
|
|
20
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { title: "Error occurred", actionLinks: actionLinks }));
|
|
21
|
+
expect(react_1.screen.getByText('Retry action link')).toBeVisible();
|
|
22
|
+
});
|
|
23
|
+
test('Renders with custom className', () => {
|
|
24
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { title: "Error occurred", className: "custom-error-class" }));
|
|
25
|
+
expect(react_1.screen.getByText('Error occurred').parentElement).toHaveClass('custom-error-class');
|
|
26
|
+
});
|
|
27
|
+
test('Renders with spread props', () => {
|
|
28
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { title: "Error occurred", id: "test-error-id" }));
|
|
29
|
+
expect(react_1.screen.getByText('Error occurred').parentElement).toHaveAttribute('id', 'test-error-id');
|
|
30
|
+
});
|
|
@@ -42,6 +42,8 @@ export interface MessageExtraContent {
|
|
|
42
42
|
endContent?: ReactNode;
|
|
43
43
|
}
|
|
44
44
|
export interface MessageProps extends Omit<HTMLProps<HTMLDivElement>, 'role'> {
|
|
45
|
+
/** Children to render instead of the default message structure, allowing more fine-tuned message control. When provided, this will override the default rendering of content, toolResponse, deepThinking, toolCall, sources, quickStarts, actions, etc. */
|
|
46
|
+
children?: ReactNode;
|
|
45
47
|
/** Unique id for message */
|
|
46
48
|
id?: string;
|
|
47
49
|
/** Role of the user sending the message */
|
|
@@ -38,7 +38,7 @@ const DeepThinking_1 = __importDefault(require("../DeepThinking"));
|
|
|
38
38
|
const ToolCall_1 = __importDefault(require("../ToolCall"));
|
|
39
39
|
const MarkdownContent_1 = __importDefault(require("../MarkdownContent"));
|
|
40
40
|
const MessageBase = (_a) => {
|
|
41
|
-
var { role, content, extraContent, name, avatar, timestamp, isLoading, actions, persistActionSelection, 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 = [], additionalRemarkPlugins = [], linkProps, error, isEditable, editPlaceholder = 'Edit prompt message...', updateWord = 'Update', cancelWord = 'Cancel', onEditUpdate, onEditCancel, inputRef, editFormProps, isCompact, isMarkdownDisabled, reactMarkdownProps, toolResponse, deepThinking, remarkGfmProps, toolCall, hasNoImagesInUserMessages = true, isPrimary } = _a, props = __rest(_a, ["role", "content", "extraContent", "name", "avatar", "timestamp", "isLoading", "actions", "persistActionSelection", "sources", "botWord", "loadingWord", "codeBlockProps", "quickResponses", "quickResponseContainerProps", "attachments", "hasRoundAvatar", "avatarProps", "quickStarts", "userFeedbackForm", "userFeedbackComplete", "isLiveRegion", "innerRef", "tableProps", "openLinkInNewTab", "additionalRehypePlugins", "additionalRemarkPlugins", "linkProps", "error", "isEditable", "editPlaceholder", "updateWord", "cancelWord", "onEditUpdate", "onEditCancel", "inputRef", "editFormProps", "isCompact", "isMarkdownDisabled", "reactMarkdownProps", "toolResponse", "deepThinking", "remarkGfmProps", "toolCall", "hasNoImagesInUserMessages", "isPrimary"]);
|
|
41
|
+
var { children, role, content, extraContent, name, avatar, timestamp, isLoading, actions, persistActionSelection, 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 = [], additionalRemarkPlugins = [], linkProps, error, isEditable, editPlaceholder = 'Edit prompt message...', updateWord = 'Update', cancelWord = 'Cancel', onEditUpdate, onEditCancel, inputRef, editFormProps, isCompact, isMarkdownDisabled, reactMarkdownProps, toolResponse, deepThinking, remarkGfmProps, toolCall, hasNoImagesInUserMessages = true, isPrimary } = _a, props = __rest(_a, ["children", "role", "content", "extraContent", "name", "avatar", "timestamp", "isLoading", "actions", "persistActionSelection", "sources", "botWord", "loadingWord", "codeBlockProps", "quickResponses", "quickResponseContainerProps", "attachments", "hasRoundAvatar", "avatarProps", "quickStarts", "userFeedbackForm", "userFeedbackComplete", "isLiveRegion", "innerRef", "tableProps", "openLinkInNewTab", "additionalRehypePlugins", "additionalRemarkPlugins", "linkProps", "error", "isEditable", "editPlaceholder", "updateWord", "cancelWord", "onEditUpdate", "onEditCancel", "inputRef", "editFormProps", "isCompact", "isMarkdownDisabled", "reactMarkdownProps", "toolResponse", "deepThinking", "remarkGfmProps", "toolCall", "hasNoImagesInUserMessages", "isPrimary"]);
|
|
42
42
|
const [messageText, setMessageText] = (0, react_1.useState)(content);
|
|
43
43
|
(0, react_1.useEffect)(() => {
|
|
44
44
|
setMessageText(content);
|
|
@@ -66,10 +66,10 @@ const MessageBase = (_a) => {
|
|
|
66
66
|
}
|
|
67
67
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [beforeMainContent && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: beforeMainContent }), error ? (0, jsx_runtime_1.jsx)(ErrorMessage_1.default, Object.assign({}, error)) : handleMarkdown()] }));
|
|
68
68
|
};
|
|
69
|
-
return ((0, jsx_runtime_1.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: [avatar && ((0, jsx_runtime_1.jsx)(react_core_1.Avatar, Object.assign({ className: `pf-chatbot__message-avatar ${hasRoundAvatar ? 'pf-chatbot__message-avatar--round' : ''} ${avatarClassName ? avatarClassName : ''}`, src: avatar, alt: "" }, avatarProps))), (0, jsx_runtime_1.jsxs)("div", { className: "pf-chatbot__message-contents", children: [(0, jsx_runtime_1.jsxs)("div", { className: "pf-chatbot__message-meta", children: [name && ((0, jsx_runtime_1.jsx)("span", { className: "pf-chatbot__message-name", children: (0, jsx_runtime_1.jsx)(react_core_1.Truncate, { content: name }) })), role === 'bot' && ((0, jsx_runtime_1.jsx)(react_core_1.Label, { variant: "outline", isCompact: true, children: botWord })), (0, jsx_runtime_1.jsx)(react_core_1.Timestamp, { date: date, children: timestamp })] }), (0, jsx_runtime_1.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
return ((0, jsx_runtime_1.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: [avatar && ((0, jsx_runtime_1.jsx)(react_core_1.Avatar, Object.assign({ className: `pf-chatbot__message-avatar ${hasRoundAvatar ? 'pf-chatbot__message-avatar--round' : ''} ${avatarClassName ? avatarClassName : ''}`, src: avatar, alt: "" }, avatarProps))), (0, jsx_runtime_1.jsxs)("div", { className: "pf-chatbot__message-contents", children: [(0, jsx_runtime_1.jsxs)("div", { className: "pf-chatbot__message-meta", children: [name && ((0, jsx_runtime_1.jsx)("span", { className: "pf-chatbot__message-name", children: (0, jsx_runtime_1.jsx)(react_core_1.Truncate, { content: name }) })), role === 'bot' && ((0, jsx_runtime_1.jsx)(react_core_1.Label, { variant: "outline", isCompact: true, children: botWord })), (0, jsx_runtime_1.jsx)(react_core_1.Timestamp, { date: date, children: timestamp })] }), (0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__message-response", children: children ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "pf-chatbot__message-and-actions", children: [renderMessage(), afterMainContent && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: afterMainContent }), toolResponse && (0, jsx_runtime_1.jsx)(ToolResponse_1.default, Object.assign({}, toolResponse)), deepThinking && (0, jsx_runtime_1.jsx)(DeepThinking_1.default, Object.assign({}, deepThinking)), toolCall && (0, jsx_runtime_1.jsx)(ToolCall_1.default, Object.assign({}, toolCall)), !isLoading && sources && (0, jsx_runtime_1.jsx)(SourcesCard_1.default, Object.assign({}, sources, { isCompact: isCompact })), quickStarts && quickStarts.quickStart && ((0, jsx_runtime_1.jsx)(QuickStartTile_1.default, { 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 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: Array.isArray(actions) ? ((0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__response-actions-groups", children: actions.map((actionGroup, index) => ((0, jsx_runtime_1.jsx)(ResponseActions_1.default, { actions: actionGroup.actions || actionGroup, persistActionSelection: persistActionSelection || actionGroup.persistActionSelection }, index))) })) : ((0, jsx_runtime_1.jsx)(ResponseActions_1.default, { actions: actions, persistActionSelection: persistActionSelection })) })), userFeedbackForm && ((0, jsx_runtime_1.jsx)(UserFeedback_1.default, Object.assign({}, userFeedbackForm, { timestamp: dateString, isCompact: isCompact }))), userFeedbackComplete && ((0, jsx_runtime_1.jsx)(UserFeedbackComplete_1.default, Object.assign({}, userFeedbackComplete, { timestamp: dateString, isCompact: isCompact }))), !isLoading && quickResponses && ((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses, quickResponseContainerProps: quickResponseContainerProps, isCompact: isCompact }))] }), attachments && ((0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__message-attachments-container", children: attachments.map((attachment) => {
|
|
70
|
+
var _a;
|
|
71
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__message-attachment", children: (0, jsx_runtime_1.jsx)(FileDetailsLabel_1.default, { fileName: attachment.name, fileId: attachment.id, onClose: attachment.onClose, onClick: attachment.onClick, isLoading: attachment.isLoading, closeButtonAriaLabel: attachment.closeButtonAriaLabel, languageTestId: attachment.languageTestId, spinnerTestId: attachment.spinnerTestId, variant: isPrimary ? 'outline' : undefined }) }, (_a = attachment.id) !== null && _a !== void 0 ? _a : attachment.name));
|
|
72
|
+
}) })), !isLoading && endContent && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: endContent })] })) })] })] })));
|
|
73
73
|
};
|
|
74
74
|
exports.MessageBase = MessageBase;
|
|
75
75
|
const Message = (0, react_1.forwardRef)((props, ref) => ((0, jsx_runtime_1.jsx)(exports.MessageBase, Object.assign({ innerRef: ref }, props))));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FunctionComponent, HTMLProps, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The container that wraps the primary message content and inline actions, such as ToolCall, ToolResponse, DeepThinking, ResponseActions, etc.
|
|
4
|
+
* Attachments should not be rendered inside this container.
|
|
5
|
+
* Use this component when passing children to Message to customize its structure.
|
|
6
|
+
*/
|
|
7
|
+
export interface MessageAndActionsProps extends HTMLProps<HTMLDivElement> {
|
|
8
|
+
/** Content to render inside the message and actions container. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Additional classes applied to the message and actions container. */
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const MessageAndActions: FunctionComponent<MessageAndActionsProps>;
|
|
14
|
+
export default MessageAndActions;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.MessageAndActions = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_styles_1 = require("@patternfly/react-styles");
|
|
17
|
+
const MessageAndActions = (_a) => {
|
|
18
|
+
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, react_styles_1.css)('pf-chatbot__message-and-actions', className) }, props, { children: children })));
|
|
20
|
+
};
|
|
21
|
+
exports.MessageAndActions = MessageAndActions;
|
|
22
|
+
exports.default = exports.MessageAndActions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
const react_1 = require("@testing-library/react");
|
|
9
|
+
const MessageAndActions_1 = __importDefault(require("./MessageAndActions"));
|
|
10
|
+
test('Renders with children', () => {
|
|
11
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAndActions_1.default, { children: "Test content" }));
|
|
12
|
+
expect(react_1.screen.getByText('Test content')).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
test('Renders with pf-chatbot__message-and-actions class by default', () => {
|
|
15
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAndActions_1.default, { children: "Test content" }));
|
|
16
|
+
expect(react_1.screen.getByText('Test content')).toHaveClass('pf-chatbot__message-and-actions', { exact: true });
|
|
17
|
+
});
|
|
18
|
+
test('Renders with custom className', () => {
|
|
19
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAndActions_1.default, { className: "custom-class", children: "Test content" }));
|
|
20
|
+
expect(react_1.screen.getByText('Test content')).toHaveClass('custom-class');
|
|
21
|
+
});
|
|
22
|
+
test('Spreads additional props', () => {
|
|
23
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAndActions_1.default, { id: "test-id", children: "Test content" }));
|
|
24
|
+
expect(react_1.screen.getByText('Test content')).toHaveAttribute('id', 'test-id');
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MessageAndActions';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./MessageAndActions"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FunctionComponent, HTMLProps, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The container for a single message attachment item, typically the FileDetailsLabel component. You must wrap any attachment components in this container.
|
|
4
|
+
* Use this component within MessageAttachmentsContainer when passing children to Message to customize its structure.
|
|
5
|
+
*/
|
|
6
|
+
export interface MessageAttachmentItemProps extends HTMLProps<HTMLDivElement> {
|
|
7
|
+
/** Content to render inside a single attachment container */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Additional classes applied to the attachment container. */
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const MessageAttachmentItem: FunctionComponent<MessageAttachmentItemProps>;
|
|
13
|
+
export default MessageAttachmentItem;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.MessageAttachmentItem = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_styles_1 = require("@patternfly/react-styles");
|
|
17
|
+
const MessageAttachmentItem = (_a) => {
|
|
18
|
+
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, react_styles_1.css)('pf-chatbot__message-attachment', className) }, props, { children: children })));
|
|
20
|
+
};
|
|
21
|
+
exports.MessageAttachmentItem = MessageAttachmentItem;
|
|
22
|
+
exports.default = exports.MessageAttachmentItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
const react_1 = require("@testing-library/react");
|
|
9
|
+
const MessageAttachmentItem_1 = __importDefault(require("./MessageAttachmentItem"));
|
|
10
|
+
test('Renders with children', () => {
|
|
11
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAttachmentItem_1.default, { children: "Test content" }));
|
|
12
|
+
expect(react_1.screen.getByText('Test content')).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
test('Renders with pf-chatbot__message-attachment class by default', () => {
|
|
15
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAttachmentItem_1.default, { children: "Test content" }));
|
|
16
|
+
expect(react_1.screen.getByText('Test content')).toHaveClass('pf-chatbot__message-attachment', { exact: true });
|
|
17
|
+
});
|
|
18
|
+
test('Renders with custom className', () => {
|
|
19
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAttachmentItem_1.default, { className: "custom-class", children: "Test content" }));
|
|
20
|
+
expect(react_1.screen.getByText('Test content')).toHaveClass('custom-class');
|
|
21
|
+
});
|
|
22
|
+
test('Spreads additional props', () => {
|
|
23
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAttachmentItem_1.default, { id: "test-id", children: "Test content" }));
|
|
24
|
+
expect(react_1.screen.getByText('Test content')).toHaveAttribute('id', 'test-id');
|
|
25
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FunctionComponent, HTMLProps, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The container to wrap MessageAttachment components. You must wrap any MessageAttachment components in this container.
|
|
4
|
+
* Use this component when passing children to Message to customize its structure.
|
|
5
|
+
*/
|
|
6
|
+
export interface MessageAttachmentsContainerProps extends HTMLProps<HTMLDivElement> {
|
|
7
|
+
/** Content to render inside the attachments container */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Additional classes applied to the attachments container. */
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const MessageAttachmentsContainer: FunctionComponent<MessageAttachmentsContainerProps>;
|
|
13
|
+
export default MessageAttachmentsContainer;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.MessageAttachmentsContainer = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_styles_1 = require("@patternfly/react-styles");
|
|
17
|
+
const MessageAttachmentsContainer = (_a) => {
|
|
18
|
+
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, react_styles_1.css)('pf-chatbot__message-attachments-container', className) }, props, { children: children })));
|
|
20
|
+
};
|
|
21
|
+
exports.MessageAttachmentsContainer = MessageAttachmentsContainer;
|
|
22
|
+
exports.default = exports.MessageAttachmentsContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
const react_1 = require("@testing-library/react");
|
|
9
|
+
const MessageAttachmentsContainer_1 = __importDefault(require("./MessageAttachmentsContainer"));
|
|
10
|
+
test('Renders with children', () => {
|
|
11
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAttachmentsContainer_1.default, { children: "Test content" }));
|
|
12
|
+
expect(react_1.screen.getByText('Test content')).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
test('Renders with pf-chatbot__message-attachments-container class by default', () => {
|
|
15
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAttachmentsContainer_1.default, { children: "Test content" }));
|
|
16
|
+
expect(react_1.screen.getByText('Test content')).toHaveClass('pf-chatbot__message-attachments-container', { exact: true });
|
|
17
|
+
});
|
|
18
|
+
test('Renders with custom className', () => {
|
|
19
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAttachmentsContainer_1.default, { className: "custom-class", children: "Test content" }));
|
|
20
|
+
expect(react_1.screen.getByText('Test content')).toHaveClass('custom-class');
|
|
21
|
+
});
|
|
22
|
+
test('Spreads additional props', () => {
|
|
23
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageAttachmentsContainer_1.default, { id: "test-id", children: "Test content" }));
|
|
24
|
+
expect(react_1.screen.getByText('Test content')).toHaveAttribute('id', 'test-id');
|
|
25
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./MessageAttachmentItem"), exports);
|
|
18
|
+
__exportStar(require("./MessageAttachmentsContainer"), exports);
|
|
@@ -16,5 +16,5 @@ export interface MessageInputProps extends FormProps {
|
|
|
16
16
|
/** Message text */
|
|
17
17
|
content?: string;
|
|
18
18
|
}
|
|
19
|
-
declare const MessageInput: FunctionComponent<MessageInputProps>;
|
|
19
|
+
export declare const MessageInput: FunctionComponent<MessageInputProps>;
|
|
20
20
|
export default MessageInput;
|
|
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.MessageInput = void 0;
|
|
14
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
16
|
const react_1 = require("react");
|
|
16
17
|
const react_core_1 = require("@patternfly/react-core");
|
|
@@ -22,4 +23,5 @@ const MessageInput = (_a) => {
|
|
|
22
23
|
};
|
|
23
24
|
return ((0, jsx_runtime_1.jsxs)(react_core_1.Form, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)(react_core_1.TextArea, { placeholder: editPlaceholder, value: messageText, onChange: onChange, "aria-label": editPlaceholder, autoResize: true, ref: inputRef }), (0, jsx_runtime_1.jsxs)(react_core_1.ActionGroup, { className: "pf-chatbot__message-edit-buttons", children: [(0, jsx_runtime_1.jsx)(react_core_1.Button, { variant: "primary", onClick: (event) => onEditUpdate && onEditUpdate(event, messageText), children: updateWord }), (0, jsx_runtime_1.jsx)(react_core_1.Button, { variant: "secondary", onClick: onEditCancel, children: cancelWord })] })] })));
|
|
24
25
|
};
|
|
25
|
-
exports.
|
|
26
|
+
exports.MessageInput = MessageInput;
|
|
27
|
+
exports.default = exports.MessageInput;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import type { HTMLProps } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* MessageLoading displays a loading animation for messages.
|
|
5
|
+
* Use this component when passing children to Message to show a loading state.
|
|
6
|
+
*/
|
|
7
|
+
export interface MessageLoadingProps extends HTMLProps<HTMLDivElement> {
|
|
8
|
+
/** Text announced to screen readers during loading. */
|
|
9
|
+
loadingWord?: string;
|
|
10
|
+
/** Flag indicating whether primary styling is applied */
|
|
11
|
+
isPrimary?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const MessageLoading: FunctionComponent<MessageLoadingProps>;
|
|
5
14
|
export default MessageLoading;
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.MessageLoading = void 0;
|
|
3
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
16
|
+
const react_styles_1 = require("@patternfly/react-styles");
|
|
17
|
+
const MessageLoading = (_a) => {
|
|
18
|
+
var { loadingWord, isPrimary } = _a, props = __rest(_a, ["loadingWord", "isPrimary"]);
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, react_styles_1.css)('pf-chatbot__message-loading', isPrimary && 'pf-m-primary') }, props, { children: (0, jsx_runtime_1.jsx)("span", { className: "pf-chatbot__message-loading-dots", children: (0, jsx_runtime_1.jsx)("span", { className: "pf-v6-screen-reader", children: loadingWord }) }) })));
|
|
20
|
+
};
|
|
21
|
+
exports.MessageLoading = MessageLoading;
|
|
22
|
+
exports.default = exports.MessageLoading;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
const react_1 = require("@testing-library/react");
|
|
9
|
+
const MessageLoading_1 = __importDefault(require("./MessageLoading"));
|
|
10
|
+
test('Renders with pf-chatbot__message-loading class by default', () => {
|
|
11
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageLoading_1.default, { "data-testid": "test-id" }));
|
|
12
|
+
expect(react_1.screen.getByTestId('test-id')).toHaveClass('pf-chatbot__message-loading', { exact: true });
|
|
13
|
+
});
|
|
14
|
+
test('Renders with pf-m-primary class when isPrimary is true', () => {
|
|
15
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageLoading_1.default, { "data-testid": "test-id", isPrimary: true }));
|
|
16
|
+
expect(react_1.screen.getByTestId('test-id')).toHaveClass('pf-chatbot__message-loading pf-m-primary');
|
|
17
|
+
});
|
|
18
|
+
test('Renders loading word when loadingWord is passed', () => {
|
|
19
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageLoading_1.default, { loadingWord: "Loading message" }));
|
|
20
|
+
expect(react_1.screen.getByText('Loading message')).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
test('Spreads additional props', () => {
|
|
23
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(MessageLoading_1.default, { "data-testid": "test-id", id: "custom-id" }));
|
|
24
|
+
expect(react_1.screen.getByTestId('test-id')).toHaveAttribute('id', 'custom-id');
|
|
25
|
+
});
|
|
@@ -16,6 +16,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
16
16
|
const react_1 = require("react");
|
|
17
17
|
const react_core_1 = require("@patternfly/react-core");
|
|
18
18
|
const react_icons_1 = require("@patternfly/react-icons");
|
|
19
|
+
const react_styles_1 = require("@patternfly/react-styles");
|
|
19
20
|
const QuickResponse = ({ quickResponses, quickResponseContainerProps = { numLabels: 5 }, onSelect, isCompact }) => {
|
|
20
21
|
const [selectedQuickResponse, setSelectedQuickResponse] = (0, react_1.useState)();
|
|
21
22
|
const handleQuickResponseClick = (id, onClick) => {
|
|
@@ -23,9 +24,9 @@ const QuickResponse = ({ quickResponses, quickResponseContainerProps = { numLabe
|
|
|
23
24
|
onClick && onClick();
|
|
24
25
|
onSelect && onSelect(id);
|
|
25
26
|
};
|
|
26
|
-
return ((0, jsx_runtime_1.jsx)(react_core_1.LabelGroup, Object.assign({ className:
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(react_core_1.LabelGroup, Object.assign({ className: (0, react_styles_1.css)('pf-chatbot__message-quick-response', quickResponseContainerProps === null || quickResponseContainerProps === void 0 ? void 0 : quickResponseContainerProps.className) }, quickResponseContainerProps, { children: quickResponses.map((_a) => {
|
|
27
28
|
var { id, onClick, content, className } = _a, props = __rest(_a, ["id", "onClick", "content", "className"]);
|
|
28
|
-
return ((0, jsx_runtime_1.jsx)(react_core_1.Label, Object.assign({ variant: id === selectedQuickResponse ? undefined : 'outline', icon: id === selectedQuickResponse ? (0, jsx_runtime_1.jsx)(react_icons_1.CheckIcon, {}) : undefined, color: "blue", onClick: () => handleQuickResponseClick(id, onClick), className:
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(react_core_1.Label, Object.assign({ variant: id === selectedQuickResponse ? undefined : 'outline', icon: id === selectedQuickResponse ? (0, jsx_runtime_1.jsx)(react_icons_1.CheckIcon, {}) : undefined, color: "blue", onClick: () => handleQuickResponseClick(id, onClick), className: (0, react_styles_1.css)(id === selectedQuickResponse && 'pf-chatbot__message-quick-response--selected', className), isCompact: isCompact }, props, { children: content }), id));
|
|
29
30
|
}) })));
|
|
30
31
|
};
|
|
31
32
|
exports.QuickResponse = QuickResponse;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|