@solexllc/usx-react 0.12.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +15 -0
  2. package/dist/{Popover-BzDCTuQM.cjs → Popover-Bg4-2-cU.cjs} +3 -0
  3. package/dist/{Popover-LToVWsWc.js → Popover-CqHczzNE.js} +3 -0
  4. package/dist/chat.cjs +7 -2
  5. package/dist/chat.js +7 -2
  6. package/dist/index.cjs +83 -56
  7. package/dist/index.js +86 -59
  8. package/package.json +4 -4
  9. package/src/components/accordion/Accordion.tsx +9 -57
  10. package/src/components/accordion/accordion.django.html +10 -20
  11. package/src/components/accordion/config.json +8 -2
  12. package/src/components/accordion-item/AccordionItem.tsx +54 -0
  13. package/src/components/accordion-item/accordion-item.django.html +19 -0
  14. package/src/components/accordion-item/accordion-item.html +8 -0
  15. package/src/components/accordion-item/config.json +55 -0
  16. package/src/components/alert/alert.django-snapshot.html +4 -4
  17. package/src/components/avatar/avatar.django-snapshot.html +6 -2
  18. package/src/components/avatar/avatar.react-snapshot.html +6 -3
  19. package/src/components/avatar/config.json +4 -2
  20. package/src/components/avatar-group/avatar-group.django-snapshot.html +176 -176
  21. package/src/components/avatar-group/avatar-group.react-snapshot.html +198 -167
  22. package/src/components/avatar-group/config.json +12 -6
  23. package/src/components/banner/banner.django-snapshot.html +2 -2
  24. package/src/components/button/Button.tsx +3 -0
  25. package/src/components/button/button.django-snapshot.html +64 -0
  26. package/src/components/button/button.django.html +2 -0
  27. package/src/components/button/button.react-snapshot.html +64 -0
  28. package/src/components/button/config.json +6 -1
  29. package/src/components/card/card.django-snapshot.html +43 -0
  30. package/src/components/card/card.react-snapshot.html +36 -0
  31. package/src/components/chat/chat.django-snapshot.html +90 -26
  32. package/src/components/chat/chat.html +10 -10
  33. package/src/components/chat/chat.react-snapshot.html +49 -49
  34. package/src/components/chat-composer/ChatComposer.tsx +3 -0
  35. package/src/components/chat-composer/chat-composer.django-snapshot.html +10 -10
  36. package/src/components/chat-composer/chat-composer.django.html +2 -2
  37. package/src/components/chat-composer/chat-composer.html +10 -10
  38. package/src/components/chat-composer/chat-composer.react-snapshot.html +10 -10
  39. package/src/components/chat-composer/chat-formatting.django.html +8 -8
  40. package/src/components/chat-window/ChatWindow.tsx +3 -1
  41. package/src/components/chat-window/chat-window.django-snapshot.html +7 -5
  42. package/src/components/chat-window/chat-window.django.html +3 -3
  43. package/src/components/chat-window/chat-window.html +1 -1
  44. package/src/components/chat-window/chat-window.react-snapshot.html +7 -7
  45. package/src/components/checkbox/checkbox.django-snapshot.html +2 -2
  46. package/src/components/data-table/data-table.django-snapshot.html +4 -5
  47. package/src/components/data-table/data-table.react-snapshot.html +4 -4
  48. package/src/components/drawer/drawer.django-snapshot.html +53 -30
  49. package/src/components/error-page/error-page.django-snapshot.html +20 -7
  50. package/src/components/fieldset/fieldset.django-snapshot.html +1 -6
  51. package/src/components/form-group/form-group.django-snapshot.html +0 -2
  52. package/src/components/header/header.django-snapshot.html +3 -3
  53. package/src/components/header/header.html +1 -1
  54. package/src/components/header/header.react-snapshot.html +3 -3
  55. package/src/components/identifier/config.json +4 -2
  56. package/src/components/identifier/identifier.django-snapshot.html +13 -16
  57. package/src/components/identifier/identifier.react-snapshot.html +13 -15
  58. package/src/components/image/image.django-snapshot.html +6 -6
  59. package/src/components/layout/layout.django-snapshot.html +2 -0
  60. package/src/components/modal/Modal.tsx +4 -3
  61. package/src/components/modal/config.json +3 -2
  62. package/src/components/modal/modal.django-snapshot.html +70 -14
  63. package/src/components/modal/modal.django.html +7 -9
  64. package/src/components/modal/modal.html +4 -4
  65. package/src/components/modal/modal.react-snapshot.html +64 -4
  66. package/src/components/page/Page.tsx +10 -7
  67. package/src/components/page/page.django-snapshot.html +5 -8
  68. package/src/components/page/page.django.html +2 -2
  69. package/src/components/page/page.html +1 -2
  70. package/src/components/page/page.react-snapshot.html +5 -8
  71. package/src/components/pagination/navigation/PaginationNavigation.tsx +2 -0
  72. package/src/components/pagination/navigation/pagination-navigation.django.html +2 -0
  73. package/src/components/pagination/pagination.django-snapshot.html +62 -0
  74. package/src/components/pagination/pagination.django.html +3 -1
  75. package/src/components/pagination/pagination.html +46 -0
  76. package/src/components/pagination/pagination.react-snapshot.html +48 -0
  77. package/src/components/pagination/summary/PaginationSummary.tsx +1 -1
  78. package/src/components/pagination/summary/pagination-summary.django.html +1 -1
  79. package/src/components/popover/Popover.tsx +1 -0
  80. package/src/components/popover/popover.django-snapshot.html +37 -1
  81. package/src/components/popover/popover.django.html +1 -1
  82. package/src/components/popover/popover.react-snapshot.html +30 -3
  83. package/src/components/section/Section.tsx +3 -1
  84. package/src/components/site-alert/site-alert.django-snapshot.html +8 -8
  85. package/src/components/swap/Swap.tsx +35 -3
  86. package/src/components/swap/config.json +28 -1
  87. package/src/components/swap/swap.django-snapshot.html +29 -7
  88. package/src/components/swap/swap.django.html +15 -1
  89. package/src/components/swap/swap.react-snapshot.html +34 -4
  90. package/src/components/theme-picker/ThemePicker.tsx +48 -42
  91. package/src/components/theme-picker/config.json +27 -29
  92. package/src/components/theme-picker/theme-picker-select.django.html +1 -1
  93. package/src/components/theme-picker/theme-picker.django-snapshot.html +283 -78
  94. package/src/components/theme-picker/theme-picker.django.html +24 -11
  95. package/src/components/theme-picker/theme-picker.html +155 -54
  96. package/src/components/theme-picker/theme-picker.react-snapshot.html +265 -67
  97. package/src/index.js +1 -0
