@solexllc/usx-react 0.10.0 → 0.11.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 (33) hide show
  1. package/dist/index.cjs +123 -66
  2. package/dist/index.js +123 -66
  3. package/package.json +4 -4
  4. package/src/components/code/code.django-snapshot.html +4 -6
  5. package/src/components/code/code.html +2 -2
  6. package/src/components/code/code.react-snapshot.html +2 -4
  7. package/src/components/header/header.django-snapshot.html +5 -7
  8. package/src/components/header/header.html +1 -11
  9. package/src/components/header/header.react-snapshot.html +3 -6
  10. package/src/components/icon-list/IconList.tsx +10 -2
  11. package/src/components/icon-list/config.json +5 -1
  12. package/src/components/icon-list/icon-list.django-snapshot.html +39 -0
  13. package/src/components/icon-list/icon-list.django.html +2 -0
  14. package/src/components/icon-list/icon-list.react-snapshot.html +31 -0
  15. package/src/components/list/List.tsx +10 -2
  16. package/src/components/list/config.json +5 -1
  17. package/src/components/list/list.django-snapshot.html +26 -0
  18. package/src/components/list/list.django.html +2 -0
  19. package/src/components/list/list.html +20 -0
  20. package/src/components/list/list.react-snapshot.html +20 -0
  21. package/src/components/page/Page.tsx +16 -0
  22. package/src/components/page/config.json +18 -1
  23. package/src/components/page/page.django-snapshot.html +74 -0
  24. package/src/components/page/page.django.html +8 -0
  25. package/src/components/page/page.html +60 -0
  26. package/src/components/page/page.react-snapshot.html +60 -0
  27. package/src/components/theme-picker/ThemePicker.tsx +95 -52
  28. package/src/components/theme-picker/config.json +7 -4
  29. package/src/components/theme-picker/theme-picker-select.django.html +7 -0
  30. package/src/components/theme-picker/theme-picker.django-snapshot.html +101 -21
  31. package/src/components/theme-picker/theme-picker.django.html +22 -24
  32. package/src/components/theme-picker/theme-picker.html +86 -56
  33. package/src/components/theme-picker/theme-picker.react-snapshot.html +74 -18
package/dist/index.cjs CHANGED
@@ -3011,11 +3011,27 @@
3011
3011
  }
3012
3012
  );
3013
3013
  }
3014
+ const TagGroup = ({
3015
+ tagProps = null,
3016
+ children = null,
3017
+ className = "",
3018
+ ...props2
3019
+ }) => {
3020
+ const classes = ClassNames(
3021
+ "usx-tag-group",
3022
+ className
3023
+ );
3024
+ const content = children ? children : Array.isArray(tagProps) ? tagProps.map((t, i) => /* @__PURE__ */ jsxRuntime.jsx(Tag, { ...t }, t.id || t.value || i)) : null;
3025
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes, ...props2, children: content });
3026
+ };
3014
3027
  function Page({
3015
3028
  id = void 0,
3016
3029
  title = "Page title",
3017
3030
  titleId = void 0,
3018
3031
  eyebrow = null,
3032
+ subtitle = void 0,
3033
+ description = void 0,
3034
+ tagProps = void 0,
3019
3035
  as: Element = "main",
3020
3036
  children = null,
3021
3037
  content = null,
@@ -3024,6 +3040,7 @@
3024
3040
  className = "",
3025
3041
  ...props2
3026
3042
  }) {
3043
+ const hasSummary = Boolean(subtitle || description || (tagProps == null ? void 0 : tagProps.length));
3027
3044
  const classes = ClassNames("usx-page", className);
3028
3045
  const pageContent = children || content;
3029
3046
  const labelledBy = ariaLabelledby || titleId || void 0;
@@ -3040,6 +3057,11 @@
3040
3057
  eyebrow ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "usx-eyebrow", children: eyebrow }) : null,
3041
3058
  title
3042
3059
  ] }),
3060
+ hasSummary && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usx-page__summary", children: [
3061
+ subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "usx-page__subtitle", children: subtitle }),
3062
+ (tagProps == null ? void 0 : tagProps.length) ? /* @__PURE__ */ jsxRuntime.jsx(TagGroup, { className: "usx-page__tags", tagProps }) : null,
3063
+ description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "usx-page__description", children: description })
3064
+ ] }),
3043
3065
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usx-page__content", children: pageContent })
3044
3066
  ]
3045
3067
  }
@@ -3823,7 +3845,7 @@
3823
3845
  }
