@solexllc/usx-react 0.1.0 → 0.1.2

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs CHANGED
@@ -1201,10 +1201,11 @@
1201
1201
  }
1202
1202
  function Icon({
1203
1203
  name,
1204
+ source = "uswds",
1204
1205
  size = 2,
1205
1206
  color,
1206
1207
  alt = name + " icon",
1207
- staticUrlPrefix = (typeof window !== "undefined" && window.usxBaseUrl || "/") + "img/sprite.svg#",
1208
+ staticUrlPrefix = (typeof window !== "undefined" && window.usxBaseUrl || "/") + "img/" + (source === "usx" ? "usx-sprite.svg" : "sprite.svg") + "#",
1208
1209
  className = "",
1209
1210
  ...props
1210
1211
  }) {
@@ -3144,19 +3145,35 @@
3144
3145
  }
3145
3146
  ) });
3146
3147
  }
3148
+ const externalIndicator = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3149
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "usa-sr-only", children: "External." }),
3150
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "launch", size: 1, className: "margin-left-05" })
3151
+ ] });
3147
3152
  function PrimaryNav({
3148
3153
  navSections,
3149
3154
  megamenu,
3150
3155
  showSecondary = false,
3151
3156
  secondaryLinks = [],
3152
3157
  searchProps = null,
3158
+ utilityContent = null,
3153
3159
  headerId = "header",
3154
3160
  renderSearchDirectly = false
3155
3161
  }) {
3156
3162
  const navClasses = classNames("usa-nav__primary", "usa-accordion");
3157
3163
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3158
3164
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "usa-nav__close", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "close" }) }),
3159
- /* @__PURE__ */ jsxRuntime.jsx("ul", { className: navClasses, children: navSections.map((section, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__primary-item", children: section.href ? /* @__PURE__ */ jsxRuntime.jsx("a", { href: section.href, className: "usa-nav__link", "aria-label": section.ariaLabel, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: section.title }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3165
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: navClasses, children: navSections.map((section, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__primary-item", children: section.href ? /* @__PURE__ */ jsxRuntime.jsxs(
3166
+ "a",
3167
+ {
3168
+ href: section.href,
3169
+ className: "usa-nav__link",
3170
+ "aria-label": section.ariaLabel,
3171
+ children: [
3172
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: section.title }),
3173
+ section.external && externalIndicator
3174
+ ]
3175
+ }
3176
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3160
3177
  /* @__PURE__ */ jsxRuntime.jsx(
3161
3178
  "button",
3162
3179
  {
@@ -3175,12 +3192,45 @@
3175
3192
  const startIndex = colIndex * linksPerColumn;
3176
3193
  const endIndex = Math.min(startIndex + linksPerColumn, links.length);
3177
3194
  const columnLinks = links.slice(startIndex, endIndex);
3178
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-col", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__submenu-list", children: columnLinks.map((link, linkIndex) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: link.href, "aria-label": link.ariaLabel, children: link.text }) }, linkIndex)) }) }, colIndex);
3195
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-col", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__submenu-list", children: columnLinks.map((link, linkIndex) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxRuntime.jsxs(
3196
+ "a",
3197
+ {
3198
+ href: link.href,
3199
+ "aria-label": link.ariaLabel,
3200
+ children: [
3201
+ link.text,
3202
+ link.external && externalIndicator
3203
+ ]
3204
+ }
3205
+ ) }, linkIndex)) }) }, colIndex);
3179
3206
  });
3180
- })() }) }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { id: `${headerId}-nav-section-${index}`, className: "usa-nav__submenu", hidden: true, children: section.links.map((link, linkIndex) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: link.href, "aria-label": link.ariaLabel, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: link.text }) }) }, linkIndex)) }))
3207
+ })() }) }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { id: `${headerId}-nav-section-${index}`, className: "usa-nav__submenu", hidden: true, children: section.links.map((link, linkIndex) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxRuntime.jsxs(
3208
+ "a",
3209
+ {
3210
+ href: link.href,
3211
+ "aria-label": link.ariaLabel,
3212
+ children: [
3213
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: link.text }),
3214
+ link.external && externalIndicator
3215
+ ]
3216
+ }
3217
+ ) }, linkIndex)) }))
3181
3218
  ] }) }, index)) }),