@@ -486,6 +486,52 @@
486
486
  </div>
487
487
  </div>
488
488
 
489
+ <h3 class="site-preview-heading">Single Page</h3>
490
+ <div class="usx-pagination">
491
+ <div class="usx-pagination__container">
492
+ <div class="usx-pagination__container-summary">
493
+ <p class="usa-label usx-label usx-pagination__summary" aria-live="polite" aria-atomic="true">
494
+ Showing <strong>1–8</strong> of <strong>8</strong> items
495
+ </p>
496
+ </div>
497
+ <div class="usx-pagination__container-end">
498
+ <div class="usx-pagination__step-options">
499
+ <label class="usa-label usx-label" for="html-pagination-single-page-step-options">Items per page</label>
500
+ <select id="html-pagination-single-page-step-options" class="usa-select usx-select">
501
+ <option value="">Select an option</option>
502
+ <option value="10" selected>10</option>
503
+ <option value="25">25</option>
504
+ <option value="50">50</option>
505
+ <option value="100">100</option>
506
+ </select>
507
+ </div>
508
+ </div>
509
+ </div>
510
+ </div>
511
+
512
+ <h3 class="site-preview-heading">No Results</h3>
513
+ <div class="usx-pagination">
514
+ <div class="usx-pagination__container">
515
+ <div class="usx-pagination__container-summary">
516
+ <p class="usa-label usx-label usx-pagination__summary" aria-live="polite" aria-atomic="true">
517
+ Showing <strong>0–0</strong> of <strong>0</strong> items
518
+ </p>
519
+ </div>
520
+ <div class="usx-pagination__container-end">
521
+ <div class="usx-pagination__step-options">
522
+ <label class="usa-label usx-label" for="html-pagination-no-results-step-options">Items per page</label>
523
+ <select id="html-pagination-no-results-step-options" class="usa-select usx-select">
524
+ <option value="">Select an option</option>
525
+ <option value="10" selected>10</option>
526
+ <option value="25">25</option>
527
+ <option value="50">50</option>
528
+ <option value="100">100</option>
529
+ </select>
530
+ </div>
531
+ </div>
532
+ </div>
533
+ </div>
534
+
489
535
  <h3 class="site-preview-heading">First Page</h3>
490
536
  <div class="usx-pagination">
491
537
  <div class="usx-pagination__container">
@@ -917,6 +917,54 @@
917
917
  </div>
918
918
  </div>
919
919
 
