@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
@@ -20,7 +20,7 @@
20
20
  id="{{ id }}"
21
21
  class="usa-input usx-input"
22
22
  placeholder="{{ placeholder }}"
23
- value="{% if value is not None %}{{ value }}{% else %}{{ defaultValue }}{% endif %}"
23
+ {% if value != None %}value="{{ value }}"{% elif defaultValue != None %}value="{{ defaultValue }}"{% endif %}
24
24
  type="search"
25
25
  name="{{ searchKey|default:'q' }}"
26
26
  />
@@ -37,24 +37,5 @@
37
37
  {% endwith %}
38
38
  {% endwith %}
39
39
  </form>
40
- <script data-id="{{ id }}" data-on-submit="{{ onSubmit }}" data-search-key="{{ searchKey|default:'q' }}">
41
- const data = document.currentScript.dataset;
42
- const onSubmit = data.onSubmit;
43
40
 
44
- if (!!onSubmit) {
45
- const id = data.id;
46
- const searchKey = data.searchKey;
47
- document.addEventListener("DOMContentLoaded", function() {
48
- document.getElementById(`${id}-form`).onsubmit = function(e) {
49
- e.preventDefault();
50
- const formData = new FormData(e.target);
51
- const query = formData.get(searchKey);
52
- const func = eval(onSubmit);
53
- func(query);
54
- return false;
55
- };
56
- });
57
- }
58
-
59
- </script>
60
41
  </section>
@@ -35,7 +35,7 @@
35
35
  >
36
36
  <option value="">Select an option</option>
37
37
 
38
- <option value="option1">Option A</option>
38
+ <option value="option1">Option A&amp;nbsp;</option>
39
39
 
40
40
  <option value="option2">Option B</option>
41
41
 
@@ -50,7 +50,7 @@
50
50
  <select class="usa-select usx-select usa-input--success" id="django-select-success">
51
51
  <option value="">Select an option</option>
52
52
 
53
- <option value="option1">Option A</option>
53
+ <option value="option1">Option A&amp;nbsp;</option>
54
54
 
55
55
  <option value="option2">Option B</option>
56
56
 
@@ -67,7 +67,7 @@
67
67
  <select class="usa-select usx-select" id="django-select-disabled" disabled>
68
68
  <option value="">Select an option</option>
69
69
 
70
- <option value="option1">Option A</option>
70
+ <option value="option1">Option A&amp;nbsp;</option>
71
71
 
72
72
  <option value="option2">Option B</option>
73
73
 
@@ -97,7 +97,7 @@
97
97
  >
98
98
  <option value="">Select an option</option>
99
99
 
100
- <option value="option1">Option A</option>
100
+ <option value="option1">Option A&amp;nbsp;</option>
101
101
 
102
102
  <option value="option2">Option B</option>
103
103
 
@@ -114,7 +114,7 @@
114
114
  <select class="usa-select usx-select" id="django-select-default-value">
115
115
  <option value="">Select an option</option>
116
116
 
117
- <option value="option1">Option A</option>
117
+ <option value="option1">Option A&amp;nbsp;</option>
118
118
 
119
119
  <option value="option2" selected>Option B</option>
120
120
 
@@ -137,7 +137,7 @@
137
137
  >
138
138
  <option value="">Select an option</option>
139
139
 
140
- <option value="option1">Option A</option>
140
+ <option value="option1">Option A&amp;nbsp;</option>
141
141
 
142
142
  <option value="option2">Option B</option>
143
143
 
@@ -152,7 +152,7 @@
152
152
  <select class="usa-select usx-select" id="django-select-value">
153
153
  <option value="">Select an option</option>
154
154
 
155
- <option value="option1">Option A</option>
155
+ <option value="option1">Option A&amp;nbsp;</option>
156
156
 
157
157
  <option value="option2">Option B</option>
158
158
 
@@ -23,7 +23,7 @@
23
23
  aria-invalid="true"
24
24
  >
25
25
  <option value="">Select an option</option>
26
- <option value="option1">Option A</option>
26
+ <option value="option1">Option A&amp;nbsp;</option>
27
27
  <option value="option2">Option B</option>
28
28
  <option value="option3">Option C</option>
29
29
  </select>
@@ -34,7 +34,7 @@
34
34
  <label class="usa-label usx-label" for="react-select-success">Success state select</label
35
35
  ><select id="react-select-success" class="usa-select usx-select usa-input--success">
36
36
  <option value="">Select an option</option>
37
- <option value="option1">Option A</option>
37
+ <option value="option1">Option A&amp;nbsp;</option>
38
38
  <option value="option2">Option B</option>
39
39
  <option value="option3">Option C</option></select
40
40
  ><span class="usa-success-message">Success message goes here.</span>
@@ -45,7 +45,7 @@
45
45
  <label class="usa-label usx-label" for="react-select-disabled">Disabled select</label
46
46
  ><select id="react-select-disabled" class="usa-select usx-select" disabled="">
47
47
  <option value="">Select an option</option>
