@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
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "callout",
3
+ "template": "callout/callout.django.html",
4
+ "version": 1,
5
+ "props": {
6
+ "className": {
7
+ "type": "string",
8
+ "description": "Additional classes."
9
+ },
10
+ "strokeColor": {
11
+ "type": "string",
12
+ "description": "Border color token. Omit to leave the border color utility unset."
13
+ },
14
+ "indent": {
15
+ "type": "select",
16
+ "description": "Left indentation.",
17
+ "options": [
18
+ "sm",
19
+ "md",
20
+ "lg",
21
+ "xl"
22
+ ]
23
+ },
24
+ "dedent": {
25
+ "type": "boolean",
26
+ "description": "Pull the callout left beyond the content edge.",
27
+ "default": false
28
+ },
29
+ "big": {
30
+ "type": "boolean",
31
+ "description": "Use a thicker border."
32
+ },
33
+ "orientation": {
34
+ "type": "select",
35
+ "description": "Horizontal uses a left border; vertical uses a top border.",
36
+ "options": [
37
+ "horizontal",
38
+ "vertical"
39
+ ],
40
+ "default": "horizontal"
41
+ },
42
+ "children": {
43
+ "type": "slot",
44
+ "description": "Body content. Takes precedence over content when supplied."
45
+ },
46
+ "content": {
47
+ "type": "slot",
48
+ "description": "Fallback body content, ignored when children is supplied."
49
+ },
50
+ "backgroundColor": {
51
+ "type": "string",
52
+ "description": "Background utility token: bg-{backgroundColor}."
53
+ },
54
+ "textColor": {
55
+ "type": "string",
56
+ "description": "Text utility token: text-{textColor}."
57
+ },
58
+ "element": {
59
+ "type": "select",
60
+ "description": "Root HTML element.",
61
+ "options": [
62
+ "div",
63
+ "section",
64
+ "aside",
65
+ "blockquote"
66
+ ],
67
+ "default": "div"
68
+ },
69
+ "cite": {
70
+ "type": "string",
71
+ "description": "Source URL when the root element is blockquote."
72
+ }
73
+ }
74
+ }
@@ -2,32 +2,16 @@ import React from 'react';
2
2
  import ClassNames from 'classnames';
3
3
  import ButtonGroup from '../button-group/ButtonGroup';
4
4
  import type { ButtonGroupItemProps } from '../button-group/ButtonGroup';
5
- import Tag from '../tag/Tag';
6
- import Image from '../image/Image';
5
+ import Tag, { type TagProps } from '../tag/Tag';
6
+ import Image, { type ImageProps } from '../image/Image';
7
7
  import Carousel from '../carousel/Carousel';
8
8
 
