@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
@@ -10,26 +10,74 @@
10
10
  { "key": "year", "header": "Year" }
11
11
  ],
12
12
  "data": [
13
- { "title": "Declaration of Independence", "description": "Statement adopted by the Continental Congress.", "year": 1776 },
14
- { "title": "Bill of Rights", "description": "The first ten amendments to the Constitution.", "year": 1791 },
15
- { "title": "Emancipation Proclamation", "description": "An executive order ending slavery in designated states.", "year": 1863 }
13
+ {
14
+ "title": "Declaration of Independence",
15
+ "description": "Statement adopted by the Continental Congress.",
16
+ "year": 1776
17
+ },
18
+ {
19
+ "title": "Bill of Rights",
20
+ "description": "The first ten amendments to the Constitution.",
21
+ "year": 1791
22
+ },
23
+ {
24
+ "title": "Emancipation Proclamation",
25
+ "description": "An executive order ending slavery in designated states.",
26
+ "year": 1863
27
+ }
16
28
  ],
17
29
  "caption": "Historic U.S. documents"
18
30
  },
19
31
  "props": {
20
- "extraAttributes": { "type": "object", "description": "Additional attributes on the USWDS enhancement target." },
32
+ "extraAttributes": {
33
+ "type": "object",
34
+ "description": "Additional attributes on the USWDS enhancement target."
35
+ },
21
36
  "id": { "type": "string", "description": "Optional table ID." },
22
- "columns": { "type": "array", "description": "Column definitions: key, header, primary (row header), sortable (USWDS sorting)." },
23
- "data": { "type": "array", "description": "Array of records displayed in the same order provided." },
24
- "caption": { "type": "slot", "description": "Accessible table title. Required for sortable tables." },
37
+ "columns": {
38
+ "type": "array",
39
+ "description": "Column definitions: key, header, primary (row header), sortable (USWDS sorting)."
40
+ },
41
+ "data": {
42
+ "type": "array",
43
+ "description": "Array of records displayed in the same order provided."
44
+ },
45
+ "caption": {
46
+ "type": "slot",
47
+ "description": "Accessible table title. Required for sortable tables."
48
+ },
25
49
  "striped": { "type": "boolean", "default": false, "description": "Alternating row shading." },
26
- "borderless": { "type": "boolean", "default": false, "description": "Remove outer cell borders." },
50
+ "borderless": {
51
+ "type": "boolean",
52
+ "default": false,
53
+ "description": "Remove outer cell borders."
54
+ },
27
55
  "compact": { "type": "boolean", "default": false, "description": "Reduce cell padding." },
28
- "scrollable": { "type": "boolean", "default": false, "description": "Wrap the table in a horizontal scroll container." },
29
- "scrollHeight": { "type": "string", "description": "Fixed height for the scroll container when scrollable is true; useful with stickyHeader." },
30
- "stickyHeader": { "type": "boolean", "default": false, "description": "Keep headings visible during scrolling." },
31
- "responsive": { "type": "select", "options": [false, "stack", "stack-header"], "default": false, "description": "USWDS mobile stacking variant." },
56
+ "scrollable": {
57
+ "type": "boolean",
58
+ "default": false,
59
+ "description": "Wrap the table in a horizontal scroll container."
60
+ },
61
+ "scrollHeight": {
62
+ "type": "string",
63
+ "description": "Fixed height for the scroll container when scrollable is true; useful with stickyHeader."
64
+ },
65
+ "stickyHeader": {
66
+ "type": "boolean",
67
+ "default": false,
68
+ "description": "Keep headings visible during scrolling."
69
+ },
70
+ "responsive": {
71
+ "type": "select",
72
+ "options": [false, "stack", "stack-header"],
73
+ "default": false,
74
+ "description": "USWDS mobile stacking variant."
75
+ },
32
76
  "className": { "type": "string", "description": "Additional table classes." },
33
- "children": { "type": "slot", "description": "Optional hand-authored table markup for React.", "renderers": { "django": { "supported": false } } }
77
+ "children": {
78
+ "type": "slot",
79
+ "description": "Optional hand-authored table markup for React.",
80
+ "renderers": { "django": { "supported": false } }
81
+ }
34
82
  }