48
- <option value="option1">Option A</option>
48
+ <option value="option1">Option A&amp;nbsp;</option>
49
49
  <option value="option2">Option B</option>
50
50
  <option value="option3">Option C</option>
51
51
  </select>
@@ -68,7 +68,7 @@
68
68
  aria-invalid="true"
69
69
  >
70
70
  <option value="">Select an option</option>
71
- <option value="option1">Option A</option>
71
+ <option value="option1">Option A&amp;nbsp;</option>
72
72
  <option value="option2">Option B</option>
73
73
  <option value="option3">Option C</option>
74
74
  </select>
@@ -80,7 +80,7 @@
80
80
  >Select with default value</label
81
81
  ><select id="react-select-default-value" class="usa-select usx-select">
82
82
  <option value="">Select an option</option>
83
- <option value="option1">Option A</option>
83
+ <option value="option1">Option A&amp;nbsp;</option>
84
84
  <option value="option2" selected="">Option B</option>
85
85
  <option value="option3">Option C</option>
86
86
  </select>
@@ -97,7 +97,7 @@
97
97
  aria-describedby="react-select-with-hint-hint"
98
98
  >
99
99
  <option value="">Select an option</option>
100
- <option value="option1">Option A</option>
100
+ <option value="option1">Option A&amp;nbsp;</option>
101
101
  <option value="option2">Option B</option>
102
102
  <option value="option3">Option C</option>
103
103
  </select>
@@ -108,7 +108,7 @@
108
108
  <label class="usa-label usx-label" for="react-select-value">Current selection</label
109
109
  ><select id="react-select-value" class="usa-select usx-select">
110
110
  <option value="">Select an option</option>
111
- <option value="option1">Option A</option>
111
+ <option value="option1">Option A&amp;nbsp;</option>
112
112
  <option value="option2">Option B</option>
113
113
  <option value="option3" selected="">Option C</option>
114
114
  </select>
