@solexllc/usx-react 0.3.1 → 0.5.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 (135) hide show
  1. package/README.md +132 -0
  2. package/dist/index.cjs +504 -450
  3. package/dist/index.js +504 -450
  4. package/package.json +6 -5
  5. package/src/assets.ts +16 -0
  6. package/src/components/alert/Alert.tsx +4 -3
  7. package/src/components/alert/alert.django.html +2 -3
  8. package/src/components/alert/config.json +15 -4
  9. package/src/components/attribution/config.json +5 -5
  10. package/src/components/banner/Banner.tsx +8 -6
  11. package/src/components/banner/banner.django.html +4 -5
  12. package/src/components/banner/config.json +7 -3
  13. package/src/components/breadcrumb/Breadcrumb.tsx +5 -6
  14. package/src/components/breadcrumb/config.json +11 -1
  15. package/src/components/button/Button.tsx +1 -1
  16. package/src/components/button/button.django.html +2 -2
  17. package/src/components/button/button.html +2 -2
  18. package/src/components/button/config.json +14 -6
  19. package/src/components/button-group/button-group.django.html +1 -1
  20. package/src/components/calendar-date/calendar-date.django.html +3 -3
  21. package/src/components/callout/Callout.tsx +53 -0
  22. package/src/components/callout/callout.django.html +5 -0
  23. package/src/components/callout/callout.html +76 -0
  24. package/src/components/callout/config.json +74 -0
  25. package/src/components/card/Card.tsx +18 -34
  26. package/src/components/card/card.django.html +12 -10
  27. package/src/components/card/config.json +15 -40
  28. package/src/components/card-group/card-group.django.html +1 -1
  29. package/src/components/carousel/Carousel.tsx +3 -2
  30. package/src/components/carousel/carousel.django.html +13 -2
  31. package/src/components/carousel/config.json +2 -2
  32. package/src/components/character-count/config.json +2 -2
  33. package/src/components/checkbox-group/CheckboxGroup.tsx +10 -20
  34. package/src/components/checkbox-group/checkbox-group.django.html +10 -4
  35. package/src/components/checkbox-group/config.json +10 -5
  36. package/src/components/clickable/clickable.html +21 -39
  37. package/src/components/clickable/config.json +2 -2
  38. package/src/components/code/Code.tsx +4 -27
  39. package/src/components/code/code.django.html +3 -9
  40. package/src/components/code/config.json +4 -0
  41. package/src/components/collection/Collection.tsx +5 -5
  42. package/src/components/collection/collection.django.html +2 -4
  43. package/src/components/collection/config.json +7 -6
  44. package/src/components/combobox/config.json +4 -4
  45. package/src/components/copy-to-clipboard/CopyToClipboard.tsx +35 -24
  46. package/src/components/copy-to-clipboard/config.json +14 -7
  47. package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +14 -14
  48. package/src/components/date-picker/config.json +4 -4
  49. package/src/components/date-range-picker/config.json +7 -7
  50. package/src/components/error-message/config.json +2 -2
  51. package/src/components/eyebrow/Eyebrow.tsx +2 -1
  52. package/src/components/eyebrow/config.json +2 -2
  53. package/src/components/fieldset/config.json +5 -5
  54. package/src/components/file-input/FileInput.tsx +3 -2
  55. package/src/components/file-input/config.json +5 -5
  56. package/src/components/file-list/FileList.tsx +2 -1
  57. package/src/components/file-list/config.json +2 -2
  58. package/src/components/footer/Footer.tsx +31 -11
  59. package/src/components/footer/config.json +4 -0
  60. package/src/components/footer/footer.django.html +10 -9
  61. package/src/components/form-group/config.json +2 -2
  62. package/src/components/header/Branding.tsx +9 -6
  63. package/src/components/header/Header.tsx +3 -1
  64. package/src/components/header/config.json +4 -0
  65. package/src/components/header/header.django.html +5 -26
  66. package/src/components/header/header.html +10 -10
  67. package/src/components/hero/Hero.tsx +8 -14
  68. package/src/components/hero/config.json +36 -27
  69. package/src/components/hero/hero.django.html +2 -2
  70. package/src/components/hint/config.json +2 -2
  71. package/src/components/icon/Icon.tsx +6 -3
  72. package/src/components/icon/config.json +12 -6
  73. package/src/components/icon/icon.django.html +6 -4
  74. package/src/components/image/Image.tsx +8 -4
  75. package/src/components/image/config.json +10 -2
  76. package/src/components/image/image.django.html +8 -6
  77. package/src/components/in-page-nav/config.json +11 -1
  78. package/src/components/indicator/config.json +2 -2
  79. package/src/components/input/config.json +2 -2
  80. package/src/components/label/config.json +2 -2
  81. package/src/components/language-selector/config.json +2 -2
  82. package/src/components/layout/Layout.tsx +1 -1
  83. package/src/components/layout/config.json +9 -9
  84. package/src/components/layout/layout.django.html +1 -1
  85. package/src/components/legend/config.json +3 -3
  86. package/src/components/link/config.json +2 -2
  87. package/src/components/memorable-date/config.json +9 -9
  88. package/src/components/misc-banner/MiscBanner.tsx +2 -1
  89. package/src/components/misc-banner/config.json +2 -2
  90. package/src/components/modal/config.json +2 -2
  91. package/src/components/page/Page.tsx +2 -1
  92. package/src/components/page/config.json +7 -7
  93. package/src/components/page/page.django.html +1 -1
  94. package/src/components/pagination/Pagination.tsx +2 -1
  95. package/src/components/pagination/container/PaginationContainer.tsx +2 -1
  96. package/src/components/prose/config.json +5 -1
  97. package/src/components/quote/Quote.tsx +58 -0
  98. package/src/components/quote/config.json +51 -0
  99. package/src/components/quote/quote.django.html +15 -0
  100. package/src/components/quote/quote.html +66 -0
  101. package/src/components/radio-buttons/config.json +3 -3
  102. package/src/components/range-slider/RangeSlider.tsx +2 -1
  103. package/src/components/range-slider/config.json +4 -4
  104. package/src/components/required/config.json +2 -2
  105. package/src/components/section/Section.tsx +6 -2
  106. package/src/components/section/config.json +19 -6
  107. package/src/components/section/section.django.html +9 -2
  108. package/src/components/select/config.json +2 -2
  109. package/src/components/site-alert/SiteAlert.tsx +5 -6
  110. package/src/components/skipnav/config.json +2 -2
  111. package/src/components/spinner/Spinner.tsx +18 -25
  112. package/src/components/spinner/config.json +4 -0
  113. package/src/components/spinner/spinner.django.html +4 -6
  114. package/src/components/summary-box/config.json +3 -3
  115. package/src/components/swap/Swap.tsx +4 -3
  116. package/src/components/swap/config.json +4 -4
  117. package/src/components/switch/config.json +2 -2
  118. package/src/components/table/config.json +13 -3
  119. package/src/components/tag/config.json +2 -2
  120. package/src/components/tag-group/config.json +2 -2
  121. package/src/components/text-area/config.json +2 -2
  122. package/src/components/time-picker/config.json +4 -4
  123. package/src/components/toggle/Toggle.tsx +69 -40
  124. package/src/components/toggle/config.json +42 -10
  125. package/src/components/toggle/toggle.django.html +25 -17
  126. package/src/components/toggle/toggle.html +319 -85
  127. package/src/components/tooltip/Tooltip.tsx +4 -2
  128. package/src/components/tooltip/config.json +9 -4
  129. package/src/components/tooltip/tooltip.django.html +1 -1
  130. package/src/components/villain/Villain.tsx +2 -1
  131. package/src/index.js +2 -1
  132. package/src/components/block/Block.tsx +0 -78
  133. package/src/components/block/block.django.html +0 -26
  134. package/src/components/block/block.html +0 -162
  135. package/src/components/block/config.json +0 -88
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "hint",
3
3
  "template": "hint/hint.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "id": {
