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

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 (225) 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/FileDetails/FileDetails.d.ts +22 -3
  22. package/dist/cjs/FileDetails/FileDetails.js +27 -912
  23. package/dist/cjs/FileDetails/FileDetails.test.js +16 -0
  24. package/dist/cjs/FileDetailsLabel/FileDetailsLabel.d.ts +8 -2
  25. package/dist/cjs/FileDetailsLabel/FileDetailsLabel.js +14 -2
  26. package/dist/cjs/FileDetailsLabel/FileDetailsLabel.test.js +19 -1
  27. package/dist/cjs/FilePreview/FilePreview.d.ts +26 -0
  28. package/dist/cjs/FilePreview/FilePreview.js +26 -0
  29. package/dist/cjs/FilePreview/FilePreview.test.d.ts +1 -0
  30. package/dist/cjs/FilePreview/FilePreview.test.js +97 -0
  31. package/dist/cjs/FilePreview/index.d.ts +2 -0
  32. package/dist/cjs/FilePreview/index.js +23 -0
  33. package/dist/cjs/ImagePreview/ImagePreview.d.ts +53 -0
  34. package/dist/cjs/ImagePreview/ImagePreview.js +47 -0
  35. package/dist/cjs/ImagePreview/ImagePreview.test.d.ts +1 -0
  36. package/dist/cjs/ImagePreview/ImagePreview.test.js +225 -0
  37. package/dist/cjs/ImagePreview/index.d.ts +2 -0
  38. package/dist/cjs/ImagePreview/index.js +23 -0
  39. package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +3 -3
  40. package/dist/cjs/Message/LinkMessage/LinkMessage.d.ts +2 -1
  41. package/dist/cjs/Message/LinkMessage/LinkMessage.js +7 -3
  42. package/dist/cjs/Message/ListMessage/ListItemMessage.d.ts +1 -1
  43. package/dist/cjs/Message/ListMessage/ListItemMessage.js +16 -1
  44. package/dist/cjs/Message/Message.d.ts +15 -0
  45. package/dist/cjs/Message/Message.js +129 -32
  46. package/dist/cjs/Message/Message.test.js +71 -0
  47. package/dist/cjs/Message/SuperscriptMessage/SuperscriptMessage.d.ts +3 -0
  48. package/dist/cjs/Message/SuperscriptMessage/SuperscriptMessage.js +5 -0
  49. package/dist/cjs/Message/UserFeedback/UserFeedback.d.ts +15 -1
  50. package/dist/cjs/Message/UserFeedback/UserFeedback.js +4 -4
  51. package/dist/cjs/Message/UserFeedback/UserFeedback.test.js +44 -0
  52. package/dist/cjs/MessageBar/MessageBar.js +19 -4
  53. package/dist/cjs/MessageBox/JumpButton.d.ts +5 -0
  54. package/dist/cjs/MessageBox/JumpButton.js +1 -1
  55. package/dist/cjs/MessageBox/JumpButton.test.js +4 -4
  56. package/dist/cjs/MessageBox/MessageBox.d.ts +9 -0
  57. package/dist/cjs/MessageBox/MessageBox.js +2 -2
  58. package/dist/cjs/MessageBox/MessageBox.test.js +2 -2
  59. package/dist/cjs/SourcesCard/SourcesCard.d.ts +13 -1
  60. package/dist/cjs/SourcesCard/SourcesCard.js +6 -6
  61. package/dist/cjs/SourcesCard/SourcesCard.test.js +49 -0
  62. package/dist/cjs/ToolResponse/ToolResponse.d.ts +30 -0
  63. package/dist/cjs/ToolResponse/ToolResponse.js +18 -0
  64. package/dist/cjs/ToolResponse/ToolResponse.test.d.ts +1 -0
  65. package/dist/cjs/ToolResponse/ToolResponse.test.js +60 -0
  66. package/dist/cjs/ToolResponse/index.d.ts +2 -0
  67. package/dist/cjs/ToolResponse/index.js +23 -0
  68. package/dist/cjs/index.d.ts +8 -0
  69. package/dist/cjs/index.js +13 -1
  70. package/dist/css/main.css +339 -27
  71. package/dist/css/main.css.map +1 -1
  72. package/dist/dynamic/DeepThinking/package.json +1 -0
  73. package/dist/dynamic/FilePreview/package.json +1 -0
  74. package/dist/dynamic/ImagePreview/package.json +1 -0
  75. package/dist/dynamic/ToolResponse/package.json +1 -0
  76. package/dist/esm/Chatbot/Chatbot.js +1 -7
  77. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.d.ts +2 -0
  78. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +2 -2
  79. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +22 -2
  80. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +17 -11
  81. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +41 -3
  82. package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +1 -1
  83. package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.js +1 -1
  84. package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.d.ts +18 -0
  85. package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.js +22 -0
  86. package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +1 -0
  87. package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +20 -0
  88. package/dist/esm/ChatbotHeader/index.d.ts +1 -0
  89. package/dist/esm/ChatbotHeader/index.js +1 -0
  90. package/dist/esm/DeepThinking/DeepThinking.d.ts +18 -0
  91. package/dist/esm/DeepThinking/DeepThinking.js +14 -0
  92. package/dist/esm/DeepThinking/DeepThinking.test.d.ts +1 -0
  93. package/dist/esm/DeepThinking/DeepThinking.test.js +43 -0
  94. package/dist/esm/DeepThinking/index.d.ts +2 -0
  95. package/dist/esm/DeepThinking/index.js +2 -0
  96. package/dist/esm/FileDetails/FileDetails.d.ts +22 -3
  97. package/dist/esm/FileDetails/FileDetails.js +27 -912
  98. package/dist/esm/FileDetails/FileDetails.test.js +16 -0
  99. package/dist/esm/FileDetailsLabel/FileDetailsLabel.d.ts +8 -2
  100. package/dist/esm/FileDetailsLabel/FileDetailsLabel.js +14 -2
  101. package/dist/esm/FileDetailsLabel/FileDetailsLabel.test.js +19 -1
  102. package/dist/esm/FilePreview/FilePreview.d.ts +26 -0
  103. package/dist/esm/FilePreview/FilePreview.js +21 -0
  104. package/dist/esm/FilePreview/FilePreview.test.d.ts +1 -0
  105. package/dist/esm/FilePreview/FilePreview.test.js +92 -0
  106. package/dist/esm/FilePreview/index.d.ts +2 -0
  107. package/dist/esm/FilePreview/index.js +2 -0
  108. package/dist/esm/ImagePreview/ImagePreview.d.ts +53 -0
  109. package/dist/esm/ImagePreview/ImagePreview.js +42 -0
  110. package/dist/esm/ImagePreview/ImagePreview.test.d.ts +1 -0
  111. package/dist/esm/ImagePreview/ImagePreview.test.js +220 -0
  112. package/dist/esm/ImagePreview/index.d.ts +2 -0
  113. package/dist/esm/ImagePreview/index.js +2 -0
  114. package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +5 -5
  115. package/dist/esm/Message/LinkMessage/LinkMessage.d.ts +2 -1
  116. package/dist/esm/Message/LinkMessage/LinkMessage.js +7 -3
  117. package/dist/esm/Message/ListMessage/ListItemMessage.d.ts +1 -1
  118. package/dist/esm/Message/ListMessage/ListItemMessage.js +16 -1
  119. package/dist/esm/Message/Message.d.ts +15 -0
  120. package/dist/esm/Message/Message.js +129 -32
  121. package/dist/esm/Message/Message.test.js +71 -0
  122. package/dist/esm/Message/SuperscriptMessage/SuperscriptMessage.d.ts +3 -0
  123. package/dist/esm/Message/SuperscriptMessage/SuperscriptMessage.js +3 -0
  124. package/dist/esm/Message/UserFeedback/UserFeedback.d.ts +15 -1
  125. package/dist/esm/Message/UserFeedback/UserFeedback.js +4 -4
  126. package/dist/esm/Message/UserFeedback/UserFeedback.test.js +45 -1
  127. package/dist/esm/MessageBar/MessageBar.js +19 -4
  128. package/dist/esm/MessageBox/JumpButton.d.ts +5 -0
  129. package/dist/esm/MessageBox/JumpButton.js +1 -1
  130. package/dist/esm/MessageBox/JumpButton.test.js +4 -4
  131. package/dist/esm/MessageBox/MessageBox.d.ts +9 -0
  132. package/dist/esm/MessageBox/MessageBox.js +2 -2
  133. package/dist/esm/MessageBox/MessageBox.test.js +2 -2
  134. package/dist/esm/SourcesCard/SourcesCard.d.ts +13 -1
  135. package/dist/esm/SourcesCard/SourcesCard.js +6 -6
  136. package/dist/esm/SourcesCard/SourcesCard.test.js +50 -1
  137. package/dist/esm/ToolResponse/ToolResponse.d.ts +30 -0
  138. package/dist/esm/ToolResponse/ToolResponse.js +14 -0
  139. package/dist/esm/ToolResponse/ToolResponse.test.d.ts +1 -0
  140. package/dist/esm/ToolResponse/ToolResponse.test.js +55 -0
  141. package/dist/esm/ToolResponse/index.d.ts +2 -0
  142. package/dist/esm/ToolResponse/index.js +2 -0
  143. package/dist/esm/index.d.ts +8 -0
  144. package/dist/esm/index.js +8 -0
  145. package/dist/tsconfig.tsbuildinfo +1 -1
  146. package/package.json +7 -6
  147. package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachmentEdit.tsx +1 -1
  148. package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +101 -3
  149. package/patternfly-docs/content/extensions/chatbot/examples/Messages/FilePreview.tsx +33 -0
  150. package/patternfly-docs/content/extensions/chatbot/examples/Messages/ImagePreview.tsx +53 -0
  151. package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithDeepThinking.tsx +17 -0
  152. package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithFeedback.tsx +111 -85
  153. package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +70 -0
  154. package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithToolResponse.tsx +135 -0
  155. package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +38 -4
  156. package/patternfly-docs/content/extensions/chatbot/examples/Messages/PreviewAttachment.tsx +1 -1
  157. package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +107 -2
  158. package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessageWithExtraContent.tsx +616 -3
  159. package/patternfly-docs/content/extensions/chatbot/examples/Messages/file-preview.svg +9 -0
  160. package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotConversationEditing.tsx +202 -0
  161. package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderBasic.tsx +17 -3
  162. package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +36 -5
  163. package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithPin.tsx +12 -2
  164. package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +22 -3
  165. package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +1 -1
  166. package/patternfly-docs/patternfly-docs.config.js +1 -1
  167. package/src/Chatbot/Chatbot.scss +9 -2
  168. package/src/Chatbot/Chatbot.tsx +18 -31
  169. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx +5 -1
  170. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +16 -10
  171. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +132 -3
  172. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +80 -33
  173. package/src/ChatbotHeader/ChatbotHeaderMenu.test.tsx +1 -1
  174. package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +2 -2
  175. package/src/ChatbotHeader/ChatbotHeaderNewChatButton.test.tsx +25 -0
  176. package/src/ChatbotHeader/ChatbotHeaderNewChatButton.tsx +64 -0
  177. package/src/ChatbotHeader/index.ts +1 -0
  178. package/src/ChatbotModal/ChatbotModal.scss +1 -1
  179. package/src/DeepThinking/DeepThinking.scss +24 -0
  180. package/src/DeepThinking/DeepThinking.test.tsx +61 -0
  181. package/src/DeepThinking/DeepThinking.tsx +68 -0
  182. package/src/DeepThinking/index.ts +3 -0
  183. package/src/FileDetails/FileDetails.scss +10 -0
  184. package/src/FileDetails/FileDetails.test.tsx +16 -0
  185. package/src/FileDetails/FileDetails.tsx +89 -32
  186. package/src/FileDetails/__snapshots__/FileDetails.test.tsx.snap +20 -14
  187. package/src/FileDetailsLabel/FileDetailsLabel.test.tsx +21 -1
  188. package/src/FileDetailsLabel/FileDetailsLabel.tsx +16 -3
  189. package/src/FileDetailsLabel/__snapshots__/FileDetailsLabel.test.tsx.snap +20 -14
  190. package/src/FilePreview/FilePreview.scss +22 -0
  191. package/src/FilePreview/FilePreview.test.tsx +112 -0
  192. package/src/FilePreview/FilePreview.tsx +58 -0
  193. package/src/FilePreview/index.ts +3 -0
  194. package/src/ImagePreview/ImagePreview.scss +61 -0
  195. package/src/ImagePreview/ImagePreview.test.tsx +253 -0
  196. package/src/ImagePreview/ImagePreview.tsx +200 -0
  197. package/src/ImagePreview/index.ts +3 -0
  198. package/src/Message/CodeBlockMessage/CodeBlockMessage.scss +2 -1
  199. package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +6 -5
  200. package/src/Message/LinkMessage/LinkMessage.tsx +6 -2
  201. package/src/Message/ListMessage/ListItemMessage.tsx +5 -1
  202. package/src/Message/ListMessage/ListMessage.scss +17 -0
  203. package/src/Message/Message.scss +44 -0
  204. package/src/Message/Message.test.tsx +90 -0
  205. package/src/Message/Message.tsx +171 -46
  206. package/src/Message/SuperscriptMessage/SuperscriptMessage.scss +8 -0
  207. package/src/Message/SuperscriptMessage/SuperscriptMessage.tsx +13 -0
  208. package/src/Message/TextMessage/TextMessage.scss +46 -5
  209. package/src/Message/UserFeedback/UserFeedback.test.tsx +107 -0
  210. package/src/Message/UserFeedback/UserFeedback.tsx +41 -6
  211. package/src/MessageBar/MessageBar.tsx +23 -3
  212. package/src/MessageBox/JumpButton.test.tsx +4 -4
  213. package/src/MessageBox/JumpButton.tsx +20 -4
  214. package/src/MessageBox/MessageBox.scss +0 -12
  215. package/src/MessageBox/MessageBox.test.tsx +2 -2
  216. package/src/MessageBox/MessageBox.tsx +23 -2
  217. package/src/SourcesCard/SourcesCard.scss +17 -0
  218. package/src/SourcesCard/SourcesCard.test.tsx +93 -0
  219. package/src/SourcesCard/SourcesCard.tsx +116 -80
  220. package/src/ToolResponse/ToolResponse.scss +36 -0
  221. package/src/ToolResponse/ToolResponse.test.tsx +78 -0
  222. package/src/ToolResponse/ToolResponse.tsx +95 -0
  223. package/src/ToolResponse/index.ts +3 -0
  224. package/src/index.ts +12 -0
  225. package/src/main.scss +16 -0
