@patternfly/chatbot 6.5.0-prerelease.27 → 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/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/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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_1 = require("@testing-library/react");
|
|
17
|
+
const user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
18
|
+
require("@testing-library/jest-dom");
|
|
19
|
+
const QuickResponse_1 = __importDefault(require("./QuickResponse"));
|
|
20
|
+
test('Renders with quick responses', () => {
|
|
21
|
+
const quickResponses = [
|
|
22
|
+
{ id: '1', content: 'Response 1' },
|
|
23
|
+
{ id: '2', content: 'Response 2' },
|
|
24
|
+
{ id: '3', content: 'Response 3' }
|
|
25
|
+
];
|
|
26
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
|
|
27
|
+
expect(react_1.screen.getByText('Response 1')).toBeVisible();
|
|
28
|
+
expect(react_1.screen.getByText('Response 2')).toBeVisible();
|
|
29
|
+
expect(react_1.screen.getByText('Response 3')).toBeVisible();
|
|
30
|
+
});
|
|
31
|
+
test('Renders with compact styling', () => {
|
|
32
|
+
const quickResponses = [{ id: '1', content: 'Compact response' }];
|
|
33
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses, isCompact: true }));
|
|
34
|
+
expect(react_1.screen.getByText('Compact response').closest('.pf-v6-c-label')).toHaveClass('pf-m-compact');
|
|
35
|
+
});
|
|
36
|
+
test('Renders with custom className on response', () => {
|
|
37
|
+
const quickResponses = [{ id: '1', content: 'Custom class response', className: 'custom-response-class' }];
|
|
38
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
|
|
39
|
+
expect(react_1.screen.getByText('Custom class response').closest('.pf-v6-c-label')).toHaveClass('custom-response-class');
|
|
40
|
+
});
|
|
41
|
+
test('Renders with custom container className', () => {
|
|
42
|
+
const quickResponses = [
|
|
43
|
+
{ id: '1', content: 'Response 1' },
|
|
44
|
+
{ id: '2', content: 'Response 2' }
|
|
45
|
+
];
|
|
46
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses, quickResponseContainerProps: { className: 'custom-container-class' } }));
|
|
47
|
+
expect(react_1.screen.getByText('Response 1').closest('.pf-v6-c-label-group')).toHaveClass('custom-container-class');
|
|
48
|
+
});
|
|
49
|
+
test('Spreads additional custom container props', () => {
|
|
50
|
+
const quickResponses = [
|
|
51
|
+
{ id: '1', content: 'Response 1' },
|
|
52
|
+
{ id: '2', content: 'Response 2' }
|
|
53
|
+
];
|
|
54
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses, quickResponseContainerProps: { id: 'custom-container-id' } }));
|
|
55
|
+
expect(react_1.screen.getByText('Response 1').closest('.pf-v6-c-label-group__list')).toHaveAttribute('id', 'custom-container-id');
|
|
56
|
+
});
|
|
57
|
+
test('Renders with pf-chatbot__message-quick-response--selected class after click', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
const user = user_event_1.default.setup();
|
|
59
|
+
const quickResponses = [
|
|
60
|
+
{ id: '1', content: 'Response 1' },
|
|
61
|
+
{ id: '2', content: 'Response 2' }
|
|
62
|
+
];
|
|
63
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
|
|
64
|
+
yield user.click(react_1.screen.getByText('Response 1'));
|
|
65
|
+
expect(react_1.screen.getByText('Response 1').closest('.pf-v6-c-label')).toHaveClass('pf-chatbot__message-quick-response--selected');
|
|
66
|
+
}));
|
|
67
|
+
test('Does not calls onClick handler when not passed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
const user = user_event_1.default.setup();
|
|
69
|
+
const handleClick = jest.fn();
|
|
70
|
+
const quickResponses = [{ id: '1', content: 'Clickable response' }];
|
|
71
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
|
|
72
|
+
yield user.click(react_1.screen.getByText('Clickable response'));
|
|
73
|
+
expect(handleClick).not.toHaveBeenCalled();
|
|
74
|
+
}));
|
|
75
|
+
test('Calls onClick handler when passed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
const user = user_event_1.default.setup();
|
|
77
|
+
const handleClick = jest.fn();
|
|
78
|
+
const quickResponses = [{ id: '1', content: 'Clickable response', onClick: handleClick }];
|
|
79
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
|
|
80
|
+
yield user.click(react_1.screen.getByText('Clickable response'));
|
|
81
|
+
expect(handleClick).toHaveBeenCalled();
|
|
82
|
+
}));
|
|
83
|
+
test('Does not call onSelect when not passed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
const user = user_event_1.default.setup();
|
|
85
|
+
const handleSelect = jest.fn();
|
|
86
|
+
const quickResponses = [
|
|
87
|
+
{ id: '1', content: 'Response 1' },
|
|
88
|
+
{ id: '2', content: 'Response 2' }
|
|
89
|
+
];
|
|
90
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
|
|
91
|
+
yield user.click(react_1.screen.getByText('Response 2'));
|
|
92
|
+
expect(handleSelect).not.toHaveBeenCalled();
|
|
93
|
+
}));
|
|
94
|
+
test('Calls onSelect when passed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
const user = user_event_1.default.setup();
|
|
96
|
+
const handleSelect = jest.fn();
|
|
97
|
+
const quickResponses = [
|
|
98
|
+
{ id: '1', content: 'Response 1' },
|
|
99
|
+
{ id: '2', content: 'Response 2' }
|
|
100
|
+
];
|
|
101
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses, onSelect: handleSelect }));
|
|
102
|
+
yield user.click(react_1.screen.getByText('Response 2'));
|
|
103
|
+
expect(handleSelect).toHaveBeenCalledWith('2');
|
|
104
|
+
}));
|
|
105
|
+
test('Spreads additional response props', () => {
|
|
106
|
+
const quickResponses = [{ id: '1', content: 'Response with props', isCompact: true, 'aria-label': 'Test label' }];
|
|
107
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
|
|
108
|
+
expect(react_1.screen.getByText('Response with props').closest('.pf-v6-c-label')).toHaveAttribute('aria-label', 'Test label');
|
|
109
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './QuickResponse';
|
|
@@ -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("./QuickResponse"), exports);
|
|
@@ -25,5 +25,5 @@ export interface QuickStartTileProps {
|
|
|
25
25
|
/** Sets the tile to compact styling */
|
|
26
26
|
isCompact?: boolean;
|
|
27
27
|
}
|
|
28
|
-
declare const QuickStartTile: FC<QuickStartTileProps>;
|
|
28
|
+
export declare const QuickStartTile: FC<QuickStartTileProps>;
|
|
29
29
|
export default QuickStartTile;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.camelize = void 0;
|
|
6
|
+
exports.QuickStartTile = exports.camelize = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const rocket_icon_1 = __importDefault(require("@patternfly/react-icons/dist/js/icons/rocket-icon"));
|
|
9
9
|
const outlined_bookmark_icon_1 = __importDefault(require("@patternfly/react-icons/dist/js/icons/outlined-bookmark-icon"));
|
|
@@ -43,4 +43,5 @@ const QuickStartTile = ({ className, quickStart, onClick, onSelectQuickStart, mi
|
|
|
43
43
|
actions: { actions: additionalAction }
|
|
44
44
|
}), { children: quickStartIcon })), (0, jsx_runtime_1.jsx)(react_core_1.CardTitle, { children: (0, jsx_runtime_1.jsx)(QuickStartTileHeader_1.default, { name: displayName, onSelect: onSelect, quickStartId: id }) }), (0, jsx_runtime_1.jsx)(react_core_1.CardBody, { children: (0, jsx_runtime_1.jsxs)(react_core_1.Stack, { hasGutter: true, children: [(0, jsx_runtime_1.jsxs)(react_core_1.Flex, { spaceItems: { default: 'spaceItemsSm' }, children: [type && (0, jsx_runtime_1.jsx)(react_core_1.Label, { color: type.color, children: type.text }), durationMinutes && ((0, jsx_runtime_1.jsx)(react_core_1.Label, { variant: "outline", "data-test": "duration", icon: (0, jsx_runtime_1.jsx)(outlined_clock_icon_1.default, {}), children: (0, react_core_1.pluralize)(durationMinutes, minuteWord, minuteWordPlural) }))] }), (0, jsx_runtime_1.jsx)(QuickStartTileDescription_1.default, { description: description, prerequisites: prerequisites, prerequisiteWord: prerequisiteWord, prerequisiteWordPlural: prerequisiteWordPlural, quickStartButtonAriaLabel: quickStartButtonAriaLabel })] }) }), (0, jsx_runtime_1.jsx)(react_core_1.CardFooter, { children: (0, jsx_runtime_1.jsx)(react_core_1.Button, { variant: "link", isInline: true, onClick: onSelect, children: (0, jsx_runtime_1.jsx)("span", { className: "pf-v6-c-button__text", children: "Start" }) }) })] }));
|
|
45
45
|
};
|
|
46
|
-
exports.
|
|
46
|
+
exports.QuickStartTile = QuickStartTile;
|
|
47
|
+
exports.default = exports.QuickStartTile;
|
|
@@ -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("./QuickStartTile"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -51,5 +51,5 @@ export interface UserFeedbackProps extends Omit<CardProps, 'onSubmit'>, OUIAProp
|
|
|
51
51
|
/** Optional privacy statement text displayed under text area */
|
|
52
52
|
privacyStatement?: string;
|
|
53
53
|
}
|
|
54
|
-
declare const UserFeedback: FunctionComponent<UserFeedbackProps>;
|
|
54
|
+
export declare const UserFeedback: FunctionComponent<UserFeedbackProps>;
|
|
55
55
|
export default UserFeedback;
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.UserFeedback = void 0;
|
|
17
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
19
|
const react_1 = require("react");
|
|
19
20
|
// Import PatternFly components
|
|
@@ -40,4 +41,5 @@ const UserFeedback = (_a) => {
|
|
|
40
41
|
onTextAreaChange && onTextAreaChange(_event, value);
|
|
41
42
|
}, placeholder: textAreaPlaceholder, "aria-label": textAreaAriaLabel, resizeOrientation: "vertical" }, textAreaProps)) })), privacyStatement && (0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__feedback-card-privacy", children: privacyStatement }), children, (0, jsx_runtime_1.jsx)(react_core_1.ActionGroup, Object.assign({}, actionGroupProps, { children: (0, jsx_runtime_1.jsx)(react_core_1.Button, Object.assign({ onClick: () => onSubmit(selectedResponse, value), size: isCompact ? 'sm' : undefined }, submitButtonProps, { children: submitWord })) }))] })) }))] })) }));
|
|
42
43
|
};
|
|
43
|
-
exports.
|
|
44
|
+
exports.UserFeedback = UserFeedback;
|
|
45
|
+
exports.default = exports.UserFeedback;
|
|
@@ -38,5 +38,5 @@ export interface UserFeedbackCompleteProps extends Omit<CardProps, 'ref'>, OUIAP
|
|
|
38
38
|
/** Timestamp passed in by Message for more context in aria announcements */
|
|
39
39
|
timestamp?: string;
|
|
40
40
|
}
|
|
41
|
-
declare const UserFeedbackComplete: FunctionComponent<UserFeedbackCompleteProps>;
|
|
41
|
+
export declare const UserFeedbackComplete: FunctionComponent<UserFeedbackCompleteProps>;
|
|
42
42
|
export default UserFeedbackComplete;
|
|
@@ -14,9 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.UserFeedbackComplete = void 0;
|
|
17
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
19
|
const react_1 = require("react");
|
|
19
|
-
// Import PatternFly components
|
|
20
20
|
const react_core_1 = require("@patternfly/react-core");
|
|
21
21
|
const CloseButton_1 = __importDefault(require("./CloseButton"));
|
|
22
22
|
const UserFeedbackComplete = (_a) => {
|
|
@@ -90,4 +90,5 @@ const UserFeedbackComplete = (_a) => {
|
|
|
90
90
|
}
|
|
91
91
|
: undefined }), (0, jsx_runtime_1.jsxs)("div", { className: "pf-chatbot__feedback-complete-body", children: [(0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__feedback-complete-image", children: (0, jsx_runtime_1.jsxs)("svg", { width: "60", height: "64", viewBox: "0 0 60 64", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M53.0555 21.5975H6.94323C3.57013 21.5975 0.835693 24.3319 0.835693 27.705V57.8925C0.835693 61.2656 3.57013 64 6.94323 64H53.0555C56.4286 64 59.1631 61.2656 59.1631 57.8925V27.705C59.1631 24.3319 56.4286 21.5975 53.0555 21.5975Z", fill: "#F8AE54" }), (0, jsx_runtime_1.jsx)("path", { d: "M55.8973 19.8247C52.5894 15.7926 29.9992 0 29.9992 0C29.9992 0 7.40996 15.7926 4.10102 19.8247C0.79312 23.8568 0.835476 25.7184 0.835476 27.8899H59.1629C59.1629 25.7184 59.2052 23.8578 55.8973 19.8257V19.8247Z", fill: "#FFCC17" }), (0, jsx_runtime_1.jsx)("g", { children: (0, jsx_runtime_1.jsx)("path", { d: "M53.0567 8.48981H6.94336V61.8388H53.0567V8.48981Z", fill: "#F2F2F2" }) }), (0, jsx_runtime_1.jsx)("path", { d: "M51.6589 7.49908H8.34204V60.8481H51.6589V7.49908Z", fill: "white" }), (0, jsx_runtime_1.jsx)("path", { d: "M0.835693 29.1296V57.8925C0.835693 59.2375 1.27165 60.4803 2.00823 61.4896L23.0303 43.5462L0.835693 29.1296Z", fill: "#FFCC17" }), (0, jsx_runtime_1.jsx)("path", { d: "M36.9695 43.5472L57.9905 61.4907C58.7271 60.4813 59.1631 59.2386 59.1631 57.8935V29.1306L36.9685 43.5472H36.9695Z", fill: "#FFF4CC" }), (0, jsx_runtime_1.jsx)("path", { d: "M0.835693 57.8925V57.8067L22.4146 42.7992L29.9994 37.5244L37.5842 42.7992L59.1641 57.8067V57.8925C59.1641 61.2665 56.4296 64 53.0566 64H6.94323C3.57024 64 0.835693 61.2665 0.835693 57.8925Z", fill: "#FFE072" }), (0, jsx_runtime_1.jsx)("g", { children: (0, jsx_runtime_1.jsx)("path", { d: "M22.1563 42.978L0.835693 57.8067V56.6993L22.1563 42.978Z", fill: "#FEF07C" }) }), (0, jsx_runtime_1.jsx)("g", { children: (0, jsx_runtime_1.jsx)("path", { d: "M37.8425 42.978L59.1631 57.8067V56.6993L37.8425 42.978Z", fill: "#FEF07C" }) }), (0, jsx_runtime_1.jsx)("path", { d: "M37.8037 32.2373C42.1136 27.9273 42.1136 20.9395 37.8037 16.6295C33.4937 12.3196 26.5059 12.3196 22.196 16.6295C17.886 20.9395 17.886 27.9273 22.196 32.2373C26.5059 36.5472 33.4937 36.5472 37.8037 32.2373Z", fill: "#0066CC" }), (0, jsx_runtime_1.jsx)("path", { d: "M27.7803 30.1276C27.6098 30.1276 27.4497 30.0614 27.3298 29.9406L22.9465 25.5562C22.8267 25.4364 22.7595 25.2762 22.7595 25.1068C22.7595 24.9374 22.8256 24.7762 22.9465 24.6554L24.2379 23.364C24.3577 23.2442 24.5178 23.177 24.6883 23.177C24.8587 23.177 25.0168 23.2431 25.1377 23.363L27.7803 26.0056L34.861 18.9259C34.9808 18.8061 35.1409 18.7389 35.3103 18.7389C35.4798 18.7389 35.6389 18.8051 35.7597 18.9239L37.0531 20.2173C37.173 20.3361 37.2401 20.4962 37.2401 20.6677C37.2401 20.8392 37.174 20.9983 37.0531 21.1181L28.2317 29.9406C28.1119 30.0604 27.9518 30.1265 27.7823 30.1265L27.7803 30.1276Z", fill: "white" })] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "pf-chatbot__feedback-complete-text", children: [(0, jsx_runtime_1.jsx)(react_core_1.CardTitle, { className: "pf-chatbot__feedback-complete-title", children: title }), (0, jsx_runtime_1.jsx)(react_core_1.CardBody, { className: `pf-chatbot__feedback-complete-card-body`, children: body })] })] })] })) })));
|
|
92
92
|
};
|
|
93
|
-
exports.
|
|
93
|
+
exports.UserFeedbackComplete = UserFeedbackComplete;
|
|
94
|
+
exports.default = exports.UserFeedbackComplete;
|
|
@@ -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("./UserFeedback"), exports);
|
|
18
|
+
__exportStar(require("./UserFeedbackComplete"), exports);
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
export { default } from './Message';
|
|
2
2
|
export { rehypeCodeBlockToggle } from './Plugins/rehypeCodeBlockToggle';
|
|
3
|
+
export * from './ErrorMessage/ErrorMessage';
|
|
4
|
+
export * from './MessageAndActions';
|
|
5
|
+
export * from './MessageAttachments';
|
|
3
6
|
export * from './Message';
|
|
7
|
+
export * from './MessageLoading';
|
|
8
|
+
export * from './MessageInput';
|
|
9
|
+
export * from './QuickResponse';
|
|
10
|
+
export * from './QuickStarts';
|
|
11
|
+
export * from './UserFeedback';
|
|
@@ -22,4 +22,12 @@ var Message_1 = require("./Message");
|
|
|
22
22
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Message_1).default; } });
|
|
23
23
|
var rehypeCodeBlockToggle_1 = require("./Plugins/rehypeCodeBlockToggle");
|
|
24
24
|
Object.defineProperty(exports, "rehypeCodeBlockToggle", { enumerable: true, get: function () { return rehypeCodeBlockToggle_1.rehypeCodeBlockToggle; } });
|
|
25
|
+
__exportStar(require("./ErrorMessage/ErrorMessage"), exports);
|
|
26
|
+
__exportStar(require("./MessageAndActions"), exports);
|
|
27
|
+
__exportStar(require("./MessageAttachments"), exports);
|
|
25
28
|
__exportStar(require("./Message"), exports);
|
|
29
|
+
__exportStar(require("./MessageLoading"), exports);
|
|
30
|
+
__exportStar(require("./MessageInput"), exports);
|
|
31
|
+
__exportStar(require("./QuickResponse"), exports);
|
|
32
|
+
__exportStar(require("./QuickStarts"), exports);
|
|
33
|
+
__exportStar(require("./UserFeedback"), exports);
|
|
@@ -29,6 +29,10 @@ export interface ActionProps extends Omit<ButtonProps, 'ref'> {
|
|
|
29
29
|
type ExtendedActionProps = ActionProps & {
|
|
30
30
|
[key: string]: any;
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* The various actions that can be attached to a bot message for users to interact with.
|
|
34
|
+
* Use this component when passing children to Message to customize its structure.
|
|
35
|
+
*/
|
|
32
36
|
export interface ResponseActionProps {
|
|
33
37
|
/** Props for message actions, such as feedback (positive or negative), copy button, share, and listen */
|
|
34
38
|
actions: Record<string, ExtendedActionProps | undefined> & {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FunctionComponent, HTMLProps, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The container for grouping multiple related ResponseActions components, typically used for having different persistence states amongst groups.
|
|
4
|
+
* Use this component when passing children to Message to customize its structure.
|
|
5
|
+
*/
|
|
6
|
+
export interface ResponseActionsGroupsProps extends HTMLProps<HTMLDivElement> {
|
|
7
|
+
/** Content to render inside the response actions groups container */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Additional classes applied to the response actions groups container. */
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const ResponseActionsGroups: FunctionComponent<ResponseActionsGroupsProps>;
|
|
13
|
+
export default ResponseActionsGroups;
|
|
@@ -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.ResponseActionsGroups = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_styles_1 = require("@patternfly/react-styles");
|
|
17
|
+
const ResponseActionsGroups = (_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__response-actions-groups', className) }, props, { children: children })));
|
|
20
|
+
};
|
|
21
|
+
exports.ResponseActionsGroups = ResponseActionsGroups;
|
|
22
|
+
exports.default = exports.ResponseActionsGroups;
|
|
@@ -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 ResponseActionsGroups_1 = __importDefault(require("./ResponseActionsGroups"));
|
|
10
|
+
test('Renders with children', () => {
|
|
11
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ResponseActionsGroups_1.default, { children: "Test content" }));
|
|
12
|
+
expect(react_1.screen.getByText('Test content')).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
test('Renders with pf-chatbot__response-actions-groups class by default', () => {
|
|
15
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ResponseActionsGroups_1.default, { children: "Test content" }));
|
|
16
|
+
expect(react_1.screen.getByText('Test content')).toHaveClass('pf-chatbot__response-actions-groups', { exact: true });
|
|
17
|
+
});
|
|
18
|
+
test('Renders with custom className', () => {
|
|
19
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(ResponseActionsGroups_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)(ResponseActionsGroups_1.default, { id: "test-id", children: "Test content" }));
|
|
24
|
+
expect(react_1.screen.getByText('Test content')).toHaveAttribute('id', 'test-id');
|
|
25
|
+
});
|
|
@@ -21,3 +21,4 @@ exports.default = void 0;
|
|
|
21
21
|
var ResponseActions_1 = require("./ResponseActions");
|
|
22
22
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(ResponseActions_1).default; } });
|
|
23
23
|
__exportStar(require("./ResponseActions"), exports);
|
|
24
|
+
__exportStar(require("./ResponseActionsGroups"), exports);
|
|
@@ -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;
|
|
@@ -14,8 +14,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
// Chatbot Main - Message - Content - Error
|
|
15
15
|
// ============================================================================
|
|
16
16
|
import { Alert } from '@patternfly/react-core';
|
|
17
|
-
const ErrorMessage = (_a) => {
|
|
18
|
-
var { title, actionLinks, children } = _a, props = __rest(_a, ["title", "actionLinks", "children"]);
|
|
19
|
-
return (_jsx(Alert, Object.assign({ isInline: true, variant: "danger", title: title, actionLinks: actionLinks }, props, { children: children })));
|
|
17
|
+
export const ErrorMessage = (_a) => {
|
|
18
|
+
var { title, actionLinks, children, className } = _a, props = __rest(_a, ["title", "actionLinks", "children", "className"]);
|
|
19
|
+
return (_jsx(Alert, Object.assign({ isInline: true, variant: "danger", title: title, actionLinks: actionLinks, className: className }, props, { children: children })));
|
|
20
20
|
};
|
|
21
21
|
export default ErrorMessage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,25 @@
|
|
|
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 ErrorMessage from './ErrorMessage';
|
|
5
|
+
test('Renders with title', () => {
|
|
6
|
+
render(_jsx(ErrorMessage, { title: "Error occurred" }));
|
|
7
|
+
expect(screen.getByText('Error occurred')).toBeVisible();
|
|
8
|
+
});
|
|
9
|
+
test('Renders with children', () => {
|
|
10
|
+
render(_jsx(ErrorMessage, { title: "Error occurred", children: "This is the error message body" }));
|
|
11
|
+
expect(screen.getByText('This is the error message body')).toBeVisible();
|
|
12
|
+
});
|
|
13
|
+
test('Renders with action links', () => {
|
|
14
|
+
const actionLinks = (_jsx("a", { href: "#retry", "data-testid": "retry-link", children: "Retry action link" }));
|
|
15
|
+
render(_jsx(ErrorMessage, { title: "Error occurred", actionLinks: actionLinks }));
|
|
16
|
+
expect(screen.getByText('Retry action link')).toBeVisible();
|
|
17
|
+
});
|
|
18
|
+
test('Renders with custom className', () => {
|
|
19
|
+
render(_jsx(ErrorMessage, { title: "Error occurred", className: "custom-error-class" }));
|
|
20
|
+
expect(screen.getByText('Error occurred').parentElement).toHaveClass('custom-error-class');
|
|
21
|
+
});
|
|
22
|
+
test('Renders with spread props', () => {
|
|
23
|
+
render(_jsx(ErrorMessage, { title: "Error occurred", id: "test-error-id" }));
|
|
24
|
+
expect(screen.getByText('Error occurred').parentElement).toHaveAttribute('id', 'test-error-id');
|
|
25
|
+
});
|
|
@@ -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 */
|
|
@@ -32,7 +32,7 @@ import DeepThinking from '../DeepThinking';
|
|
|
32
32
|
import ToolCall from '../ToolCall';
|
|
33
33
|
import MarkdownContent from '../MarkdownContent';
|
|
34
34
|
export const MessageBase = (_a) => {
|
|
35
|
-
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"]);
|
|
35
|
+
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"]);
|
|
36
36
|
const [messageText, setMessageText] = useState(content);
|
|
37
37
|
useEffect(() => {
|
|
38
38
|
setMessageText(content);
|
|
@@ -60,10 +60,10 @@ export const MessageBase = (_a) => {
|
|
|
60
60
|
}
|
|
61
61
|
return (_jsxs(_Fragment, { children: [beforeMainContent && _jsx(_Fragment, { children: beforeMainContent }), error ? _jsx(ErrorMessage, Object.assign({}, error)) : handleMarkdown()] }));
|
|
62
62
|
};
|
|
63
|
-
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: [avatar && (_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 })] }),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
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: [avatar && (_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 })] }), _jsx("div", { className: "pf-chatbot__message-response", children: children ? (_jsx(_Fragment, { children: children })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "pf-chatbot__message-and-actions", children: [renderMessage(), afterMainContent && _jsx(_Fragment, { children: afterMainContent }), toolResponse && _jsx(ToolResponse, Object.assign({}, toolResponse)), deepThinking && _jsx(DeepThinking, Object.assign({}, deepThinking)), toolCall && _jsx(ToolCall, Object.assign({}, toolCall)), !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(_Fragment, { children: Array.isArray(actions) ? (_jsx("div", { className: "pf-chatbot__response-actions-groups", children: actions.map((actionGroup, index) => (_jsx(ResponseActions, { actions: actionGroup.actions || actionGroup, persistActionSelection: persistActionSelection || actionGroup.persistActionSelection }, index))) })) : (_jsx(ResponseActions, { actions: actions, persistActionSelection: persistActionSelection })) })), 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) => {
|
|
64
|
+
var _a;
|
|
65
|
+
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, variant: isPrimary ? 'outline' : undefined }) }, (_a = attachment.id) !== null && _a !== void 0 ? _a : attachment.name));
|
|
66
|
+
}) })), !isLoading && endContent && _jsx(_Fragment, { children: endContent })] })) })] })] })));
|
|
67
67
|
};
|
|
68
68
|
const Message = forwardRef((props, ref) => (_jsx(MessageBase, Object.assign({ innerRef: ref }, props))));
|
|
69
69
|
export default Message;
|
|
@@ -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,18 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
13
|
+
import { css } from '@patternfly/react-styles';
|
|
14
|
+
export const MessageAndActions = (_a) => {
|
|
15
|
+
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
16
|
+
return (_jsx("div", Object.assign({ className: css('pf-chatbot__message-and-actions', className) }, props, { children: children })));
|
|
17
|
+
};
|
|
18
|
+
export default MessageAndActions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import MessageAndActions from './MessageAndActions';
|
|
5
|
+
test('Renders with children', () => {
|
|
6
|
+
render(_jsx(MessageAndActions, { children: "Test content" }));
|
|
7
|
+
expect(screen.getByText('Test content')).toBeInTheDocument();
|
|
8
|
+
});
|
|
9
|
+
test('Renders with pf-chatbot__message-and-actions class by default', () => {
|
|
10
|
+
render(_jsx(MessageAndActions, { children: "Test content" }));
|
|
11
|
+
expect(screen.getByText('Test content')).toHaveClass('pf-chatbot__message-and-actions', { exact: true });
|
|
12
|
+
});
|
|
13
|
+
test('Renders with custom className', () => {
|
|
14
|
+
render(_jsx(MessageAndActions, { className: "custom-class", children: "Test content" }));
|
|
15
|
+
expect(screen.getByText('Test content')).toHaveClass('custom-class');
|
|
16
|
+
});
|
|
17
|
+
test('Spreads additional props', () => {
|
|
18
|
+
render(_jsx(MessageAndActions, { id: "test-id", children: "Test content" }));
|
|
19
|
+
expect(screen.getByText('Test content')).toHaveAttribute('id', 'test-id');
|
|
20
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MessageAndActions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MessageAndActions';
|
|
@@ -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;
|