@solexllc/usx-react 0.6.1 → 0.7.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 (84) hide show
  1. package/dist/index.cjs +231 -98
  2. package/dist/index.js +231 -98
  3. package/package.json +5 -5
  4. package/src/components/accordion/accordion.html +596 -291
  5. package/src/components/alert/alert.html +112 -148
  6. package/src/components/attribution/attribution.html +50 -21
  7. package/src/components/avatar/avatar.html +86 -51
  8. package/src/components/breadcrumb/breadcrumb.html +45 -66
  9. package/src/components/button/button.html +363 -226
  10. package/src/components/callout/Callout.tsx +1 -2
  11. package/src/components/callout/callout.django.html +2 -2
  12. package/src/components/callout/callout.html +0 -5
  13. package/src/components/callout/config.json +1 -5
  14. package/src/components/card/Card.tsx +6 -3
  15. package/src/components/card/card.django.html +2 -2
  16. package/src/components/card/card.html +1032 -35
  17. package/src/components/card/config.json +6 -2
  18. package/src/components/card-group/card-group.html +388 -95
  19. package/src/components/carousel/Carousel.tsx +42 -71
  20. package/src/components/carousel/carousel.django.html +22 -46
  21. package/src/components/carousel/carousel.html +715 -32
  22. package/src/components/carousel/config.json +25 -12
  23. package/src/components/character-count/character-count.html +231 -26
  24. package/src/components/checkbox/checkbox.html +313 -241
  25. package/src/components/checkbox-group/checkbox-group.html +346 -26
  26. package/src/components/clickable/clickable.html +168 -83
  27. package/src/components/code/Code.tsx +4 -3
  28. package/src/components/code/code.django.html +1 -1
  29. package/src/components/code/config.json +4 -0
  30. package/src/components/collection/collection.html +203 -379
  31. package/src/components/combobox/combobox.html +21 -9
  32. package/src/components/container/container.html +2616 -80
  33. package/src/components/copy-to-clipboard/copy-to-clipboard.html +48 -20
  34. package/src/components/details/Details.tsx +69 -0
  35. package/src/components/details/config.json +73 -0
  36. package/src/components/details/details.django.html +7 -0
  37. package/src/components/details/details.html +186 -0
  38. package/src/components/error-message/error-message.html +15 -2
  39. package/src/components/error-page/ErrorPage.tsx +169 -0
  40. package/src/components/error-page/config.json +152 -0
  41. package/src/components/error-page/error-page.django.html +80 -0
  42. package/src/components/error-page/error-page.html +437 -0
  43. package/src/components/eyebrow/eyebrow.html +8 -4
  44. package/src/components/fieldset/fieldset.html +33 -7
  45. package/src/components/file-input/file-input.html +310 -31
  46. package/src/components/file-list/file-list.html +191 -7
  47. package/src/components/footer/footer.html +611 -232
  48. package/src/components/header/header.html +2553 -611
  49. package/src/components/hero/hero.html +300 -38
  50. package/src/components/hint/hint.html +7 -2
  51. package/src/components/identifier/identifier.html +483 -255
  52. package/src/components/image/Image.tsx +2 -2
  53. package/src/components/image/image.django.html +4 -10
  54. package/src/components/image/image.html +144 -29
  55. package/src/components/indicator/indicator.html +25 -23
  56. package/src/components/label/label.html +15 -16
  57. package/src/components/language-selector/language-selector.html +74 -25
  58. package/src/components/layout/layout.html +991 -21
  59. package/src/components/legend/legend.html +10 -9
  60. package/src/components/list/list.html +45 -25
  61. package/src/components/page/Page.tsx +15 -2
  62. package/src/components/page/config.json +13 -1
  63. package/src/components/page/page.django.html +2 -2
  64. package/src/components/page/page.html +29 -8
  65. package/src/components/pagination/pagination.html +907 -305
  66. package/src/components/prose/prose.html +244 -85
  67. package/src/components/quote/Quote.tsx +1 -1
  68. package/src/components/quote/config.json +1 -2
  69. package/src/components/quote/quote.html +2 -7
  70. package/src/components/radio-buttons/radio-buttons.html +623 -127
  71. package/src/components/required/required.html +3 -4
  72. package/src/components/search/search.html +336 -54
  73. package/src/components/section/section.html +73 -11
  74. package/src/components/select/select.html +112 -58
  75. package/src/components/skipnav/skipnav.html +40 -1
  76. package/src/components/spinner/spinner.html +143 -23
  77. package/src/components/step-indicator/step-indicator.html +26 -68
  78. package/src/components/swap/swap.html +99 -154
  79. package/src/components/table/table.html +2168 -988
  80. package/src/components/tag/tag.html +73 -17
  81. package/src/components/task-list/task-list.html +252 -15
  82. package/src/components/theme-picker/theme-picker.html +26 -8
  83. package/src/components/toggle/toggle.html +64 -5
  84. package/src/index.js +2 -0
