@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solexllc/usx-react",
3
- "version": "0.11.0",
3
+ "version": "1.0.0",
4
4
  "description": "React component library for USX.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,6 +18,10 @@
18
18
  ".": {
19
19
  "import": "./dist/index.js",
20
20
  "require": "./dist/index.cjs"
21
+ },
22
+ "./chat": {
23
+ "import": "./dist/chat.js",
24
+ "require": "./dist/chat.cjs"
21
25
  }
22
26
  },
23
27
  "files": [
@@ -25,9 +29,9 @@
25
29
  "dist"
26
30
  ],
27
31
  "dependencies": {
28
- "@solexllc/usx": "0.13.0",
29
- "@solexllc/usx-theme": "0.11.2",
30
- "@solexllc/usx-uswds-fixes": "0.1.17",
32
+ "@solexllc/usx": "1.0.0",
33
+ "@solexllc/usx-theme": "1.0.0",
34
+ "@solexllc/usx-uswds-fixes": "0.1.18",
31
35
  "classnames": "^2.5.1",
32
36
  "prop-types": "^15.8.1"
33
37
  },
@@ -44,6 +48,6 @@
44
48
  },
45
49
  "scripts": {
46
50
  "build": "vite build",
47
- "test": "pnpm build && node test/toggle-check.mjs && node test/quote-check.mjs && node test/composition-check.mjs && node test/asset-url-check.mjs && node test/container-check.mjs && node test/error-page-check.mjs"
51
+ "test": "pnpm build && node test/entry-points-check.mjs && node test/toggle-check.mjs && node test/quote-check.mjs && node test/composition-check.mjs && node test/asset-url-check.mjs && node test/container-check.mjs && node test/error-page-check.mjs && node test/chat-contract-check.mjs"
48
52
  }
49
53
  }
package/src/chat.js ADDED
@@ -0,0 +1,15 @@
1
+ // Auto-generated by scripts/generate-exports.js — do not edit by hand.
2
+ // Run: pnpm generate:exports
3
+ export { default as Chat } from './components/chat/Chat.tsx';
4
+ export { default as ChatAttachment } from './components/chat-attachment/ChatAttachment.tsx';
5
+ export { default as ChatAttachments } from './components/chat-attachments/ChatAttachments.tsx';
6
+ export { default as ChatBubble } from './components/chat-bubble/ChatBubble.tsx';
7
+ export { default as ChatComposer } from './components/chat-composer/ChatComposer.tsx';
8
+ export { default as ChatContext } from './components/chat-context/ChatContext.tsx';
9
+ export { default as ChatControls } from './components/chat-controls/ChatControls.tsx';
10
+ export { default as ChatDirectory } from './components/chat-directory/ChatDirectory.tsx';
11
+ export { default as ChatDirectoryItem } from './components/chat-directory-item/ChatDirectoryItem.tsx';
12
+ export { default as ChatHistory } from './components/chat-history/ChatHistory.tsx';
13
+ export { default as ChatMessage } from './components/chat-message/ChatMessage.tsx';
14
+ export { default as ChatMessageActions } from './components/chat-message-actions/ChatMessageActions.tsx';
15
+ export { default as ChatWindow } from './components/chat-window/ChatWindow.tsx';
@@ -1,70 +1,21 @@
1
1
  import React from 'react';
2
2
  import classnames from 'classnames';
3
+ import AccordionItem from '../accordion-item/AccordionItem';
4
+ import type { AccordionHeadingAs, AccordionItemProps } from '../accordion-item/AccordionItem';
3
5
 
4
- export type AccordionHeadingAs = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
5
-
6
- export interface AccordionItemProps {
7
- title: React.ReactNode;
8
- id: string;
9
- content: React.ReactNode;
10
- expanded?: boolean;
11
- headingClassName?: string;
12
- contentClassName?: string;
13
- headingAs?: AccordionHeadingAs;
14
- handleToggle?: React.MouseEventHandler<HTMLButtonElement>;
15
- }
6
+ export type { AccordionHeadingAs, AccordionItemProps } from '../accordion-item/AccordionItem';
16
7
 
