@patternfly/chatbot 2.2.0-prerelease.44 → 2.2.0-prerelease.46
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/Message/Message.d.ts +15 -1
- package/dist/cjs/Message/Message.js +53 -34
- package/dist/cjs/Message/Message.test.js +46 -0
- package/dist/cjs/Message/MessageInput.d.ts +18 -0
- package/dist/cjs/Message/MessageInput.js +34 -0
- package/dist/cjs/SourcesCard/SourcesCard.d.ts +6 -1
- package/dist/cjs/SourcesCard/SourcesCard.js +14 -9
- package/dist/cjs/SourcesCard/SourcesCard.test.js +25 -11
- package/dist/css/main.css +7 -7
- package/dist/css/main.css.map +1 -1
- package/dist/esm/Message/Message.d.ts +15 -1
- package/dist/esm/Message/Message.js +53 -34
- package/dist/esm/Message/Message.test.js +46 -0
- package/dist/esm/Message/MessageInput.d.ts +18 -0
- package/dist/esm/Message/MessageInput.js +29 -0
- package/dist/esm/SourcesCard/SourcesCard.d.ts +6 -1
- package/dist/esm/SourcesCard/SourcesCard.js +15 -10
- package/dist/esm/SourcesCard/SourcesCard.test.js +25 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +34 -5
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +61 -14
- package/src/Message/Message.scss +4 -0
- package/src/Message/Message.test.tsx +48 -0
- package/src/Message/Message.tsx +107 -53
- package/src/Message/MessageInput.tsx +59 -0
- package/src/SourcesCard/SourcesCard.scss +3 -7
- package/src/SourcesCard/SourcesCard.test.tsx +30 -17
- package/src/SourcesCard/SourcesCard.tsx +41 -11
@@ -41,8 +41,13 @@ import rehypeExternalLinks from 'rehype-external-links';
|
|
41
41
|
import rehypeSanitize from 'rehype-sanitize';
|
42
42
|
import LinkMessage from './LinkMessage/LinkMessage';
|
43
43
|
import ErrorMessage from './ErrorMessage/ErrorMessage';
|
44
|
+
import MessageInput from './MessageInput';
|
44
45
|
export const MessageBase = (_a) => {
|
45
|
-
var { role, content, extraContent, name, avatar, timestamp, isLoading, actions, sources, botWord = 'AI', loadingWord = 'Loading message', codeBlockProps, quickResponses, quickResponseContainerProps = { numLabels: 5 }, attachments, hasRoundAvatar = true, avatarProps, quickStarts, userFeedbackForm, userFeedbackComplete, isLiveRegion = true, innerRef, tableProps, openLinkInNewTab = true, additionalRehypePlugins = [], linkProps, error } = _a, props = __rest(_a, ["role", "content", "extraContent", "name", "avatar", "timestamp", "isLoading", "actions", "sources", "botWord", "loadingWord", "codeBlockProps", "quickResponses", "quickResponseContainerProps", "attachments", "hasRoundAvatar", "avatarProps", "quickStarts", "userFeedbackForm", "userFeedbackComplete", "isLiveRegion", "innerRef", "tableProps", "openLinkInNewTab", "additionalRehypePlugins", "linkProps", "error"]);
|
46
|
+
var { role, content, extraContent, name, avatar, timestamp, isLoading, actions, sources, botWord = 'AI', loadingWord = 'Loading message', codeBlockProps, quickResponses, quickResponseContainerProps = { numLabels: 5 }, attachments, hasRoundAvatar = true, avatarProps, quickStarts, userFeedbackForm, userFeedbackComplete, isLiveRegion = true, innerRef, tableProps, openLinkInNewTab = true, additionalRehypePlugins = [], linkProps, error, isEditable, editPlaceholder = 'Edit prompt message...', updateWord = 'Update', cancelWord = 'Cancel', onEditUpdate, onEditCancel, editFormProps } = _a, props = __rest(_a, ["role", "content", "extraContent", "name", "avatar", "timestamp", "isLoading", "actions", "sources", "botWord", "loadingWord", "codeBlockProps", "quickResponses", "quickResponseContainerProps", "attachments", "hasRoundAvatar", "avatarProps", "quickStarts", "userFeedbackForm", "userFeedbackComplete", "isLiveRegion", "innerRef", "tableProps", "openLinkInNewTab", "additionalRehypePlugins", "linkProps", "error", "isEditable", "editPlaceholder", "updateWord", "cancelWord", "onEditUpdate", "onEditCancel", "editFormProps"]);
|
47
|
+
const [messageText, setMessageText] = React.useState(content);
|
48
|
+
React.useEffect(() => {
|
49
|
+
setMessageText(content);
|
50
|
+
}, [content]);
|
46
51
|
const { beforeMainContent, afterMainContent, endContent } = extraContent || {};
|
47
52
|
let rehypePlugins = [rehypeUnwrapImages];
|
48
53
|
if (openLinkInNewTab) {
|
@@ -60,6 +65,51 @@ export const MessageBase = (_a) => {
|
|
60
65
|
// Keep timestamps consistent between Timestamp component and aria-label
|
61
66
|
const date = new Date();
|
62
67
|
const dateString = timestamp !== null && timestamp !== void 0 ? timestamp : `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
|
68
|
+
const renderMessage = () => {
|
69
|
+
if (isLoading) {
|
70
|
+
return React.createElement(MessageLoading, { loadingWord: loadingWord });
|
71
|
+
}
|
72
|
+
if (isEditable) {
|
73
|
+
return (React.createElement(React.Fragment, null,
|
74
|
+
beforeMainContent && React.createElement(React.Fragment, null, beforeMainContent),
|
75
|
+
React.createElement(MessageInput, Object.assign({ content: content, editPlaceholder: editPlaceholder, updateWord: updateWord, cancelWord: cancelWord, onEditUpdate: (event, text) => {
|
76
|
+
onEditUpdate && onEditUpdate(event);
|
77
|
+
setMessageText(text);
|
78
|
+
}, onEditCancel: onEditCancel }, editFormProps))));
|
79
|
+
}
|
80
|
+
return (React.createElement(React.Fragment, null,
|
81
|
+
beforeMainContent && React.createElement(React.Fragment, null, beforeMainContent),
|
82
|
+
error ? (React.createElement(ErrorMessage, Object.assign({}, error))) : (React.createElement(Markdown, { components: {
|
83
|
+
p: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.p }, props)),
|
84
|
+
code: (_a) => {
|
85
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
86
|
+
return (React.createElement(CodeBlockMessage, Object.assign({}, props, codeBlockProps), children));
|
87
|
+
},
|
88
|
+
h1: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h1 }, props)),
|
89
|
+
h2: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h2 }, props)),
|
90
|
+
h3: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h3 }, props)),
|
91
|
+
h4: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h4 }, props)),
|
92
|
+
h5: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h5 }, props)),
|
93
|
+
h6: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h6 }, props)),
|
94
|
+
blockquote: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.blockquote }, props)),
|
95
|
+
ul: (props) => React.createElement(UnorderedListMessage, Object.assign({}, props)),
|
96
|
+
ol: (props) => React.createElement(OrderedListMessage, Object.assign({}, props)),
|
97
|
+
li: (props) => React.createElement(ListItemMessage, Object.assign({}, props)),
|
98
|
+
table: (props) => React.createElement(TableMessage, Object.assign({}, props, tableProps)),
|
99
|
+
tbody: (props) => React.createElement(TbodyMessage, Object.assign({}, props)),
|
100
|
+
thead: (props) => React.createElement(TheadMessage, Object.assign({}, props)),
|
101
|
+
tr: (props) => React.createElement(TrMessage, Object.assign({}, props)),
|
102
|
+
td: (props) => {
|
103
|
+
// Conflicts with Td type
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
105
|
+
const { width } = props, rest = __rest(props, ["width"]);
|
106
|
+
return React.createElement(TdMessage, Object.assign({}, rest));
|
107
|
+
},
|
108
|
+
th: (props) => React.createElement(ThMessage, Object.assign({}, props)),
|
109
|
+
img: (props) => React.createElement(ImageMessage, Object.assign({}, props)),
|
110
|
+
a: (props) => (React.createElement(LinkMessage, Object.assign({ href: props.href, rel: props.rel, target: props.target }, linkProps), props.children))
|
111
|
+
}, remarkPlugins: [remarkGfm], rehypePlugins: rehypePlugins }, messageText))));
|
112
|
+
};
|
63
113
|
return (React.createElement("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),
|
64
114
|
React.createElement(Avatar, Object.assign({ className: `pf-chatbot__message-avatar ${hasRoundAvatar ? 'pf-chatbot__message-avatar--round' : ''} ${avatarClassName ? avatarClassName : ''}`, src: avatar, alt: "" }, avatarProps)),
|
65
115
|
React.createElement("div", { className: "pf-chatbot__message-contents" },
|
@@ -70,39 +120,8 @@ export const MessageBase = (_a) => {
|
|
70
120
|
React.createElement(Timestamp, { date: date }, timestamp)),
|
71
121
|
React.createElement("div", { className: "pf-chatbot__message-response" },
|
72
122
|
React.createElement("div", { className: "pf-chatbot__message-and-actions" },
|
73
|
-
|
74
|
-
|
75
|
-
error ? (React.createElement(ErrorMessage, Object.assign({}, error))) : (React.createElement(Markdown, { components: {
|
76
|
-
p: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.p }, props)),
|
77
|
-
code: (_a) => {
|
78
|
-
var { children } = _a, props = __rest(_a, ["children"]);
|
79
|
-
return (React.createElement(CodeBlockMessage, Object.assign({}, props, codeBlockProps), children));
|
80
|
-
},
|
81
|
-
h1: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h1 }, props)),
|
82
|
-
h2: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h2 }, props)),
|
83
|
-
h3: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h3 }, props)),
|
84
|
-
h4: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h4 }, props)),
|
85
|
-
h5: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h5 }, props)),
|
86
|
-
h6: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.h6 }, props)),
|
87
|
-
blockquote: (props) => React.createElement(TextMessage, Object.assign({ component: ContentVariants.blockquote }, props)),
|
88
|
-
ul: (props) => React.createElement(UnorderedListMessage, Object.assign({}, props)),
|
89
|
-
ol: (props) => React.createElement(OrderedListMessage, Object.assign({}, props)),
|
90
|
-
li: (props) => React.createElement(ListItemMessage, Object.assign({}, props)),
|
91
|
-
table: (props) => React.createElement(TableMessage, Object.assign({}, props, tableProps)),
|
92
|
-
tbody: (props) => React.createElement(TbodyMessage, Object.assign({}, props)),
|
93
|
-
thead: (props) => React.createElement(TheadMessage, Object.assign({}, props)),
|
94
|
-
tr: (props) => React.createElement(TrMessage, Object.assign({}, props)),
|
95
|
-
td: (props) => {
|
96
|
-
// Conflicts with Td type
|
97
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
98
|
-
const { width } = props, rest = __rest(props, ["width"]);
|
99
|
-
return React.createElement(TdMessage, Object.assign({}, rest));
|
100
|
-
},
|
101
|
-
th: (props) => React.createElement(ThMessage, Object.assign({}, props)),
|
102
|
-
img: (props) => React.createElement(ImageMessage, Object.assign({}, props)),
|
103
|
-
a: (props) => (React.createElement(LinkMessage, Object.assign({ href: props.href, rel: props.rel, target: props.target }, linkProps), props.children))
|
104
|
-
}, remarkPlugins: [remarkGfm], rehypePlugins: rehypePlugins }, content)),
|
105
|
-
afterMainContent && React.createElement(React.Fragment, null, afterMainContent))),
|
123
|
+
renderMessage(),
|
124
|
+
afterMainContent && React.createElement(React.Fragment, null, afterMainContent),
|
106
125
|
!isLoading && sources && React.createElement(SourcesCard, Object.assign({}, sources)),
|
107
126
|
quickStarts && quickStarts.quickStart && (React.createElement(QuickStartTile, { quickStart: quickStarts.quickStart, onSelectQuickStart: quickStarts.onSelectQuickStart, minuteWord: quickStarts.minuteWord, minuteWordPlural: quickStarts.minuteWordPlural, prerequisiteWord: quickStarts.prerequisiteWord, prerequisiteWordPlural: quickStarts.prerequisiteWordPlural, quickStartButtonAriaLabel: quickStarts.quickStartButtonAriaLabel })),
|
108
127
|
!isLoading && actions && React.createElement(ResponseActions, { actions: actions }),
|
@@ -620,4 +620,50 @@ describe('Message', () => {
|
|
620
620
|
expect(screen.getByRole('heading', { name: /Could not load chat/i })).toBeTruthy();
|
621
621
|
expect(screen.queryByText('Test')).toBeFalsy();
|
622
622
|
});
|
623
|
+
it('should handle isEditable when there is message content', () => {
|
624
|
+
render(React.createElement(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, content: "Test" }));
|
625
|
+
expect(screen.getByRole('textbox')).toBeTruthy();
|
626
|
+
expect(screen.getByRole('textbox')).toHaveValue('Test');
|
627
|
+
expect(screen.getByRole('button', { name: /Update/i })).toBeTruthy();
|
628
|
+
expect(screen.getByRole('button', { name: /Cancel/i })).toBeTruthy();
|
629
|
+
});
|
630
|
+
it('should handle isEditable when there is no message content', () => {
|
631
|
+
render(React.createElement(Message, { avatar: "./img", role: "user", name: "User", isEditable: true }));
|
632
|
+
expect(screen.getByRole('textbox')).toBeTruthy();
|
633
|
+
expect(screen.getByRole('textbox')).toHaveValue('');
|
634
|
+
expect(screen.getByRole('textbox')).toHaveAttribute('placeholder', 'Edit prompt message...');
|
635
|
+
expect(screen.getByRole('button', { name: /Update/i })).toBeTruthy();
|
636
|
+
expect(screen.getByRole('button', { name: /Cancel/i })).toBeTruthy();
|
637
|
+
});
|
638
|
+
it('should be able to change edit placeholder', () => {
|
639
|
+
render(React.createElement(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, editPlaceholder: "I am a placeholder" }));
|
640
|
+
expect(screen.getByRole('textbox')).toBeTruthy();
|
641
|
+
expect(screen.getByRole('textbox')).toHaveValue('');
|
642
|
+
expect(screen.getByRole('textbox')).toHaveAttribute('placeholder', 'I am a placeholder');
|
643
|
+
});
|
644
|
+
it('should be able to change updateWord', () => {
|
645
|
+
render(React.createElement(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, updateWord: "Submit" }));
|
646
|
+
expect(screen.getByRole('button', { name: /Submit/i })).toBeTruthy();
|
647
|
+
});
|
648
|
+
it('should be able to change cancelWord', () => {
|
649
|
+
render(React.createElement(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, cancelWord: "Don't submit" }));
|
650
|
+
expect(screen.getByRole('button', { name: /Don't submit/i })).toBeTruthy();
|
651
|
+
});
|
652
|
+
it('should be able to add onEditUpdate', () => __awaiter(void 0, void 0, void 0, function* () {
|
653
|
+
const spy = jest.fn();
|
654
|
+
render(React.createElement(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, onEditUpdate: spy }));
|
655
|
+
yield userEvent.click(screen.getByRole('button', { name: /Update/i }));
|
656
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
657
|
+
}));
|
658
|
+
it('should be able to add onEditCancel', () => __awaiter(void 0, void 0, void 0, function* () {
|
659
|
+
const spy = jest.fn();
|
660
|
+
render(React.createElement(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, onEditCancel: spy }));
|
661
|
+
yield userEvent.click(screen.getByRole('button', { name: /Cancel/i }));
|
662
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
663
|
+
}));
|
664
|
+
it('should be able to add editFormProps', () => {
|
665
|
+
const { container } = render(React.createElement(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, editFormProps: { className: 'test' } }));
|
666
|
+
const form = container.querySelector('form');
|
667
|
+
expect(form).toHaveClass('test');
|
668
|
+
});
|
623
669
|
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { FormProps } from '@patternfly/react-core';
|
3
|
+
export interface MessageInputProps extends FormProps {
|
4
|
+
/** Placeholder for edit input */
|
5
|
+
editPlaceholder?: string;
|
6
|
+
/** Label for the English word "Update" used in edit mode. */
|
7
|
+
updateWord?: string;
|
8
|
+
/** Label for the English word "Cancel" used in edit mode. */
|
9
|
+
cancelWord?: string;
|
10
|
+
/** Callback function for when edit mode update button is clicked */
|
11
|
+
onEditUpdate?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>, value: string) => void;
|
12
|
+
/** Callback functionf or when edit cancel update button is clicked */
|
13
|
+
onEditCancel?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
14
|
+
/** Message text */
|
15
|
+
content?: string;
|
16
|
+
}
|
17
|
+
declare const MessageInput: React.FunctionComponent<MessageInputProps>;
|
18
|
+
export default MessageInput;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
// ============================================================================
|
2
|
+
// Chatbot Main - Message Input
|
3
|
+
// ============================================================================
|
4
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
5
|
+
var t = {};
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
7
|
+
t[p] = s[p];
|
8
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
9
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
10
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
11
|
+
t[p[i]] = s[p[i]];
|
12
|
+
}
|
13
|
+
return t;
|
14
|
+
};
|
15
|
+
import React from 'react';
|
16
|
+
import { ActionGroup, Button, Form, TextArea } from '@patternfly/react-core';
|
17
|
+
const MessageInput = (_a) => {
|
18
|
+
var { editPlaceholder = 'Edit prompt message...', updateWord = 'Update', cancelWord = 'Cancel', onEditUpdate, onEditCancel, content } = _a, props = __rest(_a, ["editPlaceholder", "updateWord", "cancelWord", "onEditUpdate", "onEditCancel", "content"]);
|
19
|
+
const [messageText, setMessageText] = React.useState(content !== null && content !== void 0 ? content : '');
|
20
|
+
const onChange = (event, value) => {
|
21
|
+
setMessageText(value);
|
22
|
+
};
|
23
|
+
return (React.createElement(Form, Object.assign({}, props),
|
24
|
+
React.createElement(TextArea, { placeholder: editPlaceholder, value: messageText, onChange: onChange, "aria-label": editPlaceholder, autoResize: true }),
|
25
|
+
React.createElement(ActionGroup, { className: "pf-chatbot__message-edit-buttons" },
|
26
|
+
React.createElement(Button, { variant: "primary", onClick: (event) => onEditUpdate && onEditUpdate(event, messageText) }, updateWord),
|
27
|
+
React.createElement(Button, { variant: "secondary", onClick: onEditCancel }, cancelWord))));
|
28
|
+
};
|
29
|
+
export default MessageInput;
|
@@ -5,7 +5,7 @@ export interface SourcesCardProps extends CardProps {
|
|
5
5
|
className?: string;
|
6
6
|
/** Flag indicating if the pagination is disabled. */
|
7
7
|
isDisabled?: boolean;
|
8
|
-
/** Label for the English word "of"
|
8
|
+
/** @deprecated ofWord has been deprecated. Label for the English word "of." */
|
9
9
|
ofWord?: string;
|
10
10
|
/** Accessible label for the pagination component. */
|
11
11
|
paginationAriaLabel?: string;
|
@@ -15,6 +15,7 @@ export interface SourcesCardProps extends CardProps {
|
|
15
15
|
link: string;
|
16
16
|
body?: React.ReactNode | string;
|
17
17
|
isExternal?: boolean;
|
18
|
+
hasShowMore?: boolean;
|
18
19
|
}[];
|
19
20
|
/** Label for the English word "source" */
|
20
21
|
sourceWord?: string;
|
@@ -30,6 +31,10 @@ export interface SourcesCardProps extends CardProps {
|
|
30
31
|
onPreviousClick?: (event: React.SyntheticEvent<HTMLButtonElement>, page: number) => void;
|
31
32
|
/** Function called when page is changed. */
|
32
33
|
onSetPage?: (event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => void;
|
34
|
+
/** Label for English words "show more" */
|
35
|
+
showMoreWords?: string;
|
36
|
+
/** Label for English words "show less" */
|
37
|
+
showLessWords?: string;
|
33
38
|
}
|
34
39
|
declare const SourcesCard: React.FunctionComponent<SourcesCardProps>;
|
35
40
|
export default SourcesCard;
|
@@ -14,11 +14,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
14
14
|
// ============================================================================
|
15
15
|
import React from 'react';
|
16
16
|
// Import PatternFly components
|
17
|
-
import { Button, ButtonVariant, Card, CardBody, CardFooter, CardTitle, Icon, pluralize, Truncate } from '@patternfly/react-core';
|
17
|
+
import { Button, ButtonVariant, Card, CardBody, CardFooter, CardTitle, ExpandableSection, ExpandableSectionVariant, Icon, pluralize, Truncate } from '@patternfly/react-core';
|
18
18
|
import { ExternalLinkSquareAltIcon } from '@patternfly/react-icons';
|
19
19
|
const SourcesCard = (_a) => {
|
20
|
-
var { className, isDisabled,
|
20
|
+
var { className, isDisabled, paginationAriaLabel = 'Pagination', sources, sourceWord = 'source', sourceWordPlural = 'sources', toNextPageAriaLabel = 'Go to next page', toPreviousPageAriaLabel = 'Go to previous page', onNextClick, onPreviousClick, onSetPage, showMoreWords = 'show more', showLessWords = 'show less' } = _a, props = __rest(_a, ["className", "isDisabled", "paginationAriaLabel", "sources", "sourceWord", "sourceWordPlural", "toNextPageAriaLabel", "toPreviousPageAriaLabel", "onNextClick", "onPreviousClick", "onSetPage", "showMoreWords", "showLessWords"]);
|
21
21
|
const [page, setPage] = React.useState(1);
|
22
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
23
|
+
const onToggle = (_event, isExpanded) => {
|
24
|
+
setIsExpanded(isExpanded);
|
25
|
+
};
|
22
26
|
const handleNewPage = (_evt, newPage) => {
|
23
27
|
setPage(newPage);
|
24
28
|
onSetPage && onSetPage(_evt, newPage);
|
@@ -34,7 +38,10 @@ const SourcesCard = (_a) => {
|
|
34
38
|
React.createElement(Card, Object.assign({ className: "pf-chatbot__sources-card" }, props),
|
35
39
|
React.createElement(CardTitle, { className: "pf-chatbot__sources-card-title" },
|
36
40
|
React.createElement(Button, { component: "a", variant: ButtonVariant.link, href: sources[page - 1].link, icon: sources[page - 1].isExternal ? React.createElement(ExternalLinkSquareAltIcon, null) : undefined, iconPosition: "end", isInline: true, rel: sources[page - 1].isExternal ? 'noreferrer' : undefined, target: sources[page - 1].isExternal ? '_blank' : undefined }, renderTitle(sources[page - 1].title))),
|
37
|
-
sources[page - 1].body && (React.createElement(CardBody, { className: `pf-chatbot__sources-card-body
|
41
|
+
sources[page - 1].body && (React.createElement(CardBody, { className: `pf-chatbot__sources-card-body` }, sources[page - 1].hasShowMore ? (
|
42
|
+
// prevents extra VO announcements of button text - parent Message has aria-live
|
43
|
+
React.createElement("div", { "aria-live": "off" },
|
44
|
+
React.createElement(ExpandableSection, { variant: ExpandableSectionVariant.truncate, toggleText: isExpanded ? showLessWords : showMoreWords, onToggle: onToggle, isExpanded: isExpanded, truncateMaxLines: 2 }, sources[page - 1].body))) : (React.createElement("div", { className: "pf-chatbot__sources-card-body-text" }, sources[page - 1].body)))),
|
38
45
|
sources.length > 1 && (React.createElement(CardFooter, { className: "pf-chatbot__sources-card-footer-container" },
|
39
46
|
React.createElement("div", { className: "pf-chatbot__sources-card-footer" },
|
40
47
|
React.createElement("nav", { className: `pf-chatbot__sources-card-footer-buttons ${className}`, "aria-label": paginationAriaLabel },
|
@@ -46,6 +53,10 @@ const SourcesCard = (_a) => {
|
|
46
53
|
React.createElement(Icon, { iconSize: "lg" },
|
47
54
|
React.createElement("svg", { className: "pf-v6-svg", viewBox: "0 0 280 500", fill: "currentColor", "aria-hidden": "true", role: "img", width: "1em", height: "1em" },
|
48
55
|
React.createElement("path", { d: "M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z" })))),
|
56
|
+
React.createElement("span", { "aria-hidden": "true" },
|
57
|
+
page,
|
58
|
+
"/",
|
59
|
+
sources.length),
|
49
60
|
React.createElement(Button, { variant: ButtonVariant.plain, isDisabled: isDisabled || page === sources.length, "aria-label": toNextPageAriaLabel, "data-action": "next", onClick: (event) => {
|
50
61
|
const newPage = page + 1 <= sources.length ? page + 1 : sources.length;
|
51
62
|
onNextClick && onNextClick(event, newPage);
|
@@ -53,12 +64,6 @@ const SourcesCard = (_a) => {
|
|
53
64
|
} },
|
54
65
|
React.createElement(Icon, { isInline: true, iconSize: "lg" },
|
55
66
|
React.createElement("svg", { className: "pf-v6-svg", viewBox: "0 0 180 500", fill: "currentColor", "aria-hidden": "true", role: "img", width: "1em", height: "1em" },
|
56
|
-
React.createElement("path", { d: "M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z" })))))
|
57
|
-
React.createElement("span", { "aria-hidden": "true" },
|
58
|
-
page,
|
59
|
-
" ",
|
60
|
-
ofWord,
|
61
|
-
" ",
|
62
|
-
sources.length)))))));
|
67
|
+
React.createElement("path", { d: "M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z" })))))))))));
|
63
68
|
};
|
64
69
|
export default SourcesCard;
|
@@ -19,7 +19,7 @@ describe('SourcesCard', () => {
|
|
19
19
|
expect(screen.getByText('Source 1')).toBeTruthy();
|
20
20
|
// no buttons or navigation when there is only 1 source
|
21
21
|
expect(screen.queryByRole('button')).toBeFalsy();
|
22
|
-
expect(screen.queryByText('1
|
22
|
+
expect(screen.queryByText('1/1')).toBeFalsy();
|
23
23
|
});
|
24
24
|
it('should render card correctly if one source with a title is passed in', () => {
|
25
25
|
render(React.createElement(SourcesCard, { sources: [{ title: 'How to make an apple pie', link: '' }] }));
|
@@ -44,7 +44,7 @@ describe('SourcesCard', () => {
|
|
44
44
|
] }));
|
45
45
|
expect(screen.getByText('2 sources')).toBeTruthy();
|
46
46
|
expect(screen.getByText('How to make an apple pie')).toBeTruthy();
|
47
|
-
expect(screen.getByText('1
|
47
|
+
expect(screen.getByText('1/2')).toBeTruthy();
|
48
48
|
screen.getByRole('button', { name: /Go to previous page/i });
|
49
49
|
screen.getByRole('button', { name: /Go to next page/i });
|
50
50
|
});
|
@@ -54,12 +54,12 @@ describe('SourcesCard', () => {
|
|
54
54
|
{ title: 'How to make cookies', link: '' }
|
55
55
|
] }));
|
56
56
|
expect(screen.getByText('How to make an apple pie')).toBeTruthy();
|
57
|
-
expect(screen.getByText('1
|
57
|
+
expect(screen.getByText('1/2')).toBeTruthy();
|
58
58
|
expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeDisabled();
|
59
59
|
yield userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
|
60
60
|
expect(screen.queryByText('How to make an apple pie')).toBeFalsy();
|
61
61
|
expect(screen.getByText('How to make cookies')).toBeTruthy();
|
62
|
-
expect(screen.getByText('2
|
62
|
+
expect(screen.getByText('2/2')).toBeTruthy();
|
63
63
|
expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeEnabled();
|
64
64
|
expect(screen.getByRole('button', { name: /Go to next page/i })).toBeDisabled();
|
65
65
|
}));
|
@@ -79,13 +79,6 @@ describe('SourcesCard', () => {
|
|
79
79
|
expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeDisabled();
|
80
80
|
expect(screen.getByRole('button', { name: /Go to next page/i })).toBeDisabled();
|
81
81
|
});
|
82
|
-
it('should change ofWord appropriately', () => {
|
83
|
-
render(React.createElement(SourcesCard, { sources: [
|
84
|
-
{ title: 'How to make an apple pie', link: '' },
|
85
|
-
{ title: 'How to make cookies', link: '' }
|
86
|
-
], ofWord: 'de' }));
|
87
|
-
expect(screen.getByText('1 de 2')).toBeTruthy();
|
88
|
-
});
|
89
82
|
it('should render navigation aria label appropriately', () => {
|
90
83
|
render(React.createElement(SourcesCard, { sources: [
|
91
84
|
{ title: 'How to make an apple pie', link: '' },
|
@@ -155,4 +148,25 @@ describe('SourcesCard', () => {
|
|
155
148
|
yield userEvent.click(screen.getByRole('button', { name: /Go to previous page/i }));
|
156
149
|
expect(spy).toHaveBeenCalledTimes(2);
|
157
150
|
}));
|
151
|
+
it('should handle showMore appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
|
152
|
+
render(React.createElement(SourcesCard, { sources: [
|
153
|
+
{
|
154
|
+
title: 'Getting started with Red Hat OpenShift',
|
155
|
+
link: '#',
|
156
|
+
body: 'Red Hat OpenShift on IBM Cloud is a managed offering to create your own cluster of compute hosts where you can deploy and manage containerized apps on IBM Cloud ...',
|
157
|
+
hasShowMore: true
|
158
|
+
},
|
159
|
+
{
|
160
|
+
title: 'Azure Red Hat OpenShift documentation',
|
161
|
+
link: '#',
|
162
|
+
body: 'Microsoft Azure Red Hat OpenShift allows you to deploy a production ready Red Hat OpenShift cluster in Azure ...'
|
163
|
+
},
|
164
|
+
{
|
165
|
+
title: 'OKD Documentation: Home',
|
166
|
+
link: '#',
|
167
|
+
body: 'OKD is a distribution of Kubernetes optimized for continuous application development and multi-tenant deployment. OKD also serves as the upstream code base upon ...'
|
168
|
+
}
|
169
|
+
] }));
|
170
|
+
expect(screen.getByRole('region')).toHaveAttribute('class', 'pf-v6-c-expandable-section__content');
|
171
|
+
}));
|
158
172
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"root":["../src/index.ts","../src/AttachMenu/AttachMenu.tsx","../src/AttachMenu/index.ts","../src/AttachmentEdit/AttachmentEdit.test.tsx","../src/AttachmentEdit/AttachmentEdit.tsx","../src/AttachmentEdit/index.ts","../src/Chatbot/Chatbot.test.tsx","../src/Chatbot/Chatbot.tsx","../src/Chatbot/index.ts","../src/ChatbotAlert/ChatbotAlert.test.tsx","../src/ChatbotAlert/ChatbotAlert.tsx","../src/ChatbotAlert/index.ts","../src/ChatbotContent/ChatbotContent.test.tsx","../src/ChatbotContent/ChatbotContent.tsx","../src/ChatbotContent/index.ts","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx","../src/ChatbotConversationHistoryNav/EmptyState.tsx","../src/ChatbotConversationHistoryNav/LoadingState.tsx","../src/ChatbotConversationHistoryNav/index.ts","../src/ChatbotFooter/ChatbotFooter.test.tsx","../src/ChatbotFooter/ChatbotFooter.tsx","../src/ChatbotFooter/ChatbotFooternote.test.tsx","../src/ChatbotFooter/ChatbotFootnote.tsx","../src/ChatbotFooter/index.ts","../src/ChatbotHeader/ChatbotHeader.test.tsx","../src/ChatbotHeader/ChatbotHeader.tsx","../src/ChatbotHeader/ChatbotHeaderActions.test.tsx","../src/ChatbotHeader/ChatbotHeaderActions.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.tsx","../src/ChatbotHeader/ChatbotHeaderMain.test.tsx","../src/ChatbotHeader/ChatbotHeaderMain.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.test.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.test.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.tsx","../src/ChatbotHeader/index.ts","../src/ChatbotModal/ChatbotModal.tsx","../src/ChatbotModal/index.ts","../src/ChatbotPopover/ChatbotPopover.tsx","../src/ChatbotPopover/index.ts","../src/ChatbotToggle/ChatbotToggle.test.tsx","../src/ChatbotToggle/ChatbotToggle.tsx","../src/ChatbotToggle/index.ts","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx","../src/ChatbotWelcomePrompt/index.ts","../src/CodeModal/CodeModal.tsx","../src/CodeModal/index.ts","../src/Compare/Compare.test.tsx","../src/Compare/Compare.tsx","../src/Compare/index.ts","../src/FileDetails/FileDetails.test.tsx","../src/FileDetails/FileDetails.tsx","../src/FileDetails/index.ts","../src/FileDetailsLabel/FileDetailsLabel.test.tsx","../src/FileDetailsLabel/FileDetailsLabel.tsx","../src/FileDetailsLabel/index.ts","../src/FileDropZone/FileDropZone.test.tsx","../src/FileDropZone/FileDropZone.tsx","../src/FileDropZone/index.ts","../src/LoadingMessage/LoadingMessage.test.tsx","../src/LoadingMessage/LoadingMessage.tsx","../src/LoadingMessage/index.ts","../src/Message/Message.test.tsx","../src/Message/Message.tsx","../src/Message/MessageLoading.tsx","../src/Message/index.ts","../src/Message/CodeBlockMessage/CodeBlockMessage.tsx","../src/Message/ErrorMessage/ErrorMessage.tsx","../src/Message/ImageMessage/ImageMessage.tsx","../src/Message/LinkMessage/LinkMessage.tsx","../src/Message/ListMessage/ListItemMessage.tsx","../src/Message/ListMessage/OrderedListMessage.tsx","../src/Message/ListMessage/UnorderedListMessage.tsx","../src/Message/QuickResponse/QuickResponse.tsx","../src/Message/QuickStarts/FallbackImg.tsx","../src/Message/QuickStarts/QuickStartTile.tsx","../src/Message/QuickStarts/QuickStartTileDescription.test.tsx","../src/Message/QuickStarts/QuickStartTileDescription.tsx","../src/Message/QuickStarts/QuickStartTileHeader.tsx","../src/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.ts","../src/Message/QuickStarts/monitor-sampleapp-quickstart.ts","../src/Message/QuickStarts/types.ts","../src/Message/TableMessage/TableMessage.tsx","../src/Message/TableMessage/TbodyMessage.tsx","../src/Message/TableMessage/TdMessage.tsx","../src/Message/TableMessage/ThMessage.tsx","../src/Message/TableMessage/TheadMessage.tsx","../src/Message/TableMessage/TrMessage.tsx","../src/Message/TextMessage/TextMessage.tsx","../src/Message/UserFeedback/CloseButton.tsx","../src/Message/UserFeedback/UserFeedback.test.tsx","../src/Message/UserFeedback/UserFeedback.tsx","../src/Message/UserFeedback/UserFeedbackComplete.test.tsx","../src/Message/UserFeedback/UserFeedbackComplete.tsx","../src/MessageBar/AttachButton.test.tsx","../src/MessageBar/AttachButton.tsx","../src/MessageBar/MessageBar.test.tsx","../src/MessageBar/MessageBar.tsx","../src/MessageBar/MicrophoneButton.tsx","../src/MessageBar/SendButton.test.tsx","../src/MessageBar/SendButton.tsx","../src/MessageBar/StopButton.test.tsx","../src/MessageBar/StopButton.tsx","../src/MessageBar/index.ts","../src/MessageBox/JumpButton.test.tsx","../src/MessageBox/JumpButton.tsx","../src/MessageBox/MessageBox.test.tsx","../src/MessageBox/MessageBox.tsx","../src/MessageBox/index.ts","../src/PreviewAttachment/PreviewAttachment.test.tsx","../src/PreviewAttachment/PreviewAttachment.tsx","../src/PreviewAttachment/index.ts","../src/ResponseActions/ResponseActionButton.test.tsx","../src/ResponseActions/ResponseActionButton.tsx","../src/ResponseActions/ResponseActions.test.tsx","../src/ResponseActions/ResponseActions.tsx","../src/ResponseActions/index.ts","../src/Settings/SettingsForm.test.tsx","../src/Settings/SettingsForm.tsx","../src/Settings/index.ts","../src/SourceDetailsMenuItem/SourceDetailsMenuItem.tsx","../src/SourceDetailsMenuItem/index.ts","../src/SourcesCard/SourcesCard.test.tsx","../src/SourcesCard/SourcesCard.tsx","../src/SourcesCard/index.ts","../src/TermsOfUse/TermsOfUse.test.tsx","../src/TermsOfUse/TermsOfUse.tsx","../src/TermsOfUse/index.ts","../src/__mocks__/rehype-external-links.ts","../src/__mocks__/rehype-sanitize.ts","../src/__mocks__/rehype-unwrap-images.tsx","../src/tracking/console_tracking_provider.ts","../src/tracking/index.ts","../src/tracking/posthog_tracking_provider.ts","../src/tracking/segment_tracking_provider.ts","../src/tracking/trackingProviderProxy.ts","../src/tracking/tracking_api.ts","../src/tracking/tracking_registry.ts","../src/tracking/tracking_spi.ts","../src/tracking/umami_tracking_provider.ts"],"version":"5.6.3"}
|
1
|
+
{"root":["../src/index.ts","../src/AttachMenu/AttachMenu.tsx","../src/AttachMenu/index.ts","../src/AttachmentEdit/AttachmentEdit.test.tsx","../src/AttachmentEdit/AttachmentEdit.tsx","../src/AttachmentEdit/index.ts","../src/Chatbot/Chatbot.test.tsx","../src/Chatbot/Chatbot.tsx","../src/Chatbot/index.ts","../src/ChatbotAlert/ChatbotAlert.test.tsx","../src/ChatbotAlert/ChatbotAlert.tsx","../src/ChatbotAlert/index.ts","../src/ChatbotContent/ChatbotContent.test.tsx","../src/ChatbotContent/ChatbotContent.tsx","../src/ChatbotContent/index.ts","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx","../src/ChatbotConversationHistoryNav/EmptyState.tsx","../src/ChatbotConversationHistoryNav/LoadingState.tsx","../src/ChatbotConversationHistoryNav/index.ts","../src/ChatbotFooter/ChatbotFooter.test.tsx","../src/ChatbotFooter/ChatbotFooter.tsx","../src/ChatbotFooter/ChatbotFooternote.test.tsx","../src/ChatbotFooter/ChatbotFootnote.tsx","../src/ChatbotFooter/index.ts","../src/ChatbotHeader/ChatbotHeader.test.tsx","../src/ChatbotHeader/ChatbotHeader.tsx","../src/ChatbotHeader/ChatbotHeaderActions.test.tsx","../src/ChatbotHeader/ChatbotHeaderActions.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.tsx","../src/ChatbotHeader/ChatbotHeaderMain.test.tsx","../src/ChatbotHeader/ChatbotHeaderMain.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.test.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.test.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.tsx","../src/ChatbotHeader/index.ts","../src/ChatbotModal/ChatbotModal.tsx","../src/ChatbotModal/index.ts","../src/ChatbotPopover/ChatbotPopover.tsx","../src/ChatbotPopover/index.ts","../src/ChatbotToggle/ChatbotToggle.test.tsx","../src/ChatbotToggle/ChatbotToggle.tsx","../src/ChatbotToggle/index.ts","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx","../src/ChatbotWelcomePrompt/index.ts","../src/CodeModal/CodeModal.tsx","../src/CodeModal/index.ts","../src/Compare/Compare.test.tsx","../src/Compare/Compare.tsx","../src/Compare/index.ts","../src/FileDetails/FileDetails.test.tsx","../src/FileDetails/FileDetails.tsx","../src/FileDetails/index.ts","../src/FileDetailsLabel/FileDetailsLabel.test.tsx","../src/FileDetailsLabel/FileDetailsLabel.tsx","../src/FileDetailsLabel/index.ts","../src/FileDropZone/FileDropZone.test.tsx","../src/FileDropZone/FileDropZone.tsx","../src/FileDropZone/index.ts","../src/LoadingMessage/LoadingMessage.test.tsx","../src/LoadingMessage/LoadingMessage.tsx","../src/LoadingMessage/index.ts","../src/Message/Message.test.tsx","../src/Message/Message.tsx","../src/Message/MessageInput.tsx","../src/Message/MessageLoading.tsx","../src/Message/index.ts","../src/Message/CodeBlockMessage/CodeBlockMessage.tsx","../src/Message/ErrorMessage/ErrorMessage.tsx","../src/Message/ImageMessage/ImageMessage.tsx","../src/Message/LinkMessage/LinkMessage.tsx","../src/Message/ListMessage/ListItemMessage.tsx","../src/Message/ListMessage/OrderedListMessage.tsx","../src/Message/ListMessage/UnorderedListMessage.tsx","../src/Message/QuickResponse/QuickResponse.tsx","../src/Message/QuickStarts/FallbackImg.tsx","../src/Message/QuickStarts/QuickStartTile.tsx","../src/Message/QuickStarts/QuickStartTileDescription.test.tsx","../src/Message/QuickStarts/QuickStartTileDescription.tsx","../src/Message/QuickStarts/QuickStartTileHeader.tsx","../src/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.ts","../src/Message/QuickStarts/monitor-sampleapp-quickstart.ts","../src/Message/QuickStarts/types.ts","../src/Message/TableMessage/TableMessage.tsx","../src/Message/TableMessage/TbodyMessage.tsx","../src/Message/TableMessage/TdMessage.tsx","../src/Message/TableMessage/ThMessage.tsx","../src/Message/TableMessage/TheadMessage.tsx","../src/Message/TableMessage/TrMessage.tsx","../src/Message/TextMessage/TextMessage.tsx","../src/Message/UserFeedback/CloseButton.tsx","../src/Message/UserFeedback/UserFeedback.test.tsx","../src/Message/UserFeedback/UserFeedback.tsx","../src/Message/UserFeedback/UserFeedbackComplete.test.tsx","../src/Message/UserFeedback/UserFeedbackComplete.tsx","../src/MessageBar/AttachButton.test.tsx","../src/MessageBar/AttachButton.tsx","../src/MessageBar/MessageBar.test.tsx","../src/MessageBar/MessageBar.tsx","../src/MessageBar/MicrophoneButton.tsx","../src/MessageBar/SendButton.test.tsx","../src/MessageBar/SendButton.tsx","../src/MessageBar/StopButton.test.tsx","../src/MessageBar/StopButton.tsx","../src/MessageBar/index.ts","../src/MessageBox/JumpButton.test.tsx","../src/MessageBox/JumpButton.tsx","../src/MessageBox/MessageBox.test.tsx","../src/MessageBox/MessageBox.tsx","../src/MessageBox/index.ts","../src/PreviewAttachment/PreviewAttachment.test.tsx","../src/PreviewAttachment/PreviewAttachment.tsx","../src/PreviewAttachment/index.ts","../src/ResponseActions/ResponseActionButton.test.tsx","../src/ResponseActions/ResponseActionButton.tsx","../src/ResponseActions/ResponseActions.test.tsx","../src/ResponseActions/ResponseActions.tsx","../src/ResponseActions/index.ts","../src/Settings/SettingsForm.test.tsx","../src/Settings/SettingsForm.tsx","../src/Settings/index.ts","../src/SourceDetailsMenuItem/SourceDetailsMenuItem.tsx","../src/SourceDetailsMenuItem/index.ts","../src/SourcesCard/SourcesCard.test.tsx","../src/SourcesCard/SourcesCard.tsx","../src/SourcesCard/index.ts","../src/TermsOfUse/TermsOfUse.test.tsx","../src/TermsOfUse/TermsOfUse.tsx","../src/TermsOfUse/index.ts","../src/__mocks__/rehype-external-links.ts","../src/__mocks__/rehype-sanitize.ts","../src/__mocks__/rehype-unwrap-images.tsx","../src/tracking/console_tracking_provider.ts","../src/tracking/index.ts","../src/tracking/posthog_tracking_provider.ts","../src/tracking/segment_tracking_provider.ts","../src/tracking/trackingProviderProxy.ts","../src/tracking/tracking_api.ts","../src/tracking/tracking_registry.ts","../src/tracking/tracking_spi.ts","../src/tracking/umami_tracking_provider.ts"],"version":"5.6.3"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@patternfly/chatbot",
|
3
|
-
"version": "2.2.0-prerelease.
|
3
|
+
"version": "2.2.0-prerelease.46",
|
4
4
|
"description": "This library provides React components based on PatternFly 6 that can be used to build chatbots.",
|
5
5
|
"main": "dist/cjs/index.js",
|
6
6
|
"module": "dist/esm/index.js",
|
@@ -14,7 +14,7 @@ export const MessageWithSourcesExample: React.FunctionComponent = () => {
|
|
14
14
|
name="Bot"
|
15
15
|
role="bot"
|
16
16
|
avatar={patternflyAvatar}
|
17
|
-
content="
|
17
|
+
content="This example has a body description that's within the recommended limit of 2 lines:"
|
18
18
|
sources={{
|
19
19
|
sources: [
|
20
20
|
{
|
@@ -43,7 +43,36 @@ export const MessageWithSourcesExample: React.FunctionComponent = () => {
|
|
43
43
|
name="Bot"
|
44
44
|
role="bot"
|
45
45
|
avatar={patternflyAvatar}
|
46
|
-
content="
|
46
|
+
content="This example has a body description that's longer than the recommended limit of 2 lines, with a link to load the rest of the description:"
|
47
|
+
sources={{
|
48
|
+
sources: [
|
49
|
+
{
|
50
|
+
title: 'Getting started with Red Hat OpenShift',
|
51
|
+
link: '#',
|
52
|
+
body: 'Red Hat OpenShift on IBM Cloud is a managed offering to create your own cluster of compute hosts where you can deploy and manage containerized apps on IBM Cloud.',
|
53
|
+
hasShowMore: true
|
54
|
+
},
|
55
|
+
{
|
56
|
+
title: 'Azure Red Hat OpenShift documentation',
|
57
|
+
link: '#',
|
58
|
+
body: 'Microsoft Azure Red Hat OpenShift allows you to deploy a production ready Red Hat OpenShift cluster in Azure.',
|
59
|
+
hasShowMore: true
|
60
|
+
},
|
61
|
+
{
|
62
|
+
title: 'OKD Documentation: Home',
|
63
|
+
link: '#',
|
64
|
+
body: 'OKD is a distribution of Kubernetes optimized for continuous application development and multi-tenant deployment. OKD also serves as the upstream code base upon.',
|
65
|
+
hasShowMore: true
|
66
|
+
}
|
67
|
+
],
|
68
|
+
onSetPage
|
69
|
+
}}
|
70
|
+
/>
|
71
|
+
<Message
|
72
|
+
name="Bot"
|
73
|
+
role="bot"
|
74
|
+
avatar={patternflyAvatar}
|
75
|
+
content="This example has a truncated title:"
|
47
76
|
sources={{
|
48
77
|
sources: [
|
49
78
|
{
|
@@ -66,7 +95,7 @@ export const MessageWithSourcesExample: React.FunctionComponent = () => {
|
|
66
95
|
name="Bot"
|
67
96
|
role="bot"
|
68
97
|
avatar={patternflyAvatar}
|
69
|
-
content="
|
98
|
+
content="This example only includes 1 source:"
|
70
99
|
sources={{
|
71
100
|
sources: [
|
72
101
|
{
|
@@ -83,7 +112,7 @@ export const MessageWithSourcesExample: React.FunctionComponent = () => {
|
|
83
112
|
name="Bot"
|
84
113
|
role="bot"
|
85
114
|
avatar={patternflyAvatar}
|
86
|
-
content="
|
115
|
+
content="This example has a title and no body description:"
|
87
116
|
sources={{
|
88
117
|
sources: [
|
89
118
|
{ title: 'Getting started with Red Hat OpenShift', link: '#', isExternal: true },
|
@@ -105,7 +134,7 @@ export const MessageWithSourcesExample: React.FunctionComponent = () => {
|
|
105
134
|
name="Bot"
|
106
135
|
role="bot"
|
107
136
|
avatar={patternflyAvatar}
|
108
|
-
content="
|
137
|
+
content="This example displays the source as a link, without a title (not recommended)"
|
109
138
|
sources={{
|
110
139
|
sources: [
|
111
140
|
{
|
@@ -144,7 +144,7 @@ If you are using Retrieval-Augmented Generation, you may want to display sources
|
|
144
144
|
|
145
145
|
If a source will open outside of the ChatBot window, add an external link icon via `isExternal`.
|
146
146
|
|
147
|
-
The API for a source requires a link at minimum, but we strongly recommend providing a more descriptive title and body description so users have enough context.
|
147
|
+
The API for a source requires a link at minimum, but we strongly recommend providing a more descriptive title and body description so users have enough context. For the best clarity and readability, we strongly recommend limiting the title to 1 line and the body to 2 lines. If the body description is more than 2 lines, use the "long sources" or "very long sources" variant.
|
148
148
|
|
149
149
|
```js file="./MessageWithSources.tsx"
|
150
150
|
|