35
83
  }
@@ -12,9 +12,13 @@ export type TagProps = {
12
12
  dismissible?: boolean;
13
13
  isDismissed?: boolean;
14
14
  onDismiss?: (e: React.MouseEvent<HTMLButtonElement>) => void;
15
+ href?: string;
16
+ target?: string;
17
+ rel?: string;
18
+ extraAttributes?: Record<string, unknown>;
15
19
  className?: string;
16
20
  children?: React.ReactNode;
17
- } & React.HTMLAttributes<HTMLSpanElement>;
21
+ } & Omit<React.HTMLAttributes<HTMLElement>, 'onClick' | 'children'>;
18
22
 
19
23
  const Tag: React.FC<TagProps> = ({
20
24
  id,
@@ -28,17 +32,24 @@ const Tag: React.FC<TagProps> = ({
28
32
  onDismiss = () => {},
29
33
  className = '',
30
34
  children,
35
+ href,
36
+ target,
37
+ rel,
38
+ extraAttributes = {},
31
39
  ...props
32
40
  }) => {
33
41
  const [isVisible, setIsVisible] = useState(!isDismissed);
34
42
 
43
+ const interactive = Boolean(href);
44
+
35
45
  const classes = ClassNames(
36
46
  'usa-tag',
37
47
  'usx-tag',
38
48
  { 'usa-tag--big': big },
39
- { [`bg-${color}`]: color && !outline },
40
- { [`text-${color}`]: color && outline },
41
- { 'usx-tag--outline': outline },
49
+ { [`bg-${color}`]: color && !outline && !interactive },
50
+ { [`text-${color}`]: color && outline && !interactive },
51
+ { 'usx-tag--outline': outline || interactive },
52
+ { 'usa-link usx-link usx-no-visited usx-tag--interactive': interactive },
42
53
  className
43
54
  );
44
55
 
@@ -55,10 +66,10 @@ const Tag: React.FC<TagProps> = ({
55
66
  return null;
56
67
  }
57
68
 
58
- return (
59
- <span id={id} className={classes} {...props}>
69
+ const content = (
70
+ <>
60
71
  {icon && <Icon name={icon} size={big ? 3 : 2} />} {children || value}
61
- {dismissible && (
72
+ {dismissible && !interactive && (
62
73
  <button
63
74
  type="button"
64
75
  className="usx-tag__dismiss"
@@ -68,6 +79,28 @@ const Tag: React.FC<TagProps> = ({
68
79
  <Icon name="close" size={2} />
69
80
  </button>
70
81
  )}
82
+ </>
83
+ );
84
+
85
+ if (href) {
86
+ return (
87
+ <a
88
+ id={id}
89
+ href={href}
90
+ target={target}
91
+ rel={rel}
92
+ className={classes}
93
+ {...props}
94
+ {...extraAttributes}
95
+ >
96
+ {content}
97
+ </a>
98
+ );
99
+ }
100
+
101
+ return (
102
+ <span id={id} className={classes} {...props} {...extraAttributes}>
103
+ {content}
71
104
  </span>
72
105
  );
73
106
  };
@@ -23,12 +23,12 @@
23
23
  "color": {
24
24
  "type": "string",
25
25
  "default": null,
26
- "description": "Color variant for the tag (e.g., null, 'primary', 'accent-cool', 'blue', 'base', etc.)"
26
+ "description": "Color variant for a noninteractive tag. Linked tags use theme link color."
27
27
  },
28
28
  "outline": {
29
29
  "type": "boolean",
30
30
  "default": false,
31
- "description": "Whether to use the outline style (transparent background with border)"
31
+ "description": "Use a transparent background with border. Linked tags always use the outline style."
32
32
  },
33
33
  "icon": {
34
34
  "type": "string",
@@ -45,6 +45,22 @@
45
45
  "default": null,
46
46
  "description": "Optional inline JavaScript to run when the dismiss button is clicked. If omitted, the tag removes itself from the DOM."
47
47
  },
48
+ "href": {
49
+ "type": "string",
50
+ "description": "Optional destination. When supplied, Tag renders a link; otherwise it renders a span."
51
+ },
52
+ "target": {
53
+ "type": "string",
54
+ "description": "Anchor target when href is set."
55
+ },
56
+ "rel": {
57
+ "type": "string",
58
+ "description": "Anchor relationship when href is set."
59
+ },
60
+ "extraAttributes": {
61
+ "type": "object",
62
+ "description": "Additional HTML attributes, including data attributes, applied to the rendered tag element."
63
+ },
48
64
  "className": {
49
65
  "type": "string",
50
66
  "description": "Additional classes to add to the tag"
@@ -34,7 +34,7 @@
34
34
  </button>
35
35
  </span>
36
36
 
37
- <h3 class="site-preview-heading">Dismissible With Callback</h3>
37
+ <h3 class="site-preview-heading">Dismissible with callback</h3>
38
38
  <span class="usa-tag usx-tag">
39
39
  Dismissible
40
40
 
@@ -50,6 +50,21 @@
50
50
  </button>
51
51
  </span>
52
52
 
53
+ <h3 class="site-preview-heading">Clickable link</h3>
54
+ <a
55
+ href="#related-topics"
56
+ class="usa-tag usx-tag usa-link usx-link usx-no-visited usx-tag--interactive usx-tag--outline"
57
+ >
58
+ Browse related topics
59
+ </a>
60
+
61
+ <h3 class="site-preview-heading">Link styled as a tag</h3>
62
+ <a
63
+ href="#related-topics"
64
+ class="usa-link usx-link usa-tag usx-tag usx-tag--outline usx-tag--interactive usx-no-visited"
65
+ >Browse related topics</a
66
+ >
67
+
53
68
  <h3 class="site-preview-heading">Primary color</h3>
54
69
  <span class="usa-tag usx-tag bg-primary"> Primary </span>
55
70
 
@@ -1,15 +1,21 @@
1
1
  {# Django template for Tag #}
2
2
  {% load usx_components %}
3
3
 
4
- <span
4
+ <{% if href %}a{% else %}span{% endif %}
5
5
  {% if id %}id="{{ id }}"{% endif %}
6
+ {% if href %}href="{{ href }}"{% if target %} target="{{ target }}"{% endif %}{% if rel %} rel="{{ rel }}"{% endif %}{% endif %}
7
+ {% if extraAttributes %}{% for attr, attrValue in extraAttributes.items %} {{ attr }}="{% if attrValue is True %}true{% elif attrValue is False %}false{% else %}{{ attrValue }}{% endif %}"{% endfor %}{% endif %}
6
8
  class=
7
9
  "
8
10
  usa-tag usx-tag
9
11
  {% if big %}usa-tag--big{% endif %}
10
- {% if color and not outline %}bg-{{ color }}{% endif %}
11
- {% if color and outline %}text-{{ color }}{% endif %}
12
- {% if outline %}usx-tag--outline{% endif %}
12
+ {% if href %}
13
+ usa-link usx-link usx-no-visited usx-tag--interactive usx-tag--outline
14
+ {% else %}
15
+ {% if color and not outline %}bg-{{ color }}{% endif %}
16
+ {% if color and outline %}text-{{ color }}{% endif %}
17
+ {% if outline %}usx-tag--outline{% endif %}
18
+ {% endif %}
13
19
  {{ className }}
14
20
  "
15
21
  >
@@ -22,7 +28,7 @@
22
28
  {% if icon %}{% icon name=icon size=iconSize %}{% endicon %}{% endif %}{% if children %}{{ children }}{% else %}{{ value }}{% endif %}
23
29
  {% endwith %}
24
30
  {% endif %}
25
- {% if dismissible %}
31
+ {% if dismissible and not href %}
26
32
  <button
27
33
  type="button"
28
34
  class="usx-tag__dismiss"
@@ -36,4 +42,4 @@
36
42
  {% icon name="close" size="2" %}{% endicon %}
37
43
  </button>
38
44
  {% endif %}
39
- </span>
45
+ </{% if href %}a{% else %}span{% endif %}>
@@ -18,6 +18,10 @@
18
18
  <span class="usa-tag usx-tag usx-tag--outline text-blue">Blue</span>
19
19
  <span class="usa-tag usx-tag usx-tag--outline text-base">Base</span>
20
20
 
21
+ <h3 class="site-preview-heading">Clickable tags</h3>
22
+ <a class="usa-link usx-link usx-no-visited usa-tag usx-tag usx-tag--outline usx-tag--interactive" href="#related-topics">Browse related topics</a>
23
+ <button class="usa-link usx-link usx-no-visited usa-tag usx-tag usx-tag--outline usx-tag--interactive" type="button">Show related topics</button>
24
+
21
25
  <h3 class="site-preview-heading">Status tags</h3>
22
26
  <span class="usa-tag usx-tag bg-info">
23
27
  <svg class="usa-icon usa-icon--size-3" aria-hidden="true" focusable="false" role="img">
@@ -28,7 +28,7 @@
28
28
  </svg></button
29
29
  ></span>
30
30
 
31
- <h3 class="site-preview-heading">Dismissible With Callback</h3>
31
+ <h3 class="site-preview-heading">Dismissible with callback</h3>
32
32
  <span class="usa-tag usx-tag">
33
33
  Dismissible<button type="button" class="usx-tag__dismiss" aria-label="Dismiss tag">
34
34
  <svg class="usa-icon usx-icon usa-icon--size-2" aria-hidden="true" focusable="false" role="img">
@@ -36,6 +36,21 @@
36
36
  </svg></button
37
37
  ></span>
38
38
 
39
+ <h3 class="site-preview-heading">Clickable link</h3>
40
+ <a
41
+ href="#related-topics"
42
+ class="usa-tag usx-tag usx-tag--outline usa-link usx-link usx-no-visited usx-tag--interactive"
43
+ >
44
+ Browse related topics</a
45
+ >
46
+
47
+ <h3 class="site-preview-heading">Link styled as a tag</h3>
48
+ <a
49
+ href="#related-topics"
50
+ class="usa-link usx-link usa-tag usx-tag usx-tag--outline usx-tag--interactive usx-no-visited"
51
+ >Browse related topics</a
52
+ >
53
+
39
54
  <h3 class="site-preview-heading">Primary color</h3>
40
55
  <span class="usa-tag usx-tag bg-primary"> Primary</span>
41
56
 
@@ -6,27 +6,24 @@ export interface TagGroupProps extends React.HTMLAttributes<HTMLDivElement> {
6
6
  tagProps?: TagProps[] | null;
7
7
  children?: React.ReactNode;
8
8
  className?: string;
9
+ extraAttributes?: Record<string, unknown>;
9
10
  }
10
11
 
11
12
  const TagGroup: React.FC<TagGroupProps> = ({
12
13
  tagProps = null,
13
14
  children = null,
14
15
  className = '',
16
+ extraAttributes = {},
15
17
  ...props
16
18
  }) => {
17
- const classes = classNames(
18
- 'usx-tag-group',
19
- className
20
- );
19
+ const classes = classNames('usx-tag-group', className);
21
20
  const content = children
22
21
  ? children
23
22
  : Array.isArray(tagProps)
24
- ? tagProps.map((t, i) => (
25
- <Tag key={t.id || t.value || i} {...t} />
26
- ))
27
- : null;
23
+ ? tagProps.map((t, i) => <Tag key={t.id || t.value || i} {...t} />)
24
+ : null;
28
25
  return (
29
- <div className={classes} {...props}>
26
+ <div {...props} {...extraAttributes} className={classes}>
30
27
  {content}
31
28
  </div>
32
29
  );
@@ -43,6 +43,10 @@
43
43
  "className": {
44
44
  "type": "string",
45
45
  "description": "Additional classes"
46
+ },
47
+ "extraAttributes": {
48
+ "type": "object",
49
+ "description": "Additional HTML attributes on the group container, such as role and aria-label."
46
50
  }
47
51
  }
48
52
  }
@@ -1,6 +1,6 @@
1
1
  {% load usx_components %}
2
2
 
3
- <div class="usx-tag-group{% if className %} {{ className }}{% endif %}">
3
+ <div class="usx-tag-group{% if className %} {{ className }}{% endif %}"{% for attr, value in extraAttributes.items %} {{ attr }}="{% if value is True %}true{% elif value is False %}false{% else %}{{ value }}{% endif %}"{% endfor %}>
4
4
  {% if children %}
5
5
  {{ children|safe }}
6
6
  {% elif tagProps %}
@@ -2,14 +2,16 @@ import React from 'react';
2
2
  import ClassNames from 'classnames';
3
3
  import Icon from '../icon/Icon';
4
4
  import Label from '../label/Label';
5
+ import Popover, { type PopoverAlign } from '../popover/Popover';
5
6
  import Swap from '../swap/Swap';
6
7
 
7
8
  export interface ThemePickerOption {
9
+ /** Value written to <html data-usx-theme>. */
8
10
  value: string;
9
11
  label: string;
10
12
  }
11
13
 
12
- export type ThemePickerVariant = 'default' | 'swap' | 'ghost-select';
14
+ export type ThemePickerVariant = 'default' | 'swap' | 'popover';
13
15
 
14
16
  export interface ThemePickerProps {
15
17
  id?: string;
@@ -18,9 +20,10 @@ export interface ThemePickerProps {
18
20
  themes?: ThemePickerOption[];
19
21
  /** Swap uses the first option for light and the second for dark. */
20
22
  variant?: ThemePickerVariant;
23
+ /** Alignment of the panel when variant is popover. */
24
+ popoverAlign?: PopoverAlign;
21
25
  value?: string;
22
26
  defaultValue?: string;
23
- onChange?: (value: string) => void;
24
27
  className?: string;
25
28
  extraAttributes?: Record<string, unknown>;
26
29
  }
@@ -31,34 +34,24 @@ export default function ThemePicker({
31
34
  label = 'Theme',
32
35
  themes = [],
33
36
  variant = 'default',
37
+ popoverAlign = 'start',
34
38
  value,
35
39
  defaultValue,
36
- onChange,
37
40
  className = '',
38
41
  extraAttributes,
39
42
  }: ThemePickerProps) {
40
- const selectId = id || 'theme-picker';
41
- const [localValue, setLocalValue] = React.useState(defaultValue ?? themes[0]?.value ?? '');
42
- const selectedValue = value ?? localValue;
43
- const selectedLabel = themes.find((option) => option.value === selectedValue)?.label ?? label;
44
- const choose = (next: string) => {
45
- if (value === undefined) setLocalValue(next);
46
- onChange?.(next);
47
- };
48
- const select = (hidden = false) => (
43
+ const fieldId = id || 'theme-picker';
44
+ const selectedValue = value ?? defaultValue ?? themes[0]?.value ?? '';
45
+ const select = () => (
49
46
  <>
50
- <Label htmlFor={selectId} screenReaderOnly>
47
+ <Label htmlFor={fieldId} screenReaderOnly>
51
48
  {label}
52
49
  </Label>
53
50
  <select
54
- id={selectId}
51
+ id={fieldId}
55
52
  name={name}
56
- className={ClassNames(
57
- 'usa-select usx-select',
58
- hidden && 'usx-theme-picker__select--hidden'
59
- )}
60
- value={selectedValue}
61
- onChange={(event) => choose(event.target.value)}
53
+ className="usa-select usx-select"
54
+ defaultValue={selectedValue}
62
55
  >
63
56
  {themes.map((option) => (
64
57
  <option key={option.value} value={option.value}>
@@ -77,6 +70,7 @@ export default function ThemePicker({
77
70
  className
78
71
  )}
79
72
  {...extraAttributes}
73
+ hidden
80
74
  >
81
75
  {variant === 'default' && (
82
76
  <>
@@ -85,11 +79,11 @@ export default function ThemePicker({
85
79
  className="usa-button usx-button usx-button--ghost usx-theme-picker__trigger"
86
80
  aria-label={label}
87
81
  aria-expanded="false"
88
- aria-controls={`${selectId}-panel`}
82
+ aria-controls={`${fieldId}-panel`}
89
83
  >
90
84
  <Icon name="color_palette" source="usx" className="usx-theme-picker__icon" />
91
85
  </button>
92
- <div id={`${selectId}-panel`} className="usx-theme-picker__panel">
86
+ <div id={`${fieldId}-panel`} className="usx-theme-picker__panel">
93
87
  {select()}
94
88
  <button
95
89
  type="button"
@@ -104,32 +98,44 @@ export default function ThemePicker({
104
98
  {variant === 'swap' && (
105
99
  <>
106
100
  <Swap
107
- className="usx-theme-picker__swap usa-button usx-button usx-button--ghost"
101
+ as="button"
102
+ className="usx-theme-picker__swap usx-button--ghost usx-button--tight"
108
103
  variant="rotate"
109
- inputProps={{
110
- checked: selectedValue === themes[1]?.value,
111
- 'aria-label': `${label}: ${selectedLabel}. Switch to ${selectedValue === themes[1]?.value ? themes[0]?.label : themes[1]?.label}`,
112
- onChange: (event) => {
113
- event.stopPropagation();
114
- choose(themes[event.target.checked ? 1 : 0]?.value ?? '');
115
- },
116
- }}
104
+ defaultPressed={selectedValue === themes[1]?.value}
105
+ ariaLabel={`${themes[1]?.label ?? ''} ${label}`.trim()}
106
+ data-usx-theme-off={themes[0]?.value}
107
+ data-usx-theme-on={themes[1]?.value}
117
108
  offContent={<Icon name="sun" source="usx" className="usx-theme-picker__icon" />}
118
109
  onContent={<Icon name="moon" source="usx" className="usx-theme-picker__icon" />}
119
110
  />
120
- <div className="usx-theme-picker__fallback">{select()}</div>
111
+ <input id={fieldId} type="hidden" name={name} defaultValue={selectedValue} />
121
112
  </>
122
113
  )}
123
- {variant === 'ghost-select' && (
124
- <div className="usx-theme-picker__ghost">
125
- <span
126
- className="usa-button usx-button usx-button--ghost usx-theme-picker__ghost-face"
127
- aria-hidden="true"
128
- >
129
- <Icon name="color_palette" source="usx" className="usx-theme-picker__icon" />
130
- </span>
131
- {select(true)}
132
- </div>
114
+ {variant === 'popover' && (
115
+ <>
116
+ <Popover
117
+ id={`${fieldId}-panel`}
118
+ className="usx-theme-picker__popover"
119
+ align={popoverAlign}
120
+ panelShape="square"
121
+ summaryProps={{
122
+ className: 'usa-button usx-button usx-button--ghost usx-button--tight margin-0',
123
+ ariaLabel: label,
124
+ children: (
125
+ <Icon name="color_palette" source="usx" className="usx-theme-picker__icon" />
126
+ ),
127
+ }}
128
+ menuItems={themes.map((theme) => ({
129
+ type: 'button',
130
+ text: theme.label,
131
+ extraAttributes: {
132
+ 'data-usx-theme-value': theme.value,
133
+ 'aria-pressed': theme.value === selectedValue,
134
+ },
135
+ }))}
136
+ />
137
+ <input id={fieldId} type="hidden" name={name} defaultValue={selectedValue} />
138
+ </>
133
139
  )}
134
140
  </div>
135
141
  );