3824
3846
  return content;
3825
3847
  }
3826
- function IconList({ items = [], primary = false, size = null, className = "", ...props2 }) {
3848
+ function IconList({ items = [], caption, primary = false, size = null, className = "", ...props2 }) {
3827
3849
  const classes = ClassNames(
3828
3850
  "usa-icon-list",
3829
3851
  "usx-icon-list",
@@ -3831,7 +3853,7 @@
3831
3853
  size === "lg" && "usa-icon-list--size-lg",
3832
3854
  className
3833
3855
  );
3834
- return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: classes, ...props2, children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: ClassNames("usa-icon-list__item", item.itemClassName), children: [
3856
+ const list = /* @__PURE__ */ jsxRuntime.jsx("ul", { className: classes, ...props2, children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: ClassNames("usa-icon-list__item", item.itemClassName), children: [
3835
3857
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: ClassNames("usa-icon-list__icon", item.iconColor && `text-${item.iconColor}`, item.iconClassName), children: /* @__PURE__ */ jsxRuntime.jsx(
3836
3858
  Icon,
3837
3859
  {
@@ -3846,6 +3868,10 @@
3846
3868
  renderContent(item.content)
3847
3869
  ] })
3848
3870
  ] }, index)) });
3871
+ return caption ? /* @__PURE__ */ jsxRuntime.jsxs("figure", { className: "usx-list-figure", children: [
3872
+ /* @__PURE__ */ jsxRuntime.jsx("figcaption", { className: "usx-list-figure__caption", children: caption }),
3873
+ list
3874
+ ] }) : list;
3849
3875
  }
3850
3876
  const defaultRequiredLinks = {
3851
3877
  en: [
@@ -4272,7 +4298,7 @@
4272
4298
  ] }, index);
4273
4299
  });
4274
4300
  }
4275
- function List({ items = [], ordered = false, unstyled = false, className = "", ...props2 }) {
4301
+ function List({ items = [], caption, ordered = false, unstyled = false, className = "", ...props2 }) {
4276
4302
  const classes = ClassNames(
4277
4303
  "usa-list",
4278
4304
  "usx-list",
@@ -4280,7 +4306,11 @@
4280
4306
  className
4281
4307
  );
4282
4308
  const Tag2 = ordered ? "ol" : "ul";
4283
- return /* @__PURE__ */ jsxRuntime.jsx(Tag2, { className: classes, ...props2, children: renderItems(items, { ordered, unstyled }) });
4309
+ const list = /* @__PURE__ */ jsxRuntime.jsx(Tag2, { className: classes, ...props2, children: renderItems(items, { ordered, unstyled }) });
4310
+ return caption ? /* @__PURE__ */ jsxRuntime.jsxs("figure", { className: "usx-list-figure", children: [
4311
+ /* @__PURE__ */ jsxRuntime.jsx("figcaption", { className: "usx-list-figure__caption", children: caption }),
4312
+ list
4313
+ ] }) : list;
4284
4314
  }
4285
4315
  const MONTH_OPTIONS = [
4286
4316
  { value: "1", label: "January" },
@@ -5047,19 +5077,6 @@
5047
5077
  }
5048
5078
  ) : table;
5049
5079
  }
