@solexllc/usx-react 0.12.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +15 -0
  2. package/dist/{Popover-BzDCTuQM.cjs → Popover-Bg4-2-cU.cjs} +3 -0
  3. package/dist/{Popover-LToVWsWc.js → Popover-CqHczzNE.js} +3 -0
  4. package/dist/chat.cjs +7 -2
  5. package/dist/chat.js +7 -2
  6. package/dist/index.cjs +83 -56
  7. package/dist/index.js +86 -59
  8. package/package.json +4 -4
  9. package/src/components/accordion/Accordion.tsx +9 -57
  10. package/src/components/accordion/accordion.django.html +10 -20
  11. package/src/components/accordion/config.json +8 -2
  12. package/src/components/accordion-item/AccordionItem.tsx +54 -0
  13. package/src/components/accordion-item/accordion-item.django.html +19 -0
  14. package/src/components/accordion-item/accordion-item.html +8 -0
  15. package/src/components/accordion-item/config.json +55 -0
  16. package/src/components/alert/alert.django-snapshot.html +4 -4
  17. package/src/components/avatar/avatar.django-snapshot.html +6 -2
  18. package/src/components/avatar/avatar.react-snapshot.html +6 -3
  19. package/src/components/avatar/config.json +4 -2
  20. package/src/components/avatar-group/avatar-group.django-snapshot.html +176 -176
  21. package/src/components/avatar-group/avatar-group.react-snapshot.html +198 -167
  22. package/src/components/avatar-group/config.json +12 -6
  23. package/src/components/banner/banner.django-snapshot.html +2 -2
  24. package/src/components/button/Button.tsx +3 -0
  25. package/src/components/button/button.django-snapshot.html +64 -0
  26. package/src/components/button/button.django.html +2 -0
  27. package/src/components/button/button.react-snapshot.html +64 -0
  28. package/src/components/button/config.json +6 -1
  29. package/src/components/card/card.django-snapshot.html +43 -0
  30. package/src/components/card/card.react-snapshot.html +36 -0
  31. package/src/components/chat/chat.django-snapshot.html +90 -26
  32. package/src/components/chat/chat.html +10 -10
  33. package/src/components/chat/chat.react-snapshot.html +49 -49
  34. package/src/components/chat-composer/ChatComposer.tsx +3 -0
  35. package/src/components/chat-composer/chat-composer.django-snapshot.html +10 -10
  36. package/src/components/chat-composer/chat-composer.django.html +2 -2
  37. package/src/components/chat-composer/chat-composer.html +10 -10
  38. package/src/components/chat-composer/chat-composer.react-snapshot.html +10 -10
  39. package/src/components/chat-composer/chat-formatting.django.html +8 -8
  40. package/src/components/chat-window/ChatWindow.tsx +3 -1
  41. package/src/components/chat-window/chat-window.django-snapshot.html +7 -5
  42. package/src/components/chat-window/chat-window.django.html +3 -3
  43. package/src/components/chat-window/chat-window.html +1 -1
  44. package/src/components/chat-window/chat-window.react-snapshot.html +7 -7
  45. package/src/components/checkbox/checkbox.django-snapshot.html +2 -2
  46. package/src/components/data-table/data-table.django-snapshot.html +4 -5
  47. package/src/components/data-table/data-table.react-snapshot.html +4 -4
  48. package/src/components/drawer/drawer.django-snapshot.html +53 -30
  49. package/src/components/error-page/error-page.django-snapshot.html +20 -7
  50. package/src/components/fieldset/fieldset.django-snapshot.html +1 -6
  51. package/src/components/form-group/form-group.django-snapshot.html +0 -2
  52. package/src/components/header/header.django-snapshot.html +3 -3
  53. package/src/components/header/header.html +1 -1
  54. package/src/components/header/header.react-snapshot.html +3 -3
  55. package/src/components/identifier/config.json +4 -2
  56. package/src/components/identifier/identifier.django-snapshot.html +13 -16
  57. package/src/components/identifier/identifier.react-snapshot.html +13 -15
  58. package/src/components/image/image.django-snapshot.html +6 -6
  59. package/src/components/layout/layout.django-snapshot.html +2 -0
  60. package/src/components/modal/Modal.tsx +4 -3
  61. package/src/components/modal/config.json +3 -2
  62. package/src/components/modal/modal.django-snapshot.html +70 -14
  63. package/src/components/modal/modal.django.html +7 -9
  64. package/src/components/modal/modal.html +4 -4
  65. package/src/components/modal/modal.react-snapshot.html +64 -4
  66. package/src/components/page/Page.tsx +10 -7
  67. package/src/components/page/page.django-snapshot.html +5 -8
  68. package/src/components/page/page.django.html +2 -2
  69. package/src/components/page/page.html +1 -2
  70. package/src/components/page/page.react-snapshot.html +5 -8
  71. package/src/components/pagination/navigation/PaginationNavigation.tsx +2 -0
  72. package/src/components/pagination/navigation/pagination-navigation.django.html +2 -0
  73. package/src/components/pagination/pagination.django-snapshot.html +62 -0
  74. package/src/components/pagination/pagination.django.html +3 -1
  75. package/src/components/pagination/pagination.html +46 -0
  76. package/src/components/pagination/pagination.react-snapshot.html +48 -0
  77. package/src/components/pagination/summary/PaginationSummary.tsx +1 -1
  78. package/src/components/pagination/summary/pagination-summary.django.html +1 -1
  79. package/src/components/popover/Popover.tsx +1 -0
  80. package/src/components/popover/popover.django-snapshot.html +37 -1
  81. package/src/components/popover/popover.django.html +1 -1
  82. package/src/components/popover/popover.react-snapshot.html +30 -3
  83. package/src/components/section/Section.tsx +3 -1
  84. package/src/components/site-alert/site-alert.django-snapshot.html +8 -8
  85. package/src/components/swap/Swap.tsx +35 -3
  86. package/src/components/swap/config.json +28 -1
  87. package/src/components/swap/swap.django-snapshot.html +29 -7
  88. package/src/components/swap/swap.django.html +15 -1
  89. package/src/components/swap/swap.react-snapshot.html +34 -4
  90. package/src/components/theme-picker/ThemePicker.tsx +48 -42
  91. package/src/components/theme-picker/config.json +27 -29
  92. package/src/components/theme-picker/theme-picker-select.django.html +1 -1
  93. package/src/components/theme-picker/theme-picker.django-snapshot.html +283 -78
  94. package/src/components/theme-picker/theme-picker.django.html +24 -11
  95. package/src/components/theme-picker/theme-picker.html +155 -54
  96. package/src/components/theme-picker/theme-picker.react-snapshot.html +265 -67
  97. package/src/index.js +1 -0