3182
- showSecondary && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-nav__secondary", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: link.href, "aria-label": link.ariaLabel, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: link.text }) }) }, index)) }) }),
3183
- renderSearchDirectly && searchProps && /* @__PURE__ */ jsxRuntime.jsx(Search, { ...searchProps })
3219
+ showSecondary && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usa-nav__secondary", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxRuntime.jsxs(
3220
+ "a",
3221
+ {
3222
+ href: link.href,
3223
+ "aria-label": link.ariaLabel,
3224
+ children: [
3225
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: link.text }),
3226
+ link.external && externalIndicator
3227
+ ]
3228
+ }
3229
+ ) }, index)) }) }),
3230
+ renderSearchDirectly && (utilityContent || searchProps) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usx-nav__utility", children: [
3231
+ utilityContent,
3232
+ searchProps && /* @__PURE__ */ jsxRuntime.jsx(Search, { ...searchProps })
3233
+ ] })
3184
3234
  ] });
3185
3235
  }
3186
3236
  function Header({
@@ -3195,6 +3245,8 @@
3195
3245
  useMenuIcon = false,
3196
3246
  stickyNav = false,
3197
3247
  className = "",
3248
+ utilityContent = null,
3249
+ navEndContent = null,
3198
3250
  ...props
3199
3251
  }) {
3200
3252
  const headerClasses = classNames(
@@ -3228,9 +3280,23 @@
3228
3280
  }
3229
3281
  ),
3230
3282
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usa-nav__secondary", children: [
3231
- /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: link.href, "aria-label": link.ariaLabel, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: link.text }) }) }, index)) }),
3232
- searchProps && /* @__PURE__ */ jsxRuntime.jsx(Search, { ...searchProps })
3233
- ] })
3283
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxRuntime.jsxs(
3284
+ "a",
3285
+ {
3286
+ href: link.href,
3287
+ "aria-label": link.ariaLabel,
3288
+ children: [
3289
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: link.text }),
3290
+ link.external && externalIndicator
3291
+ ]
3292
+ }
3293
+ ) }, index)) }),
3294
+ (utilityContent || searchProps) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "usx-nav__utility", children: [
3295
+ utilityContent,
3296
+ searchProps && /* @__PURE__ */ jsxRuntime.jsx(Search, { ...searchProps })
3297
+ ] })
3298
+ ] }),
3299
+ navEndContent && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "usx-nav__end-slot", children: navEndContent })
3234
3300
  ] }) })
3235
3301
  ] });
3236
3302
  }
@@ -3244,6 +3310,7 @@
3244
3310
  showSecondary: false,
3245
3311
  secondaryLinks,
3246
3312
  searchProps,
3313
+ utilityContent,
3247
3314
  headerId: id,
3248
3315
  renderSearchDirectly: true
3249
3316
  }
@@ -5763,7 +5830,7 @@
5763
5830
  "button",
5764
5831
  {
5765
5832
  type: "button",
5766
- className: "usa-button usx-button usx-button--ghost usx-theme-picker__trigger",
5833
+ className: "usa-button usx-button usx-button--ghost text-muted usx-theme-picker__trigger",
5767
5834
  "aria-label": label,
5768
5835
  onClick: () => setOpen(true),
5769
5836
  children: /* @__PURE__ */ jsxRuntime.jsx(PaletteIcon, {})
package/dist/index.js CHANGED
@@ -1199,10 +1199,11 @@ function Alert({
1199
1199
  }
1200
1200
  function Icon({
1201
1201
  name,
1202
+ source = "uswds",
1202
1203
  size = 2,
1203
1204
  color,
1204
1205
  alt = name + " icon",
1205
- staticUrlPrefix = (typeof window !== "undefined" && window.usxBaseUrl || "/") + "img/sprite.svg#",
1206
+ staticUrlPrefix = (typeof window !== "undefined" && window.usxBaseUrl || "/") + "img/" + (source === "usx" ? "usx-sprite.svg" : "sprite.svg") + "#",
1206
1207
  className = "",
1207
1208
  ...props
1208
1209
  }) {
@@ -3142,19 +3143,35 @@ function Search({
3142
3143
  }
3143
3144
  ) });
3144
3145
  }
