@solexllc/usx-react 0.4.0 → 0.6.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 (105) hide show
  1. package/README.md +99 -0
  2. package/dist/index.cjs +576 -442
  3. package/dist/index.js +576 -442
  4. package/package.json +5 -5
  5. package/src/components/attribution/config.json +5 -5
  6. package/src/components/banner/config.json +2 -2
  7. package/src/components/breadcrumb/Breadcrumb.tsx +5 -6
  8. package/src/components/breadcrumb/config.json +11 -1
  9. package/src/components/button/button.html +2 -2
  10. package/src/components/button-group/button-group.django.html +1 -1
  11. package/src/components/calendar-date/calendar-date.django.html +3 -3
  12. package/src/components/callout/Callout.tsx +53 -0
  13. package/src/components/callout/callout.django.html +5 -0
  14. package/src/components/callout/callout.html +76 -0
  15. package/src/components/callout/config.json +74 -0
  16. package/src/components/card/Card.tsx +18 -34
  17. package/src/components/card/card.django.html +12 -10
  18. package/src/components/card/config.json +15 -40
  19. package/src/components/card-group/card-group.django.html +1 -1
  20. package/src/components/carousel/Carousel.tsx +3 -2
  21. package/src/components/carousel/carousel.django.html +13 -2
  22. package/src/components/carousel/config.json +2 -2
  23. package/src/components/character-count/config.json +2 -2
  24. package/src/components/checkbox-group/CheckboxGroup.tsx +10 -20
  25. package/src/components/checkbox-group/checkbox-group.django.html +10 -4
  26. package/src/components/checkbox-group/config.json +10 -5
  27. package/src/components/clickable/clickable.html +21 -39
  28. package/src/components/clickable/config.json +2 -2
  29. package/src/components/collection/Collection.tsx +5 -5
  30. package/src/components/collection/collection.django.html +2 -4
  31. package/src/components/collection/config.json +7 -6
  32. package/src/components/combobox/config.json +4 -4
  33. package/src/components/container/Container.tsx +108 -0
  34. package/src/components/container/_layout-classes.django.html +12 -0
  35. package/src/components/container/config.json +288 -0
  36. package/src/components/container/container.django.html +13 -0
  37. package/src/components/container/container.html +125 -0
  38. package/src/components/date-picker/config.json +4 -4
  39. package/src/components/date-range-picker/config.json +7 -7
  40. package/src/components/error-message/config.json +2 -2
  41. package/src/components/eyebrow/Eyebrow.tsx +2 -1
  42. package/src/components/eyebrow/config.json +2 -2
  43. package/src/components/fieldset/config.json +5 -5
  44. package/src/components/file-input/FileInput.tsx +3 -2
  45. package/src/components/file-input/config.json +5 -5
  46. package/src/components/file-list/FileList.tsx +2 -1
  47. package/src/components/file-list/config.json +2 -2
  48. package/src/components/footer/Footer.tsx +5 -5
  49. package/src/components/form-group/config.json +2 -2
  50. package/src/components/hero/Hero.tsx +8 -14
  51. package/src/components/hero/config.json +36 -27
  52. package/src/components/hero/hero.django.html +2 -2
  53. package/src/components/hint/config.json +2 -2
  54. package/src/components/in-page-nav/config.json +11 -1
  55. package/src/components/indicator/config.json +2 -2
  56. package/src/components/input/config.json +2 -2
  57. package/src/components/label/config.json +2 -2
  58. package/src/components/language-selector/config.json +2 -2
  59. package/src/components/layout/Layout.tsx +1 -1
  60. package/src/components/legend/config.json +3 -3
  61. package/src/components/link/config.json +2 -2
  62. package/src/components/memorable-date/config.json +9 -9
  63. package/src/components/misc-banner/MiscBanner.tsx +2 -1
  64. package/src/components/misc-banner/config.json +2 -2
  65. package/src/components/modal/config.json +2 -2
  66. package/src/components/page/Page.tsx +2 -1
  67. package/src/components/page/config.json +7 -7
  68. package/src/components/page/page.django.html +1 -1
  69. package/src/components/pagination/Pagination.tsx +2 -1
  70. package/src/components/pagination/container/PaginationContainer.tsx +2 -1
  71. package/src/components/prose/config.json +5 -1
  72. package/src/components/quote/Quote.tsx +58 -0
  73. package/src/components/quote/config.json +51 -0
  74. package/src/components/quote/quote.django.html +15 -0
  75. package/src/components/quote/quote.html +66 -0
  76. package/src/components/radio-buttons/config.json +3 -3
  77. package/src/components/range-slider/RangeSlider.tsx +2 -1
  78. package/src/components/range-slider/config.json +4 -4
  79. package/src/components/required/config.json +2 -2
  80. package/src/components/section/Section.tsx +6 -2
  81. package/src/components/section/config.json +19 -6
  82. package/src/components/section/section.django.html +9 -2
  83. package/src/components/select/config.json +2 -2
  84. package/src/components/site-alert/SiteAlert.tsx +5 -6
  85. package/src/components/skipnav/config.json +2 -2
  86. package/src/components/summary-box/config.json +3 -3
  87. package/src/components/swap/Swap.tsx +4 -3
  88. package/src/components/swap/config.json +4 -4
  89. package/src/components/switch/config.json +2 -2
  90. package/src/components/table/config.json +13 -3
  91. package/src/components/tag/config.json +2 -2
  92. package/src/components/tag-group/config.json +2 -2
  93. package/src/components/text-area/config.json +2 -2
  94. package/src/components/time-picker/config.json +4 -4
  95. package/src/components/toggle/Toggle.tsx +69 -40
  96. package/src/components/toggle/config.json +42 -10
  97. package/src/components/toggle/toggle.django.html +25 -17
  98. package/src/components/toggle/toggle.html +319 -85
  99. package/src/components/tooltip/config.json +2 -2
  100. package/src/components/villain/Villain.tsx +2 -1
  101. package/src/index.js +3 -1
  102. package/src/components/block/Block.tsx +0 -78
  103. package/src/components/block/block.django.html +0 -26
  104. package/src/components/block/block.html +0 -162
  105. package/src/components/block/config.json +0 -88
