@solexllc/usx-react 0.1.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 (359) hide show
  1. package/README.md +45 -0
  2. package/dist/index.cjs +6017 -0
  3. package/dist/index.js +6015 -0
  4. package/package.json +48 -0
  5. package/src/components/accordion/Accordion.jsx +170 -0
  6. package/src/components/accordion/accordion.django.html +47 -0
  7. package/src/components/accordion/accordion.html +304 -0
  8. package/src/components/accordion/config.json +31 -0
  9. package/src/components/alert/Alert.tsx +88 -0
  10. package/src/components/alert/alert.django.html +45 -0
  11. package/src/components/alert/alert.html +192 -0
  12. package/src/components/alert/config.json +70 -0
  13. package/src/components/attribution/Attribution.tsx +40 -0
  14. package/src/components/attribution/attribution.django.html +21 -0
  15. package/src/components/attribution/attribution.html +26 -0
  16. package/src/components/attribution/config.json +32 -0
  17. package/src/components/avatar/Avatar.tsx +85 -0
  18. package/src/components/avatar/avatar.django.html +27 -0
  19. package/src/components/avatar/avatar.html +101 -0
  20. package/src/components/avatar/config.json +59 -0
  21. package/src/components/avatar-group/AvatarGroup.tsx +43 -0
  22. package/src/components/avatar-group/avatar-group.django.html +8 -0
  23. package/src/components/avatar-group/avatar-group.html +208 -0
  24. package/src/components/avatar-group/config.json +60 -0
  25. package/src/components/back-to-top/BackToTop.tsx +60 -0
  26. package/src/components/back-to-top/back-to-top.django.html +38 -0
  27. package/src/components/back-to-top/back-to-top.html +107 -0
  28. package/src/components/back-to-top/config.json +44 -0
  29. package/src/components/banner/Banner.tsx +111 -0
  30. package/src/components/banner/banner.django.html +80 -0
  31. package/src/components/banner/banner.html +411 -0
  32. package/src/components/banner/config.json +47 -0
  33. package/src/components/block/Block.tsx +78 -0
  34. package/src/components/block/block.django.html +26 -0
  35. package/src/components/block/block.html +162 -0
  36. package/src/components/block/config.json +88 -0
  37. package/src/components/breadcrumb/Breadcrumb.tsx +83 -0
  38. package/src/components/breadcrumb/breadcrumb.django.html +24 -0
  39. package/src/components/breadcrumb/breadcrumb.html +108 -0
  40. package/src/components/breadcrumb/config.json +74 -0
  41. package/src/components/button/Button.tsx +121 -0
  42. package/src/components/button/button.django.html +58 -0
  43. package/src/components/button/button.html +363 -0
  44. package/src/components/button/config.json +103 -0
  45. package/src/components/button-group/ButtonGroup.tsx +33 -0
  46. package/src/components/button-group/button-group.django.html +9 -0
  47. package/src/components/button-group/button-group.html +159 -0
  48. package/src/components/button-group/config.json +25 -0
  49. package/src/components/calendar-date/CalendarDate.tsx +40 -0
  50. package/src/components/calendar-date/calendar-date.django.html +8 -0
  51. package/src/components/calendar-date/calendar-date.html +17 -0
  52. package/src/components/calendar-date/config.json +17 -0
  53. package/src/components/card/Card.tsx +137 -0
  54. package/src/components/card/card.django.html +40 -0
  55. package/src/components/card/card.html +67 -0
  56. package/src/components/card/config.json +115 -0
  57. package/src/components/card-group/CardGroup.tsx +23 -0
  58. package/src/components/card-group/card-group.django.html +6 -0
  59. package/src/components/card-group/card-group.html +164 -0
  60. package/src/components/card-group/config.json +21 -0
  61. package/src/components/carousel/Carousel.tsx +101 -0
  62. package/src/components/carousel/carousel.django.html +41 -0
  63. package/src/components/carousel/carousel.html +64 -0
  64. package/src/components/carousel/config.json +38 -0
  65. package/src/components/character-count/CharacterCount.tsx +77 -0
  66. package/src/components/character-count/character-count.django.html +19 -0
  67. package/src/components/character-count/character-count.html +110 -0
  68. package/src/components/character-count/config.json +78 -0
  69. package/src/components/checkbox/Checkbox.tsx +90 -0
  70. package/src/components/checkbox/checkbox.django.html +16 -0
  71. package/src/components/checkbox/checkbox.html +266 -0
  72. package/src/components/checkbox/config.json +71 -0
  73. package/src/components/checkbox-group/CheckboxGroup.tsx +67 -0
  74. package/src/components/checkbox-group/checkbox-group.django.html +12 -0
  75. package/src/components/checkbox-group/checkbox-group.html +36 -0
  76. package/src/components/checkbox-group/config.json +50 -0
  77. package/src/components/clickable/Clickable.tsx +78 -0
  78. package/src/components/clickable/clickable.django.html +5 -0
  79. package/src/components/clickable/clickable.html +133 -0
  80. package/src/components/clickable/config.json +26 -0
  81. package/src/components/code/Code.tsx +60 -0
  82. package/src/components/code/code.django.html +21 -0
  83. package/src/components/code/code.html +71 -0
  84. package/src/components/code/config.json +40 -0
  85. package/src/components/collection/Collection.tsx +99 -0
  86. package/src/components/collection/collection.django.html +48 -0
  87. package/src/components/collection/collection.html +384 -0
  88. package/src/components/collection/config.json +60 -0
  89. package/src/components/combobox/Combobox.tsx +114 -0
  90. package/src/components/combobox/combobox.django.html +61 -0
  91. package/src/components/combobox/combobox.html +509 -0
  92. package/src/components/combobox/config.json +80 -0
  93. package/src/components/copy-to-clipboard/CopyToClipboard.tsx +48 -0
  94. package/src/components/copy-to-clipboard/config.json +30 -0
  95. package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +16 -0
  96. package/src/components/copy-to-clipboard/copy-to-clipboard.html +68 -0
  97. package/src/components/date-picker/DatePicker.jsx +83 -0
  98. package/src/components/date-picker/config.json +71 -0
  99. package/src/components/date-picker/date-picker.django.html +67 -0
  100. package/src/components/date-picker/date-picker.html +104 -0
  101. package/src/components/date-range-picker/DateRangePicker.jsx +113 -0
  102. package/src/components/date-range-picker/config.json +92 -0
  103. package/src/components/date-range-picker/date-range-picker.django.html +66 -0
  104. package/src/components/date-range-picker/date-range-picker.html +190 -0
  105. package/src/components/error-message/ErrorMessage.tsx +23 -0
  106. package/src/components/error-message/config.json +19 -0
  107. package/src/components/error-message/error-message.django.html +2 -0
  108. package/src/components/error-message/error-message.html +2 -0
  109. package/src/components/eyebrow/Eyebrow.tsx +15 -0
  110. package/src/components/eyebrow/config.json +15 -0
  111. package/src/components/eyebrow/eyebrow.django.html +4 -0
  112. package/src/components/eyebrow/eyebrow.html +4 -0
  113. package/src/components/fieldset/Fieldset.tsx +54 -0
  114. package/src/components/fieldset/config.json +47 -0
  115. package/src/components/fieldset/fieldset.django.html +22 -0
  116. package/src/components/fieldset/fieldset.html +17 -0
  117. package/src/components/file-input/FileInput.jsx +174 -0
  118. package/src/components/file-input/config.json +80 -0
  119. package/src/components/file-input/file-input.django.html +57 -0
  120. package/src/components/file-input/file-input.html +258 -0
  121. package/src/components/file-list/FileList.jsx +105 -0
  122. package/src/components/file-list/config.json +43 -0
  123. package/src/components/file-list/file-list.django.html +30 -0
  124. package/src/components/file-list/file-list.html +61 -0
  125. package/src/components/footer/Footer.tsx +365 -0
  126. package/src/components/footer/config.json +83 -0
  127. package/src/components/footer/footer.django.html +260 -0
  128. package/src/components/footer/footer.html +392 -0
  129. package/src/components/form-group/FormGroup.tsx +26 -0
  130. package/src/components/form-group/config.json +22 -0
  131. package/src/components/form-group/form-group.django.html +4 -0
  132. package/src/components/form-group/form-group.html +17 -0
  133. package/src/components/header/Branding.tsx +101 -0
  134. package/src/components/header/Header.tsx +229 -0
  135. package/src/components/header/HeaderBranding.jsx +4 -0
  136. package/src/components/header/config.json +58 -0
  137. package/src/components/header/header.django.html +194 -0
  138. package/src/components/header/header.html +823 -0
  139. package/src/components/hero/Hero.tsx +64 -0
  140. package/src/components/hero/config.json +70 -0
  141. package/src/components/hero/hero.django.html +22 -0
  142. package/src/components/hero/hero.html +75 -0
  143. package/src/components/hint/Hint.tsx +23 -0
  144. package/src/components/hint/config.json +19 -0
  145. package/src/components/hint/hint.django.html +2 -0
  146. package/src/components/hint/hint.html +2 -0
  147. package/src/components/icon/Icon.tsx +46 -0
  148. package/src/components/icon/config.json +60 -0
  149. package/src/components/icon/icon.django.html +26 -0
  150. package/src/components/icon/icon.html +289 -0
  151. package/src/components/icon/icons_list.json +247 -0
  152. package/src/components/icon-list/IconList.tsx +59 -0
  153. package/src/components/icon-list/config.json +86 -0
  154. package/src/components/icon-list/icon-list.django.html +17 -0
  155. package/src/components/icon-list/icon-list.html +227 -0
  156. package/src/components/identifier/Identifier.tsx +193 -0
  157. package/src/components/identifier/config.json +133 -0
  158. package/src/components/identifier/identifier.django.html +99 -0
  159. package/src/components/identifier/identifier.html +737 -0
  160. package/src/components/image/Image.tsx +106 -0
  161. package/src/components/image/config.json +64 -0
  162. package/src/components/image/image.django.html +62 -0
  163. package/src/components/image/image.html +53 -0
  164. package/src/components/in-page-nav/InPageNav.jsx +76 -0
  165. package/src/components/in-page-nav/config.json +69 -0
  166. package/src/components/in-page-nav/in-page-nav.django.html +28 -0
  167. package/src/components/in-page-nav/in-page-nav.html +183 -0
  168. package/src/components/indicator/Indicator.tsx +32 -0
  169. package/src/components/indicator/README.md +1 -0
  170. package/src/components/indicator/config.json +19 -0
  171. package/src/components/indicator/indicator.django.html +10 -0
  172. package/src/components/indicator/indicator.html +42 -0
  173. package/src/components/input/Input.tsx +85 -0
  174. package/src/components/input/config.json +73 -0
  175. package/src/components/input/input.django.html +55 -0
  176. package/src/components/input/input.html +59 -0
  177. package/src/components/label/Label.tsx +42 -0
  178. package/src/components/label/config.json +39 -0
  179. package/src/components/label/label.django.html +23 -0
  180. package/src/components/label/label.html +23 -0
  181. package/src/components/language-selector/LanguageSelector.jsx +224 -0
  182. package/src/components/language-selector/config.json +107 -0
  183. package/src/components/language-selector/language-selector.django.html +40 -0
  184. package/src/components/language-selector/language-selector.html +85 -0
  185. package/src/components/layout/Layout.tsx +131 -0
  186. package/src/components/layout/config.json +36 -0
  187. package/src/components/layout/layout.django.html +28 -0
  188. package/src/components/layout/layout.html +29 -0
  189. package/src/components/legend/Legend.tsx +34 -0
  190. package/src/components/legend/config.json +27 -0
  191. package/src/components/legend/legend.django.html +11 -0
  192. package/src/components/legend/legend.html +12 -0
  193. package/src/components/link/Link.tsx +45 -0
  194. package/src/components/link/config.json +39 -0
  195. package/src/components/link/link.django.html +8 -0
  196. package/src/components/link/link.html +47 -0
  197. package/src/components/list/List.tsx +82 -0
  198. package/src/components/list/_list-items.django.html +17 -0
  199. package/src/components/list/config.json +25 -0
  200. package/src/components/list/list.django.html +11 -0
  201. package/src/components/list/list.html +26 -0
  202. package/src/components/memorable-date/MemorableDate.jsx +167 -0
  203. package/src/components/memorable-date/config.json +104 -0
  204. package/src/components/memorable-date/memorable-date.django.html +86 -0
  205. package/src/components/memorable-date/memorable-date.html +275 -0
  206. package/src/components/misc-banner/MiscBanner.tsx +112 -0
  207. package/src/components/misc-banner/config.json +57 -0
  208. package/src/components/misc-banner/misc-banner.django.html +63 -0
  209. package/src/components/misc-banner/misc-banner.html +191 -0
  210. package/src/components/modal/Modal.tsx +71 -0
  211. package/src/components/modal/config.json +57 -0
  212. package/src/components/modal/modal.django.html +43 -0
  213. package/src/components/modal/modal.html +222 -0
  214. package/src/components/page/Page.jsx +34 -0
  215. package/src/components/page/config.json +34 -0
  216. package/src/components/page/page.django.html +5 -0
  217. package/src/components/page/page.html +23 -0
  218. package/src/components/pagination/Pagination.tsx +112 -0
  219. package/src/components/pagination/config.json +135 -0
  220. package/src/components/pagination/container/PaginationContainer.tsx +38 -0
  221. package/src/components/pagination/navigation/PaginationNavigation.tsx +219 -0
  222. package/src/components/pagination/navigation/pagination-navigation.django.html +64 -0
  223. package/src/components/pagination/pagination.django.html +48 -0
  224. package/src/components/pagination/pagination.html +613 -0
  225. package/src/components/pagination/step-options/PaginationStepOptions.tsx +43 -0
  226. package/src/components/pagination/step-options/pagination-step-options.django.html +7 -0
  227. package/src/components/pagination/summary/PaginationSummary.tsx +33 -0
  228. package/src/components/pagination/summary/pagination-summary.django.html +12 -0
  229. package/src/components/process-list/ProcessList.tsx +52 -0
  230. package/src/components/process-list/config.json +15 -0
  231. package/src/components/process-list/process-list.django.html +15 -0
  232. package/src/components/process-list/process-list.html +90 -0
  233. package/src/components/prose/Prose.tsx +32 -0
  234. package/src/components/prose/config.json +28 -0
  235. package/src/components/prose/prose.django.html +35 -0
  236. package/src/components/prose/prose.html +91 -0
  237. package/src/components/radio-buttons/RadioButtons.tsx +82 -0
  238. package/src/components/radio-buttons/config.json +57 -0
  239. package/src/components/radio-buttons/radio-buttons.django.html +28 -0
  240. package/src/components/radio-buttons/radio-buttons.html +189 -0
  241. package/src/components/range-slider/RangeSlider.jsx +84 -0
  242. package/src/components/range-slider/config.json +89 -0
  243. package/src/components/range-slider/range-slider.django.html +65 -0
  244. package/src/components/range-slider/range-slider.html +106 -0
  245. package/src/components/required/Required.tsx +25 -0
  246. package/src/components/required/config.json +20 -0
  247. package/src/components/required/required.django.html +2 -0
  248. package/src/components/required/required.html +6 -0
  249. package/src/components/search/Search.tsx +92 -0
  250. package/src/components/search/config.json +69 -0
  251. package/src/components/search/search.django.html +59 -0
  252. package/src/components/search/search.html +76 -0
  253. package/src/components/section/Section.tsx +28 -0
  254. package/src/components/section/config.json +27 -0
  255. package/src/components/section/section.django.html +5 -0
  256. package/src/components/section/section.html +16 -0
  257. package/src/components/select/Select.tsx +107 -0
  258. package/src/components/select/config.json +80 -0
  259. package/src/components/select/select.django.html +64 -0
  260. package/src/components/select/select.html +62 -0
  261. package/src/components/sidenav/SideNav.tsx +74 -0
  262. package/src/components/sidenav/config.json +45 -0
  263. package/src/components/sidenav/sidenav.django.html +29 -0
  264. package/src/components/sidenav/sidenav.html +84 -0
  265. package/src/components/site-alert/SiteAlert.tsx +101 -0
  266. package/src/components/site-alert/config.json +62 -0
  267. package/src/components/site-alert/site-alert.django.html +34 -0
  268. package/src/components/site-alert/site-alert.html +312 -0
  269. package/src/components/skipnav/Skipnav.tsx +41 -0
  270. package/src/components/skipnav/config.json +29 -0
  271. package/src/components/skipnav/skipnav.django.html +11 -0
  272. package/src/components/skipnav/skipnav.html +1 -0
  273. package/src/components/spinner/Spinner.tsx +46 -0
  274. package/src/components/spinner/config.json +44 -0
  275. package/src/components/spinner/spinner.django.html +8 -0
  276. package/src/components/spinner/spinner.html +219 -0
  277. package/src/components/status/Status.tsx +28 -0
  278. package/src/components/status/config.json +47 -0
  279. package/src/components/status/status.django.html +2 -0
  280. package/src/components/status/status.html +31 -0
  281. package/src/components/step-indicator/StepIndicator.tsx +80 -0
  282. package/src/components/step-indicator/config.json +54 -0
  283. package/src/components/step-indicator/step-indicator.django.html +29 -0
  284. package/src/components/step-indicator/step-indicator.html +243 -0
  285. package/src/components/summary-box/SummaryBox.tsx +41 -0
  286. package/src/components/summary-box/config.json +30 -0
  287. package/src/components/summary-box/summary-box.django.html +19 -0
  288. package/src/components/summary-box/summary-box.html +210 -0
  289. package/src/components/swap/Swap.tsx +47 -0
  290. package/src/components/swap/config.json +61 -0
  291. package/src/components/swap/swap.django.html +14 -0
  292. package/src/components/swap/swap.html +163 -0
  293. package/src/components/switch/Switch.tsx +73 -0
  294. package/src/components/switch/config.json +55 -0
  295. package/src/components/switch/switch.django.html +28 -0
  296. package/src/components/switch/switch.html +56 -0
  297. package/src/components/table/Table.tsx +334 -0
  298. package/src/components/table/TableBody.tsx +253 -0
  299. package/src/components/table/TableCell.tsx +37 -0
  300. package/src/components/table/TableContext.tsx +87 -0
  301. package/src/components/table/TableFoot.tsx +68 -0
  302. package/src/components/table/TableGroup.tsx +69 -0
  303. package/src/components/table/TableHead.tsx +139 -0
  304. package/src/components/table/TableRow.tsx +56 -0
  305. package/src/components/table/__pycache__/table_helper.cpython-312.pyc +0 -0
  306. package/src/components/table/config.json +297 -0
  307. package/src/components/table/hooks/useRowDetails.ts +34 -0
  308. package/src/components/table/hooks/useTableGroups.ts +61 -0
  309. package/src/components/table/hooks/useTableSelect.ts +82 -0
  310. package/src/components/table/hooks/useTableSort.ts +60 -0
  311. package/src/components/table/table-body.django.html +68 -0
  312. package/src/components/table/table-detail-row.django.html +14 -0
  313. package/src/components/table/table-foot.django.html +31 -0
  314. package/src/components/table/table-group.django.html +40 -0
  315. package/src/components/table/table-head.django.html +85 -0
  316. package/src/components/table/table-row.django.html +98 -0
  317. package/src/components/table/table.django.html +60 -0
  318. package/src/components/table/table.html +1186 -0
  319. package/src/components/table/table_helper.py +298 -0
  320. package/src/components/table/types.ts +68 -0
  321. package/src/components/tag/Tag.tsx +75 -0
  322. package/src/components/tag/config.json +54 -0
  323. package/src/components/tag/tag.django.html +39 -0
  324. package/src/components/tag/tag.html +45 -0
  325. package/src/components/tag-group/TagGroup.tsx +35 -0
  326. package/src/components/tag-group/config.json +24 -0
  327. package/src/components/tag-group/tag-group.django.html +11 -0
  328. package/src/components/tag-group/tag-group.html +36 -0
  329. package/src/components/task-list/TaskList.tsx +40 -0
  330. package/src/components/task-list/config.json +41 -0
  331. package/src/components/task-list/task-list.django.html +21 -0
  332. package/src/components/task-list/task-list.html +24 -0
  333. package/src/components/text-area/TextArea.tsx +78 -0
  334. package/src/components/text-area/config.json +78 -0
  335. package/src/components/text-area/text-area.django.html +53 -0
  336. package/src/components/text-area/text-area.html +59 -0
  337. package/src/components/theme-picker/ThemePicker.tsx +106 -0
  338. package/src/components/theme-picker/config.json +39 -0
  339. package/src/components/theme-picker/theme-picker.django.html +32 -0
  340. package/src/components/theme-picker/theme-picker.html +67 -0
  341. package/src/components/time-picker/TimePicker.jsx +87 -0
  342. package/src/components/time-picker/config.json +76 -0
  343. package/src/components/time-picker/time-picker.django.html +67 -0
  344. package/src/components/time-picker/time-picker.html +123 -0
  345. package/src/components/toggle/Toggle.tsx +80 -0
  346. package/src/components/toggle/config.json +69 -0
  347. package/src/components/toggle/toggle.django.html +19 -0
  348. package/src/components/toggle/toggle.html +85 -0
  349. package/src/components/tooltip/Tooltip.tsx +33 -0
  350. package/src/components/tooltip/config.json +33 -0
  351. package/src/components/tooltip/tooltip.django.html +5 -0
  352. package/src/components/tooltip/tooltip.html +57 -0
  353. package/src/components/villain/Villain.tsx +47 -0
  354. package/src/components/villain/config.json +44 -0
  355. package/src/components/villain/villain.django.html +19 -0
  356. package/src/components/villain/villain.html +39 -0
  357. package/src/declarations.d.ts +1 -0
  358. package/src/index.js +82 -0
  359. package/src/styles/core.scss +12 -0
