@solexllc/usx-react 0.11.0 → 1.0.0

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 (240) hide show
  1. package/README.md +31 -0
  2. package/dist/Popover-Bg4-2-cU.cjs +987 -0
  3. package/dist/Popover-CqHczzNE.js +988 -0
  4. package/dist/chat.cjs +1396 -0
  5. package/dist/chat.js +1396 -0
  6. package/dist/index.cjs +4412 -5247
  7. package/dist/index.js +140 -972
  8. package/package.json +9 -5
  9. package/src/chat.js +15 -0
  10. package/src/components/accordion/Accordion.tsx +9 -57
  11. package/src/components/accordion/accordion.django.html +10 -20
  12. package/src/components/accordion/config.json +8 -2
  13. package/src/components/accordion-item/AccordionItem.tsx +54 -0
  14. package/src/components/accordion-item/accordion-item.django.html +19 -0
  15. package/src/components/accordion-item/accordion-item.html +8 -0
  16. package/src/components/accordion-item/config.json +55 -0
  17. package/src/components/alert/alert.django-snapshot.html +4 -4
  18. package/src/components/avatar/Avatar.tsx +54 -16
  19. package/src/components/avatar/avatar.django-snapshot.html +118 -2
  20. package/src/components/avatar/avatar.django.html +2 -2
  21. package/src/components/avatar/avatar.html +25 -0
  22. package/src/components/avatar/avatar.react-snapshot.html +110 -3
  23. package/src/components/avatar/config.json +17 -17
  24. package/src/components/avatar-group/AvatarGroup.tsx +17 -15
  25. package/src/components/avatar-group/avatar-group.django-snapshot.html +196 -174
  26. package/src/components/avatar-group/avatar-group.django.html +1 -1
  27. package/src/components/avatar-group/avatar-group.react-snapshot.html +216 -165
  28. package/src/components/avatar-group/config.json +14 -8
  29. package/src/components/back-to-top/BackToTop.tsx +21 -57
  30. package/src/components/back-to-top/back-to-top.django-snapshot.html +101 -202
  31. package/src/components/back-to-top/back-to-top.django.html +11 -38
  32. package/src/components/back-to-top/back-to-top.html +22 -106
  33. package/src/components/back-to-top/back-to-top.react-snapshot.html +94 -148
  34. package/src/components/back-to-top/config.json +41 -10
  35. package/src/components/banner/banner.django-snapshot.html +2 -2
  36. package/src/components/button/Button.tsx +15 -3
  37. package/src/components/button/button.django-snapshot.html +82 -0
  38. package/src/components/button/button.django.html +5 -2
  39. package/src/components/button/button.react-snapshot.html +80 -0
  40. package/src/components/button/config.json +17 -3
  41. package/src/components/callout/callout.django.html +1 -1
  42. package/src/components/callout/config.json +7 -16
  43. package/src/components/card/card.django-snapshot.html +43 -0
  44. package/src/components/card/card.react-snapshot.html +36 -0
  45. package/src/components/character-count/CharacterCount.tsx +2 -0
  46. package/src/components/character-count/character-count.react-snapshot.html +7 -0
  47. package/src/components/chat/Chat.tsx +575 -0
  48. package/src/components/chat/README.md +174 -0
  49. package/src/components/chat/avatarProps.ts +32 -0
  50. package/src/components/chat/chat.django-snapshot.html +23579 -0
  51. package/src/components/chat/chat.django.html +75 -0
  52. package/src/components/chat/chat.html +116 -0
  53. package/src/components/chat/chat.react-snapshot.html +16895 -0
  54. package/src/components/chat/config.json +1241 -0
  55. package/src/components/chat-attachment/ChatAttachment.tsx +39 -0
  56. package/src/components/chat-attachment/chat-attachment.django.html +24 -0
  57. package/src/components/chat-attachment/chat-attachment.html +10 -0
  58. package/src/components/chat-attachment/config.json +27 -0
  59. package/src/components/chat-attachments/ChatAttachments.tsx +17 -0
  60. package/src/components/chat-attachments/chat-attachments.django-snapshot.html +58 -0
  61. package/src/components/chat-attachments/chat-attachments.django.html +10 -0
  62. package/src/components/chat-attachments/chat-attachments.html +14 -0
  63. package/src/components/chat-attachments/chat-attachments.react-snapshot.html +46 -0
  64. package/src/components/chat-attachments/config.json +25 -0
  65. package/src/components/chat-bubble/ChatBubble.tsx +39 -0
  66. package/src/components/chat-bubble/ChatFormattedText.tsx +138 -0
  67. package/src/components/chat-bubble/chat-bubble.django-snapshot.html +128 -0
  68. package/src/components/chat-bubble/chat-bubble.django.html +19 -0
  69. package/src/components/chat-bubble/chat-bubble.html +1 -0
  70. package/src/components/chat-bubble/chat-bubble.react-snapshot.html +118 -0
  71. package/src/components/chat-bubble/config.json +70 -0
  72. package/src/components/chat-composer/ChatComposer.tsx +213 -0
  73. package/src/components/chat-composer/README.md +15 -0
  74. package/src/components/chat-composer/chat-composer.django-snapshot.html +575 -0
  75. package/src/components/chat-composer/chat-composer.django.html +77 -0
  76. package/src/components/chat-composer/chat-composer.html +44 -0
  77. package/src/components/chat-composer/chat-composer.react-snapshot.html +519 -0
  78. package/src/components/chat-composer/chat-formatting.django.html +59 -0
  79. package/src/components/chat-composer/config.json +137 -0
  80. package/src/components/chat-context/ChatContext.tsx +46 -0
  81. package/src/components/chat-context/chat-context.django-snapshot.html +35 -0
  82. package/src/components/chat-context/chat-context.django.html +20 -0
  83. package/src/components/chat-context/chat-context.html +9 -0
  84. package/src/components/chat-context/chat-context.react-snapshot.html +30 -0
  85. package/src/components/chat-context/config.json +36 -0
  86. package/src/components/chat-controls/ChatControls.tsx +67 -0
  87. package/src/components/chat-controls/chat-controls.django-snapshot.html +114 -0
  88. package/src/components/chat-controls/chat-controls.django.html +36 -0
  89. package/src/components/chat-controls/chat-controls.html +11 -0
  90. package/src/components/chat-controls/chat-controls.react-snapshot.html +107 -0
  91. package/src/components/chat-controls/config.json +67 -0
  92. package/src/components/chat-directory/ChatDirectory.tsx +168 -0
  93. package/src/components/chat-directory/chat-directory.django-snapshot.html +546 -0
  94. package/src/components/chat-directory/chat-directory.django.html +14 -0
  95. package/src/components/chat-directory/chat-directory.html +4 -0
  96. package/src/components/chat-directory/chat-directory.react-snapshot.html +471 -0
  97. package/src/components/chat-directory/config.json +242 -0
  98. package/src/components/chat-directory-item/ChatDirectoryItem.tsx +150 -0
  99. package/src/components/chat-directory-item/chat-directory-item.django-snapshot.html +281 -0
  100. package/src/components/chat-directory-item/chat-directory-item.django.html +38 -0
  101. package/src/components/chat-directory-item/chat-directory-item.html +9 -0
  102. package/src/components/chat-directory-item/chat-directory-item.react-snapshot.html +249 -0
  103. package/src/components/chat-directory-item/config.json +103 -0
  104. package/src/components/chat-history/ChatHistory.tsx +30 -0
  105. package/src/components/chat-history/chat-history.django-snapshot.html +113 -0
  106. package/src/components/chat-history/chat-history.django.html +20 -0
  107. package/src/components/chat-history/chat-history.html +9 -0
  108. package/src/components/chat-history/chat-history.react-snapshot.html +111 -0
  109. package/src/components/chat-history/config.json +24 -0
  110. package/src/components/chat-message/ChatMessage.tsx +148 -0
  111. package/src/components/chat-message/chat-message.django-snapshot.html +758 -0
  112. package/src/components/chat-message/chat-message.django.html +56 -0
  113. package/src/components/chat-message/chat-message.html +12 -0
  114. package/src/components/chat-message/chat-message.react-snapshot.html +627 -0
  115. package/src/components/chat-message/config.json +278 -0
  116. package/src/components/chat-message-actions/ChatMessageActions.tsx +133 -0
  117. package/src/components/chat-message-actions/chat-message-actions.django-snapshot.html +345 -0
  118. package/src/components/chat-message-actions/chat-message-actions.django.html +29 -0
  119. package/src/components/chat-message-actions/chat-message-actions.html +53 -0
  120. package/src/components/chat-message-actions/chat-message-actions.react-snapshot.html +295 -0
  121. package/src/components/chat-message-actions/config.json +121 -0
  122. package/src/components/chat-window/ChatWindow.tsx +135 -0
  123. package/src/components/chat-window/chat-window.django-snapshot.html +450 -0
  124. package/src/components/chat-window/chat-window.django.html +39 -0
  125. package/src/components/chat-window/chat-window.html +26 -0
  126. package/src/components/chat-window/chat-window.react-snapshot.html +286 -0
  127. package/src/components/chat-window/config.json +123 -0
  128. package/src/components/checkbox/checkbox.django-snapshot.html +2 -2
  129. package/src/components/clickable/Clickable.tsx +19 -5
  130. package/src/components/clickable/clickable.django-snapshot.html +11 -2
  131. package/src/components/clickable/clickable.django.html +2 -0
  132. package/src/components/clickable/clickable.react-snapshot.html +10 -2
  133. package/src/components/clickable/config.json +4 -0
  134. package/src/components/code/code.django-snapshot.html +25 -18
  135. package/src/components/code/code.react-snapshot.html +41 -4
  136. package/src/components/copy-to-clipboard/CopyToClipboard.tsx +2 -7
  137. package/src/components/copy-to-clipboard/copy-to-clipboard.django-snapshot.html +6 -4
  138. package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +3 -2
  139. package/src/components/copy-to-clipboard/copy-to-clipboard.react-snapshot.html +14 -2
  140. package/src/components/data-table/data-table.django-snapshot.html +4 -5
  141. package/src/components/data-table/data-table.react-snapshot.html +4 -4
  142. package/src/components/drawer/drawer.django-snapshot.html +53 -30
  143. package/src/components/error-page/error-page.django-snapshot.html +20 -7
  144. package/src/components/fieldset/fieldset.django-snapshot.html +1 -6
  145. package/src/components/file-list/FileList.tsx +3 -2
  146. package/src/components/file-list/config.json +5 -0
  147. package/src/components/file-list/file-list.django-snapshot.html +63 -0
  148. package/src/components/file-list/file-list.django.html +1 -1
  149. package/src/components/file-list/file-list.react-snapshot.html +53 -0
  150. package/src/components/footer/footer.django-snapshot.html +0 -3
  151. package/src/components/form-group/form-group.django-snapshot.html +0 -2
  152. package/src/components/header/header.django-snapshot.html +3 -163
  153. package/src/components/header/header.django.html +2 -2
  154. package/src/components/header/header.html +1 -1
  155. package/src/components/header/header.react-snapshot.html +3 -3
  156. package/src/components/hero/hero.django-snapshot.html +0 -20
  157. package/src/components/hero/hero.django.html +3 -3
  158. package/src/components/identifier/config.json +4 -2
  159. package/src/components/identifier/identifier.django-snapshot.html +13 -16
  160. package/src/components/identifier/identifier.react-snapshot.html +13 -15
  161. package/src/components/image/image.django-snapshot.html +6 -6
  162. package/src/components/image/image.django.html +4 -4
  163. package/src/components/input/Input.tsx +1 -1
  164. package/src/components/input/config.json +2 -3
  165. package/src/components/input/input.django-snapshot.html +4 -21
  166. package/src/components/input/input.django.html +2 -2
  167. package/src/components/layout/layout.django-snapshot.html +2 -0
  168. package/src/components/link/Link.tsx +7 -4
  169. package/src/components/link/config.json +2 -3
  170. package/src/components/link/link.django-snapshot.html +8 -0
  171. package/src/components/link/link.django.html +2 -2
  172. package/src/components/link/link.html +4 -1
  173. package/src/components/link/link.react-snapshot.html +8 -0
  174. package/src/components/memorable-date/memorable-date.django-snapshot.html +0 -8
  175. package/src/components/memorable-date/memorable-date.django.html +2 -2
  176. package/src/components/misc-banner/misc-banner.django-snapshot.html +12 -12
  177. package/src/components/misc-banner/misc-banner.django.html +4 -2
  178. package/src/components/modal/Modal.tsx +4 -3
  179. package/src/components/modal/config.json +3 -2
  180. package/src/components/modal/modal.django-snapshot.html +70 -14
  181. package/src/components/modal/modal.django.html +7 -9
  182. package/src/components/modal/modal.html +4 -4
  183. package/src/components/modal/modal.react-snapshot.html +64 -4
  184. package/src/components/page/Page.tsx +10 -7
  185. package/src/components/page/page.django-snapshot.html +5 -8
  186. package/src/components/page/page.django.html +2 -2
  187. package/src/components/page/page.html +1 -2
  188. package/src/components/page/page.react-snapshot.html +5 -8
  189. package/src/components/pagination/navigation/PaginationNavigation.tsx +2 -0
  190. package/src/components/pagination/navigation/pagination-navigation.django.html +2 -0
  191. package/src/components/pagination/pagination.django-snapshot.html +62 -0
  192. package/src/components/pagination/pagination.django.html +3 -1
  193. package/src/components/pagination/pagination.html +46 -0
  194. package/src/components/pagination/pagination.react-snapshot.html +48 -0
  195. package/src/components/pagination/summary/PaginationSummary.tsx +1 -1
  196. package/src/components/pagination/summary/pagination-summary.django.html +1 -1
  197. package/src/components/popover/Popover.tsx +61 -9
  198. package/src/components/popover/PopoverMenu.tsx +33 -15
  199. package/src/components/popover/config.json +88 -14
  200. package/src/components/popover/popover-menu.django.html +13 -2
  201. package/src/components/popover/popover.django-snapshot.html +265 -7
  202. package/src/components/popover/popover.django.html +3 -2
  203. package/src/components/popover/popover.react-snapshot.html +154 -4
  204. package/src/components/process-list/config.json +41 -3
  205. package/src/components/quote/Quote.tsx +9 -2
  206. package/src/components/search/Search.tsx +1 -1
  207. package/src/components/search/config.json +3 -4
  208. package/src/components/search/search.django-snapshot.html +262 -1684
  209. package/src/components/search/search.django.html +1 -20
  210. package/src/components/section/Section.tsx +3 -1
  211. package/src/components/select/select.django-snapshot.html +7 -7
  212. package/src/components/select/select.react-snapshot.html +7 -7
  213. package/src/components/site-alert/site-alert.django-snapshot.html +8 -8
  214. package/src/components/summary/Summary.tsx +4 -2
  215. package/src/components/summary/config.json +4 -0
  216. package/src/components/summary/summary.django.html +4 -4
  217. package/src/components/swap/Swap.tsx +35 -3
  218. package/src/components/swap/config.json +28 -1
  219. package/src/components/swap/swap.django-snapshot.html +29 -7
  220. package/src/components/swap/swap.django.html +15 -1
  221. package/src/components/swap/swap.react-snapshot.html +34 -4
  222. package/src/components/table/Table.tsx +58 -25
  223. package/src/components/table/config.json +61 -13
  224. package/src/components/tag/Tag.tsx +40 -7
  225. package/src/components/tag/config.json +18 -2
  226. package/src/components/tag/tag.django-snapshot.html +16 -1
  227. package/src/components/tag/tag.django.html +12 -6
  228. package/src/components/tag/tag.html +4 -0
  229. package/src/components/tag/tag.react-snapshot.html +16 -1
  230. package/src/components/tag-group/TagGroup.tsx +6 -9
  231. package/src/components/tag-group/config.json +4 -0
  232. package/src/components/tag-group/tag-group.django.html +1 -1
  233. package/src/components/theme-picker/ThemePicker.tsx +48 -42
  234. package/src/components/theme-picker/config.json +27 -29
  235. package/src/components/theme-picker/theme-picker-select.django.html +1 -1
  236. package/src/components/theme-picker/theme-picker.django-snapshot.html +283 -78
  237. package/src/components/theme-picker/theme-picker.django.html +24 -11
  238. package/src/components/theme-picker/theme-picker.html +155 -54
  239. package/src/components/theme-picker/theme-picker.react-snapshot.html +265 -67
  240. package/src/index.js +1 -0
