@patternfly/chatbot 6.8.0-prerelease.3 → 6.8.0-prerelease.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +2 -5
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +3 -3
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.js +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.js +2 -5
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.js +2 -2
- package/dist/cjs/FileDropZone/FileDropZone.js +1 -1
- package/dist/cjs/MarkdownContent/MarkdownContent.js +15 -1
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +2 -2
- package/dist/cjs/Message/LinkMessage/LinkMessage.js +5 -1
- package/dist/cjs/Message/Message.test.js +1 -18
- package/dist/cjs/Message/QuickStarts/QuickStartTileDescription.js +2 -5
- package/dist/cjs/MessageBar/MessageBar.test.js +1 -1
- package/dist/cjs/MessageBox/JumpButton.test.js +2 -2
- package/dist/cjs/MessageBox/MessageBox.js +79 -28
- package/dist/cjs/MessageBox/MessageBox.test.d.ts +1 -1
- package/dist/cjs/MessageBox/MessageBox.test.js +59 -0
- package/dist/cjs/ResponseActions/ResponseActionButton.test.js +6 -6
- package/dist/cjs/ResponseActions/ResponseActions.test.js +6 -7
- package/dist/cjs/SourcesCardBase/SourcesCardBase.js +5 -5
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/index.js +1 -4
- package/dist/css/main.css +0 -13
- package/dist/css/main.css.map +1 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +2 -2
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +4 -4
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.js +2 -2
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +2 -2
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.js +2 -2
- package/dist/esm/FileDropZone/FileDropZone.js +2 -2
- package/dist/esm/MarkdownContent/MarkdownContent.js +15 -1
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +2 -2
- package/dist/esm/Message/LinkMessage/LinkMessage.js +6 -2
- package/dist/esm/Message/Message.test.js +1 -18
- package/dist/esm/Message/QuickStarts/QuickStartTileDescription.js +2 -2
- package/dist/esm/MessageBar/MessageBar.test.js +2 -2
- package/dist/esm/MessageBox/JumpButton.test.js +2 -2
- package/dist/esm/MessageBox/MessageBox.js +80 -29
- package/dist/esm/MessageBox/MessageBox.test.d.ts +1 -1
- package/dist/esm/MessageBox/MessageBox.test.js +59 -0
- package/dist/esm/ResponseActions/ResponseActionButton.test.js +7 -7
- package/dist/esm/ResponseActions/ResponseActions.test.js +7 -8
- package/dist/esm/SourcesCardBase/SourcesCardBase.js +7 -7
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.js +0 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithCustomResponseActions.tsx +3 -4
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithMarkdownToolResponse.tsx +3 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx +3 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +3 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithToolResponse.tsx +5 -5
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessageWithExtraContent.tsx +7 -31
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderBasic.tsx +4 -6
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +3 -3
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerResizable.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithPin.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithSearchActions.tsx +3 -3
- package/patternfly-docs/content/extensions/chatbot/examples/UI/CompactSettings.tsx +10 -5
- package/patternfly-docs/content/extensions/chatbot/examples/UI/Settings.tsx +10 -5
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +1 -15
- package/patternfly-docs/content/extensions/chatbot/examples/demos/AttachmentDemos.md +2 -4
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +2 -5
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.tsx +4 -7
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachment.tsx +4 -6
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachmentMenu.tsx +13 -7
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotCompact.tsx +4 -7
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotDisplayMode.tsx +10 -8
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotInDrawer.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotScrolling.tsx +4 -8
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotTranscripts.tsx +4 -7
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedChatbot.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedComparisonChatbot.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/demos/WhiteEmbeddedChatbot.tsx +2 -2
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx +2 -3
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +4 -4
- package/src/ChatbotHeader/ChatbotHeaderCloseButton.tsx +2 -2
- package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +2 -2
- package/src/ChatbotHeader/ChatbotHeaderNewChatButton.tsx +2 -3
- package/src/FileDropZone/FileDropZone.tsx +2 -2
- package/src/MarkdownContent/MarkdownContent.tsx +14 -0
- package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +2 -2
- package/src/Message/LinkMessage/LinkMessage.tsx +21 -2
- package/src/Message/Message.test.tsx +4 -4
- package/src/Message/QuickStarts/QuickStartTileDescription.tsx +2 -2
- package/src/MessageBar/MessageBar.test.tsx +6 -6
- package/src/MessageBox/JumpButton.test.tsx +1 -1
- package/src/MessageBox/MessageBox.test.tsx +91 -0
- package/src/MessageBox/MessageBox.tsx +137 -40
- package/src/ResponseActions/ResponseActionButton.test.tsx +7 -7
- package/src/ResponseActions/ResponseActions.test.tsx +7 -8
- package/src/SourcesCard/SourcesCard.scss +0 -13
- package/src/SourcesCardBase/SourcesCardBase.tsx +7 -32
- package/dist/cjs/LoadingMessage/LoadingMessage.d.ts +0 -6
- package/dist/cjs/LoadingMessage/LoadingMessage.js +0 -12
- package/dist/cjs/LoadingMessage/LoadingMessage.test.d.ts +0 -1
- package/dist/cjs/LoadingMessage/LoadingMessage.test.js +0 -20
- package/dist/cjs/LoadingMessage/index.d.ts +0 -2
- package/dist/cjs/LoadingMessage/index.js +0 -23
- package/dist/dynamic/LoadingMessage/package.json +0 -1
- package/dist/esm/LoadingMessage/LoadingMessage.d.ts +0 -6
- package/dist/esm/LoadingMessage/LoadingMessage.js +0 -5
- package/dist/esm/LoadingMessage/LoadingMessage.test.d.ts +0 -1
- package/dist/esm/LoadingMessage/LoadingMessage.test.js +0 -15
- package/dist/esm/LoadingMessage/index.d.ts +0 -2
- package/dist/esm/LoadingMessage/index.js +0 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachMenu.tsx +0 -149
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/PaperclipIcon.svg +0 -10
- package/src/LoadingMessage/LoadingMessage.test.tsx +0 -15
- package/src/LoadingMessage/LoadingMessage.tsx +0 -27
- package/src/LoadingMessage/__snapshots__/LoadingMessage.test.tsx.snap +0 -64
- package/src/LoadingMessage/index.ts +0 -3
|
@@ -13,50 +13,79 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
13
13
|
// ============================================================================
|
|
14
14
|
// Chatbot Main - Messages
|
|
15
15
|
// ============================================================================
|
|
16
|
-
import { useState, useRef, useCallback,
|
|
16
|
+
import { useState, useRef, useCallback, useLayoutEffect, forwardRef, useImperativeHandle } from 'react';
|
|
17
17
|
import JumpButton from './JumpButton';
|
|
18
|
+
import { getResizeObserver } from '@patternfly/react-core';
|
|
19
|
+
const SCROLL_EDGE_DELTA = 100;
|
|
20
|
+
const getScrollMetrics = (element) => {
|
|
21
|
+
const { scrollTop, scrollHeight, clientHeight } = element;
|
|
22
|
+
const roundedScrollTop = Math.round(scrollTop);
|
|
23
|
+
const roundedClientHeight = Math.round(clientHeight);
|
|
24
|
+
const roundedScrollHeight = Math.round(scrollHeight);
|
|
25
|
+
const distanceFromBottom = roundedScrollHeight - roundedScrollTop - roundedClientHeight;
|
|
26
|
+
return {
|
|
27
|
+
roundedScrollTop,
|
|
28
|
+
roundedClientHeight,
|
|
29
|
+
roundedScrollHeight,
|
|
30
|
+
distanceFromBottom,
|
|
31
|
+
atTop: roundedScrollTop === 0,
|
|
32
|
+
nearBottom: distanceFromBottom <= SCROLL_EDGE_DELTA,
|
|
33
|
+
isOverflowing: roundedScrollHeight >= roundedClientHeight
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const isAtBottomEdge = (metrics, enableSmartScroll, autoScroll, pauseAutoScroll, programmaticScroll = false) => metrics.nearBottom ||
|
|
37
|
+
programmaticScroll ||
|
|
38
|
+
(enableSmartScroll && autoScroll && !pauseAutoScroll && metrics.roundedScrollTop > 0);
|
|
39
|
+
const shouldFollowContentGrowth = (metrics, enableSmartScroll, autoScroll, pauseAutoScroll, programmaticScroll) => programmaticScroll ||
|
|
40
|
+
metrics.nearBottom ||
|
|
41
|
+
(enableSmartScroll && autoScroll && !pauseAutoScroll && metrics.roundedScrollTop > 0);
|
|
18
42
|
export const MessageBox = forwardRef((_a, ref) => {
|
|
19
43
|
var { announcement, ariaLabel = 'Scrollable message log', children, className, position = 'top', onScrollToTopClick, onScrollToBottomClick, enableSmartScroll = false, jumpButtonTopProps, jumpButtonBottomProps, jumpButtonBottomTooltipProps, jumpButtonTopTooltipProps } = _a, props = __rest(_a, ["announcement", "ariaLabel", "children", "className", "position", "onScrollToTopClick", "onScrollToBottomClick", "enableSmartScroll", "jumpButtonTopProps", "jumpButtonBottomProps", "jumpButtonBottomTooltipProps", "jumpButtonTopTooltipProps"]);
|
|
20
|
-
const [atTop, setAtTop] = useState(
|
|
21
|
-
const [atBottom, setAtBottom] = useState(
|
|
44
|
+
const [atTop, setAtTop] = useState(true);
|
|
45
|
+
const [atBottom, setAtBottom] = useState(false);
|
|
22
46
|
const [isOverflowing, setIsOverflowing] = useState(false);
|
|
47
|
+
const [hasMeasuredScroll, setHasMeasuredScroll] = useState(false);
|
|
23
48
|
const [autoScroll, setAutoScroll] = useState(true);
|
|
49
|
+
const autoScrollRef = useRef(autoScroll);
|
|
24
50
|
const lastScrollTop = useRef(0);
|
|
25
51
|
const animationFrame = useRef(null);
|
|
26
52
|
const debounceTimeout = useRef(null);
|
|
27
53
|
const pauseAutoScrollRef = useRef(false);
|
|
54
|
+
const programmaticScrollRef = useRef(false);
|
|
28
55
|
const messageBoxRef = useRef(null);
|
|
29
56
|
const scrollQueued = useRef(false);
|
|
30
57
|
const resetUserScrollIntentTimeout = useRef();
|
|
58
|
+
autoScrollRef.current = autoScroll;
|
|
31
59
|
// Configure handlers
|
|
32
60
|
const handleScroll = useCallback(() => {
|
|
33
61
|
const element = messageBoxRef.current;
|
|
34
62
|
if (!element) {
|
|
35
63
|
return;
|
|
36
64
|
}
|
|
37
|
-
const
|
|
38
|
-
const roundedScrollTop =
|
|
39
|
-
const roundedClientHeight = Math.round(clientHeight);
|
|
40
|
-
const roundedScrollHeight = Math.round(scrollHeight);
|
|
41
|
-
const distanceFromBottom = roundedScrollHeight - roundedScrollTop - roundedClientHeight;
|
|
65
|
+
const metrics = getScrollMetrics(element);
|
|
66
|
+
const { roundedScrollTop, distanceFromBottom } = metrics;
|
|
42
67
|
const isScrollingDown = roundedScrollTop > lastScrollTop.current;
|
|
43
68
|
const DELTA_UP = 10;
|
|
44
69
|
const DELTA_DOWN = 50;
|
|
45
70
|
const DEBOUNCE_DELAY = 200;
|
|
46
71
|
const delta = isScrollingDown ? DELTA_DOWN : DELTA_UP;
|
|
47
72
|
const isAtBottom = distanceFromBottom <= delta;
|
|
48
|
-
setAtTop(
|
|
49
|
-
setAtBottom(
|
|
73
|
+
setAtTop(metrics.atTop);
|
|
74
|
+
setAtBottom(isAtBottomEdge(metrics, enableSmartScroll, autoScrollRef.current, pauseAutoScrollRef.current, programmaticScrollRef.current));
|
|
75
|
+
setIsOverflowing(metrics.isOverflowing);
|
|
76
|
+
if (isAtBottom) {
|
|
77
|
+
programmaticScrollRef.current = false;
|
|
78
|
+
}
|
|
50
79
|
if (!enableSmartScroll || scrollQueued.current) {
|
|
51
80
|
return;
|
|
52
81
|
}
|
|
53
|
-
if (roundedScrollTop === 0) {
|
|
82
|
+
if (metrics.roundedScrollTop === 0) {
|
|
54
83
|
pauseAutoScrollRef.current = false;
|
|
55
84
|
}
|
|
56
85
|
if (debounceTimeout.current) {
|
|
57
86
|
clearTimeout(debounceTimeout.current);
|
|
58
87
|
}
|
|
59
|
-
if (!isAtBottom && !pauseAutoScrollRef.current) {
|
|
88
|
+
if (!isAtBottom && !metrics.nearBottom && !pauseAutoScrollRef.current && !programmaticScrollRef.current) {
|
|
60
89
|
setAutoScroll(false);
|
|
61
90
|
}
|
|
62
91
|
// User is near bottom and scrolling down - debounce re-enabling auto-scroll
|
|
@@ -66,14 +95,7 @@ export const MessageBox = forwardRef((_a, ref) => {
|
|
|
66
95
|
}, DEBOUNCE_DELAY);
|
|
67
96
|
}
|
|
68
97
|
lastScrollTop.current = roundedScrollTop;
|
|
69
|
-
}, [
|
|
70
|
-
const checkOverflow = useCallback(() => {
|
|
71
|
-
const element = messageBoxRef.current;
|
|
72
|
-
if (element) {
|
|
73
|
-
const { scrollHeight, clientHeight } = element;
|
|
74
|
-
setIsOverflowing(scrollHeight >= clientHeight);
|
|
75
|
-
}
|
|
76
|
-
}, [messageBoxRef]);
|
|
98
|
+
}, [enableSmartScroll]);
|
|
77
99
|
const resumeAutoScroll = useCallback(() => {
|
|
78
100
|
if (!enableSmartScroll) {
|
|
79
101
|
return;
|
|
@@ -125,6 +147,7 @@ export const MessageBox = forwardRef((_a, ref) => {
|
|
|
125
147
|
return;
|
|
126
148
|
}
|
|
127
149
|
scrollQueued.current = true;
|
|
150
|
+
programmaticScrollRef.current = true;
|
|
128
151
|
if (animationFrame.current) {
|
|
129
152
|
cancelAnimationFrame(animationFrame.current);
|
|
130
153
|
}
|
|
@@ -132,24 +155,51 @@ export const MessageBox = forwardRef((_a, ref) => {
|
|
|
132
155
|
element.scrollTo({ top: element.scrollHeight, behavior });
|
|
133
156
|
resumeAutoScroll();
|
|
134
157
|
scrollQueued.current = false;
|
|
158
|
+
if (behavior === 'auto') {
|
|
159
|
+
programmaticScrollRef.current = false;
|
|
160
|
+
lastScrollTop.current = element.scrollTop;
|
|
161
|
+
}
|
|
135
162
|
});
|
|
136
163
|
onScrollToBottomClick && onScrollToBottomClick();
|
|
137
164
|
}, [messageBoxRef, enableSmartScroll]);
|
|
138
|
-
|
|
139
|
-
|
|
165
|
+
const measureJumpButtonState = useCallback(() => {
|
|
166
|
+
const element = messageBoxRef.current;
|
|
167
|
+
if (!element) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const metrics = getScrollMetrics(element);
|
|
171
|
+
setAtTop(metrics.atTop);
|
|
172
|
+
setAtBottom(isAtBottomEdge(metrics, enableSmartScroll, autoScrollRef.current, pauseAutoScrollRef.current, programmaticScrollRef.current));
|
|
173
|
+
setIsOverflowing(metrics.isOverflowing);
|
|
174
|
+
setHasMeasuredScroll(true);
|
|
175
|
+
}, [enableSmartScroll]);
|
|
176
|
+
const handleContentResize = useCallback(() => {
|
|
177
|
+
const element = messageBoxRef.current;
|
|
178
|
+
if (element) {
|
|
179
|
+
const metrics = getScrollMetrics(element);
|
|
180
|
+
const shouldFollow = shouldFollowContentGrowth(metrics, enableSmartScroll, autoScrollRef.current, pauseAutoScrollRef.current, programmaticScrollRef.current);
|
|
181
|
+
if (shouldFollow && !scrollQueued.current) {
|
|
182
|
+
programmaticScrollRef.current = true;
|
|
183
|
+
element.scrollTop = element.scrollHeight - element.clientHeight;
|
|
184
|
+
lastScrollTop.current = element.scrollTop;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
measureJumpButtonState();
|
|
188
|
+
}, [enableSmartScroll, measureJumpButtonState]);
|
|
189
|
+
// Detect scroll position before paint to avoid jump button flash on mount
|
|
190
|
+
useLayoutEffect(() => {
|
|
140
191
|
const element = messageBoxRef.current;
|
|
141
192
|
if (!element) {
|
|
142
193
|
return;
|
|
143
194
|
}
|
|
144
|
-
|
|
195
|
+
measureJumpButtonState();
|
|
145
196
|
element.addEventListener('scroll', handleScroll);
|
|
146
|
-
|
|
147
|
-
handleScroll();
|
|
148
|
-
checkOverflow();
|
|
197
|
+
const resizeObserver = getResizeObserver(element, handleContentResize);
|
|
149
198
|
return () => {
|
|
150
199
|
element.removeEventListener('scroll', handleScroll);
|
|
200
|
+
resizeObserver();
|
|
151
201
|
};
|
|
152
|
-
}, [
|
|
202
|
+
}, [handleContentResize, handleScroll, measureJumpButtonState]);
|
|
153
203
|
useImperativeHandle(ref, () => {
|
|
154
204
|
const node = messageBoxRef.current;
|
|
155
205
|
// Attach custom methods to the element
|
|
@@ -170,12 +220,13 @@ export const MessageBox = forwardRef((_a, ref) => {
|
|
|
170
220
|
}
|
|
171
221
|
if (!isScrollingDown) {
|
|
172
222
|
pauseAutoScrollRef.current = true;
|
|
223
|
+
programmaticScrollRef.current = false;
|
|
173
224
|
clearTimeout(resetUserScrollIntentTimeout.current);
|
|
174
225
|
return;
|
|
175
226
|
}
|
|
176
227
|
const { scrollTop, scrollHeight, clientHeight } = container;
|
|
177
228
|
const distanceFromBottom = scrollHeight - scrollTop - clientHeight;
|
|
178
|
-
if (distanceFromBottom <
|
|
229
|
+
if (distanceFromBottom < SCROLL_EDGE_DELTA) {
|
|
179
230
|
pauseAutoScrollRef.current = false;
|
|
180
231
|
setAutoScroll(true);
|
|
181
232
|
}
|
|
@@ -200,6 +251,6 @@ export const MessageBox = forwardRef((_a, ref) => {
|
|
|
200
251
|
onTouchMove,
|
|
201
252
|
onTouchEnd
|
|
202
253
|
};
|
|
203
|
-
return (_jsxs(_Fragment, { children: [_jsx(JumpButton, { position: "top", isHidden: isOverflowing && atTop, onClick: scrollToTop, jumpButtonProps: jumpButtonTopProps, jumpButtonTooltipProps: jumpButtonTopTooltipProps }), _jsxs("div", Object.assign({ role: "region", tabIndex: 0, "aria-label": ariaLabel, className: `pf-chatbot__messagebox ${position === 'bottom' ? 'pf-chatbot__messagebox--bottom' : ''} ${className !== null && className !== void 0 ? className : ''}`, ref: messageBoxRef }, props, (enableSmartScroll ? Object.assign({}, smartScrollHandlers) : {}), { children: [children, _jsx("div", { className: "pf-chatbot__messagebox-announcement pf-chatbot-m-hidden", "aria-live": "polite", children: announcement })] }))
|
|
254
|
+
return (_jsxs(_Fragment, { children: [_jsx(JumpButton, { position: "top", isHidden: !hasMeasuredScroll || (isOverflowing && atTop), onClick: scrollToTop, jumpButtonProps: jumpButtonTopProps, jumpButtonTooltipProps: jumpButtonTopTooltipProps }), _jsx(JumpButton, { position: "bottom", isHidden: !hasMeasuredScroll || (isOverflowing && atBottom), onClick: () => scrollToBottom({ resumeSmartScroll: true }), jumpButtonProps: jumpButtonBottomProps, jumpButtonTooltipProps: jumpButtonBottomTooltipProps }), _jsxs("div", Object.assign({ role: "region", tabIndex: 0, "aria-label": ariaLabel, className: `pf-chatbot__messagebox ${position === 'bottom' ? 'pf-chatbot__messagebox--bottom' : ''} ${className !== null && className !== void 0 ? className : ''}`, ref: messageBoxRef }, props, (enableSmartScroll ? Object.assign({}, smartScrollHandlers) : {}), { children: [children, _jsx("div", { className: "pf-chatbot__messagebox-announcement pf-chatbot-m-hidden", "aria-live": "polite", children: announcement })] }))] }));
|
|
204
255
|
});
|
|
205
256
|
export default MessageBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { createRef } from 'react';
|
|
12
12
|
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
13
|
+
import '@testing-library/jest-dom';
|
|
13
14
|
import { MessageBox } from './MessageBox';
|
|
14
15
|
import userEvent from '@testing-library/user-event';
|
|
15
16
|
describe('MessageBox', () => {
|
|
@@ -227,4 +228,62 @@ describe('MessageBox', () => {
|
|
|
227
228
|
});
|
|
228
229
|
expect((_b = ref.current) === null || _b === void 0 ? void 0 : _b.isSmartScrollActive()).toBe(true);
|
|
229
230
|
}));
|
|
231
|
+
it('should keep auto-scroll active during programmatic scroll to bottom', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
232
|
+
var _a, _b;
|
|
233
|
+
const ref = createRef();
|
|
234
|
+
render(_jsx(MessageBox, { ref: ref, enableSmartScroll: true, children: _jsx("div", { children: "Test message content" }) }));
|
|
235
|
+
const element = ref.current;
|
|
236
|
+
Object.defineProperty(element, 'scrollHeight', { configurable: true, value: 1000 });
|
|
237
|
+
Object.defineProperty(element, 'clientHeight', { configurable: true, value: 300 });
|
|
238
|
+
Object.defineProperty(element, 'scrollTop', { configurable: true, value: 0, writable: true });
|
|
239
|
+
act(() => {
|
|
240
|
+
var _a;
|
|
241
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollToBottom({ behavior: 'smooth' });
|
|
242
|
+
});
|
|
243
|
+
expect((_a = ref.current) === null || _a === void 0 ? void 0 : _a.isSmartScrollActive()).toBe(true);
|
|
244
|
+
act(() => {
|
|
245
|
+
element.scrollTop = 500;
|
|
246
|
+
element.dispatchEvent(new Event('scroll', { bubbles: true }));
|
|
247
|
+
});
|
|
248
|
+
expect((_b = ref.current) === null || _b === void 0 ? void 0 : _b.isSmartScrollActive()).toBe(true);
|
|
249
|
+
}));
|
|
250
|
+
it('should not scroll to bottom on initial layout when the message box is at the top', () => {
|
|
251
|
+
render(_jsx(MessageBox, { enableSmartScroll: true, children: _jsx("div", { children: "Tall message content" }) }));
|
|
252
|
+
const region = screen.getByRole('region');
|
|
253
|
+
Object.defineProperty(region, 'scrollHeight', { configurable: true, value: 1000 });
|
|
254
|
+
Object.defineProperty(region, 'clientHeight', { configurable: true, value: 300 });
|
|
255
|
+
Object.defineProperty(region, 'scrollTop', { configurable: true, value: 0, writable: true });
|
|
256
|
+
act(() => {
|
|
257
|
+
region.dispatchEvent(new Event('scroll'));
|
|
258
|
+
});
|
|
259
|
+
expect(region.scrollTop).toBe(0);
|
|
260
|
+
});
|
|
261
|
+
it('should show the bottom jump button at the top on initial load when overflowing', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
262
|
+
render(_jsx(MessageBox, { enableSmartScroll: true, children: _jsx("div", { children: "Tall message content" }) }));
|
|
263
|
+
const region = screen.getByRole('region');
|
|
264
|
+
Object.defineProperty(region, 'scrollHeight', { configurable: true, value: 1000 });
|
|
265
|
+
Object.defineProperty(region, 'clientHeight', { configurable: true, value: 300 });
|
|
266
|
+
Object.defineProperty(region, 'scrollTop', { configurable: true, value: 0, writable: true });
|
|
267
|
+
act(() => {
|
|
268
|
+
region.dispatchEvent(new Event('scroll'));
|
|
269
|
+
});
|
|
270
|
+
yield waitFor(() => {
|
|
271
|
+
expect(screen.queryByRole('button', { name: /Back to top/i })).toBeFalsy();
|
|
272
|
+
expect(screen.getByRole('button', { name: /Back to bottom/i })).toBeTruthy();
|
|
273
|
+
});
|
|
274
|
+
}));
|
|
275
|
+
it('should hide the bottom jump button while smart scroll is actively following content', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
276
|
+
render(_jsx(MessageBox, { enableSmartScroll: true, children: _jsx("div", { children: "Test message content" }) }));
|
|
277
|
+
const region = screen.getByRole('region');
|
|
278
|
+
Object.defineProperty(region, 'scrollHeight', { configurable: true, value: 1000 });
|
|
279
|
+
Object.defineProperty(region, 'clientHeight', { configurable: true, value: 300 });
|
|
280
|
+
Object.defineProperty(region, 'scrollTop', { configurable: true, value: 640, writable: true });
|
|
281
|
+
act(() => {
|
|
282
|
+
region.dispatchEvent(new Event('scroll'));
|
|
283
|
+
});
|
|
284
|
+
yield waitFor(() => {
|
|
285
|
+
expect(screen.getByRole('button', { name: /Back to top/i })).toBeTruthy();
|
|
286
|
+
expect(screen.queryByRole('button', { name: /Back to bottom/i })).toBeFalsy();
|
|
287
|
+
});
|
|
288
|
+
}));
|
|
230
289
|
});
|
|
@@ -11,39 +11,39 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
11
|
import { render, screen } from '@testing-library/react';
|
|
12
12
|
import '@testing-library/jest-dom';
|
|
13
13
|
import userEvent from '@testing-library/user-event';
|
|
14
|
-
import {
|
|
14
|
+
import { RhUiExportIcon } from '@patternfly/react-icons';
|
|
15
15
|
import ResponseActionButton from './ResponseActionButton';
|
|
16
16
|
describe('ResponseActionButton', () => {
|
|
17
17
|
it('renders aria-label correctly if not clicked', () => {
|
|
18
|
-
render(_jsx(ResponseActionButton, { icon: _jsx(
|
|
18
|
+
render(_jsx(ResponseActionButton, { icon: _jsx(RhUiExportIcon, {}), ariaLabel: "Download", clickedAriaLabel: "Downloaded" }));
|
|
19
19
|
expect(screen.getByRole('button', { name: 'Download' })).toBeTruthy();
|
|
20
20
|
});
|
|
21
21
|
it('renders aria-label correctly if clicked', () => {
|
|
22
|
-
render(_jsx(ResponseActionButton, { icon: _jsx(
|
|
22
|
+
render(_jsx(ResponseActionButton, { icon: _jsx(RhUiExportIcon, {}), ariaLabel: "Download", clickedAriaLabel: "Downloaded", isClicked: true }));
|
|
23
23
|
expect(screen.getByRole('button', { name: 'Downloaded' })).toBeTruthy();
|
|
24
24
|
});
|
|
25
25
|
it('renders tooltip correctly if not clicked', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
render(_jsx(ResponseActionButton, { icon: _jsx(
|
|
26
|
+
render(_jsx(ResponseActionButton, { icon: _jsx(RhUiExportIcon, {}), tooltipContent: "Download", clickedTooltipContent: "Downloaded" }));
|
|
27
27
|
expect(screen.getByRole('button', { name: 'Download' })).toBeTruthy();
|
|
28
28
|
// clicking here just triggers the tooltip; in this button, the logic is divorced from whether it is actually clicked
|
|
29
29
|
yield userEvent.click(screen.getByRole('button', { name: 'Download' }));
|
|
30
30
|
expect(screen.getByRole('tooltip', { name: 'Download' })).toBeTruthy();
|
|
31
31
|
}));
|
|
32
32
|
it('renders tooltip correctly if clicked', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
render(_jsx(ResponseActionButton, { icon: _jsx(
|
|
33
|
+
render(_jsx(ResponseActionButton, { icon: _jsx(RhUiExportIcon, {}), tooltipContent: "Download", clickedTooltipContent: "Downloaded", isClicked: true }));
|
|
34
34
|
expect(screen.getByRole('button', { name: 'Downloaded' })).toBeTruthy();
|
|
35
35
|
// clicking here just triggers the tooltip; in this button, the logic is divorced from whether it is actually clicked
|
|
36
36
|
yield userEvent.click(screen.getByRole('button', { name: 'Downloaded' }));
|
|
37
37
|
expect(screen.getByRole('tooltip', { name: 'Downloaded' })).toBeTruthy();
|
|
38
38
|
}));
|
|
39
39
|
it('if clicked variant for tooltip is not supplied, it uses the default', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
-
render(_jsx(ResponseActionButton, { icon: _jsx(
|
|
40
|
+
render(_jsx(ResponseActionButton, { icon: _jsx(RhUiExportIcon, {}), tooltipContent: "Download", isClicked: true }));
|
|
41
41
|
// clicking here just triggers the tooltip; in this button, the logic is divorced from whether it is actually clicked
|
|
42
42
|
yield userEvent.click(screen.getByRole('button', { name: 'Download' }));
|
|
43
43
|
expect(screen.getByRole('button', { name: 'Download' })).toBeTruthy();
|
|
44
44
|
}));
|
|
45
45
|
it('if clicked variant for aria label is not supplied, it uses the default', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
-
render(_jsx(ResponseActionButton, { icon: _jsx(
|
|
46
|
+
render(_jsx(ResponseActionButton, { icon: _jsx(RhUiExportIcon, {}), ariaLabel: "Download", isClicked: true }));
|
|
47
47
|
expect(screen.getByRole('button', { name: 'Download' })).toBeTruthy();
|
|
48
48
|
}));
|
|
49
49
|
});
|
|
@@ -12,7 +12,7 @@ import { render, screen } from '@testing-library/react';
|
|
|
12
12
|
import '@testing-library/jest-dom';
|
|
13
13
|
import ResponseActions from './ResponseActions';
|
|
14
14
|
import userEvent from '@testing-library/user-event';
|
|
15
|
-
import {
|
|
15
|
+
import { RhUiExportIcon, RhMicronsInformationFillIcon, RhUiRedoIcon } from '@patternfly/react-icons';
|
|
16
16
|
import Message from '../Message';
|
|
17
17
|
// Mock the icon components
|
|
18
18
|
jest.mock('@patternfly/react-icons', () => ({
|
|
@@ -28,9 +28,8 @@ jest.mock('@patternfly/react-icons', () => ({
|
|
|
28
28
|
RhUiVolumeUpFillIcon: () => _jsx("div", { children: "RhUiVolumeUpFillIcon" }),
|
|
29
29
|
RhUiExportIcon: () => _jsx("div", { children: "RhUiExportIcon" }),
|
|
30
30
|
RhUiExportFillIcon: () => _jsx("div", { children: "RhUiExportFillIcon" }),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
RedoIcon: () => _jsx("div", { children: "RedoIcon" })
|
|
31
|
+
RhMicronsInformationFillIcon: () => _jsx("div", { children: "RhMicronsInformationFillIcon" }),
|
|
32
|
+
RhUiRedoIcon: () => _jsx("div", { children: "RhUiRedoIcon" })
|
|
34
33
|
}));
|
|
35
34
|
const ALL_ACTIONS = [
|
|
36
35
|
{ type: 'positive', label: 'Good response', clickedLabel: 'Good response recorded' },
|
|
@@ -48,7 +47,7 @@ const CUSTOM_ACTIONS = [
|
|
|
48
47
|
onClick: jest.fn(),
|
|
49
48
|
tooltipContent: 'Regenerate',
|
|
50
49
|
clickedTooltipContent: 'Regenerated',
|
|
51
|
-
icon: _jsx(
|
|
50
|
+
icon: _jsx(RhUiRedoIcon, {})
|
|
52
51
|
},
|
|
53
52
|
download: {
|
|
54
53
|
ariaLabel: 'Download',
|
|
@@ -56,13 +55,13 @@ const CUSTOM_ACTIONS = [
|
|
|
56
55
|
onClick: jest.fn(),
|
|
57
56
|
tooltipContent: 'Download',
|
|
58
57
|
clickedTooltipContent: 'Downloaded',
|
|
59
|
-
icon: _jsx(
|
|
58
|
+
icon: _jsx(RhUiExportIcon, {})
|
|
60
59
|
},
|
|
61
60
|
info: {
|
|
62
61
|
ariaLabel: 'Info',
|
|
63
62
|
onClick: jest.fn(),
|
|
64
63
|
tooltipContent: 'Info',
|
|
65
|
-
icon: _jsx(
|
|
64
|
+
icon: _jsx(RhMicronsInformationFillIcon, {})
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
];
|
|
@@ -318,7 +317,7 @@ describe('ResponseActions', () => {
|
|
|
318
317
|
onClick: jest.fn(),
|
|
319
318
|
ariaLabel: 'Custom',
|
|
320
319
|
tooltipContent: 'Custom action',
|
|
321
|
-
icon: _jsx(
|
|
320
|
+
icon: _jsx(RhUiExportIcon, {})
|
|
322
321
|
}
|
|
323
322
|
};
|
|
324
323
|
render(_jsx(ResponseActions, { actions: actions, persistActionSelection: true }));
|
|
@@ -12,8 +12,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { useState } from 'react';
|
|
14
14
|
// Import PatternFly components
|
|
15
|
-
import { Button, ButtonVariant, Card, CardBody, CardFooter, CardTitle, ExpandableSection, ExpandableSectionVariant,
|
|
16
|
-
import {
|
|
15
|
+
import { Button, ButtonVariant, Card, CardBody, CardFooter, CardTitle, ExpandableSection, ExpandableSectionVariant, Truncate } from '@patternfly/react-core';
|
|
16
|
+
import { RhMicronsCaretLeftIcon, RhMicronsCaretRightIcon, RhMicronsExternalLinkIcon } from '@patternfly/react-icons';
|
|
17
17
|
const SourcesCardBase = (_a) => {
|
|
18
18
|
var _b;
|
|
19
19
|
var { className, isDisabled, paginationAriaLabel = 'Pagination', sources, toNextPageAriaLabel = 'Go to next page', toPreviousPageAriaLabel = 'Go to previous page', onNextClick, onPreviousClick, onSetPage, showMoreWords = 'show more', showLessWords = 'show less', isCompact, cardTitleProps, cardBodyProps, cardFooterProps, layout = 'paginated', cardMaxWidth = '400px' } = _a, props = __rest(_a, ["className", "isDisabled", "paginationAriaLabel", "sources", "toNextPageAriaLabel", "toPreviousPageAriaLabel", "onNextClick", "onPreviousClick", "onSetPage", "showMoreWords", "showLessWords", "isCompact", "cardTitleProps", "cardBodyProps", "cardFooterProps", "layout", "cardMaxWidth"]);
|
|
@@ -34,23 +34,23 @@ const SourcesCardBase = (_a) => {
|
|
|
34
34
|
};
|
|
35
35
|
const renderUncontrolledSourceCard = (source, index) => {
|
|
36
36
|
var _a;
|
|
37
|
-
return (_jsx("li", { className: "pf-chatbot__sources-list-item", style: { '--pf-chatbot-sources-card-max-width': cardMaxWidth }, children: _jsxs(Card, Object.assign({ isFullHeight: true, isCompact: isCompact, className: "pf-chatbot__sources-card" }, props, { children: [_jsx(CardTitle, Object.assign({ className: "pf-chatbot__sources-card-title" }, cardTitleProps, { children: _jsxs("div", { className: "pf-chatbot__sources-card-title-container", children: [_jsx(Button, Object.assign({ component: "a", variant: ButtonVariant.link, href: source.link, icon: source.isExternal ? _jsx(
|
|
37
|
+
return (_jsx("li", { className: "pf-chatbot__sources-list-item", style: { '--pf-chatbot-sources-card-max-width': cardMaxWidth }, children: _jsxs(Card, Object.assign({ isFullHeight: true, isCompact: isCompact, className: "pf-chatbot__sources-card" }, props, { children: [_jsx(CardTitle, Object.assign({ className: "pf-chatbot__sources-card-title" }, cardTitleProps, { children: _jsxs("div", { className: "pf-chatbot__sources-card-title-container", children: [_jsx(Button, Object.assign({ component: "a", variant: ButtonVariant.link, href: source.link, icon: source.isExternal ? _jsx(RhMicronsExternalLinkIcon, {}) : undefined, iconPosition: "end", isInline: true, rel: source.isExternal ? 'noreferrer' : undefined, target: source.isExternal ? '_blank' : undefined, onClick: (_a = source.onClick) !== null && _a !== void 0 ? _a : undefined }, source.titleProps, { children: renderTitle(source.title, index, source.truncateProps) })), source.subtitle && _jsx("span", { className: "pf-chatbot__sources-card-subtitle", children: source.subtitle })] }) })), source.body && (_jsx(CardBody, Object.assign({ className: `pf-chatbot__sources-card-body ${source.footer ? 'pf-chatbot__compact-sources-card-body' : undefined}` }, cardBodyProps, { children: source.hasShowMore ? (
|
|
38
38
|
// prevents extra VO announcements of button text - parent Message has aria-live
|
|
39
39
|
_jsx("div", { "aria-live": "off", children: _jsx(ExpandableSection, { variant: ExpandableSectionVariant.truncate, toggleTextCollapsed: showMoreWords, toggleTextExpanded: showLessWords, truncateMaxLines: 2, children: source.body }) })) : (_jsx("div", { className: "pf-chatbot__sources-card-body-text", children: source.body })) }))), source.footer && (_jsx(CardFooter, Object.assign({ className: "pf-chatbot__sources-card-footer" }, cardFooterProps, { children: source.footer })))] })) }, index));
|
|
40
40
|
};
|
|
41
41
|
if (layout === 'wrap') {
|
|
42
42
|
return (_jsx("div", { className: "pf-chatbot__sources-card-base pf-m-wrap", children: _jsx("ul", { className: "pf-chatbot__sources-list", role: "list", children: sources.map((source, index) => renderUncontrolledSourceCard(source, index)) }) }));
|
|
43
43
|
}
|
|
44
|
-
return (_jsx("div", { className: "pf-chatbot__sources-card-base", children: _jsxs(Card, Object.assign({ isCompact: isCompact, className: "pf-chatbot__sources-card" }, props, { children: [_jsx(CardTitle, Object.assign({ className: "pf-chatbot__sources-card-title" }, cardTitleProps, { children: _jsxs("div", { className: "pf-chatbot__sources-card-title-container", children: [_jsx(Button, Object.assign({ component: "a", variant: ButtonVariant.link, href: sources[page - 1].link, icon: sources[page - 1].isExternal ? _jsx(
|
|
44
|
+
return (_jsx("div", { className: "pf-chatbot__sources-card-base", children: _jsxs(Card, Object.assign({ isCompact: isCompact, className: "pf-chatbot__sources-card" }, props, { children: [_jsx(CardTitle, Object.assign({ className: "pf-chatbot__sources-card-title" }, cardTitleProps, { children: _jsxs("div", { className: "pf-chatbot__sources-card-title-container", children: [_jsx(Button, Object.assign({ component: "a", variant: ButtonVariant.link, href: sources[page - 1].link, icon: sources[page - 1].isExternal ? _jsx(RhMicronsExternalLinkIcon, {}) : undefined, iconPosition: "end", isInline: true, rel: sources[page - 1].isExternal ? 'noreferrer' : undefined, target: sources[page - 1].isExternal ? '_blank' : undefined, onClick: (_b = sources[page - 1].onClick) !== null && _b !== void 0 ? _b : undefined }, sources[page - 1].titleProps, { children: renderTitle(sources[page - 1].title, undefined, sources[page - 1].truncateProps) })), sources[page - 1].subtitle && (_jsx("span", { className: "pf-chatbot__sources-card-subtitle", children: sources[page - 1].subtitle }))] }) })), sources[page - 1].body && (_jsx(CardBody, Object.assign({ className: `pf-chatbot__sources-card-body ${sources[page - 1].footer ? 'pf-chatbot__compact-sources-card-body' : undefined}` }, cardBodyProps, { children: sources[page - 1].hasShowMore ? (
|
|
45
45
|
// prevents extra VO announcements of button text - parent Message has aria-live
|
|
46
|
-
_jsx("div", { "aria-live": "off", children: _jsx(ExpandableSection, { variant: ExpandableSectionVariant.truncate, toggleText: isExpanded ? showLessWords : showMoreWords, onToggle: onToggle, isExpanded: isExpanded, truncateMaxLines: 2, children: sources[page - 1].body }) })) : (_jsx("div", { className: "pf-chatbot__sources-card-body-text", children: sources[page - 1].body })) }))), sources[page - 1].footer ? (_jsx(CardFooter, Object.assign({ className: "pf-chatbot__sources-card-footer" }, cardFooterProps, { children: sources[page - 1].footer }))) : (sources.length > 1 && (_jsx(CardFooter, Object.assign({ className: "pf-chatbot__sources-card-footer-container" }, cardFooterProps, { children: _jsx("div", { className: "pf-chatbot__sources-card-footer", children: _jsxs("nav", { className: `pf-chatbot__sources-card-footer-buttons ${className}`, "aria-label": paginationAriaLabel, children: [_jsx(Button, { variant: ButtonVariant.plain, isDisabled: isDisabled || page === 1, "data-action": "previous", onClick: (event) => {
|
|
46
|
+
_jsx("div", { "aria-live": "off", children: _jsx(ExpandableSection, { variant: ExpandableSectionVariant.truncate, toggleText: isExpanded ? showLessWords : showMoreWords, onToggle: onToggle, isExpanded: isExpanded, truncateMaxLines: 2, children: sources[page - 1].body }) })) : (_jsx("div", { className: "pf-chatbot__sources-card-body-text", children: sources[page - 1].body })) }))), sources[page - 1].footer ? (_jsx(CardFooter, Object.assign({ className: "pf-chatbot__sources-card-footer" }, cardFooterProps, { children: sources[page - 1].footer }))) : (sources.length > 1 && (_jsx(CardFooter, Object.assign({ className: "pf-chatbot__sources-card-footer-container" }, cardFooterProps, { children: _jsx("div", { className: "pf-chatbot__sources-card-footer", children: _jsxs("nav", { className: `pf-chatbot__sources-card-footer-buttons ${className}`, "aria-label": paginationAriaLabel, children: [_jsx(Button, { variant: ButtonVariant.plain, isCircle: true, isDisabled: isDisabled || page === 1, "data-action": "previous", onClick: (event) => {
|
|
47
47
|
const newPage = page >= 1 ? page - 1 : 1;
|
|
48
48
|
onPreviousClick && onPreviousClick(event, newPage);
|
|
49
49
|
handleNewPage(event, newPage);
|
|
50
|
-
}, "aria-label": toPreviousPageAriaLabel, children: _jsx(
|
|
50
|
+
}, "aria-label": toPreviousPageAriaLabel, children: _jsx(RhMicronsCaretLeftIcon, {}) }), _jsxs("span", { "aria-hidden": "true", children: [page, "/", sources.length] }), _jsx(Button, { variant: ButtonVariant.plain, isCircle: true, isDisabled: isDisabled || page === sources.length, "aria-label": toNextPageAriaLabel, "data-action": "next", onClick: (event) => {
|
|
51
51
|
const newPage = page + 1 <= sources.length ? page + 1 : sources.length;
|
|
52
52
|
onNextClick && onNextClick(event, newPage);
|
|
53
53
|
handleNewPage(event, newPage);
|
|
54
|
-
}, children: _jsx(
|
|
54
|
+
}, children: _jsx(RhMicronsCaretRightIcon, {}) })] }) }) }))))] })) }));
|
|
55
55
|
};
|
|
56
56
|
export default SourcesCardBase;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -38,8 +38,6 @@ export { default as FilePreview } from './FilePreview';
|
|
|
38
38
|
export * from './FilePreview';
|
|
39
39
|
export { default as ImagePreview } from './ImagePreview';
|
|
40
40
|
export * from './ImagePreview';
|
|
41
|
-
export { default as LoadingMessage } from './LoadingMessage';
|
|
42
|
-
export * from './LoadingMessage';
|
|
43
41
|
export { default as MarkdownContent } from './MarkdownContent';
|
|
44
42
|
export * from './MarkdownContent';
|
|
45
43
|
export { default as Message } from './Message';
|
package/dist/esm/index.js
CHANGED
|
@@ -39,8 +39,6 @@ export { default as FilePreview } from './FilePreview';
|
|
|
39
39
|
export * from './FilePreview';
|
|
40
40
|
export { default as ImagePreview } from './ImagePreview';
|
|
41
41
|
export * from './ImagePreview';
|
|
42
|
-
export { default as LoadingMessage } from './LoadingMessage';
|
|
43
|
-
export * from './LoadingMessage';
|
|
44
42
|
export { default as MarkdownContent } from './MarkdownContent';
|
|
45
43
|
export * from './MarkdownContent';
|
|
46
44
|
export { default as Message } from './Message';
|
|
@@ -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/ChatbotHeaderNewChatButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderNewChatButton.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.test.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.tsx","../src/ChatbotHeader/index.ts","../src/ChatbotModal/ChatbotModal.test.tsx","../src/ChatbotModal/ChatbotModal.tsx","../src/ChatbotModal/index.ts","../src/ChatbotPopover/ChatbotPopover.tsx","../src/ChatbotPopover/index.ts","../src/ChatbotToggle/ChatbotToggle.test.tsx","../src/ChatbotToggle/ChatbotToggle.tsx","../src/ChatbotToggle/index.ts","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx","../src/ChatbotWelcomePrompt/index.ts","../src/CodeModal/CodeModal.test.tsx","../src/CodeModal/CodeModal.tsx","../src/CodeModal/index.ts","../src/Compare/Compare.test.tsx","../src/Compare/Compare.tsx","../src/Compare/index.ts","../src/DeepThinking/DeepThinking.test.tsx","../src/DeepThinking/DeepThinking.tsx","../src/DeepThinking/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/FilePreview/FilePreview.test.tsx","../src/FilePreview/FilePreview.tsx","../src/FilePreview/index.ts","../src/ImagePreview/ImagePreview.test.tsx","../src/ImagePreview/ImagePreview.tsx","../src/ImagePreview/index.ts","../src/
|
|
1
|
+
{"root":["../src/index.ts","../src/AttachMenu/AttachMenu.tsx","../src/AttachMenu/index.ts","../src/AttachmentEdit/AttachmentEdit.test.tsx","../src/AttachmentEdit/AttachmentEdit.tsx","../src/AttachmentEdit/index.ts","../src/Chatbot/Chatbot.test.tsx","../src/Chatbot/Chatbot.tsx","../src/Chatbot/index.ts","../src/ChatbotAlert/ChatbotAlert.test.tsx","../src/ChatbotAlert/ChatbotAlert.tsx","../src/ChatbotAlert/index.ts","../src/ChatbotContent/ChatbotContent.test.tsx","../src/ChatbotContent/ChatbotContent.tsx","../src/ChatbotContent/index.ts","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx","../src/ChatbotConversationHistoryNav/EmptyState.tsx","../src/ChatbotConversationHistoryNav/LoadingState.tsx","../src/ChatbotConversationHistoryNav/index.ts","../src/ChatbotFooter/ChatbotFooter.test.tsx","../src/ChatbotFooter/ChatbotFooter.tsx","../src/ChatbotFooter/ChatbotFooternote.test.tsx","../src/ChatbotFooter/ChatbotFootnote.tsx","../src/ChatbotFooter/index.ts","../src/ChatbotHeader/ChatbotHeader.test.tsx","../src/ChatbotHeader/ChatbotHeader.tsx","../src/ChatbotHeader/ChatbotHeaderActions.test.tsx","../src/ChatbotHeader/ChatbotHeaderActions.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.tsx","../src/ChatbotHeader/ChatbotHeaderMain.test.tsx","../src/ChatbotHeader/ChatbotHeaderMain.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.test.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.tsx","../src/ChatbotHeader/ChatbotHeaderNewChatButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderNewChatButton.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.test.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.tsx","../src/ChatbotHeader/index.ts","../src/ChatbotModal/ChatbotModal.test.tsx","../src/ChatbotModal/ChatbotModal.tsx","../src/ChatbotModal/index.ts","../src/ChatbotPopover/ChatbotPopover.tsx","../src/ChatbotPopover/index.ts","../src/ChatbotToggle/ChatbotToggle.test.tsx","../src/ChatbotToggle/ChatbotToggle.tsx","../src/ChatbotToggle/index.ts","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx","../src/ChatbotWelcomePrompt/index.ts","../src/CodeModal/CodeModal.test.tsx","../src/CodeModal/CodeModal.tsx","../src/CodeModal/index.ts","../src/Compare/Compare.test.tsx","../src/Compare/Compare.tsx","../src/Compare/index.ts","../src/DeepThinking/DeepThinking.test.tsx","../src/DeepThinking/DeepThinking.tsx","../src/DeepThinking/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/FilePreview/FilePreview.test.tsx","../src/FilePreview/FilePreview.tsx","../src/FilePreview/index.ts","../src/ImagePreview/ImagePreview.test.tsx","../src/ImagePreview/ImagePreview.tsx","../src/ImagePreview/index.ts","../src/MarkdownContent/MarkdownContent.test.tsx","../src/MarkdownContent/MarkdownContent.tsx","../src/MarkdownContent/index.ts","../src/Message/Message.test.tsx","../src/Message/Message.tsx","../src/Message/MessageInput.tsx","../src/Message/MessageLoading.test.tsx","../src/Message/MessageLoading.tsx","../src/Message/index.ts","../src/Message/CodeBlockMessage/CodeBlockMessage.test.tsx","../src/Message/CodeBlockMessage/CodeBlockMessage.tsx","../src/Message/ErrorMessage/ErrorMessage.test.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/MessageAndActions/MessageAndActions.test.tsx","../src/Message/MessageAndActions/MessageAndActions.tsx","../src/Message/MessageAndActions/index.ts","../src/Message/MessageAttachments/MessageAttachmentItem.test.tsx","../src/Message/MessageAttachments/MessageAttachmentItem.tsx","../src/Message/MessageAttachments/MessageAttachmentsContainer.test.tsx","../src/Message/MessageAttachments/MessageAttachmentsContainer.tsx","../src/Message/MessageAttachments/index.ts","../src/Message/Plugins/index.ts","../src/Message/Plugins/rehypeCodeBlockToggle.ts","../src/Message/Plugins/rehypeMoveImagesOutOfParagraphs.ts","../src/Message/QuickResponse/QuickResponse.test.tsx","../src/Message/QuickResponse/QuickResponse.tsx","../src/Message/QuickResponse/index.ts","../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/index.ts","../src/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.ts","../src/Message/QuickStarts/monitor-sampleapp-quickstart.ts","../src/Message/QuickStarts/types.ts","../src/Message/SuperscriptMessage/SuperscriptMessage.tsx","../src/Message/TableMessage/TableCellContent.tsx","../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/Message/UserFeedback/index.ts","../src/MessageBar/AttachButton.test.tsx","../src/MessageBar/AttachButton.tsx","../src/MessageBar/MessageBar.test.tsx","../src/MessageBar/MessageBar.tsx","../src/MessageBar/MicrophoneButton.tsx","../src/MessageBar/SendButton.test.tsx","../src/MessageBar/SendButton.tsx","../src/MessageBar/StopButton.test.tsx","../src/MessageBar/StopButton.tsx","../src/MessageBar/index.ts","../src/MessageBox/JumpButton.test.tsx","../src/MessageBox/JumpButton.tsx","../src/MessageBox/MessageBox.test.tsx","../src/MessageBox/MessageBox.tsx","../src/MessageBox/index.ts","../src/MessageDivider/MessageDivider.test.tsx","../src/MessageDivider/MessageDivider.tsx","../src/MessageDivider/index.ts","../src/Onboarding/Onboarding.test.tsx","../src/Onboarding/Onboarding.tsx","../src/Onboarding/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/ResponseActionsGroups.test.tsx","../src/ResponseActions/ResponseActionsGroups.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/SourcesCardBase/SourcesCardBase.test.tsx","../src/SourcesCardBase/SourcesCardBase.tsx","../src/SourcesCardBase/index.ts","../src/TermsOfUse/TermsOfUse.test.tsx","../src/TermsOfUse/TermsOfUse.tsx","../src/TermsOfUse/index.ts","../src/ToolCall/ToolCall.test.tsx","../src/ToolCall/ToolCall.tsx","../src/ToolCall/index.ts","../src/ToolResponse/ToolResponse.test.tsx","../src/ToolResponse/ToolResponse.tsx","../src/ToolResponse/index.ts","../src/__mocks__/monaco-editor.ts","../src/__mocks__/rehype-external-links.ts","../src/__mocks__/rehype-highlight.ts","../src/__mocks__/rehype-sanitize.ts","../src/__mocks__/rehype-unwrap-images.tsx","../src/tracking/console_tracking_provider.ts","../src/tracking/index.ts","../src/tracking/posthog_tracking_provider.ts","../src/tracking/segment_tracking_provider.ts","../src/tracking/trackingProviderProxy.ts","../src/tracking/tracking_api.ts","../src/tracking/tracking_registry.ts","../src/tracking/tracking_spi.ts","../src/tracking/umami_tracking_provider.ts"],"version":"5.6.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/chatbot",
|
|
3
|
-
"version": "6.8.0-prerelease.
|
|
3
|
+
"version": "6.8.0-prerelease.5",
|
|
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",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@octokit/rest": "^18.0.0",
|
|
69
69
|
"@patternfly/documentation-framework": "^6.47.0",
|
|
70
70
|
"@patternfly/patternfly": "^6.6.0",
|
|
71
|
-
"@patternfly/patternfly-a11y": "^5.
|
|
71
|
+
"@patternfly/patternfly-a11y": "^5.2.1",
|
|
72
72
|
"@types/dom-speech-recognition": "^0.0.4",
|
|
73
73
|
"@types/react": "^18.2.61",
|
|
74
74
|
"estree-util-is-identifier-name": "^3.0.0",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
|
|
3
3
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
4
|
-
import
|
|
5
|
-
import RedoIcon from '@patternfly/react-icons/dist/esm/icons/redo-icon';
|
|
4
|
+
import { RhMicronsInformationFillIcon, RhUiRedoIcon } from '@patternfly/react-icons';
|
|
6
5
|
|
|
7
6
|
export const CustomActionExample: FunctionComponent = () => (
|
|
8
7
|
<Message
|
|
@@ -18,14 +17,14 @@ export const CustomActionExample: FunctionComponent = () => (
|
|
|
18
17
|
onClick: () => console.log('Clicked regenerate'),
|
|
19
18
|
tooltipContent: 'Regenerate',
|
|
20
19
|
clickedTooltipContent: 'Regenerated',
|
|
21
|
-
icon: <
|
|
20
|
+
icon: <RhUiRedoIcon />
|
|
22
21
|
},
|
|
23
22
|
info: {
|
|
24
23
|
ariaLabel: 'Info',
|
|
25
24
|
// eslint-disable-next-line no-console
|
|
26
25
|
onClick: () => console.log('Clicked info'),
|
|
27
26
|
tooltipContent: 'Info',
|
|
28
|
-
icon: <
|
|
27
|
+
icon: <RhMicronsInformationFillIcon />
|
|
29
28
|
}
|
|
30
29
|
}}
|
|
31
30
|
/>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState, FunctionComponent, MouseEvent as ReactMouseEvent } from 'react';
|
|
2
2
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
3
|
-
import {
|
|
3
|
+
import { RhUiBuildFillIcon, RhUiCopyFillIcon } from '@patternfly/react-icons';
|
|
4
4
|
import {
|
|
5
5
|
Button,
|
|
6
6
|
DescriptionList,
|
|
@@ -72,7 +72,7 @@ export const MessageWithToolResponseExample: FunctionComponent = () => {
|
|
|
72
72
|
}}
|
|
73
73
|
>
|
|
74
74
|
<FlexItem>
|
|
75
|
-
<
|
|
75
|
+
<RhUiBuildFillIcon
|
|
76
76
|
style={{
|
|
77
77
|
color: 'var(--pf-t--global--icon--color--brand--default'
|
|
78
78
|
}}
|
|
@@ -102,7 +102,7 @@ export const MessageWithToolResponseExample: FunctionComponent = () => {
|
|
|
102
102
|
variant="plain"
|
|
103
103
|
aria-label="Copy tool response to clipboard"
|
|
104
104
|
icon={
|
|
105
|
-
<
|
|
105
|
+
<RhUiCopyFillIcon
|
|
106
106
|
style={{
|
|
107
107
|
color: 'var(--pf-t--global--icon--color--subtle)'
|
|
108
108
|
}}
|
package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
3
|
-
import {
|
|
3
|
+
import { RhUiBuildFillIcon, RhUiCopyFillIcon } from '@patternfly/react-icons';
|
|
4
4
|
|
|
5
5
|
export const MessageWithQuickResponsesExample: FunctionComponent = () => (
|
|
6
6
|
<>
|
|
@@ -73,8 +73,8 @@ export const MessageWithQuickResponsesExample: FunctionComponent = () => (
|
|
|
73
73
|
role="bot"
|
|
74
74
|
content="Example with icons"
|
|
75
75
|
quickResponses={[
|
|
76
|
-
{ id: '1', content: 'Update your settings', onClick: () => alert('Clicked yes'), icon: <
|
|
77
|
-
{ id: '2', content: 'Copy', onClick: () => alert('Clicked no'), icon: <
|
|
76
|
+
{ id: '1', content: 'Update your settings', onClick: () => alert('Clicked yes'), icon: <RhUiBuildFillIcon /> },
|
|
77
|
+
{ id: '2', content: 'Copy', onClick: () => alert('Clicked no'), icon: <RhUiCopyFillIcon /> }
|
|
78
78
|
]}
|
|
79
79
|
/>
|
|
80
80
|
</>
|