7
7
  "type": "string",
8
8
  "description": "Element id, referenced by the associated field's aria-describedby"
9
9
  },
10
10
  "children": {
11
- "type": "string",
11
+ "type": "slot",
12
12
  "description": "Inner HTML or text"
13
13
  },
14
14
  "className": {
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { getAssetUrl as assetUrl } from '../../assets';
2
3
 
3
4
  export interface IconProps extends React.SVGProps<SVGSVGElement> {
4
5
  name: string;
@@ -6,6 +7,7 @@ export interface IconProps extends React.SVGProps<SVGSVGElement> {
6
7
  size?: number;
7
8
  color?: string;
8
9
  alt?: string;
10
+ staticBaseUrl?: string;
9
11
  staticUrlPrefix?: string;
10
12
  className?: string;
11
13
  }
@@ -19,11 +21,12 @@ export default function Icon({
19
21
  size = 2,
20
22
  color,
21
23
  alt = name + ' icon',
22
- staticUrlPrefix = ((typeof window !== 'undefined' && (window as unknown as { usxBaseUrl?: string }).usxBaseUrl) || '/') +
23
- 'img/' + (source === 'usx' ? 'usx-sprite.svg' : 'sprite.svg') + '#',
24
+ staticBaseUrl,
25
+ staticUrlPrefix,
24
26
  className = '',
25
27
  ...props
26
28
  }: IconProps) {
29
+ const spritePrefix = staticUrlPrefix ?? assetUrl(`img/${source === 'usx' ? 'usx-sprite.svg' : 'sprite.svg'}#`, staticBaseUrl);
27
30
  return (
28
31
  <svg
29
32
  className={
@@ -40,7 +43,7 @@ export default function Icon({
40
43
  role="img"
41
44
  {...props}
42
45
  >
43
- <use href={staticUrlPrefix + name} />
46
+ <use href={spritePrefix + name} />
44
47
  </svg>
45
48
  );
46
49
  }
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "icon",
3
3
  "template": "icon/icon.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
+ "staticBaseUrl": {
7
+ "type": "string",
8
+ "description": "Optional asset base for this component. A non-empty value overrides window.usxBaseUrl in React or STATIC_URL in Django; otherwise the global base or / is used. Asset filenames remain separate."
9
+ },
6
10
  "name": {
7
11
  "type": "string",
8
12
  "default": "accessibility_new",
@@ -38,8 +42,7 @@
38
42
  },
39
43
  "staticUrlPrefix": {
40
44
  "type": "string",
41
- "default": "/img/sprite.svg#",
42
- "description": "The URL prefix for the static assets, which is used to construct the full URL for the icon sprite sheet or icon library being used."
45
+ "description": "Legacy full sprite URL prefix, including #, overriding automatic asset resolution. Use staticBaseUrl to change only the base directory."
43
46
  },
44
47
  "className": {
45
48
  "type": "string",
@@ -52,9 +55,12 @@
52
55
  "description": "Alternative text for the icon, used for accessibility purposes to provide a textual description of the icon's meaning or function."
53
56
  },
54
57
  "style": {
55
- "type": "string",
56
- "default": "",
57
- "description": "Inline styles to apply to the icon component."
58
+ "type": ["string", "object"],
59
+ "description": "Inline styles: a React CSSProperties object in React or a CSS declaration string in Django. Omit to leave inline styles unset.",
60
+ "renderers": {
61
+ "react": { "type": "object" },
62
+ "django": { "type": "string" }
63
+ }
58
64
  }
59
65
  }
60
66
  }
@@ -1,4 +1,4 @@
1
- {% load static %}
1
+ {% load components %}
2
2
 
3
3
  <svg
4
4
  class="
@@ -18,9 +18,11 @@
18
18
  focusable="false"
19
19
  role="img"
20
20
  >
21
- {% if source == 'usx' %}
22
- <use href="{% static 'img/usx-sprite.svg' %}#{{ name }}"></use>
21
+ {% if staticUrlPrefix %}
22
+ <use href="{{ staticUrlPrefix }}{{ name }}"></use>
23
+ {% elif source == 'usx' %}
24
+ <use href="{% asset_url 'img/usx-sprite.svg' staticBaseUrl %}#{{ name }}"></use>
23
25
  {% else %}
24
- <use href="{% static 'img/sprite.svg' %}#{{ name }}"></use>
26
+ <use href="{% asset_url 'img/sprite.svg' staticBaseUrl %}#{{ name }}"></use>
25
27
  {% endif %}
26
28
  </svg>
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import classNames from 'classnames';
3
+ import { getAssetUrl, getAssetSrcSet } from '../../assets';
3
4
 
4
5
  export interface ImageSource {
5
6
  srcSet: string;
@@ -13,7 +14,7 @@ export interface ResponsiveImage {
13
14
  sources: ImageSource[];
14
15
  }
15
16
 
16
- export interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
17
+ export interface ImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, 'src'> {
17
18
  src: string | ResponsiveImage;
18
19
  alt?: string;
19
20
  href?: string;
@@ -24,6 +25,7 @@ export interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
24
25
  objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down' | '';
25
26
  maxWidth?: string | number;
26
27
  maxHeight?: string | number;
28
+ staticBaseUrl?: string;
27
29
  className?: string;
28
30
  }
29
31
 
@@ -38,6 +40,8 @@ export default function Image({
38
40
  objectFit = '',
39
41
  maxWidth,
40
42
  maxHeight,
43
+ staticBaseUrl,
44
+ srcSet,
41
45
  className = '',
42
46
  ...props
43
47
  }: ImageProps) {
@@ -72,15 +76,15 @@ export default function Image({
72
76
  <source
73
77
  key={i}
74
78
  {...(source.media ? { media: source.media } : {})}
75
- srcSet={source.srcSet}
79
+ srcSet={getAssetSrcSet(source.srcSet, staticBaseUrl)}
76
80
  {...(source.type ? { type: source.type } : {})}
77
81
  {...(source.sizes ? { sizes: source.sizes } : {})}
78
82
  />
79
83
  ))}
80
- <img src={(src as ResponsiveImage).fallback} alt={alt} style={style} {...props} />
84
+ <img src={getAssetUrl((src as ResponsiveImage).fallback, staticBaseUrl)} srcSet={srcSet ? getAssetSrcSet(srcSet, staticBaseUrl) : undefined} alt={alt} style={style} {...props} />
81
85
  </picture>
82
86
  ) : (
83
- <img src={src as string} alt={alt} style={style} {...props} />
87
+ <img src={getAssetUrl(src as string, staticBaseUrl)} srcSet={srcSet ? getAssetSrcSet(srcSet, staticBaseUrl) : undefined} alt={alt} style={style} {...props} />
84
88
  );
85
89
 
86
90
  if (caption) {
@@ -6,9 +6,17 @@
6
6
  "src"
7
7
  ],
8
8
  "props": {
9
- "src": {
9
+ "staticBaseUrl": {
10
+ "type": "string",
11
+ "description": "Optional image asset base, overriding window.usxBaseUrl in React or STATIC_URL in Django. Defaults to the global base or /."
12
+ },
13
+ "srcSet": {
10
14
  "type": "string",
11
- "description": "Image source URL"
15
+ "description": "Optional image source candidates and width/density descriptors. Each candidate path is resolved against the image asset base."
16
+ },
17
+ "src": {
18
+ "type": ["string", "object"],
19
+ "description": "Image asset path or responsive object { fallback, sources: [{ srcSet, media?, type?, sizes? }] }. Paths resolve against the asset base; fully qualified and data URLs are unchanged."
12
20
  },
13
21
  "alt": {
14
22
  "type": "string",
@@ -1,4 +1,6 @@
1
1
  {# Django template for Image #}
2
+ {% load components %}
3
+ {% if srcSet %}{% asset_srcset srcSet staticBaseUrl as imageSrcSet %}{% endif %}
2
4
  {# Props: src, alt, href, rounded, circular, objectFit, maxWidth, maxHeight, caption, hideCaption, className #}
3
5
  {# For responsive images, src may be an object: { fallback, sources: [{ srcSet, media?, type?, sizes? }] } #}
4
6
 
@@ -16,17 +18,17 @@
16
18
  {% if src.fallback %}
17
19
  <picture>
18
20
  {% for source in src.sources %}
19
- <source srcset="{{ source.srcSet }}"
21
+ <source srcset="{% asset_srcset source.srcSet staticBaseUrl %}"
20
22
  {% if source.media %}media="{{ source.media }}"{% endif %}
21
23
  {% if source.type %}type="{{ source.type }}"{% endif %}
22
24
  {% if source.sizes %}sizes="{{ source.sizes }}"{% endif %}
23
25
  />
24
26
  {% endfor %}
25
- <img src="{{ src.fallback }}"{% if alt %} alt="{{ alt }}"{% endif %}
27
+ <img src="{% asset_url src.fallback staticBaseUrl %}"{% if imageSrcSet %} srcset="{{ imageSrcSet }}"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}
26
28
  {% if maxWidth or maxHeight %}style="{% if maxWidth %}max-width: {{ maxWidth }};{% if not maxHeight %} height: auto;{% endif %}{% endif %}{% if maxHeight %} max-height: {{ maxHeight }};{% if not maxWidth %} width: auto;{% endif %}{% endif %}"{% endif %} />
27
29
  </picture>
28
30
  {% elif src %}
29
- <img src="{{ src }}"{% if alt %} alt="{{ alt }}"{% endif %}
31
+ <img src="{% asset_url src staticBaseUrl %}"{% if imageSrcSet %} srcset="{{ imageSrcSet }}"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}
30
32
  {% if maxWidth or maxHeight %}style="{% if maxWidth %}max-width: {{ maxWidth }};{% if not maxHeight %} height: auto;{% endif %}{% endif %}{% if maxHeight %} max-height: {{ maxHeight }};{% if not maxWidth %} width: auto;{% endif %}{% endif %}"{% endif %} />
31
33
  {% else %}
32
34
  Image
@@ -43,17 +45,17 @@
43
45
  {% if src.fallback %}
44
46
  <picture>
45
47
  {% for source in src.sources %}
46
- <source srcset="{{ source.srcSet }}"
48
+ <source srcset="{% asset_srcset source.srcSet staticBaseUrl %}"
47
49
  {% if source.media %}media="{{ source.media }}"{% endif %}
48
50
  {% if source.type %}type="{{ source.type }}"{% endif %}
49
51
  {% if source.sizes %}sizes="{{ source.sizes }}"{% endif %}
50
52
  />
51
53
  {% endfor %}
52
- <img src="{{ src.fallback }}"{% if alt %} alt="{{ alt }}"{% endif %}
54
+ <img src="{% asset_url src.fallback staticBaseUrl %}"{% if imageSrcSet %} srcset="{{ imageSrcSet }}"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}
53
55
  {% if maxWidth or maxHeight %}style="{% if maxWidth %}max-width: {{ maxWidth }};{% if not maxHeight %} height: auto;{% endif %}{% endif %}{% if maxHeight %} max-height: {{ maxHeight }};{% if not maxWidth %} width: auto;{% endif %}{% endif %}"{% endif %} />
54
56
  </picture>
55
57
  {% elif src %}
56
- <img src="{{ src }}"{% if alt %} alt="{{ alt }}"{% endif %}
58
+ <img src="{% asset_url src staticBaseUrl %}"{% if imageSrcSet %} srcset="{{ imageSrcSet }}"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}
57
59
  {% if maxWidth or maxHeight %}style="{% if maxWidth %}max-width: {{ maxWidth }};{% if not maxHeight %} height: auto;{% endif %}{% endif %}{% if maxHeight %} max-height: {{ maxHeight }};{% if not maxWidth %} width: auto;{% endif %}{% endif %}"{% endif %} />
58
60
  {% else %}
59
61
  Image
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "in-page-nav",
3
3
  "template": "in-page-nav/in-page-nav.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "default": {
6
6
  "id": "in-page-nav-default",
7
7
  "content": "<h2>Introduction</h2><p>This page walks through setting up and using the example project.</p><p>It's also meant to demonstrate how the in-page navigation component tracks scroll position and highlights whichever section is currently in view. Scroll down through each section below to see the link list on the side update automatically.</p><p>None of the copy on this page is meant to be read closely — it exists purely to give the navigation something substantial enough to observe.</p><h2>Getting started</h2><p>Before you begin, make sure the prerequisites below are met.</p><p>Getting started with any new project usually means working through a short checklist before the real work begins. The sections below cover what you'll need and how to get everything installed.</p><h3>Prerequisites</h3><p>A recent browser and a working internet connection.</p><p>You'll also want a modern code editor and enough disk space for the dependencies. Nothing here is unusual — most standard front-end tooling already satisfies these requirements.</p><p>If you already have Node.js and a package manager installed, you can skip ahead to the installation section below.</p><h3>Installation</h3><p>Download the package and follow the setup instructions.</p><p>Installation typically takes just a few minutes. Run the installer, accept the default options, and confirm that the command-line tool reports a successful install before moving on.</p><p>If you run into trouble, double-check that your environment matches the prerequisites listed above before trying again.</p><h2>Advanced usage</h2><p>Once installed, explore the configuration options to fit your workflow.</p><p>Advanced users can customize almost every aspect of the setup, from heading detection to scroll offsets and intersection thresholds — all of which this component exposes as simple data attributes.</p><p>Most projects never need to touch these settings, but they're available for the cases that do.</p><h2>Conclusion</h2><p>You should now be ready to explore the rest of the documentation.</p><p>Thanks for reading through this example. Scroll back up and watch the navigation list highlight each section as it passes by — that's the entire behavior this component provides.</p>"
@@ -64,6 +64,16 @@
64
64
  "type": "string",
65
65
  "default": "",
66
66
  "description": "Additional classes for the observed content container."
67
+ },
68
+ "children": {
69
+ "type": "slot",
70
+ "description": "Composed content containing the observed headings; takes precedence over content (React only).",
71
+ "renderers": {
72
+ "django": {
73
+ "supported": false,
74
+ "description": "The Django template does not consume children."
75
+ }
76
+ }
67
77
  }
68
78
  }
69
79
  }
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "indicator",
3
3
  "template": "indicator/indicator.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "items": {
7
7
  "type": "object",
8
8
  "description": "Array of indicator badge objects. Each item supports: className (classes beyond usx-indicator-item), label (text content), and style (inline styles)."
9
9
  },
10
10
  "children": {
11
- "type": "string",
11
+ "type": "slot",
12
12
  "description": "The element being decorated by the indicator badges."
13
13
  },
14
14
  "className": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "input",
3
3
  "template": "input/input.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "label": {
7
- "type": "string",
7
+ "type": "slot",
8
8
  "default": null,
9
9
  "description": "The label for the input field. If provided, it will render a label element associated with the control."
10
10
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "label",
3
3
  "template": "label/label.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "htmlFor": {
7
7
  "type": "string",
@@ -28,7 +28,7 @@
28
28
  "description": "Label text content"
29
29
  },