5050
- const TagGroup = ({
5051
- tagProps = null,
5052
- children = null,
5053
- className = "",
5054
- ...props2
5055
- }) => {
5056
- const classes = ClassNames(
5057
- "usx-tag-group",
5058
- className
5059
- );
5060
- const content = children ? children : Array.isArray(tagProps) ? tagProps.map((t, i) => /* @__PURE__ */ jsxRuntime.jsx(Tag, { ...t }, t.id || t.value || i)) : null;
5061
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes, ...props2, children: content });
5062
- };
5063
5080
  function TaskList({ tasks = [], className }) {
5064
5081
  return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: ClassNames("usx-task-list", className), children: tasks == null ? void 0 : tasks.map((task, i) => {
5065
5082
  return /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(Clickable, { href: task.href, className: "usx-task-list__item", children: [
@@ -5076,67 +5093,107 @@
5076
5093
  name,
5077
5094
  label = "Theme",
5078
5095
  themes = [],
5096
+ variant = "default",
5079
5097
  value,
5080
5098
  defaultValue,
5081
5099
  onChange,
5082
5100
  className = "",
5083
5101
  extraAttributes
5084
5102
  }) {
5085
- var _a;
5103
+ var _a, _b, _c, _d, _e, _f;
5086
5104
  const selectId = id || "theme-picker";
5087
- const selection = value !== void 0 ? { value } : { defaultValue: defaultValue ?? ((_a = themes[0]) == null ? void 0 : _a.value) };
5088
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ClassNames("usx-theme-picker", className), ...extraAttributes, children: [
5105
+ const [localValue, setLocalValue] = React.useState(defaultValue ?? ((_a = themes[0]) == null ? void 0 : _a.value) ?? "");
5106
+ const selectedValue = value ?? localValue;
5107
+ const selectedLabel = ((_b = themes.find((option) => option.value === selectedValue)) == null ? void 0 : _b.label) ?? label;
5108
+ const choose = (next) => {
5109
+ if (value === void 0) setLocalValue(next);
5110
+ onChange == null ? void 0 : onChange(next);
5111
+ };
5112
+ const select = (hidden = false) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5113
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: selectId, screenReaderOnly: true, children: label }),
5089
5114
  /* @__PURE__ */ jsxRuntime.jsx(
5090
- "button",
5115
+ "select",
5091
5116
  {
5092
- type: "button",
5093
- className: "usa-button usx-button usx-button--ghost usx-theme-picker__trigger",
5094
- "aria-label": label,
5095
- "aria-expanded": "false",
5096
- "aria-controls": `${selectId}-panel`,
5097
- children: /* @__PURE__ */ jsxRuntime.jsx(PaletteIcon, {})
5117
+ id: selectId,
5118
+ name,
5119
+ className: ClassNames(
5120
+ "usa-select usx-select",
5121
+ hidden && "usx-theme-picker__select--hidden"
5122
+ ),
5123
+ value: selectedValue,
5124
+ onChange: (event) => choose(event.target.value),
5125
+ children: themes.map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value))
5098
5126
  }
5099
- ),
5100
- /* @__PURE__ */ jsxRuntime.jsxs("div", { id: `${selectId}-panel`, className: "usx-theme-picker__panel", children: [
5101
- /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: selectId, screenReaderOnly: true, children: label }),
5102
- /* @__PURE__ */ jsxRuntime.jsx(
5103
- "select",
5104
- {
5105
- id: selectId,
5106
- name,
5107
- className: "usa-select usx-select",
5108
- ...selection,
5109
- onChange: (event) => onChange == null ? void 0 : onChange(event.target.value),
5110
- children: themes.map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value))
5111
- }
5112
- ),
5113
- /* @__PURE__ */ jsxRuntime.jsx(
5114
- "button",
5115
- {
5116
- type: "button",
5117
- className: "usa-button usx-button usa-button--primary usx-theme-picker__toggle",
5118
- "aria-label": "Confirm theme",
5119
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "close", className: "usx-theme-picker__icon" })
5120
- }
5121
- )
5122
- ] })
5127
+ )
5123
5128
  ] });