920
+ <h3 class="site-preview-heading">Single Page</h3>
921
+ <div class="usx-pagination">
922
+ <div class="usx-pagination__container">
923
+ <div class="usx-pagination__container-summary">
924
+ <p class="usa-label usx-label usx-pagination__summary" aria-live="polite" aria-atomic="true">
925
+ Showing <strong>1–8</strong> of <strong>8</strong> items
926
+ </p>
927
+ </div>
928
+ <div class="usx-pagination__container-end">
929
+ <div class="usx-pagination__step-options">
930
+ <label class="usa-label usx-label" for="react-pagination-single-page-step-options"
931
+ >Items per page</label
932
+ ><select id="react-pagination-single-page-step-options" class="usa-select usx-select">
933
+ <option value="">Select an option</option>
934
+ <option value="10" selected="">10</option>
935
+ <option value="25">25</option>
936
+ <option value="50">50</option>
937
+ <option value="100">100</option>
938
+ </select>
939
+ </div>
940
+ </div>
941
+ </div>
942
+ </div>
943
+
944
+ <h3 class="site-preview-heading">No Results</h3>
945
+ <div class="usx-pagination">
946
+ <div class="usx-pagination__container">
947
+ <div class="usx-pagination__container-summary">
948
+ <p class="usa-label usx-label usx-pagination__summary" aria-live="polite" aria-atomic="true">
949
+ Showing <strong>0–0</strong> of <strong>0</strong> items
950
+ </p>
951
+ </div>
952
+ <div class="usx-pagination__container-end">
953
+ <div class="usx-pagination__step-options">
954
+ <label class="usa-label usx-label" for="react-pagination-no-results-step-options"
955
+ >Items per page</label
956
+ ><select id="react-pagination-no-results-step-options" class="usa-select usx-select">
957
+ <option value="">Select an option</option>
958
+ <option value="10" selected="">10</option>
959
+ <option value="25">25</option>
960
+ <option value="50">50</option>
961
+ <option value="100">100</option>
962
+ </select>
963
+ </div>
964
+ </div>
965
+ </div>
966
+ </div>
967
+
920
968
  <h3 class="site-preview-heading">First Page</h3>
921
969
  <div class="usx-pagination">
922
970
  <div class="usx-pagination__container">