30
30
  "children": {
31
- "type": "string",
31
+ "type": "slot",
32
32
  "description": "Inner HTML or text"
33
33
  },
34
34
  "className": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "language-selector",
3
3
  "template": "language-selector/language-selector.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "default": {
6
6
  "variant": "menu",
7
7
  "languages": [
@@ -85,7 +85,7 @@
85
85
  "description": "Compact sizing for the menu variant (usa-language--small), e.g. inside a header"
86
86
  },
87
87
  "label": {
88
- "type": "string",
88
+ "type": "slot",
89
89
  "default": "Languages",
90
90
  "description": "Menu variant trigger button text"
91
91
  },
@@ -12,7 +12,7 @@ export interface SingleColumnLayoutProps extends HTMLAttributes<HTMLDivElement>
12
12
  }
13
13
 
14
14
  export function SingleColumnLayout({ children, expandButton = null, className = '', ...props }: SingleColumnLayoutProps) {
15
- const classes = ['usx-layout__single-column', className].filter(Boolean).join(' ');
15
+ const classes = ClassNames('usx-layout__single-column', className);
16
16
  return (
17
17
  <div className={classes} {...props}>
18
18
  {expandButton}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "layout",
3
3
  "template": "layout/layout.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "variant": {
7
7
  "type": "select",
@@ -13,20 +13,20 @@
13
13
  "description": "Layout variant: single-column centers content, grid supports sidebars"
14
14
  },
15
15
  "children": {
16
- "type": "string",
17
- "description": "Inner HTML or text content (for single-column)"
16
+ "type": "slot",
17
+ "description": "Main content in either layout variant. Accepts text, React nodes, or a Django template fragment; takes precedence over content when truthy."
18
18
  },
19
19
  "content": {
20
- "type": "string",
21
- "description": "Main content for grid layout"
20
+ "type": "slot",
21
+ "description": "Fallback main content in either layout variant when children is falsy. Accepts text, React nodes, or a Django template fragment."
22
22
  },
23
23
  "leftSidebar": {
24
- "type": "string",
25
- "description": "Left sidebar content (grid variant only)"
24
+ "type": "slot",
25
+ "description": "Left sidebar content in the grid variant; accepts text, React nodes, or a Django template fragment."
26
26
  },
27
27
  "rightSidebar": {
28
- "type": "string",
29
- "description": "Right sidebar content (grid variant only)"
28
+ "type": "slot",
29
+ "description": "Right sidebar content in the grid variant; accepts text, React nodes, or a Django template fragment."
30
30
  },
31
31
  "expandLeftSidebar": {
32
32
  "type": "boolean",
@@ -4,7 +4,7 @@
4
4
  {# For grid: content, leftSidebar, rightSidebar #}
5
5
  {% fragment as expandButton %}
6
6
  {% if expandable %}
7
- {% html_attrs aria_expanded="false" aria_label="Expand" onclick="const layout = this.closest('.usx-layout'); const expanded = layout.classList.toggle('usx-expanded'); this.setAttribute('aria-expanded', expanded); this.setAttribute('aria-label', expanded ? 'Contract' : 'Expand');" as expandAttributes %}
7
+ {% dict aria_expanded="false" aria_label="Expand" onclick="const layout = this.closest('.usx-layout'); const expanded = layout.classList.toggle('usx-expanded'); this.setAttribute('aria-expanded', expanded); this.setAttribute('aria-label', expanded ? 'Contract' : 'Expand');" as expandAttributes %}
8
8
  {% button variant="primary" ghost=True type="button" className="usx-layout__expand-button" extraAttributes=expandAttributes %}
9
9
  {% icon source='usx' name='expand' size=3 className='usx-layout__expand-icon usx-layout__expand-icon--expand' %}{% endicon %}
10
10
  {% icon source='usx' name='contract' size=3 className='usx-layout__expand-icon usx-layout__expand-icon--contract' %}{% endicon %}
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "legend",
3
3
  "template": "legend/legend.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "text": {
7
- "type": "string",
7
+ "type": "slot",
8
8
  "description": "Text for the legend"
9
9
  },
10
10
  "required": {
@@ -16,7 +16,7 @@
16
16
  "description": "Whether to use the larger legend style (adds class `usa-legend--large`)"
17
17
  },
18
18
  "children": {
19
- "type": "string",
19
+ "type": "slot",
20
20
  "description": "Inner HTML or text"
21
21
  },
22
22
  "className": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "link",
3
3
  "template": "link/link.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "required": [
6
6
  "href",
7
7
  "children"
@@ -12,7 +12,7 @@
12
12
  "description": "Link destination URL."
13
13
  },
14
14
  "children": {
15
- "type": "string",
15
+ "type": "slot",
16
16
  "description": "Inner link text or HTML."
17
17
  },
18
18
  "visited": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "memorable-date",
3
3
  "template": "memorable-date/memorable-date.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "default": {
6
6
  "id": "memorable-date",
7
7
  "legend": "Date of Birth"
@@ -13,42 +13,42 @@
13
13
  "description": "Base id for the component. Month/day/year field ids and hint ids are derived from this."
14
14
  },
