@patternfly/chatbot 2.2.0-prerelease.10 → 2.2.0-prerelease.11
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/ChatbotConversationHistoryNav.d.ts +15 -1
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +8 -8
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +36 -0
- package/dist/cjs/Compare/Compare.d.ts +17 -0
- package/dist/cjs/Compare/Compare.js +50 -0
- package/dist/cjs/Compare/Compare.test.d.ts +1 -0
- package/dist/cjs/Compare/Compare.test.js +20 -0
- package/dist/cjs/Compare/index.d.ts +2 -0
- package/dist/cjs/Compare/index.js +23 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +4 -1
- package/dist/css/main.css +75 -0
- package/dist/css/main.css.map +1 -1
- package/dist/dynamic/Compare/package.json +1 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +15 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +8 -8
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +36 -0
- package/dist/esm/Compare/Compare.d.ts +17 -0
- package/dist/esm/Compare/Compare.js +43 -0
- package/dist/esm/Compare/Compare.test.d.ts +1 -0
- package/dist/esm/Compare/Compare.test.js +15 -0
- package/dist/esm/Compare/index.d.ts +2 -0
- package/dist/esm/Compare/index.js +2 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerResizable.tsx +94 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +10 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +24 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedComparisonChatbot.tsx +206 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +109 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +36 -7
- package/src/Compare/Compare.scss +72 -0
- package/src/Compare/Compare.test.tsx +31 -0
- package/src/Compare/Compare.tsx +98 -0
- package/src/Compare/index.ts +2 -0
- package/src/index.ts +3 -0
- package/src/main.scss +1 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
.pf-chatbot__compare-container {
|
2
|
+
display: flex;
|
3
|
+
flex-direction: column;
|
4
|
+
position: relative;
|
5
|
+
height: 100%;
|
6
|
+
}
|
7
|
+
.pf-chatbot__compare-toggle {
|
8
|
+
width: 100%;
|
9
|
+
|
10
|
+
.pf-v6-c-toggle-group__button {
|
11
|
+
width: 100%;
|
12
|
+
display: flex;
|
13
|
+
justify-content: center;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
.pf-chatbot__compare {
|
17
|
+
display: flex;
|
18
|
+
height: 100%;
|
19
|
+
width: 100%;
|
20
|
+
|
21
|
+
@media screen and (max-width: 900px) {
|
22
|
+
overflow-y: auto;
|
23
|
+
}
|
24
|
+
|
25
|
+
.pf-chatbot__compare-item:first-of-type {
|
26
|
+
border-right: 1px solid var(--pf-t--global--border--color--default);
|
27
|
+
|
28
|
+
@media screen and (max-width: 900px) {
|
29
|
+
border-right: 0px;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
.pf-chatbot__compare-item {
|
35
|
+
flex: 1;
|
36
|
+
|
37
|
+
.pf-chatbot--embedded .pf-chatbot__messagebox {
|
38
|
+
width: 100%;
|
39
|
+
}
|
40
|
+
|
41
|
+
.pf-chatbot__content {
|
42
|
+
padding: 0;
|
43
|
+
}
|
44
|
+
|
45
|
+
.pf-chatbot.pf-chatbot--embedded {
|
46
|
+
@media screen and (max-width: 900px) {
|
47
|
+
height: 100%;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
.pf-chatbot__compare-item-hidden {
|
52
|
+
display: block;
|
53
|
+
|
54
|
+
@media screen and (max-width: 900px) {
|
55
|
+
display: none;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
.pf-chatbot__compare-mobile-controls {
|
60
|
+
padding: var(--pf-t--global--spacer--md) var(--pf-t--global--spacer--lg) 0 var(--pf-t--global--spacer--lg);
|
61
|
+
display: none;
|
62
|
+
background-color: var(--pf-t--global--background--color--secondary--default);
|
63
|
+
position: sticky;
|
64
|
+
top: 0;
|
65
|
+
z-index: 9999;
|
66
|
+
|
67
|
+
@media screen and (max-width: 900px) {
|
68
|
+
display: flex;
|
69
|
+
flex-direction: column;
|
70
|
+
gap: var(--pf-t--global--spacer--md);
|
71
|
+
}
|
72
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '@testing-library/react';
|
3
|
+
import '@testing-library/jest-dom';
|
4
|
+
import Compare from './Compare';
|
5
|
+
|
6
|
+
const firstChild = (
|
7
|
+
<div>
|
8
|
+
<h1>Child 1</h1>
|
9
|
+
</div>
|
10
|
+
);
|
11
|
+
|
12
|
+
const secondChild = (
|
13
|
+
<div>
|
14
|
+
<h1>Child 2</h1>
|
15
|
+
</div>
|
16
|
+
);
|
17
|
+
|
18
|
+
describe('Compare', () => {
|
19
|
+
it('should render compare correctly', () => {
|
20
|
+
render(
|
21
|
+
<Compare
|
22
|
+
firstChildDisplayName="Child 1"
|
23
|
+
secondChildDisplayName="Child 2"
|
24
|
+
firstChild={firstChild}
|
25
|
+
secondChild={secondChild}
|
26
|
+
/>
|
27
|
+
);
|
28
|
+
expect(screen.getByRole('heading', { name: /Child 1/i })).toBeTruthy();
|
29
|
+
expect(screen.getByRole('heading', { name: /Child 2/i })).toBeTruthy();
|
30
|
+
});
|
31
|
+
});
|
@@ -0,0 +1,98 @@
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
2
|
+
import { ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
|
3
|
+
|
4
|
+
interface CompareProps {
|
5
|
+
/** First of two children to render */
|
6
|
+
firstChild: React.ReactNode;
|
7
|
+
/** Second of two children to render */
|
8
|
+
secondChild: React.ReactNode;
|
9
|
+
/** Display name for first child, used in mobile toggle */
|
10
|
+
firstChildDisplayName: string;
|
11
|
+
/** Display name for second child, used in mobile toggle */
|
12
|
+
secondChildDisplayName: string;
|
13
|
+
/** Aria label for mobile toggle group */
|
14
|
+
toggleGroupAriaLabel?: string;
|
15
|
+
/** Callback for when mobile toggle is used */
|
16
|
+
onToggleClick?: (event: MouseEvent | React.MouseEvent<any, MouseEvent> | React.KeyboardEvent<Element>) => void;
|
17
|
+
}
|
18
|
+
|
19
|
+
export const Compare = ({
|
20
|
+
firstChild,
|
21
|
+
secondChild,
|
22
|
+
firstChildDisplayName,
|
23
|
+
secondChildDisplayName,
|
24
|
+
onToggleClick,
|
25
|
+
toggleGroupAriaLabel = 'Select which chatbot to display'
|
26
|
+
}: PropsWithChildren<CompareProps>) => {
|
27
|
+
const [isSelected, setIsSelected] = React.useState('toggle-group-chatbot-1');
|
28
|
+
const [showFirstChatbot, setShowFirstChatbot] = React.useState(true);
|
29
|
+
const [showSecondChatbot, setShowSecondChatbot] = React.useState(false);
|
30
|
+
|
31
|
+
React.useEffect(() => {
|
32
|
+
// we want to show the first if we switch to the mobile toggle view
|
33
|
+
// and reset/switch back to normal otherwise
|
34
|
+
const updateChatbotVisibility = () => {
|
35
|
+
if (window.innerWidth >= 901) {
|
36
|
+
setShowFirstChatbot(true);
|
37
|
+
setShowSecondChatbot(true);
|
38
|
+
} else {
|
39
|
+
setShowFirstChatbot(true);
|
40
|
+
setShowSecondChatbot(false);
|
41
|
+
setIsSelected('toggle-group-chatbot-1');
|
42
|
+
}
|
43
|
+
};
|
44
|
+
window.addEventListener('resize', updateChatbotVisibility);
|
45
|
+
|
46
|
+
return () => {
|
47
|
+
window.removeEventListener('resize', updateChatbotVisibility);
|
48
|
+
};
|
49
|
+
}, []);
|
50
|
+
|
51
|
+
// this only happens on mobile
|
52
|
+
const handleChildToggleClick = (
|
53
|
+
event: MouseEvent | React.MouseEvent<any, MouseEvent> | React.KeyboardEvent<Element>
|
54
|
+
) => {
|
55
|
+
const id = event.currentTarget.id;
|
56
|
+
setIsSelected(id);
|
57
|
+
setShowSecondChatbot(!showSecondChatbot);
|
58
|
+
setShowFirstChatbot(!showFirstChatbot);
|
59
|
+
onToggleClick && onToggleClick(event);
|
60
|
+
};
|
61
|
+
|
62
|
+
return (
|
63
|
+
<>
|
64
|
+
<div className="pf-chatbot__compare-mobile-controls">
|
65
|
+
<ToggleGroup aria-label={toggleGroupAriaLabel}>
|
66
|
+
<ToggleGroupItem
|
67
|
+
className="pf-chatbot__compare-toggle"
|
68
|
+
text={firstChildDisplayName}
|
69
|
+
buttonId="toggle-group-chatbot-1"
|
70
|
+
isSelected={isSelected === 'toggle-group-chatbot-1'}
|
71
|
+
onChange={handleChildToggleClick}
|
72
|
+
/>
|
73
|
+
<ToggleGroupItem
|
74
|
+
className="pf-chatbot__compare-toggle"
|
75
|
+
text={secondChildDisplayName}
|
76
|
+
buttonId="toggle-group-chatbot-2"
|
77
|
+
isSelected={isSelected === 'toggle-group-chatbot-2'}
|
78
|
+
onChange={handleChildToggleClick}
|
79
|
+
/>
|
80
|
+
</ToggleGroup>
|
81
|
+
</div>
|
82
|
+
<div className="pf-chatbot__compare">
|
83
|
+
<div
|
84
|
+
className={`pf-chatbot__compare-item ${!showFirstChatbot ? 'pf-chatbot__compare-item-hidden' : undefined}`}
|
85
|
+
>
|
86
|
+
{firstChild}
|
87
|
+
</div>
|
88
|
+
<div
|
89
|
+
className={`pf-chatbot__compare-item ${!showSecondChatbot ? 'pf-chatbot__compare-item-hidden' : undefined}`}
|
90
|
+
>
|
91
|
+
{secondChild}
|
92
|
+
</div>
|
93
|
+
</div>
|
94
|
+
</>
|
95
|
+
);
|
96
|
+
};
|
97
|
+
|
98
|
+
export default Compare;
|
package/src/index.ts
CHANGED
@@ -39,6 +39,9 @@ export * from './ChatbotWelcomePrompt';
|
|
39
39
|
export { default as CodeModal } from './CodeModal';
|
40
40
|
export * from './CodeModal';
|
41
41
|
|
42
|
+
export { default as Compare } from './Compare';
|
43
|
+
export * from './Compare';
|
44
|
+
|
42
45
|
export { default as FileDetails } from './FileDetails';
|
43
46
|
export * from './FileDetails';
|
44
47
|
|
package/src/main.scss
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
@import './ChatbotToggle/ChatbotToggle';
|
11
11
|
@import './ChatbotWelcomePrompt/ChatbotWelcomePrompt';
|
12
12
|
@import './CodeModal/CodeModal';
|
13
|
+
@import './Compare/Compare';
|
13
14
|
@import './FileDetails/FileDetails';
|
14
15
|
@import './FileDetailsLabel/FileDetailsLabel';
|
15
16
|
@import './FileDropZone/FileDropZone';
|