@patternfly/chatbot 6.5.0-prerelease.3 → 6.5.0-prerelease.5

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.
Files changed (63) hide show
  1. package/dist/cjs/AttachMenu/AttachMenu.d.ts +7 -1
  2. package/dist/cjs/AttachMenu/AttachMenu.js +2 -2
  3. package/dist/cjs/ChatbotFooter/ChatbotFooter.d.ts +5 -2
  4. package/dist/cjs/ChatbotFooter/ChatbotFooter.js +2 -2
  5. package/dist/cjs/ChatbotFooter/ChatbotFooter.test.js +5 -1
  6. package/dist/cjs/FileDetailsLabel/FileDetailsLabel.d.ts +2 -1
  7. package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.d.ts +3 -1
  8. package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +2 -2
  9. package/dist/cjs/Message/Message.d.ts +2 -0
  10. package/dist/cjs/Message/Message.js +6 -6
  11. package/dist/cjs/Message/Message.test.js +32 -0
  12. package/dist/cjs/Message/MessageLoading.d.ts +2 -1
  13. package/dist/cjs/Message/MessageLoading.js +1 -1
  14. package/dist/cjs/Message/TableMessage/TableMessage.d.ts +4 -1
  15. package/dist/cjs/Message/TableMessage/TableMessage.js +2 -2
  16. package/dist/cjs/Message/TextMessage/TextMessage.d.ts +4 -1
  17. package/dist/cjs/Message/TextMessage/TextMessage.js +2 -2
  18. package/dist/cjs/MessageBar/MessageBar.d.ts +9 -1
  19. package/dist/cjs/MessageBar/MessageBar.js +3 -3
  20. package/dist/cjs/MessageBar/MessageBar.test.js +37 -0
  21. package/dist/css/main.css +27 -0
  22. package/dist/css/main.css.map +1 -1
  23. package/dist/esm/AttachMenu/AttachMenu.d.ts +7 -1
  24. package/dist/esm/AttachMenu/AttachMenu.js +2 -2
  25. package/dist/esm/ChatbotFooter/ChatbotFooter.d.ts +5 -2
  26. package/dist/esm/ChatbotFooter/ChatbotFooter.js +2 -2
  27. package/dist/esm/ChatbotFooter/ChatbotFooter.test.js +5 -1
  28. package/dist/esm/FileDetailsLabel/FileDetailsLabel.d.ts +2 -1
  29. package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.d.ts +3 -1
  30. package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +2 -2
  31. package/dist/esm/Message/Message.d.ts +2 -0
  32. package/dist/esm/Message/Message.js +6 -6
  33. package/dist/esm/Message/Message.test.js +32 -0
  34. package/dist/esm/Message/MessageLoading.d.ts +2 -1
  35. package/dist/esm/Message/MessageLoading.js +1 -1
  36. package/dist/esm/Message/TableMessage/TableMessage.d.ts +4 -1
  37. package/dist/esm/Message/TableMessage/TableMessage.js +2 -2
  38. package/dist/esm/Message/TextMessage/TextMessage.d.ts +4 -1
  39. package/dist/esm/Message/TextMessage/TextMessage.js +2 -2
  40. package/dist/esm/MessageBar/MessageBar.d.ts +9 -1
  41. package/dist/esm/MessageBar/MessageBar.js +3 -3
  42. package/dist/esm/MessageBar/MessageBar.test.js +37 -0
  43. package/package.json +1 -1
  44. package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +12 -4
  45. package/patternfly-docs/content/extensions/chatbot/examples/demos/WhiteEmbeddedChatbot.tsx +451 -0
  46. package/src/AttachMenu/AttachMenu.tsx +16 -3
  47. package/src/ChatbotFooter/ChatbotFooter.scss +4 -0
  48. package/src/ChatbotFooter/ChatbotFooter.test.tsx +10 -1
  49. package/src/ChatbotFooter/ChatbotFooter.tsx +10 -3
  50. package/src/FileDetailsLabel/FileDetailsLabel.tsx +2 -2
  51. package/src/Message/CodeBlockMessage/CodeBlockMessage.scss +4 -0
  52. package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +4 -1
  53. package/src/Message/Message.test.tsx +37 -0
  54. package/src/Message/Message.tsx +8 -4
  55. package/src/Message/MessageLoading.scss +4 -0
  56. package/src/Message/MessageLoading.tsx +2 -2
  57. package/src/Message/TableMessage/TableMessage.scss +4 -0
  58. package/src/Message/TableMessage/TableMessage.tsx +6 -2
  59. package/src/Message/TextMessage/TextMessage.scss +6 -0
  60. package/src/Message/TextMessage/TextMessage.tsx +11 -2
  61. package/src/MessageBar/MessageBar.scss +4 -0
  62. package/src/MessageBar/MessageBar.test.tsx +62 -1
  63. package/src/MessageBar/MessageBar.tsx +24 -2