15
15
  "legend": {
16
- "type": "string",
16
+ "type": "slot",
17
17
  "default": "Date of Birth",
18
18
  "description": "Legend text for the fieldset."
19
19
  },
20
20
  "groupHint": {
21
- "type": "string",
21
+ "type": "slot",
22
22
  "default": "Select a month. Enter 1 or 2 digits for the day and 4 digits for the year.",
23
23
  "description": "Visible hint shown once for the whole group. Hidden from screen readers (aria-hidden) since each field has its own hint."
24
24
  },
25
25
  "monthLabel": {
26
- "type": "string",
26
+ "type": "slot",
27
27
  "default": "Month",
28
28
  "description": "Label text for the month select."
29
29
  },
30
30
  "dayLabel": {
31
- "type": "string",
31
+ "type": "slot",
32
32
  "default": "Day",
33
33
  "description": "Label text for the day input."
34
34
  },
35
35
  "yearLabel": {
36
- "type": "string",
36
+ "type": "slot",
37
37
  "default": "Year",
38
38
  "description": "Label text for the year input."
39
39
  },
40
40
  "monthHint": {
41
- "type": "string",
41
+ "type": "slot",
42
42
  "default": "Select a month from the dropdown.",
43
43
  "description": "Screen-reader-only hint for the month field."
44
44
  },