@@ -0,0 +1,174 @@
1
+ # Chat integration
2
+
3
+ Chat's React and Django renderers produce markup from the same `config.json` contract. Neither renderer manages navigation, drafts, requests, or event handlers. `view`, `activeConversationId`, `activeThreadId`, `recipientId`, messages, and delivery states are supplied by the host.
4
+
5
+ The host owns the launcher's content, styling, and placement through `summaryProps`:
6
+
7
+ ```jsx
8
+ <Chat
9
+ id="support"
10
+ side="top"
11
+ align="end"
12
+ summaryProps={{
13
+ className: 'my-custom-launcher',
14
+ ariaLabel: 'Contact support',
15
+ children: <span>Contact support</span>,
16
+ }}
17
+ >
18
+ <button type="button">Request a callback</button>
19
+ </Chat>
20
+ ```
21
+
22
+ ```django
23
+ {% dict label='Contact support' className='my-custom-launcher' as launcherProps %}
24
+ {% chat id='support' side='top' align='end' summaryProps=launcherProps %}
25
+ <button type="button">Request a callback</button>
26
+ {% endchat %}
27
+ ```
28
+
29
+ Chat and ChatWindow pass these props to Popover's unstyled Summary without adding launcher classes. The default label is `Open chat`. Use `summaryProps.children` for rich launcher content, and `ariaLabel` for icon-only launchers. Chat's own `children` remain custom controls above the composer; ChatWindow's children remain its body. All behavior belongs to enhancement or the host.
30
+
31
+ For a viewport-corner launcher, place Chat inside a host-owned fixed container and set `side="top"` and `align="end"`. The Floating Launcher story demonstrates this layout. Chat no longer has a `floating` prop.
32
+
33
+ Chat composes the following parts. Each has its own `config.json`, markup-only React renderer, matching Django template, and stories under `Chat/<part>`. Story files live in `chat/subcomponents/<component-name>/`.
34
+
35
+ On viewports at or below 35rem, the open Chat window fills the viewport. Its header and composer stay visible while the conversation history or directory scrolls.
36
+
37
+ Conversations and threads open at the latest message. An appended message keeps the transcript at the bottom only when the reader was already there; reading older messages leaves the scroll position intact. The unread divider remains in the transcript to identify the first unread message.
38
+
39
+ | Part | Responsibility |
40
+ | --- | --- |
41
+ | ChatWindow | Popover launcher and window, heading, back/new-message controls, conversation actions, required close button, and status. Its children supply the body. |
42
+ | ChatDirectory | Resolves conversation/contact data and composes a list of ChatDirectoryItem rows. |
43
+ | ChatDirectoryItem | One conversation, contact, or selectable recipient: shared avatar, title, subtitle, preview, metadata, and optional sibling action menu. |
44
+ | ChatContext | The subject of a conversation, such as a listing or support request. |
45
+ | ChatMessage | One transcript list item: sender, avatar, bubble, delivery feedback, timestamp, thread count, and action bar. |
46
+ | ChatBubble | Formatted text or rich content, attachments, and existing reactions. |
47
+ | ChatMessageActions | Reaction picker, reply/forward controls, copy, and host-supplied message actions. |
48
+ | ChatAttachments | The `ul.usx-chat__attachments` list, composed from ChatAttachment items with optional images and download links. |
49
+ | ChatHistory | Earlier-history loading, retry, and beginning-of-history states. |
50
+ | ChatControls | Suggested questions, choices, and a slot for custom controls. |
51
+ | ChatComposer | Text area, optional formatting and attachments, emoji picker, and submission controls. |
52
+
53
+ Directory rows use Clickable as a single button or navigation link. The visible context title is plain text within the row; its URL is available from the opened conversation. Action menus are separate sibling controls. Standalone Directory navigation emits the same `usx:chat-navigate` events as the assembled Chat.
54
+
55
+ Selectable ChatDirectory rows use the Checkbox input and label classes. The label contains the participant Avatar and text; its native checkbox remains associated with the composer form.
56
+
57
+ The parent resolves the selected conversation/thread, derives message grouping, and composes these parts. Formatting text and deriving presentation from props are pure rendering operations.
58
+
59
+ A message group is a sequence of `ChatMessage` items with `message.groupPosition` set to `first`, `middle`, and `last` (or `single`). It does not introduce another DOM wrapper or live region. Chat derives positions from sender and timestamps; standalone consumers can supply them. Grouping accepts ISO calendar timestamps (`YYYY-MM-DDTHH:mm[:ss[.fraction]]`) with `Z`, an explicit `±HH:mm` offset, or no timezone. Missing timezones mean UTC. Fractions are truncated to milliseconds, and invalid dates remain ungrouped. The supplied `timeLabel` and `sentAt` datetime attribute are rendered unchanged; no display timezone conversion is performed. The Message/Grouped story demonstrates the complete sequence. Each message retains its own actions, and intermediate timestamps remain available to assistive technology.
60
+
61
+ `ChatDirectoryItem`, `ChatMessage`, `ChatHistory`, and `ChatControls` render list items and belong inside an appropriate `ol` or `ul`. `ChatAttachments` supplies the attachment list; its retained ChatAttachment item renderer is demonstrated and checked through the Attachments stories. `ChatBubble` composes this list with message content and reactions. `ChatMessageActions` stays visible when used by itself; within `ChatMessage`, it appears on hover, focus, or the existing touch enhancement. These parts keep the same CSS classes and data hooks as the assembled Chat.
62
+
63
+ Participants can provide `avatarProps.statusRingColor` and `avatarProps.statusLabel`. Directory presence maps `online` to the `success` border utility and `away` to `warning`; other Avatar status colors and labels remain host supplied.
64
+
65
+ Avatar defaults are shared by messages, directory rows, and typing indicators. Supplied `avatarProps.contentClassName` replaces the default colors, including an empty string. Chat retains Button and Link theming; composer tools wrap to the available width, while the segmented formatting bar scrolls horizontally on narrow screens. Rich-message content controls its own form layout.
66
+
67
+ Import Chat and its parts from `@solexllc/usx-react/chat`. Include the optional
68
+ `pkg:@solexllc/usx/chat` Sass entry (or `pkg:@solexllc/usx/chat/themed` for runtime
69
+ theming) alongside the core styles. See [asset setup](../../../../usx/README.md#optional-chat).
70
+
71
+ Initialize the default exports from `@solexllc/usx/js/chat` and `@solexllc/usx/js/popover` after rendering either technology. Chat is excluded from `@solexllc/usx/js` and `js/start`. Chat's enhancement handles formatting, emoji insertion, attachment selection, keyboard submission, copying, message action controls, and history request events. There is no separate composer enhancement or React-specific initialization path.
72
+
73
+ Like other USX enhancements, `init(root)` marks enhanced components with `data-enhanced="true"` and respects a host wrapper with `usx-data-enhanced="true"` to opt out of behavior.
74
+
75
+ | Event | Host responsibility |
76
+ | --- | --- |
77
+ | `usx:chat-navigate` | Render the requested view using the supplied conversation, participant, or thread ID. |
78
+ | `usx:chat-send` | Send `text` and `files`; use `clientMessageId` for correlation and render delivery state. Cancel the event to handle submission locally. |
79
+ | `usx:chat-retry` | Retry the supplied message and update its delivery state. |
80
+ | `usx:chat-forward` | Choose a recipient and prepare the forwarded draft. |
81
+ | `usx:chat-message-action` | Handle the action ID for the message. |
82
+ | `usx:chat-directory-action` | Handle `actionId` for `conversationId` and/or `participantId`, from a directory row or the open conversation header. |
83
+ | `usx:chat-recipients-change` | Observe the selected `recipientIds`; optionally update host state or recipient-dependent capabilities. |
84
+ | `usx:chat-reaction` | Update the selected reaction and count for the message. |
85
+ | `usx:chat-option` | Handle a suggestion or choice; cancel to override filling the composer. |
86
+ | `usx:chat-load-older` | Fetch history using the cursor and IDs, then restore the provided scroll anchor. |
87
+
88
+ Set `formAction` for native form submission. Supply `allowAttachments` to enable uploads; a conversation or contact may override that option. Each use of Attach files adds to the staged FileList, and each Delete control removes one file from the list and input. Supply `allowFormatting` to render the formatting panel and enable its shortcuts. Both default to false. `emojiPack` supplies the picker and shortcode choices; an empty array hides the picker.
89
+
90
+ Hosts retain drafts and pending files across view changes, handle optimistic delivery and failures, and update data after navigation or actions. The interactive React stories demonstrate one application host; that code is not shipped in the component library. `captureChatScroll` and `restoreChatScroll` from the Chat enhancement support preserving the visible message during history updates.
91
+
92
+ Conversations share one `actions` list between their directory row and their open conversation or thread header. Labels, availability, disabled states, and event payloads are identical in both locations. Standalone ChatWindow accepts this list as `conversationActions` with `conversationId`; built-in Copy conversation and the custom `actions` slot remain available alongside it.
93
+
94
+ Directory entries accept `actions: [{ id, label, disabled? }]`, just like messages. For example, a group may offer `leave-group` and `delete-history`; a message may offer `delete-message`, `recall`, or `mark-unread`. These IDs are host-defined, not commands interpreted by USX. Omit an action when unavailable, including recall outside the host's allowed time window. Omit `actions` or supply `[]` for no menu. The host handles confirmation, authorization, persistence, and any resulting markup update. Selecting an action closes its menu and restores focus before dispatching the event. Directory menus are siblings of the navigation control, so selecting an action does not open the conversation.
95
+
96
+ Message-action events include `messageId`, `actionId`, and the surrounding `conversationId` and `threadRootId` when present. Directory actions also work with standalone ChatDirectory markup after `chat.init()` and `popover.init()`; listen on the directory or an ancestor.
97
+
98
+ Use `messageActions: { sent: [...], received: [...] }` to configure consistent host actions across messages. Each side contains `{ id, label, disabled? }` objects. Resolution takes the first defined list in this order: `message.actions`, the sender's `participant.messageActions`, the selected conversation's `messageActions.sent` or `.received`, then Chat's matching default. Missing lists inherit; `[]` explicitly opts out. This also applies to thread replies. Copy, reply, forwarding, and reaction controls retain their separate options.
99
+
100
+ For example, Chat can supply Edit/Delete for sent messages and Mark unread for received messages. A customer conversation can set `messageActions.sent: []`, a bot participant can set `messageActions: []`, and one archived message can set `actions: []`. **Message Action Defaults** demonstrates these policies without repeating actions on every message. **Message Actions** demonstrates the per-message exceptions for recall eligibility.
101
+
102
+ Read state remains host-owned. The examples expose exactly one of Mark read or Mark unread, replace it after activation, and update the unread divider and inbox count. Opening an unread conversation acknowledges it in the example host; explicitly marking a message unread remains effective when returning to the inbox. Action IDs are still host-defined rather than commands interpreted by the component enhancement.
103
+
104
+ The React and Django **Attachments** examples preload real `File` objects into the composer using story-only browser code. The host calls the native form `reset()` after accepting a send, and the shared enhancement clears the staged list and send state. The **Failed Send** host retains the original files and image previews for retry, then sends the same payload instead of merely changing its status label.
105
+
106
+ History request events carry a visible-message anchor. In threads, the anchor is a reply, because the original message stays ahead of every reply page. The example adapter restores it after React commits or Django replaces the markup, including loading/error updates, so newly loaded messages appear above the current reading position. Failed automatic loads require an explicit retry.
107
+
108
+ The `contacts` view is now a new-message draft: select one or more people and write before creating a conversation. `recipientIds` supplies initial selections. ChatDirectory uses `selectable`, `recipientIds`, and `formId` to render checkboxes associated with ChatComposer's `${id}-composer` form. Their repeated `recipientIds` fields are included in native form submission and in `usx:chat-send.detail.recipientIds`. `requireRecipients` disables sending until at least one recipient is selected; drafting stays available. Selection emits `usx:chat-recipients-change` without navigating away. On send, the host decides whether to reuse an existing conversation or create a direct/group conversation. The single `recipientId` prop remains supported for existing integrations.
109
+
110
+ Stories: **Chat/Conversation Actions**, **Chat/Message Actions**, and **Chat/New Group Message** show the complete patterns. **Conversation Actions** demonstrates both the header and inbox-row action menus in one example. **Message Actions** combines reactions, editing, forwarding, threads, deleting, recalling, and marking unread; it includes a message with no replies for starting a thread and an older message for which recall is unavailable. **Formatting** demonstrates the included emoji pack in both pickers and `:name:` shortcodes; **Custom Emoji Pack** shows the host override. **Empty Inbox** demonstrates the first conversation flow. **All Unread** and **Mixed Unread** remain separate because their divider positions need to be visible when each story opens. **Directory/With Actions**, **Directory/Contact Actions**, **Directory/Recipient Picker**, **Message Actions/Host Actions**, and **Composer/Group Message** demonstrate the corresponding parts. The action stories use in-memory example hosts: leaving removes the group, deleting history empties the conversation, deleting removes a message, recalling replaces its text, and marking unread updates the divider and inbox badge. The group-message story creates or reuses an in-memory conversation after sending.
111
+
112
+ Defaults are defined in each component’s `config.json`. Empty strings, zero, false, and empty arrays are explicit values; they must not accidentally trigger a fallback intended for an omitted prop.
113
+
114
+ `pnpm test:parity` checks the renderer snapshots for every component with stories and runs shared direct-input regression tests. Chat's fixtures retain the omitted/default/empty-value, variant, nested override, thread, slot, and avatar cases. See [renderer parity testing](../../../../../scripts/tests/fixtures/renderer-parity/README.md) for coverage and how to add cases for any component.
115
+
116
+ `node packages/usx-react/test/chat-contract-check.mjs` checks that Chat's React prop names match its contracts and that its renderers contain no interaction hooks or event attributes. Parity comparisons belong to the shared command.
117
+
118
+ Django uses the existing component `get_context()` hook to prepare rendering data in `chat_component.py`, following DataTable's pattern. The shared template-tag library contains no Chat helpers. These context methods derive markup from props; host state and browser interaction remain outside the renderers.
119
+
120
+ Play tests live exclusively in the `HTML.stories.jsx` snapshot suites. React and Django stories supply examples and snapshot states without play hooks. The snapshot tests cover action defaults and per-message opt-outs, read-action commands, directory/header payloads, recipient submission, staged-file reset, failed/sent image markup, and history anchors. Host-owned persistence and navigation effects remain in the demo hosts; the snapshot tests assert the component's markup and enhancement events. The snapshot tooling tests also reject play hooks in React or Django story files.
121
+
122
+ ## Story coverage
123
+
124
+ React and Django use the same example host. Changes stay in memory; **Reset example** restores the scenario. The isolated parts use that host too: their events have a surrounding conversation, history source, or composer to act on. Navigation can open the complete Chat so forwarding, recipient selection, and thread replies remain usable.
125
+
126
+ Each top-level story has a distinct purpose:
127
+
128
+ | Story | Specific coverage |
129
+ | --- | --- |
130
+ | Default | Minimal conversation, sending, reactions |
131
+ | Inbox Journey | Inbox navigation, drafts, forwarding, read-on-open |
132
+ | Empty Inbox | Creating the first conversation |
133
+ | Group Inbox | Group avatars, avatar overflow, sender previews |
134
+ | Multiple Participants | Multiple senders and simultaneous typing indicators |
135
+ | Bot Controls With History | Suggested questions and choices with mock responses |
136
+ | Attachments | Preloaded staged files; sending files without text |
137
+ | Actions And Rich Content | Custom content and header links alongside copy, mute, pin, read state, and deletion |
138
+ | Message Actions | Editing, deletion, recall, read/unread toggles, thread creation |
139
+ | Message Action Defaults | Sender defaults, contact overrides, conversation overrides, explicit per-message opt-out; navigate between coworker, customer, and bot |
140
+ | Conversation Actions | Shared directory/header actions; leave a group or delete its history from either location |
141
+ | Formatting | Optional formatting toolbar and text shortcuts |
142
+ | Custom Emoji Pack | Host-defined emoji and aliases |
143
+ | Thread History | Loading older replies while retaining the scroll position |
144
+ | Long History | Loading older conversation messages, retrying a failed load, incoming-message announcements |
145
+ | Contextual Inbox | Separate subjects with the same contact and working subject links |
146
+ | Mixed Unread | Initial unread boundary within a loaded conversation |
147
+ | Linked Navigation | Host-owned conversation routes |
148
+ | Failed Send | Text and image failures, retry, preserving image-only content |
149
+ | Floating Launcher | Host-owned placement and Popover alignment |
150
+ | Text Launcher | Custom launcher content through `summaryProps` |
151
+ | Unavailable Thread | Missing thread root and recovery through Back |
152
+ | New Group Message | Selecting multiple recipients before sending |
153
+
154
+ Customer/bot action states, an already-read inbox, unread message actions, and directory actions are reached within these journeys rather than duplicated as separate stories. The all-unread fixture was redundant with the unread-boundary example.
155
+
156
+ The subcomponent stories isolate their own contracts:
157
+
158
+ | Part | Distinct examples |
159
+ | --- | --- |
160
+ | Window | Basic shell/status; inbox New message; thread Back/actions; closed custom launcher |
161
+ | Directory | Empty state; contacts; unread inbox; conversation actions; contact actions; selectable recipients; contextual rows |
162
+ | Directory Item | Conversation metadata/actions; contact; linked contact; selected recipient; group avatars; wrapping/truncation |
163
+ | Context | Plain context; link to an actual example request |
164
+ | Message | Incoming; outgoing/read/edited; actions and replies; sending completion; failed-send retry; unknown sender; grouped bubbles; short-bubble action alignment |
165
+ | Bubble | Plain text; formatted text; attachment; toggleable reaction; custom interactive content |
166
+ | Message Actions | Built-in actions and reporting; host lifecycle actions/disabled action; reactions only |
167
+ | Attachments | Images and downloadable files within a complete list |
168
+ | Composer | Plain text; formatting; attachments/emoji; thread reply; preselected group recipients |
169
+ | Controls | Suggested questions; choices; disabled choices with an enable control; custom controls slot |
170
+ | History | Load; pending request that completes; retryable error; beginning of history |
171
+
172
+ Play tests remain on the HTML snapshots. They verify the rendered contracts and enhancement events; the React/Django stories supply the mock application responses.
173
+
174
+ Thread replies are controlled by `allowThreads` (default `false`) on Chat, with an optional override on each conversation. Enabling it provides the thread action on every delivered message, regardless of sender or existing replies. `ChatMessage` receives that resolved setting; messages no longer carry `canReplyInThread`. Thread views do not offer nested threads, and pending/failed messages must be sent successfully before they can start one.
@@ -0,0 +1,32 @@
1
+ import ClassNames from 'classnames';
2
+ import type { AvatarProps } from '../avatar/Avatar';
3
+ import type { AvatarGroupAvatar } from '../avatar-group/AvatarGroup';
4
+ import type { ChatParticipant } from './Chat';
5
+
6
+ export default function chatAvatarProps(
7
+ participant: ChatParticipant | undefined,
8
+ name: string,
9
+ statusRingColor?: AvatarProps['statusRingColor'],
10
+ statusLabel?: AvatarProps['statusLabel'],
11
+ tooltipProps?: AvatarProps['tooltipProps']
12
+ ): AvatarGroupAvatar {
13
+ const initials = name
14
+ .trim()
15
+ .split(/\s+/)
16
+ .slice(0, 2)
17
+ .map((part) => Array.from(part)[0] || '')
18
+ .join('')
19
+ .toUpperCase();
20
+ return {
21
+ variant: 'initials',
22
+ value: initials,
23
+ alt: name,
24
+ shape: 'circle',
25
+ contentClassName: 'bg-primary-light text-inverse',
26
+ ...participant?.avatarProps,
27
+ statusRingColor: statusRingColor ?? participant?.avatarProps?.statusRingColor,
28
+ statusLabel: statusLabel ?? participant?.avatarProps?.statusLabel,
29
+ tooltipProps: tooltipProps ?? participant?.avatarProps?.tooltipProps,
30
+ className: ClassNames('usx-chat__avatar', participant?.avatarProps?.className),
31
+ };
32
+ }