@patternfly/chatbot 6.4.0-prerelease.13 → 6.4.0-prerelease.15

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 (22) hide show
  1. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +1 -1
  2. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +6 -6
  3. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +13 -12
  4. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +17 -5
  5. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +24 -20
  6. package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +3 -3
  7. package/dist/css/main.css +26 -30
  8. package/dist/css/main.css.map +1 -1
  9. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +1 -1
  10. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +6 -6
  11. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +13 -12
  12. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +18 -6
  13. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +24 -20
  14. package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +5 -5
  15. package/package.json +3 -3
  16. package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessageWithExtraContent.tsx +10 -1
  17. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx +6 -6
  18. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx +1 -0
  19. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +28 -36
  20. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +32 -18
  21. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +74 -60
  22. package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +6 -5
@@ -193,26 +193,30 @@ describe('ChatbotConversationHistoryNav', () => {
193
193
  const iconElement = container.querySelector('.pf-chatbot__title-icon');
194
194
  expect(iconElement).toBeInTheDocument();
195
195
  });
196
- it('Passes listTitleProps to Title', () => {
197
- render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: { Today: initialConversations }, listTitleProps: { className: 'test' } }));
198
- expect(screen.getByRole('heading', { name: /Today/i })).toHaveClass('test');
199
- });
200
- it('Overrides list title heading level when titleProps.headingLevel is passed', () => {
201
- render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: { Today: initialConversations }, listTitleProps: { headingLevel: 'h2' } }));
202
- expect(screen.queryByRole('heading', { name: /Today/i, level: 4 })).not.toBeInTheDocument();
203
- expect(screen.getByRole('heading', { name: /Today/i, level: 2 })).toBeInTheDocument();
204
- });
205
- it('Passes listProps to List when conversations is an array', () => {
206
- render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: initialConversations, listProps: { className: 'test' } }));
207
- expect(screen.getByRole('list')).toHaveClass('test');
208
- });
209
- it('Passes listProps to List when conversations is an object', () => {
210
- render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: { Today: initialConversations }, listProps: { Today: { className: 'test' } } }));
211
- expect(screen.getByRole('list')).toHaveClass('test');
212
- });
213
- it('Passes listItemProps to ListItem', () => {
214
- render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: [{ id: '1', text: 'ChatBot documentation', listItemProps: { className: 'test' } }] }));
215
- expect(screen.getByRole('listitem')).toHaveClass('test');
196
+ it('Passes menuProps to Menu', () => {
197
+ var _a;
198
+ render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: initialConversations, menuProps: { className: 'test' } }));
199
+ expect((_a = screen.getByRole('menu').parentElement) === null || _a === void 0 ? void 0 : _a.parentElement).toHaveClass('test');
200
+ });
201
+ it('Passes menuContentProps to MenuContent', () => {
202
+ render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: initialConversations, menuContentProps: { className: 'test' } }));
203
+ expect(screen.getByRole('menu').parentElement).toHaveClass('test');
204
+ });
205
+ it('Passes menuListProps to MenuList when conversations is an array', () => {
206
+ render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: initialConversations, menuListProps: { className: 'test' } }));
207
+ expect(screen.getByRole('menu')).toHaveClass('test');
208
+ });
209
+ it('Passes menuListProps to MenuList when conversations is an object', () => {
210
+ render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: { Today: initialConversations }, menuListProps: { Today: { className: 'test' } } }));
211
+ expect(screen.getByRole('menu')).toHaveClass('test');
212
+ });
213
+ it('Passes menuGroupProps to MenuGroup when conversations is an object', () => {
214
+ render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: { Today: initialConversations }, menuGroupProps: { Today: { className: 'test' } } }));
215
+ expect(screen.getByRole('menu').parentElement).toHaveClass('test');
216
+ });
217
+ it('Passes additionalProps to MenuItem', () => {
218
+ render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: [{ id: '1', text: 'ChatBot documentation', additionalProps: { className: 'test' } }] }));
219
+ expect(screen.getByRole('menuitem')).toHaveClass('test');
216
220
  });
