@solexllc/usx-react 0.10.0 → 0.12.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 (208) hide show
  1. package/README.md +16 -0
  2. package/dist/Popover-BzDCTuQM.cjs +984 -0
  3. package/dist/Popover-LToVWsWc.js +985 -0
  4. package/dist/chat.cjs +1391 -0
  5. package/dist/chat.js +1391 -0
  6. package/dist/index.cjs +4426 -5231
  7. package/dist/index.js +168 -970
  8. package/package.json +9 -5
  9. package/src/chat.js +15 -0
  10. package/src/components/avatar/Avatar.tsx +54 -16
  11. package/src/components/avatar/avatar.django-snapshot.html +112 -0
  12. package/src/components/avatar/avatar.django.html +2 -2
  13. package/src/components/avatar/avatar.html +25 -0
  14. package/src/components/avatar/avatar.react-snapshot.html +104 -0
  15. package/src/components/avatar/config.json +13 -15
  16. package/src/components/avatar-group/AvatarGroup.tsx +17 -15
  17. package/src/components/avatar-group/avatar-group.django-snapshot.html +22 -0
  18. package/src/components/avatar-group/avatar-group.django.html +1 -1
  19. package/src/components/avatar-group/avatar-group.react-snapshot.html +20 -0
  20. package/src/components/avatar-group/config.json +2 -2
  21. package/src/components/back-to-top/BackToTop.tsx +21 -57
  22. package/src/components/back-to-top/back-to-top.django-snapshot.html +101 -202
  23. package/src/components/back-to-top/back-to-top.django.html +11 -38
  24. package/src/components/back-to-top/back-to-top.html +22 -106
  25. package/src/components/back-to-top/back-to-top.react-snapshot.html +94 -148
  26. package/src/components/back-to-top/config.json +41 -10
  27. package/src/components/button/Button.tsx +12 -3
  28. package/src/components/button/button.django-snapshot.html +18 -0
  29. package/src/components/button/button.django.html +3 -2
  30. package/src/components/button/button.react-snapshot.html +16 -0
  31. package/src/components/button/config.json +11 -2
  32. package/src/components/callout/callout.django.html +1 -1
  33. package/src/components/callout/config.json +7 -16
  34. package/src/components/character-count/CharacterCount.tsx +2 -0
  35. package/src/components/character-count/character-count.react-snapshot.html +7 -0
  36. package/src/components/chat/Chat.tsx +575 -0
  37. package/src/components/chat/README.md +174 -0
  38. package/src/components/chat/avatarProps.ts +32 -0
  39. package/src/components/chat/chat.django-snapshot.html +23515 -0
  40. package/src/components/chat/chat.django.html +75 -0
  41. package/src/components/chat/chat.html +116 -0
  42. package/src/components/chat/chat.react-snapshot.html +16895 -0
  43. package/src/components/chat/config.json +1241 -0
  44. package/src/components/chat-attachment/ChatAttachment.tsx +39 -0
  45. package/src/components/chat-attachment/chat-attachment.django.html +24 -0
  46. package/src/components/chat-attachment/chat-attachment.html +10 -0
  47. package/src/components/chat-attachment/config.json +27 -0
  48. package/src/components/chat-attachments/ChatAttachments.tsx +17 -0
  49. package/src/components/chat-attachments/chat-attachments.django-snapshot.html +58 -0
  50. package/src/components/chat-attachments/chat-attachments.django.html +10 -0
  51. package/src/components/chat-attachments/chat-attachments.html +14 -0
  52. package/src/components/chat-attachments/chat-attachments.react-snapshot.html +46 -0
  53. package/src/components/chat-attachments/config.json +25 -0
  54. package/src/components/chat-bubble/ChatBubble.tsx +39 -0
  55. package/src/components/chat-bubble/ChatFormattedText.tsx +138 -0
  56. package/src/components/chat-bubble/chat-bubble.django-snapshot.html +128 -0
  57. package/src/components/chat-bubble/chat-bubble.django.html +19 -0
  58. package/src/components/chat-bubble/chat-bubble.html +1 -0
  59. package/src/components/chat-bubble/chat-bubble.react-snapshot.html +118 -0
  60. package/src/components/chat-bubble/config.json +70 -0
  61. package/src/components/chat-composer/ChatComposer.tsx +210 -0
  62. package/src/components/chat-composer/README.md +15 -0
  63. package/src/components/chat-composer/chat-composer.django-snapshot.html +575 -0
  64. package/src/components/chat-composer/chat-composer.django.html +77 -0
  65. package/src/components/chat-composer/chat-composer.html +44 -0
  66. package/src/components/chat-composer/chat-composer.react-snapshot.html +519 -0
  67. package/src/components/chat-composer/chat-formatting.django.html +59 -0
  68. package/src/components/chat-composer/config.json +137 -0
  69. package/src/components/chat-context/ChatContext.tsx +46 -0
  70. package/src/components/chat-context/chat-context.django-snapshot.html +35 -0
  71. package/src/components/chat-context/chat-context.django.html +20 -0
  72. package/src/components/chat-context/chat-context.html +9 -0
  73. package/src/components/chat-context/chat-context.react-snapshot.html +30 -0
  74. package/src/components/chat-context/config.json +36 -0
  75. package/src/components/chat-controls/ChatControls.tsx +67 -0
  76. package/src/components/chat-controls/chat-controls.django-snapshot.html +114 -0
  77. package/src/components/chat-controls/chat-controls.django.html +36 -0
  78. package/src/components/chat-controls/chat-controls.html +11 -0
  79. package/src/components/chat-controls/chat-controls.react-snapshot.html +107 -0
  80. package/src/components/chat-controls/config.json +67 -0
  81. package/src/components/chat-directory/ChatDirectory.tsx +168 -0
  82. package/src/components/chat-directory/chat-directory.django-snapshot.html +546 -0
  83. package/src/components/chat-directory/chat-directory.django.html +14 -0
  84. package/src/components/chat-directory/chat-directory.html +4 -0
  85. package/src/components/chat-directory/chat-directory.react-snapshot.html +471 -0
  86. package/src/components/chat-directory/config.json +242 -0
  87. package/src/components/chat-directory-item/ChatDirectoryItem.tsx +150 -0
  88. package/src/components/chat-directory-item/chat-directory-item.django-snapshot.html +281 -0
  89. package/src/components/chat-directory-item/chat-directory-item.django.html +38 -0
  90. package/src/components/chat-directory-item/chat-directory-item.html +9 -0
  91. package/src/components/chat-directory-item/chat-directory-item.react-snapshot.html +249 -0
  92. package/src/components/chat-directory-item/config.json +103 -0
  93. package/src/components/chat-history/ChatHistory.tsx +30 -0
  94. package/src/components/chat-history/chat-history.django-snapshot.html +113 -0
  95. package/src/components/chat-history/chat-history.django.html +20 -0
  96. package/src/components/chat-history/chat-history.html +9 -0
  97. package/src/components/chat-history/chat-history.react-snapshot.html +111 -0
  98. package/src/components/chat-history/config.json +24 -0
  99. package/src/components/chat-message/ChatMessage.tsx +148 -0
  100. package/src/components/chat-message/chat-message.django-snapshot.html +758 -0
  101. package/src/components/chat-message/chat-message.django.html +56 -0
  102. package/src/components/chat-message/chat-message.html +12 -0
  103. package/src/components/chat-message/chat-message.react-snapshot.html +627 -0
  104. package/src/components/chat-message/config.json +278 -0
  105. package/src/components/chat-message-actions/ChatMessageActions.tsx +133 -0
  106. package/src/components/chat-message-actions/chat-message-actions.django-snapshot.html +345 -0
  107. package/src/components/chat-message-actions/chat-message-actions.django.html +29 -0
  108. package/src/components/chat-message-actions/chat-message-actions.html +53 -0
  109. package/src/components/chat-message-actions/chat-message-actions.react-snapshot.html +295 -0
  110. package/src/components/chat-message-actions/config.json +121 -0
  111. package/src/components/chat-window/ChatWindow.tsx +133 -0
  112. package/src/components/chat-window/chat-window.django-snapshot.html +448 -0
  113. package/src/components/chat-window/chat-window.django.html +39 -0
  114. package/src/components/chat-window/chat-window.html +26 -0
  115. package/src/components/chat-window/chat-window.react-snapshot.html +286 -0
  116. package/src/components/chat-window/config.json +123 -0
  117. package/src/components/clickable/Clickable.tsx +19 -5
  118. package/src/components/clickable/clickable.django-snapshot.html +11 -2
  119. package/src/components/clickable/clickable.django.html +2 -0
  120. package/src/components/clickable/clickable.react-snapshot.html +10 -2
  121. package/src/components/clickable/config.json +4 -0
  122. package/src/components/code/code.django-snapshot.html +27 -22
  123. package/src/components/code/code.html +2 -2
  124. package/src/components/code/code.react-snapshot.html +43 -8
  125. package/src/components/copy-to-clipboard/CopyToClipboard.tsx +2 -7
  126. package/src/components/copy-to-clipboard/copy-to-clipboard.django-snapshot.html +6 -4
  127. package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +3 -2
  128. package/src/components/copy-to-clipboard/copy-to-clipboard.react-snapshot.html +14 -2
  129. package/src/components/file-list/FileList.tsx +3 -2
  130. package/src/components/file-list/config.json +5 -0
  131. package/src/components/file-list/file-list.django-snapshot.html +63 -0
  132. package/src/components/file-list/file-list.django.html +1 -1
  133. package/src/components/file-list/file-list.react-snapshot.html +53 -0
  134. package/src/components/footer/footer.django-snapshot.html +0 -3
  135. package/src/components/header/header.django-snapshot.html +5 -167
  136. package/src/components/header/header.django.html +2 -2
  137. package/src/components/header/header.html +1 -11
  138. package/src/components/header/header.react-snapshot.html +3 -6
  139. package/src/components/hero/hero.django-snapshot.html +0 -20
  140. package/src/components/hero/hero.django.html +3 -3
  141. package/src/components/icon-list/IconList.tsx +10 -2
  142. package/src/components/icon-list/config.json +5 -1
  143. package/src/components/icon-list/icon-list.django-snapshot.html +39 -0
  144. package/src/components/icon-list/icon-list.django.html +2 -0
  145. package/src/components/icon-list/icon-list.react-snapshot.html +31 -0
  146. package/src/components/image/image.django.html +4 -4
  147. package/src/components/input/Input.tsx +1 -1
  148. package/src/components/input/config.json +2 -3
  149. package/src/components/input/input.django-snapshot.html +4 -21
  150. package/src/components/input/input.django.html +2 -2
  151. package/src/components/link/Link.tsx +7 -4
  152. package/src/components/link/config.json +2 -3
  153. package/src/components/link/link.django-snapshot.html +8 -0
  154. package/src/components/link/link.django.html +2 -2
  155. package/src/components/link/link.html +4 -1
  156. package/src/components/link/link.react-snapshot.html +8 -0
  157. package/src/components/list/List.tsx +10 -2
  158. package/src/components/list/config.json +5 -1
  159. package/src/components/list/list.django-snapshot.html +26 -0
  160. package/src/components/list/list.django.html +2 -0
  161. package/src/components/list/list.html +20 -0
  162. package/src/components/list/list.react-snapshot.html +20 -0
  163. package/src/components/memorable-date/memorable-date.django-snapshot.html +0 -8
  164. package/src/components/memorable-date/memorable-date.django.html +2 -2
  165. package/src/components/misc-banner/misc-banner.django-snapshot.html +12 -12
  166. package/src/components/misc-banner/misc-banner.django.html +4 -2
  167. package/src/components/page/Page.tsx +16 -0
  168. package/src/components/page/config.json +18 -1
  169. package/src/components/page/page.django-snapshot.html +74 -0
  170. package/src/components/page/page.django.html +8 -0
  171. package/src/components/page/page.html +60 -0
  172. package/src/components/page/page.react-snapshot.html +60 -0
  173. package/src/components/popover/Popover.tsx +60 -9
  174. package/src/components/popover/PopoverMenu.tsx +33 -15
  175. package/src/components/popover/config.json +88 -14
  176. package/src/components/popover/popover-menu.django.html +13 -2
  177. package/src/components/popover/popover.django-snapshot.html +229 -7
  178. package/src/components/popover/popover.django.html +3 -2
  179. package/src/components/popover/popover.react-snapshot.html +127 -4
  180. package/src/components/process-list/config.json +41 -3
  181. package/src/components/quote/Quote.tsx +9 -2
  182. package/src/components/search/Search.tsx +1 -1
  183. package/src/components/search/config.json +3 -4
  184. package/src/components/search/search.django-snapshot.html +262 -1684
  185. package/src/components/search/search.django.html +1 -20
  186. package/src/components/select/select.django-snapshot.html +7 -7
  187. package/src/components/select/select.react-snapshot.html +7 -7
  188. package/src/components/summary/Summary.tsx +4 -2
  189. package/src/components/summary/config.json +4 -0
  190. package/src/components/summary/summary.django.html +4 -4
  191. package/src/components/table/Table.tsx +58 -25
  192. package/src/components/table/config.json +61 -13
  193. package/src/components/tag/Tag.tsx +40 -7
  194. package/src/components/tag/config.json +18 -2
  195. package/src/components/tag/tag.django-snapshot.html +16 -1
  196. package/src/components/tag/tag.django.html +12 -6
  197. package/src/components/tag/tag.html +4 -0
  198. package/src/components/tag/tag.react-snapshot.html +16 -1
  199. package/src/components/tag-group/TagGroup.tsx +6 -9
  200. package/src/components/tag-group/config.json +4 -0
  201. package/src/components/tag-group/tag-group.django.html +1 -1
  202. package/src/components/theme-picker/ThemePicker.tsx +95 -52
  203. package/src/components/theme-picker/config.json +7 -4
  204. package/src/components/theme-picker/theme-picker-select.django.html +7 -0
  205. package/src/components/theme-picker/theme-picker.django-snapshot.html +101 -21
  206. package/src/components/theme-picker/theme-picker.django.html +22 -24
  207. package/src/components/theme-picker/theme-picker.html +86 -56
  208. package/src/components/theme-picker/theme-picker.react-snapshot.html +74 -18