3146
+ const externalIndicator = /* @__PURE__ */ jsxs(Fragment, { children: [
3147
+ /* @__PURE__ */ jsx("span", { className: "usa-sr-only", children: "External." }),
3148
+ /* @__PURE__ */ jsx(Icon, { name: "launch", size: 1, className: "margin-left-05" })
3149
+ ] });
3145
3150
  function PrimaryNav({
3146
3151
  navSections,
3147
3152
  megamenu,
3148
3153
  showSecondary = false,
3149
3154
  secondaryLinks = [],
3150
3155
  searchProps = null,
3156
+ utilityContent = null,
3151
3157
  headerId = "header",
3152
3158
  renderSearchDirectly = false
3153
3159
  }) {
3154
3160
  const navClasses = classNames("usa-nav__primary", "usa-accordion");
3155
3161
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3156
3162
  /* @__PURE__ */ jsx("button", { type: "button", className: "usa-nav__close", children: /* @__PURE__ */ jsx(Icon, { name: "close" }) }),
3157
- /* @__PURE__ */ jsx("ul", { className: navClasses, children: navSections.map((section, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__primary-item", children: section.href ? /* @__PURE__ */ jsx("a", { href: section.href, className: "usa-nav__link", "aria-label": section.ariaLabel, children: /* @__PURE__ */ jsx("span", { children: section.title }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
3163
+ /* @__PURE__ */ jsx("ul", { className: navClasses, children: navSections.map((section, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__primary-item", children: section.href ? /* @__PURE__ */ jsxs(
3164
+ "a",
3165
+ {
3166
+ href: section.href,
3167
+ className: "usa-nav__link",
3168
+ "aria-label": section.ariaLabel,
3169
+ children: [
3170
+ /* @__PURE__ */ jsx("span", { children: section.title }),
3171
+ section.external && externalIndicator
3172
+ ]
3173
+ }
3174
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
3158
3175
  /* @__PURE__ */ jsx(
3159
3176
  "button",
3160
3177
  {
@@ -3173,12 +3190,45 @@ function PrimaryNav({
3173
3190
  const startIndex = colIndex * linksPerColumn;
3174
3191
  const endIndex = Math.min(startIndex + linksPerColumn, links.length);
3175
3192
  const columnLinks = links.slice(startIndex, endIndex);
3176
- return /* @__PURE__ */ jsx("div", { className: "usa-col", children: /* @__PURE__ */ jsx("ul", { className: "usa-nav__submenu-list", children: columnLinks.map((link, linkIndex) => /* @__PURE__ */ jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsx("a", { href: link.href, "aria-label": link.ariaLabel, children: link.text }) }, linkIndex)) }) }, colIndex);
3193
+ return /* @__PURE__ */ jsx("div", { className: "usa-col", children: /* @__PURE__ */ jsx("ul", { className: "usa-nav__submenu-list", children: columnLinks.map((link, linkIndex) => /* @__PURE__ */ jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxs(
3194
+ "a",
3195
+ {
3196
+ href: link.href,
3197
+ "aria-label": link.ariaLabel,
3198
+ children: [
3199
+ link.text,
3200
+ link.external && externalIndicator
3201
+ ]
3202
+ }
3203
+ ) }, linkIndex)) }) }, colIndex);
3177
3204
  });
3178
- })() }) }) : /* @__PURE__ */ jsx("ul", { id: `${headerId}-nav-section-${index}`, className: "usa-nav__submenu", hidden: true, children: section.links.map((link, linkIndex) => /* @__PURE__ */ jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsx("a", { href: link.href, "aria-label": link.ariaLabel, children: /* @__PURE__ */ jsx("span", { children: link.text }) }) }, linkIndex)) }))
3205
+ })() }) }) : /* @__PURE__ */ jsx("ul", { id: `${headerId}-nav-section-${index}`, className: "usa-nav__submenu", hidden: true, children: section.links.map((link, linkIndex) => /* @__PURE__ */ jsx("li", { className: "usa-nav__submenu-item", children: /* @__PURE__ */ jsxs(
3206
+ "a",
3207
+ {
3208
+ href: link.href,
3209
+ "aria-label": link.ariaLabel,
3210
+ children: [
3211
+ /* @__PURE__ */ jsx("span", { children: link.text }),
3212
+ link.external && externalIndicator
3213
+ ]
3214
+ }
3215
+ ) }, linkIndex)) }))
3179
3216
  ] }) }, index)) }),
3180
- showSecondary && /* @__PURE__ */ jsx("div", { className: "usa-nav__secondary", children: /* @__PURE__ */ jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsx("a", { href: link.href, "aria-label": link.ariaLabel, children: /* @__PURE__ */ jsx("span", { children: link.text }) }) }, index)) }) }),
3181
- renderSearchDirectly && searchProps && /* @__PURE__ */ jsx(Search, { ...searchProps })
3217
+ showSecondary && /* @__PURE__ */ jsx("div", { className: "usa-nav__secondary", children: /* @__PURE__ */ jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxs(
3218
+ "a",
3219
+ {
3220
+ href: link.href,
3221
+ "aria-label": link.ariaLabel,
3222
+ children: [
3223
+ /* @__PURE__ */ jsx("span", { children: link.text }),
3224
+ link.external && externalIndicator
3225
+ ]
3226
+ }
3227
+ ) }, index)) }) }),
3228
+ renderSearchDirectly && (utilityContent || searchProps) && /* @__PURE__ */ jsxs("div", { className: "usx-nav__utility", children: [
3229
+ utilityContent,
3230
+ searchProps && /* @__PURE__ */ jsx(Search, { ...searchProps })
3231
+ ] })
3182
3232
  ] });
3183
3233
  }