217
221
  it('should be able to spread search input props when searchInputProps is passed', () => {
218
222
  render(_jsx(ChatbotConversationHistoryNav, { onDrawerToggle: onDrawerToggle, isDrawerOpen: true, displayMode: ChatbotDisplayMode.fullscreen, setIsDrawerOpen: jest.fn(), conversations: initialConversations, handleTextInputChange: jest.fn(), searchInputProps: { value: 'I am a sample search' } }));
@@ -13,9 +13,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
13
13
  // ============================================================================
14
14
  // Chatbot Main - Message - Content - Code Block
15
15
  // ============================================================================
16
- import { useState, useRef, useId, useCallback, useEffect } from 'react';
16
+ import { useState, useRef, useCallback, useEffect } from 'react';
17
17
  // Import PatternFly components
18
- import { CodeBlock, CodeBlockAction, CodeBlockCode, Button, Tooltip, ExpandableSection, ExpandableSectionToggle, ExpandableSectionVariant } from '@patternfly/react-core';
18
+ import { CodeBlock, CodeBlockAction, CodeBlockCode, Button, Tooltip, ExpandableSection, ExpandableSectionToggle, ExpandableSectionVariant, getUniqueId } from '@patternfly/react-core';
19
19
  import { CheckIcon } from '@patternfly/react-icons/dist/esm/icons/check-icon';
20
20
  import { CopyIcon } from '@patternfly/react-icons/dist/esm/icons/copy-icon';
21
21
  const DEFAULT_EXPANDED_TEXT = 'Show less';
@@ -26,9 +26,9 @@ const CodeBlockMessage = (_a) => {
26
26
  const [copied, setCopied] = useState(false);
27
27
  const [isExpanded, setIsExpanded] = useState(false);
28
28
  const buttonRef = useRef();
29
- const tooltipID = useId();
30
- const toggleId = useId();
31
- const contentId = useId();
29
+ const tooltipID = getUniqueId();
30
+ const toggleId = getUniqueId();
31
+ const contentId = getUniqueId();
32
32
  const codeBlockRef = useRef(null);
33
33
  const language = (_b = /language-(\w+)/.exec(className || '')) === null || _b === void 0 ? void 0 : _b[1];
34
34
  // Get custom toggle text from data attributes if available - for use with rehype plugins
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/chatbot",
3
- "version": "6.4.0-prerelease.13",
3
+ "version": "6.4.0-prerelease.15",
4
4
  "description": "This library provides React components based on PatternFly 6 that can be used to build chatbots.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -49,8 +49,8 @@
49
49
  "unist-util-visit": "^5.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "react": "^17 || ^18 || ^19",
53
- "react-dom": "^17 || ^18 || ^19"
52
+ "react": "^18 || ^19",
53
+ "react-dom": "^18 || ^19"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@patternfly/documentation-framework": "6.16.0",
@@ -331,7 +331,16 @@ Setting up cluster console...`;
331
331
  </CardHeader>
332
332
  <CardExpandableContent>
333
333
  <CardBody>
334
- <hr className="pf-v6-u-mb-md" />
334
+ <hr
335
+ style={
336
+ {
337
+ border: 'none',
338
+ height: 'var(--pf-t--global--border--width--divider--default)',
339
+ backgroundColor: 'var(--pf-t--global--border--color--control--read-only)'
340
+ } as React.CSSProperties
341
+ }
342
+ className="pf-v6-u-mb-md"
343
+ />
335
344
  <Accordion
336
345
  style={
337
346
  {
@@ -14,13 +14,13 @@ describe('ChatbotConversationHistoryDropdown', () => {
14
14
 
15
15
  it('should render the dropdown', () => {
16
16
  render(<ChatbotConversationHistoryDropdown menuItems={menuItems} menuClassName="custom-class" />);
17
- expect(screen.queryByRole('button', { name: /Conversation options/i })).toBeInTheDocument();
17
+ expect(screen.queryByRole('menuitem', { name: /Conversation options/i })).toBeInTheDocument();
18
18
  });
19
19
 
20
20
  it('should display the dropdown menuItems', () => {
21
21
  render(<ChatbotConversationHistoryDropdown menuItems={menuItems} />);
22
22
 
23
- const toggle = screen.queryByRole('button', { name: /Conversation options/i })!;
23
+ const toggle = screen.queryByRole('menuitem', { name: /Conversation options/i })!;
24
24
 
25
25
  expect(toggle).toBeInTheDocument();
26
26
  fireEvent.click(toggle);
@@ -33,7 +33,7 @@ describe('ChatbotConversationHistoryDropdown', () => {
33
33
 
34
34
  it('should invoke onSelect callback when menuitem is clicked', () => {
35
35
  render(<ChatbotConversationHistoryDropdown menuItems={menuItems} onSelect={onSelect} />);
36
- const toggle = screen.queryByRole('button', { name: /Conversation options/i })!;
36
+ const toggle = screen.queryByRole('menuitem', { name: /Conversation options/i })!;
37
37
  fireEvent.click(toggle);
38
38
  fireEvent.click(screen.getByText('Rename'));
39
39
 
@@ -42,7 +42,7 @@ describe('ChatbotConversationHistoryDropdown', () => {
42
42
 
43
43
  it('should toggle the dropdown when menuitem is clicked', () => {
44
44
  render(<ChatbotConversationHistoryDropdown menuItems={menuItems} onSelect={onSelect} />);
45
- const toggle = screen.queryByRole('button', { name: /Conversation options/i })!;
45
+ const toggle = screen.queryByRole('menuitem', { name: /Conversation options/i })!;
46
46
  fireEvent.click(toggle);
47
47
  fireEvent.click(screen.getByText('Delete'));
48
48
 
@@ -53,7 +53,7 @@ describe('ChatbotConversationHistoryDropdown', () => {
53
53
 
54
54
  it('should close the dropdown when user clicks outside', () => {
55
55
  render(<ChatbotConversationHistoryDropdown menuItems={menuItems} onSelect={onSelect} />);
56
- const toggle = screen.queryByRole('button', { name: /Conversation options/i })!;
56
+ const toggle = screen.queryByRole('menuitem', { name: /Conversation options/i })!;
57
57
  fireEvent.click(toggle);
58
58
 
59
59
  expect(screen.queryByText('Delete')).toBeInTheDocument();
@@ -64,7 +64,7 @@ describe('ChatbotConversationHistoryDropdown', () => {
64
64
 
65
65
  it('should show the tooltip when the user hovers over the toggle button', async () => {
66
66
  render(<ChatbotConversationHistoryDropdown menuItems={menuItems} label="Actions dropdown" />);
67
- const toggle = screen.queryByRole('button', { name: /Actions dropdown/i })!;
67
+ const toggle = screen.queryByRole('menuitem', { name: /Actions dropdown/i })!;
68
68
 
69
69
  fireEvent(
70
70
  toggle,
@@ -48,6 +48,7 @@ export const ChatbotConversationHistoryDropdown: FunctionComponent<ChatbotConver
48
48
  isExpanded={isOpen}
49
49
  onClick={() => setIsOpen(!isOpen)}
50
50
  id={id}
51
+ role="menuitem"
51
52
  >
52
53
  <EllipsisIcon />
53
54
  </MenuToggle>
@@ -42,61 +42,53 @@
42
42
  }
43
43
  // Drawer menu
44
44
  // ----------------------------------------------------------------------------
45
- .pf-chatbot__conversation-list {
46
- --pf-v6-c-list--Gap: var(--pf-t--global--spacer--xs);
47
-
48
- margin-block-start: var(--pf-t--global--spacer--md);
49
- margin-block-end: var(--pf-t--global--spacer--md);
45
+ .pf-v6-c-menu {
46
+ --pf-v6-c-menu--PaddingBlockStart: 0;
47
+ --pf-v6-c-menu--BackgroundColor: var(--pf-t--global--background--color--floating--default);
48
+ overflow: initial;
49
+ position: relative;
50
+ }
51
+ .pf-v6-c-menu__item-main {
52
+ --pf-v6-c-menu__item-main--ColumnGap: var(--pf-t--global--spacer--md);
50
53
  }
51
54
 
52
- .pf-chatbot__conversation-list-header {
55
+ .pf-chatbot__menu-item-header > .pf-v6-c-menu__group-title {
53
56
  color: var(--pf-t--global--text--color--subtle);
54
57
  font-weight: var(--pf-t--global--font--weight--body--bold);
55
58
  font-size: var(--pf-t--global--icon--size--font--sm);
56
- padding-inline-start: var(--pf-t--global--spacer--sm);
57
- padding-inline-end: var(--pf-t--global--spacer--sm);
59
+ --pf-v6-c-menu__group-title--PaddingInlineStart: var(--pf-t--global--spacer--sm);
60
+ --pf-v6-c-menu__group-title--PaddingInlineEnd: var(--pf-t--global--spacer--sm);
58
61
  position: -webkit-sticky;
59
62
  position: sticky;
60
63
  top: 0;
61
64
  background-color: var(--pf-t--global--background--color--floating--default);
62
65
  z-index: var(--pf-t--global--z-index--md);
63
66
  }
64
- .pf-chatbot__conversation-list-item {
65
- & > span {
66
- display: flex;
67
- column-gap: var(--pf-t--global--spacer--sm);
68
- }
69
-
70
- & .pf-chatbot__conversation-history-item {
71
- --pf-v6-c-button--JustifyContent: flex-start;
72
- --pf-v6-c-button--FontSize: var(--pf-t--global--font--size--body--lg);
73
- --pf-v6-c-button--m-link--Color: var(--pf-t--global--text--color--regular);
74
- --pf-v6-c-button--m-link__icon--Color: var(--pf-t--global--icon--color--regular);
75
- --pf-v6-c-button--m-link--hover--Color: var(--pf-t--global--text--color--regular--hover);
76
- --pf-v6-c-button--m-link--hover__icon--Color: var(--pf-t--global--icon--color--regular);
77
- --pf-v6-c-button--m-link--m-clicked--Color: var(--pf-t--global--text--color--regular--clicked);
78
- --pf-v6-c-button--m-link--m-clicked__icon--Color: var(--pf-t--global--icon--color--regular);
79
67
 
80
- column-gap: var(--pf-t--global--spacer--md);
81
- flex-basis: 100%;
82
-
83
- & .pf-v6-c-button__text {
84
- overflow: hidden;
85
- text-overflow: ellipsis;
86
- white-space: nowrap;
87
- }
88
- }
68
+ .pf-chatbot__menu-item {
69
+ --pf-v6-c-menu__item--PaddingInlineStart: var(--pf-t--global--spacer--sm);
70
+ --pf-v6-c-menu__item--PaddingInlineEnd: var(--pf-t--global--spacer--sm);
71
+ padding-block-start: var(--pf-t--global--spacer--xs);
72
+ padding-block-end: var(--pf-t--global--spacer--xs);
73
+ color: var(--pf-t--global--text--color--regular);
74
+ font-size: var(--pf-t--global--font--size--body--lg);
75
+ font-weight: var(--pf-t--global--font--weight--body--default);
76
+ border-radius: var(--pf-t--global--border--radius--small);
77
+ }
78
+ // allows focus state to have border radius
79
+ .pf-v6-c-menu__list-item.pf-chatbot__menu-item {
80
+ overflow: hidden;
89
81
  }
90
82
 
91
83
  .pf-chatbot__history-actions {
92
84
  transform: rotate(90deg);
93
85
  }
94
86
 
95
- .pf-chatbot__conversation-list-item--active {
87
+ .pf-chatbot__menu-item--active {
96
88
  background-color: var(--pf-t--global--background--color--action--plain--clicked);
97
89
  }
98
90
 
99
- button.pf-chatbot__conversation-list-item--active {
91
+ button.pf-chatbot__menu-item--active {
100
92
  background-color: initial;
101
93
  }
102
94
  }
@@ -259,8 +251,8 @@
259
251
  }
260
252
  }
261
253
 
262
- .pf-chatbot__conversation-history-item {
263
- --pf-v6-c-button--FontSize: var(--pf-t--global--font--size--body--md);
254
+ .pf-chatbot__menu-item {
255
+ font-size: var(--pf-t--global--font--size--body--md);
264
256
  }
265
257
 
266
258
  .pf-v6-c-drawer__head {
@@ -492,36 +492,36 @@ describe('ChatbotConversationHistoryNav', () => {
492
492
  expect(iconElement).toBeInTheDocument();
493
493
  });
494
494
 
495
- it('Passes listTitleProps to Title', () => {
495
+ it('Passes menuProps to Menu', () => {
496
496
  render(
497
497
  <ChatbotConversationHistoryNav
498
498
  onDrawerToggle={onDrawerToggle}
499
499
  isDrawerOpen={true}
500
500
  displayMode={ChatbotDisplayMode.fullscreen}
501
501
  setIsDrawerOpen={jest.fn()}
502
- conversations={{ Today: initialConversations }}
503
- listTitleProps={{ className: 'test' }}
502
+ conversations={initialConversations}
503
+ menuProps={{ className: 'test' }}
504
504
  />
505
505
  );
506
- expect(screen.getByRole('heading', { name: /Today/i })).toHaveClass('test');
506
+
507
+ expect(screen.getByRole('menu').parentElement?.parentElement).toHaveClass('test');
507
508
  });
508
509
 
509
- it('Overrides list title heading level when titleProps.headingLevel is passed', () => {
510
+ it('Passes menuContentProps to MenuContent', () => {
510
511
  render(
511
512
  <ChatbotConversationHistoryNav
512
513
  onDrawerToggle={onDrawerToggle}
513
514
  isDrawerOpen={true}
514
515
  displayMode={ChatbotDisplayMode.fullscreen}
515
516
  setIsDrawerOpen={jest.fn()}
516
- conversations={{ Today: initialConversations }}
517
- listTitleProps={{ headingLevel: 'h2' }}
517
+ conversations={initialConversations}
518
+ menuContentProps={{ className: 'test' }}
518
519
  />
519
520
  );
520
- expect(screen.queryByRole('heading', { name: /Today/i, level: 4 })).not.toBeInTheDocument();
521
- expect(screen.getByRole('heading', { name: /Today/i, level: 2 })).toBeInTheDocument();
521
+ expect(screen.getByRole('menu').parentElement).toHaveClass('test');
522
522
  });
523
523
 
524
- it('Passes listProps to List when conversations is an array', () => {
524
+ it('Passes menuListProps to MenuList when conversations is an array', () => {
525
525
  render(
526
526
  <ChatbotConversationHistoryNav
527
527
  onDrawerToggle={onDrawerToggle}
@@ -529,13 +529,27 @@ describe('ChatbotConversationHistoryNav', () => {
529
529
  displayMode={ChatbotDisplayMode.fullscreen}
530
530
  setIsDrawerOpen={jest.fn()}
531
531
  conversations={initialConversations}
532
- listProps={{ className: 'test' }}
532
+ menuListProps={{ className: 'test' }}
533
+ />
534
+ );
535
+ expect(screen.getByRole('menu')).toHaveClass('test');
536
+ });
537
+
538
+ it('Passes menuListProps to MenuList when conversations is an object', () => {
539
+ render(
540
+ <ChatbotConversationHistoryNav
541
+ onDrawerToggle={onDrawerToggle}
542
+ isDrawerOpen={true}
543
+ displayMode={ChatbotDisplayMode.fullscreen}
544
+ setIsDrawerOpen={jest.fn()}
545
+ conversations={{ Today: initialConversations }}
546
+ menuListProps={{ Today: { className: 'test' } }}
533
547
  />
534
548
  );
535
- expect(screen.getByRole('list')).toHaveClass('test');
549
+ expect(screen.getByRole('menu')).toHaveClass('test');
536
550
  });
537
551
 
538
- it('Passes listProps to List when conversations is an object', () => {
552
+ it('Passes menuGroupProps to MenuGroup when conversations is an object', () => {
539
553
  render(
540
554
  <ChatbotConversationHistoryNav
541
555
  onDrawerToggle={onDrawerToggle}
@@ -543,23 +557,23 @@ describe('ChatbotConversationHistoryNav', () => {
543
557
  displayMode={ChatbotDisplayMode.fullscreen}
544
558
  setIsDrawerOpen={jest.fn()}
545
559
  conversations={{ Today: initialConversations }}
546
- listProps={{ Today: { className: 'test' } }}
560
+ menuGroupProps={{ Today: { className: 'test' } }}
547
561
  />
548
562
  );
549
- expect(screen.getByRole('list')).toHaveClass('test');
563
+ expect(screen.getByRole('menu').parentElement).toHaveClass('test');
550
564
  });
551
565
 
552
- it('Passes listItemProps to ListItem', () => {
566
+ it('Passes additionalProps to MenuItem', () => {
553
567
  render(
554
568
  <ChatbotConversationHistoryNav
555
569
  onDrawerToggle={onDrawerToggle}
556
570
  isDrawerOpen={true}
557
571
  displayMode={ChatbotDisplayMode.fullscreen}
558
572
  setIsDrawerOpen={jest.fn()}
559
- conversations={[{ id: '1', text: 'ChatBot documentation', listItemProps: { className: 'test' } }]}
573
+ conversations={[{ id: '1', text: 'ChatBot documentation', additionalProps: { className: 'test' } }]}
560
574
  />
561
575
  );
562
- expect(screen.getByRole('listitem')).toHaveClass('test');
576
+ expect(screen.getByRole('menuitem')).toHaveClass('test');
563
577
  });
564
578
 
565
579
  it('should be able to spread search input props when searchInputProps is passed', () => {
@@ -2,7 +2,6 @@
2
2
  // Chatbot Header - Chatbot Conversation History Nav
3
3
  // ============================================================================
4
4
  import type { KeyboardEvent, FunctionComponent } from 'react';
5
-
6
5
  import { useRef, Fragment } from 'react';
7
6
 
8
7
  // Import PatternFly components
@@ -19,9 +18,6 @@ import {
19
18
  DrawerCloseButton,
20
19
  DrawerContentBody,
21
20
  SearchInput,
22
- List,
23
- ListItem,
24
- ListItemProps,
25
21
  Title,
26
22
  DrawerPanelContentProps,
27
23
  DrawerContentProps,
@@ -32,10 +28,18 @@ import {
32
28
  DrawerPanelBodyProps,
33
29
  SkeletonProps,
34
30
  Icon,
35
- MenuProps, // Remove in next breaking change
31
+ MenuProps,
36
32
  TitleProps,
37
- ListProps,
38
- SearchInputProps
33
+ MenuListProps,
34
+ SearchInputProps,
35
+ MenuList,
36
+ MenuGroup,
37
+ MenuItem,
38
+ Menu,
39
+ MenuContent,
40
+ MenuItemProps,
41
+ MenuGroupProps,
42
+ MenuContentProps
39
43
  } from '@patternfly/react-core';
40
44
 
41
45
  import { OutlinedClockIcon, OutlinedCommentAltIcon, PenToSquareIcon } from '@patternfly/react-icons';
@@ -61,10 +65,8 @@ export interface Conversation {
61
65
  label?: string;
62
66
  /** Callback for when user selects item. */
63
67
  onSelect?: (event?: React.MouseEvent, value?: string | number) => void;
64
- /** Additional props passed to conversation button item */
65
- additionalProps?: ButtonProps;
66
- /** Additional props passed to conversation list item */
67
- listItemProps?: Omit<ListItemProps, 'children'>;
68
+ /** Additional props passed to menu item */
69
+ additionalProps?: MenuItemProps;
68
70
  /** Custom dropdown ID to ensure uniqueness across demo instances */
69
71
  dropdownId?: string;
70
72
  }
@@ -83,10 +85,10 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
83
85
  conversations: Conversation[] | { [key: string]: Conversation[] };
84
86
  /** Additional button props for new chat button. */
85
87
  newChatButtonProps?: ButtonProps;
86
- /** Additional props applied to all conversation list headers */
87
- listTitleProps?: Partial<TitleProps>;
88
- /** Additional props applied to conversation list. If conversations is an object, you should pass an object of ListProps for each group. */
89
- listProps?: ListProps | { [key: string]: ListProps };
88
+ /** Additional props applied to conversation menu group. If conversations is an object, you should pass an object of MenuGroupProps for each group. */
89
+ menuGroupProps?: MenuGroupProps | { [key: string]: MenuGroupProps };
90
+ /** Additional props applied to conversation list. If conversations is an object, you should pass an object of MenuListProps for each group. */
91
+ menuListProps?: Omit<MenuListProps, 'children'> | { [key: string]: Omit<MenuListProps, 'children'> };
90
92
  /** Text shown in blue button */
91
93
  newChatButtonText?: string;
92
94
  /** Callback function for when blue button is clicked. Omit to hide blue "new chat button" */
@@ -107,7 +109,7 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
107
109
  reverseButtonOrder?: boolean;
108
110
  /** Custom test id for the drawer actions */
109
111
  drawerActionsTestId?: string;
110
- /** @deprecated Additional props applied to list container */
112
+ /** Additional props applied to menu */
111
113
  menuProps?: MenuProps;
112
114
  /** Additional props applied to panel */
113
115
  drawerPanelContentProps?: DrawerPanelContentProps;
@@ -143,6 +145,8 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
143
145
  navTitleProps?: Partial<TitleProps>;
144
146
  /** Visually hidden text that gets announced by assistive technologies. Should be used to convey the result count when the search input value changes. */
145
147
  searchInputScreenReaderText?: string;
148
+ /** Additional props passed to MenuContent */
149
+ menuContentProps?: Omit<MenuContentProps, 'ref'>;
146
150
  }
147
151
 
148
152
  export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversationHistoryNavProps> = ({
@@ -152,8 +156,7 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
152
156
  activeItemId,
153
157
  onSelectActiveItem,
154
158
  conversations,
155
- listTitleProps,
156
- listProps,
159
+ menuListProps,
157
160
  newChatButtonText = 'New chat',
158
161
  drawerContent,
159
162
  onNewChat,
@@ -182,6 +185,9 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
182
185
  navTitleProps,
183
186
  navTitleIcon = <OutlinedClockIcon />,
184
187
  searchInputScreenReaderText,
188
+ menuProps,
189
+ menuGroupProps,
190
+ menuContentProps,
185
191
  ...props
186
192
  }: ChatbotConversationHistoryNavProps) => {
187
193
  const drawerRef = useRef<HTMLDivElement>(null);
@@ -190,61 +196,65 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
190
196
  drawerRef.current && drawerRef.current.focus();
191
197
  };
192
198
 
199
+ const isConversation = (item: any): item is Conversation =>
200
+ item && typeof item === 'object' && 'id' in item && 'text' in item;
201
+
193
202
  const getNavItem = (conversation: Conversation) => (
194
- <ListItem
195
- className={`pf-chatbot__conversation-list-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__conversation-list-item--active' : ''}`}
196
- key={conversation.id}
197
- {...conversation.listItemProps}
198
- /* eslint-enable indent */
203
+ <MenuItem
204
+ className={`pf-chatbot__menu-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__menu-item--active' : ''}`}
205
+ itemId={conversation.id}
206
+ {...(conversation.noIcon ? {} : { icon: conversation.icon ?? <OutlinedCommentAltIcon /> })}
207
+ /* eslint-disable indent */
208
+ {...(conversation.menuItems
209
+ ? {
210
+ actions: (
211
+ <ConversationHistoryDropdown
212
+ menuClassName={conversation.menuClassName}
213
+ onSelect={conversation.onSelect}
214
+ menuItems={conversation.menuItems}
215
+ label={conversation.label}
216
+ />
217
+ )
218
+ }
219
+ : {})}
220
+ {...conversation.additionalProps}
199
221
  >
200
- <>
201
- <Button
202
- className="pf-chatbot__conversation-history-item"
203
- variant="link"
204
- {...conversation.additionalProps}
205
- {...(conversation.noIcon ? {} : { icon: conversation.icon ?? <OutlinedCommentAltIcon /> })}
206
- onClick={(event) => onSelectActiveItem?.(event, conversation.id)}
207
- >
208
- {conversation.text}
209
- </Button>
210
- {conversation.menuItems && (
211
- <ConversationHistoryDropdown
212
- menuClassName={conversation.menuClassName}
213
- onSelect={conversation.onSelect}
214
- menuItems={conversation.menuItems}
215
- label={conversation.label}
216
- id={conversation.dropdownId}
217
- />
218
- )}
219
- </>
220
- </ListItem>
222
+ {conversation.text}
223
+ </MenuItem>
221
224
  );
222
225
 
223
226
  const buildConversations = () => {
224
227
  if (Array.isArray(conversations)) {
225
228
  return (
226
- <List className="pf-chatbot__conversation-list" isPlain {...listProps}>
227
- {conversations.map((conversation) => (
228
- <Fragment key={conversation.id}>{getNavItem(conversation)}</Fragment>
229
- ))}
230
- </List>
229
+ <MenuList {...menuListProps}>
230
+ {conversations.map((conversation) => {
231
+ if (isConversation(conversation)) {
232
+ return <Fragment key={conversation.id}>{getNavItem(conversation)}</Fragment>;
233
+ } else {
234
+ return conversation;
235
+ }
236
+ })}
237
+ </MenuList>
231
238
  );
232
239
  } else {
233
240
  return (
234
- <div>
241
+ <>
235
242
  {Object.keys(conversations).map((navGroup) => (
236
- <section key={navGroup}>
237
- <Title headingLevel="h4" className="pf-chatbot__conversation-list-header" {...listTitleProps}>
238
- {navGroup}
239
- </Title>
240
- <List className="pf-chatbot__conversation-list" isPlain {...listProps?.[navGroup]}>
241
- {conversations[navGroup].map((conversation) => (
243
+ <MenuGroup
244
+ className="pf-chatbot__menu-item-header"
245
+ label={navGroup}
246
+ key={navGroup}
247
+ labelHeadingLevel="h3"
248
+ {...menuGroupProps?.[navGroup]}
249
+ >
250
+ <MenuList {...menuListProps?.[navGroup]}>
251
+ {conversations[navGroup].map((conversation: Conversation) => (
242
252
  <Fragment key={conversation.id}>{getNavItem(conversation)}</Fragment>
243
253
  ))}
244
- </List>
245
- </section>
254
+ </MenuList>
255
+ </MenuGroup>
246
256
  ))}
247
- </div>
257
+ </>
248
258
  );
249
259
  }
250
260
  };
@@ -264,7 +274,11 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
264
274
  if (noResultsState) {
265
275
  return <HistoryEmptyState {...noResultsState} />;
266
276
  }
267
- return <>{buildConversations()}</>;
277
+ return (
278
+ <Menu isPlain onSelect={onSelectActiveItem} activeItemId={activeItemId} {...menuProps}>
279
+ <MenuContent {...menuContentProps}>{buildConversations()}</MenuContent>
280
+ </Menu>
281
+ );
268
282
  };
269
283
 
270
284
  const renderDrawerContent = () => (
@@ -1,7 +1,7 @@
1
1
  // ============================================================================
2
2
  // Chatbot Main - Message - Content - Code Block
3
3
  // ============================================================================
4
- import { useState, useRef, useId, useCallback, useEffect } from 'react';
4
+ import { useState, useRef, useCallback, useEffect } from 'react';
5
5
  // Import PatternFly components
6
6
  import {
7
7
  CodeBlock,
@@ -13,7 +13,8 @@ import {
13
13
  ExpandableSectionToggle,
14
14
  ExpandableSectionProps,
15
15
  ExpandableSectionToggleProps,
16
- ExpandableSectionVariant
16
+ ExpandableSectionVariant,
17
+ getUniqueId
17
18
  } from '@patternfly/react-core';
18
19
 
19
20
  import { CheckIcon } from '@patternfly/react-icons/dist/esm/icons/check-icon';
@@ -56,9 +57,9 @@ const CodeBlockMessage = ({
56
57
  const [isExpanded, setIsExpanded] = useState(false);
57
58
 
58
59
  const buttonRef = useRef();
59
- const tooltipID = useId();
60
- const toggleId = useId();
61
- const contentId = useId();
60
+ const tooltipID = getUniqueId();
61
+ const toggleId = getUniqueId();
62
+ const contentId = getUniqueId();
62
63
  const codeBlockRef = useRef<HTMLDivElement>(null);
63
64
 
64
65
  const language = /language-(\w+)/.exec(className || '')?.[1];