@@ -0,0 +1,451 @@
1
+ import { useEffect, useRef, useState, FunctionComponent, MouseEvent } from 'react';
2
+
3
+ import {
4
+ Bullseye,
5
+ Brand,
6
+ DropdownList,
7
+ DropdownItem,
8
+ Page,
9
+ Masthead,
10
+ MastheadMain,
11
+ MastheadBrand,
12
+ MastheadLogo,
13
+ PageSidebarBody,
14
+ PageSidebar,
15
+ MastheadToggle,
16
+ PageToggleButton,
17
+ SkipToContent
18
+ } from '@patternfly/react-core';
19
+
20
+ import Chatbot, { ChatbotDisplayMode } from '@patternfly/chatbot/dist/dynamic/Chatbot';
21
+ import ChatbotContent from '@patternfly/chatbot/dist/dynamic/ChatbotContent';
22
+ import ChatbotWelcomePrompt from '@patternfly/chatbot/dist/dynamic/ChatbotWelcomePrompt';
23
+ import ChatbotFooter, { ChatbotFootnote } from '@patternfly/chatbot/dist/dynamic/ChatbotFooter';
24
+ import MessageBar from '@patternfly/chatbot/dist/dynamic/MessageBar';
25
+ import MessageBox from '@patternfly/chatbot/dist/dynamic/MessageBox';
26
+ import Message, { MessageProps } from '@patternfly/chatbot/dist/dynamic/Message';
27
+ import ChatbotConversationHistoryNav, {
28
+ Conversation
29
+ } from '@patternfly/chatbot/dist/dynamic/ChatbotConversationHistoryNav';
30
+ import ChatbotHeader, {
31
+ ChatbotHeaderMenu,
32
+ ChatbotHeaderMain,
33
+ ChatbotHeaderTitle,
34
+ ChatbotHeaderActions,
35
+ ChatbotHeaderSelectorDropdown
36
+ } from '@patternfly/chatbot/dist/dynamic/ChatbotHeader';
37
+
38
+ import PFHorizontalLogoColor from '../UI/PF-HorizontalLogo-Color.svg';
39
+ import PFHorizontalLogoReverse from '../UI/PF-HorizontalLogo-Reverse.svg';
40
+ import { BarsIcon } from '@patternfly/react-icons';
41
+ import userAvatar from '../Messages/user_avatar.svg';
42
+ import patternflyAvatar from '../Messages/patternfly_avatar.jpg';
43
+ import '@patternfly/react-core/dist/styles/base.css';
44
+ import '@patternfly/chatbot/dist/css/main.css';
45
+
46
+ const footnoteProps = {
47
+ label: 'ChatBot uses AI. Check for mistakes.',
48
+ popover: {
49
+ title: 'Verify information',
50
+ description: `While ChatBot strives for accuracy, AI is experimental and can make mistakes. We cannot guarantee that all information provided by ChatBot is up to date or without error. You should always verify responses using reliable sources, especially for crucial information and decision making.`,
51
+ bannerImage: {
52
+ src: 'https://cdn.dribbble.com/userupload/10651749/file/original-8a07b8e39d9e8bf002358c66fce1223e.gif',
53
+ alt: 'Example image for footnote popover'
54
+ },
55
+ cta: {
56
+ label: 'Dismiss',
57
+ onClick: () => {
58
+ alert('Do something!');
59
+ }
60
+ },
61
+ link: {
62
+ label: 'View AI policy',
63
+ url: 'https://www.redhat.com/'
64
+ }
65
+ }
66
+ };
67
+
68
+ const markdown = `A paragraph with *emphasis* and **strong importance**.
69
+
70
+ > A block quote with ~strikethrough~ and a URL: https://reactjs.org.
71
+
72
+ Here is an inline code - \`() => void\`
73
+
74
+ Here is some YAML code:
75
+
76
+ ~~~yaml
77
+ apiVersion: helm.openshift.io/v1beta1/
78
+ kind: HelmChartRepository
79
+ metadata:
80
+ name: azure-sample-repo0oooo00ooo
81
+ spec:
82
+ connectionConfig:
83
+ url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs
84
+ ~~~
85
+
86
+ Here is some JavaScript code:
87
+
88
+ ~~~js
89
+ const MessageLoading = () => (
90
+ <div className="pf-chatbot__message-loading">
91
+ <span className="pf-chatbot__message-loading-dots">
92
+ <span className="pf-v6-screen-reader">Loading message</span>
93
+ </span>
94
+ </div>
95
+ );
96
+
97
+ export default MessageLoading;
98
+
99
+ ~~~
100
+
101
+ Here is a table:
102
+
103
+ | Version | GA date | User role
104
+ |-|-|-|
105
+ | 2.5 | September 30, 2024 | Administrator |
106
+ | 2.5 | June 27, 2023 | Editor |
107
+ | 3.0 | April 1, 2025 | Administrator
108
+ `;
109
+
110
+ // It's important to set a date and timestamp prop since the Message components re-render.
111
+ // The timestamps re-render with them.
112
+ const date = new Date();
113
+
114
+ const initialMessages: MessageProps[] = [
115
+ {
116
+ id: '1',
117
+ role: 'user',
118
+ content: 'Hello, can you give me an example of what you can do?',
119
+ name: 'User',
120
+ avatar: userAvatar,
121
+ timestamp: date.toLocaleString(),
122
+ avatarProps: { isBordered: true },
123
+ isPrimary: true
124
+ },
125
+ {
126
+ id: '2',
127
+ role: 'bot',
128
+ content: markdown,
129
+ name: 'Bot',
130
+ avatar: patternflyAvatar,
131
+ timestamp: date.toLocaleString(),
132
+ actions: {
133
+ // eslint-disable-next-line no-console
134
+ positive: { onClick: () => console.log('Good response') },
135
+ // eslint-disable-next-line no-console
136
+ negative: { onClick: () => console.log('Bad response') },
137
+ // eslint-disable-next-line no-console
138
+ copy: { onClick: () => console.log('Copy') },
139
+ // eslint-disable-next-line no-console
140
+ download: { onClick: () => console.log('Download') },
141
+ // eslint-disable-next-line no-console
142
+ listen: { onClick: () => console.log('Listen') }
143
+ },
144
+ isPrimary: true,
145
+ attachments: [{ name: 'auth-operator.yml', id: '1' }]
146
+ }
147
+ ];
148
+
149
+ const welcomePrompts = [
150
+ {
151
+ title: 'Set up account',
152
+ message: 'Choose the necessary settings and preferences for your account.'
153
+ },
154
+ {
155
+ title: 'Troubleshoot issue',
156
+ message: 'Find documentation and instructions to resolve your issue.'
157
+ }
158
+ ];
159
+
160
+ const initialConversations = {
161
+ Today: [{ id: '1', text: 'Hello, can you give me an example of what you can do?' }],
162
+ 'This month': [
163
+ {
164
+ id: '2',
165
+ text: 'Enterprise Linux installation and setup'
166
+ },
167
+ { id: '3', text: 'Troubleshoot system crash' }
168
+ ],
169
+ March: [
170
+ { id: '4', text: 'Ansible security and updates' },
171
+ { id: '5', text: 'Red Hat certification' },
172
+ { id: '6', text: 'Lightspeed user documentation' }
173
+ ],
174
+ February: [
175
+ { id: '7', text: 'Crashing pod assistance' },
176
+ { id: '8', text: 'OpenShift AI pipelines' },
177
+ { id: '9', text: 'Updating subscription plan' },
178
+ { id: '10', text: 'Red Hat licensing options' }
179
+ ],
180
+ January: [
181
+ { id: '11', text: 'RHEL system performance' },
182
+ { id: '12', text: 'Manage user accounts' }
183
+ ]
184
+ };
185
+
186
+ export const EmbeddedChatbotDemo: FunctionComponent = () => {
187
+ const [messages, setMessages] = useState<MessageProps[]>(initialMessages);
188
+ const [selectedModel, setSelectedModel] = useState('Granite 7B');
189
+ const [isSendButtonDisabled, setIsSendButtonDisabled] = useState(false);
190
+ const [isDrawerOpen, setIsDrawerOpen] = useState(false);
191
+ const [conversations, setConversations] = useState<Conversation[] | { [key: string]: Conversation[] }>(
192
+ initialConversations
193
+ );
194
+ const [isSidebarOpen, setIsSidebarOpen] = useState(false);
195
+ const [announcement, setAnnouncement] = useState<string>();
196
+ const scrollToBottomRef = useRef<HTMLDivElement>(null);
197
+ const historyRef = useRef<HTMLButtonElement>(null);
198
+
199
+ const displayMode = ChatbotDisplayMode.embedded;
200
+ // Auto-scrolls to the latest message
201
+ useEffect(() => {
202
+ // don't scroll the first load - in this demo, we know we start with two messages
203
+ if (messages.length > 2) {
204
+ scrollToBottomRef.current?.scrollIntoView({ behavior: 'smooth' });
205
+ }
206
+ }, [messages]);
207
+
208
+ const onSelectModel = (_event: MouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => {
209
+ setSelectedModel(value as string);
210
+ };
211
+
212
+ // you will likely want to come up with your own unique id function; this is for demo purposes only
213
+ const generateId = () => {
214
+ const id = Date.now() + Math.random();
215
+ return id.toString();
216
+ };
217
+
218
+ const handleSend = (message: string) => {
219
+ setIsSendButtonDisabled(true);
220
+ const newMessages: MessageProps[] = [];
221
+ // We can't use structuredClone since messages contains functions, but we can't mutate
222
+ // items that are going into state or the UI won't update correctly
223
+ messages.forEach((message) => newMessages.push(message));
224
+ // It's important to set a timestamp prop since the Message components re-render.
225
+ // The timestamps re-render with them.
226
+ const date = new Date();
227
+ newMessages.push({
228
+ id: generateId(),
229
+ role: 'user',
230
+ content: message,
231
+ name: 'User',
232
+ avatar: userAvatar,
233
+ timestamp: date.toLocaleString(),
234
+ avatarProps: { isBordered: true },
235
+ isPrimary: true
236
+ });
237
+ newMessages.push({
238
+ id: generateId(),
239
+ role: 'bot',
240
+ content: 'API response goes here',
241
+ name: 'Bot',
242
+ avatar: patternflyAvatar,
243
+ isLoading: true,
244
+ timestamp: date.toLocaleString(),
245
+ isPrimary: true
246
+ });
247
+ setMessages(newMessages);
248
+ // make announcement to assistive devices that new messages have been added
249
+ setAnnouncement(`Message from User: ${message}. Message from Bot is loading.`);
250
+
251
+ // this is for demo purposes only; in a real situation, there would be an API response we would wait for
252
+ setTimeout(() => {
253
+ const loadedMessages: MessageProps[] = [];
254
+ // we can't use structuredClone since messages contains functions, but we can't mutate
255
+ // items that are going into state or the UI won't update correctly
256
+ newMessages.forEach((message) => loadedMessages.push(message));
257
+ loadedMessages.pop();
258
+ loadedMessages.push({
259
+ id: generateId(),
260
+ role: 'bot',
261
+ content: 'API response goes here',
262
+ name: 'Bot',
263
+ avatar: patternflyAvatar,
264
+ isLoading: false,
265
+ actions: {
266
+ // eslint-disable-next-line no-console
267
+ positive: { onClick: () => console.log('Good response') },
268
+ // eslint-disable-next-line no-console
269
+ negative: { onClick: () => console.log('Bad response') },
270
+ // eslint-disable-next-line no-console
271
+ copy: { onClick: () => console.log('Copy') },
272
+ // eslint-disable-next-line no-console
273
+ download: { onClick: () => console.log('Download') },
274
+ // eslint-disable-next-line no-console
275
+ listen: { onClick: () => console.log('Listen') }
276
+ },
277
+ timestamp: date.toLocaleString(),
278
+ isPrimary: true
279
+ });
280
+ setMessages(loadedMessages);
281
+ // make announcement to assistive devices that new message has loaded
282
+ setAnnouncement(`Message from Bot: API response goes here`);
283
+ setIsSendButtonDisabled(false);
284
+ }, 5000);
285
+ };
286
+
287
+ const findMatchingItems = (targetValue: string) => {
288
+ let filteredConversations = Object.entries(initialConversations).reduce((acc, [key, items]) => {
289
+ const filteredItems = items.filter((item) => item.text.toLowerCase().includes(targetValue.toLowerCase()));
290
+ if (filteredItems.length > 0) {
291
+ acc[key] = filteredItems;
292
+ }
293
+ return acc;
294
+ }, {});
295
+
296
+ // append message if no items are found
297
+ if (Object.keys(filteredConversations).length === 0) {
298
+ filteredConversations = [{ id: '13', noIcon: true, text: 'No results found' }];
299
+ }
300
+ return filteredConversations;
301
+ };
302
+
303
+ const horizontalLogo = (
304
+ <Bullseye>
305
+ <Brand className="show-light" src={PFHorizontalLogoColor} alt="PatternFly" />
306
+ <Brand className="show-dark" src={PFHorizontalLogoReverse} alt="PatternFly" />
307
+ </Bullseye>
308
+ );
309
+
310
+ const masthead = (
311
+ <Masthead>
312
+ <MastheadMain>
313
+ <MastheadToggle>
314
+ <PageToggleButton
315
+ variant="plain"
316
+ aria-label="Global navigation"
317
+ isSidebarOpen={isSidebarOpen}
318
+ onSidebarToggle={() => setIsSidebarOpen(!isSidebarOpen)}
319
+ id="fill-nav-toggle"
320
+ >
321
+ <BarsIcon />
322
+ </PageToggleButton>
323
+ </MastheadToggle>
324
+ <MastheadBrand>
325
+ <MastheadLogo href="https://patternfly.org" target="_blank">
326
+ Logo
327
+ </MastheadLogo>
328
+ </MastheadBrand>
329
+ </MastheadMain>
330
+ </Masthead>
331
+ );
332
+
333
+ const sidebar = (
334
+ <PageSidebar isSidebarOpen={isSidebarOpen} id="fill-sidebar">
335
+ <PageSidebarBody>Navigation</PageSidebarBody>
336
+ </PageSidebar>
337
+ );
338
+
339
+ const skipToChatbot = (event: MouseEvent) => {
340
+ event.preventDefault();
341
+ if (historyRef.current) {
342
+ historyRef.current.focus();
343
+ }
344
+ };
345
+
346
+ const skipToContent = (
347
+ /* You can also add a SkipToContent for your main content here */
348
+ <SkipToContent href="#" onClick={skipToChatbot}>
349
+ Skip to chatbot
350
+ </SkipToContent>
351
+ );
352
+
353
+ return (
354
+ <Page skipToContent={skipToContent} masthead={masthead} sidebar={sidebar} isContentFilled>
355
+ <Chatbot displayMode={displayMode}>
356
+ <ChatbotConversationHistoryNav
357
+ displayMode={displayMode}
358
+ onDrawerToggle={() => {
359
+ setIsDrawerOpen(!isDrawerOpen);
360
+ setConversations(initialConversations);
361
+ }}
362
+ isDrawerOpen={isDrawerOpen}
363
+ setIsDrawerOpen={setIsDrawerOpen}
364
+ activeItemId="1"
365
+ // eslint-disable-next-line no-console
366
+ onSelectActiveItem={(e, selectedItem) => console.log(`Selected history item with id ${selectedItem}`)}
367
+ conversations={conversations}
368
+ onNewChat={() => {
369
+ setIsDrawerOpen(!isDrawerOpen);
370
+ setMessages([]);
371
+ setConversations(initialConversations);
372
+ }}
373
+ handleTextInputChange={(value: string) => {
374
+ if (value === '') {
375
+ setConversations(initialConversations);
376
+ }
377
+ // this is where you would perform search on the items in the drawer
378
+ // and update the state
379
+ const newConversations: { [key: string]: Conversation[] } = findMatchingItems(value);
380
+ setConversations(newConversations);
381
+ }}
382
+ drawerContent={
383
+ <>
384
+ <ChatbotHeader>
385
+ <ChatbotHeaderMain>
386
+ <ChatbotHeaderMenu
387
+ ref={historyRef}
388
+ aria-expanded={isDrawerOpen}
389
+ onMenuToggle={() => setIsDrawerOpen(!isDrawerOpen)}
390
+ />
391
+ <ChatbotHeaderTitle>{horizontalLogo}</ChatbotHeaderTitle>
392
+ </ChatbotHeaderMain>
393
+ <ChatbotHeaderActions>
394
+ <ChatbotHeaderSelectorDropdown value={selectedModel} onSelect={onSelectModel}>
395
+ <DropdownList>
396
+ <DropdownItem value="Granite 7B" key="granite">
397
+ Granite 7B
398
+ </DropdownItem>
399
+ <DropdownItem value="Llama 3.0" key="llama">
400
+ Llama 3.0
401
+ </DropdownItem>
402
+ <DropdownItem value="Mistral 3B" key="mistral">
403
+ Mistral 3B
404
+ </DropdownItem>
405
+ </DropdownList>
406
+ </ChatbotHeaderSelectorDropdown>
407
+ </ChatbotHeaderActions>
408
+ </ChatbotHeader>
409
+ <ChatbotContent isPrimary>
410
+ {/* Update the announcement prop on MessageBox whenever a new message is sent
411
+ so that users of assistive devices receive sufficient context */}
412
+ <MessageBox announcement={announcement}>
413
+ <ChatbotWelcomePrompt
414
+ title="Hi, ChatBot User!"
415
+ description="How can I help you today?"
416
+ prompts={welcomePrompts}
417
+ />
418
+ {/* This code block enables scrolling to the top of the last message.
419
+ You can instead choose to move the div with scrollToBottomRef on it below
420
+ the map of messages, so that users are forced to scroll to the bottom.
421
+ If you are using streaming, you will want to take a different approach;
422
+ see: https://github.com/patternfly/chatbot/issues/201#issuecomment-2400725173 */}
423
+ {messages.map((message, index) => {
424
+ if (index === messages.length - 1) {
425
+ return (
426
+ <>
427
+ <div ref={scrollToBottomRef}></div>
428
+ <Message key={message.id} {...message} />
429
+ </>
430
+ );
431
+ }
432
+ return <Message key={message.id} {...message} />;
433
+ })}
434
+ </MessageBox>
435
+ </ChatbotContent>
436
+ <ChatbotFooter isPrimary>
437
+ <MessageBar
438
+ isPrimary
439
+ onSendMessage={handleSend}
440
+ hasMicrophoneButton
441
+ isSendButtonDisabled={isSendButtonDisabled}
442
+ />
443
+ <ChatbotFootnote {...footnoteProps} />
444
+ </ChatbotFooter>
445
+ </>
446
+ }
447
+ ></ChatbotConversationHistoryNav>
448
+ </Chatbot>
449
+ </Page>
450
+ );
451
+ };
@@ -11,7 +11,10 @@ import {
11
11
  DropdownProps,
12
12
  Dropdown,
13
13
  DropdownToggleProps,
14
- PopperOptions
14
+ PopperOptions,
15
+ MenuSearchInputProps,
16
+ SearchInputProps,
17
+ MenuSearchProps
15
18
  } from '@patternfly/react-core';
16
19
 
17
20
  export interface AttachMenuProps extends DropdownProps {
@@ -35,6 +38,12 @@ export interface AttachMenuProps extends DropdownProps {
35
38
  searchInputAriaLabel?: string;
36
39
  /** Toggle to be rendered */
37
40
  toggle: DropdownToggleProps | ((toggleRef: React.RefObject<any>) => React.ReactNode);
41
+ /** Additional props passed to MenuSearch component */
42
+ menuSearchProps?: Omit<MenuSearchProps, 'ref'>;
43
+ /** Additional props passed to MenuSearchInput component */
44
+ menuSearchInputProps?: Omit<MenuSearchInputProps, 'ref'>;
45
+ /** Additional props passed to SearchInput component */
46
+ searchInputProps?: SearchInputProps;
38
47
  }
39
48
 
40
49
  export const AttachMenu: FunctionComponent<AttachMenuProps> = ({
@@ -49,6 +58,9 @@ export const AttachMenu: FunctionComponent<AttachMenuProps> = ({
49
58
  searchInputPlaceholder,
50
59
  searchInputAriaLabel = 'Filter menu items',
51
60
  toggle,
61
+ menuSearchProps,
62
+ menuSearchInputProps,
63
+ searchInputProps,
52
64
  ...props
53
65
  }: AttachMenuProps) => (
54
66
  <Dropdown
@@ -61,12 +73,13 @@ export const AttachMenu: FunctionComponent<AttachMenuProps> = ({
61
73
  onSelect={onSelect}
62
74
  {...props}
63
75
  >
64
- <MenuSearch>
65
- <MenuSearchInput>
76
+ <MenuSearch {...menuSearchProps}>
77
+ <MenuSearchInput {...menuSearchInputProps}>
66
78
  <SearchInput
67
79
  aria-label={searchInputAriaLabel}
68
80
  onChange={(_event, value) => handleTextInputChange(value)}
69
81
  placeholder={searchInputPlaceholder}
82
+ {...searchInputProps}
70
83
  />
71
84
  </MenuSearchInput>
72
85
  </MenuSearch>
@@ -11,6 +11,10 @@
11
11
  flex-direction: column;
12
12
  row-gap: var(--pf-chatbot__footer--RowGap);
13
13
  position: relative; // this is so focus ring on parent chatbot doesn't include footer
14
+
15
+ &.pf-m-primary {
16
+ background-color: var(--pf-t--global--background--color--primary--default);
17
+ }
14
18
  }
15
19
  .pf-chatbot__footer-container {
16
20
  padding: 0 var(--pf-t--global--spacer--lg) var(--pf-t--global--spacer--lg) var(--pf-t--global--spacer--lg);
@@ -15,10 +15,19 @@ describe('ChatbotFooter', () => {
15
15
 
16
16
  it('should handle isCompact', () => {
17
17
  render(
18
- <ChatbotFooter className="custom-class" isCompact data-testid="footer">
18
+ <ChatbotFooter isCompact data-testid="footer">
19
19
  Chatbot Content
20
20
  </ChatbotFooter>
21
21
  );
22
22
  expect(screen.getByTestId('footer')).toHaveClass('pf-m-compact');
23
23
  });
24
+
25
+ it('should handle isPrimary', () => {
26
+ render(
27
+ <ChatbotFooter isPrimary data-testid="footer">
28
+ Chatbot Content
29
+ </ChatbotFooter>
30
+ );
31
+ expect(screen.getByTestId('footer')).toHaveClass('pf-m-primary');
32
+ });
24
33
  });
@@ -13,20 +13,27 @@ import type { HTMLProps, FunctionComponent } from 'react';
13
13
  import { Divider } from '@patternfly/react-core';
14
14
 
15
15
  export interface ChatbotFooterProps extends HTMLProps<HTMLDivElement> {
16
- /** Children for the Footer that supports MessageBar and FootNote components*/
16
+ /** Children for the footer - supports MessageBar and FootNote components*/
17
17
  children?: React.ReactNode;
18
- /** Custom classname for the Footer component */
18
+ /** Custom classname for the footer component */
19
19
  className?: string;
20
+ /** Sets footer to compact styling. */
20
21
  isCompact?: boolean;
22
+ /** Sets background color to primary */
23
+ isPrimary?: boolean;
21
24
  }
22
25
 
23
26
  export const ChatbotFooter: FunctionComponent<ChatbotFooterProps> = ({
24
27
  children,
25
28
  className,
26
29
  isCompact,
30
+ isPrimary,
27
31
  ...props
28
32
  }: ChatbotFooterProps) => (
29
- <div className={`pf-chatbot__footer ${isCompact ? 'pf-m-compact' : ''} ${className ?? ''}`} {...props}>
33
+ <div
34
+ className={`pf-chatbot__footer ${isCompact ? 'pf-m-compact' : ''} ${isPrimary ? 'pf-m-primary' : ''} ${className ?? ''}`}
35
+ {...props}
36
+ >
30
37
  <Divider />
31
38
  <div className="pf-chatbot__footer-container">{children}</div>
32
39
  </div>
@@ -1,10 +1,10 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import { Button, Label } from '@patternfly/react-core';
2
+ import { Button, Label, LabelProps } from '@patternfly/react-core';
3
3
  import FileDetails from '../FileDetails';
4
4
  import { Spinner } from '@patternfly/react-core';
5
5
  import { TimesIcon } from '@patternfly/react-icons';
6
6
 
7
- export interface FileDetailsLabelProps {
7
+ export interface FileDetailsLabelProps extends Omit<LabelProps, 'onClose' | 'onClick'> {
8
8
  /** Name of file, including extension */
9
9
  fileName: string;
10
10
  /** Unique id of file */
@@ -81,6 +81,10 @@
81
81
  --pf-chatbot-message-text-inline-code-font-size: var(--pf-t--global--font--size--body--default);
82
82
  background-color: var(--pf-t--global--background--color--tertiary--default);
83
83
  font-size: var(--pf-chatbot-message-text-inline-code-font-size);
84
+
85
+ &.pf-m-primary {
86
+ background-color: var(--pf-t--global--background--color--secondary--default);
87
+ }
84
88
  }
85
89
 
86
90
  .pf-chatbot__message-code-toggle {
@@ -39,6 +39,8 @@ export interface CodeBlockMessageProps {
39
39
  collapsedText?: string;
40
40
  /** Custom actions added to header of code block, after any default actions such as the "copy" action. */
41
41
  customActions?: React.ReactNode;
42
+ /** Sets background colors to be appropriate on primary chatbot background */
43
+ isPrimary?: boolean;
42
44
  }
43
45
 
44
46
  const DEFAULT_EXPANDED_TEXT = 'Show less';
@@ -54,6 +56,7 @@ const CodeBlockMessage = ({
54
56
  expandedText = DEFAULT_EXPANDED_TEXT,
55
57
  collapsedText = DEFAULT_COLLAPSED_TEXT,
56
58
  customActions,
59
+ isPrimary,
57
60
  ...props
58
61
  }: CodeBlockMessageProps) => {
59
62
  const [copied, setCopied] = useState(false);
@@ -108,7 +111,7 @@ const CodeBlockMessage = ({
108
111
 
109
112
  if (!String(children).includes('\n')) {
110
113
  return (
111
- <code {...props} className="pf-chatbot__message-inline-code">
114
+ <code {...props} className={`pf-chatbot__message-inline-code ${isPrimary ? 'pf-m-primary' : ''}`}>
112
115
  {children}
113
116
  </code>
114
117
  );
@@ -1093,4 +1093,41 @@ describe('Message', () => {
1093
1093
  expect(screen.getByText('Thought for 3 seconds')).toBeTruthy();
1094
1094
  expect(screen.getByText("Here's why I said this.")).toBeTruthy();
1095
1095
  });
1096
+ it('should handle isPrimary correctly for inline code when it is true', () => {
1097
+ const { container } = render(<Message avatar="./img" role="user" name="User" content={INLINE_CODE} isPrimary />);
1098
+ expect(container.querySelector('.pf-m-primary')).toBeTruthy();
1099
+ });
1100
+ it('should handle isPrimary correctly for inline code when it is false', () => {
1101
+ const { container } = render(<Message avatar="./img" role="user" name="User" content={INLINE_CODE} />);
1102
+ expect(container.querySelector('.pf-m-primary')).toBeFalsy();
1103
+ });
1104
+ it('should handle isPrimary correctly for table when it is true', () => {
1105
+ const { container } = render(<Message avatar="./img" role="user" name="User" content={TABLE} isPrimary />);
1106
+ expect(container.querySelector('.pf-m-primary')).toBeTruthy();
1107
+ });
1108
+ it('should handle isPrimary correctly for table when it is false', () => {
1109
+ const { container } = render(<Message avatar="./img" role="user" name="User" content={TABLE} />);
1110
+ expect(container.querySelector('.pf-m-primary')).toBeFalsy();
1111
+ });
1112
+ it('should handle isPrimary correctly for loading when it is true', () => {
1113
+ const { container } = render(<Message avatar="./img" role="user" name="User" content="" isPrimary isLoading />);
1114
+ expect(container.querySelector('.pf-m-primary')).toBeTruthy();
1115
+ });
1116
+ it('should handle isPrimary correctly for loading when it is false', () => {
1117
+ const { container } = render(<Message avatar="./img" role="user" name="User" content="" isLoading />);
1118
+
1119
+ expect(container.querySelector('.pf-m-primary')).toBeFalsy();
1120
+ });
1121
+ it('should handle isPrimary correctly for attachments when it is true', () => {
1122
+ const { container } = render(
1123
+ <Message avatar="./img" role="user" name="User" content="" isPrimary attachments={[{ name: 'testAttachment' }]} />
1124
+ );
1125
+ expect(container.querySelector('.pf-m-outline')).toBeTruthy();
1126
+ });
1127
+ it('should handle isPrimary correctly for attachments when it is false', () => {
1128
+ const { container } = render(
1129
+ <Message avatar="./img" role="user" name="User" content="" attachments={[{ name: 'testAttachment' }]} />
1130
+ );
1131
+ expect(container.querySelector('.pf-m-outline')).toBeFalsy();
1132
+ });
1096
1133
  });