3184
3234
  function Header({
@@ -3193,6 +3243,8 @@ function Header({
3193
3243
  useMenuIcon = false,
3194
3244
  stickyNav = false,
3195
3245
  className = "",
3246
+ utilityContent = null,
3247
+ navEndContent = null,
3196
3248
  ...props
3197
3249
  }) {
3198
3250
  const headerClasses = classNames(
@@ -3226,9 +3278,23 @@ function Header({
3226
3278
  }
3227
3279
  ),
3228
3280
  /* @__PURE__ */ jsxs("div", { className: "usa-nav__secondary", children: [
3229
- /* @__PURE__ */ jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsx("a", { href: link.href, "aria-label": link.ariaLabel, children: /* @__PURE__ */ jsx("span", { children: link.text }) }) }, index)) }),
3230
- searchProps && /* @__PURE__ */ jsx(Search, { ...searchProps })
3231
- ] })
3281
+ /* @__PURE__ */ jsx("ul", { className: "usa-nav__secondary-links", children: secondaryLinks.map((link, index) => /* @__PURE__ */ jsx("li", { className: "usa-nav__secondary-item", children: /* @__PURE__ */ jsxs(
3282
+ "a",
3283
+ {
3284
+ href: link.href,
3285
+ "aria-label": link.ariaLabel,
3286
+ children: [
3287
+ /* @__PURE__ */ jsx("span", { children: link.text }),
3288
+ link.external && externalIndicator
3289
+ ]
3290
+ }
3291
+ ) }, index)) }),
3292
+ (utilityContent || searchProps) && /* @__PURE__ */ jsxs("div", { className: "usx-nav__utility", children: [
3293
+ utilityContent,
3294
+ searchProps && /* @__PURE__ */ jsx(Search, { ...searchProps })
3295
+ ] })
3296
+ ] }),
3297
+ navEndContent && /* @__PURE__ */ jsx("div", { className: "usx-nav__end-slot", children: navEndContent })
3232
3298
  ] }) })
3233
3299
  ] });
3234
3300
  }
