@patternfly/chatbot 6.4.0-prerelease.2 → 6.4.0-prerelease.20

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 (186) hide show
  1. package/dist/cjs/Chatbot/Chatbot.js +1 -7
  2. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.d.ts +2 -0
  3. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +2 -2
  4. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +22 -2
  5. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +15 -9
  6. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +40 -2
  7. package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.js +1 -1
  8. package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.js +1 -1
  9. package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.d.ts +18 -0
  10. package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.js +25 -0
  11. package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +1 -0
  12. package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +22 -0
  13. package/dist/cjs/ChatbotHeader/index.d.ts +1 -0
  14. package/dist/cjs/ChatbotHeader/index.js +1 -0
  15. package/dist/cjs/DeepThinking/DeepThinking.d.ts +18 -0
  16. package/dist/cjs/DeepThinking/DeepThinking.js +18 -0
  17. package/dist/cjs/DeepThinking/DeepThinking.test.d.ts +1 -0
  18. package/dist/cjs/DeepThinking/DeepThinking.test.js +48 -0
  19. package/dist/cjs/DeepThinking/index.d.ts +2 -0
  20. package/dist/cjs/DeepThinking/index.js +23 -0
  21. package/dist/cjs/FilePreview/FilePreview.d.ts +26 -0
  22. package/dist/cjs/FilePreview/FilePreview.js +26 -0
  23. package/dist/cjs/FilePreview/FilePreview.test.d.ts +1 -0
  24. package/dist/cjs/FilePreview/FilePreview.test.js +97 -0
  25. package/dist/cjs/FilePreview/index.d.ts +2 -0
  26. package/dist/cjs/FilePreview/index.js +23 -0
  27. package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +3 -3
  28. package/dist/cjs/Message/LinkMessage/LinkMessage.d.ts +2 -1
  29. package/dist/cjs/Message/LinkMessage/LinkMessage.js +7 -3
  30. package/dist/cjs/Message/ListMessage/ListItemMessage.d.ts +1 -1
  31. package/dist/cjs/Message/ListMessage/ListItemMessage.js +16 -1
  32. package/dist/cjs/Message/Message.d.ts +15 -0
  33. package/dist/cjs/Message/Message.js +129 -32
  34. package/dist/cjs/Message/Message.test.js +71 -0
  35. package/dist/cjs/Message/SuperscriptMessage/SuperscriptMessage.d.ts +3 -0
  36. package/dist/cjs/Message/SuperscriptMessage/SuperscriptMessage.js +5 -0
  37. package/dist/cjs/Message/UserFeedback/UserFeedback.d.ts +15 -1
  38. package/dist/cjs/Message/UserFeedback/UserFeedback.js +4 -4
  39. package/dist/cjs/Message/UserFeedback/UserFeedback.test.js +44 -0
  40. package/dist/cjs/MessageBar/MessageBar.js +19 -4
  41. package/dist/cjs/MessageBox/JumpButton.d.ts +5 -0
  42. package/dist/cjs/MessageBox/JumpButton.js +1 -1
  43. package/dist/cjs/MessageBox/JumpButton.test.js +4 -4
  44. package/dist/cjs/MessageBox/MessageBox.d.ts +9 -0
  45. package/dist/cjs/MessageBox/MessageBox.js +2 -2
  46. package/dist/cjs/MessageBox/MessageBox.test.js +2 -2
  47. package/dist/cjs/SourcesCard/SourcesCard.d.ts +13 -1
  48. package/dist/cjs/SourcesCard/SourcesCard.js +6 -6
  49. package/dist/cjs/SourcesCard/SourcesCard.test.js +49 -0
  50. package/dist/cjs/ToolResponse/ToolResponse.d.ts +30 -0
  51. package/dist/cjs/ToolResponse/ToolResponse.js +18 -0
  52. package/dist/cjs/ToolResponse/ToolResponse.test.d.ts +1 -0
  53. package/dist/cjs/ToolResponse/ToolResponse.test.js +60 -0
  54. package/dist/cjs/ToolResponse/index.d.ts +2 -0
  55. package/dist/cjs/ToolResponse/index.js +23 -0
  56. package/dist/cjs/index.d.ts +6 -0
  57. package/dist/cjs/index.js +10 -1
  58. package/dist/css/main.css +273 -17
  59. package/dist/css/main.css.map +1 -1
  60. package/dist/dynamic/DeepThinking/package.json +1 -0
  61. package/dist/dynamic/FilePreview/package.json +1 -0
  62. package/dist/dynamic/ToolResponse/package.json +1 -0
  63. package/dist/esm/Chatbot/Chatbot.js +1 -7
  64. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.d.ts +2 -0
  65. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +2 -2
  66. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +22 -2
  67. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +17 -11
  68. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +41 -3
  69. package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +1 -1
  70. package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.js +1 -1
  71. package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.d.ts +18 -0
  72. package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.js +22 -0
  73. package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +1 -0
  74. package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +20 -0
  75. package/dist/esm/ChatbotHeader/index.d.ts +1 -0
  76. package/dist/esm/ChatbotHeader/index.js +1 -0
  77. package/dist/esm/DeepThinking/DeepThinking.d.ts +18 -0
  78. package/dist/esm/DeepThinking/DeepThinking.js +14 -0
  79. package/dist/esm/DeepThinking/DeepThinking.test.d.ts +1 -0
  80. package/dist/esm/DeepThinking/DeepThinking.test.js +43 -0
  81. package/dist/esm/DeepThinking/index.d.ts +2 -0
  82. package/dist/esm/DeepThinking/index.js +2 -0
  83. package/dist/esm/FilePreview/FilePreview.d.ts +26 -0
  84. package/dist/esm/FilePreview/FilePreview.js +21 -0
  85. package/dist/esm/FilePreview/FilePreview.test.d.ts +1 -0
  86. package/dist/esm/FilePreview/FilePreview.test.js +92 -0
  87. package/dist/esm/FilePreview/index.d.ts +2 -0
  88. package/dist/esm/FilePreview/index.js +2 -0
  89. package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +5 -5
  90. package/dist/esm/Message/LinkMessage/LinkMessage.d.ts +2 -1
  91. package/dist/esm/Message/LinkMessage/LinkMessage.js +7 -3
  92. package/dist/esm/Message/ListMessage/ListItemMessage.d.ts +1 -1
  93. package/dist/esm/Message/ListMessage/ListItemMessage.js +16 -1
  94. package/dist/esm/Message/Message.d.ts +15 -0
  95. package/dist/esm/Message/Message.js +129 -32
  96. package/dist/esm/Message/Message.test.js +71 -0
  97. package/dist/esm/Message/SuperscriptMessage/SuperscriptMessage.d.ts +3 -0
  98. package/dist/esm/Message/SuperscriptMessage/SuperscriptMessage.js +3 -0
  99. package/dist/esm/Message/UserFeedback/UserFeedback.d.ts +15 -1
  100. package/dist/esm/Message/UserFeedback/UserFeedback.js +4 -4
  101. package/dist/esm/Message/UserFeedback/UserFeedback.test.js +45 -1
  102. package/dist/esm/MessageBar/MessageBar.js +19 -4
  103. package/dist/esm/MessageBox/JumpButton.d.ts +5 -0
  104. package/dist/esm/MessageBox/JumpButton.js +1 -1
  105. package/dist/esm/MessageBox/JumpButton.test.js +4 -4
  106. package/dist/esm/MessageBox/MessageBox.d.ts +9 -0
  107. package/dist/esm/MessageBox/MessageBox.js +2 -2
  108. package/dist/esm/MessageBox/MessageBox.test.js +2 -2
  109. package/dist/esm/SourcesCard/SourcesCard.d.ts +13 -1
  110. package/dist/esm/SourcesCard/SourcesCard.js +6 -6
  111. package/dist/esm/SourcesCard/SourcesCard.test.js +50 -1
  112. package/dist/esm/ToolResponse/ToolResponse.d.ts +30 -0
  113. package/dist/esm/ToolResponse/ToolResponse.js +14 -0
  114. package/dist/esm/ToolResponse/ToolResponse.test.d.ts +1 -0
  115. package/dist/esm/ToolResponse/ToolResponse.test.js +55 -0
  116. package/dist/esm/ToolResponse/index.d.ts +2 -0
  117. package/dist/esm/ToolResponse/index.js +2 -0
  118. package/dist/esm/index.d.ts +6 -0
  119. package/dist/esm/index.js +6 -0
  120. package/dist/tsconfig.tsbuildinfo +1 -1
  121. package/package.json +7 -6
  122. package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +101 -3
  123. package/patternfly-docs/content/extensions/chatbot/examples/Messages/FilePreview.tsx +33 -0
  124. package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithDeepThinking.tsx +17 -0
  125. package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithFeedback.tsx +111 -85
  126. package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +70 -0
  127. package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithToolResponse.tsx +135 -0
  128. package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +28 -4
  129. package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +107 -2
  130. package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessageWithExtraContent.tsx +616 -3
  131. package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotConversationEditing.tsx +202 -0
  132. package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderBasic.tsx +17 -3
  133. package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +36 -5
  134. package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithPin.tsx +12 -2
  135. package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +22 -3
  136. package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +1 -1
  137. package/patternfly-docs/patternfly-docs.config.js +1 -1
  138. package/src/Chatbot/Chatbot.scss +9 -2
  139. package/src/Chatbot/Chatbot.tsx +18 -31
  140. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx +5 -1
  141. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +28 -10
  142. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +132 -3
  143. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +80 -33
  144. package/src/ChatbotHeader/ChatbotHeaderMenu.test.tsx +1 -1
  145. package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +2 -2
  146. package/src/ChatbotHeader/ChatbotHeaderNewChatButton.test.tsx +25 -0
  147. package/src/ChatbotHeader/ChatbotHeaderNewChatButton.tsx +64 -0
  148. package/src/ChatbotHeader/index.ts +1 -0
  149. package/src/ChatbotModal/ChatbotModal.scss +1 -1
  150. package/src/DeepThinking/DeepThinking.scss +24 -0
  151. package/src/DeepThinking/DeepThinking.test.tsx +61 -0
  152. package/src/DeepThinking/DeepThinking.tsx +68 -0
  153. package/src/DeepThinking/index.ts +3 -0
  154. package/src/FileDetails/__snapshots__/FileDetails.test.tsx.snap +6 -9
  155. package/src/FileDetailsLabel/__snapshots__/FileDetailsLabel.test.tsx.snap +6 -9
  156. package/src/FilePreview/FilePreview.scss +22 -0
  157. package/src/FilePreview/FilePreview.test.tsx +112 -0
  158. package/src/FilePreview/FilePreview.tsx +58 -0
  159. package/src/FilePreview/index.ts +3 -0
  160. package/src/Message/CodeBlockMessage/CodeBlockMessage.scss +2 -1
  161. package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +6 -5
  162. package/src/Message/LinkMessage/LinkMessage.tsx +6 -2
  163. package/src/Message/ListMessage/ListItemMessage.tsx +5 -1
  164. package/src/Message/ListMessage/ListMessage.scss +17 -0
  165. package/src/Message/Message.scss +44 -0
  166. package/src/Message/Message.test.tsx +90 -0
  167. package/src/Message/Message.tsx +171 -46
  168. package/src/Message/SuperscriptMessage/SuperscriptMessage.scss +8 -0
  169. package/src/Message/SuperscriptMessage/SuperscriptMessage.tsx +13 -0
  170. package/src/Message/TextMessage/TextMessage.scss +46 -5
  171. package/src/Message/UserFeedback/UserFeedback.test.tsx +107 -0
  172. package/src/Message/UserFeedback/UserFeedback.tsx +41 -6
  173. package/src/MessageBar/MessageBar.tsx +23 -3
  174. package/src/MessageBox/JumpButton.test.tsx +4 -4
  175. package/src/MessageBox/JumpButton.tsx +20 -4
  176. package/src/MessageBox/MessageBox.test.tsx +2 -2
  177. package/src/MessageBox/MessageBox.tsx +22 -1
  178. package/src/SourcesCard/SourcesCard.scss +17 -0
  179. package/src/SourcesCard/SourcesCard.test.tsx +93 -0
  180. package/src/SourcesCard/SourcesCard.tsx +116 -80
  181. package/src/ToolResponse/ToolResponse.scss +36 -0
  182. package/src/ToolResponse/ToolResponse.test.tsx +78 -0
  183. package/src/ToolResponse/ToolResponse.tsx +95 -0
  184. package/src/ToolResponse/index.ts +3 -0
  185. package/src/index.ts +9 -0
  186. package/src/main.scss +3 -0