9
- export interface CardTag {
10
- value: string;
11
- color?: string;
12
- }
13
-
14
- export interface CardAction {
15
- children: string;
16
- variant?: ButtonGroupItemProps['variant'];
17
- onClick?: () => void;
18
- }
19
-
20
- export interface CardImage {
21
- src: string;
22
- alt: string;
23
- }
24
-
25
9
  export interface CardProps extends React.HTMLAttributes<HTMLElement> {
26
10
  title?: string;
27
11
  description?: string;
28
- tags?: CardTag[];
29
- actions?: CardAction[];
30
- images?: CardImage[];
12
+ tagProps?: TagProps[];
13
+ buttonProps?: ButtonGroupItemProps[];
14
+ imageProps?: ImageProps[];
31
15
  headerFirst?: boolean;
32
16
  flag?: boolean;
33
17
  mediaRight?: boolean;
@@ -42,9 +26,9 @@ export interface CardProps extends React.HTMLAttributes<HTMLElement> {
42
26
  export default function Card({
43
27
  title,
44
28
  description,
45
- tags,
46
- actions,
47
- images,
29
+ tagProps,
30
+ buttonProps,
31
+ imageProps,
48
32
  headerFirst = false,
49
33
  flag = false,
50
34
  mediaRight = false,
@@ -75,22 +59,22 @@ export default function Card({
75
59
  }
76
60
  );
77
61
 
78
- const hasStructuredContent = title || description || tags || actions || images;
62
+ const hasStructuredContent = title || description || tagProps || buttonProps || imageProps;
79
63
  const shouldRenderStructured = hasStructuredContent && !children;
80
64
 
81
- const hasImages = images && images.length > 0;
82
- const useCarousel = images && images.length > 1;
65
+ const hasImages = imageProps && imageProps.length > 0;
66
+ const useCarousel = imageProps && imageProps.length > 1;
83
67
  const media = useCarousel ? (
84
68
  <Carousel
85
69
  id={`${props.id || 'card'}-carousel`}
86
70
  showDots={showCarouselDots}
87
71
  className="usx-card__carousel"
88
- slides={images?.map((img, index) => ({
89
- content: <Image key={index} {...img} hideCaption={true} />,
72
+ slides={imageProps?.map((img, index) => ({
73
+ content: <Image key={index} hideCaption={true} {...img} />,
90
74
  }))}
91
75
  />
92
76
  ) : hasImages ? (
93
- <Image {...images[0]} hideCaption={true} className="usa-card__img" />
77
+ <Image hideCaption={true} {...imageProps[0]} className={ClassNames('usa-card__img', imageProps[0].className)} />
94
78
  ) : null;
95
79
 
96
80
  return (
@@ -111,9 +95,9 @@ export default function Card({
111
95
  )}
112
96
 
113
97
  <div className="usa-card__body">
114
- {tags && tags.length > 0 && (
98
+ {tagProps && tagProps.length > 0 && (
115
99
  <div className="usx-tag-group">
116
- {tags.map((tag, index) => (
100
+ {tagProps.map((tag, index) => (
117
101
  <Tag key={index} {...tag} />
118
102
  ))}
119
103
  </div>
@@ -123,9 +107,9 @@ export default function Card({
123
107
  )}
124
108
  </div>
125
109
 
126
- {actions && actions.length > 0 && (
110
+ {buttonProps && buttonProps.length > 0 && (
127
111
  <div className="usa-card__footer">
128
- <ButtonGroup buttonProps={actions} className="flex-wrap" />
112
+ <ButtonGroup buttonProps={buttonProps} className="flex-wrap" />
129
113
  </div>
130
114
  )}
131
115
  </>
@@ -3,26 +3,28 @@
3
3
  <div class="usa-card__container">
4
4
  {% if children %}
5
5
  {{ children }}
6
- {% elif title or description or tags or actions or images %}
6
+ {% elif title or description or tagProps or buttonProps or imageProps %}
7
7
  {% if title %}
8
8
  <div class="usa-card__header">
9
9
  <h4 class="usa-card__heading">{{ title }}</h4>
10
10
  </div>
11
11
  {% endif %}
12
- {% if images and images|length > 1 %}
12
+ {% if imageProps and imageProps|length > 1 %}
13
13
  <div class="usa-card__media{% if mediaInset %} usa-card__media--inset{% endif %}{% if mediaExdent %} usa-card__media--exdent{% endif %}">
14
- {% carousel slides=images id=id|default:'card'|add:'-carousel' showDots=showCarouselDots|default_bool:True className='usx-card__carousel' %}{% endcarousel %}
14
+ {% carousel slides=imageProps id=id|default:'card'|add:'-carousel' showDots=showCarouselDots|default_bool:True className='usx-card__carousel' %}{% endcarousel %}
15
15
  </div>
16
- {% elif images and images.0 %}
16
+ {% elif imageProps and imageProps.0 %}
17
17
  <div class="usa-card__media{% if mediaInset %} usa-card__media--inset{% endif %}{% if mediaExdent %} usa-card__media--exdent{% endif %}">
18
- {% image src=images.0.src alt=images.0.alt caption=images.0.caption hideCaption=True href=images.0.href rounded=images.0.rounded circular=images.0.circular objectFit=images.0.objectFit maxWidth=images.0.maxWidth maxHeight=images.0.maxHeight className='usa-card__img' %}{% endimage %}
18
+ {% with imageClass=imageProps.0.className|default:'' %}
19
+ {% image props=imageProps.0 hideCaption=imageProps.0.hideCaption|default_bool:True className='usa-card__img '|add:imageClass %}{{ imageProps.0.children|safe }}{% endimage %}
20
+ {% endwith %}
19
21
  </div>
20
22
  {% endif %}
21
23
  <div class="usa-card__body">
22
- {% if tags %}
24
+ {% if tagProps %}
23
25
  <div class="usx-tag-group">
24
- {% for tag in tags %}
25
- {% tag value=tag.value color=tag.color %}{% endtag %}
26
+ {% for tag in tagProps %}
27
+ {% tag props=tag %}{{ tag.children|safe }}{% endtag %}
26
28
  {% endfor %}
27
29
  </div>
28
30
  {% endif %}
@@ -30,9 +32,9 @@
30
32
  <p>{{ description }}</p>
31
33
  {% endif %}
32
34
  </div>
33
- {% if actions %}
35
+ {% if buttonProps %}
34
36
  <div class="usa-card__footer">
35
- {% button_group buttonProps=actions className='flex-wrap' %}{% endbutton_group %}
37
+ {% button_group buttonProps=buttonProps className='flex-wrap' %}{% endbutton_group %}
36
38
  </div>
37
39
  {% endif %}
38
40
  {% else %}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "card",
3
3
  "template": "card/card.django.html",
4
- "version": 1,
4
+ "version": 3,
5
5
  "props": {
6
6
  "id": {
7
7
  "type": "string",
@@ -15,62 +15,37 @@
15
15
  "type": "string",
16
16
  "description": "The description text displayed in the card body"
17
17
  },
18
- "tags": {
18
+ "tagProps": {
19
19
  "type": "array",
20
- "description": "Array of tag objects with value and color properties",
20
+ "description": "Props for each tag component.",
21
21
  "items": {
22
22
  "type": "object",
23
- "description": "Card tag.",
24
- "properties": {
25
- "value": {
26
- "type": "string",
27
- "description": "Tag text"
28
- },
29
- "color": {
30
- "type": "string",
31
- "description": "Tag color variant"
32
- }
33
- }
23
+ "component": "tag",
24
+ "description": "Props passed to the tag component."
34
25
  }
35
26
  },
36
- "actions": {
27
+ "buttonProps": {
37
28
  "type": "array",
38
- "description": "Array of action button objects",
29
+ "description": "Props for each button component.",
39
30
  "items": {
40
31
  "type": "object",
41
- "description": "Card action button.",
32
+ "component": "button",
33
+ "description": "Props passed to the button component.",
42
34
  "properties": {
43
- "children": {
44
- "type": "string",
45
- "description": "Button text"
46
- },
47
- "variant": {
35
+ "itemClassName": {
48
36
  "type": "string",
49
- "description": "Button variant"
50
- },
51
- "onClick": {
52
- "type": "function",
53
- "description": "Click handler"
37
+ "description": "Additional classes for the button group list item."
54
38
  }
55
39
  }
56
40
  }
57
41
  },
58
- "images": {
42
+ "imageProps": {
59
43
  "type": "array",
60
- "description": "Array of image objects; multiple images render as a carousel",
44
+ "description": "Props for each image component.",
61
45
  "items": {
62
46
  "type": "object",
63
- "description": "Card image.",
64
- "properties": {
65
- "src": {
66
- "type": "string",
67
- "description": "Image source URL"
68
- },
69
- "alt": {
70
- "type": "string",
71
- "description": "Alt text for the image"
72
- }
73
- }
47
+ "component": "image",
48
+ "description": "Props passed to the image component."
74
49
  }
75
50
  },
76
51
  "headerFirst": {
@@ -1,6 +1,6 @@
1
1
  {% load components %}
2
2
  <ul class="usa-card-group usx-card-group{% if className %} {{ className }}{% endif %}">
3
3
  {% for card in cardProps %}
4
- {% card tag='li' title=card.title description=card.description footer=card.footer actions=card.actions images=card.images flag=card.flag mediaRight=card.mediaRight headerFirst=card.headerFirst className=card.className %}{% endcard %}
4
+ {% card props=card tag='li' %}{{ card.children|safe }}{% endcard %}
5
5
  {% endfor %}
6
6
  </ul>
@@ -21,7 +21,7 @@ export function Slide({
21
21
  children = null,
22
22
  ...rest
23
23
  }: SlideProps) {
24
- const cls = ['usx-carousel__slide', className].filter(Boolean).join(' ');
24
+ const cls = ClassNames('usx-carousel__slide', className);
25
25
  return (
26
26
  <section
27
27
  id={id}
@@ -63,6 +63,7 @@ export default function Carousel({
63
63
  }: CarouselProps) {
64
64
  const classes = ClassNames('usx-carousel', className);
65
65
  const childArray = React.Children.toArray(children).filter(Boolean);
66
+
66
67
  return (
67
68
  <div className={classes} {...props} role="region" aria-roledescription="carousel" aria-label={ariaLabel}>
68
69
  <div className="usx-carousel__viewport" tabIndex={-1}>
@@ -88,7 +89,7 @@ export default function Carousel({
88
89
  </div>
89
90
  {showDots && (
90
91
  <div className="usx-carousel__dots" aria-label="Slide navigation">
91
- {slides?.map((_, i) => (
92
+ {(childArray.length > 0 ? childArray : slides)?.map((_, i) => (
92
93
  <a key={i} href={`#${id}-slide-${i + 1}`} aria-label={`Go to slide ${i + 1}`} tabIndex={-1} />
93
94
  ))}
94
95
  {childArray.length > 0 && slideIds.length === childArray.length && slideIds.map((slideId, i) => (
@@ -5,14 +5,20 @@
5
5
  <div class="usx-carousel__viewport" tabindex="-1">
6
6
  <div class="usx-carousel__track">
7
7
  {% if children %}
8
- {{ children|safe }}
8
+ {% if children.length > 0 %}
9
+ {% for child in children %}
10
+ {{ child|safe }}
11
+ {% endfor %}
12
+ {% else %}
13
+ {{ children|safe }}
14
+ {% endif %}
9
15
  {% elif slides %}
10
16
  {% for slide in slides %}
11
17
  <section id="{{ id }}-slide-{{ forloop.counter }}" class="usx-carousel__slide" role="group" aria-roledescription="slide" aria-label="{{ forloop.counter }} of {{ slides|length }}" tabindex="0">
12
18
  {% if slide.content %}
13
19
  {{ slide.content|safe }}
14
20
  {% elif slide.src %}
15
- {% image src=slide.src alt=slide.alt caption=slide.caption hideCaption=True href=slide.href rounded=slide.rounded circular=slide.circular objectFit=slide.objectFit maxWidth=slide.maxWidth maxHeight=slide.maxHeight className=slide.className %}{% endimage %}
21
+ {% image props=slide hideCaption=slide.hideCaption|default_bool:True %}{{ slide.children|safe }}{% endimage %}
16
22
  {% else %}
17
23
  {# Fallback: render the slide object/string directly #}
18
24
  {{ slide|safe }}
@@ -27,6 +33,11 @@
27
33
 
28
34
  {% if showDots %}
29
35
  <div class="usx-carousel__dots" aria-label="Slide navigation">
36
+ {% if children and children.length > 0 %}
37
+ {% for child in children %}
38
+ <a href="#{{ id }}-slide-{{ forloop.counter }}" aria-label="Go to slide {{ forloop.counter }}" tabindex="-1"></a>
39
+ {% endfor %}
40
+ {% endif %}
30
41
  {% if slides %}
31
42
  {% for slide in slides %}
32
43
  <a href="#{{ id }}-slide-{{ forloop.counter }}" aria-label="Go to slide {{ forloop.counter }}" tabindex="-1"></a>
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "carousel",
3
3
  "template": "carousel/carousel.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "id": {
7
7
  "type": "string",
@@ -13,7 +13,7 @@
13
13
  "description": "Array of slide objects {content: string|node}"
14
14
  },
15
15
  "children": {
16
- "type": "string",
16
+ "type": "slot",
17
17
  "description": "Optional raw slide markup rendered directly inside the track."
18
18
  },
19
19
  "slideIds": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "character-count",
3
3
  "template": "character-count/character-count.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "props": {
6
6
  "id": {
7
7
  "type": "string",
@@ -9,7 +9,7 @@
9
9
  "description": "ID for the input/textarea field. Used to wire label, hint, message, and error/success spans."
10
10
  },
11
11
  "label": {
12
- "type": "string",
12
+ "type": "slot",
13
13
  "default": null,
14
14
  "description": "Label text for the field."
15
15
  },
@@ -2,16 +2,9 @@ import React from 'react';
2
2
  import classNames from 'classnames';
3
3
  import Fieldset from '../fieldset/Fieldset';
4
4
  import FormGroup from '../form-group/FormGroup';
5
- import Checkbox from '../checkbox/Checkbox';
5
+ import Checkbox, { type CheckboxProps } from '../checkbox/Checkbox';
6
6
 
7
- export interface CheckboxOption {
8
- id?: string;
9
- value: string;
10
- label: React.ReactNode;
11
- description?: string;
12
- checked?: boolean;
13
- disabled?: boolean;
14
- }
7
+ export type CheckboxGroupItemProps = Omit<CheckboxProps, 'id'> & { id?: string };
15
8
 
16
9
  export interface CheckboxGroupProps extends React.HTMLAttributes<HTMLFieldSetElement> {
17
10
  tile?: boolean;
@@ -21,7 +14,7 @@ export interface CheckboxGroupProps extends React.HTMLAttributes<HTMLFieldSetEle
21
14
  hint?: React.ReactNode;
22
15
  error?: React.ReactNode;
23
16
  name?: string;
24
- options: CheckboxOption[];
17
+ checkboxProps: CheckboxGroupItemProps[];
25
18
  className?: string;
26
19
  }
27
20
 
@@ -33,7 +26,8 @@ const CheckboxGroup: React.FC<CheckboxGroupProps> = ({
33
26
  hint = null,
34
27
  error = null,
35
28
  name = 'checkbox-group',
36
- options = [],
29
+ id: groupId,
30
+ checkboxProps = [],
37
31
  className = '',
38
32
  ...props
39
33
  }) => {
@@ -41,21 +35,17 @@ const CheckboxGroup: React.FC<CheckboxGroupProps> = ({
41
35
 
42
36
  return (
43
37
  <FormGroup error={!!error}>
44
- <Fieldset legend={legend} required={required} hint={hint} error={error} className={classes} {...props}>
45
- {options.map((opt, idx) => {
46
- const id = opt.id || `${name}-${idx}`;
38
+ <Fieldset id={groupId} legend={legend} required={required} hint={hint} error={error} className={classes} {...props}>
39
+ {checkboxProps.map((opt, idx) => {
40
+ const id = opt.id || `${groupId || name}-${idx}`;
47
41
  return (
48
42
  <Checkbox
49
43
  key={id}
50
- id={id}
51
44
  name={name}
52
- value={opt.value}
53
- label={opt.label as string}
54
- description={opt.description}
55
- checked={!!opt.checked}
56
- disabled={!!opt.disabled}
57
45
  tile={tile}
58
46
  small={small}
47
+ {...opt}
48
+ id={id}
59
49
  />
60
50
  );
61
51
  })}
@@ -1,12 +1,18 @@
1
1
  {# Django template for CheckboxGroup #}
2
2
  {% load components %}
3
3
 
4
+ {% with groupName=name|default:"checkbox-group" groupClass=className|default:"" %}
4
5
  {% form_group error=error %}
5
- {% fieldset legend=legend required=required hint=hint error=error className="usa-checkbox-group usx-checkbox-group" %}
6
- {% for opt in options %}
7
- {% with optionId=id|add:"-"|add:opt.value %}
8
- {% checkbox id=optionId name=name|default:"checkbox-group" value=opt.value label=opt.label description=opt.description checked=opt.checked disabled=opt.disabled tile=tile small=small %}{% endcheckbox %}
6
+ {% fieldset legend=legend required=required hint=hint error=error id=id className="usa-checkbox-group usx-checkbox-group "|add:groupClass %}
7
+ {% for opt in checkboxProps %}
8
+ {% with index=forloop.counter0|stringformat:"s" %}
9
+ {% with baseId=id|default:groupName %}
10
+ {% with optionId=baseId|add:"-"|add:index %}
11
+ {% checkbox props=opt id=opt.id|default:optionId name=opt.name|default:groupName tile=opt.tile|default_bool:tile small=opt.small|default_bool:small %}{% endcheckbox %}
12
+ {% endwith %}
13
+ {% endwith %}
9
14
  {% endwith %}
10
15
  {% endfor %}
11
16
  {% endfieldset %}
12
17
  {% endform_group %}
18
+ {% endwith %}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "checkbox-group",
3
3
  "template": "checkbox-group/checkbox-group.django.html",
4
- "version": 1,
4
+ "version": 3,
5
5
  "props": {
6
6
  "id": {
7
7
  "type": "string",
@@ -27,20 +27,25 @@
27
27
  "default": false
28
28
  },
29
29
  "hint": {
30
- "type": "string",
30
+ "type": "slot",
31
31
  "description": "Group-level hint text, rendered after the legend"
32
32
  },
33
33
  "error": {
34
- "type": "string",
34
+ "type": "slot",
35
35
  "description": "Group-level error message, rendered after the hint"
36
36
  },
37
37
  "name": {
38
38
  "type": "string",
39
39
  "description": "Name attribute shared by the checkbox inputs"
40
40
  },
41
- "options": {
41
+ "checkboxProps": {
42
42
  "type": "array",
43
- "description": "Array of option objects: {id, value, label, description, checked, disabled}"
43
+ "description": "Checkbox props. Item values override group name, tile, and small defaults; omitted IDs use the group id or name plus the item index.",
44
+ "items": {
45
+ "type": "object",
46
+ "component": "checkbox",
47
+ "description": "Props passed to the checkbox component."
48
+ }
44
49
  },
45
50
  "className": {
46
51
  "type": "string",
@@ -63,22 +63,6 @@
63
63
 
64
64
 
65
65
  <h3 class="site-preview-heading margin-top-5">Read John's Story</h3>
66
- <div class="usx-block usx-block--callout usx-border-primary">
67
- <div class="usx-block__content usx-border-info maxw-tablet margin-0">
68
- <p class="font-serif-lg maxw-tablet margin-0">
69
- ❝We found this wand shop that had the best wands, and we were
70
- like, "We have to go here!" So we went there.❞
71
- </p>
72
- <div class="usx-block__attribution">
73
- <div class="usx-attribution">
74
- <span class="usx-attribution__content">
75
- <span class="usx-attribution__primary">John Doe</span>
76
- <span class="usx-attribution__secondary">Under Secretary for the Department of Magic and Mystical Affairs</span>
77
- </span>
78
- </div>
79
- </div>
80
- </div>
81
- </div>
82
66
  <a class="usx-clickable display-flex flex-align-center margin-1 usx-width-fit" href="https://google.com">
83
67
  <span class="usx-circle bg-black text-white usx-clickable__bg-color-on-hover display-flex flex-align-center flex-justify-center width-4 height-4">
84
68
  <svg class="usa-icon usa-icon--size-3" aria-hidden="true" focusable="false" role="img">
@@ -88,31 +72,29 @@
88
72
  <span class="margin-left-1 usx-clickable__link">Read John's Story</span>
89
73
  </a>
90
74
 
91
- <h3 class="site-preview-heading margin-top-5">Read John's Story inside blockquote</h3>
92
- <a class="usx-clickable display-flex usx-block usx-block--callout usx-border-primary" href="https://google.com">
93
- <div class="usx-block__content usx-border-info maxw-tablet margin-0">
94
- <p class="font-serif-lg maxw-tablet margin-0">
95
- ❝We found this wand shop that had the best wands, and we were
96
- like, "We have to go here!" So we went there.❞
97
- </p>
98
- <div class="usx-block__attribution">
99
- <div class="usx-attribution">
100
- <span class="usx-attribution__content">
101
- <span class="usx-attribution__primary">John Doe</span>
102
- <span class="usx-attribution__secondary">Under Secretary for the Department of Magic and Mystical Affairs</span>
103
- </span>
104
- </div>
105
- </div>
106
-
107
- <div class="display-flex flex-align-center margin-top-2">
108
- <span class="usx-circle bg-black text-white usx-clickable__bg-color-on-hover display-flex flex-align-center flex-justify-center width-4 height-4">
109
- <svg class="usa-icon usa-icon--size-3" aria-hidden="true" focusable="false" role="img">
110
- <use href="./img/sprite.svg#arrow_forward"></use>
111
- </svg>
112
- </span>
113
- <span class="margin-left-1 usx-clickable__link">Read John's Story</span>
75
+ <h3 class="site-preview-heading margin-top-5">Clickable Quote</h3>
76
+ <a class="usx-clickable display-block maxw-tablet" href="https://google.com">
77
+ <div class="usx-quote usx-quote--vertical">
78
+ <div class="usx-callout usx-callout--vertical usx-border-primary">
79
+ <figure class="usx-quote__body">
80
+ <blockquote class="usx-quote__content font-serif-lg">❝We found this wand shop that had the best wands, and we were like, "We have to go here!" So we went there.❞</blockquote>
81
+ <figcaption class="usx-quote__attribution">
82
+ <div class="usx-attribution">
83
+ <span class="usx-attribution__content">
84
+ <span class="usx-attribution__primary">John Doe</span>
85
+ <span class="usx-attribution__secondary">Under Secretary for the Department of Magic and Mystical Affairs</span>
86
+ </span>
87
+ </div>
88
+ </figcaption>
89
+ </figure>
114
90
  </div>
115
91
  </div>
92
+ <span class="display-flex flex-align-center margin-top-2">
93
+ <span class="usx-circle bg-black text-white usx-clickable__bg-color-on-hover display-flex flex-align-center flex-justify-center width-4 height-4">
94
+ <svg class="usa-icon usa-icon--size-3" aria-hidden="true" focusable="false" role="img"><use href="./img/sprite.svg#arrow_forward"></use></svg>
95
+ </span>
96
+ <span class="margin-left-1 usx-clickable__link">Read John's Story</span>
97
+ </span>
116
98
  </a>
117
99
 
118
100
  <h2 class="site-preview-heading margin-top-5">Basic Class demonstrations</h2>
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "clickable",
3
3
  "template": "clickable/clickable.django.html",
4
- "version": 1,
4
+ "version": 2,
5
5
  "required": [
6
6
  "href"
7
7
  ],
@@ -19,7 +19,7 @@
19
19
  "description": "Optional id attribute for the anchor element."
20
20
  },
21
21
  "children": {
22
- "type": "string",
22
+ "type": "slot",
23
23
  "description": "Safe inner HTML. Apply usx-clickable__link, usx-clickable__color-on-hover, and/or usx-clickable__bg-color-on-hover to any child elements as needed."
24
24
  }
25
25
  }