@@ -3242,6 +3308,7 @@ function Header({
3242
3308
  showSecondary: false,
3243
3309
  secondaryLinks,
3244
3310
  searchProps,
3311
+ utilityContent,
3245
3312
  headerId: id,
3246
3313
  renderSearchDirectly: true
3247
3314
  }
@@ -5761,7 +5828,7 @@ function ThemePicker({
5761
5828
  "button",
5762
5829
  {
5763
5830
  type: "button",
5764
- className: "usa-button usx-button usx-button--ghost usx-theme-picker__trigger",
5831
+ className: "usa-button usx-button usx-button--ghost text-muted usx-theme-picker__trigger",
5765
5832
  "aria-label": label,
5766
5833
  onClick: () => setOpen(true),
5767
5834
  children: /* @__PURE__ */ jsx(PaletteIcon, {})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solexllc/usx-react",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "React component library for USX.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,13 +24,10 @@
24
24
  "src",
25
25
  "dist"
26
26
  ],
27
- "scripts": {
28
- "build": "vite build"
29
- },
30
27
  "dependencies": {
31
- "@solexllc/usx": "workspace:*",
32
- "@solexllc/usx-theme": "workspace:*",
33
- "@solexllc/usx-uswds-fixes": "workspace:*",
28
+ "@solexllc/usx": "0.1.2",
29
+ "@solexllc/usx-theme": "0.1.1",
30
+ "@solexllc/usx-uswds-fixes": "0.1.1",
34
31
  "classnames": "^2.5.1",
35
32
  "prop-types": "^15.8.1"
36
33
  },
@@ -44,5 +41,8 @@
44
41
  "peerDependencies": {
45
42
  "react": ">=17",
46
43
  "react-dom": ">=17"
44
+ },
45
+ "scripts": {
46
+ "build": "vite build"
47
47
  }
48
- }
48
+ }
@@ -4,10 +4,18 @@ import Icon from '../icon/Icon';
4
4
  import Search, { SearchProps } from '../search/Search';
5
5
  import Branding, { BrandingProps } from './Branding';
6
6
 
7
+ const externalIndicator = (
8
+ <>
9
+ <span className="usa-sr-only">External.</span>
10
+ <Icon name="launch" size={1} className="margin-left-05" />
11
+ </>
12
+ );
13
+
7
14
  export interface HeaderNavLink {
8
15
  text: string;
9
16
  href: string;
10
17
  ariaLabel?: string;
18
+ external?: boolean;
11
19
  }
12
20
 
13
21
  export interface HeaderNavSection {
@@ -15,6 +23,7 @@ export interface HeaderNavSection {
15
23
  links?: HeaderNavLink[];
16
24
  href?: string;
17
25
  ariaLabel?: string;
26
+ external?: boolean;
18
27
  }
19
28
 
20
29
  interface PrimaryNavProps {
@@ -23,6 +32,7 @@ interface PrimaryNavProps {
23
32
  showSecondary?: boolean;
24
33
  secondaryLinks?: HeaderNavLink[];
25
34
  searchProps?: SearchProps | null;
35
+ utilityContent?: React.ReactNode;
26
36
  headerId?: string;
27
37
  renderSearchDirectly?: boolean;
28
38
  }
@@ -33,6 +43,7 @@ function PrimaryNav({
33
43
  showSecondary = false,
34
44
  secondaryLinks = [],
35
45
  searchProps = null,
46
+ utilityContent = null,
36
47
  headerId = 'header',
37
48
  renderSearchDirectly = false,
38
49
  }: PrimaryNavProps) {
@@ -47,8 +58,13 @@ function PrimaryNav({
47
58
  {navSections.map((section, index) => (
48
59
  <li key={index} className="usa-nav__primary-item">
49
60
  {section.href ? (
50
- <a href={section.href} className="usa-nav__link" aria-label={section.ariaLabel}>
61
+ <a
62
+ href={section.href}
63
+ className="usa-nav__link"
64
+ aria-label={section.ariaLabel}
65
+ >
51
66
  <span>{section.title}</span>
67
+ {section.external && externalIndicator}
52
68
  </a>
53
69
  ) : (
54
70
  <>
@@ -77,8 +93,12 @@ function PrimaryNav({
77
93
  <ul className="usa-nav__submenu-list">
78
94
  {columnLinks.map((link, linkIndex) => (
79
95
  <li key={linkIndex} className="usa-nav__submenu-item">
80
- <a href={link.href} aria-label={link.ariaLabel}>
96
+ <a
97
+ href={link.href}
98
+ aria-label={link.ariaLabel}
99
+ >
81
100
  {link.text}
101
+ {link.external && externalIndicator}
82
102
  </a>
83
103
  </li>
84
104
  ))}
@@ -93,8 +113,12 @@ function PrimaryNav({
93
113
  <ul id={`${headerId}-nav-section-${index}`} className="usa-nav__submenu" hidden={true}>
94
114
  {section.links!.map((link, linkIndex) => (
95
115
  <li key={linkIndex} className="usa-nav__submenu-item">
96
- <a href={link.href} aria-label={link.ariaLabel}>
116
+ <a
117
+ href={link.href}
118
+ aria-label={link.ariaLabel}
119
+ >
97
120
  <span>{link.text}</span>
121
+ {link.external && externalIndicator}
98
122
  </a>
99
123
  </li>
100
124
  ))}
@@ -111,15 +135,24 @@ function PrimaryNav({
111
135
  <ul className="usa-nav__secondary-links">
112
136
  {secondaryLinks.map((link, index) => (
113
137
  <li key={index} className="usa-nav__secondary-item">
114
- <a href={link.href} aria-label={link.ariaLabel}>
138
+ <a
139
+ href={link.href}
140
+ aria-label={link.ariaLabel}
141
+ >
115
142
  <span>{link.text}</span>
143
+ {link.external && externalIndicator}
116
144
  </a>
117
145
  </li>
118
146
  ))}
119
147
  </ul>
120
148
  </div>
121
149
  )}
122
- {renderSearchDirectly && searchProps && <Search {...searchProps} />}
150
+ {renderSearchDirectly && (utilityContent || searchProps) && (
151
+ <div className="usx-nav__utility">
152
+ {utilityContent}
153
+ {searchProps && <Search {...searchProps} />}
154
+ </div>
155
+ )}
123
156
  </>
124
157
  );
125
158
  }
@@ -136,6 +169,10 @@ export interface HeaderProps extends React.HTMLAttributes<HTMLElement> {
136
169
  useMenuIcon?: boolean;
137
170
  stickyNav?: boolean;
138
171
  className?: string;
172
+ /** Rendered inline, to the left of the search box (in both header variants). */
173
+ utilityContent?: React.ReactNode;
174
+ /** Rendered right-justified, in line with the primary nav links (extended header only). */
175
+ navEndContent?: React.ReactNode;
139
176
  }
140
177
 
141
178
  export default function Header({
@@ -150,6 +187,8 @@ export default function Header({
150
187
  useMenuIcon = false,
151
188
  stickyNav = false,
152
189
  className = '',
190
+ utilityContent = null,
191
+ navEndContent = null,
153
192
  ...props
154
193
  }: HeaderProps) {
155
194
  const headerClasses = ClassNames(
@@ -194,14 +233,24 @@ export default function Header({
194
233
  <ul className="usa-nav__secondary-links">
195
234
  {secondaryLinks.map((link, index) => (
196
235
  <li key={index} className="usa-nav__secondary-item">
197
- <a href={link.href} aria-label={link.ariaLabel}>
236
+ <a
237
+ href={link.href}
238
+ aria-label={link.ariaLabel}
239
+ >
198
240
  <span>{link.text}</span>
241
+ {link.external && externalIndicator}
199
242
  </a>
200
243
  </li>
201
244
  ))}
202
245
  </ul>
203
- {searchProps && <Search {...searchProps} />}
246
+ {(utilityContent || searchProps) && (
247
+ <div className="usx-nav__utility">
248
+ {utilityContent}
249
+ {searchProps && <Search {...searchProps} />}
250
+ </div>
251
+ )}
204
252
  </div>
253
+ {navEndContent && <div className="usx-nav__end-slot">{navEndContent}</div>}
205
254
  </div>
206
255
  </nav>
207
256
  </>
@@ -219,6 +268,7 @@ export default function Header({
219
268
  showSecondary={false}
220
269
  secondaryLinks={secondaryLinks}
221
270
  searchProps={searchProps}
271
+ utilityContent={utilityContent}
222
272
  headerId={id}
223
273
  renderSearchDirectly={true}
224
274
  />
@@ -53,6 +53,14 @@
53
53
  "className": {
54
54
  "type": "string",
55
55
  "description": "Additional classes"
56
+ },
57
+ "utilityContent": {
58
+ "type": "slot",
59
+ "description": "Rendered inline, to the left of the search box (in both header variants)."
60
+ },
61
+ "navEndContent": {
62
+ "type": "slot",
63
+ "description": "Rendered right-justified, in line with the primary nav links (extended header only)."
56
64
  }
57
65
  }
58
66
  }
@@ -56,7 +56,7 @@
56
56
  </em>
57
57
  {% endif %}
58
58
  </div>
59
- <button type="button" class="usa-menu-btn">
59
+ <button type="button" class="usa-menu-btn align-center">
60
60
  {% if useMenuIcon %}
61
61
  {% icon name='menu' size=3 %}{% endicon %}
62
62
  {% else %}
@@ -65,130 +65,144 @@
65
65
  </button>
66
66
  </div>
67
67
 
68
- {% if extended %}
69
- <nav aria-label="Primary navigation" class="usa-nav usx-nav">
70
- <div class="usa-nav__inner">
71
- <button type="button" class="usa-nav__close">
72
- {% icon name='close' %}{% endicon %}
73
- </button>
74
- <ul class="usa-nav__primary usa-accordion">
75
- {% for section in navSections %}
76
- <li class="usa-nav__primary-item">
77
- {% if section.href %}
78
- <a href="{{ section.href }}" class="usa-nav__link" {% if section.ariaLabel %}aria-label="{{ section.ariaLabel }}"{% endif %}>
79
- <span>{{ section.title }}</span>
80
- </a>
81
- {% else %}
82
- <button type="button" class="usa-accordion__button usa-nav__link" aria-expanded="false" aria-controls="{{ id }}-nav-section-{{ forloop.counter0 }}">
83
- <span>{{ section.title }}</span>
84
- </button>
85
- {% if section.links %}
86
- {% if megamenu %}
87
- <div id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu usa-megamenu" hidden="hidden">
88
- <div class="grid-row grid-gap-4">
89
- <div class="usa-col">
90
- <ul class="usa-nav__submenu-list">
91
- {% for link in section.links %}
92
- <li class="usa-nav__submenu-item">
93
- <a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
94
- {{ link.text }}
95
- </a>
96
- </li>
97
- {% endfor %}
98
- </ul>
99
- </div>
68
+ {% if not extended %}
69
+ <nav aria-label="Primary navigation" class="usa-nav usx-nav{% if stickyNav %} usx-nav--sticky{% endif %}">
70
+ <button type="button" class="usa-nav__close">
71
+ {% icon name='close' %}{% endicon %}
72
+ </button>
73
+ <ul class="usa-nav__primary usa-accordion">
74
+ {% for section in navSections %}
75
+ <li class="usa-nav__primary-item">
76
+ {% if section.href %}
77
+ <a href="{{ section.href }}" class="usa-nav__link" {% if section.ariaLabel %}aria-label="{{ section.ariaLabel }}"{% endif %}>
78
+ <span>{{ section.title }}</span>
79
+ {% if section.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
80
+ </a>
81
+ {% else %}
82
+ <button type="button" class="usa-accordion__button usa-nav__link" aria-expanded="false" aria-controls="{{ id }}-nav-section-{{ forloop.counter0 }}">
83
+ <span>{{ section.title }}</span>
84
+ </button>
85
+ {% if section.links %}
86
+ {% if megamenu %}
87
+ <div id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu usa-megamenu" hidden="hidden">
88
+ <div class="grid-row grid-gap-4">
89
+ <div class="usa-col">
90
+ <ul class="usa-nav__submenu-list">
91
+ {% for link in section.links %}
92
+ <li class="usa-nav__submenu-item">
93
+ <a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
94
+ {{ link.text }}
95
+ {% if link.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
96
+ </a>
97
+ </li>
98
+ {% endfor %}
99
+ </ul>
100
100
  </div>
101
101
  </div>
102
- {% else %}
103
- <ul id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu" hidden="hidden">
104
- {% for link in section.links %}
105
- <li class="usa-nav__submenu-item">
106
- <a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
107
- <span>{{ link.text }}</span>
108
- </a>
109
- </li>
110
- {% endfor %}
111
- </ul>
112
- {% endif %}
102
+ </div>
103
+ {% else %}
104
+ <ul id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu" hidden="hidden">
105
+ {% for link in section.links %}
106
+ <li class="usa-nav__submenu-item">
107
+ <a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
108
+ <span>{{ link.text }}</span>
109
+ {% if link.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
110
+ </a>
111
+ </li>
112
+ {% endfor %}
113
+ </ul>
113
114
  {% endif %}
114
115
  {% endif %}
115
- </li>
116
- {% endfor %}
117
- </ul>
118
- <div class="usa-nav__secondary">
119
- <ul class="usa-nav__secondary-links">
120
- {% for link in secondaryLinks %}
121
- <li class="usa-nav__secondary-item">
122
- <a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
123
- <span>{{ link.text }}</span>
124
- </a>
125
- </li>
126
- {% endfor %}
127
- </ul>
116
+ {% endif %}
117
+ </li>
118
+ {% endfor %}
119
+ </ul>
120
+ {% if utilityContent or searchProps %}
121
+ <div class="usx-nav__utility">
122
+ {% if utilityContent %}{{ utilityContent|safe }}{% endif %}
128
123
  {% if searchProps %}
129
124
  {% search id=searchProps.id ariaLabel=searchProps.ariaLabel searchKey=searchProps.searchKey label=searchProps.label icon=searchProps.icon iconOnly=searchProps.iconOnly buttonVariant=searchProps.buttonVariant big=searchProps.big action=searchProps.action placeholder=searchProps.placeholder defaultValue=searchProps.defaultValue onSubmit=searchProps.onSubmit className=searchProps.className|default:'' %}{% endsearch %}
130
125
  {% endif %}
131
126
  </div>
132
- </div>
127
+ {% endif %}
133
128
  </nav>
134
- {% else %}
135
-
136
- <nav aria-label="Primary navigation" class="usa-nav usx-nav">
137
- <button type="button" class="usa-nav__close">
138
- {% icon name='close' %}{% endicon %}
139
- </button>
140
- <ul class="usa-nav__primary usa-accordion">
141
- {% for section in navSections %}
142
- <li class="usa-nav__primary-item">
143
- {% if section.href %}
144
- <a href="{{ section.href }}" class="usa-nav__link" {% if section.ariaLabel %}aria-label="{{ section.ariaLabel }}"{% endif %}>
145
- <span>{{ section.title }}</span>
146
- </a>
147
- {% else %}
148
- <button type="button" class="usa-accordion__button usa-nav__link" aria-expanded="false" aria-controls="{{ id }}-nav-section-{{ forloop.counter0 }}">
149
- <span>{{ section.title }}</span>
150
- </button>
151
- {% if section.links %}
152
- {% if megamenu %}
153
- <div id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu usa-megamenu" hidden="hidden">
154
- <div class="grid-row grid-gap-4">
155
- <div class="usa-col">
156
- <ul class="usa-nav__submenu-list">
157
- {% for link in section.links %}
158
- <li class="usa-nav__submenu-item">
159
- <a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
160
- {{ link.text }}
161
- </a>
162
- </li>
163
- {% endfor %}
164
- </ul>
165
- </div>
129
+ {% endif %}
130
+ {% if not extended %}</div>{% endif %}
131
+ </header>
132
+ {% if extended %}
133
+ <nav aria-label="Primary navigation" class="usa-nav usx-nav{% if stickyNav %} usx-nav--sticky{% endif %}">
134
+ <div class="usa-nav__inner">
135
+ <button type="button" class="usa-nav__close">
136
+ {% icon name='close' %}{% endicon %}
137
+ </button>
138
+ <ul class="usa-nav__primary usa-accordion">
139
+ {% for section in navSections %}
140
+ <li class="usa-nav__primary-item">
141
+ {% if section.href %}
142
+ <a href="{{ section.href }}" class="usa-nav__link" {% if section.ariaLabel %}aria-label="{{ section.ariaLabel }}"{% endif %}>
143
+ <span>{{ section.title }}</span>
144
+ {% if section.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
145
+ </a>
146
+ {% else %}
147
+ <button type="button" class="usa-accordion__button usa-nav__link" aria-expanded="false" aria-controls="{{ id }}-nav-section-{{ forloop.counter0 }}">
148
+ <span>{{ section.title }}</span>
149
+ </button>
150
+ {% if section.links %}
151
+ {% if megamenu %}
152
+ <div id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu usa-megamenu" hidden="hidden">
153
+ <div class="grid-row grid-gap-4">
154
+ <div class="usa-col">
155
+ <ul class="usa-nav__submenu-list">
156
+ {% for link in section.links %}
157
+ <li class="usa-nav__submenu-item">
158
+ <a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
159
+ {{ link.text }}
160
+ {% if link.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
161
+ </a>
162
+ </li>
163
+ {% endfor %}
164
+ </ul>
166
165
  </div>
167
166
  </div>
168
- {% else %}
169
- <ul id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu" hidden="hidden">
170
- {% for link in section.links %}
171
- <li class="usa-nav__submenu-item">
172
- <a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
173
- <span>{{ link.text }}</span>
174
- </a>
175
- </li>
176
- {% endfor %}
177
- </ul>
178
- {% endif %}
167
+ </div>
168
+ {% else %}
169
+ <ul id="{{ id }}-nav-section-{{ forloop.counter0 }}" class="usa-nav__submenu" hidden="hidden">
170
+ {% for link in section.links %}
171
+ <li class="usa-nav__submenu-item">
172
+ <a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
173
+ <span>{{ link.text }}</span>
174
+ {% if link.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
175
+ </a>
176
+ </li>
177
+ {% endfor %}
178
+ </ul>
179
179
  {% endif %}
180
180
  {% endif %}
181
+ {% endif %}
182
+ </li>
183
+ {% endfor %}
184
+ </ul>
185
+ <div class="usa-nav__secondary">
186
+ <ul class="usa-nav__secondary-links">
187
+ {% for link in secondaryLinks %}
188
+ <li class="usa-nav__secondary-item">
189
+ <a href="{{ link.href }}" {% if link.ariaLabel %}aria-label="{{ link.ariaLabel }}"{% endif %}>
190
+ <span>{{ link.text }}</span>
191
+ {% if link.external %}<span class="usa-sr-only">External.</span>{% icon name='launch' size=1 className='margin-left-05' %}{% endicon %}{% endif %}
192
+ </a>
181
193
  </li>
182
194
  {% endfor %}
183
195
  </ul>
184
- {% if searchProps %}
185
- {% search id=searchProps.id ariaLabel=searchProps.ariaLabel searchKey=searchProps.searchKey label=searchProps.label icon=searchProps.icon iconOnly=searchProps.iconOnly buttonVariant=searchProps.buttonVariant big=searchProps.big action=searchProps.action placeholder=searchProps.placeholder defaultValue=searchProps.defaultValue onSubmit=searchProps.onSubmit className=searchProps.className|default:'' %}{% endsearch %}
196
+ {% if utilityContent or searchProps %}
197
+ <div class="usx-nav__utility">
198
+ {% if utilityContent %}{{ utilityContent|safe }}{% endif %}
199
+ {% if searchProps %}
200
+ {% search id=searchProps.id ariaLabel=searchProps.ariaLabel searchKey=searchProps.searchKey label=searchProps.label icon=searchProps.icon iconOnly=searchProps.iconOnly buttonVariant=searchProps.buttonVariant big=searchProps.big action=searchProps.action placeholder=searchProps.placeholder defaultValue=searchProps.defaultValue onSubmit=searchProps.onSubmit className=searchProps.className|default:'' %}{% endsearch %}
201
+ {% endif %}
202
+ </div>
186
203
  {% endif %}
187
- </nav>
204
+ </div>
205
+ {% if navEndContent %}<div class="usx-nav__end-slot">{{ navEndContent|safe }}</div>{% endif %}
188
206
  </div>
189
- {% endif %}
190
-
191
- {% if not extended %}
192
- </div>
193
- {% endif %}
194
- </header>
207
+ </nav>
208
+ {% endif %}
@@ -86,7 +86,7 @@ export default function ThemePicker({
86
86
  ) : (
87
87
  <button
88
88
  type="button"
89
- className="usa-button usx-button usx-button--ghost usx-theme-picker__trigger"
89
+ className="usa-button usx-button usx-button--ghost text-muted usx-theme-picker__trigger"
90
90
  aria-label={label}
91
91
  onClick={() => setOpen(true)}
92
92
  >