@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
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@solexllc/usx-react",
3
+ "version": "0.1.0",
4
+ "description": "React component library for USX.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/solexconsulting/usx.git",
9
+ "directory": "packages/usx-react"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "type": "module",
15
+ "main": "dist/index.cjs",
16
+ "module": "dist/index.js",
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.cjs"
21
+ }
22
+ },
23
+ "files": [
24
+ "src",
25
+ "dist"
26
+ ],
27
+ "scripts": {
28
+ "build": "vite build"
29
+ },
30
+ "dependencies": {
31
+ "@solexllc/usx": "workspace:*",
32
+ "@solexllc/usx-theme": "workspace:*",
33
+ "@solexllc/usx-uswds-fixes": "workspace:*",
34
+ "classnames": "^2.5.1",
35
+ "prop-types": "^15.8.1"
36
+ },
37
+ "devDependencies": {
38
+ "@vitejs/plugin-react": "^4.3.4",
39
+ "react": "^18.3.1",
40
+ "react-dom": "^18.3.1",
41
+ "sass": "^1.98.0",
42
+ "vite": "^6.4.1"
43
+ },
44
+ "peerDependencies": {
45
+ "react": ">=17",
46
+ "react-dom": ">=17"
47
+ }
48
+ }
@@ -0,0 +1,170 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classnames from 'classnames';
4
+
5
+ function AccordionItem({
6
+ title,
7
+ id,
8
+ content,
9
+ expanded,
10
+ className,
11
+ headingLevel,
12
+ handleToggle,
13
+ }) {
14
+ const headingClasses = classnames('usa-accordion__heading', className)
15
+ const contentClasses = classnames(
16
+ 'usa-accordion__content',
17
+ 'usa-prose',
18
+ className
19
+ )
20
+
21
+ const Heading = headingLevel
22
+
23
+ const handleClick = (e) => {
24
+ // Prevent default navigation/behavior and stop other listeners
25
+ // (including non-React handlers added by imported JS) from running.
26
+ if (e && typeof e.preventDefault === 'function') e.preventDefault();
27
+ if (e && typeof e.stopImmediatePropagation === 'function') e.stopImmediatePropagation();
28
+ if (e && typeof e.stopPropagation === 'function') e.stopPropagation();
29
+ handleToggle(e)
30
+ }
31
+
32
+ return (
33
+ <>
34
+ <Heading id={`${id}-heading`} className={headingClasses}>
35
+ <button
36
+ type="button"
37
+ className="usa-accordion__button"
38
+ aria-expanded={expanded}
39
+ aria-controls={`${id}-content`}
40
+ data-testid={`accordionButton_${id}`}
41
+ onClickCapture={handleClick}>
42
+ {title}
43
+ </button>
44
+ </Heading>
45
+ <div
46
+ id={`${id}-content`}
47
+ aria-labelledby={`${id}-heading`}
48
+ data-testid={`accordionItem_${id}`}
49
+ className={contentClasses}
50
+ hidden={!expanded}>
51
+ {content}
52
+ </div>
53
+ </>
54
+ )
55
+ };
56
+
57
+ function buildExpansions(
58
+ items,
59
+ multiselectable,
60
+ savedExpansions = new Map()
61
+ ) {
62
+ const lastExpandedItem = multiselectable
63
+ ? undefined
64
+ : items.findLast((item) => item.expanded || savedExpansions.get(item.id))
65
+ return items.reduce((map, item) => {
66
+ map.set(
67
+ item.id,
68
+ multiselectable
69
+ ? (savedExpansions.get(item.id) ?? item.expanded)
70
+ : !!lastExpandedItem && item.id === lastExpandedItem.id
71
+ )
72
+ return map
73
+ }, new Map())
74
+ }
75
+
76
+ AccordionItem.propTypes = {
77
+ title: PropTypes.node.isRequired,
78
+ id: PropTypes.string.isRequired,
79
+ content: PropTypes.node.isRequired,
80
+ expanded: PropTypes.bool,
81
+ className: PropTypes.string,
82
+ headingLevel: PropTypes.string,
83
+ handleToggle: PropTypes.func,
84
+ }
85
+
86
+ Accordion.propTypes = {
87
+ id: PropTypes.string,
88
+ bordered: PropTypes.bool,
89
+ items: PropTypes.arrayOf(PropTypes.shape(AccordionItem.propTypes)),
90
+ multiselectable: PropTypes.bool,
91
+ headingLevel: PropTypes.string,
92
+ className: PropTypes.string,
93
+ };
94
+
95
+ export function Accordion({
96
+ id,
97
+ bordered = false,
98
+ items = [],
99
+ multiselectable = false,
100
+ headingLevel = 'h3',
101
+ className = '',
102
+ ...props
103
+ }) {
104
+ const [savedExpansions, setSavedExpansions] = useState(() =>
105
+ buildExpansions(items, multiselectable)
106
+ )
107
+
108
+ const [prevItems, setPrevItems] = useState(items)
109
+ useEffect(() => {
110
+ if (items !== prevItems) {
111
+ setPrevItems(items)
112
+ }
113
+ }, [items, prevItems])
114
+
115
+ useEffect(() => {
116
+ if (items !== prevItems) {
117
+ setSavedExpansions((prevExpansions) =>
118
+ buildExpansions(items, multiselectable, prevExpansions)
119
+ )
120
+ }
121
+ }, [items, multiselectable, prevItems])
122
+
123
+ const accordionClasses = classnames(
124
+ 'usa-accordion',
125
+ 'usx-accordion',
126
+ bordered && 'usa-accordion--bordered',
127
+ className
128
+ )
129
+
130
+
131
+ const toggleItem = (itemId) => {
132
+ setSavedExpansions((prevExpansions) => {
133
+ const updatedExpansions = new Map(prevExpansions)
134
+ if (updatedExpansions.get(itemId)) {
135
+ updatedExpansions.set(itemId, false)
136
+ } else {
137
+ if (!multiselectable) {
138
+ updatedExpansions.forEach((_val, key, map) => map.set(key, false))
139
+ }
140
+ updatedExpansions.set(itemId, true)
141
+ }
142
+ return updatedExpansions
143
+ })
144
+ }
145
+
146
+ return (
147
+ <div
148
+ id={id}
149
+ className={accordionClasses}
150
+ data-allow-multiple={multiselectable}
151
+ {...props}
152
+ >
153
+ {items.map((item) => (
154
+ <AccordionItem
155
+ key={item.id}
156
+ {...item}
157
+ expanded={savedExpansions.get(item.id) ?? false}
158
+ handleToggle={(e) => {
159
+ if (item.handleToggle) item.handleToggle(e)
160
+ toggleItem(item.id)
161
+ }}
162
+ headingLevel={headingLevel}
163
+ className={className}
164
+ />
165
+ ))}
166
+ </div>
167
+ );
168
+ }
169
+
170
+ export default Accordion;
@@ -0,0 +1,47 @@
1
+ <div
2
+ id="{{ id }}"
3
+ class="usa-accordion usx-accordion {% if bordered %}usa-accordion--bordered{% endif %} {{ className }}"
4
+ {% if multiselectable %}
5
+ data-allow-multiple="true"
6
+ {% endif %}
7
+ >
8
+ {% for item in items %}
9
+ {% if headingLevel == 'h1' %}
10
+ <h1 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ className }}">
11
+ {% elif headingLevel == 'h2' %}
12
+ <h2 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ className }}">
13
+ {% elif headingLevel == 'h4' %}
14
+ <h4 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ className }}">
15
+ {% else %}
16
+ <h3 id="{{ id }}-{{ forloop.counter0 }}-heading" class="usa-accordion__heading {{ className }}">
17
+ {% endif %}
18
+ <button
19
+ class="usa-accordion__button"
20
+ aria-expanded="false"
21
+ aria-controls="{{ id }}-{{ forloop.counter0 }}-content"
22
+ type="button"
23
+ >
24
+ {{ item.title }}
25
+ </button>
26
+ {% if headingLevel == 'h1' %}
27
+ </h1>
28
+ {% elif headingLevel == 'h2' %}
29
+ </h2>
30
+ {% elif headingLevel == 'h4' %}
31
+ </h4>
32
+ {% else %}
33
+ </h3>
34
+ {% endif %}
35
+
36
+ <div
37
+ id="{{ id }}-{{ forloop.counter0 }}-content"
38
+ class="usa-accordion__content"
39
+ aria-labelledby="{{ id }}-{{ forloop.counter0 }}-heading"
40
+ hidden
41
+ >
42
+ {{ item.content }}
43
+ </div>
44
+
45
+ {% endfor %}
46
+
47
+ </div>
@@ -0,0 +1,304 @@
1
+ <h3 class="site-preview-heading">Borderless</h3>
2
+ <div class="usa-accordion">
3
+ <h4 class="usa-accordion__heading">
4
+ <button
5
+ type="button"
6
+ class="usa-accordion__button"
7
+ aria-expanded="true"
8
+ aria-controls="a1"
9
+ >
10
+ First Amendment
11
+ </button>
12
+ </h4>
13
+ <div id="a1" class="usa-accordion__content usa-prose">
14
+ <p>
15
+ Congress shall make no law respecting an establishment of religion, or
16
+ prohibiting the free exercise thereof; or abridging the freedom of speech,
17
+ or of the press; or the right of the people peaceably to assemble, and to
18
+ petition the Government for a redress of grievances.
19
+ </p>
20
+ </div>
21
+ <h4 class="usa-accordion__heading">
22
+ <button
23
+ type="button"
24
+ class="usa-accordion__button"
25
+ aria-expanded="false"
26
+ aria-controls="a2"
27
+ >
28
+ Second Amendment
29
+ </button>
30
+ </h4>
31
+ <div id="a2" class="usa-accordion__content usa-prose">
32
+ <p>
33
+ A well regulated Militia, being necessary to the security of a free State,
34
+ the right of the people to keep and bear Arms, shall not be infringed.
35
+ </p>
36
+ <ul>
37
+ <li>This is a list item</li>
38
+ <li>Another list item</li>
39
+ </ul>
40
+ </div>
41
+ <h4 class="usa-accordion__heading">
42
+ <button
43
+ type="button"
44
+ class="usa-accordion__button"
45
+ aria-expanded="false"
46
+ aria-controls="a3"
47
+ >
48
+ Third Amendment
49
+ </button>
50
+ </h4>
51
+ <div id="a3" class="usa-accordion__content usa-prose">
52
+ <p>
53
+ No Soldier shall, in time of peace be quartered in any house, without the
54
+ consent of the Owner, nor in time of war, but in a manner to be prescribed
55
+ by law.
56
+ </p>
57
+ </div>
58
+ <h4 class="usa-accordion__heading">
59
+ <button
60
+ type="button"
61
+ class="usa-accordion__button"
62
+ aria-expanded="false"
63
+ aria-controls="a4"
64
+ >
65
+ Fourth Amendment
66
+ </button>
67
+ </h4>
68
+ <div id="a4" class="usa-accordion__content usa-prose">
69
+ <p>
70
+ The right of the people to be secure in their persons, houses, papers, and
71
+ effects, against unreasonable searches and seizures, shall not be
72
+ violated, and no Warrants shall issue, but upon probable cause, supported
73
+ by Oath or affirmation, and particularly describing the place to be
74
+ searched, and the persons or things to be seized.
75
+ </p>
76
+ </div>
77
+ <h4 class="usa-accordion__heading">
78
+ <button
79
+ type="button"
80
+ class="usa-accordion__button"
81
+ aria-expanded="false"
82
+ aria-controls="a5"
83
+ >
84
+ Fifth Amendment
85
+ </button>
86
+ </h4>
87
+ <div id="a5" class="usa-accordion__content usa-prose">
88
+ <p>
89
+ No person shall be held to answer for a capital, or otherwise infamous
90
+ crime, unless on a presentment or indictment of a Grand Jury, except in
91
+ cases arising in the land or naval forces, or in the Militia, when in
92
+ actual service in time of War or public danger; nor shall any person be
93
+ subject for the same offence to be twice put in jeopardy of life or limb;
94
+ nor shall be compelled in any criminal case to be a witness against
95
+ himself, nor be deprived of life, liberty, or property, without due
96
+ process of law; nor shall private property be taken for public use,
97
+ without just compensation.
98
+ </p>
99
+ </div>
100
+ </div>
101
+
102
+ <h3 class="site-preview-heading">Bordered</h3>
103
+
104
+ <div class="usa-accordion usa-accordion--bordered usa-accordion--icon-start">
105
+ <h4 class="usa-accordion__heading">
106
+ <button
107
+ type="button"
108
+ class="usa-accordion__button"
109
+ aria-expanded="true"
110
+ aria-controls="b-a1"
111
+ >
112
+ First Amendment
113
+ </button>
114
+ </h4>
115
+ <div id="b-a1" class="usa-accordion__content usa-prose">
116
+ <p>
117
+ Congress shall make no law respecting an establishment of religion, or
118
+ prohibiting the free exercise thereof; or abridging the freedom of speech,
119
+ or of the press; or the right of the people peaceably to assemble, and to
120
+ petition the Government for a redress of grievances.
121
+ </p>
122
+ </div>
123
+ <h4 class="usa-accordion__heading">
124
+ <button
125
+ type="button"
126
+ class="usa-accordion__button"
127
+ aria-expanded="false"
128
+ aria-controls="b-a2"
129
+ >
130
+ Second Amendment
131
+ </button>
132
+ </h4>
133
+ <div id="b-a2" class="usa-accordion__content usa-prose">
134
+ <p>
135
+ A well regulated Militia, being necessary to the security of a free State,
136
+ the right of the people to keep and bear Arms, shall not be infringed.
137
+ </p>
138
+ <ul>
139
+ <li>This is a list item</li>
140
+ <li>Another list item</li>
141
+ </ul>
142
+ </div>
143
+ <h4 class="usa-accordion__heading">
144
+ <button
145
+ type="button"
146
+ class="usa-accordion__button"
147
+ aria-expanded="false"
148
+ aria-controls="b-a3"
149
+ >
150
+ Third Amendment
151
+ </button>
152
+ </h4>
153
+ <div id="b-a3" class="usa-accordion__content usa-prose">
154
+ <p>
155
+ No Soldier shall, in time of peace be quartered in any house, without the
156
+ consent of the Owner, nor in time of war, but in a manner to be prescribed
157
+ by law.
158
+ </p>
159
+ </div>
160
+ <h4 class="usa-accordion__heading">
161
+ <button
162
+ type="button"
163
+ class="usa-accordion__button"
164
+ aria-expanded="false"
165
+ aria-controls="b-a4"
166
+ >
167
+ Fourth Amendment
168
+ </button>
169
+ </h4>
170
+ <div id="b-a4" class="usa-accordion__content usa-prose">
171
+ <p>
172
+ The right of the people to be secure in their persons, houses, papers, and
173
+ effects, against unreasonable searches and seizures, shall not be
174
+ violated, and no Warrants shall issue, but upon probable cause, supported
175
+ by Oath or affirmation, and particularly describing the place to be
176
+ searched, and the persons or things to be seized.
177
+ </p>
178
+ </div>
179
+ <h4 class="usa-accordion__heading">
180
+ <button
181
+ type="button"
182
+ class="usa-accordion__button"
183
+ aria-expanded="false"
184
+ aria-controls="b-a5"
185
+ >
186
+ Fifth Amendment
187
+ </button>
188
+ </h4>
189
+ <div id="b-a5" class="usa-accordion__content usa-prose">
190
+ <p>
191
+ No person shall be held to answer for a capital, or otherwise infamous
192
+ crime, unless on a presentment or indictment of a Grand Jury, except in
193
+ cases arising in the land or naval forces, or in the Militia, when in
194
+ actual service in time of War or public danger; nor shall any person be
195
+ subject for the same offence to be twice put in jeopardy of life or limb;
196
+ nor shall be compelled in any criminal case to be a witness against
197
+ himself, nor be deprived of life, liberty, or property, without due
198
+ process of law; nor shall private property be taken for public use,
199
+ without just compensation.
200
+ </p>
201
+ </div>
202
+ </div>
203
+
204
+ <h3 class="site-preview-heading">Multiselectable</h3>
205
+
206
+ <div class="usa-accordion usa-accordion--multiselectable usa-accordion--icon-end" data-allow-multiple>
207
+ <h4 class="usa-accordion__heading">
208
+ <button
209
+ type="button"
210
+ class="usa-accordion__button"
211
+ aria-expanded="true"
212
+ aria-controls="m-a1"
213
+ >
214
+ First Amendment
215
+ </button>
216
+ </h4>
217
+ <div id="m-a1" class="usa-accordion__content usa-prose">
218
+ <p>
219
+ Congress shall make no law respecting an establishment of religion, or
220
+ prohibiting the free exercise thereof; or abridging the freedom of speech,
221
+ or of the press; or the right of the people peaceably to assemble, and to
222
+ petition the Government for a redress of grievances.
223
+ </p>
224
+ </div>
225
+ <h4 class="usa-accordion__heading">
226
+ <button
227
+ type="button"
228
+ class="usa-accordion__button"
229
+ aria-expanded="false"
230
+ aria-controls="m-a2"
231
+ >
232
+ Second Amendment
233
+ </button>
234
+ </h4>
235
+ <div id="m-a2" class="usa-accordion__content usa-prose">
236
+ <p>
237
+ A well regulated Militia, being necessary to the security of a free State,
238
+ the right of the people to keep and bear Arms, shall not be infringed.
239
+ </p>
240
+ <ul>
241
+ <li>This is a list item</li>
242
+ <li>Another list item</li>
243
+ </ul>
244
+ </div>
245
+ <h4 class="usa-accordion__heading">
246
+ <button
247
+ type="button"
248
+ class="usa-accordion__button"
249
+ aria-expanded="false"
250
+ aria-controls="m-a3"
251
+ >
252
+ Third Amendment
253
+ </button>
254
+ </h4>
255
+ <div id="m-a3" class="usa-accordion__content usa-prose">
256
+ <p>
257
+ No Soldier shall, in time of peace be quartered in any house, without the
258
+ consent of the Owner, nor in time of war, but in a manner to be prescribed
259
+ by law.
260
+ </p>
261
+ </div>
262
+ <h4 class="usa-accordion__heading">
263
+ <button
264
+ type="button"
265
+ class="usa-accordion__button"
266
+ aria-expanded="false"
267
+ aria-controls="m-a4"
268
+ >
269
+ Fourth Amendment
270
+ </button>
271
+ </h4>
272
+ <div id="m-a4" class="usa-accordion__content usa-prose">
273
+ <p>
274
+ The right of the people to be secure in their persons, houses, papers, and
275
+ effects, against unreasonable searches and seizures, shall not be
276
+ violated, and no Warrants shall issue, but upon probable cause, supported
277
+ by Oath or affirmation, and particularly describing the place to be
278
+ searched, and the persons or things to be seized.
279
+ </p>
280
+ </div>
281
+ <h4 class="usa-accordion__heading">
282
+ <button
283
+ type="button"
284
+ class="usa-accordion__button"
285
+ aria-expanded="false"
286
+ aria-controls="m-a5"
287
+ >
288
+ Fifth Amendment
289
+ </button>
290
+ </h4>
291
+ <div id="m-a5" class="usa-accordion__content usa-prose">
292
+ <p>
293
+ No person shall be held to answer for a capital, or otherwise infamous
294
+ crime, unless on a presentment or indictment of a Grand Jury, except in
295
+ cases arising in the land or naval forces, or in the Militia, when in
296
+ actual service in time of War or public danger; nor shall any person be
297
+ subject for the same offence to be twice put in jeopardy of life or limb;
298
+ nor shall be compelled in any criminal case to be a witness against
299
+ himself, nor be deprived of life, liberty, or property, without due
300
+ process of law; nor shall private property be taken for public use,
301
+ without just compensation.
302
+ </p>
303
+ </div>
304
+ </div>
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "accordion",
3
+ "template": "accordion/accordion.django.html",
4
+ "version": 1,
5
+ "props": {
6
+ "id": {
7
+ "type": "string",
8
+ "description": "Base ID for the accordion. Each item's ID will be this base plus the item's index."
9
+ },
10
+ "bordered": {
11
+ "type": "boolean",
12
+ "default": false,
13
+ "description": "Whether the accordion has borders."
14
+ },
15
+ "items": {
16
+ "type": "array",
17
+ "default": [],
18
+ "description": "An array of accordion items."
19
+ },
20
+ "multiselectable": {
21
+ "type": "boolean",
22
+ "default": false,
23
+ "description": "Whether multiple accordion items can be expanded at the same time."
24
+ },
25
+ "className": {
26
+ "type": "string",
27
+ "default": "",
28
+ "description": "Additional CSS classes to apply to the accordion. Use usa-accordion--icon-start or usa-accordion--icon-end to set icon position for this accordion. For live global theming, set --usx-accordion-icon-position to 1.25rem auto (start) or auto 1.25rem (end)."
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,88 @@
1
+ import React from 'react';
2
+ import ClassNames from 'classnames';
3
+
4
+ export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ heading?: string;
6
+ text?: string;
7
+ variant?: 'info' | 'warning' | 'success' | 'error' | 'emergency';
8
+ slim?: boolean;
9
+ noIcon?: boolean;
10
+ className?: string;
11
+ role?: string;
12
+ ariaLabel?: string;
13
+ ariaLabelledby?: string;
14
+ onDismiss?: () => void;
15
+ children?: React.ReactNode;
16
+ }
17
+
18
+ export default function Alert({
19
+ heading,
20
+ text,
21
+ variant,
22
+ slim = false,
23
+ noIcon = false,
24
+ className = '',
25
+ role,
26
+ ariaLabel,
27
+ ariaLabelledby,
28
+ onDismiss = undefined,
29
+ children = null,
30
+ ...props
31
+ }: AlertProps) {
32
+ const normalizedVariant = variant && ['info', 'warning', 'success', 'error', 'emergency'].includes(variant)
33
+ ? variant
34
+ : null;
35
+
36
+ const classes = ClassNames(
37
+ 'usa-alert',
38
+ 'usx-alert',
39
+ normalizedVariant ? `usa-alert--${normalizedVariant}` : '',
40
+ slim ? 'usa-alert--slim' : '',
41
+ noIcon ? 'usa-alert--no-icon' : '',
42
+ className
43
+ );
44
+
45
+ const resolvedRole = role || (
46
+ normalizedVariant === 'error' || normalizedVariant === 'emergency'
47
+ ? 'alert'
48
+ : normalizedVariant === 'success'
49
+ ? 'status'
50
+ : 'region'
51
+ );
52
+
53
+ const accessibilityProps: React.HTMLAttributes<HTMLDivElement> = {
54
+ role: resolvedRole,
55
+ };
56
+
57
+ if (ariaLabelledby) {
58
+ accessibilityProps['aria-labelledby'] = ariaLabelledby;
59
+ } else if (ariaLabel) {
60
+ accessibilityProps['aria-label'] = ariaLabel;
61
+ } else if (resolvedRole === 'region') {
62
+ accessibilityProps['aria-label'] = heading || `${normalizedVariant} alert`;
63
+ }
64
+
65
+ return (
66
+ <div className={classes} {...accessibilityProps} {...props}>
67
+ <div className="usa-alert__body">
68
+ {!slim && heading ? <h4 className="usa-alert__heading">{heading}</h4> : null}
69
+ {children ? (
70
+ <div className="usa-alert__text">
71
+ {children}
72
+ </div>
73
+ ) : (
74
+ <p className="usa-alert__text">
75
+ {text}
76
+ </p>
77
+ )}
78
+ {onDismiss && (
79
+ <button className="usx-alert__dismiss" aria-label="Dismiss alert" onClick={onDismiss}>
80
+ <svg className="usa-icon usa-icon--size-3" aria-hidden="true" focusable="false" role="img">
81
+ <use href="./img/sprite.svg#close" />
82
+ </svg>
83
+ </button>
84
+ )}
85
+ </div>
86
+ </div>
87
+ );
88
+ }