@patternfly/chatbot 6.4.0-prerelease.5 → 6.4.0-prerelease.7

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 (21) 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 +15 -4
  4. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +7 -13
  5. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +25 -0
  6. package/dist/css/main.css +31 -27
  7. package/dist/css/main.css.map +1 -1
  8. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +1 -1
  9. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +6 -6
  10. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +15 -4
  11. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +8 -14
  12. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +25 -0
  13. package/package.json +1 -1
  14. package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotConversationEditing.tsx +202 -0
  15. package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +14 -1
  16. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx +6 -6
  17. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx +0 -1
  18. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +40 -32
  19. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +86 -0
  20. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +60 -49
  21. package/src/ChatbotModal/ChatbotModal.scss +1 -1
@@ -8,6 +8,7 @@ import { useRef, Fragment } from 'react';
8
8
  // Import PatternFly components
9
9
  import {
10
10
  Button,
11
+ ButtonProps,
11
12
  Drawer,
12
13
  DrawerPanelContent,
13
14
  DrawerContent,
@@ -18,13 +19,10 @@ import {
18
19
  DrawerCloseButton,
19
20
  DrawerContentBody,
20
21
  SearchInput,
21
- Menu,
22
- MenuList,
23
- MenuGroup,
24
- MenuItem,
25
- MenuContent,
26
- MenuItemProps,
27
- MenuProps,
22
+ List,
23
+ ListItem,
24
+ ListItemProps,
25
+ Title,
28
26
  DrawerPanelContentProps,
29
27
  DrawerContentProps,
30
28
  DrawerContentBodyProps,
@@ -33,9 +31,11 @@ import {
33
31
  DrawerCloseButtonProps,
34
32
  DrawerPanelBodyProps,
35
33
  SkeletonProps,
36
- Title,
37
34
  Icon,
38
- ButtonProps
35
+ MenuProps, // Remove in next breaking change
36
+ TitleProps,
37
+ ListProps,
38
+ SearchInputProps
39
39
  } from '@patternfly/react-core';
40
40
 
41
41
  import { OutlinedClockIcon, OutlinedCommentAltIcon, PenToSquareIcon } from '@patternfly/react-icons';
@@ -61,8 +61,10 @@ export interface Conversation {
61
61
  label?: string;
62
62
  /** Callback for when user selects item. */
63
63
  onSelect?: (event?: React.MouseEvent, value?: string | number) => void;
64
- /** Additional props passed to conversation menu item */
65
- additionalProps?: MenuItemProps;
64
+ /** Additional props passed to conversation button item */
65
+ additionalProps?: ButtonProps;
66
+ /** Additional props passed to conversation list item */
67
+ listItemProps?: Omit<ListItemProps, 'children'>;
66
68
  }
67
69
  export interface ChatbotConversationHistoryNavProps extends DrawerProps {
68
70
  /** Function called to toggle drawer */
@@ -79,6 +81,10 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
79
81
  conversations: Conversation[] | { [key: string]: Conversation[] };
80
82
  /** Additional button props for new chat button. */
81
83
  newChatButtonProps?: ButtonProps;
84
+ /** Additional props applied to all conversation list headers */
85
+ titleProps?: Partial<TitleProps>;
86
+ /** Additional props applied to conversation list. If conversations is an object, you should pass an object of ListProps for each group. */
87
+ listProps?: ListProps | { [key: string]: ListProps };
82
88
  /** Text shown in blue button */
83
89
  newChatButtonText?: string;
84
90
  /** Callback function for when blue button is clicked. Omit to hide blue "new chat button" */
@@ -89,6 +95,8 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
89
95
  searchInputPlaceholder?: string;
90
96
  /** Aria label for search input */
91
97
  searchInputAriaLabel?: string;
98
+ /** Additional props passed to search input */
99
+ searchInputProps?: SearchInputProps;
92
100
  /** A callback for when the input value changes. Omit to hide input field */
93
101
  handleTextInputChange?: (value: string) => void;
94
102
  /** Display mode of chatbot */
@@ -97,7 +105,7 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
97
105
  reverseButtonOrder?: boolean;
98
106
  /** Custom test id for the drawer actions */
99
107
  drawerActionsTestId?: string;
100
- /** Additional props applied to menu */
108
+ /** @deprecated Additional props applied to list container */
101
109
  menuProps?: MenuProps;
102
110
  /** Additional props applied to panel */
103
111
  drawerPanelContentProps?: DrawerPanelContentProps;
@@ -136,17 +144,19 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
136
144
  activeItemId,
137
145
  onSelectActiveItem,
138
146
  conversations,
147
+ titleProps,
148
+ listProps,
139
149
  newChatButtonText = 'New chat',
140
150
  drawerContent,
141
151
  onNewChat,
142
152
  newChatButtonProps,
143
153
  searchInputPlaceholder = 'Search previous conversations...',
144
154
  searchInputAriaLabel = 'Filter menu items',
155
+ searchInputProps,
145
156
  handleTextInputChange,
146
157
  displayMode,
147
158
  reverseButtonOrder = false,
148
159
  drawerActionsTestId = 'chatbot-nav-drawer-actions',
149
- menuProps,
150
160
  drawerPanelContentProps,
151
161
  drawerContentProps,
152
162
  drawerContentBodyProps,
@@ -170,55 +180,59 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
170
180
  };
171
181
 
172
182
  const getNavItem = (conversation: Conversation) => (
173
- <MenuItem
174
- className={`pf-chatbot__menu-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__menu-item--active' : ''}`}
175
- itemId={conversation.id}
183
+ <ListItem
184
+ className={`pf-chatbot__conversation-list-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__conversation-list-item--active' : ''}`}
176
185
  key={conversation.id}
177
- {...(conversation.noIcon ? {} : { icon: conversation.icon ?? <OutlinedCommentAltIcon /> })}
178
- /* eslint-disable indent */
179
- {...(conversation.menuItems
180
- ? {
181
- actions: (
182
- <ConversationHistoryDropdown
183
- menuClassName={conversation.menuClassName}
184
- onSelect={conversation.onSelect}
185
- menuItems={conversation.menuItems}
186
- label={conversation.label}
187
- />
188
- )
189
- }
190
- : {})}
191
- {...conversation.additionalProps}
186
+ {...conversation.listItemProps}
192
187
  /* eslint-enable indent */
193
188
  >
194
- {conversation.text}
195
- </MenuItem>
189
+ <>
190
+ <Button
191
+ className="pf-chatbot__conversation-history-item"
192
+ variant="link"
193
+ {...conversation.additionalProps}
194
+ {...(conversation.noIcon ? {} : { icon: conversation.icon ?? <OutlinedCommentAltIcon /> })}
195
+ onClick={(event) => onSelectActiveItem?.(event, conversation.id)}
196
+ >
197
+ {conversation.text}
198
+ </Button>
199
+ {conversation.menuItems && (
200
+ <ConversationHistoryDropdown
201
+ menuClassName={conversation.menuClassName}
202
+ onSelect={conversation.onSelect}
203
+ menuItems={conversation.menuItems}
204
+ label={conversation.label}
205
+ />
206
+ )}
207
+ </>
208
+ </ListItem>
196
209
  );
197
210
 
198
- const buildMenu = () => {
211
+ const buildConversations = () => {
199
212
  if (Array.isArray(conversations)) {
200
- // Render for array of MenuItemObject
201
213
  return (
202
- <MenuList>
214
+ <List className="pf-chatbot__conversation-list" isPlain {...listProps}>
203
215
  {conversations.map((conversation) => (
204
216
  <Fragment key={conversation.id}>{getNavItem(conversation)}</Fragment>
205
217
  ))}
206
- </MenuList>
218
+ </List>
207
219
  );
208
220
  } else {
209
- // Render for object with NavItemObject arrays as values
210
221
  return (
211
- <>
222
+ <div>
212
223
  {Object.keys(conversations).map((navGroup) => (
213
- <MenuGroup className="pf-chatbot__menu-item-header" label={navGroup} key={navGroup}>
214
- <MenuList>
224
+ <section key={navGroup}>
225
+ <Title headingLevel="h4" className="pf-chatbot__conversation-list-header" {...titleProps}>
226
+ {navGroup}
227
+ </Title>
228
+ <List className="pf-chatbot__conversation-list" isPlain {...listProps?.[navGroup]}>
215
229
  {conversations[navGroup].map((conversation) => (
216
230
  <Fragment key={conversation.id}>{getNavItem(conversation)}</Fragment>
217
231
  ))}
218
- </MenuList>
219
- </MenuGroup>
232
+ </List>
233
+ </section>
220
234
  ))}
221
- </>
235
+ </div>
222
236
  );
223
237
  }
224
238
  };
@@ -238,11 +252,7 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
238
252
  if (noResultsState) {
239
253
  return <HistoryEmptyState {...noResultsState} />;
240
254
  }
241
- return (
242
- <Menu isPlain onSelect={onSelectActiveItem} activeItemId={activeItemId} {...menuProps}>
243
- <MenuContent>{buildMenu()}</MenuContent>
244
- </Menu>
245
- );
255
+ return <>{buildConversations()}</>;
246
256
  };
247
257
 
248
258
  const renderDrawerContent = () => (
@@ -286,6 +296,7 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
286
296
  aria-label={searchInputAriaLabel}
287
297
  onChange={(_event, value) => handleTextInputChange(value)}
288
298
  placeholder={searchInputPlaceholder}
299
+ {...searchInputProps}
289
300
  />
290
301
  </div>
291
302
  )}
@@ -20,7 +20,7 @@
20
20
  padding-block-end: var(--pf-t--global--spacer--xl);
21
21
  }
22
22
  .pf-v6-c-modal-box__header {
23
- padding-block-end: var(--pf-t--global--spacer--lg);
23
+ padding-block-end: var(--pf-t--global--spacer--sm);
24
24
  }
25
25
  }
26
26