@@ -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 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
  }
@@ -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": {
@@ -0,0 +1,108 @@
1
+ import React from 'react';
2
+ import ClassNames from 'classnames';
3
+ import config from './config.json';
4
+
5
+ type Column = 'auto' | 'fill' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12';
6
+ type Spacing = '0' | '2px' | '05' | '1' | '2' | '3' | '4' | '5' | '6';
7
+
8
+ export interface ContainerLayout {
9
+ display?: 'block' | 'flex' | 'inline' | 'inline-block' | 'inline-flex' | 'none' | 'flow-root';
10
+ direction?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
11
+ wrap?: 'wrap' | 'nowrap' | 'wrap-reverse';
12
+ justify?: 'start' | 'end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
13
+ align?: 'start' | 'end' | 'center' | 'stretch' | 'baseline';
14
+ alignSelf?: 'auto' | 'start' | 'end' | 'center' | 'stretch' | 'baseline';
15
+ flex?: 'auto' | 'fill' | 'none';
16
+ gap?: Spacing;
17
+ column?: Column;
18
+ offset?: 'none' | Exclude<Column, 'auto' | 'fill'>;
19
+ gutters?: 'sm' | 'md' | 'lg' | Spacing;
20
+ float?: 'none' | 'left' | 'right';
21
+ }
22
+
23
+ export interface ContainerProps extends ContainerLayout {
24
+ element?: 'div' | 'section' | 'article' | 'aside' | 'nav' | 'ul' | 'ol' | 'li';
25
+ gridContainer?: 'default' | 'card' | 'card-lg' | 'mobile' | 'mobile-lg' | 'tablet' | 'tablet-lg' | 'desktop' | 'desktop-lg' | 'widescreen';
26
+ gridRow?: boolean;
27
+ responsive?: Partial<Record<'mobileLg' | 'tablet' | 'desktop', ContainerLayout>>;
28
+ children?: React.ReactNode;
29
+ content?: React.ReactNode;
30
+ className?: string;
31
+ id?: string;
32
+ role?: string;
33
+ ariaLabel?: string;
34
+ ariaLabelledby?: string;
35
+ }
36
+
37
+ const breakpoints = [['mobileLg', 'mobile-lg'], ['tablet', 'tablet'], ['desktop', 'desktop']] as const;
38
+ const layoutKeys = [
39
+ 'display', 'direction', 'wrap', 'justify', 'align', 'alignSelf',
40
+ 'flex', 'gap', 'column', 'offset', 'gutters', 'float',
41
+ ] as const;
42
+
43
+ function layoutClasses(layout: ContainerLayout, prefix = ''): string[] {
44
+ if (!layout || typeof layout !== 'object' || Array.isArray(layout)) return [];
45
+
46
+ return layoutKeys.flatMap((key) => {
47
+ const value = layout[key];
48
+ // CMS payloads may bypass TypeScript. Only emit supported utility tokens.
49
+ if (typeof value !== 'string' || !config.props[key].options.includes(value)) return [];
50
+ let className: string;
51
+ if (key === 'column') className = `grid-col-${value}`;
52
+ else if (key === 'offset') className = `grid-offset-${value}`;
53
+ else if (key === 'gutters') className = `grid-gap-${value}`;
54
+ else className = `usx-container--${key === 'alignSelf' ? 'align-self' : key}-${value}`;
55
+ return [`${prefix}${className}`];
56
+ });
57
+ }
58
+
59
+ /** An unstyled grouping element with opt-in, mobile-first layout controls. */
60
+ export default function Container({
61
+ element = 'div',
62
+ gridContainer,
63
+ gridRow = false,
64
+ display,
65
+ direction,
66
+ wrap,
67
+ justify,
68
+ align,
69
+ alignSelf,
70
+ flex,
71
+ gap,
72
+ column,
73
+ offset,
74
+ gutters,
75
+ float,
76
+ responsive,
77
+ children,
78
+ content,
79
+ className = '',
80
+ id,
81
+ role,
82
+ ariaLabel,
83
+ ariaLabelledby,
84
+ }: ContainerProps) {
85
+ const Element = config.props.element.options.includes(element) ? element : 'div';
86
+ const classes = ClassNames(
87
+ 'usx-container',
88
+ gridContainer && config.props.gridContainer.options.includes(gridContainer)
89
+ ? gridContainer === 'default' ? 'grid-container' : `grid-container-${gridContainer}`
90
+ : null,
91
+ { 'grid-row': gridRow === true },
92
+ layoutClasses({ display, direction, wrap, justify, align, alignSelf, flex, gap, column, offset, gutters, float }),
93
+ breakpoints.map(([key, prefix]) => layoutClasses(responsive?.[key] ?? {}, `${prefix}:`)),
94
+ typeof className === 'string' ? className : undefined,
95
+ );
96
+
97
+ return (
98
+ <Element
99
+ className={classes}
100
+ id={typeof id === 'string' ? id : undefined}
101
+ role={typeof role === 'string' ? role : undefined}
102
+ aria-label={typeof ariaLabel === 'string' ? ariaLabel : undefined}
103
+ aria-labelledby={typeof ariaLabelledby === 'string' ? ariaLabelledby : undefined}
104
+ >
105
+ {children ?? content}
106
+ </Element>
107
+ );
108
+ }
@@ -0,0 +1,12 @@
1
+ {% if layout.display == 'block' or layout.display == 'flex' or layout.display == 'inline' or layout.display == 'inline-block' or layout.display == 'inline-flex' or layout.display == 'none' or layout.display == 'flow-root' %} {{ prefix }}usx-container--display-{{ layout.display }}{% endif %}
2
+ {% if layout.direction == 'row' or layout.direction == 'column' or layout.direction == 'row-reverse' or layout.direction == 'column-reverse' %} {{ prefix }}usx-container--direction-{{ layout.direction }}{% endif %}
3
+ {% if layout.wrap == 'wrap' or layout.wrap == 'nowrap' or layout.wrap == 'wrap-reverse' %} {{ prefix }}usx-container--wrap-{{ layout.wrap }}{% endif %}
4
+ {% if layout.justify == 'start' or layout.justify == 'end' or layout.justify == 'center' or layout.justify == 'space-between' or layout.justify == 'space-around' or layout.justify == 'space-evenly' %} {{ prefix }}usx-container--justify-{{ layout.justify }}{% endif %}
5
+ {% if layout.align == 'start' or layout.align == 'end' or layout.align == 'center' or layout.align == 'stretch' or layout.align == 'baseline' %} {{ prefix }}usx-container--align-{{ layout.align }}{% endif %}
6
+ {% if layout.alignSelf == 'auto' or layout.alignSelf == 'start' or layout.alignSelf == 'end' or layout.alignSelf == 'center' or layout.alignSelf == 'stretch' or layout.alignSelf == 'baseline' %} {{ prefix }}usx-container--align-self-{{ layout.alignSelf }}{% endif %}
7
+ {% if layout.flex == 'auto' or layout.flex == 'fill' or layout.flex == 'none' %} {{ prefix }}usx-container--flex-{{ layout.flex }}{% endif %}
8
+ {% if layout.gap == '0' or layout.gap == '2px' or layout.gap == '05' or layout.gap == '1' or layout.gap == '2' or layout.gap == '3' or layout.gap == '4' or layout.gap == '5' or layout.gap == '6' %} {{ prefix }}usx-container--gap-{{ layout.gap }}{% endif %}
9
+ {% if layout.column == 'auto' or layout.column == 'fill' or layout.column == '1' or layout.column == '2' or layout.column == '3' or layout.column == '4' or layout.column == '5' or layout.column == '6' or layout.column == '7' or layout.column == '8' or layout.column == '9' or layout.column == '10' or layout.column == '11' or layout.column == '12' %} {{ prefix }}grid-col-{{ layout.column }}{% endif %}
10
+ {% if layout.offset == 'none' or layout.offset == '1' or layout.offset == '2' or layout.offset == '3' or layout.offset == '4' or layout.offset == '5' or layout.offset == '6' or layout.offset == '7' or layout.offset == '8' or layout.offset == '9' or layout.offset == '10' or layout.offset == '11' or layout.offset == '12' %} {{ prefix }}grid-offset-{{ layout.offset }}{% endif %}
11
+ {% if layout.gutters == 'sm' or layout.gutters == 'md' or layout.gutters == 'lg' or layout.gutters == '0' or layout.gutters == '2px' or layout.gutters == '05' or layout.gutters == '1' or layout.gutters == '2' or layout.gutters == '3' or layout.gutters == '4' or layout.gutters == '5' or layout.gutters == '6' %} {{ prefix }}grid-gap-{{ layout.gutters }}{% endif %}
12
+ {% if layout.float == 'none' or layout.float == 'left' or layout.float == 'right' %} {{ prefix }}usx-container--float-{{ layout.float }}{% endif %}