@patternfly/chatbot 6.3.0-prerelease.6 → 6.3.0-prerelease.8
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/Chatbot/Chatbot.test.js +4 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +1 -1
- package/dist/cjs/ChatbotFooter/ChatbotFooter.d.ts +1 -0
- package/dist/cjs/ChatbotFooter/ChatbotFooter.js +2 -2
- package/dist/cjs/ChatbotFooter/ChatbotFooter.test.d.ts +1 -1
- package/dist/cjs/ChatbotFooter/ChatbotFooter.test.js +5 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.d.ts +3 -2
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.js +20 -6
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.js +5 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.js +3 -3
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +5 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.js +2 -2
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +5 -0
- package/dist/cjs/ChatbotPopover/ChatbotPopover.js +1 -1
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.d.ts +1 -0
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.js +3 -3
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +4 -0
- package/dist/cjs/Message/Message.js +2 -2
- package/dist/cjs/Message/QuickStarts/QuickStartTile.d.ts +2 -0
- package/dist/cjs/Message/QuickStarts/QuickStartTile.js +2 -2
- package/dist/cjs/MessageBar/AttachButton.d.ts +1 -0
- package/dist/cjs/MessageBar/AttachButton.js +3 -3
- package/dist/cjs/MessageBar/AttachButton.test.js +4 -0
- package/dist/cjs/MessageBar/MessageBar.d.ts +1 -0
- package/dist/cjs/MessageBar/MessageBar.js +13 -12
- package/dist/cjs/MessageBar/MicrophoneButton.d.ts +1 -0
- package/dist/cjs/MessageBar/MicrophoneButton.js +3 -3
- package/dist/cjs/MessageBar/SendButton.d.ts +1 -0
- package/dist/cjs/MessageBar/SendButton.js +3 -3
- package/dist/cjs/MessageBar/SendButton.test.js +4 -0
- package/dist/cjs/MessageBar/StopButton.d.ts +1 -0
- package/dist/cjs/MessageBar/StopButton.js +3 -3
- package/dist/cjs/MessageBar/StopButton.test.js +4 -0
- package/dist/cjs/SourcesCard/SourcesCard.js +2 -2
- package/dist/css/main.css +133 -2
- package/dist/css/main.css.map +1 -1
- package/dist/esm/Chatbot/Chatbot.test.js +4 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +1 -1
- package/dist/esm/ChatbotFooter/ChatbotFooter.d.ts +1 -0
- package/dist/esm/ChatbotFooter/ChatbotFooter.js +2 -2
- package/dist/esm/ChatbotFooter/ChatbotFooter.test.d.ts +1 -1
- package/dist/esm/ChatbotFooter/ChatbotFooter.test.js +5 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.d.ts +3 -2
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +20 -6
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.js +5 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.js +3 -3
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +5 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.js +2 -2
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +5 -0
- package/dist/esm/ChatbotPopover/ChatbotPopover.js +1 -1
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.d.ts +1 -0
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.js +3 -3
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +4 -0
- package/dist/esm/Message/Message.js +2 -2
- package/dist/esm/Message/QuickStarts/QuickStartTile.d.ts +2 -0
- package/dist/esm/Message/QuickStarts/QuickStartTile.js +2 -2
- package/dist/esm/MessageBar/AttachButton.d.ts +1 -0
- package/dist/esm/MessageBar/AttachButton.js +3 -3
- package/dist/esm/MessageBar/AttachButton.test.js +4 -0
- package/dist/esm/MessageBar/MessageBar.d.ts +1 -0
- package/dist/esm/MessageBar/MessageBar.js +13 -12
- package/dist/esm/MessageBar/MicrophoneButton.d.ts +1 -0
- package/dist/esm/MessageBar/MicrophoneButton.js +3 -3
- package/dist/esm/MessageBar/SendButton.d.ts +1 -0
- package/dist/esm/MessageBar/SendButton.js +3 -3
- package/dist/esm/MessageBar/SendButton.test.js +4 -0
- package/dist/esm/MessageBar/StopButton.d.ts +1 -0
- package/dist/esm/MessageBar/StopButton.js +3 -3
- package/dist/esm/MessageBar/StopButton.test.js +4 -0
- package/dist/esm/SourcesCard/SourcesCard.js +2 -2
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx +24 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickStart.tsx +11 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +21 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +8 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotCompact.tsx +481 -0
- package/src/Chatbot/Chatbot.test.tsx +9 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +10 -1
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +5 -1
- package/src/ChatbotFooter/ChatbotFooter.scss +5 -0
- package/src/ChatbotFooter/ChatbotFooter.test.tsx +10 -0
- package/src/ChatbotFooter/ChatbotFooter.tsx +3 -1
- package/src/ChatbotHeader/ChatbotHeader.scss +17 -0
- package/src/ChatbotHeader/ChatbotHeaderMenu.test.tsx +8 -0
- package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +10 -5
- package/src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx +6 -0
- package/src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx +5 -2
- package/src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx +10 -0
- package/src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx +4 -0
- package/src/ChatbotPopover/ChatbotPopover.scss +9 -5
- package/src/ChatbotPopover/ChatbotPopover.tsx +1 -1
- package/src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.scss +9 -1
- package/src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx +13 -0
- package/src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx +13 -2
- package/src/ChatbotWelcomePrompt/__snapshots__/ChatbotWelcomePrompt.test.tsx.snap +1 -1
- package/src/Message/Message.scss +27 -0
- package/src/Message/Message.tsx +2 -1
- package/src/Message/QuickStarts/QuickStartTile.tsx +5 -1
- package/src/Message/TextMessage/TextMessage.scss +25 -0
- package/src/MessageBar/AttachButton.scss +10 -0
- package/src/MessageBar/AttachButton.test.tsx +4 -0
- package/src/MessageBar/AttachButton.tsx +5 -2
- package/src/MessageBar/MessageBar.scss +17 -0
- package/src/MessageBar/MessageBar.tsx +15 -6
- package/src/MessageBar/MicrophoneButton.scss +10 -0
- package/src/MessageBar/MicrophoneButton.tsx +5 -2
- package/src/MessageBar/SendButton.scss +10 -0
- package/src/MessageBar/SendButton.test.tsx +5 -1
- package/src/MessageBar/SendButton.tsx +5 -2
- package/src/MessageBar/StopButton.scss +10 -0
- package/src/MessageBar/StopButton.test.tsx +5 -1
- package/src/MessageBar/StopButton.tsx +5 -2
- package/src/MessageBox/MessageBox.scss +6 -0
- package/src/SourcesCard/SourcesCard.scss +8 -0
- package/src/SourcesCard/SourcesCard.tsx +2 -1
@@ -12,7 +12,7 @@ export const camelize = (str) => str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function
|
|
12
12
|
} // or if (/\s+/.test(match)) for white spaces
|
13
13
|
return index === 0 ? match.toLowerCase() : match.toUpperCase();
|
14
14
|
});
|
15
|
-
const QuickStartTile = ({ className, quickStart, onClick, onSelectQuickStart, minuteWord = 'minute', minuteWordPlural = 'minutes', prerequisiteWord, prerequisiteWordPlural, quickStartButtonAriaLabel, action }) => {
|
15
|
+
const QuickStartTile = ({ className, quickStart, onClick, onSelectQuickStart, minuteWord = 'minute', minuteWordPlural = 'minutes', prerequisiteWord, prerequisiteWordPlural, quickStartButtonAriaLabel, action, isCompact }) => {
|
16
16
|
const { metadata: { name: id }, spec: { icon, displayName, description, durationMinutes, prerequisites, link, type } } = quickStart;
|
17
17
|
let quickStartIcon;
|
18
18
|
if (typeof icon === 'object') {
|
@@ -33,7 +33,7 @@ const QuickStartTile = ({ className, quickStart, onClick, onSelectQuickStart, mi
|
|
33
33
|
};
|
34
34
|
const ActionIcon = (action === null || action === void 0 ? void 0 : action.icon) || OutlinedBookmarkIcon;
|
35
35
|
const additionalAction = action ? (React.createElement(Button, Object.assign({ "aria-label": action['aria-label'], icon: React.createElement(ActionIcon, null), variant: "plain", onClick: action.onClick }, action.buttonProps))) : undefined;
|
36
|
-
return (React.createElement(Card, { className: `pf-chatbot__quickstarts-tile ${className ? className : ''}`, id: `${id}-chatbot-qs-tile`, style: { height: '100%' }, "data-testid": `chatbot-qs-card-${camelize(displayName)}
|
36
|
+
return (React.createElement(Card, { className: `pf-chatbot__quickstarts-tile ${className ? className : ''}`, id: `${id}-chatbot-qs-tile`, style: { height: '100%' }, "data-testid": `chatbot-qs-card-${camelize(displayName)}`, isCompact: isCompact },
|
37
37
|
React.createElement(CardHeader, Object.assign({}, (action && {
|
38
38
|
actions: { actions: additionalAction }
|
39
39
|
})), quickStartIcon),
|
@@ -17,5 +17,6 @@ export interface AttachButtonProps extends ButtonProps {
|
|
17
17
|
tooltipContent?: string;
|
18
18
|
/** Test id applied to input */
|
19
19
|
inputTestId?: string;
|
20
|
+
isCompact?: boolean;
|
20
21
|
}
|
21
22
|
export declare const AttachButton: React.ForwardRefExoticComponent<AttachButtonProps & React.RefAttributes<any>>;
|
@@ -18,7 +18,7 @@ import { Button, Icon, Tooltip } from '@patternfly/react-core';
|
|
18
18
|
import { useDropzone } from 'react-dropzone';
|
19
19
|
import { PaperclipIcon } from '@patternfly/react-icons/dist/esm/icons/paperclip-icon';
|
20
20
|
const AttachButtonBase = (_a) => {
|
21
|
-
var { onAttachAccepted, onClick, isDisabled, className, tooltipProps, innerRef, tooltipContent = 'Attach', inputTestId } = _a, props = __rest(_a, ["onAttachAccepted", "onClick", "isDisabled", "className", "tooltipProps", "innerRef", "tooltipContent", "inputTestId"]);
|
21
|
+
var { onAttachAccepted, onClick, isDisabled, className, tooltipProps, innerRef, tooltipContent = 'Attach', inputTestId, isCompact } = _a, props = __rest(_a, ["onAttachAccepted", "onClick", "isDisabled", "className", "tooltipProps", "innerRef", "tooltipContent", "inputTestId", "isCompact"]);
|
22
22
|
const { open, getInputProps } = useDropzone({
|
23
23
|
multiple: true,
|
24
24
|
onDropAccepted: onAttachAccepted
|
@@ -28,7 +28,7 @@ const AttachButtonBase = (_a) => {
|
|
28
28
|
React.createElement(Tooltip, Object.assign({ id: "pf-chatbot__tooltip--attach", content: tooltipContent, position: "top", entryDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.entryDelay) || 0, exitDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.exitDelay) || 0, distance: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.distance) || 8, animationDuration: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.animationDuration) || 0,
|
29
29
|
// prevents VO announcements of both aria label and tooltip
|
30
30
|
aria: "none" }, tooltipProps),
|
31
|
-
React.createElement(Button, Object.assign({ variant: "plain", ref: innerRef, className: `pf-chatbot__button--attach ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Attach button', isDisabled: isDisabled, onClick: onClick !== null && onClick !== void 0 ? onClick : open, icon: React.createElement(Icon, { iconSize:
|
32
|
-
React.createElement(PaperclipIcon, null)) }, props)))));
|
31
|
+
React.createElement(Button, Object.assign({ variant: "plain", ref: innerRef, className: `pf-chatbot__button--attach ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Attach button', isDisabled: isDisabled, onClick: onClick !== null && onClick !== void 0 ? onClick : open, icon: React.createElement(Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
|
32
|
+
React.createElement(PaperclipIcon, null)), size: isCompact ? 'sm' : undefined }, props)))));
|
33
33
|
};
|
34
34
|
export const AttachButton = React.forwardRef((props, ref) => (React.createElement(AttachButtonBase, Object.assign({ innerRef: ref }, props))));
|
@@ -58,4 +58,8 @@ describe('Attach button', () => {
|
|
58
58
|
expect(input.files).toHaveLength(1);
|
59
59
|
expect(spy).toHaveBeenCalledTimes(1);
|
60
60
|
}));
|
61
|
+
it('should handle isCompact', () => {
|
62
|
+
render(React.createElement(AttachButton, { isCompact: true, "data-testid": "button" }));
|
63
|
+
expect(screen.getByTestId('button')).toHaveClass('pf-m-compact');
|
64
|
+
});
|
61
65
|
});
|
@@ -78,6 +78,7 @@ export interface MessageBarProps extends TextAreaProps {
|
|
78
78
|
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>, value: string | number) => void;
|
79
79
|
/** Display mode of chatbot, if you want to message bar to resize when the display mode changes */
|
80
80
|
displayMode?: ChatbotDisplayMode;
|
81
|
+
isCompact?: boolean;
|
81
82
|
}
|
82
83
|
export declare const MessageBar: React.FunctionComponent<MessageBarProps>;
|
83
84
|
export default MessageBar;
|
@@ -18,7 +18,7 @@ import { AttachButton } from './AttachButton';
|
|
18
18
|
import AttachMenu from '../AttachMenu';
|
19
19
|
import StopButton from './StopButton';
|
20
20
|
export const MessageBar = (_a) => {
|
21
|
-
var { onSendMessage, className, alwayShowSendButton, placeholder = 'Send a message...', hasAttachButton = true, hasMicrophoneButton, listeningText = 'Listening', handleAttach, attachMenuProps, isSendButtonDisabled, handleStopButton, hasStopButton, buttonProps, onChange, displayMode, value } = _a, props = __rest(_a, ["onSendMessage", "className", "alwayShowSendButton", "placeholder", "hasAttachButton", "hasMicrophoneButton", "listeningText", "handleAttach", "attachMenuProps", "isSendButtonDisabled", "handleStopButton", "hasStopButton", "buttonProps", "onChange", "displayMode", "value"]);
|
21
|
+
var { onSendMessage, className, alwayShowSendButton, placeholder = 'Send a message...', hasAttachButton = true, hasMicrophoneButton, listeningText = 'Listening', handleAttach, attachMenuProps, isSendButtonDisabled, handleStopButton, hasStopButton, buttonProps, onChange, displayMode, value, isCompact = false } = _a, props = __rest(_a, ["onSendMessage", "className", "alwayShowSendButton", "placeholder", "hasAttachButton", "hasMicrophoneButton", "listeningText", "handleAttach", "attachMenuProps", "isSendButtonDisabled", "handleStopButton", "hasStopButton", "buttonProps", "onChange", "displayMode", "value", "isCompact"]);
|
22
22
|
// Text Input
|
23
23
|
// --------------------------------------------------------------------------
|
24
24
|
const [message, setMessage] = React.useState(value !== null && value !== void 0 ? value : '');
|
@@ -26,11 +26,12 @@ export const MessageBar = (_a) => {
|
|
26
26
|
const [hasSentMessage, setHasSentMessage] = React.useState(false);
|
27
27
|
const textareaRef = React.useRef(null);
|
28
28
|
const attachButtonRef = React.useRef(null);
|
29
|
+
const topMargin = '1rem';
|
29
30
|
const setInitialLineHeight = (field) => {
|
30
31
|
field.style.setProperty('line-height', '1rem');
|
31
32
|
const parent = field.parentElement;
|
32
33
|
if (parent) {
|
33
|
-
parent.style.setProperty('margin-top',
|
34
|
+
parent.style.setProperty('margin-top', topMargin);
|
34
35
|
parent.style.setProperty('margin-bottom', `0rem`);
|
35
36
|
parent.style.setProperty('height', 'inherit');
|
36
37
|
const grandparent = parent.parentElement;
|
@@ -52,8 +53,8 @@ export const MessageBar = (_a) => {
|
|
52
53
|
parseInt(computed.getPropertyValue('border-bottom-width'));
|
53
54
|
parent.style.setProperty('height', `${height}px`);
|
54
55
|
if (height > 32 || window.innerWidth <= 507) {
|
55
|
-
parent.style.setProperty('margin-bottom',
|
56
|
-
parent.style.setProperty('margin-top',
|
56
|
+
parent.style.setProperty('margin-bottom', topMargin);
|
57
|
+
parent.style.setProperty('margin-top', topMargin);
|
57
58
|
}
|
58
59
|
}
|
59
60
|
};
|
@@ -74,8 +75,8 @@ export const MessageBar = (_a) => {
|
|
74
75
|
const handleNewLine = (field) => {
|
75
76
|
const parent = field.parentElement;
|
76
77
|
if (parent) {
|
77
|
-
parent.style.setProperty('margin-bottom',
|
78
|
-
parent.style.setProperty('margin-top',
|
78
|
+
parent.style.setProperty('margin-bottom', topMargin);
|
79
|
+
parent.style.setProperty('margin-top', topMargin);
|
79
80
|
}
|
80
81
|
};
|
81
82
|
React.useEffect(() => {
|
@@ -170,16 +171,16 @@ export const MessageBar = (_a) => {
|
|
170
171
|
const renderButtons = () => {
|
171
172
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
172
173
|
if (hasStopButton && handleStopButton) {
|
173
|
-
return (React.createElement(StopButton, Object.assign({ onClick: handleStopButton, tooltipContent: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.stop) === null || _a === void 0 ? void 0 : _a.tooltipContent }, (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.stop) === null || _b === void 0 ? void 0 : _b.props)));
|
174
|
+
return (React.createElement(StopButton, Object.assign({ onClick: handleStopButton, tooltipContent: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.stop) === null || _a === void 0 ? void 0 : _a.tooltipContent, isCompact: isCompact }, (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.stop) === null || _b === void 0 ? void 0 : _b.props)));
|
174
175
|
}
|
175
176
|
return (React.createElement(React.Fragment, null,
|
176
|
-
attachMenuProps && (React.createElement(AttachButton, Object.assign({ ref: attachButtonRef, onClick: handleAttachMenuToggle, isDisabled: isListeningMessage, tooltipContent: (_c = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _c === void 0 ? void 0 : _c.tooltipContent }, (_d = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _d === void 0 ? void 0 : _d.props))),
|
177
|
-
!attachMenuProps && hasAttachButton && (React.createElement(AttachButton, Object.assign({ onAttachAccepted: handleAttach, isDisabled: isListeningMessage, tooltipContent: (_e = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _e === void 0 ? void 0 : _e.tooltipContent, inputTestId: (_f = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _f === void 0 ? void 0 : _f.inputTestId }, (_g = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _g === void 0 ? void 0 : _g.props))),
|
178
|
-
hasMicrophoneButton && (React.createElement(MicrophoneButton, Object.assign({ isListening: isListeningMessage, onIsListeningChange: setIsListeningMessage, onSpeechRecognition: handleSpeechRecognition, tooltipContent: (_h = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _h === void 0 ? void 0 : _h.tooltipContent, language: (_j = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _j === void 0 ? void 0 : _j.language }, (_k = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _k === void 0 ? void 0 : _k.props))),
|
179
|
-
(alwayShowSendButton || message) && (React.createElement(SendButton, Object.assign({ value: message, onClick: () => handleSend(message), isDisabled: isSendButtonDisabled, tooltipContent: (_l = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.send) === null || _l === void 0 ? void 0 : _l.tooltipContent }, (_m = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.send) === null || _m === void 0 ? void 0 : _m.props)))));
|
177
|
+
attachMenuProps && (React.createElement(AttachButton, Object.assign({ ref: attachButtonRef, onClick: handleAttachMenuToggle, isDisabled: isListeningMessage, tooltipContent: (_c = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _c === void 0 ? void 0 : _c.tooltipContent, isCompact: isCompact }, (_d = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _d === void 0 ? void 0 : _d.props))),
|
178
|
+
!attachMenuProps && hasAttachButton && (React.createElement(AttachButton, Object.assign({ onAttachAccepted: handleAttach, isDisabled: isListeningMessage, tooltipContent: (_e = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _e === void 0 ? void 0 : _e.tooltipContent, inputTestId: (_f = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _f === void 0 ? void 0 : _f.inputTestId, isCompact: isCompact }, (_g = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.attach) === null || _g === void 0 ? void 0 : _g.props))),
|
179
|
+
hasMicrophoneButton && (React.createElement(MicrophoneButton, Object.assign({ isListening: isListeningMessage, onIsListeningChange: setIsListeningMessage, onSpeechRecognition: handleSpeechRecognition, tooltipContent: (_h = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _h === void 0 ? void 0 : _h.tooltipContent, language: (_j = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _j === void 0 ? void 0 : _j.language, isCompact: isCompact }, (_k = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.microphone) === null || _k === void 0 ? void 0 : _k.props))),
|
180
|
+
(alwayShowSendButton || message) && (React.createElement(SendButton, Object.assign({ value: message, onClick: () => handleSend(message), isDisabled: isSendButtonDisabled, tooltipContent: (_l = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.send) === null || _l === void 0 ? void 0 : _l.tooltipContent, isCompact: isCompact }, (_m = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.send) === null || _m === void 0 ? void 0 : _m.props)))));
|
180
181
|
};
|
181
182
|
const messageBarContents = (React.createElement(React.Fragment, null,
|
182
|
-
React.createElement("div", { className:
|
183
|
+
React.createElement("div", { className: `pf-chatbot__message-bar-input ${isCompact ? 'pf-m-compact' : ''}` },
|
183
184
|
React.createElement(TextArea, Object.assign({ className: "pf-chatbot__message-textarea", value: message, onChange: handleChange, "aria-label": isListeningMessage ? listeningText : placeholder, placeholder: isListeningMessage ? listeningText : placeholder, ref: textareaRef, onKeyDown: handleKeyDown }, props))),
|
184
185
|
React.createElement("div", { className: "pf-chatbot__message-bar-actions" }, renderButtons())));
|
185
186
|
if (attachMenuProps) {
|
@@ -18,6 +18,7 @@ export interface MicrophoneButtonProps extends ButtonProps {
|
|
18
18
|
};
|
19
19
|
/** Locale code for language speech recognition is conducted in. This should be in the format 'en-US', a.k.a. the ISO 639-1 code, a dash, and the ISO_3166-1 code. */
|
20
20
|
language?: string;
|
21
|
+
isCompact?: boolean;
|
21
22
|
}
|
22
23
|
export declare const MicrophoneButton: React.FunctionComponent<MicrophoneButtonProps>;
|
23
24
|
export default MicrophoneButton;
|
@@ -18,7 +18,7 @@ import { Button, Tooltip, Icon } from '@patternfly/react-core';
|
|
18
18
|
// Import FontAwesome icons
|
19
19
|
import { MicrophoneIcon } from '@patternfly/react-icons/dist/esm/icons/microphone-icon';
|
20
20
|
export const MicrophoneButton = (_a) => {
|
21
|
-
var { isListening, onIsListeningChange, onSpeechRecognition, className, tooltipProps, tooltipContent = { active: 'Stop listening', inactive: 'Use microphone' }, language = 'en-US' } = _a, props = __rest(_a, ["isListening", "onIsListeningChange", "onSpeechRecognition", "className", "tooltipProps", "tooltipContent", "language"]);
|
21
|
+
var { isListening, onIsListeningChange, onSpeechRecognition, className, tooltipProps, tooltipContent = { active: 'Stop listening', inactive: 'Use microphone' }, language = 'en-US', isCompact } = _a, props = __rest(_a, ["isListening", "onIsListeningChange", "onSpeechRecognition", "className", "tooltipProps", "tooltipContent", "language", "isCompact"]);
|
22
22
|
// Microphone
|
23
23
|
// --------------------------------------------------------------------------
|
24
24
|
const [speechRecognition, setSpeechRecognition] = React.useState();
|
@@ -63,7 +63,7 @@ export const MicrophoneButton = (_a) => {
|
|
63
63
|
return null;
|
64
64
|
}
|
65
65
|
return (React.createElement(Tooltip, Object.assign({ aria: "none", "aria-live": "polite", id: "pf-chatbot__tooltip--use-microphone", content: isListening ? tooltipContent.active : tooltipContent.inactive, position: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.position) || 'top', entryDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.entryDelay) || 0, exitDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.exitDelay) || 0, distance: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.distance) || 8, animationDuration: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.animationDuration) || 0 }, tooltipProps),
|
66
|
-
React.createElement(Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--microphone ${isListening ? 'pf-chatbot__button--microphone--active' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Microphone button', onClick: isListening ? stopListening : startListening, icon: React.createElement(Icon, { iconSize:
|
67
|
-
React.createElement(MicrophoneIcon, null)) }, props))));
|
66
|
+
React.createElement(Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--microphone ${isListening ? 'pf-chatbot__button--microphone--active' : ''} ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Microphone button', onClick: isListening ? stopListening : startListening, icon: React.createElement(Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
|
67
|
+
React.createElement(MicrophoneIcon, null)), size: isCompact ? 'sm' : undefined }, props))));
|
68
68
|
};
|
69
69
|
export default MicrophoneButton;
|
@@ -9,6 +9,7 @@ export interface SendButtonProps extends ButtonProps {
|
|
9
9
|
tooltipProps?: Omit<TooltipProps, 'content'>;
|
10
10
|
/** English text "Send" used in the tooltip */
|
11
11
|
tooltipContent?: string;
|
12
|
+
isCompact?: boolean;
|
12
13
|
}
|
13
14
|
export declare const SendButton: React.FunctionComponent<SendButtonProps>;
|
14
15
|
export default SendButton;
|
@@ -17,11 +17,11 @@ import React from 'react';
|
|
17
17
|
import { Button, Tooltip, Icon } from '@patternfly/react-core';
|
18
18
|
import { PaperPlaneIcon } from '@patternfly/react-icons/dist/esm/icons/paper-plane-icon';
|
19
19
|
export const SendButton = (_a) => {
|
20
|
-
var { className, onClick, tooltipProps, tooltipContent = 'Send' } = _a, props = __rest(_a, ["className", "onClick", "tooltipProps", "tooltipContent"]);
|
20
|
+
var { className, onClick, tooltipProps, tooltipContent = 'Send', isCompact } = _a, props = __rest(_a, ["className", "onClick", "tooltipProps", "tooltipContent", "isCompact"]);
|
21
21
|
return (React.createElement(Tooltip, Object.assign({ id: "pf-chatbot__tooltip--send", content: tooltipContent, position: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.position) || 'top', entryDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.entryDelay) || 0, exitDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.exitDelay) || 0, distance: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.distance) || 8, animationDuration: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.animationDuration) || 0,
|
22
22
|
// prevents VO announcements of both aria label and tooltip
|
23
23
|
aria: "none" }, tooltipProps),
|
24
|
-
React.createElement(Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--send ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Send button', onClick: onClick, icon: React.createElement(Icon, { iconSize:
|
25
|
-
React.createElement(PaperPlaneIcon, null)) }, props))));
|
24
|
+
React.createElement(Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--send ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Send button', onClick: onClick, icon: React.createElement(Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
|
25
|
+
React.createElement(PaperPlaneIcon, null)), size: isCompact ? 'sm' : undefined }, props))));
|
26
26
|
};
|
27
27
|
export default SendButton;
|
@@ -46,4 +46,8 @@ describe('Send button', () => {
|
|
46
46
|
yield userEvent.click(screen.getByRole('button', { name: 'Send button' }));
|
47
47
|
expect(screen.getByRole('tooltip', { name: 'Send' })).toHaveAttribute('id', 'test');
|
48
48
|
}));
|
49
|
+
it('should handle isCompact', () => {
|
50
|
+
renderSend({ 'data-testid': 'button', isCompact: true });
|
51
|
+
expect(screen.getByTestId('button')).toHaveClass('pf-m-compact');
|
52
|
+
});
|
49
53
|
});
|
@@ -9,6 +9,7 @@ export interface StopButtonProps extends ButtonProps {
|
|
9
9
|
tooltipProps?: Omit<TooltipProps, 'content'>;
|
10
10
|
/** English text "Stop" used in the tooltip */
|
11
11
|
tooltipContent?: string;
|
12
|
+
isCompact?: boolean;
|
12
13
|
}
|
13
14
|
export declare const StopButton: React.FunctionComponent<StopButtonProps>;
|
14
15
|
export default StopButton;
|
@@ -16,12 +16,12 @@ import React from 'react';
|
|
16
16
|
// Import PatternFly components
|
17
17
|
import { Button, Tooltip, Icon } from '@patternfly/react-core';
|
18
18
|
export const StopButton = (_a) => {
|
19
|
-
var { className, onClick, tooltipProps, tooltipContent = 'Stop' } = _a, props = __rest(_a, ["className", "onClick", "tooltipProps", "tooltipContent"]);
|
19
|
+
var { className, onClick, tooltipProps, tooltipContent = 'Stop', isCompact } = _a, props = __rest(_a, ["className", "onClick", "tooltipProps", "tooltipContent", "isCompact"]);
|
20
20
|
return (React.createElement(Tooltip, Object.assign({ id: "pf-chatbot__tooltip--stop", content: tooltipContent, position: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.position) || 'top', entryDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.entryDelay) || 0, exitDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.exitDelay) || 0, distance: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.distance) || 8, animationDuration: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.animationDuration) || 0,
|
21
21
|
// prevents VO announcements of both aria label and tooltip
|
22
22
|
aria: "none" }, tooltipProps),
|
23
|
-
React.createElement(Button, Object.assign({ className: `pf-chatbot__button--stop ${className !== null && className !== void 0 ? className : ''}`, variant: "link", "aria-label": props['aria-label'] || 'Stop button', onClick: onClick, icon: React.createElement(Icon, { iconSize:
|
23
|
+
React.createElement(Button, Object.assign({ className: `pf-chatbot__button--stop ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, variant: "link", "aria-label": props['aria-label'] || 'Stop button', onClick: onClick, icon: React.createElement(Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
|
24
24
|
React.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
25
|
-
React.createElement("path", { d: "M0.5 3C0.5 1.62109 1.62109 0.5 3 0.5H13C14.3789 0.5 15.5 1.62109 15.5 3V13C15.5 14.3789 14.3789 15.5 13 15.5H3C1.62109 15.5 0.5 14.3789 0.5 13V3Z", fill: "currentColor" }))) }, props))));
|
25
|
+
React.createElement("path", { d: "M0.5 3C0.5 1.62109 1.62109 0.5 3 0.5H13C14.3789 0.5 15.5 1.62109 15.5 3V13C15.5 14.3789 14.3789 15.5 13 15.5H3C1.62109 15.5 0.5 14.3789 0.5 13V3Z", fill: "currentColor" }))), size: isCompact ? 'sm' : undefined }, props))));
|
26
26
|
};
|
27
27
|
export default StopButton;
|
@@ -46,4 +46,8 @@ describe('Stop button', () => {
|
|
46
46
|
yield userEvent.click(screen.getByRole('button', { name: 'Stop button' }));
|
47
47
|
expect(screen.getByRole('tooltip', { name: 'Stop' })).toHaveAttribute('id', 'test');
|
48
48
|
}));
|
49
|
+
it('should handle isCompact', () => {
|
50
|
+
renderStop({ 'data-testid': 'button', isCompact: true });
|
51
|
+
expect(screen.getByTestId('button')).toHaveClass('pf-m-compact');
|
52
|
+
});
|
49
53
|
});
|
@@ -17,7 +17,7 @@ import React from 'react';
|
|
17
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, 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"]);
|
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', isCompact } = _a, props = __rest(_a, ["className", "isDisabled", "paginationAriaLabel", "sources", "sourceWord", "sourceWordPlural", "toNextPageAriaLabel", "toPreviousPageAriaLabel", "onNextClick", "onPreviousClick", "onSetPage", "showMoreWords", "showLessWords", "isCompact"]);
|
21
21
|
const [page, setPage] = React.useState(1);
|
22
22
|
const [isExpanded, setIsExpanded] = React.useState(false);
|
23
23
|
const onToggle = (_event, isExpanded) => {
|
@@ -35,7 +35,7 @@ const SourcesCard = (_a) => {
|
|
35
35
|
};
|
36
36
|
return (React.createElement("div", { className: "pf-chatbot__source" },
|
37
37
|
React.createElement("span", null, pluralize(sources.length, sourceWord, sourceWordPlural)),
|
38
|
-
React.createElement(Card, Object.assign({ className: "pf-chatbot__sources-card" }, props),
|
38
|
+
React.createElement(Card, Object.assign({ isCompact: isCompact, className: "pf-chatbot__sources-card" }, props),
|
39
39
|
React.createElement(CardTitle, { className: "pf-chatbot__sources-card-title" },
|
40
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))),
|
41
41
|
sources[page - 1].body && (React.createElement(CardBody, { className: `pf-chatbot__sources-card-body` }, sources[page - 1].hasShowMore ? (
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@patternfly/chatbot",
|
3
|
-
"version": "6.3.0-prerelease.
|
3
|
+
"version": "6.3.0-prerelease.8",
|
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",
|
package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx
CHANGED
@@ -50,5 +50,29 @@ export const MessageWithQuickResponsesExample: React.FunctionComponent = () => (
|
|
50
50
|
{ id: '2', content: 'No', onClick: () => alert('Clicked no') }
|
51
51
|
]}
|
52
52
|
/>
|
53
|
+
<Message
|
54
|
+
name="Bot"
|
55
|
+
role="bot"
|
56
|
+
avatar={patternflyAvatar}
|
57
|
+
content="Welcome back, User! How can I help you today?"
|
58
|
+
quickResponses={[
|
59
|
+
{ id: '1', content: 'Help me with an access issue', onClick: () => alert('Clicked id 1') },
|
60
|
+
{ id: '2', content: 'Show my critical vulnerabilities', onClick: () => alert('Clicked id 2') },
|
61
|
+
{ id: '3', content: 'Create new integrations', onClick: () => alert('Clicked id 3') },
|
62
|
+
{ id: '4', content: 'Get recommendations from an advisor', onClick: () => alert('Clicked id 4') },
|
63
|
+
{ id: '5', content: 'Something else', onClick: () => alert('Clicked id 5') }
|
64
|
+
]}
|
65
|
+
/>
|
66
|
+
<Message
|
67
|
+
name="Bot"
|
68
|
+
role="bot"
|
69
|
+
avatar={patternflyAvatar}
|
70
|
+
content="Example with compact responses"
|
71
|
+
quickResponses={[
|
72
|
+
{ id: '1', content: 'Yes', onClick: () => alert('Clicked id 1') },
|
73
|
+
{ id: '2', content: 'No', onClick: () => alert('Clicked id 2') }
|
74
|
+
]}
|
75
|
+
isCompact
|
76
|
+
/>
|
53
77
|
</>
|
54
78
|
);
|
package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickStart.tsx
CHANGED
@@ -27,5 +27,16 @@ export const MessageWithQuickStartExample: React.FunctionComponent = () => (
|
|
27
27
|
onSelectQuickStart: (id) => alert(id)
|
28
28
|
}}
|
29
29
|
/>
|
30
|
+
<Message
|
31
|
+
name="Bot"
|
32
|
+
role="bot"
|
33
|
+
avatar={patternflyAvatar}
|
34
|
+
content="This quick start tile is compact"
|
35
|
+
quickStarts={{
|
36
|
+
quickStart: monitorSampleAppQuickStart,
|
37
|
+
onSelectQuickStart: (id) => alert(id)
|
38
|
+
}}
|
39
|
+
isCompact
|
40
|
+
/>
|
30
41
|
</>
|
31
42
|
);
|
@@ -150,6 +150,27 @@ export const MessageWithSourcesExample: React.FunctionComponent = () => {
|
|
150
150
|
onSetPage
|
151
151
|
}}
|
152
152
|
/>
|
153
|
+
<Message
|
154
|
+
name="Bot"
|
155
|
+
role="bot"
|
156
|
+
avatar={patternflyAvatar}
|
157
|
+
content="This example displays a compact sources card"
|
158
|
+
sources={{
|
159
|
+
sources: [
|
160
|
+
{
|
161
|
+
link: '#'
|
162
|
+
},
|
163
|
+
{
|
164
|
+
link: '#'
|
165
|
+
},
|
166
|
+
{
|
167
|
+
link: '#'
|
168
|
+
}
|
169
|
+
],
|
170
|
+
onSetPage
|
171
|
+
}}
|
172
|
+
isCompact
|
173
|
+
/>
|
153
174
|
</>
|
154
175
|
);
|
155
176
|
};
|
@@ -59,7 +59,6 @@ import userAvatar from '../Messages/user_avatar.svg';
|
|
59
59
|
import patternflyAvatar from '../Messages/patternfly_avatar.jpg';
|
60
60
|
import { getTrackingProviders } from "@patternfly/chatbot/dist/dynamic/tracking";
|
61
61
|
|
62
|
-
|
63
62
|
### Basic ChatBot
|
64
63
|
|
65
64
|
This demo displays a basic ChatBot, which includes:
|
@@ -87,6 +86,14 @@ This demo displays a basic ChatBot, which includes:
|
|
87
86
|
|
88
87
|
```
|
89
88
|
|
89
|
+
### Compact ChatBot
|
90
|
+
|
91
|
+
This demo displays a basic compact ChatBot
|
92
|
+
|
93
|
+
```js file="./ChatbotCompact.tsx" isFullscreen
|
94
|
+
|
95
|
+
```
|
96
|
+
|
90
97
|
### Embedded ChatBot
|
91
98
|
|
92
99
|
This demo displays an embedded ChatBot. Embedded ChatBots are meant to be placed within a page in your product. This demo includes:
|