45
45
  "dayHint": {
46
- "type": "string",
46
+ "type": "slot",
47
47
  "default": "Enter 1 or 2 digits for the day.",
48
48
  "description": "Screen-reader-only hint for the day field."
49
49
  },
50
50
  "yearHint": {
51
- "type": "string",
51
+ "type": "slot",
52
52
  "default": "Enter 4 digits for the year.",
53
53
  "description": "Screen-reader-only hint for the year field."
54
54
  },
@@ -1,4 +1,5 @@
1
1
  import React, { ReactNode, HTMLAttributes, useId } from 'react';
2
+ import ClassNames from 'classnames';
2
3
  import Icon from '../icon/Icon';
3
4
 
4
5
  export interface MiscBannerProps extends HTMLAttributes<HTMLDivElement> {
@@ -33,7 +34,7 @@ export default function MiscBanner({
33
34
  }: MiscBannerProps) {
34
35
  const menuId = useId();
35
36
  const toggleId = useId();
36
- const classes = ['usx-misc-banner', `bg-${tone}`, className].filter(Boolean).join(' ');
37
+ const classes = ClassNames('usx-misc-banner', `bg-${tone}`, className);
37
38
  const mobileLinks: { href: string; text: string }[] = [];
38
39
  const hasLearnMoreLink = showLearnMore && Boolean(casualLinkText);
39
40
  const hasReturnLink = showReturnLink && Boolean(importantLinkText);
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "misc-banner",
3
3
  "template": "misc-banner/misc-banner.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "children": {
7
- "type": "string",
7
+ "type": "slot",
8
8
  "description": "Advanced override for custom inner markup"
9
9
  },
10
10
  "className": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modal",
3
3
  "template": "modal/modal.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "id": {
7
7
  "type": "string",
@@ -44,7 +44,7 @@
44
44
  "description": "When true, prevents closing the modal via the overlay or Escape key, and hides the close button. Used for required-action flows."
45
45
  },