@@ -1,102 +1,73 @@
1
1
  import React from 'react';
2
2
  import ClassNames from 'classnames';
3
3
 
4
- export interface SlideProps extends React.HTMLAttributes<HTMLElement> {
5
- id?: string;
6
- className?: string;
7
- role?: string;
8
- ariaRoledescription?: string;
9
- ariaLabel?: string;
10
- tabIndex?: number;
11
- children?: React.ReactNode;
12
- }
13
-
14
- export function Slide({
15
- id,
16
- className = '',
17
- role = 'group',
18
- ariaRoledescription = 'slide',
19
- ariaLabel,
20
- tabIndex = 0,
21
- children = null,
22
- ...rest
23
- }: SlideProps) {
24
- const cls = ClassNames('usx-carousel__slide', className);
25
- return (
26
- <section
27
- id={id}
28
- className={cls}
29
- role={role}
30
- aria-roledescription={ariaRoledescription}
31
- aria-label={ariaLabel}
32
- tabIndex={tabIndex}
33
- {...rest}
34
- >
35
- {children}
36
- </section>
37
- );
38
- }
39
-
40
4
  export interface CarouselSlide {
41
5
  content: React.ReactNode;
6
+ label?: string;
42
7
  }
43
8
 
44
9
  export interface CarouselProps extends React.HTMLAttributes<HTMLDivElement> {
45
- id?: string;
46
10
  slides?: CarouselSlide[];
47
11
  ariaLabel?: string;
48
- className?: string;
49
12
  showDots?: boolean;
13
+ statusClassName?: string;
50
14
  children?: React.ReactNode;
51
- slideIds?: string[];
15
+ }
16
+
17
+ function flattenChildren(children: React.ReactNode): React.ReactNode[] {
18
+ return React.Children.toArray(children).flatMap((child) =>
19
+ React.isValidElement<{ children?: React.ReactNode }>(child) && child.type === React.Fragment
20
+ ? flattenChildren(child.props.children)
21
+ : [child]
22
+ );
52
23
  }
53
24
 