@@ -1,4 +1,12 @@
1
- import { CSSProperties, useState, Fragment, FunctionComponent, MouseEvent, Ref } from 'react';
1
+ import {
2
+ CSSProperties,
3
+ useState,
4
+ Fragment,
5
+ FunctionComponent,
6
+ MouseEvent as ReactMouseEvent,
7
+ KeyboardEvent as ReactKeyboardEvent,
8
+ Ref
9
+ } from 'react';
2
10
  import Message from '@patternfly/chatbot/dist/dynamic/Message';
3
11
  import patternflyAvatar from './patternfly_avatar.jpg';
4
12
  import squareImg from './PF-social-color-square.svg';
@@ -44,6 +52,8 @@ export const BotMessageExample: FunctionComponent = () => {
44
52
  return table;
45
53
  case 'Image':
46
54
  return image;
55
+ case 'Footnote':
56
+ return footnote;
47
57
  default:
48
58
  return;
49
59
  }
@@ -150,6 +160,18 @@ _Italic text, formatted with single underscores_
150
160
 
151
161
  const image = `![Multi-colored wavy lines on a black background](https://cdn.dribbble.com/userupload/10651749/file/original-8a07b8e39d9e8bf002358c66fce1223e.gif)`;
152
162
 
163
+ const footnote = `This is some text that has a short footnote[^1] and this is text with a longer footnote.[^bignote]
164
+
165
+ [^1]: This is a short footnote. To return the highlight to the original message, click the arrow.
166
+
167
+ [^bignote]: This is a long footnote with multiple paragraphs and formatting.
168
+
169
+ To break long footnotes into paragraphs, indent the text.
170
+
171
+ Add as many paragraphs as you like. You can include *italic text*, **bold text**, and \`code\`.
172
+
173
+ > You can even include blockquotes in footnotes!`;
174
+
153
175
  const error = {
154
176
  title: 'Could not load chat',
155
177
  children: 'Wait a few minutes and check your network settings. If the issue persists: ',
@@ -165,8 +187,8 @@ _Italic text, formatted with single underscores_
165
187
  )