17
8
  export interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
18
9
  extraAttributes?: Record<string, unknown>;
19
10
  bordered?: boolean;
20
- items?: AccordionItemProps[];
11
+ items?: (Omit<AccordionItemProps, 'id'> & { id?: string })[];
21
12
  multiselectable?: boolean;
22
13
  headingAs?: AccordionHeadingAs;
23
14
  iconPosition?: 'start' | 'end';
15
+ headingClassName?: string;
16
+ contentClassName?: string;
24
17
  }
25
18
 
26
- function AccordionItem({
27
- title,
28
- id,
29
- content,
30
- expanded = false,
31
- headingClassName,
32
- contentClassName,
33
- headingAs = 'h3',
34
- handleToggle,
35
- }: AccordionItemProps) {
36
- const headingClasses = classnames('usa-accordion__heading', headingClassName)
37
- const contentClasses = classnames(
38
- 'usa-accordion__content',
39
- 'usa-prose',
40
- contentClassName
41
- )
42
-
43
- const Heading = headingAs
44
-
45
- return (
46
- <>
47
- <Heading id={`${id}-heading`} className={headingClasses}>
48
- <button
49
- type="button"
50
- className="usa-accordion__button"
51
- aria-expanded={expanded}
52
- aria-controls={`${id}-content`}
53
- onClick={handleToggle}>
54
- {title}
55
- </button>
56
- </Heading>
57
- <div
58
- id={`${id}-content`}
59
- aria-labelledby={`${id}-heading`}
60
- className={contentClasses}
61
- hidden={!expanded}>
62
- {content}
63
- </div>
64
- </>
65
- )
66
- };
67
-
68
19
  export function Accordion({
69
20
  id,
70
21
  bordered = false,
@@ -95,10 +46,11 @@ export function Accordion({
95
46
  {...props}
96
47
  {...extraAttributes}
97
48
  >
98
- {items.map((item) => (
49
+ {items.map((item, index) => (
99
50
  <AccordionItem
100
- key={item.id}
51
+ key={item.id || `${id ?? ''}-${index}`}
101
52
  {...item}
53
+ id={item.id || `${id ?? ''}-${index}`}
102
54
  headingAs={headingAs}
103
55
  headingClassName={headingClassName}
104
56
  contentClassName={contentClassName}
@@ -1,3 +1,4 @@
1
+ {% load usx_components %}
1
2
  <div
2
3
  id="{{ id }}"
3
4
  class="usa-accordion usx-accordion {% if bordered %}usa-accordion--bordered{% endif %}{% if iconPosition == 'start' %} usa-accordion--icon-start{% elif iconPosition == 'end' %} usa-accordion--icon-end{% endif %}{% if className %} {{ className }}{% endif %}" {% if extraAttributes %}{% for attr, value in extraAttributes.items %} {{ attr }}="{% if value is True %}true{% elif value is False %}false{% else %}{{ value }}{% endif %}"{% endfor %}{% endif %}
@@ -6,26 +7,15 @@
6
7
  {% endif %}
7
8
  >
8
9
  {% for item in items %}
9
- <{% if headingAs == 'h1' %}h1{% elif headingAs == 'h2' %}h2{% elif headingAs == 'h4' %}h4{% elif headingAs == 'h5' %}h5{% elif headingAs == 'h6' %}h6{% else %}h3{% endif %} id="{% if item.id %}{{ item.id }}{% else %}{{ id }}-{{ forloop.counter0 }}{% endif %}-heading" class="usa-accordion__heading{% if headingClassName %} {{ headingClassName }}{% endif %}">
10
- <button
11
- class="usa-accordion__button"
12
- aria-expanded="{% if item.expanded %}true{% else %}false{% endif %}"
13
- aria-controls="{% if item.id %}{{ item.id }}{% else %}{{ id }}-{{ forloop.counter0 }}{% endif %}-content"
14
- type="button"
15
- >
16
- {{ item.title }}
17
- </button>
18
- </{% if headingAs == 'h1' %}h1{% elif headingAs == 'h2' %}h2{% elif headingAs == 'h4' %}h4{% elif headingAs == 'h5' %}h5{% elif headingAs == 'h6' %}h6{% else %}h3{% endif %}>
19
-
20
- <div
21
- id="{% if item.id %}{{ item.id }}{% else %}{{ id }}-{{ forloop.counter0 }}{% endif %}-content"
22
- class="usa-accordion__content usa-prose{% if contentClassName %} {{ contentClassName }}{% endif %}"
23
- aria-labelledby="{% if item.id %}{{ item.id }}{% else %}{{ id }}-{{ forloop.counter0 }}{% endif %}-heading"
24
- {% if not item.expanded %}hidden{% endif %}
25
- >
26
- {{ item.content }}
27
- </div>
28
-
10
+ {% if item.id %}
11
+ {% accordion_item props=item id=item.id headingAs=headingAs headingClassName=headingClassName contentClassName=contentClassName %}{% endaccordion_item %}
12
+ {% else %}
13
+ {% with index=forloop.counter0|stringformat:"s" %}
14
+ {% with baseId=id|default:""|add:"-"|add:index %}
15
+ {% accordion_item props=item id=baseId headingAs=headingAs headingClassName=headingClassName contentClassName=contentClassName %}{% endaccordion_item %}
16
+ {% endwith %}
17
+ {% endwith %}
18
+ {% endif %}
29
19
  {% endfor %}
30
20
 
31
21
  </div>
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "accordion",
3
3
  "template": "accordion/accordion.django.html",
4
- "version": 3,
4
+ "version": 4,
5
5
  "default": {
6
6
  "id": "accordion-default",
7
7
  "items": [
@@ -36,7 +36,13 @@
36
36
  "items": {
37
37
  "type": "array",
38
38
  "default": [],
39
- "description": "An array of accordion items. Each item sets title and content, and may set id (used for the heading and content ids) and expanded (start open)."
39
+ "description": "Accordion items. The parent supplies the heading element and heading/content classes for every item.",
40
+ "items": {
41
+ "type": "object",
42
+ "description": "Props for one accordion item. If id is omitted, the accordion id and item index are used.",
43
+ "component": "accordion-item",
44
+ "omit": ["headingAs", "headingClassName", "contentClassName"]
45
+ }
40
46
  },
41
47
  "multiselectable": {
42
48
  "type": "boolean",
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import classnames from 'classnames';
3
+
4
+ export type AccordionHeadingAs = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
5
+
6
+ export interface AccordionItemProps {
7
+ title: React.ReactNode;
8
+ id: string;
9
+ content?: React.ReactNode;
10
+ children?: React.ReactNode;
11
+ expanded?: boolean;
12
+ headingClassName?: string;
13
+ contentClassName?: string;
14
+ headingAs?: AccordionHeadingAs;
15
+ handleToggle?: React.MouseEventHandler<HTMLButtonElement>;
16
+ }
17
+
18
+ export default function AccordionItem({
19
+ title,
20
+ id,
21
+ content,
22
+ children,
23
+ expanded = false,
24
+ headingClassName,
25
+ contentClassName,
26
+ headingAs = 'h3',
27
+ handleToggle,
28
+ }: AccordionItemProps) {
29
+ const headingClasses = classnames('usa-accordion__heading', headingClassName);
30
+ const contentClasses = classnames('usa-accordion__content', 'usa-prose', contentClassName);
31
+ const Heading = headingAs;
32
+
33
+ return (
34
+ <>
35
+ <Heading id={`${id}-heading`} className={headingClasses}>
36
+ <button
37
+ type="button"
38
+ className="usa-accordion__button"
39
+ aria-expanded={expanded}
40
+ aria-controls={`${id}-content`}
41
+ onClick={handleToggle}>
42
+ {title}
43
+ </button>
44
+ </Heading>
45
+ <div
46
+ id={`${id}-content`}
47
+ aria-labelledby={`${id}-heading`}
48
+ className={contentClasses}
49
+ hidden={!expanded}>
50
+ {children ?? content}
51
+ </div>
52
+ </>
53
+ );
54
+ }
@@ -0,0 +1,19 @@
1
+ <{% if headingAs == 'h1' %}h1{% elif headingAs == 'h2' %}h2{% elif headingAs == 'h4' %}h4{% elif headingAs == 'h5' %}h5{% elif headingAs == 'h6' %}h6{% else %}h3{% endif %} id="{{ id }}-heading" class="usa-accordion__heading{% if headingClassName %} {{ headingClassName }}{% endif %}">
2
+ <button
3
+ class="usa-accordion__button"
4
+ aria-expanded="{% if expanded %}true{% else %}false{% endif %}"
5
+ aria-controls="{{ id }}-content"
6
+ type="button"
7
+ >
8
+ {% if title is not None and title is not True and title is not False %}{{ title }}{% endif %}
9
+ </button>
10
+ </{% if headingAs == 'h1' %}h1{% elif headingAs == 'h2' %}h2{% elif headingAs == 'h4' %}h4{% elif headingAs == 'h5' %}h5{% elif headingAs == 'h6' %}h6{% else %}h3{% endif %}>
11
+
12
+ <div
13
+ id="{{ id }}-content"
14
+ class="usa-accordion__content usa-prose{% if contentClassName %} {{ contentClassName }}{% endif %}"
15
+ aria-labelledby="{{ id }}-heading"
16
+ {% if not expanded %}hidden{% endif %}
17
+ >
18
+ {% if children is not None %}{% if children is not True and children is not False %}{{ children }}{% endif %}{% elif content is not None and content is not True and content is not False %}{{ content }}{% endif %}
19
+ </div>
@@ -0,0 +1,8 @@
1
+ <h3 id="accordion-item-example-heading" class="usa-accordion__heading">
2
+ <button type="button" class="usa-accordion__button" aria-expanded="false" aria-controls="accordion-item-example-content">
3
+ Accordion item
4
+ </button>
5
+ </h3>
6
+ <div id="accordion-item-example-content" class="usa-accordion__content usa-prose" aria-labelledby="accordion-item-example-heading" hidden>
7
+ Accordion item content.
8
+ </div>
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "accordion-item",
3
+ "template": "accordion-item/accordion-item.django.html",
4
+ "version": 1,
5
+ "required": ["id", "title"],
6
+ "default": {
7
+ "id": "accordion-item-example",
8
+ "title": "Accordion item",
9
+ "content": "Accordion item content."
10
+ },
11
+ "props": {
12
+ "id": {
13
+ "type": "string",
14
+ "description": "Unique base ID for the heading and content."
15
+ },
16
+ "title": {
17
+ "type": "slot",
18
+ "description": "Content of the accordion heading button."
19
+ },
20
+ "content": {
21
+ "type": "slot",
22
+ "description": "Content of the accordion panel. Ignored when children is provided."
23
+ },
24
+ "children": {
25
+ "type": "slot",
26
+ "description": "Content of the accordion panel. Takes precedence over content when provided."
27
+ },
28
+ "expanded": {
29
+ "type": "boolean",
30
+ "default": false,
31
+ "description": "Whether the panel starts expanded."
32
+ },
33
+ "headingAs": {
34
+ "type": "select",
35
+ "options": ["h1", "h2", "h3", "h4", "h5", "h6"],
36
+ "default": "h3",
37
+ "description": "Heading element wrapping the button. In Accordion, the parent controls this value."
38
+ },
39
+ "headingClassName": {
40
+ "type": "string",
41
+ "description": "Additional heading classes. In Accordion, the parent controls this value."
42
+ },
43
+ "contentClassName": {
44
+ "type": "string",
45
+ "description": "Additional panel classes. In Accordion, the parent controls this value."
46
+ },
47
+ "handleToggle": {
48
+ "type": "function",
49
+ "description": "React click handler for the heading button.",
50
+ "renderers": {
51
+ "django": { "supported": false, "description": "Callbacks cannot be rendered by Django." }
52
+ }
53
+ }
54
+ }
55
+ }
@@ -110,7 +110,7 @@
110
110
  <div class="usa-alert__body">
111
111
  <h4 class="usa-alert__heading">Informative region</h4>
112
112
 
113
- <p class="usa-alert__text">Info and warning alerts default to role="region".</p>
113
+ <p class="usa-alert__text">Info and warning alerts default to role=&quot;region&quot;.</p>
114
114
  </div>
115
115
  </div>
116
116
 
@@ -119,7 +119,7 @@
119
119
  <div class="usa-alert__body">
120
120
  <h4 class="usa-alert__heading">Success status</h4>
121
121
 
122
- <p class="usa-alert__text">Success alerts default to role="status".</p>
122
+ <p class="usa-alert__text">Success alerts default to role=&quot;status&quot;.</p>
123
123
  </div>
124
124
  </div>
125
125
 
@@ -128,7 +128,7 @@
128
128
  <div class="usa-alert__body">
129
129
  <h4 class="usa-alert__heading">Error alert</h4>
130
130
 
131
- <p class="usa-alert__text">Error and emergency alerts default to role="alert".</p>
131
+ <p class="usa-alert__text">Error and emergency alerts default to role=&quot;alert&quot;.</p>
132
132
  </div>
133
133
  </div>
134
134
 
@@ -160,7 +160,7 @@
160
160
  <button
161
161
  class="usx-alert__dismiss"
162
162
  aria-label="Dismiss alert"
163
- onclick="this.closest('.usa-alert').remove()"
163
+ onclick="this.closest(&#x27;.usa-alert&#x27;).remove();"
164
164
  >
165
165
  <svg
166
166
  class="usa-icon usx-icon usa-icon--size-3"
@@ -12,13 +12,20 @@ const shapeClassMap = {
12
12
  'rounded-xl': 'usx-rounded-xl',
13
13
  };
14
14
 
15
- export interface AvatarProps extends React.HTMLAttributes<HTMLAnchorElement> {
15
+ export interface AvatarProps extends Omit<
16
+ React.ImgHTMLAttributes<HTMLImageElement>,
17
+ 'src' | 'alt' | 'onClick'
18
+ > {
16
19
  href?: string;
17
20
  src?: string | null;
18
21
  alt?: string | null;
19
22
  variant?: 'image' | 'initials' | 'icon';
20
23
  value?: string | null;
21
24
  shape?: null | 'circle' | 'rounded-sm' | 'rounded-md' | 'rounded-lg' | 'rounded-xl';
25
+ /** Existing border utility color name used for the 4px status ring. */
26
+ statusRingColor?: string | null;
27
+ /** Host-supplied status text appended to the accessible name. */
28
+ statusLabel?: string | null;
22
29
  tooltipProps?: Omit<TooltipProps, 'children'> | null;
23
30
  className?: string;
24
31
  imageClassName?: string;
@@ -26,12 +33,14 @@ export interface AvatarProps extends React.HTMLAttributes<HTMLAnchorElement> {
26
33
  }
27
34
 
28
35
  export default function Avatar({
29
- href = '#',
36
+ href,
30
37
  src = null,
31
38
  alt = null,
32
39
  variant = 'image',
33
40
  value = null,
34
41
  shape = null,
42
+ statusRingColor = null,
43
+ statusLabel = null,
35
44
  tooltipProps = null,
36
45
  className = '',
37
46
  imageClassName = '',
@@ -40,36 +49,65 @@ export default function Avatar({
40
49
  }: AvatarProps) {
41
50
  const isInitialsVariant = variant === 'initials';
42
51
  const isIconVariant = variant === 'icon';
52
+ const ringColor = statusRingColor?.trim();
53
+ const label = statusLabel?.trim();
54
+ const accessibleLabel = label ? [alt, label].filter(Boolean).join(', ') : alt || undefined;
43
55
 
44
56
  const wrapperClasses = classNames(
45
57
  'usx-avatar',
46
- className,
58
+ ringColor && 'border-05',
59
+ ringColor && `border-${ringColor}`,
60
+ ringColor &&
61
+ (shape ? shapeClassMap[shape] : isInitialsVariant || isIconVariant ? 'usx-circle' : null),
62
+ className
47
63
  );
48
64
  const imgClasses = classNames(
49
65
  'usx-avatar__img',
50
66
  shape ? shapeClassMap[shape] : null,
51
- imageClassName,
67
+ imageClassName
52
68
  );
53
69
  const contentClasses = classNames(
54
70
  'usx-avatar__content',
55
71
  shape ? shapeClassMap[shape] : 'usx-circle',
56
- contentClassName,
72
+ contentClassName
57
73
  );
58
74
 
59
- const avatarContent = isInitialsVariant
60
- ? <span className={contentClasses}>{value}</span>
61
- : isIconVariant
62
- ? (
63
- <span className={contentClasses}>
64
- <Icon name={value as string} alt={alt ? undefined : `${value} icon`} />
65
- </span>
66
- )
67
- : <img className={imgClasses} src={src || undefined} alt={alt || undefined} role="img" {...props} />;
75
+ const avatarContent = isInitialsVariant ? (
76
+ <span className={contentClasses}>{value}</span>
77
+ ) : isIconVariant ? (
78
+ <span className={contentClasses}>
79
+ <Icon name={value as string} alt={alt ? undefined : `${value} icon`} />
80
+ </span>
81
+ ) : (
82
+ <img
83
+ className={imgClasses}
84
+ src={src || undefined}
85
+ alt={alt || undefined}
86
+ role="img"
87
+ {...props}
88
+ />
89
+ );
68
90
 
69
- const avatar = (
70
- <a href={href} className={wrapperClasses} aria-label={(isInitialsVariant || isIconVariant) ? alt || undefined : undefined}>
91
+ const avatar = href ? (
92
+ <a
93
+ href={href}
94
+ className={wrapperClasses}
95
+ aria-label={
96
+ label ? accessibleLabel : isInitialsVariant || isIconVariant ? alt || undefined : undefined
97
+ }
98
+ >
71
99
  {avatarContent}
72
100
  </a>
101
+ ) : (
102
+ <span
103
+ className={wrapperClasses}
104
+ role={label ? 'img' : undefined}
105
+ aria-label={
106
+ label ? accessibleLabel : isInitialsVariant || isIconVariant ? alt || undefined : undefined
107
+ }
108
+ >
109
+ {avatarContent}
110
+ </span>
73
111
  );
74
112
 
75
113
  return tooltipProps ? <Tooltip {...tooltipProps}>{avatar}</Tooltip> : avatar;
@@ -1,6 +1,10 @@
1
1
  <h3 class="site-preview-heading">Default</h3>
2
- <a href="https://google.com/search?q=Statue+of+Liberty" class="usx-avatar">
3
- <img class="usx-avatar__img" src="./lady_liberty.png" alt="Statue of Liberty" role="img" />
2
+ <a
3
+ href="https://google.com/search?q=Statue+of+Liberty"
4
+ class="usx-avatar"
5
+ aria-label="Statue of Liberty"
6
+ >
7
+ <span class="usx-avatar__content usx-circle bg-primary-lighter text-primary-darker">SL</span>
4
8
  </a>
5
9
 
6
10
  <h3 class="site-preview-heading">Circle Avatar</h3>
@@ -63,6 +67,11 @@
63
67
  <span class="usx-avatar__content usx-circle bg-primary-lighter text-primary-darker">AB</span>
64
68
  </a>
65
69
 
70
+ <h3 class="site-preview-heading">Non Interactive</h3>
71
+ <span class="usx-avatar" aria-label="Morgan">
72
+ <span class="usx-avatar__content usx-circle bg-primary-lighter text-primary-darker">MO</span>
73
+ </span>
74
+
66
75
  <h3 class="site-preview-heading">Initials Avatar Small</h3>
67
76
  <a href="#" class="usx-avatar usx-avatar--size-sm" aria-label="George Washington">
68
77
  <span class="usx-avatar__content usx-circle bg-primary-lighter text-primary-darker">GW</span>
@@ -129,3 +138,110 @@
129
138
  <use href="img/sprite.svg#person"></use></svg
130
139
  ></span>
131
140
  </a>
141
+
142
+ <h3 class="site-preview-heading">Status Success</h3>
143
+ <span class="usx-tooltip">
144
+ <a
145
+ href="https://google.com/search?q=Statue+of+Liberty"
146
+ class="usx-avatar border-05 border-success usx-circle"
147
+ aria-label="Statue of Liberty, Online"
148
+ >
149
+ <img
150
+ class="usx-avatar__img usx-circle"
151
+ src="./lady_liberty.png"
152
+ alt="Statue of Liberty"
153
+ role="img"
154
+ />
155
+ </a>
156
+
157
+ <span class="usa-tooltip__body usa-tooltip__body--right" role="tooltip">Online</span>
158
+ </span>
159
+
160
+ <h3 class="site-preview-heading">Status Caution</h3>
161
+ <span
162
+ class="usx-avatar border-05 border-warning usx-circle"
163
+ role="img"
164
+ aria-label="Alex Brown, Pending review"
165
+ >
166
+ <span class="usx-avatar__content usx-circle bg-primary-lighter text-primary-darker">AB</span>
167
+ </span>
168
+
169
+ <h3 class="site-preview-heading">Status Danger</h3>
170
+ <span
171
+ class="usx-avatar border-05 border-error usx-circle"
172
+ role="img"
173
+ aria-label="Account owner, Do not disturb"
174
+ >
175
+ <span class="usx-avatar__content usx-circle bg-primary-lighter text-base-darkest">
176
+ <svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img">
177
+ <use href="img/sprite.svg#person"></use></svg
178
+ ></span>
179
+ </span>
180
+
181
+ <h3 class="site-preview-heading">Status Neutral</h3>
182
+ <a
183
+ href="https://google.com/search?q=Statue+of+Liberty"
184
+ class="usx-avatar border-05 border-base usx-rounded-md"
185
+ aria-label="Statue of Liberty, Offline"
186
+ >
187
+ <img
188
+ class="usx-avatar__img usx-rounded-md"
189
+ src="./lady_liberty.png"
190
+ alt="Statue of Liberty"
191
+ role="img"
192
+ />
193
+ </a>
194
+
195
+ <h3 class="site-preview-heading">Status Info</h3>
196
+ <a
197
+ href="https://google.com/search?q=Statue+of+Liberty"
198
+ class="usx-avatar border-05 border-info usx-circle"
199
+ aria-label="Statue of Liberty, Verified"
200
+ >
201
+ <img
202
+ class="usx-avatar__img usx-circle"
203
+ src="./lady_liberty.png"
204
+ alt="Statue of Liberty"
205
+ role="img"
206
+ />
207
+ </a>
208
+
209
+ <h3 class="site-preview-heading">Status Special</h3>
210
+ <span
211
+ class="usx-avatar border-05 border-accent-cool usx-circle"
212
+ role="img"
213
+ aria-label="Site administrator, Elevated privileges"
214
+ >
215
+ <span class="usx-avatar__content usx-circle bg-primary-lighter text-base-darkest">
216
+ <svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img">
217
+ <use href="img/sprite.svg#person"></use></svg
218
+ ></span>
219
+ </span>
220
+
221
+ <h3 class="site-preview-heading">Status Warning</h3>
222
+ <span
223
+ class="usx-avatar border-05 border-accent-warm usx-circle usx-avatar--size-sm"
224
+ role="img"
225
+ aria-label="Alex Brown, Requires action"
226
+ >
227
+ <span class="usx-avatar__content usx-circle bg-primary-lighter text-primary-darker">AB</span>
228
+ </span>
229
+
230
+ <h3 class="site-preview-heading">Status Secondary Color</h3>
231
+ <a
232
+ href="https://google.com/search?q=Statue+of+Liberty"
233
+ class="usx-avatar border-05 border-secondary usx-circle"
234
+ aria-label="Statue of Liberty, Premium member"
235
+ >
236
+ <img
237
+ class="usx-avatar__img usx-circle"
238
+ src="./lady_liberty.png"
239
+ alt="Statue of Liberty"
240
+ role="img"
241
+ />
242
+ </a>
243
+
244
+ <h3 class="site-preview-heading">Status Label Only</h3>
245
+ <span class="usx-avatar" role="img" aria-label="Alex Brown, Available by appointment">
246
+ <span class="usx-avatar__content usx-circle bg-primary-lighter text-primary-darker">AB</span>
247
+ </span>
@@ -3,7 +3,7 @@
3
3
  {% load usx_components %}
4
4
 
5
5
  {% fragment as avatarLink %}
6
- <a href="{% if href is None %}#{% else %}{{ href }}{% endif %}" class="usx-avatar{% if className %} {{ className }}{% endif %}"{% if variant == 'initials' or variant == 'icon' %}{% if alt %} aria-label="{{ alt }}"{% endif %}{% endif %}>
6
+ <{% if href %}a href="{{ href }}"{% else %}span{% endif %} class="usx-avatar{% if statusRingColor %} border-05 border-{{ statusRingColor }}{% if shape == 'circle' %} usx-circle{% elif shape == 'rounded-sm' %} usx-rounded-sm{% elif shape == 'rounded-md' %} usx-rounded-md{% elif shape == 'rounded-lg' %} usx-rounded-lg{% elif shape == 'rounded-xl' %} usx-rounded-xl{% elif variant == 'initials' or variant == 'icon' %} usx-circle{% endif %}{% endif %}{% if className %} {{ className }}{% endif %}"{% if not href and statusLabel %} role="img"{% endif %}{% if statusLabel %} aria-label="{% if alt %}{{ alt }}, {% endif %}{{ statusLabel }}"{% elif variant == 'initials' or variant == 'icon' %}{% if alt %} aria-label="{{ alt }}"{% endif %}{% endif %}>
7
7
  {% if variant == 'initials' %}
8
8
  <span class="usx-avatar__content{% if shape == 'circle' %} usx-circle{% elif shape == 'rounded-sm' %} usx-rounded-sm{% elif shape == 'rounded-md' %} usx-rounded-md{% elif shape == 'rounded-lg' %} usx-rounded-lg{% elif shape == 'rounded-xl' %} usx-rounded-xl{% else %} usx-circle{% endif %}{% if contentClassName %} {{ contentClassName }}{% endif %}">{{ value }}</span>
9
9
  {% elif variant == 'icon' %}
@@ -16,7 +16,7 @@
16
16
  role="img"
17
17
  />
18
18
  {% endif %}
19
- </a>
19
+ {% if href %}</a>{% else %}</span>{% endif %}
20
20
  {% endfragment %}
21
21
 
22
22
  {% if tooltipProps %}