package/README.md CHANGED
@@ -20,6 +20,21 @@ module also observes newly inserted tables. Enhanced components receive
20
20
  to preview their no-JavaScript fallback. See the Storybook
21
21
  **Documentation → USX React → JavaScript Enhancement** page for examples.
22
22
 
23
+ ## Accordion items
24
+
25
+ `Accordion` renders its `items` using the exported `AccordionItem`
26
+ subcomponent. Each item accepts `id`, `title`, `content` or `children`, `expanded`, and a
27
+ React `handleToggle` callback. When an item has no `id`, Accordion derives one
28
+ from its own `id` and the item index; provide a unique Accordion ID. The
29
+ Accordion's `headingAs`, `headingClassName`, and `contentClassName` apply to
30
+ all items and override those item-level values.
31
+ When both `children` and `content` are supplied, `children` takes precedence.
32
+
33
+ `AccordionItem` can also be rendered independently inside an
34
+ `usa-accordion` container. In that case its ID is required and its own heading
35
+ level and classes apply. Load or initialize the USWDS accordion enhancement
36
+ on the container as described above.
37
+
23
38
  ## Optional Chat
24
39
 
25
40
  Chat and all its parts are available through a separate entry point in this
@@ -349,6 +349,7 @@ function Button({
349
349
  href,
350
350
  isExternal = false,
351
351
  big = false,
352
+ tighten = false,
352
353
  inverse = false,
353
354
  ghost = false,
354
355
  loading = false,
@@ -379,6 +380,7 @@ function Button({
379
380
  "usx-button",
380
381
  variant && variantClasses[variant],
381
382
  big && "usa-button--big",
383
+ tighten && "usx-button--tight",
382
384
  inverse && "usa-button--inverse",
383
385
  ghost && "usx-button--ghost",
384
386
  className
@@ -921,6 +923,7 @@ function Popover({
921
923
  Button,
922
924
  {
923
925
  variant: "unstyled",
926
+ tighten: true,
924
927
  className: "usx-popover__header-action usx-popover__header-close",
925
928
  "aria-label": closeIconLabel,
926
929
  iconProps: [{ name: "close" }],
@@ -348,6 +348,7 @@ function Button({
348
348
  href,
349
349
  isExternal = false,
350
350
  big = false,
351
+ tighten = false,
351
352
  inverse = false,
352
353
  ghost = false,
353
354
  loading = false,
@@ -378,6 +379,7 @@ function Button({
378
379
  "usx-button",
379
380
  variant && variantClasses[variant],
380
381
  big && "usa-button--big",
382
+ tighten && "usx-button--tight",
381
383
  inverse && "usa-button--inverse",
382
384
  ghost && "usx-button--ghost",
383
385
  className
@@ -920,6 +922,7 @@ function Popover({
920
922
  Button,
921
923
  {
922
924
  variant: "unstyled",
925
+ tighten: true,
923
926
  className: "usx-popover__header-action usx-popover__header-close",
924
927
  "aria-label": closeIconLabel,
925
928
  iconProps: [{ name: "close" }],
package/dist/chat.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
- const Popover = require("./Popover-BzDCTuQM.cjs");
4
+ const Popover = require("./Popover-Bg4-2-cU.cjs");
5
5
  const React = require("react");
6
6
  function ChatWindow({
7
7
  id,
@@ -41,6 +41,7 @@ function ChatWindow({
41
41
  Popover.Button,
42
42
  {
43
43
  variant: "unstyled",
44
+ tighten: true,
44
45
  className: "usx-popover__header-action",
45
46
  "aria-label": view === "thread" ? "Back to conversation" : "Back",
46
47
  iconProps: [{ name: "arrow_back" }],
@@ -52,6 +53,7 @@ function ChatWindow({
52
53
  Popover.Button,
53
54
  {
54
55
  variant: "unstyled",
56
+ tighten: true,
55
57
  className: "usx-popover__header-action",
56
58
  "aria-label": "New message",
57
59
  iconProps: [{ name: "add" }],
@@ -89,7 +91,7 @@ function ChatWindow({
89
91
  ],
90
92
  summaryProps: {
91
93
  ariaLabel: "Conversation actions",
92
- className: "usa-button usx-button usa-button--unstyled usx-popover__header-action",
94
+ className: "usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action",
93
95
  children: /* @__PURE__ */ jsxRuntime.jsx(Popover.Icon, { name: "more_vert" })
94
96
  },
95
97
  children: actions
@@ -984,6 +986,7 @@ function ChatComposer({
984
986
  ].map(([format, label, shortcut, icon]) => ({
985
987
  type: "button",
986
988
  variant: "outline",
989
+ tighten: true,
987
990
  className: "usx-chat__format-button",
988
991
  disabled,
989
992
  "aria-label": label,
@@ -1020,6 +1023,7 @@ function ChatComposer({
1020
1023
  {
1021
1024
  type: "button",
1022
1025
  variant: "outline",
1026
+ tighten: true,
1023
1027
  "aria-label": "Attach files",
1024
1028
  title: "Attach files",
1025
1029
  extraAttributes: { "data-usx-chat-attach": "" },
@@ -1031,6 +1035,7 @@ function ChatComposer({
1031
1035
  {
1032
1036
  type: "button",
1033
1037
  variant: "outline",
1038
+ tighten: true,
1034
1039
  "aria-label": "Show formatting",
1035
1040
  title: "Show formatting",
1036
1041
  "aria-expanded": false,
package/dist/chat.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { P as Popover, B as Button, I as Icon, C as ClassNames$1, a as Image, e as TagGroup, A as Avatar, i as Alert, m as getDefaultExportFromCjs, k as AvatarGroup, T as Tag, j as Clickable, h as Callout, f as Link, b as ButtonGroup, c as TextArea } from "./Popover-LToVWsWc.js";
2
+ import { P as Popover, B as Button, I as Icon, C as ClassNames$1, a as Image, e as TagGroup, A as Avatar, i as Alert, m as getDefaultExportFromCjs, k as AvatarGroup, T as Tag, j as Clickable, h as Callout, f as Link, b as ButtonGroup, c as TextArea } from "./Popover-CqHczzNE.js";
3
3
  import React from "react";
4
4
  function ChatWindow({
5
5
  id,
@@ -39,6 +39,7 @@ function ChatWindow({
39
39
  Button,
40
40
  {
41
41
  variant: "unstyled",
42
+ tighten: true,
42
43
  className: "usx-popover__header-action",
43
44
  "aria-label": view === "thread" ? "Back to conversation" : "Back",
44
45
  iconProps: [{ name: "arrow_back" }],
@@ -50,6 +51,7 @@ function ChatWindow({
50
51
  Button,
51
52
  {
52
53
  variant: "unstyled",
54
+ tighten: true,
53
55
  className: "usx-popover__header-action",
54
56
  "aria-label": "New message",
55
57
  iconProps: [{ name: "add" }],
@@ -87,7 +89,7 @@ function ChatWindow({
87
89
  ],
88
90
  summaryProps: {
89
91
  ariaLabel: "Conversation actions",
90
- className: "usa-button usx-button usa-button--unstyled usx-popover__header-action",
92
+ className: "usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action",
91
93
  children: /* @__PURE__ */ jsx(Icon, { name: "more_vert" })
92
94
  },
93
95
  children: actions
@@ -982,6 +984,7 @@ function ChatComposer({
982
984
  ].map(([format, label, shortcut, icon]) => ({
983
985
  type: "button",
984
986
  variant: "outline",
987
+ tighten: true,
985
988
  className: "usx-chat__format-button",
986
989
  disabled,
987
990
  "aria-label": label,
@@ -1018,6 +1021,7 @@ function ChatComposer({
1018
1021
  {
1019
1022
  type: "button",
1020
1023
  variant: "outline",
1024
+ tighten: true,
1021
1025
  "aria-label": "Attach files",
1022
1026
  title: "Attach files",
1023
1027
  extraAttributes: { "data-usx-chat-attach": "" },
@@ -1029,6 +1033,7 @@ function ChatComposer({
1029
1033
  {
1030
1034
  type: "button",
1031
1035
  variant: "outline",
1036
+ tighten: true,
1032
1037
  "aria-label": "Show formatting",
1033
1038
  title: "Show formatting",
1034
1039
  "aria-expanded": false,
package/dist/index.cjs CHANGED
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
- const Popover = require("./Popover-BzDCTuQM.cjs");
4
+ const Popover = require("./Popover-Bg4-2-cU.cjs");
5
5
  const React = require("react");
6
6
  function AccordionItem({
7
7
  title,
8
8
  id,
9
9
  content,
10
+ children,
10
11
  expanded = false,
11
12
  headingClassName,
12
13
  contentClassName,
@@ -14,11 +15,7 @@ function AccordionItem({
14
15
  handleToggle
15
16
  }) {
16
17
  const headingClasses = Popover.ClassNames("usa-accordion__heading", headingClassName);
17
- const contentClasses = Popover.ClassNames(
18
- "usa-accordion__content",
19
- "usa-prose",
20
- contentClassName
21
- );
18
+ const contentClasses = Popover.ClassNames("usa-accordion__content", "usa-prose", contentClassName);
22
19
  const Heading = headingAs;
23
20
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
24
21
  /* @__PURE__ */ jsxRuntime.jsx(Heading, { id: `${id}-heading`, className: headingClasses, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -39,7 +36,7 @@ function AccordionItem({
39
36
  "aria-labelledby": `${id}-heading`,
40
37
  className: contentClasses,
41
38
  hidden: !expanded,
42
- children: content
39
+ children: children ?? content
43
40
  }
44
41
  )
45
42
  ] });
@@ -72,15 +69,16 @@ function Accordion({
72
69
  "data-allow-multiple": multiselectable ? true : void 0,
73
70
  ...props2,
74
71
  ...extraAttributes,
75
- children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
72
+ children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
76
73
  AccordionItem,
77
74
  {
78
75
  ...item,
76
+ id: item.id || `${id ?? ""}-${index}`,
79
77
  headingAs,
80
78
  headingClassName,
81
79
  contentClassName
82
80
  },
83
- item.id
81
+ item.id || `${id ?? ""}-${index}`
84
82
  ))
85
83
  }
86
84
  );
@@ -1456,6 +1454,7 @@ function TableCell({
1456
1454
  function getPageItems(currentPage, totalPages) {
1457
1455
  const page = (p) => ({ type: "page", page: p });
1458
1456
  const ellipsis = (key) => ({ type: "ellipsis", key });
1457
+ if (totalPages <= 1) return [];
1459
1458
  if (totalPages <= 7) {
1460
1459
  return Array.from({ length: totalPages }, (_, i) => page(i + 1));
1461
1460
  }
@@ -1513,6 +1512,7 @@ function PaginationNavigation({
1513
1512
  onPageChange
1514
1513
  }) {
1515
1514
  const unbounded = totalPages === void 0 || totalPages === null;
1515
+ if (!unbounded && totalPages <= 1) return null;
1516
1516
  const items = unbounded ? getUnboundedPageItems(currentPage) : getPageItems(currentPage, totalPages);
1517
1517
  const isFirstPage = currentPage === 1;
1518
1518
  const isLastPage = !unbounded && currentPage === totalPages;
@@ -1737,7 +1737,7 @@ function PaginationSummary({
1737
1737
  itemLabel = "items",
1738
1738
  className = ""
1739
1739
  }) {
1740
- const firstItem = (currentPage - 1) * pageSize + 1;
1740
+ const firstItem = totalItems === 0 ? 0 : (currentPage - 1) * pageSize + 1;
1741
1741
  const lastItem = Math.min(currentPage * pageSize, totalItems);
1742
1742
  const classes = Popover.ClassNames(
1743
1743
  "usa-label",
@@ -2262,7 +2262,7 @@ function Drawer({
2262
2262
  }
2263
2263
  function Page({
2264
2264
  id = void 0,
2265
- title = "Page title",
2265
+ title,
2266
2266
  titleId = void 0,
2267
2267
  eyebrow = null,
2268
2268
  subtitle = void 0,
@@ -2279,7 +2279,8 @@ function Page({
2279
2279
  const hasSummary = Boolean(subtitle || description || (tagProps == null ? void 0 : tagProps.length));
2280
2280
  const classes = Popover.ClassNames("usx-page", className);
2281
2281
  const pageContent = children || content;
2282
- const labelledBy = ariaLabelledby || titleId || void 0;
2282
+ const hasTitle = Boolean(title) && typeof title !== "boolean" || title === 0;
2283
+ const labelledBy = ariaLabelledby || (hasTitle ? titleId : void 0);
2283
2284
  return /* @__PURE__ */ jsxRuntime.jsxs(
2284
2285
  Element,
2285
2286
  {
@@ -2289,8 +2290,8 @@ function Page({
2289
2290
  "aria-labelledby": labelledBy,
2290
2291
  ...props2,
2291
2292
  children: [
2292
- /* @__PURE__ */ jsxRuntime.jsxs("h1", { id: titleId, className: "usx-page__title", children: [
2293
- eyebrow ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "usx-eyebrow", children: eyebrow }) : null,
2293
+ hasTitle && /* @__PURE__ */ jsxRuntime.jsxs("h1", { id: titleId, className: "usx-page__title", children: [
2294
+ eyebrow && typeof eyebrow !== "boolean" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "usx-eyebrow", children: eyebrow }) : null,
2294
2295
  title
2295
2296
  ] }),
2296
2297
  hasSummary && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usx-page__summary", children: [
@@ -3754,7 +3755,7 @@ function Modal({
3754
3755
  description,
3755
3756
  actionProps = [
3756
3757
  { children: "Continue", variant: "primary", extraAttributes: { "data-close-modal": true } },
3757
- { children: "Go back", variant: "unstyled", className: "padding-105 text-center", extraAttributes: { "data-close-modal": true } }
3758
+ { children: "Go back", variant: "unstyled", tighten: true, className: "text-center", extraAttributes: { "data-close-modal": true } }
3758
3759
  ],
3759
3760
  size = "default",
3760
3761
  forceAction = false,
@@ -3767,6 +3768,7 @@ function Modal({
3767
3768
  "usa-modal--lg": size === "lg",
3768
3769
  "usx-modal--lg-collapsed": size === "lg-collapsed"
3769
3770
  }, className);
3771
+ const hasChildren = children != null;
3770
3772
  return /* @__PURE__ */ jsxRuntime.jsx(
3771
3773
  "div",
3772
3774
  {
@@ -3780,7 +3782,7 @@ function Modal({
3780
3782
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usa-modal__content", children: [
3781
3783
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usa-modal__main", children: [
3782
3784
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "usa-modal__heading", id: `${id}-heading`, children: heading }),
3783
- /* @__PURE__ */ jsxRuntime.jsx(Prose, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { id: `${id}-description`, children: children ?? description }) }),
3785
+ /* @__PURE__ */ jsxRuntime.jsx(Prose, { id: hasChildren ? `${id}-description` : void 0, children: hasChildren ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }) : /* @__PURE__ */ jsxRuntime.jsx("p", { id: `${id}-description`, children: description }) }),
3784
3786
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-modal__footer", children: /* @__PURE__ */ jsxRuntime.jsx(Popover.ButtonGroup, { buttonProps: actionProps }) })
3785
3787
  ] }),
3786
3788
  !forceAction && /* @__PURE__ */ jsxRuntime.jsx(
@@ -4123,6 +4125,10 @@ const Swap = ({
4123
4125
  children = null,
4124
4126
  className = "",
4125
4127
  variant = "default",
4128
+ as = "label",
4129
+ defaultPressed = false,
4130
+ ariaLabel,
4131
+ disabled = false,
4126
4132
  onContent = "ON",
4127
4133
  offContent = "OFF",
4128
4134
  includeInput = true,
@@ -4132,14 +4138,33 @@ const Swap = ({
4132
4138
  ...props2
4133
4139
  }) => {
4134
4140
  const variantClass = variant !== "default" ? `usx-swap--${variant}` : "";
4135
- const classes = Popover.ClassNames("usx-swap", variantClass, className);
4141
+ const classes = Popover.ClassNames(
4142
+ "usx-swap",
4143
+ variantClass,
4144
+ as === "button" && "usa-button usx-button usx-swap--button",
4145
+ className
4146
+ );
4136
4147
  const onClasses = Popover.ClassNames("usx-swap-on", onClassName);
4137
4148
  const offClasses = Popover.ClassNames("usx-swap-off", offClassName);
4138
4149
  const content = children || /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4139
- includeInput ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", autoComplete: "off", ...inputProps }) : null,
4150
+ as === "label" && includeInput ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", autoComplete: "off", ...inputProps }) : null,
4140
4151
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: onClasses, children: onContent }),
4141
4152
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: offClasses, children: offContent })
4142
4153
  ] });
4154
+ if (as === "button") {
4155
+ return /* @__PURE__ */ jsxRuntime.jsx(
4156
+ "button",
4157
+ {
4158
+ type: "button",
4159
+ className: classes,
4160
+ "aria-pressed": defaultPressed,
4161
+ "aria-label": ariaLabel,
4162
+ disabled,
4163
+ ...props2,
4164
+ children: content
4165
+ }
4166
+ );
4167
+ }
4143
4168
  return /* @__PURE__ */ jsxRuntime.jsx("label", { className: classes, ...props2, children: content });
4144
4169
  };
4145
4170
  function Switch({ className, labelClassName, color, ...props2 }) {
@@ -4234,34 +4259,24 @@ function ThemePicker({
4234
4259
  label = "Theme",
4235
4260
  themes = [],
4236
4261
  variant = "default",
4262
+ popoverAlign = "start",
4237
4263
  value,
4238
4264
  defaultValue,
4239
- onChange,
4240
4265
  className = "",
4241
4266
  extraAttributes
4242
4267
  }) {
4243
- var _a, _b, _c, _d, _e, _f;
4244
- const selectId = id || "theme-picker";
4245
- const [localValue, setLocalValue] = React.useState(defaultValue ?? ((_a = themes[0]) == null ? void 0 : _a.value) ?? "");
4246
- const selectedValue = value ?? localValue;
4247
- const selectedLabel = ((_b = themes.find((option) => option.value === selectedValue)) == null ? void 0 : _b.label) ?? label;
4248
- const choose = (next) => {
4249
- if (value === void 0) setLocalValue(next);
4250
- onChange == null ? void 0 : onChange(next);
4251
- };
4252
- const select = (hidden = false) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4253
- /* @__PURE__ */ jsxRuntime.jsx(Popover.Label, { htmlFor: selectId, screenReaderOnly: true, children: label }),
4268
+ var _a, _b, _c, _d, _e;
4269
+ const fieldId = id || "theme-picker";
4270
+ const selectedValue = value ?? defaultValue ?? ((_a = themes[0]) == null ? void 0 : _a.value) ?? "";
4271
+ const select = () => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4272
+ /* @__PURE__ */ jsxRuntime.jsx(Popover.Label, { htmlFor: fieldId, screenReaderOnly: true, children: label }),
4254
4273
  /* @__PURE__ */ jsxRuntime.jsx(
4255
4274
  "select",
4256
4275
  {
4257
- id: selectId,
4276
+ id: fieldId,
4258
4277
  name,
4259
- className: Popover.ClassNames(
4260
- "usa-select usx-select",
4261
- hidden && "usx-theme-picker__select--hidden"
4262
- ),
4263
- value: selectedValue,
4264
- onChange: (event) => choose(event.target.value),
4278
+ className: "usa-select usx-select",
4279
+ defaultValue: selectedValue,
4265
4280
  children: themes.map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value))
4266
4281
  }
4267
4282
  )
@@ -4275,6 +4290,7 @@ function ThemePicker({
4275
4290
  className
4276
4291
  ),
4277
4292
  ...extraAttributes,
4293
+ hidden: true,
4278
4294
  children: [
4279
4295
  variant === "default" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4280
4296
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -4284,11 +4300,11 @@ function ThemePicker({
4284
4300
  className: "usa-button usx-button usx-button--ghost usx-theme-picker__trigger",
4285
4301
  "aria-label": label,
4286
4302
  "aria-expanded": "false",
4287
- "aria-controls": `${selectId}-panel`,
4303
+ "aria-controls": `${fieldId}-panel`,
4288
4304
  children: /* @__PURE__ */ jsxRuntime.jsx(Popover.Icon, { name: "color_palette", source: "usx", className: "usx-theme-picker__icon" })
4289
4305
  }
4290
4306
  ),
4291
- /* @__PURE__ */ jsxRuntime.jsxs("div", { id: `${selectId}-panel`, className: "usx-theme-picker__panel", children: [
4307
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { id: `${fieldId}-panel`, className: "usx-theme-picker__panel", children: [
4292
4308
  select(),
4293
4309
  /* @__PURE__ */ jsxRuntime.jsx(
4294
4310
  "button",
@@ -4305,33 +4321,43 @@ function ThemePicker({
4305
4321
  /* @__PURE__ */ jsxRuntime.jsx(
4306
4322
  Swap,
4307
4323
  {
4308
- className: "usx-theme-picker__swap usa-button usx-button usx-button--ghost",
4324
+ as: "button",
4325
+ className: "usx-theme-picker__swap usx-button--ghost usx-button--tight",
4309
4326
  variant: "rotate",
4310
- inputProps: {
4311
- checked: selectedValue === ((_c = themes[1]) == null ? void 0 : _c.value),
4312
- "aria-label": `${label}: ${selectedLabel}. Switch to ${selectedValue === ((_d = themes[1]) == null ? void 0 : _d.value) ? (_e = themes[0]) == null ? void 0 : _e.label : (_f = themes[1]) == null ? void 0 : _f.label}`,
4313
- onChange: (event) => {
4314
- var _a2;
4315
- event.stopPropagation();
4316
- choose(((_a2 = themes[event.target.checked ? 1 : 0]) == null ? void 0 : _a2.value) ?? "");
4317
- }
4318
- },
4327
+ defaultPressed: selectedValue === ((_b = themes[1]) == null ? void 0 : _b.value),
4328
+ ariaLabel: `${((_c = themes[1]) == null ? void 0 : _c.label) ?? ""} ${label}`.trim(),
4329
+ "data-usx-theme-off": (_d = themes[0]) == null ? void 0 : _d.value,
4330
+ "data-usx-theme-on": (_e = themes[1]) == null ? void 0 : _e.value,
4319
4331
  offContent: /* @__PURE__ */ jsxRuntime.jsx(Popover.Icon, { name: "sun", source: "usx", className: "usx-theme-picker__icon" }),
4320
4332
  onContent: /* @__PURE__ */ jsxRuntime.jsx(Popover.Icon, { name: "moon", source: "usx", className: "usx-theme-picker__icon" })
4321
4333
  }
4322
4334
  ),
4323
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usx-theme-picker__fallback", children: select() })
4335
+ /* @__PURE__ */ jsxRuntime.jsx("input", { id: fieldId, type: "hidden", name, defaultValue: selectedValue })
4324
4336
  ] }),
4325
- variant === "ghost-select" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usx-theme-picker__ghost", children: [
4337
+ variant === "popover" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4326
4338
  /* @__PURE__ */ jsxRuntime.jsx(
4327
- "span",
4339
+ Popover.Popover,
4328
4340
  {
4329
- className: "usa-button usx-button usx-button--ghost usx-theme-picker__ghost-face",
4330
- "aria-hidden": "true",
4331
- children: /* @__PURE__ */ jsxRuntime.jsx(Popover.Icon, { name: "color_palette", source: "usx", className: "usx-theme-picker__icon" })
4341
+ id: `${fieldId}-panel`,
4342
+ className: "usx-theme-picker__popover",
4343
+ align: popoverAlign,
4344
+ panelShape: "square",
4345
+ summaryProps: {
4346
+ className: "usa-button usx-button usx-button--ghost usx-button--tight margin-0",
4347
+ ariaLabel: label,
4348
+ children: /* @__PURE__ */ jsxRuntime.jsx(Popover.Icon, { name: "color_palette", source: "usx", className: "usx-theme-picker__icon" })
4349
+ },
4350
+ menuItems: themes.map((theme) => ({
4351
+ type: "button",
4352
+ text: theme.label,
4353
+ extraAttributes: {
4354
+ "data-usx-theme-value": theme.value,
4355
+ "aria-pressed": theme.value === selectedValue
4356
+ }
4357
+ }))
4332
4358
  }
4333
4359
  ),
4334
- select(true)
4360
+ /* @__PURE__ */ jsxRuntime.jsx("input", { id: fieldId, type: "hidden", name, defaultValue: selectedValue })
4335
4361
  ] })
4336
4362
  ]
4337
4363
  }
@@ -4552,6 +4578,7 @@ exports.TagGroup = Popover.TagGroup;
4552
4578
  exports.TextArea = Popover.TextArea;
4553
4579
  exports.Tooltip = Popover.Tooltip;
4554
4580
  exports.Accordion = Accordion;
4581
+ exports.AccordionItem = AccordionItem;
4555
4582
  exports.Attribution = Attribution;
4556
4583
  exports.BackToTop = BackToTop;
4557
4584
  exports.Banner = Banner;