5124
- }
5125
- function PaletteIcon() {
5126
- return /* @__PURE__ */ jsxRuntime.jsx(
5127
- "svg",
5129
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5130
+ "div",
5128
5131
  {
5129
- className: "usa-icon usx-theme-picker__icon",
5130
- "aria-hidden": "true",
5131
- focusable: "false",
5132
- viewBox: "0 0 24 24",
5133
- children: /* @__PURE__ */ jsxRuntime.jsx(
5134
- "path",
5135
- {
5136
- fill: "currentColor",
5137
- d: "M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"
5138
- }
5139
- )
5132
+ className: ClassNames(
5133
+ "usx-theme-picker",
5134
+ variant !== "default" && `usx-theme-picker--${variant}`,
5135
+ className
5136
+ ),
5137
+ ...extraAttributes,
5138
+ children: [
5139
+ variant === "default" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5140
+ /* @__PURE__ */ jsxRuntime.jsx(
5141
+ "button",
5142
+ {
5143
+ type: "button",
5144
+ className: "usa-button usx-button usx-button--ghost usx-theme-picker__trigger",
5145
+ "aria-label": label,
5146
+ "aria-expanded": "false",
5147
+ "aria-controls": `${selectId}-panel`,
5148
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "color_palette", source: "usx", className: "usx-theme-picker__icon" })
5149
+ }
5150
+ ),
5151
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { id: `${selectId}-panel`, className: "usx-theme-picker__panel", children: [
5152
+ select(),
5153
+ /* @__PURE__ */ jsxRuntime.jsx(
5154
+ "button",
5155
+ {
5156
+ type: "button",
5157
+ className: "usa-button usx-button usa-button--primary usx-theme-picker__toggle",
5158
+ "aria-label": "Confirm theme",
5159
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "close", className: "usx-theme-picker__icon" })
5160
+ }
5161
+ )
5162
+ ] })
5163
+ ] }),
5164
+ variant === "swap" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5165
+ /* @__PURE__ */ jsxRuntime.jsx(
5166
+ Swap,
5167
+ {
5168
+ className: "usx-theme-picker__swap usa-button usx-button usx-button--ghost",
5169
+ variant: "rotate",
5170
+ inputProps: {
5171
+ checked: selectedValue === ((_c = themes[1]) == null ? void 0 : _c.value),
5172
+ "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}`,
5173
+ onChange: (event) => {
5174
+ var _a2;
5175
+ event.stopPropagation();
5176
+ choose(((_a2 = themes[event.target.checked ? 1 : 0]) == null ? void 0 : _a2.value) ?? "");
5177
+ }
5178
+ },
5179
+ offContent: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "sun", source: "usx", className: "usx-theme-picker__icon" }),
5180
+ onContent: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "moon", source: "usx", className: "usx-theme-picker__icon" })
5181
+ }
5182
+ ),
5183
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usx-theme-picker__fallback", children: select() })
5184
+ ] }),
5185
+ variant === "ghost-select" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usx-theme-picker__ghost", children: [
5186
+ /* @__PURE__ */ jsxRuntime.jsx(
5187
+ "span",
5188
+ {
5189
+ className: "usa-button usx-button usx-button--ghost usx-theme-picker__ghost-face",
5190
+ "aria-hidden": "true",
5191
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "color_palette", source: "usx", className: "usx-theme-picker__icon" })
5192
+ }
5193
+ ),
5194
+ select(true)
5195
+ ] })
5196
+ ]
5140
5197
  }
5141
5198
  );
5142
5199
  }
package/dist/index.js CHANGED
@@ -3009,11 +3009,27 @@ function Link({
3009
3009
  }
3010
3010
  );
3011
3011
  }
3012
+ const TagGroup = ({
3013
+ tagProps = null,
3014
+ children = null,
3015
+ className = "",
3016
+ ...props2
3017
+ }) => {
3018
+ const classes = ClassNames(
3019
+ "usx-tag-group",
3020
+ className
3021
+ );
3022
+ const content = children ? children : Array.isArray(tagProps) ? tagProps.map((t, i) => /* @__PURE__ */ jsx(Tag, { ...t }, t.id || t.value || i)) : null;
3023
+ return /* @__PURE__ */ jsx("div", { className: classes, ...props2, children: content });
3024
+ };
3012
3025
  function Page({
3013
3026
  id = void 0,
3014
3027
  title = "Page title",
3015
3028
  titleId = void 0,
3016
3029
  eyebrow = null,
3030
+ subtitle = void 0,
3031
+ description = void 0,
3032
+ tagProps = void 0,
3017
3033
  as: Element = "main",
3018
3034
  children = null,
3019
3035
  content = null,
@@ -3022,6 +3038,7 @@ function Page({
3022
3038
  className = "",
3023
3039
  ...props2
3024
3040
  }) {
3041
+ const hasSummary = Boolean(subtitle || description || (tagProps == null ? void 0 : tagProps.length));
3025
3042
  const classes = ClassNames("usx-page", className);
3026
3043
  const pageContent = children || content;
3027
3044
  const labelledBy = ariaLabelledby || titleId || void 0;
@@ -3038,6 +3055,11 @@ function Page({
3038
3055
  eyebrow ? /* @__PURE__ */ jsx("span", { className: "usx-eyebrow", children: eyebrow }) : null,
3039
3056
  title
3040
3057
  ] }),
3058
+ hasSummary && /* @__PURE__ */ jsxs("div", { className: "usx-page__summary", children: [
3059
+ subtitle && /* @__PURE__ */ jsx("p", { className: "usx-page__subtitle", children: subtitle }),
3060
+ (tagProps == null ? void 0 : tagProps.length) ? /* @__PURE__ */ jsx(TagGroup, { className: "usx-page__tags", tagProps }) : null,
3061
+ description && /* @__PURE__ */ jsx("p", { className: "usx-page__description", children: description })
3062
+ ] }),
3041
3063
  /* @__PURE__ */ jsx("div", { className: "usx-page__content", children: pageContent })
3042
3064
  ]
3043
3065
  }
@@ -3821,7 +3843,7 @@ function renderContent(content) {
3821
3843
  }
