@patternfly/chatbot 6.3.0-prerelease.2 → 6.3.0-prerelease.4
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/AttachmentEdit/AttachmentEdit.d.ts +2 -0
- package/dist/cjs/AttachmentEdit/AttachmentEdit.js +2 -2
- package/dist/cjs/Chatbot/Chatbot.d.ts +2 -0
- package/dist/cjs/Chatbot/Chatbot.js +2 -2
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +2 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +2 -2
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +4 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeader.js +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.d.ts +4 -2
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.js +20 -6
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.js +5 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.js +1 -1
- package/dist/cjs/ChatbotModal/ChatbotModal.d.ts +3 -0
- package/dist/cjs/ChatbotModal/ChatbotModal.js +2 -2
- package/dist/cjs/ChatbotModal/ChatbotModal.test.d.ts +1 -0
- package/dist/cjs/ChatbotModal/ChatbotModal.test.js +28 -0
- package/dist/cjs/CodeModal/CodeModal.d.ts +2 -0
- package/dist/cjs/CodeModal/CodeModal.js +3 -3
- package/dist/cjs/CodeModal/CodeModal.test.d.ts +1 -0
- package/dist/cjs/CodeModal/CodeModal.test.js +15 -0
- package/dist/cjs/FileDetails/FileDetails.js +1 -1
- package/dist/cjs/PreviewAttachment/PreviewAttachment.d.ts +2 -0
- package/dist/cjs/PreviewAttachment/PreviewAttachment.js +2 -2
- package/dist/cjs/Settings/SettingsForm.d.ts +2 -0
- package/dist/cjs/Settings/SettingsForm.js +2 -2
- package/dist/cjs/Settings/SettingsForm.test.d.ts +1 -1
- package/dist/cjs/Settings/SettingsForm.test.js +12 -0
- package/dist/css/main.css +54 -9
- package/dist/css/main.css.map +1 -1
- package/dist/esm/AttachmentEdit/AttachmentEdit.d.ts +2 -0
- package/dist/esm/AttachmentEdit/AttachmentEdit.js +2 -2
- package/dist/esm/Chatbot/Chatbot.d.ts +2 -0
- package/dist/esm/Chatbot/Chatbot.js +2 -2
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +2 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +2 -2
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +4 -0
- package/dist/esm/ChatbotHeader/ChatbotHeader.js +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.d.ts +4 -2
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.js +20 -6
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.js +5 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMain.js +1 -1
- package/dist/esm/ChatbotModal/ChatbotModal.d.ts +3 -0
- package/dist/esm/ChatbotModal/ChatbotModal.js +2 -2
- package/dist/esm/ChatbotModal/ChatbotModal.test.d.ts +1 -0
- package/dist/esm/ChatbotModal/ChatbotModal.test.js +23 -0
- package/dist/esm/CodeModal/CodeModal.d.ts +2 -0
- package/dist/esm/CodeModal/CodeModal.js +3 -3
- package/dist/esm/CodeModal/CodeModal.test.d.ts +1 -0
- package/dist/esm/CodeModal/CodeModal.test.js +10 -0
- package/dist/esm/FileDetails/FileDetails.js +1 -1
- package/dist/esm/PreviewAttachment/PreviewAttachment.d.ts +2 -0
- package/dist/esm/PreviewAttachment/PreviewAttachment.js +2 -2
- package/dist/esm/Settings/SettingsForm.d.ts +2 -0
- package/dist/esm/Settings/SettingsForm.js +2 -2
- package/dist/esm/Settings/SettingsForm.test.d.ts +1 -1
- package/dist/esm/Settings/SettingsForm.test.js +12 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachmentEdit.tsx +10 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/PreviewAttachment.tsx +10 -1
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +9 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithActions.tsx +9 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithSelection.tsx +11 -2
- package/patternfly-docs/content/extensions/chatbot/examples/UI/CompactSettings.tsx +289 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +7 -0
- package/src/AttachmentEdit/AttachmentEdit.tsx +5 -1
- package/src/Chatbot/Chatbot.scss +7 -0
- package/src/Chatbot/Chatbot.tsx +4 -1
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +28 -2
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +18 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +4 -1
- package/src/ChatbotHeader/ChatbotHeader.scss +8 -0
- package/src/ChatbotHeader/ChatbotHeader.tsx +1 -1
- package/src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx +6 -0
- package/src/ChatbotHeader/ChatbotHeaderCloseButton.tsx +12 -6
- package/src/ChatbotHeader/ChatbotHeaderMain.tsx +3 -1
- package/src/ChatbotModal/ChatbotModal.scss +15 -4
- package/src/ChatbotModal/ChatbotModal.test.tsx +59 -0
- package/src/ChatbotModal/ChatbotModal.tsx +5 -1
- package/src/CodeModal/CodeModal.scss +11 -3
- package/src/CodeModal/CodeModal.test.tsx +24 -0
- package/src/CodeModal/CodeModal.tsx +6 -2
- package/src/FileDetails/FileDetails.tsx +1 -1
- package/src/FileDetails/__snapshots__/FileDetails.test.tsx.snap +1 -1
- package/src/FileDetailsLabel/__snapshots__/FileDetailsLabel.test.tsx.snap +1 -1
- package/src/PreviewAttachment/PreviewAttachment.tsx +5 -1
- package/src/Settings/Settings.scss +11 -0
- package/src/Settings/SettingsForm.test.tsx +17 -0
- package/src/Settings/SettingsForm.tsx +12 -2
@@ -10,7 +10,10 @@ import { ChatbotDisplayMode } from '../Chatbot';
|
|
10
10
|
export interface ChatbotModalProps extends Omit<ModalProps, 'ref'> {
|
11
11
|
/** Display mode for the Chatbot parent; this influences the styles applied */
|
12
12
|
displayMode?: ChatbotDisplayMode;
|
13
|
+
/** Additional className applied to modal */
|
13
14
|
className?: string;
|
15
|
+
/** Sets modal to compact styling. */
|
16
|
+
isCompact?: boolean;
|
14
17
|
}
|
15
18
|
|
16
19
|
export const ChatbotModal: React.FunctionComponent<ChatbotModalProps> = ({
|
@@ -18,6 +21,7 @@ export const ChatbotModal: React.FunctionComponent<ChatbotModalProps> = ({
|
|
18
21
|
displayMode = ChatbotDisplayMode.default,
|
19
22
|
className,
|
20
23
|
isOpen,
|
24
|
+
isCompact,
|
21
25
|
...props
|
22
26
|
}: ChatbotModalProps) => {
|
23
27
|
const modal = (
|
@@ -26,7 +30,7 @@ export const ChatbotModal: React.FunctionComponent<ChatbotModalProps> = ({
|
|
26
30
|
ouiaId="ChatbotModal"
|
27
31
|
aria-labelledby="chatbot-modal-title"
|
28
32
|
aria-describedby="chatbot-modal"
|
29
|
-
className={`pf-chatbot__chatbot-modal pf-chatbot__chatbot-modal--${displayMode} ${className}`}
|
33
|
+
className={`pf-chatbot__chatbot-modal pf-chatbot__chatbot-modal--${displayMode} ${isCompact ? 'pf-m-compact' : ''} ${className}`}
|
30
34
|
backdropClassName="pf-chatbot__chatbot-modal-backdrop"
|
31
35
|
{...props}
|
32
36
|
>
|
@@ -61,8 +61,10 @@
|
|
61
61
|
.pf-v6-c-code-editor__header-main {
|
62
62
|
display: none;
|
63
63
|
}
|
64
|
-
.pf-
|
65
|
-
|
64
|
+
.pf-v6-c-modal-box__close {
|
65
|
+
.pf-v6-c-button.pf-m-plain {
|
66
|
+
--pf-v6-c-button__icon--Color: var(--pf-t--global--icon--color--subtle);
|
67
|
+
}
|
66
68
|
}
|
67
69
|
}
|
68
70
|
|
@@ -78,10 +80,16 @@
|
|
78
80
|
}
|
79
81
|
}
|
80
82
|
|
81
|
-
.pf-chatbot__code-modal-
|
83
|
+
.pf-chatbot__code-modal-editor {
|
82
84
|
flex: 1;
|
83
85
|
}
|
84
86
|
|
85
87
|
.pf-chatbot__code-modal--fullscreen {
|
86
88
|
height: inherit !important; // override shared modal so code editor works in full screen
|
87
89
|
}
|
90
|
+
|
91
|
+
.pf-chatbot__code-modal.pf-m-compact {
|
92
|
+
.pf-chatbot__code-modal-body {
|
93
|
+
gap: var(--pf-t--global--spacer--md);
|
94
|
+
}
|
95
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '@testing-library/react';
|
3
|
+
import '@testing-library/jest-dom';
|
4
|
+
import CodeModal from './CodeModal';
|
5
|
+
|
6
|
+
describe('ChatbotModal', () => {
|
7
|
+
it('should render compact modal', () => {
|
8
|
+
render(
|
9
|
+
<CodeModal
|
10
|
+
isCompact
|
11
|
+
code="Hello world"
|
12
|
+
fileName="greetings.txt"
|
13
|
+
isModalOpen={true}
|
14
|
+
handleModalToggle={jest.fn()}
|
15
|
+
onPrimaryAction={jest.fn()}
|
16
|
+
onSecondaryAction={jest.fn()}
|
17
|
+
title="Preview attachment"
|
18
|
+
primaryActionBtn="Submit"
|
19
|
+
secondaryActionBtn="Cancel"
|
20
|
+
></CodeModal>
|
21
|
+
);
|
22
|
+
expect(screen.getByRole('dialog')).toHaveClass('pf-m-compact');
|
23
|
+
});
|
24
|
+
});
|
@@ -40,6 +40,8 @@ export interface CodeModalProps {
|
|
40
40
|
title: string;
|
41
41
|
/** Display mode for the Chatbot parent; this influences the styles applied */
|
42
42
|
displayMode?: ChatbotDisplayMode;
|
43
|
+
/** Sets modal to compact styling. */
|
44
|
+
isCompact?: boolean;
|
43
45
|
}
|
44
46
|
|
45
47
|
export const CodeModal: React.FunctionComponent<CodeModalProps> = ({
|
@@ -57,6 +59,7 @@ export const CodeModal: React.FunctionComponent<CodeModalProps> = ({
|
|
57
59
|
secondaryActionBtn,
|
58
60
|
title,
|
59
61
|
displayMode = ChatbotDisplayMode.default,
|
62
|
+
isCompact,
|
60
63
|
...props
|
61
64
|
}: CodeModalProps) => {
|
62
65
|
const [newCode, setNewCode] = React.useState(code);
|
@@ -94,8 +97,9 @@ export const CodeModal: React.FunctionComponent<CodeModalProps> = ({
|
|
94
97
|
ouiaId="CodeModal"
|
95
98
|
aria-labelledby="code-modal-title"
|
96
99
|
aria-describedby="code-modal"
|
97
|
-
className={`pf-chatbot__code-modal pf-chatbot__code-modal--${displayMode}`}
|
100
|
+
className={`pf-chatbot__code-modal ${isCompact ? 'pf-m-compact' : ''} pf-chatbot__code-modal--${displayMode}`}
|
98
101
|
displayMode={displayMode}
|
102
|
+
isCompact={isCompact}
|
99
103
|
>
|
100
104
|
<ModalHeader title={title} labelId="code-modal-title" />
|
101
105
|
<ModalBody id="code-modal-body">
|
@@ -103,7 +107,7 @@ export const CodeModal: React.FunctionComponent<CodeModalProps> = ({
|
|
103
107
|
<StackItem className="pf-chatbot__code-modal-file-details">
|
104
108
|
<FileDetails fileName={fileName} />
|
105
109
|
</StackItem>
|
106
|
-
<StackItem className="pf-chatbot__code-modal-
|
110
|
+
<StackItem className="pf-chatbot__code-modal-editor">
|
107
111
|
<CodeEditor
|
108
112
|
isDarkTheme
|
109
113
|
isLineNumbersVisible={isLineNumbersVisible}
|
@@ -946,7 +946,7 @@ export const FileDetails = ({
|
|
946
946
|
}: PropsWithChildren<FileDetailsProps>) => {
|
947
947
|
const language = extensionToLanguage[path.extname(fileName).slice(1)]?.toUpperCase();
|
948
948
|
return (
|
949
|
-
<Flex className={`pf-chatbot__file-details ${className}`} gap={{ default: 'gapSm' }}>
|
949
|
+
<Flex className={`pf-chatbot__file-details ${className ? className : ''}`} gap={{ default: 'gapSm' }}>
|
950
950
|
<Flex
|
951
951
|
className="pf-chatbot__code-icon"
|
952
952
|
justifyContent={{ default: 'justifyContentCenter' }}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
exports[`FileDetails should render file details 1`] = `
|
4
4
|
<div>
|
5
5
|
<div
|
6
|
-
class="pf-v6-l-flex pf-m-gap-sm pf-chatbot__file-details
|
6
|
+
class="pf-v6-l-flex pf-m-gap-sm pf-chatbot__file-details "
|
7
7
|
>
|
8
8
|
<div
|
9
9
|
class="pf-v6-l-flex pf-m-align-items-center pf-m-align-self-center pf-m-justify-content-center pf-chatbot__code-icon"
|
@@ -15,7 +15,7 @@ exports[`FileDetailsLabel should render file details label 1`] = `
|
|
15
15
|
class="pf-chatbot__file-label-contents"
|
16
16
|
>
|
17
17
|
<div
|
18
|
-
class="pf-v6-l-flex pf-m-gap-sm pf-chatbot__file-details
|
18
|
+
class="pf-v6-l-flex pf-m-gap-sm pf-chatbot__file-details "
|
19
19
|
>
|
20
20
|
<div
|
21
21
|
class="pf-v6-l-flex pf-m-align-items-center pf-m-align-self-center pf-m-justify-content-center pf-chatbot__code-icon"
|
@@ -22,6 +22,8 @@ export interface PreviewAttachmentProps {
|
|
22
22
|
title?: string;
|
23
23
|
/** Display mode for the Chatbot parent; this influences the styles applied */
|
24
24
|
displayMode?: ChatbotDisplayMode;
|
25
|
+
/** Sets modal to compact styling. */
|
26
|
+
isCompact?: boolean;
|
25
27
|
}
|
26
28
|
|
27
29
|
export const PreviewAttachment: React.FunctionComponent<PreviewAttachmentProps> = ({
|
@@ -32,7 +34,8 @@ export const PreviewAttachment: React.FunctionComponent<PreviewAttachmentProps>
|
|
32
34
|
onDismiss = undefined,
|
33
35
|
onEdit,
|
34
36
|
title = 'Preview attachment',
|
35
|
-
displayMode = ChatbotDisplayMode.default
|
37
|
+
displayMode = ChatbotDisplayMode.default,
|
38
|
+
isCompact
|
36
39
|
}: PreviewAttachmentProps) => {
|
37
40
|
const handleEdit = (_event: React.MouseEvent | MouseEvent | KeyboardEvent) => {
|
38
41
|
handleModalToggle(_event);
|
@@ -60,6 +63,7 @@ export const PreviewAttachment: React.FunctionComponent<PreviewAttachmentProps>
|
|
60
63
|
title={title}
|
61
64
|
isReadOnly
|
62
65
|
displayMode={displayMode}
|
66
|
+
isCompact={isCompact}
|
63
67
|
/>
|
64
68
|
);
|
65
69
|
};
|
@@ -32,3 +32,14 @@
|
|
32
32
|
font-weight: var(--pf-t--global--font--weight--body--bold);
|
33
33
|
text-align: center;
|
34
34
|
}
|
35
|
+
|
36
|
+
.pf-chatbot__settings-form-container.pf-m-compact {
|
37
|
+
.pf-chatbot__settings-form-row {
|
38
|
+
padding: var(--pf-t--global--spacer--md);
|
39
|
+
font-size: var(--pf-t--global--font--size--body--md);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
.pf-chatbot__header.pf-m-compact {
|
44
|
+
padding-inline-start: var(--pf-t--global--spacer--md);
|
45
|
+
}
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
2
2
|
import { Button } from '@patternfly/react-core';
|
3
3
|
import { render, screen } from '@testing-library/react';
|
4
4
|
import { SettingsForm } from './SettingsForm';
|
5
|
+
import '@testing-library/jest-dom';
|
5
6
|
|
6
7
|
describe('SettingsForm', () => {
|
7
8
|
it('should render settingsForm with custom classname', () => {
|
@@ -25,4 +26,20 @@ describe('SettingsForm', () => {
|
|
25
26
|
|
26
27
|
expect(screen.getByRole('button', { name: 'Archive chat' })).toBeTruthy();
|
27
28
|
});
|
29
|
+
|
30
|
+
it('should render settingsForm with isCompact', () => {
|
31
|
+
const fields = [
|
32
|
+
{
|
33
|
+
id: 'archived-chat',
|
34
|
+
label: 'Archive chat',
|
35
|
+
field: (
|
36
|
+
<Button id="archived-chat" variant="secondary">
|
37
|
+
Archive chat
|
38
|
+
</Button>
|
39
|
+
)
|
40
|
+
}
|
41
|
+
];
|
42
|
+
render(<SettingsForm data-testid="settings-form" fields={fields} isCompact />);
|
43
|
+
expect(screen.getByTestId('settings-form')).toHaveClass('pf-m-compact');
|
44
|
+
});
|
28
45
|
});
|
@@ -5,10 +5,20 @@ export interface SettingsFormProps {
|
|
5
5
|
className?: string;
|
6
6
|
/** Array of fields to display in the settings layout */
|
7
7
|
fields?: { id: string; label: string; field: React.ReactElement }[];
|
8
|
+
/** Sets form to compact styling. */
|
9
|
+
isCompact?: boolean;
|
8
10
|
}
|
9
11
|
|
10
|
-
export const SettingsForm: React.FunctionComponent<SettingsFormProps> = ({
|
11
|
-
|
12
|
+
export const SettingsForm: React.FunctionComponent<SettingsFormProps> = ({
|
13
|
+
className,
|
14
|
+
fields = [],
|
15
|
+
isCompact,
|
16
|
+
...props
|
17
|
+
}) => (
|
18
|
+
<div
|
19
|
+
className={`pf-chatbot__settings-form-container ${isCompact ? 'pf-m-compact' : ''} ${className ? ` ${className}` : ''}`}
|
20
|
+
{...props}
|
21
|
+
>
|
12
22
|
<form className="pf-chatbot__settings-form">
|
13
23
|
{fields.map((field) => (
|
14
24
|
<div className="pf-chatbot__settings-form-row" key={field.label}>
|