@@ -0,0 +1,33 @@
1
+ import { useState, FunctionComponent, MouseEvent as ReactMouseEvent } from 'react';
2
+ import { Button, Checkbox } from '@patternfly/react-core';
3
+ import FilePreview from '@patternfly/chatbot/dist/dynamic/FilePreview';
4
+
5
+ export const AttachmentEditModalExample: FunctionComponent = () => {
6
+ const [isModalOpen, setIsModalOpen] = useState(false);
7
+ const [isCompact, setIsCompact] = useState(false);
8
+
9
+ const handleModalToggle = (_event: ReactMouseEvent | MouseEvent | KeyboardEvent) => {
10
+ setIsModalOpen(!isModalOpen);
11
+ };
12
+
13
+ return (
14
+ <>
15
+ <Checkbox
16
+ label="Show compact version"
17
+ isChecked={isCompact}
18
+ onChange={() => setIsCompact(!isCompact)}
19
+ id="modal-compact-no-preview"
20
+ name="modal-compact-no-preview"
21
+ ></Checkbox>
22
+ <Button onClick={handleModalToggle}>Launch file preview modal</Button>
23
+ <FilePreview
24
+ isModalOpen={isModalOpen}
25
+ handleModalToggle={handleModalToggle}
26
+ fileName="compressed-file.zip"
27
+ isCompact={isCompact}
28
+ >
29
+ Preview unavailable
30
+ </FilePreview>
31
+ </>
32
+ );
33
+ };
@@ -0,0 +1,17 @@
1
+ import { FunctionComponent } from 'react';
2
+ import Message from '@patternfly/chatbot/dist/dynamic/Message';
3
+ import patternflyAvatar from './patternfly_avatar.jpg';
4
+
5
+ export const MessageWithDeepThinkingExample: FunctionComponent = () => (
6
+ <Message
7
+ name="Bot"
8
+ role="bot"
9
+ avatar={patternflyAvatar}
10
+ content="This example has a body description that's within the recommended limit of 2 lines."
11
+ deepThinking={{
12
+ toggleContent: 'Show thinking',
13
+ subheading: 'Thought for 3 seconds',
14
+ body: "Here's why I said this."
15
+ }}
16
+ />
17
+ );
@@ -1,104 +1,130 @@
1
1
  import { useState, FunctionComponent } from 'react';