54
25
  export default function Carousel({
55
- id = 'carousel-1',
56
26
  slides = [],
57
27
  ariaLabel = 'Featured content',
58
- className = '',
59
28
  showDots = true,
60
- children = null,
61
- slideIds = [],
29
+ statusClassName,
30
+ children,
31
+ className,
32
+ role = 'region',
62
33
  ...props
63
34
  }: CarouselProps) {
64
- const classes = ClassNames('usx-carousel', className);
65
- const childArray = React.Children.toArray(children).filter(Boolean);
35
+ const childSlides = flattenChildren(children);
36
+ const items: CarouselSlide[] = childSlides.length
37
+ ? childSlides.map((content) => ({ content }))
38
+ : slides;
39
+ const count = items.length;
66
40
 
67
41
  return (
68
- <div className={classes} {...props} role="region" aria-roledescription="carousel" aria-label={ariaLabel}>
69
- <div className="usx-carousel__viewport" tabIndex={-1}>
70
- <div className="usx-carousel__track">
71
- {childArray.length > 0 ? (
72
- childArray
73
- ) : slides.length > 0 ? (
74
- slides.map((slide, i) => (
75
- <Slide
76
- id={`${id}-slide-${i + 1}`}
77
- key={i}
78
- className=""
79
- ariaLabel={`${i + 1} of ${slides.length}`}
80
- tabIndex={0}
42
+ <div
43
+ key={`${count}-${showDots}-${statusClassName ?? ''}`}
44
+ {...props}
45
+ className={ClassNames('usx-carousel', className)}
46
+ role={role}
47
+ aria-roledescription="carousel"
48
+ aria-label={ariaLabel}
49
+ data-show-dots={showDots ? undefined : 'false'}
50
+ data-status-class-name={statusClassName}
51
+ >
52
+ <div className="usx-carousel__viewport">
53
+ <div className="usx-carousel__track" aria-live="polite" tabIndex={count > 1 ? 0 : undefined}>
54
+ {count ? (
55
+ items.map((item, index) => (
56
+ <div
57
+ key={index}
58
+ className="usx-carousel__slide"
59
+ role="group"
60
+ aria-roledescription="slide"
61
+ aria-label={item.label || `${index + 1} of ${count}`}
81
62
  >
82
- {slide?.content || slide}
83
- </Slide>
63
+ {item.content}
64
+ </div>
84
65
  ))
85
66
  ) : (
86
- <p><em>No slides available.</em></p>
67
+ <p>No slides available.</p>
87
68
  )}
88
69
  </div>
89
70
  </div>
90
- {showDots && (
91
- <div className="usx-carousel__dots" aria-label="Slide navigation">
92
- {(childArray.length > 0 ? childArray : slides)?.map((_, i) => (
93
- <a key={i} href={`#${id}-slide-${i + 1}`} aria-label={`Go to slide ${i + 1}`} tabIndex={-1} />
94
- ))}
95
- {childArray.length > 0 && slideIds.length === childArray.length && slideIds.map((slideId, i) => (
96
- <a key={i} href={slideId} aria-label={`Go to slide ${i + 1}`} tabIndex={-1} />
97
- ))}
98
- </div>
99
- )}
100
71
  </div>
101
72
  );
102
73
  }
@@ -1,52 +1,28 @@
1
1
  {% load components %}
2
-
3
- {# Django template for Carousel #}
4
- <div class="usx-carousel {{ className|default:'' }}" role="region" aria-roledescription="carousel" aria-label="{{ ariaLabel|default:'Featured content' }}">
5
- <div class="usx-carousel__viewport" tabindex="-1">
6
- <div class="usx-carousel__track">
7
- {% if children %}
8
- {% if children.length > 0 %}
9
- {% for child in children %}
10
- {{ child|safe }}
11
- {% endfor %}
12
- {% else %}
13
- {{ children|safe }}
14
- {% endif %}
15
- {% elif slides %}
16
- {% for slide in slides %}
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">
18
- {% if slide.content %}
19
- {{ slide.content|safe }}
20
- {% elif slide.src %}
21
- {% image props=slide hideCaption=slide.hideCaption|default_bool:True %}{{ slide.children|safe }}{% endimage %}
22
- {% else %}
23
- {# Fallback: render the slide object/string directly #}
24
- {{ slide|safe }}
25
- {% endif %}
26
- </section>
27
- {% endfor %}
2
+ {% with childSlides=children|as_list %}
3
+ {% with fallback=slides|default:'' %}
4
+ {% with items=childSlides|default:fallback %}
5
+ <div{% if id %} id="{{ id }}"{% endif %} class="usx-carousel{% if className %} {{ className }}{% endif %}" role="{{ role|default:'region' }}" aria-roledescription="carousel" aria-label="{{ ariaLabel|default:'Featured content' }}"{% if not showDots|default_bool:True %} data-show-dots="false"{% endif %}{% if statusClassName %} data-status-class-name="{{ statusClassName }}"{% endif %}>
6
+ <div class="usx-carousel__viewport">
7
+ <div class="usx-carousel__track" aria-live="polite"{% if items|length > 1 %} tabindex="0"{% endif %}>
8
+ {% if items %}
9
+ {% for item in items %}
10
+ <div class="usx-carousel__slide" role="group" aria-roledescription="slide" aria-label="{% if childSlides %}{{ forloop.counter }} of {{ items|length }}{% else %}{{ item.label|default:forloop.counter }}{% if not item.label %} of {{ items|length }}{% endif %}{% endif %}">
11
+ {% if childSlides %}
12
+ {{ item|safe }}
13
+ {% elif item.content %}
14
+ {{ item.content|safe }}
15
+ {% elif item.src %}
16
+ {% image props=item hideCaption=item.hideCaption|default_bool:True %}{{ item.children|safe }}{% endimage %}
17
+ {% endif %}
18
+ </div>
19
+ {% endfor %}
28
20
  {% else %}
29
- <p><em>No slides available.</em></p>
21
+ <p>No slides available.</p>
30
22
  {% endif %}
31
23
  </div>
32
24
  </div>
33
-
34
- {% if showDots %}
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 %}
41
- {% if slides %}
42
- {% for slide in slides %}
43
- <a href="#{{ id }}-slide-{{ forloop.counter }}" aria-label="Go to slide {{ forloop.counter }}" tabindex="-1"></a>
44
- {% endfor %}
45
- {% elif slideIds %}
46
- {% for slideId in slideIds %}
47
- <a href="{{ slideId }}" aria-label="Go to slide {{ forloop.counter }}" tabindex="-1"></a>
48
- {% endfor %}
49
- {% endif %}
50
- </div>
51
- {% endif %}
52
25
  </div>
26
+ {% endwith %}
27
+ {% endwith %}
28
+ {% endwith %}