3822
3844
  return content;
3823
3845
  }
3824
- function IconList({ items = [], primary = false, size = null, className = "", ...props2 }) {
3846
+ function IconList({ items = [], caption, primary = false, size = null, className = "", ...props2 }) {
3825
3847
  const classes = ClassNames(
3826
3848
  "usa-icon-list",
3827
3849
  "usx-icon-list",
@@ -3829,7 +3851,7 @@ function IconList({ items = [], primary = false, size = null, className = "", ..
3829
3851
  size === "lg" && "usa-icon-list--size-lg",
3830
3852
  className
3831
3853
  );
3832
- return /* @__PURE__ */ jsx("ul", { className: classes, ...props2, children: items.map((item, index) => /* @__PURE__ */ jsxs("li", { className: ClassNames("usa-icon-list__item", item.itemClassName), children: [
3854
+ const list = /* @__PURE__ */ jsx("ul", { className: classes, ...props2, children: items.map((item, index) => /* @__PURE__ */ jsxs("li", { className: ClassNames("usa-icon-list__item", item.itemClassName), children: [
3833
3855
  /* @__PURE__ */ jsx("div", { className: ClassNames("usa-icon-list__icon", item.iconColor && `text-${item.iconColor}`, item.iconClassName), children: /* @__PURE__ */ jsx(
3834
3856
  Icon,
3835
3857
  {
@@ -3844,6 +3866,10 @@ function IconList({ items = [], primary = false, size = null, className = "", ..
3844
3866
  renderContent(item.content)
3845
3867
  ] })
3846
3868
  ] }, index)) });
3869
+ return caption ? /* @__PURE__ */ jsxs("figure", { className: "usx-list-figure", children: [
3870
+ /* @__PURE__ */ jsx("figcaption", { className: "usx-list-figure__caption", children: caption }),
3871
+ list
3872
+ ] }) : list;
3847
3873
  }
3848
3874
  const defaultRequiredLinks = {
3849
3875
  en: [
@@ -4270,7 +4296,7 @@ function renderItems(items = [], parentOptions = {}) {
4270
4296
  ] }, index);
4271
4297
  });
4272
4298
  }
4273
- function List({ items = [], ordered = false, unstyled = false, className = "", ...props2 }) {
4299
+ function List({ items = [], caption, ordered = false, unstyled = false, className = "", ...props2 }) {
4274
4300
  const classes = ClassNames(
4275
4301
  "usa-list",
4276
4302
  "usx-list",
@@ -4278,7 +4304,11 @@ function List({ items = [], ordered = false, unstyled = false, className = "", .
4278
4304
  className
4279
4305
  );
4280
4306
  const Tag2 = ordered ? "ol" : "ul";
4281
- return /* @__PURE__ */ jsx(Tag2, { className: classes, ...props2, children: renderItems(items, { ordered, unstyled }) });
4307
+ const list = /* @__PURE__ */ jsx(Tag2, { className: classes, ...props2, children: renderItems(items, { ordered, unstyled }) });
4308
+ return caption ? /* @__PURE__ */ jsxs("figure", { className: "usx-list-figure", children: [
4309
+ /* @__PURE__ */ jsx("figcaption", { className: "usx-list-figure__caption", children: caption }),
4310
+ list
4311
+ ] }) : list;
4282
4312
  }
4283
4313
  const MONTH_OPTIONS = [
4284
4314
  { value: "1", label: "January" },
@@ -5045,19 +5075,6 @@ function Table({
5045
5075
  }
5046
5076
  ) : table;
5047
5077
  }
5048
- const TagGroup = ({
5049
- tagProps = null,
5050
- children = null,
5051
- className = "",
5052
- ...props2
5053
- }) => {
5054
- const classes = ClassNames(
5055
- "usx-tag-group",
5056
- className
5057
- );
5058
- const content = children ? children : Array.isArray(tagProps) ? tagProps.map((t, i) => /* @__PURE__ */ jsx(Tag, { ...t }, t.id || t.value || i)) : null;
5059
- return /* @__PURE__ */ jsx("div", { className: classes, ...props2, children: content });
5060
- };
5061
5078
  function TaskList({ tasks = [], className }) {
5062
5079
  return /* @__PURE__ */ jsx("ul", { className: ClassNames("usx-task-list", className), children: tasks == null ? void 0 : tasks.map((task, i) => {
5063
5080
  return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(Clickable, { href: task.href, className: "usx-task-list__item", children: [
@@ -5074,67 +5091,107 @@ function ThemePicker({
5074
5091
  name,
5075
5092
  label = "Theme",
5076
5093
  themes = [],
5094
+ variant = "default",
5077
5095
  value,
5078
5096
  defaultValue,
5079
5097
  onChange,
5080
5098
  className = "",
5081
5099
  extraAttributes
5082
5100
  }) {
5083
- var _a;
5101
+ var _a, _b, _c, _d, _e, _f;
5084
5102
  const selectId = id || "theme-picker";
5085
- const selection = value !== void 0 ? { value } : { defaultValue: defaultValue ?? ((_a = themes[0]) == null ? void 0 : _a.value) };
5086
- return /* @__PURE__ */ jsxs("div", { className: ClassNames("usx-theme-picker", className), ...extraAttributes, children: [
5103
+ const [localValue, setLocalValue] = React.useState(defaultValue ?? ((_a = themes[0]) == null ? void 0 : _a.value) ?? "");
5104
+ const selectedValue = value ?? localValue;
5105
+ const selectedLabel = ((_b = themes.find((option) => option.value === selectedValue)) == null ? void 0 : _b.label) ?? label;
5106
+ const choose = (next) => {
5107
+ if (value === void 0) setLocalValue(next);
5108
+ onChange == null ? void 0 : onChange(next);
5109
+ };
5110
+ const select = (hidden = false) => /* @__PURE__ */ jsxs(Fragment, { children: [
5111
+ /* @__PURE__ */ jsx(Label, { htmlFor: selectId, screenReaderOnly: true, children: label }),
5087
5112
  /* @__PURE__ */ jsx(
5088
- "button",
5113
+ "select",
5089
5114
  {
5090
- type: "button",
5091
- className: "usa-button usx-button usx-button--ghost usx-theme-picker__trigger",
5092
- "aria-label": label,
5093
- "aria-expanded": "false",
5094
- "aria-controls": `${selectId}-panel`,
5095
- children: /* @__PURE__ */ jsx(PaletteIcon, {})
5115
+ id: selectId,
5116
+ name,
5117
+ className: ClassNames(
5118
+ "usa-select usx-select",
5119
+ hidden && "usx-theme-picker__select--hidden"
5120
+ ),
5121
+ value: selectedValue,
5122
+ onChange: (event) => choose(event.target.value),
5123
+ children: themes.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
5096
5124
  }
5097
- ),
5098
- /* @__PURE__ */ jsxs("div", { id: `${selectId}-panel`, className: "usx-theme-picker__panel", children: [
5099
- /* @__PURE__ */ jsx(Label, { htmlFor: selectId, screenReaderOnly: true, children: label }),
5100
- /* @__PURE__ */ jsx(
5101
- "select",
5102
- {
5103
- id: selectId,
5104
- name,
5105
- className: "usa-select usx-select",
5106
- ...selection,
5107
- onChange: (event) => onChange == null ? void 0 : onChange(event.target.value),
5108
- children: themes.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
5109
- }
5110
- ),
5111
- /* @__PURE__ */ jsx(
5112
- "button",
5113
- {
5114
- type: "button",
5115
- className: "usa-button usx-button usa-button--primary usx-theme-picker__toggle",
5116
- "aria-label": "Confirm theme",
5117
- children: /* @__PURE__ */ jsx(Icon, { name: "close", className: "usx-theme-picker__icon" })
5118
- }
5119
- )
5120
- ] })
5125
+ )
5121
5126
  ] });
5122
- }
5123
- function PaletteIcon() {
5124
- return /* @__PURE__ */ jsx(
5125
- "svg",
5127
+ return /* @__PURE__ */ jsxs(
5128
+ "div",
5126
5129
  {
5127
- className: "usa-icon usx-theme-picker__icon",
5128
- "aria-hidden": "true",
5129
- focusable: "false",
5130
- viewBox: "0 0 24 24",
5131
- children: /* @__PURE__ */ jsx(
5132
- "path",
5133
- {
5134
- fill: "currentColor",
5135
- d: "M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"
5136
- }
5137
- )
5130
+ className: ClassNames(
5131
+ "usx-theme-picker",
5132
+ variant !== "default" && `usx-theme-picker--${variant}`,
5133
+ className
5134
+ ),
5135
+ ...extraAttributes,
5136
+ children: [
5137
+ variant === "default" && /* @__PURE__ */ jsxs(Fragment, { children: [
5138
+ /* @__PURE__ */ jsx(
5139
+ "button",
5140
+ {
5141
+ type: "button",
5142
+ className: "usa-button usx-button usx-button--ghost usx-theme-picker__trigger",
5143
+ "aria-label": label,
5144
+ "aria-expanded": "false",
5145
+ "aria-controls": `${selectId}-panel`,
5146
+ children: /* @__PURE__ */ jsx(Icon, { name: "color_palette", source: "usx", className: "usx-theme-picker__icon" })
5147
+ }
5148
+ ),
5149
+ /* @__PURE__ */ jsxs("div", { id: `${selectId}-panel`, className: "usx-theme-picker__panel", children: [
5150
+ select(),
5151
+ /* @__PURE__ */ jsx(
5152
+ "button",
5153
+ {
5154
+ type: "button",
5155
+ className: "usa-button usx-button usa-button--primary usx-theme-picker__toggle",
5156
+ "aria-label": "Confirm theme",
5157
+ children: /* @__PURE__ */ jsx(Icon, { name: "close", className: "usx-theme-picker__icon" })
5158
+ }
5159
+ )
5160
+ ] })
5161
+ ] }),
5162
+ variant === "swap" && /* @__PURE__ */ jsxs(Fragment, { children: [
5163
+ /* @__PURE__ */ jsx(
5164
+ Swap,
5165
+ {
5166
+ className: "usx-theme-picker__swap usa-button usx-button usx-button--ghost",
5167
+ variant: "rotate",
5168
+ inputProps: {
5169
+ checked: selectedValue === ((_c = themes[1]) == null ? void 0 : _c.value),
5170
+ "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}`,
5171
+ onChange: (event) => {
5172
+ var _a2;
5173
+ event.stopPropagation();
5174
+ choose(((_a2 = themes[event.target.checked ? 1 : 0]) == null ? void 0 : _a2.value) ?? "");
5175
+ }
5176
+ },
5177
+ offContent: /* @__PURE__ */ jsx(Icon, { name: "sun", source: "usx", className: "usx-theme-picker__icon" }),
5178
+ onContent: /* @__PURE__ */ jsx(Icon, { name: "moon", source: "usx", className: "usx-theme-picker__icon" })
5179
+ }
5180
+ ),
5181
+ /* @__PURE__ */ jsx("div", { className: "usx-theme-picker__fallback", children: select() })
5182
+ ] }),
5183
+ variant === "ghost-select" && /* @__PURE__ */ jsxs("div", { className: "usx-theme-picker__ghost", children: [
5184
+ /* @__PURE__ */ jsx(
5185
+ "span",
5186
+ {
5187
+ className: "usa-button usx-button usx-button--ghost usx-theme-picker__ghost-face",
5188
+ "aria-hidden": "true",
5189
+ children: /* @__PURE__ */ jsx(Icon, { name: "color_palette", source: "usx", className: "usx-theme-picker__icon" })
5190
+ }
5191
+ ),
5192
+ select(true)
5193
+ ] })
5194
+ ]
5138
5195
  }
5139
5196
  );
5140
5197
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solexllc/usx-react",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "React component library for USX.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,9 +25,9 @@
25
25
  "dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@solexllc/usx": "0.12.0",
29
- "@solexllc/usx-theme": "0.11.1",
30
- "@solexllc/usx-uswds-fixes": "0.1.16",
28
+ "@solexllc/usx": "0.13.0",
29
+ "@solexllc/usx-theme": "0.11.2",
30
+ "@solexllc/usx-uswds-fixes": "0.1.17",
31
31
  "classnames": "^2.5.1",
32
32
  "prop-types": "^15.8.1"
33
33
  },
@@ -106,7 +106,7 @@
106
106
  <div class="usx-mockup-code__content">
107
107
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
108
108
 
109
- <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot; tabIndex={-1}&gt;</code></pre>
109
+ <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot;&gt;</code></pre>
110
110
 
111
111
  <pre
112
112
  data-prefix="3"
@@ -127,7 +127,7 @@
127
127
  class="usa-button usx-button usx-button--ghost usx-copy"
128
128
  onclick="
129
129
  navigator.clipboard.writeText(
130
- '\u003CLayout\u003E\u000A \u003CPage title\u003D\u0022Account\u0022 tabIndex\u003D{\u002D1}\u003E\u000A \u003CSection title\u003D\u0022Contact information\u0022\u003E\u000A \u003CContactDetails user\u003D{currentUser} /\u003E\u000A \u003C/Section\u003E\u000A \u003C/Page\u003E\u000A\u003C/Layout\u003E'
130
+ '\u003CLayout\u003E\u000A \u003CPage title\u003D\u0022Account\u0022\u003E\u000A \u003CSection title\u003D\u0022Contact information\u0022\u003E\u000A \u003CContactDetails user\u003D{currentUser} /\u003E\u000A \u003C/Section\u003E\u000A \u003C/Page\u003E\u000A\u003C/Layout\u003E'
131
131
  )
132
132
  "
133
133
  >
@@ -157,9 +157,7 @@
157
157
  <div class="usx-mockup-code__content">
158
158
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
159
159
 
160
- <pre
161
- data-prefix="2"
162
- ><code> &lt;Page title="<strong>Account</strong>" tabIndex={-1}&gt;</code></pre>
160
+ <pre data-prefix="2"><code> &lt;Page title="<strong>Account</strong>"&gt;</code></pre>
163
161
 
164
162
  <pre data-prefix="3"><code> &lt;Section title="Contact information"&gt;</code></pre>
165
163
 
@@ -178,7 +176,7 @@
178
176
  class="usa-button usx-button usx-button--ghost usx-copy"
179
177
  onclick="
180
178
  navigator.clipboard.writeText(
181
- '\u003CLayout\u003E\u000A \u003CPage title\u003D\u0022Account\u0022 tabIndex\u003D{\u002D1}\u003E\u000A \u003CSection title\u003D\u0022Contact information\u0022\u003E\u000A \u003CContactDetails user\u003D{currentUser} /\u003E\u000A \u003C/Section\u003E\u000A \u003C/Page\u003E\u000A\u003C/Layout\u003E'
179
+ '\u003CLayout\u003E\u000A \u003CPage title\u003D\u0022Account\u0022\u003E\u000A \u003CSection title\u003D\u0022Contact information\u0022\u003E\u000A \u003CContactDetails user\u003D{currentUser} /\u003E\u000A \u003C/Section\u003E\u000A \u003C/Page\u003E\u000A\u003C/Layout\u003E'
182
180
  )
183
181
  "
184
182
  >
@@ -88,7 +88,7 @@
88
88
  <div class="usx-mockup-code">
89
89
  <div class="usx-mockup-code__content">
90
90
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
91
- <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot; tabIndex={-1}&gt;</code></pre>
91
+ <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot;&gt;</code></pre>
92
92
  <pre
93
93
  data-prefix="3"
94
94
  ><code> &lt;Section title=&quot;Contact information&quot;&gt;</code></pre>
@@ -129,7 +129,7 @@
129
129
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
130
130
  <pre
131
131
  data-prefix="2"
132
- ><code> &lt;Page title="<strong>Account</strong>" tabIndex={-1}&gt;</code></pre>
132
+ ><code> &lt;Page title="<strong>Account</strong>"&gt;</code></pre>
133
133
  <pre data-prefix="3"><code> &lt;Section title="Contact information"&gt;</code></pre>
134
134
  <pre data-prefix="4"><code> &lt;ContactDetails user={currentUser} /&gt;</code></pre>
135
135
  <pre data-prefix="5"><code> &lt;/Section&gt;</code></pre>
@@ -81,7 +81,7 @@
81
81
  <div class="usx-mockup-code">
82
82
  <div class="usx-mockup-code__content">
83
83
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
84
- <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot; tabIndex={-1}&gt;</code></pre>
84
+ <pre data-prefix="2"><code> &lt;Page title=&quot;Account&quot;&gt;</code></pre>
85
85
  <pre
86
86
  data-prefix="3"
87
87
  ><code> &lt;Section title=&quot;Contact information&quot;&gt;</code></pre>
@@ -113,9 +113,7 @@
113
113
  <div class="usx-mockup-code">
114
114
  <div class="usx-mockup-code__content">
115
115
  <pre data-prefix="1"><code>&lt;Layout&gt;</code></pre>
116
- <pre
117
- data-prefix="2"
118
- ><code> &lt;Page title="<strong>Account</strong>" tabIndex={-1}&gt;</code></pre>
116
+ <pre data-prefix="2"><code> &lt;Page title="<strong>Account</strong>"&gt;</code></pre>
119
117
  <pre data-prefix="3"><code> &lt;Section title="Contact information"&gt;</code></pre>
120
118
  <pre data-prefix="4"><code> &lt;ContactDetails user={currentUser} /&gt;</code></pre>
121
119
  <pre data-prefix="5"><code> &lt;/Section&gt;</code></pre>