@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
@@ -2,6 +2,7 @@ import React from 'react';
|
|
2
2
|
import { DropdownItem } from '@patternfly/react-core';
|
3
3
|
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
4
4
|
import { ChatbotHeaderOptionsDropdown } from './ChatbotHeaderOptionsDropdown';
|
5
|
+
import '@testing-library/jest-dom';
|
5
6
|
|
6
7
|
describe('ChatbotHeaderOptionsDropdown', () => {
|
7
8
|
const dropdownItems = (
|
@@ -42,4 +43,9 @@ describe('ChatbotHeaderOptionsDropdown', () => {
|
|
42
43
|
expect(onSelect).toHaveBeenCalled();
|
43
44
|
});
|
44
45
|
});
|
46
|
+
|
47
|
+
it('should handle isCompact', () => {
|
48
|
+
render(<ChatbotHeaderOptionsDropdown isCompact>{dropdownItems}</ChatbotHeaderOptionsDropdown>);
|
49
|
+
expect(screen.getByRole('button', { name: 'Chatbot options' })).toHaveClass('pf-m-compact');
|
50
|
+
});
|
45
51
|
});
|
@@ -20,6 +20,7 @@ export interface ChatbotHeaderOptionsDropdownProps extends Omit<DropdownProps, '
|
|
20
20
|
tooltipProps?: TooltipProps;
|
21
21
|
/** Aria label for menu toggle */
|
22
22
|
menuToggleAriaLabel?: string;
|
23
|
+
isCompact?: boolean;
|
23
24
|
}
|
24
25
|
|
25
26
|
export const ChatbotHeaderOptionsDropdown: React.FunctionComponent<ChatbotHeaderOptionsDropdownProps> = ({
|
@@ -28,6 +29,7 @@ export const ChatbotHeaderOptionsDropdown: React.FunctionComponent<ChatbotHeader
|
|
28
29
|
onSelect,
|
29
30
|
tooltipProps,
|
30
31
|
menuToggleAriaLabel = 'Chatbot options',
|
32
|
+
isCompact,
|
31
33
|
...props
|
32
34
|
}: ChatbotHeaderOptionsDropdownProps) => {
|
33
35
|
const [isOptionsMenuOpen, setIsOptionsMenuOpen] = React.useState(false);
|
@@ -42,17 +44,18 @@ export const ChatbotHeaderOptionsDropdown: React.FunctionComponent<ChatbotHeader
|
|
42
44
|
{...tooltipProps}
|
43
45
|
>
|
44
46
|
<MenuToggle
|
45
|
-
className=
|
47
|
+
className={`pf-chatbot__button--toggle-options ${isCompact ? 'pf-m-compact' : ''}`}
|
46
48
|
variant="plain"
|
47
49
|
aria-label={menuToggleAriaLabel}
|
48
50
|
ref={toggleRef}
|
49
51
|
icon={
|
50
|
-
<Icon
|
52
|
+
<Icon size={isCompact ? 'lg' : 'xl'} isInline>
|
51
53
|
<EllipsisIcon />
|
52
54
|
</Icon>
|
53
55
|
}
|
54
56
|
isExpanded={isOptionsMenuOpen}
|
55
57
|
onClick={() => setIsOptionsMenuOpen(!isOptionsMenuOpen)}
|
58
|
+
size={isCompact ? 'sm' : undefined}
|
56
59
|
/>
|
57
60
|
</Tooltip>
|
58
61
|
);
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
2
2
|
import { DropdownItem } from '@patternfly/react-core';
|
3
3
|
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
4
4
|
import { ChatbotHeaderSelectorDropdown } from './ChatbotHeaderSelectorDropdown';
|
5
|
+
import '@testing-library/jest-dom';
|
5
6
|
|
6
7
|
describe('ChatbotHeaderSelectorDropdown', () => {
|
7
8
|
const dropdownItems = (
|
@@ -40,4 +41,13 @@ describe('ChatbotHeaderSelectorDropdown', () => {
|
|
40
41
|
expect(onSelect).toHaveBeenCalled();
|
41
42
|
});
|
42
43
|
});
|
44
|
+
|
45
|
+
it('should handle isCompact', () => {
|
46
|
+
render(
|
47
|
+
<ChatbotHeaderSelectorDropdown value="Option 1" isCompact>
|
48
|
+
{dropdownItems}
|
49
|
+
</ChatbotHeaderSelectorDropdown>
|
50
|
+
);
|
51
|
+
expect(screen.getByRole('button', { name: /Select model/i })).toHaveClass('pf-m-compact');
|
52
|
+
});
|
43
53
|
});
|
@@ -15,6 +15,7 @@ export interface ChatbotHeaderSelectorDropdownProps extends Omit<DropdownProps,
|
|
15
15
|
menuToggleAriaLabel?: string;
|
16
16
|
/** Text displayed in Tooltip wrapping the display mode dropdown */
|
17
17
|
tooltipContent?: string;
|
18
|
+
isCompact?: boolean;
|
18
19
|
}
|
19
20
|
|
20
21
|
export const ChatbotHeaderSelectorDropdown: React.FunctionComponent<ChatbotHeaderSelectorDropdownProps> = ({
|
@@ -25,6 +26,7 @@ export const ChatbotHeaderSelectorDropdown: React.FunctionComponent<ChatbotHeade
|
|
25
26
|
tooltipProps,
|
26
27
|
tooltipContent = 'Select model',
|
27
28
|
menuToggleAriaLabel,
|
29
|
+
isCompact,
|
28
30
|
...props
|
29
31
|
}: ChatbotHeaderSelectorDropdownProps) => {
|
30
32
|
const [isOptionsMenuOpen, setIsOptionsMenuOpen] = React.useState(false);
|
@@ -45,6 +47,8 @@ export const ChatbotHeaderSelectorDropdown: React.FunctionComponent<ChatbotHeade
|
|
45
47
|
ref={toggleRef}
|
46
48
|
isExpanded={isOptionsMenuOpen}
|
47
49
|
onClick={() => setIsOptionsMenuOpen(!isOptionsMenuOpen)}
|
50
|
+
size={isCompact ? 'sm' : undefined}
|
51
|
+
className={`${isCompact ? 'pf-m-compact' : ''}`}
|
48
52
|
>
|
49
53
|
{value}
|
50
54
|
</MenuToggle>
|
@@ -2,14 +2,19 @@
|
|
2
2
|
// Chatbot Popover
|
3
3
|
// ============================================================================
|
4
4
|
.pf-chatbot__popover {
|
5
|
-
.pf-v6-c-popover__arrow {
|
5
|
+
.pf-v6-c-popover__arrow {
|
6
|
+
display: none;
|
7
|
+
}
|
6
8
|
|
7
9
|
// Footnote popover
|
8
10
|
&--footnote.pf-chatbot__popover {
|
9
|
-
|
10
11
|
// Contents
|
11
|
-
img {
|
12
|
-
|
12
|
+
img {
|
13
|
+
border-radius: var(--pf-t--global--border--radius--small);
|
14
|
+
}
|
15
|
+
.pf-v6-c-content--h3 {
|
16
|
+
font-weight: var(--pf-t--global--font--weight--body--bold);
|
17
|
+
}
|
13
18
|
.pf-v6-c-content--p {
|
14
19
|
font-size: var(--pf-t--global--font--size--body--lg);
|
15
20
|
}
|
@@ -23,5 +28,4 @@
|
|
23
28
|
font-size: var(--pf-t--global--font--size--body--lg);
|
24
29
|
}
|
25
30
|
}
|
26
|
-
|
27
31
|
}
|
@@ -7,7 +7,7 @@ import React from 'react';
|
|
7
7
|
import { Popover, PopoverProps } from '@patternfly/react-core';
|
8
8
|
|
9
9
|
export const ChatbotPopover: React.FunctionComponent<PopoverProps> = ({ children, className, ...props }) => (
|
10
|
-
<Popover className={`pf-chatbot__popover
|
10
|
+
<Popover className={`pf-chatbot__popover ${className ?? ''}`} showClose={false} {...props}>
|
11
11
|
{children}
|
12
12
|
</Popover>
|
13
13
|
);
|
@@ -8,7 +8,6 @@
|
|
8
8
|
gap: var(--pf-t--global--spacer--lg);
|
9
9
|
|
10
10
|
.pf-v6-c-content--h1 {
|
11
|
-
--pf-v6-c-content--h1--FontSize: var(--pf-t--global--font--size--3xl); // larger than any of our semantic tokens
|
12
11
|
--pf-v6-c-content--h1--FontWeight: var(--pf-t--global--font--weight--400);
|
13
12
|
--pf-v6-c-content--h1--MarginBlockEnd: 0;
|
14
13
|
}
|
@@ -34,6 +33,15 @@
|
|
34
33
|
}
|
35
34
|
}
|
36
35
|
|
36
|
+
.pf-chatbot--layout--welcome.pf-m-compact {
|
37
|
+
gap: var(--pf-t--global--spacer--md);
|
38
|
+
padding-block-end: var(--pf-t--global--spacer--md);
|
39
|
+
|
40
|
+
.pf-chatbot__prompt-suggestions {
|
41
|
+
gap: var(--pf-t--global--spacer--md);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
37
45
|
// ============================================================================
|
38
46
|
// Chatbot Display Mode - Fullscreen and Embedded
|
39
47
|
// ============================================================================
|
@@ -69,4 +69,17 @@ describe('ChatbotWelcomePrompt', () => {
|
|
69
69
|
const element = screen.getByTestId('welcome-prompt');
|
70
70
|
expect(element).toHaveClass('test');
|
71
71
|
});
|
72
|
+
|
73
|
+
it('should handle isCompact', () => {
|
74
|
+
render(
|
75
|
+
<ChatbotWelcomePrompt
|
76
|
+
title="Hi, ChatBot User!"
|
77
|
+
description="How can I help you today?"
|
78
|
+
className="test"
|
79
|
+
testId="welcome-prompt"
|
80
|
+
isCompact
|
81
|
+
/>
|
82
|
+
);
|
83
|
+
expect(screen.getByTestId('welcome-prompt')).toHaveClass('pf-m-compact');
|
84
|
+
});
|
72
85
|
});
|
@@ -16,6 +16,7 @@ export interface ChatbotWelcomePromptProps extends React.HTMLProps<HTMLDivElemen
|
|
16
16
|
className?: string;
|
17
17
|
/** Custom test id for the WelcomePrompt component */
|
18
18
|
testId?: string;
|
19
|
+
isCompact?: boolean;
|
19
20
|
}
|
20
21
|
|
21
22
|
export interface WelcomePrompt {
|
@@ -33,9 +34,14 @@ export const ChatbotWelcomePrompt: React.FunctionComponent<ChatbotWelcomePromptP
|
|
33
34
|
prompts,
|
34
35
|
className,
|
35
36
|
testId,
|
37
|
+
isCompact = false,
|
36
38
|
...props
|
37
39
|
}: ChatbotWelcomePromptProps) => (
|
38
|
-
<div
|
40
|
+
<div
|
41
|
+
data-testid={testId}
|
42
|
+
className={`pf-chatbot--layout--welcome ${isCompact ? 'pf-m-compact' : ''} ${className ?? ''}`}
|
43
|
+
{...props}
|
44
|
+
>
|
39
45
|
<Content component={ContentVariants.h1}>
|
40
46
|
<span className="pf-chatbot__hello">{title}</span>
|
41
47
|
<br />
|
@@ -45,7 +51,12 @@ export const ChatbotWelcomePrompt: React.FunctionComponent<ChatbotWelcomePromptP
|
|
45
51
|
{prompts && (
|
46
52
|
<div className="pf-chatbot__prompt-suggestions">
|
47
53
|
{prompts?.map((prompt, index) => (
|
48
|
-
<Card
|
54
|
+
<Card
|
55
|
+
key={`welcome-prompt-${index}`}
|
56
|
+
className="pf-chatbot__prompt-suggestion"
|
57
|
+
isClickable
|
58
|
+
isCompact={isCompact}
|
59
|
+
>
|
49
60
|
<CardHeader
|
50
61
|
selectableActions={{
|
51
62
|
onClickAction: prompt.onClick,
|
package/src/Message/Message.scss
CHANGED
@@ -104,3 +104,30 @@
|
|
104
104
|
@import './MessageLoading';
|
105
105
|
@import './CodeBlockMessage/CodeBlockMessage';
|
106
106
|
@import './TextMessage/TextMessage';
|
107
|
+
|
108
|
+
// ============================================================================
|
109
|
+
// Information density styles
|
110
|
+
// ============================================================================
|
111
|
+
.pf-chatbot.pf-m-compact {
|
112
|
+
.pf-chatbot__message {
|
113
|
+
gap: var(--pf-t--global--spacer--md);
|
114
|
+
padding-bottom: var(--pf-t--global--spacer--sm);
|
115
|
+
|
116
|
+
.pf-chatbot__message-contents {
|
117
|
+
gap: var(--pf-t--global--spacer--xs);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
.pf-chatbot__message-name {
|
122
|
+
font-size: var(--pf-t--global--font--size--xs);
|
123
|
+
}
|
124
|
+
|
125
|
+
.pf-chatbot__message-avatar.pf-chatbot__message-avatar--round.pf-v6-c-avatar {
|
126
|
+
--pf-v6-c-avatar--Width: 2rem;
|
127
|
+
--pf-v6-c-avatar--Height: 2rem;
|
128
|
+
}
|
129
|
+
|
130
|
+
.pf-chatbot__message-contents {
|
131
|
+
gap: var(--pf-t--global--spacer--xs);
|
132
|
+
}
|
133
|
+
}
|
package/src/Message/Message.tsx
CHANGED
@@ -339,7 +339,7 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
|
|
339
339
|
<div className="pf-chatbot__message-and-actions">
|
340
340
|
{renderMessage()}
|
341
341
|
{afterMainContent && <>{afterMainContent}</>}
|
342
|
-
{!isLoading && sources && <SourcesCard {...sources} />}
|
342
|
+
{!isLoading && sources && <SourcesCard {...sources} isCompact={isCompact} />}
|
343
343
|
{quickStarts && quickStarts.quickStart && (
|
344
344
|
<QuickStartTile
|
345
345
|
quickStart={quickStarts.quickStart}
|
@@ -349,6 +349,7 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
|
|
349
349
|
prerequisiteWord={quickStarts.prerequisiteWord}
|
350
350
|
prerequisiteWordPlural={quickStarts.prerequisiteWordPlural}
|
351
351
|
quickStartButtonAriaLabel={quickStarts.quickStartButtonAriaLabel}
|
352
|
+
isCompact={isCompact}
|
352
353
|
/>
|
353
354
|
)}
|
354
355
|
{!isLoading && actions && <ResponseActions actions={actions} />}
|
@@ -49,6 +49,8 @@ export interface QuickStartTileProps {
|
|
49
49
|
prerequisiteWordPlural?: string;
|
50
50
|
/** Aria-label for the quick start description button */
|
51
51
|
quickStartButtonAriaLabel?: string;
|
52
|
+
/** Sets the tile to compact styling */
|
53
|
+
isCompact?: boolean;
|
52
54
|
}
|
53
55
|
|
54
56
|
const QuickStartTile: React.FC<QuickStartTileProps> = ({
|
@@ -61,7 +63,8 @@ const QuickStartTile: React.FC<QuickStartTileProps> = ({
|
|
61
63
|
prerequisiteWord,
|
62
64
|
prerequisiteWordPlural,
|
63
65
|
quickStartButtonAriaLabel,
|
64
|
-
action
|
66
|
+
action,
|
67
|
+
isCompact
|
65
68
|
}) => {
|
66
69
|
const {
|
67
70
|
metadata: { name: id },
|
@@ -105,6 +108,7 @@ const QuickStartTile: React.FC<QuickStartTileProps> = ({
|
|
105
108
|
id={`${id}-chatbot-qs-tile`}
|
106
109
|
style={{ height: '100%' }}
|
107
110
|
data-testid={`chatbot-qs-card-${camelize(displayName)}`}
|
111
|
+
isCompact={isCompact}
|
108
112
|
>
|
109
113
|
<CardHeader
|
110
114
|
{...(action && {
|
@@ -58,3 +58,28 @@
|
|
58
58
|
}
|
59
59
|
}
|
60
60
|
}
|
61
|
+
|
62
|
+
// ============================================================================
|
63
|
+
// Information density styles
|
64
|
+
// ============================================================================
|
65
|
+
.pf-chatbot.pf-m-compact {
|
66
|
+
// Need to inline shorter text
|
67
|
+
.pf-chatbot__message-text {
|
68
|
+
.pf-v6-c-button.pf-m-link {
|
69
|
+
font-size: var(--pf-t--global--font--size--sm);
|
70
|
+
}
|
71
|
+
|
72
|
+
.pf-v6-c-content,
|
73
|
+
.pf-v6-c-content--small,
|
74
|
+
.pf-v6-c-content--blockquote,
|
75
|
+
p,
|
76
|
+
a {
|
77
|
+
--pf-v6-c-content--FontSize: var(--pf-t--global--font--size--sm);
|
78
|
+
}
|
79
|
+
|
80
|
+
.pf-v6-c-content--blockquote {
|
81
|
+
--pf-v6-c-content--blockquote--PaddingBlockStart: 0;
|
82
|
+
--pf-v6-c-content--blockquote--PaddingBlockEnd: 0;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
@@ -34,3 +34,13 @@
|
|
34
34
|
}
|
35
35
|
}
|
36
36
|
}
|
37
|
+
|
38
|
+
// ============================================================================
|
39
|
+
// Information density styles
|
40
|
+
// ============================================================================
|
41
|
+
.pf-v6-c-button.pf-chatbot__button--attach.pf-m-compact {
|
42
|
+
width: 1.5rem;
|
43
|
+
height: 1.5rem;
|
44
|
+
padding: var(--pf-t--global--spacer--sm);
|
45
|
+
align-items: center;
|
46
|
+
}
|
@@ -50,4 +50,8 @@ describe('Attach button', () => {
|
|
50
50
|
expect(input.files).toHaveLength(1);
|
51
51
|
expect(spy).toHaveBeenCalledTimes(1);
|
52
52
|
});
|
53
|
+
it('should handle isCompact', () => {
|
54
|
+
render(<AttachButton isCompact data-testid="button" />);
|
55
|
+
expect(screen.getByTestId('button')).toHaveClass('pf-m-compact');
|
56
|
+
});
|
53
57
|
});
|
@@ -25,6 +25,7 @@ export interface AttachButtonProps extends ButtonProps {
|
|
25
25
|
tooltipContent?: string;
|
26
26
|
/** Test id applied to input */
|
27
27
|
inputTestId?: string;
|
28
|
+
isCompact?: boolean;
|
28
29
|
}
|
29
30
|
|
30
31
|
const AttachButtonBase: React.FunctionComponent<AttachButtonProps> = ({
|
@@ -36,6 +37,7 @@ const AttachButtonBase: React.FunctionComponent<AttachButtonProps> = ({
|
|
36
37
|
innerRef,
|
37
38
|
tooltipContent = 'Attach',
|
38
39
|
inputTestId,
|
40
|
+
isCompact,
|
39
41
|
...props
|
40
42
|
}: AttachButtonProps) => {
|
41
43
|
const { open, getInputProps } = useDropzone({
|
@@ -62,15 +64,16 @@ const AttachButtonBase: React.FunctionComponent<AttachButtonProps> = ({
|
|
62
64
|
<Button
|
63
65
|
variant="plain"
|
64
66
|
ref={innerRef}
|
65
|
-
className={`pf-chatbot__button--attach ${className ?? ''}`}
|
67
|
+
className={`pf-chatbot__button--attach ${isCompact ? 'pf-m-compact' : ''} ${className ?? ''}`}
|
66
68
|
aria-label={props['aria-label'] || 'Attach button'}
|
67
69
|
isDisabled={isDisabled}
|
68
70
|
onClick={onClick ?? open}
|
69
71
|
icon={
|
70
|
-
<Icon iconSize=
|
72
|
+
<Icon iconSize={isCompact ? 'lg' : 'xl'} isInline>
|
71
73
|
<PaperclipIcon />
|
72
74
|
</Icon>
|
73
75
|
}
|
76
|
+
size={isCompact ? 'sm' : undefined}
|
74
77
|
{...props}
|
75
78
|
/>
|
76
79
|
</Tooltip>
|
@@ -110,3 +110,20 @@
|
|
110
110
|
}
|
111
111
|
}
|
112
112
|
}
|
113
|
+
|
114
|
+
// ============================================================================
|
115
|
+
// Information density styles
|
116
|
+
// ============================================================================
|
117
|
+
.pf-chatbot__message-bar-input.pf-m-compact {
|
118
|
+
padding-block-start: 0;
|
119
|
+
padding-block-end: 0;
|
120
|
+
|
121
|
+
.pf-chatbot__message-textarea {
|
122
|
+
font-size: var(--pf-t--global--font--size--sm) !important;
|
123
|
+
}
|
124
|
+
|
125
|
+
.pf-chatbot__message-bar-actions {
|
126
|
+
padding-block-start: var(--pf-t--global--spacer--md);
|
127
|
+
padding-block-end: var(--pf-t--global--spacer--md);
|
128
|
+
}
|
129
|
+
}
|
@@ -76,6 +76,7 @@ export interface MessageBarProps extends TextAreaProps {
|
|
76
76
|
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>, value: string | number) => void;
|
77
77
|
/** Display mode of chatbot, if you want to message bar to resize when the display mode changes */
|
78
78
|
displayMode?: ChatbotDisplayMode;
|
79
|
+
isCompact?: boolean;
|
79
80
|
}
|
80
81
|
|
81
82
|
export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
|
@@ -95,6 +96,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
|
|
95
96
|
onChange,
|
96
97
|
displayMode,
|
97
98
|
value,
|
99
|
+
isCompact = false,
|
98
100
|
...props
|
99
101
|
}: MessageBarProps) => {
|
100
102
|
// Text Input
|
@@ -105,11 +107,13 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
|
|
105
107
|
const textareaRef = React.useRef<HTMLTextAreaElement>(null);
|
106
108
|
const attachButtonRef = React.useRef<HTMLButtonElement>(null);
|
107
109
|
|
110
|
+
const topMargin = '1rem';
|
111
|
+
|
108
112
|
const setInitialLineHeight = (field: HTMLTextAreaElement) => {
|
109
113
|
field.style.setProperty('line-height', '1rem');
|
110
114
|
const parent = field.parentElement;
|
111
115
|
if (parent) {
|
112
|
-
parent.style.setProperty('margin-top',
|
116
|
+
parent.style.setProperty('margin-top', topMargin);
|
113
117
|
parent.style.setProperty('margin-bottom', `0rem`);
|
114
118
|
parent.style.setProperty('height', 'inherit');
|
115
119
|
|
@@ -135,8 +139,8 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
|
|
135
139
|
parent.style.setProperty('height', `${height}px`);
|
136
140
|
|
137
141
|
if (height > 32 || window.innerWidth <= 507) {
|
138
|
-
parent.style.setProperty('margin-bottom',
|
139
|
-
parent.style.setProperty('margin-top',
|
142
|
+
parent.style.setProperty('margin-bottom', topMargin);
|
143
|
+
parent.style.setProperty('margin-top', topMargin);
|
140
144
|
}
|
141
145
|
}
|
142
146
|
};
|
@@ -160,8 +164,8 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
|
|
160
164
|
const handleNewLine = (field: HTMLTextAreaElement) => {
|
161
165
|
const parent = field.parentElement;
|
162
166
|
if (parent) {
|
163
|
-
parent.style.setProperty('margin-bottom',
|
164
|
-
parent.style.setProperty('margin-top',
|
167
|
+
parent.style.setProperty('margin-bottom', topMargin);
|
168
|
+
parent.style.setProperty('margin-top', topMargin);
|
165
169
|
}
|
166
170
|
};
|
167
171
|
|
@@ -274,6 +278,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
|
|
274
278
|
<StopButton
|
275
279
|
onClick={handleStopButton}
|
276
280
|
tooltipContent={buttonProps?.stop?.tooltipContent}
|
281
|
+
isCompact={isCompact}
|
277
282
|
{...buttonProps?.stop?.props}
|
278
283
|
/>
|
279
284
|
);
|
@@ -286,6 +291,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
|
|
286
291
|
onClick={handleAttachMenuToggle}
|
287
292
|
isDisabled={isListeningMessage}
|
288
293
|
tooltipContent={buttonProps?.attach?.tooltipContent}
|
294
|
+
isCompact={isCompact}
|
289
295
|
{...buttonProps?.attach?.props}
|
290
296
|
/>
|
291
297
|
)}
|
@@ -295,6 +301,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
|
|
295
301
|
isDisabled={isListeningMessage}
|
296
302
|
tooltipContent={buttonProps?.attach?.tooltipContent}
|
297
303
|
inputTestId={buttonProps?.attach?.inputTestId}
|
304
|
+
isCompact={isCompact}
|
298
305
|
{...buttonProps?.attach?.props}
|
299
306
|
/>
|
300
307
|
)}
|
@@ -305,6 +312,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
|
|
305
312
|
onSpeechRecognition={handleSpeechRecognition}
|
306
313
|
tooltipContent={buttonProps?.microphone?.tooltipContent}
|
307
314
|
language={buttonProps?.microphone?.language}
|
315
|
+
isCompact={isCompact}
|
308
316
|
{...buttonProps?.microphone?.props}
|
309
317
|
/>
|
310
318
|
)}
|
@@ -314,6 +322,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
|
|
314
322
|
onClick={() => handleSend(message)}
|
315
323
|
isDisabled={isSendButtonDisabled}
|
316
324
|
tooltipContent={buttonProps?.send?.tooltipContent}
|
325
|
+
isCompact={isCompact}
|
317
326
|
{...buttonProps?.send?.props}
|
318
327
|
/>
|
319
328
|
)}
|
@@ -323,7 +332,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
|
|
323
332
|
|
324
333
|
const messageBarContents = (
|
325
334
|
<>
|
326
|
-
<div className=
|
335
|
+
<div className={`pf-chatbot__message-bar-input ${isCompact ? 'pf-m-compact' : ''}`}>
|
327
336
|
<TextArea
|
328
337
|
className="pf-chatbot__message-textarea"
|
329
338
|
value={message}
|
@@ -46,3 +46,13 @@
|
|
46
46
|
box-shadow: 0 0 0 16px rgba(0, 102, 204, 0);
|
47
47
|
}
|
48
48
|
}
|
49
|
+
|
50
|
+
// ============================================================================
|
51
|
+
// Information density styles
|
52
|
+
// ============================================================================
|
53
|
+
.pf-v6-c-button.pf-chatbot__button--microphone.pf-m-compact {
|
54
|
+
width: 1.5rem;
|
55
|
+
height: 1.5rem;
|
56
|
+
padding: var(--pf-t--global--spacer--sm);
|
57
|
+
align-items: center;
|
58
|
+
}
|
@@ -24,6 +24,7 @@ export interface MicrophoneButtonProps extends ButtonProps {
|
|
24
24
|
tooltipContent?: { active?: string; inactive?: string };
|
25
25
|
/** 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. */
|
26
26
|
language?: string;
|
27
|
+
isCompact?: boolean;
|
27
28
|
}
|
28
29
|
|
29
30
|
export const MicrophoneButton: React.FunctionComponent<MicrophoneButtonProps> = ({
|
@@ -34,6 +35,7 @@ export const MicrophoneButton: React.FunctionComponent<MicrophoneButtonProps> =
|
|
34
35
|
tooltipProps,
|
35
36
|
tooltipContent = { active: 'Stop listening', inactive: 'Use microphone' },
|
36
37
|
language = 'en-US',
|
38
|
+
isCompact,
|
37
39
|
...props
|
38
40
|
}: MicrophoneButtonProps) => {
|
39
41
|
// Microphone
|
@@ -102,14 +104,15 @@ export const MicrophoneButton: React.FunctionComponent<MicrophoneButtonProps> =
|
|
102
104
|
>
|
103
105
|
<Button
|
104
106
|
variant="plain"
|
105
|
-
className={`pf-chatbot__button--microphone ${isListening ? 'pf-chatbot__button--microphone--active' : ''} ${className ?? ''}`}
|
107
|
+
className={`pf-chatbot__button--microphone ${isListening ? 'pf-chatbot__button--microphone--active' : ''} ${isCompact ? 'pf-m-compact' : ''} ${className ?? ''}`}
|
106
108
|
aria-label={props['aria-label'] || 'Microphone button'}
|
107
109
|
onClick={isListening ? stopListening : startListening}
|
108
110
|
icon={
|
109
|
-
<Icon iconSize=
|
111
|
+
<Icon iconSize={isCompact ? 'lg' : 'xl'} isInline>
|
110
112
|
<MicrophoneIcon />
|
111
113
|
</Icon>
|
112
114
|
}
|
115
|
+
size={isCompact ? 'sm' : undefined}
|
113
116
|
{...props}
|
114
117
|
/>
|
115
118
|
</Tooltip>
|
@@ -51,3 +51,13 @@
|
|
51
51
|
transform: translate3d(0, 0, 0);
|
52
52
|
}
|
53
53
|
}
|
54
|
+
|
55
|
+
// ============================================================================
|
56
|
+
// Information density styles
|
57
|
+
// ============================================================================
|
58
|
+
.pf-v6-c-button.pf-chatbot__button--send.pf-m-compact {
|
59
|
+
width: 1.5rem;
|
60
|
+
height: 1.5rem;
|
61
|
+
padding: var(--pf-t--global--spacer--sm);
|
62
|
+
align-items: center;
|
63
|
+
}
|
@@ -5,7 +5,7 @@ import userEvent from '@testing-library/user-event';
|
|
5
5
|
import { SendButton } from './SendButton';
|
6
6
|
import { TooltipProps } from '@patternfly/react-core';
|
7
7
|
|
8
|
-
const renderSend = (props?: { [key: string]: string | Omit<TooltipProps, 'content'> }) => {
|
8
|
+
const renderSend = (props?: { [key: string]: string | boolean | Omit<TooltipProps, 'content'> }) => {
|
9
9
|
const spy = jest.fn();
|
10
10
|
render(<SendButton onClick={spy} {...props} />);
|
11
11
|
};
|
@@ -40,4 +40,8 @@ describe('Send button', () => {
|
|
40
40
|
await userEvent.click(screen.getByRole('button', { name: 'Send button' }));
|
41
41
|
expect(screen.getByRole('tooltip', { name: 'Send' })).toHaveAttribute('id', 'test');
|
42
42
|
});
|
43
|
+
it('should handle isCompact', () => {
|
44
|
+
renderSend({ 'data-testid': 'button', isCompact: true });
|
45
|
+
expect(screen.getByTestId('button')).toHaveClass('pf-m-compact');
|
46
|
+
});
|
43
47
|
});
|
@@ -17,6 +17,7 @@ export interface SendButtonProps extends ButtonProps {
|
|
17
17
|
tooltipProps?: Omit<TooltipProps, 'content'>;
|
18
18
|
/** English text "Send" used in the tooltip */
|
19
19
|
tooltipContent?: string;
|
20
|
+
isCompact?: boolean;
|
20
21
|
}
|
21
22
|
|
22
23
|
export const SendButton: React.FunctionComponent<SendButtonProps> = ({
|
@@ -24,6 +25,7 @@ export const SendButton: React.FunctionComponent<SendButtonProps> = ({
|
|
24
25
|
onClick,
|
25
26
|
tooltipProps,
|
26
27
|
tooltipContent = 'Send',
|
28
|
+
isCompact,
|
27
29
|
...props
|
28
30
|
}: SendButtonProps) => (
|
29
31
|
<Tooltip
|
@@ -40,14 +42,15 @@ export const SendButton: React.FunctionComponent<SendButtonProps> = ({
|
|
40
42
|
>
|
41
43
|
<Button
|
42
44
|
variant="plain"
|
43
|
-
className={`pf-chatbot__button--send ${className ?? ''}`}
|
45
|
+
className={`pf-chatbot__button--send ${isCompact ? 'pf-m-compact' : ''} ${className ?? ''}`}
|
44
46
|
aria-label={props['aria-label'] || 'Send button'}
|
45
47
|
onClick={onClick}
|
46
48
|
icon={
|
47
|
-
<Icon iconSize=
|
49
|
+
<Icon iconSize={isCompact ? 'lg' : 'xl'} isInline>
|
48
50
|
<PaperPlaneIcon />
|
49
51
|
</Icon>
|
50
52
|
}
|
53
|
+
size={isCompact ? 'sm' : undefined}
|
51
54
|
{...props}
|
52
55
|
/>
|
53
56
|
</Tooltip>
|
@@ -34,3 +34,13 @@
|
|
34
34
|
}
|
35
35
|
}
|
36
36
|
}
|
37
|
+
|
38
|
+
// ============================================================================
|
39
|
+
// Information density styles
|
40
|
+
// ============================================================================
|
41
|
+
.pf-v6-c-button.pf-chatbot__button--stop.pf-m-compact {
|
42
|
+
width: 1.5rem;
|
43
|
+
height: 1.5rem;
|
44
|
+
padding: var(--pf-t--global--spacer--sm);
|
45
|
+
align-items: center;
|
46
|
+
}
|