@@ -16,7 +16,7 @@ export default function PaginationSummary({
16
16
  itemLabel = 'items',
17
17
  className = '',
18
18
  }: PaginationSummaryProps) {
19
- const firstItem = (currentPage - 1) * pageSize + 1;
19
+ const firstItem = totalItems === 0 ? 0 : (currentPage - 1) * pageSize + 1;
20
20
  const lastItem = Math.min(currentPage * pageSize, totalItems);
21
21
  const classes = ClassNames(
22
22
  'usa-label',
@@ -5,7 +5,7 @@
5
5
  {% widthratio previousPages 1 resolvedPageSize as computedOffset %}
6
6
  {% widthratio resolvedPage 1 resolvedPageSize as computedLast %}
7
7
  <p class="usa-label usx-label usx-pagination__summary" aria-live="polite" aria-atomic="true">
8
- Showing <strong>{% if firstItem %}{{ firstItem }}{% else %}{{ computedOffset|add:"1" }}{% endif %}–{% if lastItem %}{{ lastItem }}{% elif totalItems and computedLast > totalItems %}{{ totalItems }}{% else %}{{ computedLast }}{% endif %}</strong>
8
+ Showing <strong>{% if totalItems == 0 %}0–0{% else %}{% if firstItem %}{{ firstItem }}{% else %}{{ computedOffset|add:"1" }}{% endif %}–{% if lastItem %}{{ lastItem }}{% elif totalItems and computedLast|add:"0" > totalItems %}{{ totalItems }}{% else %}{{ computedLast }}{% endif %}{% endif %}</strong>
9
9
  of <strong>{{ totalItems }}</strong> {{ itemLabel }}
10
10
  </p>
11
11
  {% endwith %}
@@ -129,6 +129,7 @@ export default function Popover({
129
129
  {showCloseIcon && (
130
130
  <Button
131
131
  variant="unstyled"
132
+ tighten
132
133
  className="usx-popover__header-action usx-popover__header-close"
133
134
  aria-label={closeIconLabel}
134
135
  iconProps={[{ name: 'close' }]}
@@ -129,6 +129,42 @@
129
129
  class="usx-popover__panel"
130
130
  ><div class="usx-popover__panel-content">Manage your account settings.</div></div></details>
131
131
 
132
+ <h3 class="site-preview-heading">Show Close Icon</h3>
133
+ <!-- prettier-ignore -->
134
+ <details
135
+
136
+ class="usx-popover"
137
+ data-side="bottom"
138
+ data-align="start"
139
+
140
+
141
+ >
142
+
143
+
144
+ <summary class="usa-button usx-button usa-button--primary margin-0">Open panel with close icon</summary>
145
+
146
+ <div
147
+ id="django-popover-close-icon"
148
+ class="usx-popover__panel"
149
+ ><header class="usx-popover__header"><div class="usx-popover__header-content"><h2 class="usx-popover__panel-heading" tabindex="-1">Panel with close icon</h2></div><div class="usx-popover__header-right-actions"><button type="button" class="usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action usx-popover__header-close" aria-label="Close panel" data-usx-popover-close="django-popover-close-icon">
150
+
151
+ <svg
152
+ class="
153
+ usa-icon usx-icon
154
+
155
+
156
+
157
+ "
158
+
159
+ aria-hidden="true"
160
+ focusable="false"
161
+ role="img"
162
+ >
163
+
164
+ <use href="img/sprite.svg#close"></use>
165
+
166
+ </svg></button></div></header><div class="usx-popover__panel-content">Use the icon in the header to close this panel.</div></div></details>
167
+
132
168
  <h3 class="site-preview-heading">Header Actions</h3>
133
169
  <!-- prettier-ignore -->
134
170
  <details
@@ -146,7 +182,7 @@
146
182
  <div
147
183
  id="django-popover-header-actions"
148
184
  class="usx-popover__panel"
149
- ><header class="usx-popover__header"><div class="usx-popover__header-left-actions"><button type="button" class="usa-button usx-button usa-button--unstyled usx-popover__header-action" aria-label="Back to records"><svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img"><use href="/img/sprite.svg#arrow_back"></use></svg></button></div><div class="usx-popover__header-content"><h2 class="usx-popover__panel-heading" tabindex="-1">Record 10482</h2></div><div class="usx-popover__header-right-actions"><details class="usx-popover" data-side="bottom" data-align="end"><summary class="usa-button usx-button usa-button--unstyled usx-popover__header-action" aria-label="Record actions"><svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img"><use href="/img/sprite.svg#more_vert"></use></svg></summary><div id="django-popover-header-actions-menu" class="usx-popover__panel"><ul class="usx-popover__menu"><li><button type="button" class="usx-popover__menu-item"><svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img"><use href="/img/sprite.svg#content_copy"></use></svg>Copy record</button></li></ul></div></details><button type="button" class="usa-button usx-button usa-button--unstyled usx-popover__header-action usx-popover__header-close" aria-label="Close record" data-usx-popover-close="django-popover-header-actions">
185
+ ><header class="usx-popover__header"><div class="usx-popover__header-left-actions"><button type="button" class="usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action" aria-label="Back to records"><svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img"><use href="/img/sprite.svg#arrow_back"></use></svg></button></div><div class="usx-popover__header-content"><h2 class="usx-popover__panel-heading" tabindex="-1">Record 10482</h2></div><div class="usx-popover__header-right-actions"><details class="usx-popover" data-side="bottom" data-align="end"><summary class="usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action" aria-label="Record actions"><svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img"><use href="/img/sprite.svg#more_vert"></use></svg></summary><div id="django-popover-header-actions-menu" class="usx-popover__panel"><ul class="usx-popover__menu"><li><button type="button" class="usx-popover__menu-item"><svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img"><use href="/img/sprite.svg#content_copy"></use></svg>Copy record</button></li></ul></div></details><button type="button" class="usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action usx-popover__header-close" aria-label="Close record" data-usx-popover-close="django-popover-header-actions">
150
186
 
151
187
  <svg
152
188
  class="
@@ -10,4 +10,4 @@
10
10
  >{% summary props=summaryProps label=summaryProps|get_optional:'label'|default_if_none:'Open panel' unstyled=True %}{% endsummary %}<div
11
11
  id="{{ id|force_escape }}"
12
12
  class="usx-popover__panel{% if panelShape == 'square' %} usx-popover__panel--square{% endif %}{% if panelClassName %} {{ panelClassName }}{% endif %}"
13
- >{% if headerLeftActions or panelHeading or headerRightActions or showCloseIcon %}<header class="usx-popover__header{% if headerClassName %} {{ headerClassName }}{% endif %}">{% if headerLeftActions %}<div class="usx-popover__header-left-actions">{{ headerLeftActions|safe }}</div>{% endif %}<div class="usx-popover__header-content">{% if panelHeading %}{% if headingAs == 'h1' %}<h1 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h1>{% elif headingAs == 'h3' %}<h3 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h3>{% elif headingAs == 'h4' %}<h4 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h4>{% elif headingAs == 'h5' %}<h5 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h5>{% elif headingAs == 'h6' %}<h6 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h6>{% else %}<h2 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h2>{% endif %}{% endif %}</div>{% if headerRightActions or showCloseIcon %}<div class="usx-popover__header-right-actions">{% if headerRightActions %}{{ headerRightActions|safe }}{% endif %}{% if showCloseIcon %}<button type="button" class="usa-button usx-button usa-button--unstyled usx-popover__header-action usx-popover__header-close" aria-label="{{ closeIconLabel|default:'Close'|force_escape }}" data-usx-popover-close="{{ id|force_escape }}">{% icon name='close' %}{% endicon %}</button>{% endif %}</div>{% endif %}</header>{% endif %}{% if menuItems %}{% include "popover/popover-menu.django.html" with items=menuItems prefix=id panelShape=panelShape only %}{% endif %}{% if children %}<div class="usx-popover__panel-content{% if scrollable %} usx-popover__scroll{% endif %}{% if contentClassName %} {{ contentClassName }}{% endif %}">{% if children is not True and children is not False %}{{ children|safe }}{% endif %}</div>{% endif %}{% if showClose %}<button type="button" class="usa-button usx-button usa-button--unstyled usx-popover__panel-close" data-usx-popover-close="{{ id|force_escape }}">{{ closeLabel|default:'Close'|force_escape }}</button>{% endif %}</div></details>
13
+ >{% if headerLeftActions or panelHeading or headerRightActions or showCloseIcon %}<header class="usx-popover__header{% if headerClassName %} {{ headerClassName }}{% endif %}">{% if headerLeftActions %}<div class="usx-popover__header-left-actions">{{ headerLeftActions|safe }}</div>{% endif %}<div class="usx-popover__header-content">{% if panelHeading %}{% if headingAs == 'h1' %}<h1 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h1>{% elif headingAs == 'h3' %}<h3 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h3>{% elif headingAs == 'h4' %}<h4 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h4>{% elif headingAs == 'h5' %}<h5 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h5>{% elif headingAs == 'h6' %}<h6 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h6>{% else %}<h2 class="usx-popover__panel-heading"{% if panelHeadingId %} id="{{ panelHeadingId|force_escape }}"{% endif %} tabindex="-1">{{ panelHeading|force_escape }}</h2>{% endif %}{% endif %}</div>{% if headerRightActions or showCloseIcon %}<div class="usx-popover__header-right-actions">{% if headerRightActions %}{{ headerRightActions|safe }}{% endif %}{% if showCloseIcon %}<button type="button" class="usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action usx-popover__header-close" aria-label="{{ closeIconLabel|default:'Close'|force_escape }}" data-usx-popover-close="{{ id|force_escape }}">{% icon name='close' %}{% endicon %}</button>{% endif %}</div>{% endif %}</header>{% endif %}{% if menuItems %}{% include "popover/popover-menu.django.html" with items=menuItems prefix=id panelShape=panelShape only %}{% endif %}{% if children %}<div class="usx-popover__panel-content{% if scrollable %} usx-popover__scroll{% endif %}{% if contentClassName %} {{ contentClassName }}{% endif %}">{% if children is not True and children is not False %}{{ children|safe }}{% endif %}</div>{% endif %}{% if showClose %}<button type="button" class="usa-button usx-button usa-button--unstyled usx-popover__panel-close" data-usx-popover-close="{{ id|force_escape }}">{{ closeLabel|default:'Close'|force_escape }}</button>{% endif %}</div></details>
@@ -81,6 +81,33 @@
81
81
  </div>
82
82
  </details>
83
83
 
84
+ <h3 class="site-preview-heading">Show Close Icon</h3>
85
+ <details class="usx-popover" data-side="bottom" data-align="start">
86
+ <summary class="usa-button usx-button usa-button--primary margin-0">
87
+ Open panel with close icon
88
+ </summary>
89
+ <div id="react-popover-close-icon" class="usx-popover__panel">
90
+ <header class="usx-popover__header">
91
+ <div class="usx-popover__header-content">
92
+ <h2 class="usx-popover__panel-heading" tabindex="-1">Panel with close icon</h2>
93
+ </div>
94
+ <div class="usx-popover__header-right-actions">
95
+ <button
96
+ type="button"
97
+ class="usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action usx-popover__header-close"
98
+ aria-label="Close panel"
99
+ data-usx-popover-close="react-popover-close-icon"
100
+ >
101
+ <svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img">
102
+ <use href="/img/sprite.svg#close"></use>
103
+ </svg>
104
+ </button>
105
+ </div>
106
+ </header>
107
+ <div class="usx-popover__panel-content">Use the icon in the header to close this panel.</div>
108
+ </div>
109
+ </details>
110
+
84
111
  <h3 class="site-preview-heading">Header Actions</h3>
85
112
  <details class="usx-popover" data-side="bottom" data-align="start">
86
113
  <summary class="usa-button usx-button margin-0">Open record</summary>
@@ -89,7 +116,7 @@
89
116
  <div class="usx-popover__header-left-actions">
90
117
  <button
91
118
  type="button"
92
- class="usa-button usx-button usa-button--unstyled usx-popover__header-action"
119
+ class="usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action"
93
120
  aria-label="Back to records"
94
121
  >
95
122
  <svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img">
@@ -103,7 +130,7 @@
103
130
  <div class="usx-popover__header-right-actions">
104
131
  <details class="usx-popover" data-side="bottom" data-align="end">
105
132
  <summary
106
- class="usa-button usx-button usa-button--unstyled usx-popover__header-action"
133
+ class="usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action"
107
134
  aria-label="Record actions"
108
135
  >
109
136
  <svg class="usa-icon usx-icon" aria-hidden="true" focusable="false" role="img">
@@ -124,7 +151,7 @@
124
151
  </details>
125
152
  <button
126
153
  type="button"
127
- class="usa-button usx-button usa-button--unstyled usx-popover__header-action usx-popover__header-close"
154
+ class="usa-button usx-button usa-button--unstyled usx-button--tight usx-popover__header-action usx-popover__header-close"
128
155
  aria-label="Close record"
129
156
  data-usx-popover-close="react-popover-header-actions"
130
157
  >
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
2
  import ClassNames from 'classnames';
3
3
 
4
- export interface SectionProps extends React.HTMLAttributes<HTMLElement> {
4
+ export interface SectionProps extends Omit<React.HTMLAttributes<HTMLElement>, 'content'> {
5
5
  title?: string;
6
6
  headingAs?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
7
7
  children?: React.ReactNode;
8
8
  content?: React.ReactNode;
9
9
  className?: string;
10
+ id?: string;
11
+ style?: React.CSSProperties;
10
12
  }
11
13
 
12
14
  const Section: React.FC<SectionProps> = ({
@@ -145,7 +145,7 @@
145
145
  <button
146
146
  class="usx-alert__dismiss"
147
147
  aria-label="Dismiss alert"
148
- onclick="this.closest('.usa-site-alert').remove()"
148
+ onclick="this.closest(&#x27;.usa-site-alert&#x27;).remove();"
149
149
  >
150
150
  <svg
151
151
  class="usa-icon usx-icon usa-icon--size-3"
@@ -174,7 +174,7 @@
174
174
  <button
175
175
  class="usx-alert__dismiss"
176
176
  aria-label="Dismiss alert"
177
- onclick="this.closest('.usa-site-alert').remove()"
177
+ onclick="this.closest(&#x27;.usa-site-alert&#x27;).remove();"
178
178
  >
179
179
  <svg
180
180
  class="usa-icon usx-icon usa-icon--size-3"
@@ -203,7 +203,7 @@
203
203
  <button
204
204
  class="usx-alert__dismiss"
205
205
  aria-label="Dismiss alert"
206
- onclick="this.closest('.usa-site-alert').remove()"
206
+ onclick="this.closest(&#x27;.usa-site-alert&#x27;).remove();"
207
207
  >
208
208
  <svg
209
209
  class="usa-icon usx-icon usa-icon--size-3"
@@ -238,7 +238,7 @@
238
238
  <button
239
239
  class="usx-alert__dismiss"
240
240
  aria-label="Dismiss alert"
241
- onclick="this.closest('.usa-site-alert').remove()"
241
+ onclick="this.closest(&#x27;.usa-site-alert&#x27;).remove();"
242
242
  >
243
243
  <svg
244
244
  class="usa-icon usx-icon usa-icon--size-3"
@@ -267,7 +267,7 @@
267
267
  <button
268
268
  class="usx-alert__dismiss"
269
269
  aria-label="Dismiss alert"
270
- onclick="this.closest('.usa-site-alert').remove()"
270
+ onclick="this.closest(&#x27;.usa-site-alert&#x27;).remove();"
271
271
  >
272
272
  <svg
273
273
  class="usa-icon usx-icon usa-icon--size-3"
@@ -298,7 +298,7 @@
298
298
  <button
299
299
  class="usx-alert__dismiss"
300
300
  aria-label="Dismiss alert"
301
- onclick="this.closest('.usa-site-alert').remove()"
301
+ onclick="this.closest(&#x27;.usa-site-alert&#x27;).remove();"
302
302
  >
303
303
  <svg
304
304
  class="usa-icon usx-icon usa-icon--size-3"
@@ -341,7 +341,7 @@
341
341
  <button
342
342
  class="usx-alert__dismiss"
343
343
  aria-label="Dismiss alert"
344
- onclick="this.closest('.usa-site-alert').remove()"
344
+ onclick="this.closest(&#x27;.usa-site-alert&#x27;).remove();"
345
345
  >
346
346
  <svg
347
347
  class="usa-icon usx-icon usa-icon--size-3"
@@ -384,7 +384,7 @@
384
384
  <button
385
385
  class="usx-alert__dismiss"
386
386
  aria-label="Dismiss alert"
387
- onclick="this.closest('.usa-site-alert').remove()"
387
+ onclick="this.closest(&#x27;.usa-site-alert&#x27;).remove();"
388
388
  >
389
389
  <svg
390
390
  class="usa-icon usx-icon usa-icon--size-3"
@@ -1,10 +1,17 @@
1
1
  import React from 'react';
2
2
  import ClassNames from 'classnames';
3
3
 
4
- export interface SwapProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
4
+ export interface SwapProps extends React.HTMLAttributes<HTMLElement> {
5
5
  children?: React.ReactNode;
6
6
  className?: string;
7
7
  variant?: 'default' | 'active' | 'rotate' | 'flip';
8
+ /** Button mode toggles aria-pressed and swaps content after JavaScript enhancement. */
9
+ as?: 'label' | 'button';
10
+ /** Initial state for button mode. */
11
+ defaultPressed?: boolean;
12
+ /** Stable accessible name for button mode. */
13
+ ariaLabel?: string;
14
+ disabled?: boolean;
8
15
  onContent?: React.ReactNode;
9
16
  offContent?: React.ReactNode;
10
17
  includeInput?: boolean;
@@ -17,6 +24,10 @@ const Swap: React.FC<SwapProps> = ({
17
24
  children = null,
18
25
  className = '',
19
26
  variant = 'default',
27
+ as = 'label',
28
+ defaultPressed = false,
29
+ ariaLabel,
30
+ disabled = false,
20
31
  onContent = 'ON',
21
32
  offContent = 'OFF',
22
33
  includeInput = true,
@@ -26,18 +37,39 @@ const Swap: React.FC<SwapProps> = ({
26
37
  ...props
27
38
  }) => {
28
39
  const variantClass = variant !== 'default' ? `usx-swap--${variant}` : '';
29
- const classes = ClassNames('usx-swap', variantClass, className);
40
+ const classes = ClassNames(
41
+ 'usx-swap',
42
+ variantClass,
43
+ as === 'button' && 'usa-button usx-button usx-swap--button',
44
+ className
45
+ );
30
46
  const onClasses = ClassNames('usx-swap-on', onClassName);
31
47
  const offClasses = ClassNames('usx-swap-off', offClassName);
32
48
 
33
49
  const content = children || (
34
50
  <>
35
- {includeInput ? <input type="checkbox" autoComplete="off" {...inputProps} /> : null}
51
+ {as === 'label' && includeInput ? (
52
+ <input type="checkbox" autoComplete="off" {...inputProps} />
53
+ ) : null}
36
54
  <span className={onClasses}>{onContent}</span>
37
55
  <span className={offClasses}>{offContent}</span>
38
56
  </>
39
57
  );
40
58
 
59
+ if (as === 'button') {
60
+ return (
61
+ <button
62
+ type="button"
63
+ className={classes}
64
+ aria-pressed={defaultPressed}
65
+ aria-label={ariaLabel}
66
+ disabled={disabled}
67
+ {...props}
68
+ >
69
+ {content}
70
+ </button>
71
+ );
72
+ }
41
73
  return (
42
74
  <label className={classes} {...props}>
43
75
  {content}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "swap",
3
3
  "template": "swap/swap.django.html",
4
- "version": 2,
4
+ "version": 3,
5
5
  "default": {
6
6
  "className": "",
7
7
  "variant": "default",
@@ -25,6 +25,33 @@
25
25
  "type": "boolean",
26
26
  "description": "Render default checkbox input control"
27
27
  },
28
+ "as": {
29
+ "type": "select",
30
+ "options": ["label", "button"],
31
+ "default": "label",
32
+ "description": "Render a checkbox label or an enhanced toggle button. Button mode swaps content on click and emits change after updating aria-pressed."
33
+ },
34
+ "defaultPressed": {
35
+ "type": "boolean",
36
+ "description": "Initial pressed state in button mode"
37
+ },
38
+ "onClick": {
39
+ "type": "function",
40
+ "description": "React button click handler. In Django or HTML, listen for the native click event on the button.",
41
+ "renderers": {
42
+ "django": {
43
+ "supported": false
44
+ }
45
+ }
46
+ },
47
+ "ariaLabel": {
48
+ "type": "string",
49
+ "description": "Stable accessible name for button mode"
50
+ },
51
+ "disabled": {
52
+ "type": "boolean",
53
+ "description": "Disable the button in button mode"
54
+ },
28
55
  "inputId": {
29
56
  "type": "string",
30
57
  "description": "ID applied to the generated checkbox"
@@ -101,10 +101,32 @@
101
101
  <span class="usx-swap-off">Custom OFF</span>
102
102
  </label>
103
103
 
104
- <h3 class="site-preview-heading">Trigger Alert On Swap</h3>
105
- <label class="usx-swap">
106
- <input type="checkbox" autocomplete="off" onChange="alert(&#x27;Swap triggered!&#x27;)" />
107
-
108
- <span class="usx-swap-on">ON</span>
109
- <span class="usx-swap-off">OFF</span>
110
- </label>
104
+ <h3 class="site-preview-heading">Button Text</h3>
105
+ <button
106
+ type="button"
107
+ class="usx-swap usa-button usx-button usx-swap--button"
108
+ aria-pressed="false"
109
+ aria-label="Details"
110
+ >
111
+ <span class="usx-swap-on">Hide details</span>
112
+ <span class="usx-swap-off">Show details</span>
113
+ </button>
114
+
115
+ <h3 class="site-preview-heading">Button Icon</h3>
116
+ <button
117
+ type="button"
118
+ class="usx-swap usx-swap--rotate usa-button usx-button usx-swap--button"
119
+ aria-pressed="true"
120
+ aria-label="Notifications"
121
+ >
122
+ <span class="usx-swap-on">
123
+ <svg class="usa-icon usx-icon usa-icon--size-4" aria-hidden="true" focusable="false" role="img">
124
+ <use href="img/sprite.svg#notifications_active"></use>
125
+ </svg>
126
+ </span>
127
+ <span class="usx-swap-off">
128
+ <svg class="usa-icon usx-icon usa-icon--size-4" aria-hidden="true" focusable="false" role="img">
129
+ <use href="img/sprite.svg#notifications"></use>
130
+ </svg>
131
+ </span>
132
+ </button>
@@ -1,14 +1,28 @@
1
1
  {# Django template for Swap #}
2
+ {% if as == 'button' %}
3
+ <button
4
+ type="button"
5
+ class="usx-swap{% if variant and variant != 'default' %} usx-swap--{{ variant }}{% endif %} usa-button usx-button usx-swap--button{% if className %} {{ className }}{% endif %}"
6
+ aria-pressed="{% if defaultPressed %}true{% else %}false{% endif %}"
7
+ {% if ariaLabel %}aria-label="{{ ariaLabel }}"{% endif %}
8
+ {% if disabled %}disabled=""{% endif %}
9
+ >
10
+ {% else %}
2
11
  <label class="usx-swap{% if variant and variant != 'default' %} usx-swap--{{ variant }}{% endif %}{% if className %} {{ className }}{% endif %}">
12
+ {% endif %}
3
13
  {% if content %}
4
14
  {{ content|safe }}
5
15
  {% elif children %}
6
16
  {{ children|safe }}
7
17
  {% else %}
8
- {% if includeInput != False %}
18
+ {% if as != 'button' and includeInput != False %}
9
19
  <input type="checkbox" autocomplete="off"{% if inputId %} id="{{ inputId }}"{% endif %}{% if inputClassName %} class="{{ inputClassName }}"{% endif %}{% if inputChecked %} checked{% endif %} {% for attr, value in inputProps.items %} {{ attr }}="{{ value }}"{% endfor %}/>
10
20
  {% endif %}
11
21
  <span class="usx-swap-on{% if onClassName %} {{ onClassName }}{% endif %}">{{ onContent|default:'ON'|safe }}</span>
12
22
  <span class="usx-swap-off{% if offClassName %} {{ offClassName }}{% endif %}">{{ offContent|default:'OFF'|safe }}</span>
13
23
  {% endif %}
24
+ {% if as == 'button' %}
25
+ </button>
26
+ {% else %}
14
27
  </label>
28
+ {% endif %}
@@ -93,8 +93,38 @@
93
93
  ><span class="usx-swap-off">Custom OFF</span></label
94
94
  >
95
95
 
96
- <h3 class="site-preview-heading">Trigger Alert On Swap</h3>
97
- <label class="usx-swap"
98
- ><input type="checkbox" autocomplete="off" /><span class="usx-swap-on">ON</span
99
- ><span class="usx-swap-off">OFF</span></label
96
+ <h3 class="site-preview-heading">Button Text</h3>
97
+ <button
98
+ type="button"
99
+ class="usx-swap usa-button usx-button usx-swap--button"
100
+ aria-pressed="false"
101
+ aria-label="Details"
102
+ >
103
+ <span class="usx-swap-on">Hide details</span><span class="usx-swap-off">Show details</span>
104
+ </button>
105
+
106
+ <h3 class="site-preview-heading">Button Icon</h3>
107
+ <button
108
+ type="button"
109
+ class="usx-swap usx-swap--rotate usa-button usx-button usx-swap--button"
110
+ aria-pressed="true"
111
+ aria-label="Notifications"
100
112
  >
113
+ <span class="usx-swap-on"
114
+ ><svg
115
+ class="usa-icon usx-icon usa-icon--size-4"
116
+ aria-hidden="true"
117
+ focusable="false"
118
+ role="img"
119
+ >
120
+ <use href="/img/sprite.svg#notifications_active"></use></svg></span
121
+ ><span class="usx-swap-off"
122
+ ><svg
123
+ class="usa-icon usx-icon usa-icon--size-4"
124
+ aria-hidden="true"
125
+ focusable="false"
126
+ role="img"
127
+ >
128
+ <use href="/img/sprite.svg#notifications"></use></svg
129
+ ></span>
130
+ </button>