46
46
  "children": {
47
- "type": "string",
47
+ "type": "slot",
48
48
  "default": null,
49
49
  "description": "Inner HTML to render as the modal body, replacing the description text."
50
50
  },
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import ClassNames from 'classnames';
2
3
 
3
4
  export interface PageProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title' | 'content'> {
4
5
  title?: React.ReactNode;
@@ -17,7 +18,7 @@ export default function Page({
17
18
  className = '',
18
19
  ...props
19
20
  }: PageProps) {
20
- const classes = ['usx-page', className].filter(Boolean).join(' ');
21
+ const classes = ClassNames('usx-page', className);
21
22
  const pageContent = children || content;
22
23
 
23
24
  const Element = element;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "page",
3
3
  "template": "page/page.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "required": [
6
6
  "title"
7
7
  ],
@@ -11,20 +11,20 @@
11
11
  "description": "Optional id attribute applied to the root main element."
12
12
  },
13
13
  "title": {
14
- "type": "string",
14
+ "type": "slot",
15
15
  "description": "Required page title rendered as an h1."
16
16
  },
17
17
  "eyebrow": {
18
- "type": "string",
18
+ "type": "slot",
19
19
  "description": "Optional eyebrow text rendered above the page title inside the h1."
20
20
  },
21
21
  "content": {
22
- "type": "string",
23
- "description": "Body content rendered below the title. Supports HTML in Django stories."
22
+ "type": "slot",
23
+ "description": "Body content rendered below the title. Supports HTML in Django stories. Ignored if children is provided."
24
24
  },