166
188
  };
167
189
 
168
- const onSelect = (_event: MouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => {
169
- setVariant(value);
190
+ const onSelect = (_event: ReactMouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => {
191
+ setVariant(value as string);
170
192
  setSelected(value as string);
171
193
  setIsOpen(false);
172
194
  if (value === 'Expandable code') {
@@ -196,6 +218,76 @@ _Italic text, formatted with single underscores_
196
218
  </MenuToggle>
197
219
  );
198
220
 
221
+ const handleFootnoteNavigation = (event: ReactMouseEvent<HTMLElement> | ReactKeyboardEvent<HTMLElement>) => {
222
+ const target = event.target as HTMLElement;
223
+
224
+ // Depending on whether it is a click event or keyboard event, target may be a link or something like a span
225
+ // Look for the closest anchor element (could be a parent)
226
+ const anchorElement = target.closest('a');
227
+ const href = anchorElement?.getAttribute('href');
228
+
229
+ // Check if this is a footnote link - we only have internal links in this example, so this is all we need here
230
+ if (href && href.startsWith('#')) {
231
+ // Prevent default behavior to avoid page re-render on click in PatternFly docs framework
232
+ event.preventDefault();
233
+
234
+ let targetElement: HTMLElement | null = null;
235
+ const targetId = href.replace('#', '');
236
+ targetElement = document.querySelector(`[id="${targetId}"]`);
237
+
238
+ if (targetElement) {
239
+ let focusTarget = targetElement;
240
+
241
+ // If we found a footnote definition container, focus on the parent li element
242
+ if (targetElement.id?.startsWith('bot-message-fn-')) {
243
+ // Find the parent li element that contains the footnote
244
+ const parentLi = targetElement.closest('li');
245
+ if (parentLi) {
246
+ focusTarget = parentLi as HTMLElement;
247
+ }
248
+ }
249
+
250
+ focusTarget.focus();
251
+
252
+ let elementToHighlight = targetElement;
253
+
254
+ // If this is a backref link (going back to footnote reference),
255
+ // we want to highlight more of the ref line and not just the link itself
256
+ // since the target is so small
257
+ if (targetElement.id?.startsWith('bot-message-fnref-')) {
258
+ const refLink = targetElement;
259
+
260
+ // Walk up the DOM to find a meaningful container
261
+ let parent = refLink.parentElement;
262
+ while (parent && parent.tagName.toLowerCase() !== 'p' && parent !== document.body) {
263
+ parent = parent.parentElement;
264
+ }
265
+
266
+ // Use if found, otherwise use the immediate parent or target as a fallback
267
+ elementToHighlight = parent || refLink.parentElement || targetElement;
268
+ }
269
+
270
+ // Briefly highlight the target element for fun to show what you can do
271
+ const originalBackground = elementToHighlight.style.backgroundColor;
272
+ const originalTransition = elementToHighlight.style.transition;
273
+
274
+ elementToHighlight.style.transition = 'background-color 0.3s ease';
275
+ elementToHighlight.style.backgroundColor = 'var(--pf-t--global--background--color--tertiary--default)';
276
+
277
+ setTimeout(() => {
278
+ elementToHighlight.style.backgroundColor = originalBackground;
279
+ setTimeout(() => {
280
+ elementToHighlight.style.transition = originalTransition;
281
+ }, 300);
282
+ }, 1000);
283
+ }
284
+ }
285
+ };
286
+
287
+ const onClick = (event: ReactMouseEvent<HTMLElement> | ReactKeyboardEvent<HTMLElement>) => {
288
+ handleFootnoteNavigation(event);
289
+ };
290
+
199
291
  return (
200
292
  <>
201
293
  <Message
@@ -248,6 +340,7 @@ _Italic text, formatted with single underscores_
248
340
  <SelectOption value="More complex list">More complex list</SelectOption>
249
341
  <SelectOption value="Table">Table</SelectOption>
250
342
  <SelectOption value="Image">Image</SelectOption>
343
+ <SelectOption value="Footnote">Footnote</SelectOption>
251
344
  <SelectOption value="Error">Error</SelectOption>
252
345
  </SelectList>
253
346
  </Select>
@@ -265,6 +358,11 @@ _Italic text, formatted with single underscores_
265
358
  // The purpose of this plugin is to provide unique link names for the code blocks
266
359
  // Because they are in the same message, this requires a custom plugin to parse the syntax tree
267
360
  additionalRehypePlugins={[rehypeCodeBlockToggle]}
361
+ linkProps={{ onClick }}
362
+ // clobberPrefix controls the label ids
363
+ reactMarkdownProps={{
364
+ remarkRehypeOptions: { footnoteLabel: 'Bot message footnotes', clobberPrefix: 'bot-message-' }
365
+ }}
268
366
  />
269
367
  </>
270
368
  );
@@ -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,53 @@
1
+ import { useState, FunctionComponent, MouseEvent as ReactMouseEvent } from 'react';
2
+ import { Button, Checkbox } from '@patternfly/react-core';
3
+ import ImagePreview from '@patternfly/chatbot/dist/dynamic/ImagePreview';
4
+ import filePreview from './file-preview.svg';
5
+
6
+ export const AttachmentEditModalExample: FunctionComponent = () => {
7
+ const [isModalOpen, setIsModalOpen] = useState(false);
8
+ const [isCompact, setIsCompact] = useState(false);
9
+ const [hasNav, setHasNav] = useState(false);
10
+
11
+ const handleModalToggle = (_event: ReactMouseEvent | MouseEvent | KeyboardEvent) => {
12
+ setIsModalOpen(!isModalOpen);
13
+ };
14
+
15
+ return (
16
+ <>
17
+ <Checkbox
18
+ label="Show multiple images"
19
+ isChecked={hasNav}
20
+ onChange={() => setHasNav(!hasNav)}
21
+ id="modal-compact-image-has-nav"
22
+ name="modal-compact-image-has-nav"
23
+ ></Checkbox>
24
+ <Checkbox
25
+ label="Show compact version"
26
+ isChecked={isCompact}
27
+ onChange={() => setIsCompact(!isCompact)}
28
+ id="modal-compact-image-preview"
29
+ name="modal-compact-image-preview"
30
+ ></Checkbox>
31
+ <Button onClick={handleModalToggle}>Launch image preview modal</Button>
32
+ <ImagePreview
33
+ isModalOpen={isModalOpen}
34
+ handleModalToggle={handleModalToggle}
35
+ isCompact={isCompact}
36
+ onCloseFileDetailsLabel={() => {
37
+ // eslint-disable-next-line no-console
38
+ console.log('Clicked close button');
39
+ }}
40
+ images={
41
+ hasNav
42
+ ? /* eslint-disable indent */
43
+ [
44
+ { fileName: 'image1.png', fileSize: '134KB', image: <img src={filePreview} alt="Preview one" /> },
45
+ { fileName: 'image2.png', fileSize: '134KB', image: <img src={filePreview} alt="Preview two" /> }
46
+ ]
47
+ : [{ fileName: 'image.png', fileSize: '134KB', image: <img src={filePreview} alt="One" /> }]
48
+ /* eslint-enable indent */
49
+ }
50
+ ></ImagePreview>
51
+ </>
52
+ );
53
+ };
@@ -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"