@@ -0,0 +1,34 @@
1
+ import React, { ReactNode, HTMLAttributes } from 'react';
2
+ import ClassNames from 'classnames';
3
+ import Required from '../required/Required';
4
+
5
+ export interface LegendProps extends HTMLAttributes<HTMLLegendElement> {
6
+ text?: string | undefined;
7
+ required?: boolean;
8
+ large?: boolean;
9
+ children?: ReactNode;
10
+ className?: string;
11
+ }
12
+
13
+ export default function Legend({
14
+ text,
15
+ required = false,
16
+ large = false,
17
+ children = null,
18
+ className = '',
19
+ ...props
20
+ }: LegendProps) {
21
+ const classes = ClassNames(
22
+ 'usa-legend',
23
+ 'usx-legend',
24
+ { 'usa-legend--large': large },
25
+ className
26
+ );
27
+
28
+ return (
29
+ <legend className={classes} {...props}>
30
+ {required && <Required />}
31
+ {children || text}
32
+ </legend>
33
+ );
34
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "legend",
3
+ "template": "legend/legend.django.html",
4
+ "version": 1,
5
+ "props": {
6
+ "text": {
7
+ "type": "string",
8
+ "description": "Text for the legend"
9
+ },
10
+ "required": {
11
+ "type": "boolean",
12
+ "description": "Whether to indicate the field is required (adds an asterisk)"
13
+ },
14
+ "large": {
15
+ "type": "boolean",
16
+ "description": "Whether to use the larger legend style (adds class `usa-legend--large`)"
17
+ },
18
+ "children": {
19
+ "type": "string",
20
+ "description": "Inner HTML or text"
21
+ },
22
+ "className": {
23
+ "type": "string",
24
+ "description": "Additional classes"
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,11 @@
1
+ {# Django template for Legend #}
2
+ {% load components %}
3
+ <legend
4
+ class="
5
+ usa-legend usx-legend
6
+ {% if large %}usa-legend--large{% endif %}
7
+ {{ className }}
8
+ "
9
+ >
10
+ {% if required %}{% required %}{% endrequired %}{% endif %}{{ children|default:text }}
11
+ </legend>
@@ -0,0 +1,12 @@
1
+ <h3 class="site-preview-heading">Default</h3>
2
+ <legend class="usa-legend usx-legend">Legend</legend>
3
+
4
+ <h3 class="site-preview-heading">With additional class</h3>
5
+ <legend class="usa-legend usx-legend text-primary">Legend with extra class</legend>
6
+
7
+ <h3 class ="site-preview-heading">Legend for required fieldset</h3>
8
+ <fieldset class="usa-fieldset">
9
+ <legend class="usa-legend usx-legend">
10
+ <abbr title="Required" class="usx-required">*</abbr>Legend for required fieldset
11
+ </legend>
12
+ </fieldset>
@@ -0,0 +1,45 @@
1
+ import React, { AnchorHTMLAttributes, ReactNode } from 'react';
2
+ import classNames from 'classnames';
3
+
4
+ export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
5
+ href?: string;
6
+ children?: ReactNode;
7
+ visited?: boolean;
8
+ external?: boolean;
9
+ alt?: boolean;
10
+ newTab?: boolean;
11
+ rel?: string;
12
+ className?: string;
13
+ }
14
+
15
+ export default function Link({
16
+ href = 'javascript:void(0);',
17
+ children,
18
+ visited = false,
19
+ external = false,
20
+ alt = false,
21
+ newTab = false,
22
+ className = '',
23
+ ...props
24
+ }: LinkProps) {
25
+ const classes = classNames(
26
+ 'usa-link',
27
+ 'usx-link',
28
+ visited && 'usx-link--visited',
29
+ external && 'usa-link--external',
30
+ alt && 'usa-link--alt',
31
+ className,
32
+ );
33
+
34
+ return (
35
+ <a
36
+ href={href}
37
+ className={classes}
38
+ target={newTab || external ? '_blank' : undefined}
39
+ rel={newTab || external ? 'noreferrer noopener' : undefined}
40
+ {...props}
41
+ >
42
+ {children}
43
+ </a>
44
+ );
45
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "link",
3
+ "template": "link/link.django.html",
4
+ "version": 1,
5
+ "required": [
6
+ "href",
7
+ "children"
8
+ ],
9
+ "props": {
10
+ "href": {
11
+ "type": "string",
12
+ "description": "Link destination URL."
13
+ },
14
+ "children": {
15
+ "type": "string",
16
+ "description": "Inner link text or HTML."
17
+ },
18
+ "visited": {
19
+ "type": "boolean",
20
+ "description": "Apply visited styling class."
21
+ },
22
+ "external": {
23
+ "type": "boolean",
24
+ "description": "Apply external-link styling and default rel=noreferrer."
25
+ },
26
+ "alt": {
27
+ "type": "boolean",
28
+ "description": "Use alternate link style for dark backgrounds."
29
+ },
30
+ "newTab": {
31
+ "type": "boolean",
32
+ "description": "Open link in a new tab (target=_blank)."
33
+ },
34
+ "className": {
35
+ "type": "string",
36
+ "description": "Additional classes."
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,8 @@
1
+ {# Django template for Link #}
2
+ {% load components %}
3
+
4
+ <a
5
+ href="{{ href|default:'javascript:void(0);' }}"
6
+ class="usa-link usx-link{% if visited %} usx-link--visited{% endif %}{% if external %} usa-link--external{% endif %}{% if alt %} usa-link--alt{% endif %}{% if className %} {{ className }}{% endif %}"
7
+ {% if newTab or external %}target="_blank" rel="noreferrer noopener"{% endif %}
8
+ >{{ children|safe }}</a>
@@ -0,0 +1,47 @@
1
+ <p>
2
+ This is <a class="usa-link usx-link" href="javascript:void(0);">a text link</a> on a
3
+ light background.
4
+ </p>
5
+ <p>
6
+ This is
7
+ <a class="usa-link usx-link usx-link--visited" href="javascript:void(0);"
8
+ >a visited link</a
9
+ >.
10
+ </p>
11
+ <p>
12
+ This is a link that opens in the <em>current</em> tab and goes to an
13
+ <a
14
+ class="usa-link usx-link usa-link--external"
15
+ rel="noreferrer"
16
+ href="https://i.giphy.com/media/WPzQF6ruiIIVzHNlwX/source.gif"
17
+ >external website</a
18
+ >.
19
+ </p>
20
+ <p>
21
+ This is a link that opens in a <em>new</em> tab and goes to an
22
+ <a
23
+ class="usa-link usx-link usa-link--external"
24
+ rel="noreferrer"
25
+ target="_blank"
26
+ href="https://i.giphy.com/media/WPzQF6ruiIIVzHNlwX/source.gif"
27
+ >external website</a
28
+ >.
29
+ </p>
30
+ <div class="usa-dark-background padding-1 display-inline-block">
31
+
32
+ <p>
33
+ This is
34
+ <a class="usa-link usx-link" href="javascript:void(0);"
35
+ >a text link on a dark background</a
36
+ >.
37
+ </p>
38
+ <p>
39
+ <a
40
+ class="usa-link usx-link usa-link--alt usa-link--external"
41
+ rel="noreferrer"
42
+ href="https://i.giphy.com/media/WPzQF6ruiIIVzHNlwX/source.gif"
43
+ >This</a
44
+ >
45
+ is an alternate external text link on a dark background.
46
+ </p>
47
+ </div>
@@ -0,0 +1,82 @@
1
+ import React, { ReactNode, HTMLAttributes } from 'react';
2
+ import ClassNames from 'classnames';
3
+
4
+ export type ListItem =
5
+ | ReactNode
6
+ | {
7
+ content?: ReactNode;
8
+ children?: ListItem[];
9
+ ordered?: boolean;
10
+ unstyled?: boolean;
11
+ className?: string;
12
+ };
13
+
14
+ function isItemObject(item: ListItem): item is Exclude<ListItem, ReactNode> {
15
+ return (
16
+ item &&
17
+ typeof item === 'object' &&
18
+ !Array.isArray(item) &&
19
+ !React.isValidElement(item)
20
+ );
21
+ }
22
+
23
+ function renderItems(items: ListItem[] = [], parentOptions: { ordered?: boolean; unstyled?: boolean } = {}) {
24
+ return items.map((item, index) => {
25
+ const objectItem = isItemObject(item);
26
+ const content = objectItem && Object.prototype.hasOwnProperty.call(item, 'content')
27
+ ? item.content
28
+ : item;
29
+ const children = objectItem && Array.isArray(item.children) ? item.children : [];
30
+ const childOrdered = objectItem && typeof item.ordered === 'boolean'
31
+ ? item.ordered
32
+ : parentOptions.ordered;
33
+ const childUnstyled = objectItem && typeof item.unstyled === 'boolean'
34
+ ? item.unstyled
35
+ : parentOptions.unstyled;
36
+ const childClassName = objectItem && typeof item.className === 'string'
37
+ ? item.className
38
+ : '';
39
+ const ChildTag = childOrdered ? 'ol' : 'ul';
40
+
41
+ const childClasses = ClassNames(
42
+ 'usa-list',
43
+ 'usx-list',
44
+ childUnstyled && 'usa-list--unstyled',
45
+ childClassName,
46
+ );
47
+
48
+ return (
49
+ <li key={index}>
50
+ {content}
51
+ {children.length > 0 && (
52
+ <ChildTag className={childClasses}>
53
+ {renderItems(children, { ordered: childOrdered, unstyled: childUnstyled })}
54
+ </ChildTag>
55
+ )}
56
+ </li>
57
+ );
58
+ });
59
+ }
60
+
61
+ export interface ListProps extends HTMLAttributes<HTMLUListElement | HTMLOListElement> {
62
+ items?: ListItem[];
63
+ ordered?: boolean;
64
+ unstyled?: boolean;
65
+ className?: string;
66
+ }
67
+
68
+ export default function List({ items = [], ordered = false, unstyled = false, className = '', ...props }: ListProps) {
69
+ const classes = ClassNames(
70
+ 'usa-list',
71
+ 'usx-list',
72
+ unstyled && 'usa-list--unstyled',
73
+ className,
74
+ );
75
+ const Tag = ordered ? 'ol' : 'ul';
76
+
77
+ return (
78
+ <Tag className={classes} {...props}>
79
+ {renderItems(items, { ordered, unstyled })}
80
+ </Tag>
81
+ );
82
+ }
@@ -0,0 +1,17 @@
1
+ {% for item in items %}
2
+ <li>
3
+ {% if item.content %}{{ item.content }}{% else %}{{ item }}{% endif %}
4
+
5
+ {% if item.children %}
6
+ {% if item.ordered %}
7
+ <ol class="usa-list usx-list{% if item.unstyled %} usa-list--unstyled{% elif unstyled %} usa-list--unstyled{% endif %}{% if item.className %} {{ item.className }}{% endif %}">
8
+ {% include "list/_list-items.django.html" with items=item.children ordered=True unstyled=unstyled only %}
9
+ </ol>
10
+ {% else %}
11
+ <ul class="usa-list usx-list{% if item.unstyled %} usa-list--unstyled{% elif unstyled %} usa-list--unstyled{% endif %}{% if item.className %} {{ item.className }}{% endif %}">
12
+ {% include "list/_list-items.django.html" with items=item.children ordered=False unstyled=unstyled only %}
13
+ </ul>
14
+ {% endif %}
15
+ {% endif %}
16
+ </li>
17
+ {% endfor %}
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "list",
3
+ "template": "list/list.django.html",
4
+ "version": 1,
5
+ "props": {
6
+ "items": {
7
+ "type": "object",
8
+ "description": "Array of list items. A string renders a simple item. Objects can include content and children for nested lists of any depth; optional ordered/unstyled/className customize nested lists."
9
+ },
10
+ "ordered": {
11
+ "type": "boolean",
12
+ "default": false,
13
+ "description": "Render an ordered list using an ol element."
14
+ },
15
+ "unstyled": {
16
+ "type": "boolean",
17
+ "default": false,
18
+ "description": "Remove default list styling with usa-list--unstyled."
19
+ },
20
+ "className": {
21
+ "type": "string",
22
+ "description": "Additional classes"
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,11 @@
1
+ {% load components %}
2
+
3
+ {% if ordered %}
4
+ <ol class="usa-list usx-list{% if unstyled %} usa-list--unstyled{% endif %}{% if className %} {{ className }}{% endif %}">
5
+ {% include "list/_list-items.django.html" with items=items ordered=ordered unstyled=unstyled only %}
6
+ </ol>
7
+ {% else %}
8
+ <ul class="usa-list usx-list{% if unstyled %} usa-list--unstyled{% endif %}{% if className %} {{ className }}{% endif %}">
9
+ {% include "list/_list-items.django.html" with items=items ordered=ordered unstyled=unstyled only %}
10
+ </ul>
11
+ {% endif %}
@@ -0,0 +1,26 @@
1
+ <div class="grid-row grid-gap">
2
+ <div class="mobile-lg:grid-col-4">
3
+ <h3 class="site-preview-heading margin-0">Unordered list</h3>
4
+ <ul class="usa-list">
5
+ <li>Unordered list item</li>
6
+ <li>Unordered list item</li>
7
+ <li>Unordered list item</li>
8
+ </ul>
9
+ </div>
10
+ <div class="mobile-lg:grid-col-4 margin-top-4 mobile-lg:margin-top-0">
11
+ <h3 class="site-preview-heading margin-0">Ordered list</h3>
12
+ <ol class="usa-list">
13
+ <li>Ordered list item</li>
14
+ <li>Ordered list item</li>
15
+ <li>Ordered list item</li>
16
+ </ol>
17
+ </div>
18
+ <div class="mobile-lg:grid-col-4 margin-top-4 mobile-lg:margin-top-0">
19
+ <h3 class="site-preview-heading margin-0">Unstyled list</h3>
20
+ <ul class="usa-list usa-list--unstyled">
21
+ <li>Unstyled list item</li>
22
+ <li>Unstyled list item</li>
23
+ <li>Unstyled list item</li>
24
+ </ul>
25
+ </div>
26
+ </div>
@@ -0,0 +1,167 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Fieldset from '../fieldset/Fieldset';
4
+ import FormGroup from '../form-group/FormGroup';
5
+ import Hint from '../hint/Hint';
6
+ import Select from '../select/Select';
7
+ import Input from '../input/Input';
8
+
9
+ const MONTH_OPTIONS = [
10
+ { value: '1', label: 'January' },
11
+ { value: '2', label: 'February' },
12
+ { value: '3', label: 'March' },
13
+ { value: '4', label: 'April' },
14
+ { value: '5', label: 'May' },
15
+ { value: '6', label: 'June' },
16
+ { value: '7', label: 'July' },
17
+ { value: '8', label: 'August' },
18
+ { value: '9', label: 'September' },
19
+ { value: '10', label: 'October' },
20
+ { value: '11', label: 'November' },
21
+ { value: '12', label: 'December' },
22
+ ];
23
+
24
+ export default function MemorableDate({
25
+ id = 'memorable-date',
26
+ legend = 'Date of Birth',
27
+ groupHint = 'Select a month. Enter 1 or 2 digits for the day and 4 digits for the year.',
28
+ monthLabel = 'Month',
29
+ dayLabel = 'Day',
30
+ yearLabel = 'Year',
31
+ monthHint = 'Select a month from the dropdown.',
32
+ dayHint = 'Enter 1 or 2 digits for the day.',
33
+ yearHint = 'Enter 4 digits for the year.',
34
+ monthName,
35
+ dayName,
36
+ yearName,
37
+ defaultMonth,
38
+ defaultDay,
39
+ defaultYear,
40
+ disabled = false,
41
+ ariaDisabled = false,
42
+ required = false,
43
+ error = null,
44
+ className = '',
45
+ }) {
46
+ const monthId = `${id}-month`;
47
+ const dayId = `${id}-day`;
48
+ const yearId = `${id}-year`;
49
+ const groupHintId = `${id}-hint`;
50
+ const monthHintId = `${monthId}-hint`;
51
+ const dayHintId = `${dayId}-hint`;
52
+ const yearHintId = `${yearId}-hint`;
53
+ const errorId = error ? `${id}-error` : undefined;
54
+ const hasError = !!error;
55
+
56
+ const describedBy = (hintId) => [hintId, errorId].filter(Boolean).join(' ') || undefined;
57
+
58
+ // Native disabled and aria-disabled are mutually exclusive, matching real USWDS's variants.
59
+ const stateProps = disabled
60
+ ? { disabled: true }
61
+ : ariaDisabled
62
+ ? { 'aria-disabled': 'true' }
63
+ : {};
64
+
65
+ return (
66
+ <FormGroup error={hasError}>
67
+ <Fieldset legend={legend} required={required} className={className} error={error} errorId={errorId}>
68
+ {groupHint && (
69
+ <Hint aria-hidden="true" id={groupHintId}>
70
+ {groupHint}
71
+ </Hint>
72
+ )}
73
+ <div className="usa-memorable-date usx-memorable-date">
74
+ <FormGroup className="usa-form-group--month usa-form-group--select">
75
+ <Select
76
+ id={monthId}
77
+ name={monthName || monthId}
78
+ label={monthLabel}
79
+ options={MONTH_OPTIONS}
80
+ placeholder="- Select -"
81
+ defaultValue={defaultMonth}
82
+ required={required}
83
+ aria-describedby={describedBy(monthHintId)}
84
+ aria-invalid={hasError || undefined}
85
+ formGroup={false}
86
+ className={hasError ? 'usa-input--error' : undefined}
87
+ {...stateProps}
88
+ />
89
+ {monthHint && (
90
+ <span className="usa-hint usa-sr-only" id={monthHintId}>
91
+ {monthHint}
92
+ </span>
93
+ )}
94
+ </FormGroup>
95
+ <FormGroup className="usa-form-group--day">
96
+ <Input
97
+ id={dayId}
98
+ name={dayName || dayId}
99
+ label={dayLabel}
100
+ placeholder=""
101
+ defaultValue={defaultDay}
102
+ maxLength={2}
103
+ pattern="[0-9]*"
104
+ inputMode="numeric"
105
+ required={required}
106
+ error={hasError || undefined}
107
+ aria-describedby={describedBy(dayHintId)}
108
+ formGroup={false}
109
+ {...stateProps}
110
+ />
111
+ {dayHint && (
112
+ <span className="usa-hint usa-sr-only" id={dayHintId}>
113
+ {dayHint}
114
+ </span>
115
+ )}
116
+ </FormGroup>
117
+ <FormGroup className="usa-form-group--year">
118
+ <Input
119
+ id={yearId}
120
+ name={yearName || yearId}
121
+ label={yearLabel}
122
+ placeholder=""
123
+ defaultValue={defaultYear}
124
+ minLength={4}
125
+ maxLength={4}
126
+ pattern="[0-9]*"
127
+ inputMode="numeric"
128
+ required={required}
129
+ error={hasError || undefined}
130
+ aria-describedby={describedBy(yearHintId)}
131
+ formGroup={false}
132
+ {...stateProps}
133
+ />
134
+ {yearHint && (
135
+ <span className="usa-hint usa-sr-only" id={yearHintId}>
136
+ {yearHint}
137
+ </span>
138
+ )}
139
+ </FormGroup>
140
+ </div>
141
+ </Fieldset>
142
+ </FormGroup>
143
+ );
144
+ }
145
+
146
+ MemorableDate.propTypes = {
147
+ id: PropTypes.string,
148
+ legend: PropTypes.node,
149
+ groupHint: PropTypes.node,
150
+ monthLabel: PropTypes.node,
151
+ dayLabel: PropTypes.node,
152
+ yearLabel: PropTypes.node,
153
+ monthHint: PropTypes.node,
154
+ dayHint: PropTypes.node,
155
+ yearHint: PropTypes.node,
156
+ monthName: PropTypes.string,
157
+ dayName: PropTypes.string,
158
+ yearName: PropTypes.string,
159
+ defaultMonth: PropTypes.string,
160
+ defaultDay: PropTypes.string,
161
+ defaultYear: PropTypes.string,
162
+ disabled: PropTypes.bool,
163
+ ariaDisabled: PropTypes.bool,
164
+ required: PropTypes.bool,
165
+ error: PropTypes.string,
166
+ className: PropTypes.string,
167
+ };
@@ -0,0 +1,104 @@
1
+ {
2
+ "name": "memorable-date",
3
+ "template": "memorable-date/memorable-date.django.html",
4
+ "version": 1,
5
+ "default": {
6
+ "id": "memorable-date",
7
+ "legend": "Date of Birth"
8
+ },
9
+ "props": {
10
+ "id": {
11
+ "type": "string",
12
+ "default": "memorable-date",
13
+ "description": "Base id for the component. Month/day/year field ids and hint ids are derived from this."
14
+ },
15
+ "legend": {
16
+ "type": "string",
17
+ "default": "Date of Birth",
18
+ "description": "Legend text for the fieldset."
19
+ },
20
+ "groupHint": {
21
+ "type": "string",
22
+ "default": "Select a month. Enter 1 or 2 digits for the day and 4 digits for the year.",
23
+ "description": "Visible hint shown once for the whole group. Hidden from screen readers (aria-hidden) since each field has its own hint."
24
+ },
25
+ "monthLabel": {
26
+ "type": "string",
27
+ "default": "Month",
28
+ "description": "Label text for the month select."
29
+ },
30
+ "dayLabel": {
31
+ "type": "string",
32
+ "default": "Day",
33
+ "description": "Label text for the day input."
34
+ },
35
+ "yearLabel": {
36
+ "type": "string",
37
+ "default": "Year",
38
+ "description": "Label text for the year input."
39
+ },
40
+ "monthHint": {
41
+ "type": "string",
42
+ "default": "Select a month from the dropdown.",
43
+ "description": "Screen-reader-only hint for the month field."
44
+ },
45
+ "dayHint": {
46
+ "type": "string",
47
+ "default": "Enter 1 or 2 digits for the day.",
48
+ "description": "Screen-reader-only hint for the day field."
49
+ },
50
+ "yearHint": {
51
+ "type": "string",
52
+ "default": "Enter 4 digits for the year.",
53
+ "description": "Screen-reader-only hint for the year field."
54
+ },
55
+ "monthName": {
56
+ "type": "string",
57
+ "description": "name attribute for the month select. Defaults to <id>-month."
58
+ },
59
+ "dayName": {
60
+ "type": "string",
61
+ "description": "name attribute for the day input. Defaults to <id>-day."
62
+ },
63
+ "yearName": {
64
+ "type": "string",
65
+ "description": "name attribute for the year input. Defaults to <id>-year."
66
+ },
67
+ "defaultMonth": {
68
+ "type": "string",
69
+ "description": "Initial selected month value (\"1\"-\"12\")."
70
+ },
71
+ "defaultDay": {
72
+ "type": "string",
73
+ "description": "Initial day value."
74
+ },
75
+ "defaultYear": {
76
+ "type": "string",
77
+ "description": "Initial year value."
78
+ },
79
+ "disabled": {
80
+ "type": "boolean",
81
+ "default": false,
82
+ "description": "Disables all three fields."
83
+ },
84
+ "ariaDisabled": {
85
+ "type": "boolean",
86
+ "default": false,
87
+ "description": "Marks all three fields aria-disabled without preventing interaction, matching USWDS's aria-disabled variant."
88
+ },
89
+ "required": {
90
+ "type": "boolean",
91
+ "default": false,
92
+ "description": "Marks the fieldset and all three fields as required."
93
+ },
94
+ "error": {
95
+ "type": "string",
96
+ "description": "Error message shown once below the fields, referenced by all three fields' aria-describedby."
97
+ },
98
+ "className": {
99
+ "type": "string",
100
+ "default": "",
101
+ "description": "Additional classes for the usa-fieldset wrapper."
102
+ }
103
+ }
104
+ }