25
25
  "children": {
26
- "type": "string",
27
- "description": "Body content for React usage."
26
+ "type": "slot",
27
+ "description": "Body content for React usage. Takes precedence over content if both are provided."
28
28
  },
29
29
  "className": {
30
30
  "type": "string",
@@ -1,5 +1,5 @@
1
1
  {# Django template for Page #}
2
2
  <main{% if id %} id="{{ id }}"{% endif %} class="usx-page{% if className %} {{ className }}{% endif %}">
3
3
  <h1 class="usx-page__title">{% if eyebrow %}<span class="usx-eyebrow">{{ eyebrow }}</span>{% endif %}{{ title|default:'Page title' }}</h1>
4
- <div class="usx-page__content">{{ content|default:''|safe }}</div>
4
+ <div class="usx-page__content">{% if children %}{{ children|safe }}{% elif content %}{{ content|safe }}{% endif %}</div>
5
5
  </main>
@@ -1,4 +1,5 @@
1
1
  import React, { useState } from 'react';
2
+ import ClassNames from 'classnames';
2
3
  import PaginationNavigation from './navigation/PaginationNavigation';
3
4
  import PaginationStepOptions from './step-options/PaginationStepOptions';
4
5
  import PaginationSummary from './summary/PaginationSummary';
@@ -70,7 +71,7 @@ export default function Pagination({
70
71
  onPageChange?.(newPage, size);
71
72
  };
72
73
 
73
- const classes = ['usx-pagination', className].filter(Boolean).join(' ');
74
+ const classes = ClassNames('usx-pagination', className);
74
75
 
75
76
  return (
76
77
  <div className={classes}>
@@ -1,4 +1,5 @@
1
1
  import React, { ReactNode, HTMLAttributes } from 'react';
2
+ import ClassNames from 'classnames';
2
3
 
3
4
  export interface PaginationContainerProps extends HTMLAttributes<HTMLDivElement> {
4
5
  summary?: ReactNode;
@@ -20,7 +21,7 @@ export default function PaginationContainer({
20
21
  className = '',
21
22
  ...props
22
23
  }: PaginationContainerProps) {
23
- const classes = ['usx-pagination__container', className].filter(Boolean).join(' ');
24
+ const classes = ClassNames('usx-pagination__container', className);
24
25
 
25
26
  return (
26
27
  <div className={classes} {...props}>