2
2
  import Message from '@patternfly/chatbot/dist/dynamic/Message';
3
3
  import patternflyAvatar from './patternfly_avatar.jpg';
4
- import { Checkbox, FormGroup, Stack } from '@patternfly/react-core';
4
+ import { Checkbox, FormGroup, Flex, FlexItem } from '@patternfly/react-core';
5
5
 
6
6
  export const MessageWithFeedbackExample: FunctionComponent = () => {
7
7
  const [hasCloseButton, setHasCloseButton] = useState(false);
8
8
  const [hasTextArea, setHasTextArea] = useState(false);
9
+ const [hasChildren, setHasChildren] = useState(false);
10
+
11
+ const children = <>Do not share any personal or other sensitive information in your feedback.</>;
9
12
 
10
13
  return (
11
14
  <>
12
- <Stack hasGutter>
13
- <FormGroup role="radiogroup" isInline fieldId="feedback-card" label="Variant">
14
- <Checkbox
15
- isChecked={hasTextArea}
16
- onChange={() => {
17
- setHasTextArea(!hasTextArea);
15
+ <Flex direction={{ default: 'column' }} spaceItems={{ default: 'spaceItemsMd' }}>
16
+ <FlexItem>
17
+ <FormGroup role="radiogroup" isInline isStack fieldId="feedback-card" label="Variant">
18
+ <Checkbox
19
+ isChecked={hasTextArea}
20
+ onChange={() => {
21
+ setHasTextArea(!hasTextArea);
22
+ }}
23
+ name="feedback-card-with-text-area"
24
+ label="Has text area"
25
+ id="has-text-area"
26
+ />
27
+ <Checkbox
28
+ isChecked={hasChildren}
29
+ onChange={() => {
30
+ setHasChildren(!hasChildren);
31
+ }}
32
+ name="feedback-card-with-children"
33
+ label="Has additional content"
34
+ id="has-children"
35
+ />
36
+ </FormGroup>
37
+ </FlexItem>
38
+ <FlexItem>
39
+ <Message
40
+ name="Bot"
41
+ role="bot"
42
+ avatar={patternflyAvatar}
43
+ content="This is a message with the feedback card:"
44
+ userFeedbackForm={{
45
+ quickResponses: [
46
+ { id: '1', content: 'Helpful information' },
47
+ { id: '2', content: 'Easy to understand' },
48
+ { id: '3', content: 'Resolved my issue' }
49
+ ],
50
+ onSubmit: (quickResponse, additionalFeedback) =>
51
+ alert(`Selected ${quickResponse} and received the additional feedback: ${additionalFeedback}`),
52
+ hasTextArea,
53
+ children: hasChildren ? children : undefined,
54
+ // eslint-disable-next-line no-console
55
+ onClose: () => console.log('closed feedback form'),
56
+ focusOnLoad: false
18
57
  }}
19
- name="basic-inline-radio"
20
- label="Has text area"
21
- id="has-text-area"
22
58
  />
23
- </FormGroup>
24
- <Message
25
- name="Bot"
26
- role="bot"
27
- avatar={patternflyAvatar}
28
- content="This is a message with the feedback card:"
29
- userFeedbackForm={{
30
- quickResponses: [
31
- { id: '1', content: 'Helpful information' },
32
- { id: '2', content: 'Easy to understand' },
33
- { id: '3', content: 'Resolved my issue' }
34
- ],
35
- onSubmit: (quickResponse, additionalFeedback) =>
36
- alert(`Selected ${quickResponse} and received the additional feedback: ${additionalFeedback}`),
37
- hasTextArea,
38
- // eslint-disable-next-line no-console
39
- onClose: () => console.log('closed feedback form'),
40
- focusOnLoad: false
41
- }}
42
- />
43
- <Message
44
- name="Bot"
45
- role="bot"
46
- avatar={patternflyAvatar}
47
- content="This is a compact message with the feedback card:"
48
- userFeedbackForm={{
49
- quickResponses: [
50
- { id: '1', content: 'Helpful information' },
51
- { id: '2', content: 'Easy to understand' },
52
- { id: '3', content: 'Resolved my issue' }
53
- ],
54
- onSubmit: (quickResponse, additionalFeedback) =>
55
- alert(`Selected ${quickResponse} and received the additional feedback: ${additionalFeedback}`),
56
- hasTextArea,
57
- // eslint-disable-next-line no-console
58
- onClose: () => console.log('closed feedback form'),
59
- focusOnLoad: false
60
- }}
61
- isCompact
62
- />
63
- </Stack>
64
- <Stack hasGutter>
65
- <FormGroup role="radiogroup" isInline fieldId="feedback-thank-you" label="Variant">
66
- <Checkbox
67
- isChecked={hasCloseButton}
68
- onChange={() => {
69
- setHasCloseButton(!hasCloseButton);
59
+ </FlexItem>
60
+ <FlexItem>
61
+ <Message
62
+ name="Bot"
63
+ role="bot"
64
+ avatar={patternflyAvatar}
65
+ content="This is a compact message with the feedback card:"
66
+ userFeedbackForm={{
67
+ quickResponses: [
68
+ { id: '1', content: 'Helpful information' },
69
+ { id: '2', content: 'Easy to understand' },
70
+ { id: '3', content: 'Resolved my issue' }
71
+ ],
72
+ onSubmit: (quickResponse, additionalFeedback) =>
73
+ alert(`Selected ${quickResponse} and received the additional feedback: ${additionalFeedback}`),
74
+ hasTextArea,
75
+ children: hasChildren ? children : undefined,
76
+ // eslint-disable-next-line no-console
77
+ onClose: () => console.log('closed feedback form'),
78
+ focusOnLoad: false
70
79
  }}
71
- name="basic-inline-radio"
72
- label="Has close button"
73
- id="has-close"
80
+ isCompact
74
81
  />
75
- </FormGroup>
76
- <Message
77
- name="Bot"
78
- role="bot"
79
- avatar={patternflyAvatar}
80
- content="This is a thank-you message, which is displayed once the feedback card is submitted:"
81
- // eslint-disable-next-line no-console
82
- userFeedbackComplete={{
82
+ </FlexItem>
83
+ </Flex>
84
+ <Flex direction={{ default: 'column' }}>
85
+ <FlexItem>
86
+ <FormGroup role="radiogroup" isInline fieldId="feedback-thank-you" label="Variant">
87
+ <Checkbox
88
+ isChecked={hasCloseButton}
89
+ onChange={() => {
90
+ setHasCloseButton(!hasCloseButton);
91
+ }}
92
+ name="basic-inline-radio"
93
+ label="Has close button"
94
+ id="has-close"
95
+ />
96
+ </FormGroup>
97
+ </FlexItem>
98
+ <FlexItem>
99
+ <Message
100
+ name="Bot"
101
+ role="bot"
102
+ avatar={patternflyAvatar}
103
+ content="This is a thank-you message, which is displayed once the feedback card is submitted:"
83
104
  // eslint-disable-next-line no-console
84
- onClose: hasCloseButton ? () => console.log('closed completion message') : undefined,
85
- focusOnLoad: false
86
- }}
87
- />
88
- <Message
89
- name="Bot"
90
- role="bot"
91
- avatar={patternflyAvatar}
92
- content="This is a compact thank-you message, which is displayed once the feedback card is submitted:"
93
- // eslint-disable-next-line no-console
94
- userFeedbackComplete={{
105
+ userFeedbackComplete={{
106
+ // eslint-disable-next-line no-console
107
+ onClose: hasCloseButton ? () => console.log('closed completion message') : undefined,
108
+ focusOnLoad: false
109
+ }}
110
+ />
111
+ </FlexItem>
112
+ <FlexItem>
113
+ <Message
114
+ name="Bot"
115
+ role="bot"
116
+ avatar={patternflyAvatar}
117
+ content="This is a compact thank-you message, which is displayed once the feedback card is submitted:"
95
118
  // eslint-disable-next-line no-console
96
- onClose: hasCloseButton ? () => console.log('closed completion message') : undefined,
97
- focusOnLoad: false
98
- }}
99
- isCompact
100
- />
101
- </Stack>
119
+ userFeedbackComplete={{
120
+ // eslint-disable-next-line no-console
121
+ onClose: hasCloseButton ? () => console.log('closed completion message') : undefined,
122
+ focusOnLoad: false
123
+ }}
124
+ isCompact
125
+ />
126
+ </FlexItem>
127
+ </Flex>
102
128
  </>
103
129
  );
104
130
  };
@@ -1,6 +1,8 @@
1
1
  import { FunctionComponent, MouseEvent as ReactMouseEvent, KeyboardEvent as ReactKeyboardEvent } from 'react';
2
2
  import Message from '@patternfly/chatbot/dist/dynamic/Message';
3
3
  import patternflyAvatar from './patternfly_avatar.jpg';
4
+ import { Button, Flex, FlexItem, Label, Popover } from '@patternfly/react-core';
5
+ import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons';
4
6
 
5
7
  export const MessageWithSourcesExample: FunctionComponent = () => {
6
8
  const onSetPage = (_event: ReactMouseEvent | ReactKeyboardEvent | MouseEvent, newPage: number) => {
@@ -8,8 +10,76 @@ export const MessageWithSourcesExample: FunctionComponent = () => {
8
10
  console.log(`Page changed to ${newPage}`);
9
11
  };
10
12
 
13
+ const date = new Date();
14
+
15
+ const datePart = date.toLocaleDateString('en', {
16
+ year: 'numeric',
17
+ month: 'short',
18
+ day: 'numeric'
19
+ });
20
+
21
+ const timePart = date.toLocaleTimeString('en', {
22
+ hour: '2-digit',
23
+ minute: '2-digit',
24
+ hour12: true
25
+ });
26
+
27
+ const formattedDate = `${datePart}, ${timePart}`;
28
+
11
29
  return (
12
30
  <>
31
+ <Message
32
+ name="Bot"
33
+ role="bot"
34
+ avatar={patternflyAvatar}
35
+ content="This example has a custom subtitle and footer with no pagination"
36
+ sources={{
37
+ sources: [
38
+ {
39
+ title: 'Getting started with Red Hat OpenShift',
40
+ subtitle: 'Red Hat knowledge base',
41
+ link: '#',
42
+ body: 'Red Hat OpenShift on IBM Cloud is a managed offering to create your own cluster of compute hosts where you can deploy and manage containerized apps on IBM Cloud ...',
43
+ isExternal: true,
44
+ footer: (
45
+ <Flex className="pf-chatbot__sources-card-subtle" gap={{ default: 'gapXs' }}>
46
+ <FlexItem alignSelf={{ default: 'alignSelfStretch' }}>
47
+ <Flex justifyContent={{ default: 'justifyContentSpaceBetween' }}>
48
+ <FlexItem>
49
+ <Label color="green">Confidence 93%</Label>
50
+ </FlexItem>
51
+ <FlexItem>
52
+ <Popover
53
+ headerContent={
54
+ <Flex gap={{ default: 'gapXs' }}>
55
+ <FlexItem>
56
+ <OutlinedQuestionCircleIcon />
57
+ </FlexItem>
58
+ <FlexItem>Why this confidence score?</FlexItem>
59
+ </Flex>
60
+ }
61
+ bodyContent={
62
+ <>
63
+ A high confidence score indicates a strong match. The system found significant overlap in
64
+ key data points, including text content, names, dates, and organizational details, with a
65
+ high degree of certainty. This match is highly reliable.
66
+ </>
67
+ }
68
+ >
69
+ <Button variant="link" icon={<OutlinedQuestionCircleIcon />}>
70
+ Learn about this score
71
+ </Button>
72
+ </Popover>
73
+ </FlexItem>
74
+ </Flex>
75
+ </FlexItem>
76
+ <FlexItem>{`Last updated: ${formattedDate}`}</FlexItem>
77
+ </Flex>
78
+ )
79
+ }
80
+ ]
81
+ }}
82
+ />
13
83
  <Message
14
84
  name="Bot"
15
85
  role="bot"
@@ -0,0 +1,135 @@
1
+ import { useState, FunctionComponent, MouseEvent as ReactMouseEvent } from 'react';
2
+ import Message from '@patternfly/chatbot/dist/dynamic/Message';
3
+ import patternflyAvatar from './patternfly_avatar.jpg';
4
+ import { CopyIcon, WrenchIcon } from '@patternfly/react-icons';
5
+ import {
6
+ Button,
7
+ DescriptionList,
8
+ DescriptionListDescription,
9
+ DescriptionListGroup,
10
+ DescriptionListTerm,
11
+ ExpandableSection,
12
+ ExpandableSectionVariant,
13
+ Flex,
14
+ FlexItem,
15
+ Label
16
+ } from '@patternfly/react-core';
17
+
18
+ export const MessageWithToolResponseExample: FunctionComponent = () => {
19
+ const [isExpanded, setIsExpanded] = useState(false);
20
+
21
+ const onToggle = (_event: ReactMouseEvent, isExpanded: boolean) => {
22
+ setIsExpanded(isExpanded);
23
+ };
24
+
25
+ return (
26
+ <Message
27
+ name="Bot"
28
+ role="bot"
29
+ avatar={patternflyAvatar}
30
+ content="This example has a body description that's within the recommended limit of 2 lines:"
31
+ toolResponse={{
32
+ toggleContent: 'Tool response: toolName',
33
+ subheading: 'Thought for 3 seconds',
34
+ body: "Here's the summary for your toolName response:",
35
+ cardTitle: (
36
+ <Flex alignItems={{ default: 'alignItemsCenter' }} justifyContent={{ default: 'justifyContentSpaceBetween' }}>
37
+ <FlexItem>
38
+ <Flex direction={{ default: 'column' }} gap={{ default: 'gapXs' }}>
39
+ <FlexItem grow={{ default: 'grow' }}>
40
+ <Flex gap={{ default: 'gapXs' }}>
41
+ <FlexItem>
42
+ <WrenchIcon style={{ color: 'var(--pf-t--global--icon--color--brand--default' }} />
43
+ </FlexItem>
44
+ <FlexItem>toolName</FlexItem>
45
+ </Flex>
46
+ </FlexItem>
47
+ <FlexItem>
48
+ <Flex gap={{ default: 'gapSm' }} style={{ fontSize: '12px', fontWeight: '400' }}>
49
+ <FlexItem>Execution time:</FlexItem>
50
+ <FlexItem>0.12 seconds</FlexItem>
51
+ </Flex>
52
+ </FlexItem>
53
+ </Flex>
54
+ </FlexItem>
55
+ <FlexItem>
56
+ <Button
57
+ variant="plain"
58
+ aria-label="Copy tool response to clipboard"
59
+ icon={<CopyIcon style={{ color: 'var(--pf-t--global--icon--color--subtle)' }} />}
60
+ ></Button>
61
+ </FlexItem>
62
+ </Flex>
63
+ ),
64
+ cardBody: (
65
+ <>
66
+ <DescriptionList
67
+ style={{ '--pf-v6-c-description-list--RowGap': 'var(--pf-t--global--spacer--md)' } as any}
68
+ aria-label="Tool response"
69
+ >
70
+ <DescriptionListGroup
71
+ style={{ '--pf-v6-c-description-list__group--RowGap': 'var(--pf-t--global--spacer--xs)' } as any}
72
+ >
73
+ <DescriptionListTerm>Parameters</DescriptionListTerm>
74
+ <DescriptionListDescription>
75
+ <Flex direction={{ default: 'column' }}>
76
+ <FlexItem>Optional description text for parameters.</FlexItem>
77
+ <FlexItem>
78
+ <Flex gap={{ default: 'gapSm' }}>
79
+ <FlexItem>
80
+ <Label variant="outline" color="blue">
81
+ type
82
+ </Label>
83
+ </FlexItem>
84
+ <FlexItem>
85
+ <Label variant="outline" color="blue">
86
+ properties
87
+ </Label>
88
+ </FlexItem>
89
+ <FlexItem>
90
+ <Label variant="outline" color="blue">
91
+ label
92
+ </Label>
93
+ </FlexItem>
94
+ <FlexItem>
95
+ <Label variant="outline" color="blue">
96
+ label
97
+ </Label>
98
+ </FlexItem>
99
+ </Flex>
100
+ </FlexItem>
101
+ </Flex>
102
+ </DescriptionListDescription>
103
+ </DescriptionListGroup>
104
+ <DescriptionListGroup
105
+ style={{ '--pf-v6-c-description-list__group--RowGap': 'var(--pf-t--global--spacer--xs)' } as any}
106
+ >
107
+ <DescriptionListTerm>Response</DescriptionListTerm>
108
+ <DescriptionListDescription>
109
+ <ExpandableSection
110
+ variant={ExpandableSectionVariant.truncate}
111
+ toggleTextExpanded="show less of response"
112
+ toggleTextCollapsed="show more of response"
113
+ onToggle={onToggle}
114
+ isExpanded={isExpanded}
115
+ style={
116
+ {
117
+ '--pf-v6-c-expandable-section__content--Opacity': '1',
118
+ '--pf-v6-c-expandable-section__content--PaddingInlineStart': 0,
119
+ '--pf-v6-c-expandable-section__content--TranslateY': 0,
120
+ '--pf-v6-c-expandable-section--m-expand-top__content--TranslateY': 0
121
+ } as any
122
+ }
123
+ >
124
+ Descriptive text about the tool response, including completion status, details on the data that was
125
+ processed, or anything else relevant to the use case.
126
+ </ExpandableSection>
127
+ </DescriptionListDescription>
128
+ </DescriptionListGroup>
129
+ </DescriptionList>
130
+ </>
131
+ )
132
+ }}
133
+ />
134
+ );
135
+ };
@@ -34,10 +34,7 @@ import Message from '@patternfly/chatbot/dist/dynamic/Message';
34
34
  import MessageDivider from '@patternfly/chatbot/dist/dynamic/MessageDivider';
35
35
  import { rehypeCodeBlockToggle } from '@patternfly/chatbot/dist/esm/Message/Plugins/rehypeCodeBlockToggle';
36
36
  import SourcesCard from '@patternfly/chatbot/dist/dynamic/SourcesCard';
37
- import { RobotIcon } from '@patternfly/react-icons/dist/esm/icons/robot-icon';
38
- import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
39
- import DownloadIcon from '@patternfly/react-icons/dist/esm/icons/download-icon';
40
- import RedoIcon from '@patternfly/react-icons/dist/esm/icons/redo-icon';
37
+ import { ArrowCircleDownIcon, ArrowRightIcon, CheckCircleIcon, CopyIcon, CubeIcon, CubesIcon, DownloadIcon, InfoCircleIcon, OutlinedQuestionCircleIcon, RedoIcon, RobotIcon, WrenchIcon } from '@patternfly/react-icons';
41
38
  import patternflyAvatar from './patternfly_avatar.jpg';
42
39
  import AttachmentEdit from '@patternfly/chatbot/dist/dynamic/AttachmentEdit';
43
40
  import FileDetails from '@patternfly/chatbot/dist/dynamic/FileDetails';
@@ -50,6 +47,7 @@ import { monitorSampleAppQuickStart } from '@patternfly/chatbot/src/Message/Quic
50
47
  import userAvatar from './user_avatar.svg';
51
48
  import squareImg from './PF-social-color-square.svg';
52
49
  import { CSSProperties, useState, Fragment, FunctionComponent, MouseEvent as ReactMouseEvent, KeyboardEvent as ReactKeyboardEvent, Ref, isValidElement, cloneElement, Children, ReactNode, useRef, useEffect } from 'react';
50
+ import FilePreview from '@patternfly/chatbot/dist/dynamic/FilePreview';
53
51
 
54
52
  The `content` prop of the `<Message>` component is passed to a `<Markdown>` component (from [react-markdown](https://remarkjs.github.io/react-markdown/)), which is configured to translate plain text strings into PatternFly [`<Content>` components](/components/content) and code blocks into PatternFly [`<CodeBlock>` components.](/components/code-block)
55
53
 
@@ -181,6 +179,24 @@ The API for a source requires a link at minimum, but we strongly recommend provi
181
179
 
182
180
  ```
183
181
 
182
+ ### Messages with tool responses
183
+
184
+ If you are using [model context protocol (MCP)](https://www.redhat.com/en/blog/model-context-protocol-discover-missing-link-ai-integration), you may find it useful to display information on tool responses as part of a message. Passing `toolResponse` to `<Message>` allows you to display a card with an optional subheading and body, as well as custom card content. Content is intentionally left fully customizable for now as this is an evolving area.
185
+
186
+ ```js file="./MessageWithToolResponse.tsx"
187
+
188
+ ```
189
+
190
+ ### Messages with deep thinking
191
+
192
+ You can share details about the "thought process" behind an LLM's response, also known as deep thinking. To display a customizable, expandable card with these details, pass `deepThinking` to `<Message>` and provide a subheading (optional) and content body.
193
+
194
+ Because this is an evolving area, this card content is currently fully customizable.
195
+
196
+ ```js file="./MessageWithDeepThinking.tsx"
197
+
198
+ ```
199
+
184
200
  ### Messages with quick start tiles
185
201
 
186
202
  [Quick start](/extensions/quick-starts/) tiles can be added to messages via the `quickStarts` prop. Users can initiate the quick start from a link within the message tile.
@@ -258,6 +274,14 @@ To allow users to edit an attached file, load a new code editor within the ChatB
258
274
 
259
275
  ```
260
276
 
277
+ ### File preview
278
+
279
+ If the contents of an attachment cannot be previewed, load a file preview modal with a view of the file name and an unavailable message. When users close the modal, return to the main ChatBot window.
280
+
281
+ ```js file="./FilePreview.tsx"
282
+
283
+ ```
284
+
261
285
  ### Failed attachment error
262
286
 
263
287
  When an attachment upload fails, a [danger alert](/components/alert) is displayed to provide details about the reason for failure.