@@ -5,6 +5,7 @@ export interface SummaryProps {
5
5
  label?: React.ReactNode;
6
6
  children?: React.ReactNode;
7
7
  ariaLabel?: string;
8
+ title?: string;
8
9
  className?: string;
9
10
  textClassName?: string;
10
11
  markerColor?: string;
@@ -18,6 +19,7 @@ export default function Summary({
18
19
  label = 'Details',
19
20
  children,
20
21
  ariaLabel,
22
+ title,
21
23
  className = '',
22
24
  textClassName = '',
23
25
  markerColor = undefined,
@@ -28,7 +30,7 @@ export default function Summary({
28
30
  }: SummaryProps) {
29
31
  if (unstyled) {
30
32
  return (
31
- <summary className={className || undefined} aria-label={ariaLabel}>
33
+ <summary className={className || undefined} aria-label={ariaLabel} title={title}>
32
34
  {children ?? label}
33
35
  </summary>
34
36
  );
@@ -47,7 +49,7 @@ export default function Summary({
47
49
  textClassName
48
50
  );
49
51
  return (
50
- <summary className={summaryClassNames} aria-label={ariaLabel}>
52
+ <summary className={summaryClassNames} aria-label={ariaLabel} title={title}>
51
53
  <span className={summaryTextClassNames}>{children ?? (label || 'Details')}</span>
52
54
  </summary>
53
55
  );
@@ -19,6 +19,10 @@
19
19
  "type": "string",
20
20
  "description": "Accessible name for the summary control."
21
21
  },
22
+ "title": {
23
+ "type": "string",
24
+ "description": "Optional native tooltip text for an icon-only summary."
25
+ },
22
26
  "className": {
23
27
  "type": "string",
24
28
  "default": "",
@@ -1,11 +1,11 @@
1
1
  {# Django template for Summary #}
2
2
  {% load usx_components %}
3
- {% spaceless %}
4
3
  {% if unstyled %}
5
- <summary{% if className %} class="{{ className|force_escape }}"{% endif %}{% if ariaLabel %} aria-label="{{ ariaLabel|force_escape }}"{% endif %}>{% if children != None %}{{ children|safe }}{% elif label %}{{ label|force_escape }}{% else %}Details{% endif %}</summary>
4
+ <summary{% if className %} class="{{ className|force_escape }}"{% endif %}{% if ariaLabel != None %} aria-label="{{ ariaLabel|force_escape }}"{% endif %}{% if title != None %} title="{{ title|force_escape }}"{% endif %}>{% if children != None %}{% if children is not True and children is not False %}{{ children|safe }}{% endif %}{% else %}{{ label|force_escape }}{% endif %}</summary>
6
5
  {% else %}
7
- <summary class="usx-summary{% if markerColor and not noMarker %} marker-{{ markerColor|force_escape }}{% endif %}{% if noMarker %} usx-summary--no-marker{% endif %}{% if noUnderline %} usx-summary--no-underline{% endif %}{% if className %} {{ className|force_escape }}{% endif %}"{% if ariaLabel %} aria-label="{{ ariaLabel|force_escape }}"{% endif %}>
6
+ {% spaceless %}
7
+ <summary class="usx-summary{% if markerColor and not noMarker %} marker-{{ markerColor|force_escape }}{% endif %}{% if noMarker %} usx-summary--no-marker{% endif %}{% if noUnderline %} usx-summary--no-underline{% endif %}{% if className %} {{ className|force_escape }}{% endif %}"{% if ariaLabel != None %} aria-label="{{ ariaLabel|force_escape }}"{% endif %}{% if title != None %} title="{{ title|force_escape }}"{% endif %}>
8
8
  <span class="usx-summary-text{% if underlineColor and not noUnderline %} underline-{{ underlineColor|force_escape }}{% endif %}{% if textClassName %} {{ textClassName|force_escape }}{% endif %}">{% if children != None %}{{ children|safe }}{% elif label %}{{ label|force_escape }}{% else %}Details{% endif %}</span>
9
9
  </summary>
10
- {% endif %}
11
10
  {% endspaceless %}
11
+ {% endif %}
@@ -29,9 +29,20 @@ export interface TableProps extends Omit<React.TableHTMLAttributes<HTMLTableElem
29
29
 
30
30
  /** A themeable USWDS table. Sorting is supplied by USWDS's table script. */
31
31
  export default function Table({
32
- columns = [], data = [], caption, striped = false, borderless = false,
33
- compact = false, scrollable = false, scrollHeight, stickyHeader = false, responsive = false,
34
- className, children, extraAttributes, ...props
32
+ columns = [],
33
+ data = [],
34
+ caption,
35
+ striped = false,
36
+ borderless = false,
37
+ compact = false,
38
+ scrollable = false,
39
+ scrollHeight,
40
+ stickyHeader = false,
41
+ responsive = false,
42
+ className,
43
+ children,
44
+ extraAttributes,
45
+ ...props
35
46
  }: TableProps) {
36
47
  const hasSorting = !children && columns.some((column) => column.sortable);
37
48
  const table = (
@@ -40,7 +51,8 @@ export default function Table({
40
51
  {...props}
41
52
  {...extraAttributes}
42
53
  className={classnames(
43
- 'usa-table', 'usx-table',
54
+ 'usa-table',
55
+ 'usx-table',
44
56
  striped && 'usa-table--striped',
45
57
  borderless && 'usa-table--borderless',
46
58
  compact && 'usa-table--compact',
@@ -53,30 +65,51 @@ export default function Table({
53
65
  {children ?? (
54
66
  <>
55
67
  <caption className="usx-table__caption">{caption || 'Data table'}</caption>
56
- <thead><tr>{columns.map((column) => (
57
- <th key={column.key} scope="col" data-sortable={column.sortable ? '' : undefined}>
58
- {column.header}
59
- </th>
60
- ))}</tr></thead>
61
- <tbody>{data.map((row, index) => (
62
- <tr key={index}>{columns.map((column) => {
63
- const Cell = column.primary ? 'th' : 'td';
64
- const value = row[column.key];
65
- return <Cell
66
- key={column.key}
67
- scope={column.primary ? 'row' : undefined}
68
- data-label={responsive ? String(column.header) : undefined}
69
- >{value ?? ''}</Cell>;
70
- })}</tr>
71
- ))}</tbody>
68
+ <thead>
69
+ <tr>
70
+ {columns.map((column) => (
71
+ <th key={column.key} scope="col" data-sortable={column.sortable ? '' : undefined}>
72
+ {column.header}
73
+ </th>
74
+ ))}
75
+ </tr>
76
+ </thead>
77
+ <tbody>
78
+ {data.map((row, index) => (
79
+ <tr key={index}>
80
+ {columns.map((column) => {
81
+ const Cell = column.primary ? 'th' : 'td';
82
+ const value = row[column.key];
83
+ return (
84
+ <Cell
85
+ key={column.key}
86
+ scope={column.primary ? 'row' : undefined}
87
+ data-label={responsive ? String(column.header) : undefined}
88
+ >
89
+ {value ?? ''}
90
+ </Cell>
91
+ );
92
+ })}
93
+ </tr>
94
+ ))}
95
+ </tbody>
72
96
  </>
73
97
  )}
74
98
  </table>
75
- {hasSorting && <div className="usa-sr-only usa-table__announcement-region" aria-live="polite" />}
99
+ {hasSorting && (
100
+ <div className="usa-sr-only usa-table__announcement-region" aria-live="polite" />
101
+ )}
76
102
  </>
77
103
  );
78
- return scrollable
79
- ? <div className="usa-table-container--scrollable" tabIndex={0}
80
- style={scrollHeight ? { height: scrollHeight, overflow: 'auto' } : undefined}>{table}</div>
81
- : table;
104
+ return scrollable ? (
105
+ <div
106
+ className="usa-table-container--scrollable"
107
+ tabIndex={0}
108
+ style={scrollHeight ? { height: scrollHeight, overflow: 'auto' } : undefined}
109
+ >
110
+ {table}
111
+ </div>
112
+ ) : (
113
+ table
114
+ );
82
115
  }
@@ -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