@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,20 +1,6 @@
1
1
  import React from 'react';
2
2
  import ClassNames from 'classnames';
3
-
4
- function usxCopy(text: string) {
5
- if (navigator.clipboard) {
6
- navigator.clipboard.writeText(text);
7
- } else {
8
- const ta = document.createElement('textarea');
9
- ta.value = text;
10
- ta.style.cssText = 'position:fixed;opacity:0';
11
- document.body.appendChild(ta);
12
- ta.focus();
13
- ta.select();
14
- try { document.execCommand('copy'); } catch { /* ignore */ }
15
- document.body.removeChild(ta);
16
- }
17
- }
3
+ import CopyToClipboard from '../copy-to-clipboard/CopyToClipboard';
18
4
 
19
5
  export interface CodeLine {
20
6
  code: string;
@@ -26,10 +12,11 @@ export interface CodeProps {
26
12
  lines?: CodeLine[];
27
13
  allowHtml?: boolean;
28
14
  copyText?: string | null;
15
+ staticBaseUrl?: string;
29
16
  className?: string;
30
17
  }
31
18
 
32
- export default function Code({ lines = [], allowHtml = false, copyText = null, className = '' }: CodeProps) {
19
+ export default function Code({ lines = [], allowHtml = false, copyText = null, staticBaseUrl, className = '' }: CodeProps) {
33
20
  return (
34
21
  <div className={ClassNames('usx-mockup-code', className)}>
35
22
  <div className="usx-mockup-code__content">
@@ -44,17 +31,7 @@ export default function Code({ lines = [], allowHtml = false, copyText = null, c
44
31
  ))}
45
32
  </div>
46
33
  {copyText && (
47
- <button
48
- className="usa-button usx-button usx-button--ghost usx-copy"
49
- onClick={() => usxCopy(copyText)}
50
- >
51
- <svg className="usa-icon usx-copy__copy" aria-hidden="true" focusable="false" role="img">
52
- <use href="./img/sprite.svg#content_copy" />
53
- </svg>
54
- <svg className="usa-icon usx-copy__check" aria-hidden="true" focusable="false" role="img">
55
- <use href="./img/sprite.svg#check" />
56
- </svg>
57
- </button>
34
+ <CopyToClipboard copyText={copyText} staticBaseUrl={staticBaseUrl} tooltipProps={{ label: 'Copy', copiedTooltip: 'Copied', position: 'left' }}/>
58
35
  )}
59
36
  </div>
60
37
  );
@@ -1,4 +1,5 @@
1
1
  {# Django template for Code #}
2
+ {% load components %}
2
3
  <div class="usx-mockup-code{% if className %} {{ className }}{% endif %}">
3
4
  <div class="usx-mockup-code__content">
4
5
  {% for line in lines %}
@@ -8,14 +9,7 @@
8
9
  {% endfor %}
9
10
  </div>
10
11
  {% if copyText %}
11
- <button class="usa-button usx-button usx-button--ghost usx-copy"
12
- onclick="navigator.clipboard.writeText('{{ copyText|escapejs }}')">
13
- <svg class="usa-icon usx-copy__copy" aria-hidden="true" focusable="false" role="img">
14
- <use href="./img/sprite.svg#content_copy"></use>
15
- </svg>
16
- <svg class="usa-icon usx-copy__check" aria-hidden="true" focusable="false" role="img">
17
- <use href="./img/sprite.svg#check"></use>
18
- </svg>
19
- </button>
12
+ {% dict label="Copy" copiedTooltip="Copied" position="left" as tooltipProps %}
13
+ {% copy_to_clipboard copyText=copyText tooltipProps=tooltipProps staticBaseUrl=staticBaseUrl %}{% endcopy_to_clipboard %}
20
14
  {% endif %}
21
15
  </div>
@@ -6,6 +6,10 @@
6
6
  "lines"
7
7
  ],
8
8
  "props": {
9
+ "staticBaseUrl": {
10
+ "type": "string",
11
+ "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."
12
+ },
9
13
  "lines": {
10
14
  "type": "array",
11
15
  "description": "Array of line objects. Each supports: code (string), prefix (string, omit for no data-prefix attribute), className (string).",
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import ClassNames from 'classnames';
3
- import CalendarDate from '../calendar-date/CalendarDate';
3
+ import CalendarDate, { type CalendarDateProps } from '../calendar-date/CalendarDate';
4
4
 
5
5
  export interface CollectionMetaItem {
6
6
  text: string;
@@ -18,19 +18,19 @@ export interface CollectionItemProps {
18
18
  description?: string;
19
19
  imgSrc?: string;
20
20
  imgAlt?: string;
21
- calendarDate?: string | { datetime: string; month: string; day: string };
21
+ calendarDateProps?: CalendarDateProps;
22
22
  meta?: (string | CollectionMetaItem)[];
23
23
  tags?: (string | CollectionTag)[];
24
24
  }
25
25
 
26
- function CollectionItem({ href, heading, description, imgSrc, imgAlt = '', calendarDate, meta, tags }: CollectionItemProps) {
26
+ function CollectionItem({ href, heading, description, imgSrc, imgAlt = '', calendarDateProps, meta, tags }: CollectionItemProps) {
27
27
  return (
28
28
  <li className="usa-collection__item">
29
29
  {imgSrc && (
30
30
  <img className="usa-collection__img" src={imgSrc} alt={imgAlt} />
31
31
  )}
32
- {calendarDate && (
33
- <CalendarDate datetime={typeof calendarDate === 'string' ? calendarDate : calendarDate.datetime} underCollection={true} />
32
+ {calendarDateProps && (
33
+ <CalendarDate underCollection={true} {...calendarDateProps} />
34
34
  )}
35
35
  <div className="usa-collection__body">
36
36
  <h4 className="usa-collection__heading">
@@ -6,10 +6,8 @@
6
6
  {% if item.imgSrc %}
7
7
  <img class="usa-collection__img" src="{{ item.imgSrc }}" alt="{{ item.imgAlt }}" />
8
8
  {% endif %}
9
- {% if item.calendarDate %}
10
- {% with datetime=item.calendarDate %}
11
- {% calendar_date datetime=datetime under_collection=True %}{% endcalendar_date %}
12
- {% endwith %}
9
+ {% if item.calendarDateProps %}
10
+ {% calendar_date props=item.calendarDateProps underCollection=item.calendarDateProps.underCollection|default_bool:True %}{% endcalendar_date %}
13
11
  {% endif %}
14
12
  <div class="usa-collection__body">
15
13
  <h4 class="usa-collection__heading">
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "collection",
3
3
  "template": "collection/collection.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "items": {
7
7
  "type": "array",
8
8
  "default": [],
9
- "description": "Array of collection item objects. Each item: { href, heading, description?, imgSrc?, imgAlt?, calendarDate?: { datetime, month, day }, meta?: [{ text, datetime? }], tags?: [{ label, isNew? }] }",
9
+ "description": "Collection items with optional calendarDateProps, meta, and tags.",
10
10
  "items": {
11
11
  "type": "object",
12
12
  "description": "Collection item.",
@@ -31,10 +31,6 @@
31
31
  "type": "string",
32
32
  "description": "Alt text for the thumbnail image."
33
33
  },
34
- "calendarDate": {
35
- "type": "object",
36
- "description": "Optional { datetime, month, day } calendar date badge."
37
- },
38
34
  "meta": {
39
35
  "type": "array",
40
36
  "description": "Optional meta list: [{ text, datetime? }]."
@@ -42,6 +38,11 @@
42
38
  "tags": {
43
39
  "type": "array",
44
40
  "description": "Optional tag list: [{ label, isNew? }]."
41
+ },
42
+ "calendarDateProps": {
43
+ "type": "object",
44
+ "component": "calendar-date",
45
+ "description": "Props passed to the calendar-date component."
45
46
  }
46
47
  }
47
48
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "combobox",
3
3
  "template": "combobox/combobox.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "id": {
7
7
  "type": "string",
@@ -12,7 +12,7 @@
12
12
  "description": "name attribute for the select"
13
13
  },
14
14
  "label": {
15
- "type": "string",
15
+ "type": "slot",
16
16
  "description": "Label text for the combobox"
17
17
  },
18
18
  "disabled": {
@@ -26,7 +26,7 @@
26
26
  "default": false
27
27
  },
28
28
  "hint": {
29
- "type": "string",
29
+ "type": "slot",
30
30
  "description": "Hint text (renders aria-describedby)"
31
31
  },
32
32
  "placeholder": {
@@ -38,7 +38,7 @@
38
38
  "description": "Default selected value"
39
39
  },
40
40
  "error": {
41
- "type": "string",
41
+ "type": "slot",
42
42
  "description": "Error message (renders aria-describedby and error class)"
43
43
  },
44
44
  "options": {
@@ -1,48 +1,59 @@
1
1
  import React from 'react';
2
2
  import ClassNames from 'classnames';
3
+ import Button from '../button/Button';
4
+ import Icon from '../icon/Icon';
5
+ import Tooltip from '../tooltip/Tooltip';
6
+ import type { TooltipProps } from '../tooltip/Tooltip';
7
+
8
+ function copyTextToClipboard(text: string) {
9
+ if (window.navigator.clipboard) {
10
+ return window.navigator.clipboard.writeText(text);
11
+ }
12
+ }
3
13
 
4
14
  export interface CopyToClipboardProps {
5
15
  copyText?: string;
6
16
  label?: string | null;
7
- tooltip?: string | null;
8
- copiedTooltip?: string;
17
+ tooltipProps?: TooltipProps & { copiedTooltip?: string };
18
+ staticBaseUrl?: string;
9
19
  className?: string;
10
20
  }
11
21
 
12
22
  export default function CopyToClipboard({
13
23
  copyText = '',
14
24
  label = null,
15
- tooltip = null,
16
- copiedTooltip = 'Copied',
25
+ tooltipProps,
26
+ staticBaseUrl,
17
27
  className = '',
18
28
  }: CopyToClipboardProps) {
19
29
  const button = (
20
- <button
21
- className={ClassNames(
22
- 'usa-button',
23
- 'usx-button',
24
- 'usx-button--ghost',
25
- 'usx-copy',
26
- className
27
- )}
28
- onClick={() => window.navigator.clipboard.writeText(copyText)}
30
+ <Button
31
+ ghost={true}
32
+ className={ClassNames('usx-copy', className)}
33
+ onClick={() => copyTextToClipboard(copyText)}
29
34
  type="button"
30
35
  >
31
- <svg className="usa-icon usx-copy__copy" aria-hidden="true" focusable="false" role="img">
32
- <use href="./img/sprite.svg#content_copy" />
33
- </svg>
34
- <svg className="usa-icon usx-copy__check" aria-hidden="true" focusable="false" role="img">
35
- <use href="./img/sprite.svg#check" />
36
- </svg>
36
+ <Icon name="content_copy" size={0} className="usx-copy__copy" staticBaseUrl={staticBaseUrl} />
37
+ <Icon name="check" size={0} className="usx-copy__check" staticBaseUrl={staticBaseUrl} />
37
38
  {label && <span className="margin-left-1">{label}</span>}
38
- </button>
39
+ </Button>
39
40
  );
40
41
 
42
+ if (!tooltipProps) return button;
43
+
44
+ const { label: tooltipLabel, copiedTooltip = 'Copied', ...tooltipOptions } = tooltipProps;
45
+
41
46
  return (
42
- <span className="usx-tooltip">
47
+ <Tooltip
48
+ {...tooltipOptions}
49
+ label={(
50
+ <>
51
+ <span className="usx-copy__tooltip--copy">{tooltipLabel}</span>
52
+ <span className="usx-copy__tooltip--copied">{copiedTooltip}</span>
53
+ </>
54
+ )}
55
+ >
43
56
  {button}
44
- {tooltip && <span className="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copy" role="tooltip">{tooltip}</span>}
45
- <span className="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copied" role="tooltip">{copiedTooltip}</span>
46
- </span>
57
+ </Tooltip>
47
58
  );
48
59
  }
@@ -6,6 +6,10 @@
6
6
  "copyText"
7
7
  ],
8
8
  "props": {
9
+ "staticBaseUrl": {
10
+ "type": "string",
11
+ "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."
12
+ },
9
13
  "copyText": {
10
14
  "type": "string",
11
15
  "description": "Text to copy to clipboard"
@@ -14,13 +18,16 @@
14
18
  "type": "string",
15
19
  "description": "Visible text label on the button"
16
20
  },
17
- "tooltip": {
18
- "type": "string",
19
- "description": "Tooltip text; omit to hide the tooltip wrapper"
20
- },
21
- "copiedTooltip": {
22
- "type": "string",
23
- "description": "Tooltip text shown after copying (default: 'Copied')"
21
+ "tooltipProps": {
22
+ "type": "object",
23
+ "component": "tooltip",
24
+ "description": "Optional Tooltip props passed through unchanged, except label is composed into copy/copied spans. Omit to render only the button. The clipboard button supplies the trigger; Tooltip supplies its own defaults.",
25
+ "properties": {
26
+ "copiedTooltip": {
27
+ "type": "string",
28
+ "description": "Tooltip text shown after copying (default: 'Copied')"
29
+ }
30
+ }
24
31
  },
25
32
  "className": {
26
33
  "type": "string",
@@ -1,16 +1,16 @@
1
1
  {# Django template for CopyToClipboard #}
2
- {% if tooltip %}<span class="usx-tooltip">{% endif %}
3
- <button class="usa-button usx-button usx-button--ghost usx-copy{% if className %} {{ className }}{% endif %}"
4
- onclick="navigator.clipboard.writeText('{{ copyText|escapejs }}')">
5
- <svg class="usa-icon usx-copy__copy" aria-hidden="true" focusable="false" role="img">
6
- <use href="./img/sprite.svg#content_copy"></use>
7
- </svg>
8
- <svg class="usa-icon usx-copy__check" aria-hidden="true" focusable="false" role="img">
9
- <use href="./img/sprite.svg#check"></use>
10
- </svg>
2
+ {% load components %}
3
+ {% with buttonClass=className|default:''|add:' usx-copy' escapedCopyText=copyText|default:''|escapejs %}
4
+ {% dict onclick="navigator.clipboard.writeText('"|add:escapedCopyText|add:"')" as copyAttributes %}
5
+ {% button ghost=True className=buttonClass extraAttributes=copyAttributes as copyButton %}
6
+ {% icon name='content_copy' className="usx-copy__copy" staticBaseUrl=staticBaseUrl %}{% endicon %}
7
+ {% icon name='check' className="usx-copy__check" staticBaseUrl=staticBaseUrl %}{% endicon %}
11
8
  {% if label %}<span class="margin-left-1">{{ label }}</span>{% endif %}
12
- </button>
13
- {% if tooltip %}
14
- <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copy" role="tooltip">{{ tooltip }}</span>
15
- <span class="usa-tooltip__body usa-tooltip__body--right usx-copy__tooltip--copied" role="tooltip">{{ copiedTooltip|default:'Copied' }}</span>
16
- </span>{% endif %}
9
+ {% endbutton %}
10
+ {% if tooltipProps != None %}
11
+ {% fragment as tooltipLabel %}<span class="usx-copy__tooltip--copy">{{ tooltipProps.label|default_if_none:'' }}</span><span class="usx-copy__tooltip--copied">{% if tooltipProps.copiedTooltip != None %}{{ tooltipProps.copiedTooltip }}{% else %}Copied{% endif %}</span>{% endfragment %}
12
+ {% tooltip props=tooltipProps label=tooltipLabel %}{{ copyButton }}{% endtooltip %}
13
+ {% else %}
14
+ {{ copyButton }}
15
+ {% endif %}
16
+ {% endwith %}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "date-picker",
3
3
  "template": "date-picker/date-picker.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "default": {
6
6
  "id": "appointment-date",
7
7
  "name": "appointment-date",
@@ -19,16 +19,16 @@
19
19
  "description": "name attribute for the input. Defaults to id."
20
20
  },
21
21
  "label": {
22
- "type": "string",
22
+ "type": "slot",
23
23
  "description": "Label text for the field."
24
24
  },
25
25
  "hint": {
26
- "type": "string",
26
+ "type": "slot",
27
27
  "default": "mm/dd/yyyy",
28
28
  "description": "Hint text displayed below the label."
29
29
  },
30
30
  "error": {
31
- "type": "string",
31
+ "type": "slot",
32
32
  "description": "Error message. Renders aria-describedby and error styling."
33
33
  },
34
34
  "disabled": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "date-range-picker",
3
3
  "template": "date-range-picker/date-range-picker.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "default": {
6
6
  "startId": "event-date-start",
7
7
  "endId": "event-date-end",
@@ -30,31 +30,31 @@
30
30
  "description": "name attribute for the end date input. Defaults to endId."
31
31
  },
32
32
  "startLabel": {
33
- "type": "string",
33
+ "type": "slot",
34
34
  "default": "Event start date",
35
35
  "description": "Label text for the start date field."
36
36
  },
37
37
  "endLabel": {
38
- "type": "string",
38
+ "type": "slot",
39
39
  "default": "Event end date",
40
40
  "description": "Label text for the end date field."
41
41
  },
42
42
  "startHint": {
43
- "type": "string",
43
+ "type": "slot",
44
44
  "default": "mm/dd/yyyy",
45
45
  "description": "Hint text displayed below the start date label."
46
46
  },
47
47
  "endHint": {
48
- "type": "string",
48
+ "type": "slot",
49
49
  "default": "mm/dd/yyyy",
50
50
  "description": "Hint text displayed below the end date label."
51
51
  },
52
52
  "startError": {
53
- "type": "string",
53
+ "type": "slot",
54
54
  "description": "Error message for the start date field."
55
55
  },
56
56
  "endError": {
57
- "type": "string",
57
+ "type": "slot",
58
58
  "description": "Error message for the end date field."
59
59
  },
60
60
  "disabled": {
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "error-message",
3
3
  "template": "error-message/error-message.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 ClassNames from 'classnames';
2
3
 
3
4
  export interface EyebrowProps extends React.HTMLAttributes<HTMLSpanElement> {
4
5
  children?: React.ReactNode;
@@ -6,7 +7,7 @@ export interface EyebrowProps extends React.HTMLAttributes<HTMLSpanElement> {
6
7
  }
7
8
 
8
9
  export default function Eyebrow({ children = null, className = '', ...props }: EyebrowProps) {
9
- const classes = ['usx-eyebrow', className].filter(Boolean).join(' ');
10
+ const classes = ClassNames('usx-eyebrow', className);
10
11
  return (
11
12
  <span className={classes} {...props}>
12
13
  {children}
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "eyebrow",
3
3
  "template": "eyebrow/eyebrow.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "children": {
7
- "type": "string",
7
+ "type": "slot",
8
8
  "description": "Eyebrow text content"
9
9
  },
10
10
  "className": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "fieldset",
3
3
  "template": "fieldset/fieldset.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "legend": {
7
- "type": "string",
7
+ "type": "slot",
8
8
  "description": "Text for the fieldset legend"
9
9
  },
10
10
  "largeLegend": {
@@ -20,11 +20,11 @@
20
20
  "description": "Whether to disable all form controls within the fieldset"
21
21
  },
22
22
  "hint": {
23
- "type": "string",
23
+ "type": "slot",
24
24
  "description": "Group-level hint text, rendered after the legend"
25
25
  },
26
26
  "error": {
27
- "type": "string",
27
+ "type": "slot",
28
28
  "description": "Group-level error message, rendered after the hint"
29
29
  },
30
30
  "hintId": {
@@ -36,7 +36,7 @@
36
36
  "description": "Element id for the error message span"
37
37
  },
38
38
  "children": {
39
- "type": "string",
39
+ "type": "slot",
40
40
  "description": "Inner HTML or text"
41
41
  },
42
42
  "className": {
@@ -1,4 +1,5 @@
1
1
  import React, { useRef, useState } from 'react';
2
+ import ClassNames from 'classnames';
2
3
 
3
4
  import Label from '../label/Label';
4
5
  import Hint from '../hint/Hint';
@@ -125,7 +126,7 @@ export default function FileInput({
125
126
  {commonHint}
126
127
  {commonError}
127
128
  <input
128
- className={['usa-file-input', 'usx-file-input', className].filter(Boolean).join(' ')}
129
+ className={ClassNames('usa-file-input', 'usx-file-input', className)}
129
130
  id={id}
130
131
  type="file"
131
132
  name={name || id}
@@ -149,7 +150,7 @@ export default function FileInput({
149
150
  {commonError}
150
151
  <div className="usx-file-input__add-only">
151
152
  <input
152
- className={['usa-file-input', 'usx-file-input', className].filter(Boolean).join(' ')}
153
+ className={ClassNames('usa-file-input', 'usx-file-input', className)}
153
154
  id={id}
154
155
  type="file"
155
156
  name={name || id}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "file-input",
3
3
  "template": "file-input/file-input.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "default": {
6
6
  "id": "file-input-single",
7
7
  "name": "file-input-single",
@@ -18,20 +18,20 @@
18
18
  "description": "name attribute for the input. Defaults to id."
19
19
  },
20
20
  "label": {
21
- "type": "string",
21
+ "type": "slot",
22
22
  "description": "Label text for the field."
23
23
  },
24
24
  "hint": {
25
- "type": "string",
25
+ "type": "slot",
26
26
  "description": "Hint text displayed below the label."
27
27
  },
28
28
  "fileListHint": {
29
- "type": "string",
29
+ "type": "slot",
30
30
  "default": "Selected files",
31
31
  "description": "Heading/hint text shown above the managed file list, passed to FileList's hint prop. React only."
32
32
  },
33
33
  "error": {
34
- "type": "string",
34
+ "type": "slot",
35
35
  "description": "Error message. Renders aria-describedby and error styling."
36
36
  },
37
37
  "disabled": {
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import ClassNames from 'classnames';
2
3
 
3
4
  import Icon from '../icon/Icon';
4
5
  import Link from '../link/Link';
@@ -52,7 +53,7 @@ export default function FileList({ files, hint = 'Selected files', onRemove = nu
52
53
  const lastEntry = getEntryDisplay(files[files.length - 1]);
53
54
 
54
55
  return (
55
- <div className={['usx-file-input__list', 'margin-top-1', className].filter(Boolean).join(' ')}>
56
+ <div className={ClassNames('usx-file-input__list', 'margin-top-1', className)}>
56
57
  <span className="usa-sr-only" aria-live="polite">
57
58
  {`You have selected the file: ${lastEntry.name}.`}
58
59
  </span>
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "file-list",
3
3
  "template": "file-list/file-list.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "default": {
6
6
  "files": [
7
7
  {
@@ -22,7 +22,7 @@
22
22
  "description": "Files to render as rows. Each entry is { key, file?, name?, size?, url?, onRemove? } — key uniquely identifies the row; file is a browser File (name/size read from it); name/size describe entries with no File object (e.g. files already on the server); url renders the name as a download link; onRemove overrides the onRemove prop for just this row. React only."
23
23
  },
24
24
  "hint": {
25
- "type": "string",
25
+ "type": "slot",
26
26
  "default": "Selected files",
27
27
  "description": "Heading/hint text shown above the file list."
28
28
  },