@@ -0,0 +1,118 @@
1
+ <h3 class="site-preview-heading">Default</h3>
2
+ <div>
3
+ <section id="react-example-bubble-default" class="usx-chat" style="max-width: 28rem">
4
+ <div data-chat-view="conversation" class="usx-chat__window" style="height: auto">
5
+ <span class="usx-chat__copy-status usa-sr-only" role="status"></span>
6
+ <ol class="usx-chat__messages">
7
+ <li data-message-id="example-message" data-sender-name="Avery">
8
+ <div class="usx-chat__bubble"><p>Your appointment is confirmed.</p></div>
9
+ </li>
10
+ </ol>
11
+ </div>
12
+ </section>
13
+ </div>
14
+
15
+ <h3 class="site-preview-heading">Formatted</h3>
16
+ <div>
17
+ <section id="react-example-bubble-formatted" class="usx-chat" style="max-width: 28rem">
18
+ <div data-chat-view="conversation" class="usx-chat__window" style="height: auto">
19
+ <span class="usx-chat__copy-status usa-sr-only" role="status"></span>
20
+ <ol class="usx-chat__messages">
21
+ <li data-message-id="example-message" data-sender-name="Avery">
22
+ <div class="usx-chat__bubble">
23
+ <p><strong>Bring with you:</strong></p>
24
+ <ul>
25
+ <li>Photo identification</li>
26
+ <li>Your appointment letter</li>
27
+ </ul>
28
+ <blockquote><p>Arrive ten minutes early.</p></blockquote>
29
+ </div>
30
+ </li>
31
+ </ol>
32
+ </div>
33
+ </section>
34
+ </div>
35
+
36
+ <h3 class="site-preview-heading">Attachments</h3>
37
+ <div>
38
+ <section id="react-example-bubble-attachments" class="usx-chat" style="max-width: 28rem">
39
+ <div data-chat-view="conversation" class="usx-chat__window" style="height: auto">
40
+ <span class="usx-chat__copy-status usa-sr-only" role="status"></span>
41
+ <ol class="usx-chat__messages">
42
+ <li data-message-id="example-message" data-sender-name="Avery">
43
+ <div class="usx-chat__bubble">
44
+ <p>Here are your notes.</p>
45
+ <ul class="usx-chat__attachments">
46
+ <li>
47
+ <a
48
+ class="usa-button usx-button usa-button--unstyled"
49
+ href="/liberty-island-notes.txt"
50
+ download="Appointment notes.txt"
51
+ ><svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img">
52
+ <use href="/img/sprite.svg#attach_file"></use></svg
53
+ ><span>Appointment notes.txt</span></a
54
+ >
55
+ </li>
56
+ </ul>
57
+ </div>
58
+ </li>
59
+ </ol>
60
+ </div>
61
+ </section>
62
+ </div>
63
+
64
+ <h3 class="site-preview-heading">Reactions</h3>
65
+ <div>
66
+ <section id="react-example-bubble-reactions" class="usx-chat" style="max-width: 28rem">
67
+ <div data-chat-view="conversation" class="usx-chat__window" style="height: auto">
68
+ <span class="usx-chat__copy-status usa-sr-only" role="status"></span>
69
+ <ol class="usx-chat__messages">
70
+ <li data-message-id="example-message" data-sender-name="Avery">
71
+ <div class="usx-chat__bubble">
72
+ <p>Thank you for the update.</p>
73
+ <div role="group" aria-label="Reactions" class="usx-tag-group usx-chat__reactions">
74
+ <button
75
+ type="button"
76
+ class="usa-button usx-button usa-button--unstyled usa-tag usx-tag usx-tag--outline usx-tag--interactive usa-link usx-link usx-no-visited usx-chat__reaction"
77
+ aria-pressed="true"
78
+ aria-label="Helpful, 2"
79
+ data-usx-chat-reaction="Helpful"
80
+ >
81
+ 👍 2
82
+ </button>
83
+ </div>
84
+ </div>
85
+ </li>
86
+ </ol>
87
+ </div>
88
+ </section>
89
+ </div>
90
+
91
+ <h3 class="site-preview-heading">Rich Content</h3>
92
+ <div>
93
+ <section id="react-example-bubble-richcontent" class="usx-chat" style="max-width: 28rem">
94
+ <div data-chat-view="conversation" class="usx-chat__window" style="height: auto">
95
+ <span class="usx-chat__copy-status usa-sr-only" role="status"></span>
96
+ <ol class="usx-chat__messages">
97
+ <li data-message-id="example-message" data-sender-name="Avery">
98
+ <div class="usx-chat__bubble">
99
+ <p>Review package: application_AR2048_supporting_documents_2026_11_18_final.pdf</p>
100
+ <ul class="usa-button-group usx-button-group">
101
+ <li class="usa-button-group__item">
102
+ <a class="usa-button usx-button usa-button--primary" href="#review">Review</a>
103
+ </li>
104
+ <li class="usa-button-group__item">
105
+ <a
106
+ class="usa-button usx-button usa-button--outline"
107
+ href="/liberty-island-notes.txt"
108
+ download=""
109
+ >Download</a
110
+ >
111
+ </li>
112
+ </ul>
113
+ </div>
114
+ </li>
115
+ </ol>
116
+ </div>
117
+ </section>
118
+ </div>
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "chat-bubble",
3
+ "template": "chat-bubble/chat-bubble.django.html",
4
+ "version": 1,
5
+ "default": {
6
+ "text": "Your appointment is confirmed."
7
+ },
8
+ "props": {
9
+ "text": {
10
+ "type": "string",
11
+ "description": "Message text. Chat safely renders **bold**, *italic*, <u>underline</u>, ~~strike~~, numbered and bulleted lines, > quotes, and fenced code blocks. Use content for other rich content."
12
+ },
13
+ "content": {
14
+ "type": "slot",
15
+ "description": "Optional rich message content. Sanitize HTML before passing it to Django; supply exportText for copied transcripts."
16
+ },
17
+ "attachments": {
18
+ "type": "array",
19
+ "description": "Files and images included with the message.",
20
+ "items": {
21
+ "type": "object",
22
+ "description": "One file or image attachment.",
23
+ "properties": {
24
+ "name": {
25
+ "type": "string",
26
+ "description": "Accessible file name."
27
+ },
28
+ "url": {
29
+ "type": "string",
30
+ "description": "Download URL, if available."
31
+ },
32
+ "imageUrl": {
33
+ "type": "string",
34
+ "description": "Optional image preview URL rendered through Image."
35
+ },
36
+ "alt": {
37
+ "type": "string",
38
+ "description": "Description of the preview image. Defaults to the file name."
39
+ }
40
+ }
41
+ }
42
+ },
43
+ "reactions": {
44
+ "type": "array",
45
+ "description": "Current reactions, rendered as toggle buttons in supplied order. Keep an entry in place while its count remains positive.",
46
+ "items": {
47
+ "type": "object",
48
+ "description": "One reaction.",
49
+ "properties": {
50
+ "emoji": {
51
+ "type": "string",
52
+ "description": "Visible emoji."
53
+ },
54
+ "label": {
55
+ "type": "string",
56
+ "description": "Accessible reaction name and event value."
57
+ },
58
+ "count": {
59
+ "type": "number",
60
+ "description": "Number of reactions."
61
+ },
62
+ "selected": {
63
+ "type": "boolean",
64
+ "description": "Whether the current user selected this reaction."
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,210 @@
1
+ import React from 'react';
2
+ import Button from '../button/Button';
3
+ import ButtonGroup from '../button-group/ButtonGroup';
4
+ import Icon from '../icon/Icon';
5
+ import Popover from '../popover/Popover';
6
+ import type { PopoverMenuItem } from '../popover/PopoverMenu';
7
+ import TextArea from '../text-area/TextArea';
8
+ import config from './config.json';
9
+
10
+ export interface ChatComposerEmoji {
11
+ emoji: string;
12
+ name: string;
13
+ label: string;
14
+ aliases?: string[];
15
+ }
16
+
17
+ export interface ChatComposerProps {
18
+ id: string;
19
+ value?: string;
20
+ formAction?: string;
21
+ disabled?: boolean;
22
+ allowAttachments?: boolean;
23
+ allowFormatting?: boolean;
24
+ accept?: string;
25
+ emojiPack?: ChatComposerEmoji[];
26
+ isThread?: boolean;
27
+ conversationId?: string;
28
+ recipientId?: string;
29
+ recipientIds?: string[];
30
+ /** Require at least one recipient, including associated picker checkboxes, before sending. */
31
+ requireRecipients?: boolean;
32
+ threadRootId?: string;
33
+ }
34
+
35
+ export default function ChatComposer({
36
+ id,
37
+ value = '',
38
+ formAction,
39
+ disabled = false,
40
+ allowAttachments = false,
41
+ allowFormatting = false,
42
+ accept,
43
+ emojiPack = config.props.emojiPack.default,
44
+ isThread = false,
45
+ conversationId,
46
+ recipientId,
47
+ recipientIds = [],
48
+ requireRecipients = false,
49
+ threadRootId,
50
+ }: ChatComposerProps) {
51
+ return (
52
+ <form
53
+ id={`${id}-composer`}
54
+ data-usx-chat-require-recipients={requireRecipients ? 'true' : undefined}
55
+ className="usx-chat-composer usx-chat__composer"
56
+ action={formAction}
57
+ method="post"
58
+ encType={allowAttachments ? 'multipart/form-data' : undefined}
59
+ >
60
+ {conversationId && <input type="hidden" name="conversationId" value={conversationId} />}
61
+ {recipientId && !conversationId && (
62
+ <input type="hidden" name="recipientId" value={recipientId} />
63
+ )}
64
+ {!conversationId &&
65
+ recipientIds.map((recipient, index) => (
66
+ <input key={index} type="hidden" name="recipientIds" value={recipient} />
67
+ ))}
68
+ {isThread && threadRootId && <input type="hidden" name="threadRootId" value={threadRootId} />}
69
+ {allowFormatting && (
70
+ <div
71
+ id={`${id}-formatting`}
72
+ className="usx-chat__formatting"
73
+ aria-label="Message formatting"
74
+ hidden
75
+ >
76
+ <ButtonGroup
77
+ segmented
78
+ className="usx-chat__format-buttons"
79
+ buttonProps={(
80
+ [
81
+ ['bold', 'Bold', 'Ctrl/⌘+B', <strong key="bold">B</strong>],
82
+ ['italic', 'Italic', 'Ctrl/⌘+I', <em key="italic">I</em>],
83
+ ['underline', 'Underline', 'Ctrl/⌘+U', <u key="underline">U</u>],
84
+ ['strike', 'Strikethrough', 'Ctrl/⌘+Shift+X', <s key="strike">S</s>],
85
+ ['ordered', 'Numbered list', 'Ctrl/⌘+Shift+7', '1.'],
86
+ ['unordered', 'Bulleted list', 'Ctrl/⌘+Shift+8', <Icon key="list" name="list" />],
87
+ [
88
+ 'quote',
89
+ 'Block quote',
90
+ 'Ctrl/⌘+Shift+9',
91
+ <Icon key="quote" name="format_quote" />,
92
+ ],
93
+ ['code', 'Code block', 'Ctrl/⌘+Alt+Shift+C', <Icon key="code" name="code" />],
94
+ ] as const
95
+ ).map(([format, label, shortcut, icon]) => ({
96
+ type: 'button' as const,
97
+ variant: 'outline' as const,
98
+ className: 'usx-chat__format-button',
99
+ disabled,
100
+ 'aria-label': label,
101
+ title: `${label} (${shortcut})`,
102
+ extraAttributes: { 'data-usx-chat-format': format },
103
+ children: icon,
104
+ }))}
105
+ />
106
+ </div>
107
+ )}
108
+ <TextArea
109
+ id={`${id}-message`}
110
+ label={isThread ? 'Reply in thread' : 'Message'}
111
+ screenReaderOnlyLabel
112
+ formGroup={false}
113
+ name="message"
114
+ defaultValue={value}
115
+ disabled={disabled}
116
+ placeholder={isThread ? 'Reply in thread' : 'Write a message'}
117
+ rows={2}
118
+ />
119
+ <div className="usx-chat__composer-actions">
120
+ <div className="usx-chat__attach">
121
+ {(allowAttachments || allowFormatting) && (
122
+ <ButtonGroup
123
+ className="usx-chat__composer-tools"
124
+ buttonProps={[
125
+ ...(allowAttachments
126
+ ? [
127
+ {
128
+ type: 'button' as const,
129
+ variant: 'outline' as const,
130
+ 'aria-label': 'Attach files',
131
+ title: 'Attach files',
132
+ extraAttributes: { 'data-usx-chat-attach': '' },
133
+ disabled,
134
+ children: <Icon name="attach_file" />,
135
+ },
136
+ ]
137
+ : []),
138
+ ...(allowFormatting
139
+ ? [
140
+ {
141
+ type: 'button' as const,
142
+ variant: 'outline' as const,
143
+ 'aria-label': 'Show formatting',
144
+ title: 'Show formatting',
145
+ 'aria-expanded': false,
146
+ 'aria-controls': `${id}-formatting`,
147
+ extraAttributes: { 'data-usx-chat-toggle-formatting': '' },
148
+ disabled,
149
+ children: <Icon name="text_fields" />,
150
+ },
151
+ ]
152
+ : []),
153
+ ]}
154
+ />
155
+ )}
156
+ {emojiPack.length > 0 && !disabled && (
157
+ <Popover
158
+ id={`${id}-emoji-picker`}
159
+ side="top"
160
+ align="start"
161
+ panelShape="square"
162
+ className="usx-chat__emoji-picker"
163
+ menuItems={emojiPack.slice(0, 100).map(
164
+ (option): PopoverMenuItem => ({
165
+ type: 'button',
166
+ id: option.name,
167
+ text: option.emoji,
168
+ extraAttributes: {
169
+ 'aria-label': option.label,
170
+ title: `:${option.name}:`,
171
+ 'data-usx-chat-emoji': option.emoji,
172
+ 'data-usx-chat-emoji-name': option.name,
173
+ 'data-usx-chat-emoji-aliases': (option.aliases ?? []).join(','),
174
+ },
175
+ })
176
+ )}
177
+ summaryProps={{
178
+ ariaLabel: 'Choose emoji',
179
+ title: 'Choose emoji',
180
+ className: 'usa-button usx-button usa-button--outline',
181
+ children: <Icon name="sentiment_satisfied" />,
182
+ }}
183
+ />
184
+ )}
185
+ {allowAttachments && (
186
+ <input
187
+ type="file"
188
+ hidden
189
+ name="attachments"
190
+ multiple
191
+ accept={accept}
192
+ disabled={disabled}
193
+ aria-label="Attach files"
194
+ />
195
+ )}
196
+ </div>
197
+ <Button
198
+ type="submit"
199
+ variant="primary"
200
+ className="usx-chat__send"
201
+ label={isThread ? 'Send reply' : 'Send'}
202
+ iconProps={[{ name: 'send' }]}
203
+ disabled={
204
+ disabled || !value.trim() || (requireRecipients && !recipientId && !recipientIds.length)
205
+ }
206
+ />
207
+ </div>
208
+ </form>
209
+ );
210
+ }
@@ -0,0 +1,15 @@
1
+ # Chat Composer
2
+
3
+ ChatComposer renders a message form using the same props in React and Django. `value` supplies initial text. `allowAttachments` adds a file input and a slim FileList for files staged to send; the list appears only after a selection and each row has a remove action. `allowFormatting` adds the formatting toggle and panel. Both default to false. `emojiPack` replaces the default emoji choices; an empty array hides the picker. `isThread` changes the reply labels and includes `threadRootId` when supplied.
4
+
5
+ Import `ChatComposer` from `@solexllc/usx-react/chat` and include the optional [Chat styles](../../../../usx/README.md#optional-chat). Initialize the default exports from `@solexllc/usx/js/chat` and `@solexllc/usx/js/popover`, even when displaying the composer alone. The same enhancement handles either renderer's textarea, file controls, formatting, emoji, and submission. Each file selection is added to the staged files. When files exist, the shared native FileList renderer creates slim rows and a screen-reader-only “Files ready to send” heading. Removing a row also removes its corresponding input file. Listen for `usx:chat-send` on the surrounding Chat or standalone form. The host sends messages and retains drafts. `formAction` enables native form submission.
6
+
7
+ For a new conversation, supply `recipientIds` or associate ChatDirectory recipient checkboxes with the form ID `${id}-composer`. Enable `requireRecipients` to prevent sends without recipients while allowing users to draft text. Native submissions carry repeated `recipientIds` fields; enhancement sends the same IDs in `usx:chat-send.detail.recipientIds`. The host creates or reuses the conversation. Existing `recipientId` integrations remain supported; `conversationId` identifies an existing conversation.
8
+
9
+ ```tsx
10
+ <ChatComposer id="support-composer" value="" allowAttachments allowFormatting />
11
+ ```
12
+
13
+ ```django
14
+ {% chat_composer id='support-composer' allowAttachments=True allowFormatting=True %}{% endchat_composer %}
15
+ ```