@patternfly/chatbot 6.4.0-prerelease.14 → 6.4.0-prerelease.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +1 -1
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +6 -6
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +13 -12
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +17 -5
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +24 -20
- package/dist/cjs/SourcesCard/SourcesCard.d.ts +13 -1
- package/dist/cjs/SourcesCard/SourcesCard.js +6 -6
- package/dist/cjs/SourcesCard/SourcesCard.test.js +49 -0
- package/dist/css/main.css +43 -30
- package/dist/css/main.css.map +1 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +1 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +6 -6
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +13 -12
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +18 -6
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +24 -20
- package/dist/esm/SourcesCard/SourcesCard.d.ts +13 -1
- package/dist/esm/SourcesCard/SourcesCard.js +6 -6
- package/dist/esm/SourcesCard/SourcesCard.test.js +50 -1
- package/package.json +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +70 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +1 -1
- package/patternfly-docs/patternfly-docs.config.js +1 -1
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx +6 -6
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx +1 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +28 -36
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +32 -18
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +74 -60
- package/src/SourcesCard/SourcesCard.scss +17 -0
- package/src/SourcesCard/SourcesCard.test.tsx +93 -0
- package/src/SourcesCard/SourcesCard.tsx +116 -80
|
@@ -10,14 +10,18 @@ import {
|
|
|
10
10
|
ButtonVariant,
|
|
11
11
|
Card,
|
|
12
12
|
CardBody,
|
|
13
|
+
CardBodyProps,
|
|
13
14
|
CardFooter,
|
|
15
|
+
CardFooterProps,
|
|
14
16
|
CardProps,
|
|
15
17
|
CardTitle,
|
|
18
|
+
CardTitleProps,
|
|
16
19
|
ExpandableSection,
|
|
17
20
|
ExpandableSectionVariant,
|
|
18
21
|
Icon,
|
|
19
22
|
pluralize,
|
|
20
|
-
Truncate
|
|
23
|
+
Truncate,
|
|
24
|
+
TruncateProps
|
|
21
25
|
} from '@patternfly/react-core';
|
|
22
26
|
import { ExternalLinkSquareAltIcon } from '@patternfly/react-icons';
|
|
23
27
|
|
|
@@ -34,6 +38,8 @@ export interface SourcesCardProps extends CardProps {
|
|
|
34
38
|
sources: {
|
|
35
39
|
/** Title of sources card */
|
|
36
40
|
title?: string;
|
|
41
|
+
/** Subtitle of sources card */
|
|
42
|
+
subtitle?: string;
|
|
37
43
|
/** Link to source */
|
|
38
44
|
link: string;
|
|
39
45
|
/** Body of sources card */
|
|
@@ -46,6 +52,10 @@ export interface SourcesCardProps extends CardProps {
|
|
|
46
52
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
47
53
|
/** Any additional props applied to the title of the Sources card */
|
|
48
54
|
titleProps?: ButtonProps;
|
|
55
|
+
/** Custom footer applied to the Sources card */
|
|
56
|
+
footer?: React.ReactNode;
|
|
57
|
+
/** Additional props passed to Truncate component */
|
|
58
|
+
truncateProps?: TruncateProps;
|
|
49
59
|
}[];
|
|
50
60
|
/** Label for the English word "source" */
|
|
51
61
|
sourceWord?: string;
|
|
@@ -65,6 +75,12 @@ export interface SourcesCardProps extends CardProps {
|
|
|
65
75
|
showMoreWords?: string;
|
|
66
76
|
/** Label for English words "show less" */
|
|
67
77
|
showLessWords?: string;
|
|
78
|
+
/** Additional props passed to card title */
|
|
79
|
+
cardTitleProps?: CardTitleProps;
|
|
80
|
+
/** Additional props passed to card body */
|
|
81
|
+
cardBodyProps?: CardBodyProps;
|
|
82
|
+
/** Additional props passed to card footer */
|
|
83
|
+
cardFooterProps?: CardFooterProps;
|
|
68
84
|
}
|
|
69
85
|
|
|
70
86
|
const SourcesCard: FunctionComponent<SourcesCardProps> = ({
|
|
@@ -82,6 +98,9 @@ const SourcesCard: FunctionComponent<SourcesCardProps> = ({
|
|
|
82
98
|
showMoreWords = 'show more',
|
|
83
99
|
showLessWords = 'show less',
|
|
84
100
|
isCompact,
|
|
101
|
+
cardTitleProps,
|
|
102
|
+
cardBodyProps,
|
|
103
|
+
cardFooterProps,
|
|
85
104
|
...props
|
|
86
105
|
}: SourcesCardProps) => {
|
|
87
106
|
const [page, setPage] = useState(1);
|
|
@@ -96,9 +115,9 @@ const SourcesCard: FunctionComponent<SourcesCardProps> = ({
|
|
|
96
115
|
onSetPage && onSetPage(_evt, newPage);
|
|
97
116
|
};
|
|
98
117
|
|
|
99
|
-
const renderTitle = (title?: string) => {
|
|
118
|
+
const renderTitle = (title?: string, truncateProps?: TruncateProps) => {
|
|
100
119
|
if (title) {
|
|
101
|
-
return <Truncate content={title} />;
|
|
120
|
+
return <Truncate content={title} {...truncateProps} />;
|
|
102
121
|
}
|
|
103
122
|
return `Source ${page}`;
|
|
104
123
|
};
|
|
@@ -107,24 +126,32 @@ const SourcesCard: FunctionComponent<SourcesCardProps> = ({
|
|
|
107
126
|
<div className="pf-chatbot__source">
|
|
108
127
|
<span>{pluralize(sources.length, sourceWord, sourceWordPlural)}</span>
|
|
109
128
|
<Card isCompact={isCompact} className="pf-chatbot__sources-card" {...props}>
|
|
110
|
-
<CardTitle className="pf-chatbot__sources-card-title">
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
129
|
+
<CardTitle className="pf-chatbot__sources-card-title" {...cardTitleProps}>
|
|
130
|
+
<div className="pf-chatbot__sources-card-title-container">
|
|
131
|
+
<Button
|
|
132
|
+
component="a"
|
|
133
|
+
variant={ButtonVariant.link}
|
|
134
|
+
href={sources[page - 1].link}
|
|
135
|
+
icon={sources[page - 1].isExternal ? <ExternalLinkSquareAltIcon /> : undefined}
|
|
136
|
+
iconPosition="end"
|
|
137
|
+
isInline
|
|
138
|
+
rel={sources[page - 1].isExternal ? 'noreferrer' : undefined}
|
|
139
|
+
target={sources[page - 1].isExternal ? '_blank' : undefined}
|
|
140
|
+
onClick={sources[page - 1].onClick ?? undefined}
|
|
141
|
+
{...sources[page - 1].titleProps}
|
|
142
|
+
>
|
|
143
|
+
{renderTitle(sources[page - 1].title, sources[page - 1].truncateProps)}
|
|
144
|
+
</Button>
|
|
145
|
+
{sources[page - 1].subtitle && (
|
|
146
|
+
<span className="pf-chatbot__sources-card-subtitle">{sources[page - 1].subtitle}</span>
|
|
147
|
+
)}
|
|
148
|
+
</div>
|
|
125
149
|
</CardTitle>
|
|
126
150
|
{sources[page - 1].body && (
|
|
127
|
-
<CardBody
|
|
151
|
+
<CardBody
|
|
152
|
+
className={`pf-chatbot__sources-card-body ${sources[page - 1].footer ? 'pf-chatbot__compact-sources-card-body' : undefined}`}
|
|
153
|
+
{...cardBodyProps}
|
|
154
|
+
>
|
|
128
155
|
{sources[page - 1].hasShowMore ? (
|
|
129
156
|
// prevents extra VO announcements of button text - parent Message has aria-live
|
|
130
157
|
<div aria-live="off">
|
|
@@ -143,68 +170,77 @@ const SourcesCard: FunctionComponent<SourcesCardProps> = ({
|
|
|
143
170
|
)}
|
|
144
171
|
</CardBody>
|
|
145
172
|
)}
|
|
146
|
-
{sources
|
|
147
|
-
<CardFooter className="pf-chatbot__sources-card-footer
|
|
148
|
-
|
|
149
|
-
<nav className={`pf-chatbot__sources-card-footer-buttons ${className}`} aria-label={paginationAriaLabel}>
|
|
150
|
-
<Button
|
|
151
|
-
variant={ButtonVariant.plain}
|
|
152
|
-
isDisabled={isDisabled || page === 1}
|
|
153
|
-
data-action="previous"
|
|
154
|
-
onClick={(event) => {
|
|
155
|
-
const newPage = page >= 1 ? page - 1 : 1;
|
|
156
|
-
onPreviousClick && onPreviousClick(event, newPage);
|
|
157
|
-
handleNewPage(event, newPage);
|
|
158
|
-
}}
|
|
159
|
-
aria-label={toPreviousPageAriaLabel}
|
|
160
|
-
>
|
|
161
|
-
<Icon iconSize="lg">
|
|
162
|
-
{/* these are inline because the viewBox that works in a round icon is different than the PatternFly default */}
|
|
163
|
-
<svg
|
|
164
|
-
className="pf-v6-svg"
|
|
165
|
-
viewBox="0 0 280 500"
|
|
166
|
-
fill="currentColor"
|
|
167
|
-
aria-hidden="true"
|
|
168
|
-
role="img"
|
|
169
|
-
width="1em"
|
|
170
|
-
height="1em"
|
|
171
|
-
>
|
|
172
|
-
<path d="M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z"></path>
|
|
173
|
-
</svg>
|
|
174
|
-
</Icon>
|
|
175
|
-
</Button>
|
|
176
|
-
<span aria-hidden="true">
|
|
177
|
-
{page}/{sources.length}
|
|
178
|
-
</span>
|
|
179
|
-
<Button
|
|
180
|
-
variant={ButtonVariant.plain}
|
|
181
|
-
isDisabled={isDisabled || page === sources.length}
|
|
182
|
-
aria-label={toNextPageAriaLabel}
|
|
183
|
-
data-action="next"
|
|
184
|
-
onClick={(event) => {
|
|
185
|
-
const newPage = page + 1 <= sources.length ? page + 1 : sources.length;
|
|
186
|
-
onNextClick && onNextClick(event, newPage);
|
|
187
|
-
handleNewPage(event, newPage);
|
|
188
|
-
}}
|
|
189
|
-
>
|
|
190
|
-
<Icon isInline iconSize="lg">
|
|
191
|
-
{/* these are inline because the viewBox that works in a round icon is different than the PatternFly default */}
|
|
192
|
-
<svg
|
|
193
|
-
className="pf-v6-svg"
|
|
194
|
-
viewBox="0 0 180 500"
|
|
195
|
-
fill="currentColor"
|
|
196
|
-
aria-hidden="true"
|
|
197
|
-
role="img"
|
|
198
|
-
width="1em"
|
|
199
|
-
height="1em"
|
|
200
|
-
>
|
|
201
|
-
<path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"></path>
|
|
202
|
-
</svg>
|
|
203
|
-
</Icon>
|
|
204
|
-
</Button>
|
|
205
|
-
</nav>
|
|
206
|
-
</div>
|
|
173
|
+
{sources[page - 1].footer ? (
|
|
174
|
+
<CardFooter className="pf-chatbot__sources-card-footer" {...cardFooterProps}>
|
|
175
|
+
{sources[page - 1].footer}
|
|
207
176
|
</CardFooter>
|
|
177
|
+
) : (
|
|
178
|
+
sources.length > 1 && (
|
|
179
|
+
<CardFooter className="pf-chatbot__sources-card-footer-container" {...cardFooterProps}>
|
|
180
|
+
<div className="pf-chatbot__sources-card-footer">
|
|
181
|
+
<nav
|
|
182
|
+
className={`pf-chatbot__sources-card-footer-buttons ${className}`}
|
|
183
|
+
aria-label={paginationAriaLabel}
|
|
184
|
+
>
|
|
185
|
+
<Button
|
|
186
|
+
variant={ButtonVariant.plain}
|
|
187
|
+
isDisabled={isDisabled || page === 1}
|
|
188
|
+
data-action="previous"
|
|
189
|
+
onClick={(event) => {
|
|
190
|
+
const newPage = page >= 1 ? page - 1 : 1;
|
|
191
|
+
onPreviousClick && onPreviousClick(event, newPage);
|
|
192
|
+
handleNewPage(event, newPage);
|
|
193
|
+
}}
|
|
194
|
+
aria-label={toPreviousPageAriaLabel}
|
|
195
|
+
>
|
|
196
|
+
<Icon iconSize="lg">
|
|
197
|
+
{/* these are inline because the viewBox that works in a round icon is different than the PatternFly default */}
|
|
198
|
+
<svg
|
|
199
|
+
className="pf-v6-svg"
|
|
200
|
+
viewBox="0 0 280 500"
|
|
201
|
+
fill="currentColor"
|
|
202
|
+
aria-hidden="true"
|
|
203
|
+
role="img"
|
|
204
|
+
width="1em"
|
|
205
|
+
height="1em"
|
|
206
|
+
>
|
|
207
|
+
<path d="M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z"></path>
|
|
208
|
+
</svg>
|
|
209
|
+
</Icon>
|
|
210
|
+
</Button>
|
|
211
|
+
<span aria-hidden="true">
|
|
212
|
+
{page}/{sources.length}
|
|
213
|
+
</span>
|
|
214
|
+
<Button
|
|
215
|
+
variant={ButtonVariant.plain}
|
|
216
|
+
isDisabled={isDisabled || page === sources.length}
|
|
217
|
+
aria-label={toNextPageAriaLabel}
|
|
218
|
+
data-action="next"
|
|
219
|
+
onClick={(event) => {
|
|
220
|
+
const newPage = page + 1 <= sources.length ? page + 1 : sources.length;
|
|
221
|
+
onNextClick && onNextClick(event, newPage);
|
|
222
|
+
handleNewPage(event, newPage);
|
|
223
|
+
}}
|
|
224
|
+
>
|
|
225
|
+
<Icon isInline iconSize="lg">
|
|
226
|
+
{/* these are inline because the viewBox that works in a round icon is different than the PatternFly default */}
|
|
227
|
+
<svg
|
|
228
|
+
className="pf-v6-svg"
|
|
229
|
+
viewBox="0 0 180 500"
|
|
230
|
+
fill="currentColor"
|
|
231
|
+
aria-hidden="true"
|
|
232
|
+
role="img"
|
|
233
|
+
width="1em"
|
|
234
|
+
height="1em"
|
|
235
|
+
>
|
|
236
|
+
<path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"></path>
|
|
237
|
+
</svg>
|
|
238
|
+
</Icon>
|
|
239
|
+
</Button>
|
|
240
|
+
</nav>
|
|
241
|
+
</div>
|
|
242
|
+
</CardFooter>
|
|
243
|
+
)
|
|
208
244
|
)}
|
|
209
245
|
</Card>
|
|
210
246
|
</div>
|