@solexllc/usx-react 0.6.0 → 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.
- package/dist/index.cjs +231 -98
- package/dist/index.js +231 -98
- package/package.json +5 -5
- package/src/components/accordion/accordion.html +596 -291
- package/src/components/alert/alert.html +112 -148
- package/src/components/attribution/attribution.html +50 -21
- package/src/components/avatar/avatar.html +86 -51
- package/src/components/breadcrumb/breadcrumb.html +45 -66
- package/src/components/button/button.html +363 -226
- package/src/components/callout/Callout.tsx +1 -2
- package/src/components/callout/callout.django.html +2 -2
- package/src/components/callout/callout.html +0 -5
- package/src/components/callout/config.json +1 -5
- package/src/components/card/Card.tsx +6 -3
- package/src/components/card/card.django.html +2 -2
- package/src/components/card/card.html +1032 -35
- package/src/components/card/config.json +6 -2
- package/src/components/card-group/card-group.html +388 -95
- package/src/components/carousel/Carousel.tsx +42 -71
- package/src/components/carousel/carousel.django.html +22 -46
- package/src/components/carousel/carousel.html +715 -32
- package/src/components/carousel/config.json +25 -12
- package/src/components/character-count/character-count.html +231 -26
- package/src/components/checkbox/checkbox.html +313 -241
- package/src/components/checkbox-group/checkbox-group.html +346 -26
- package/src/components/clickable/clickable.html +168 -83
- package/src/components/code/Code.tsx +4 -3
- package/src/components/code/code.django.html +1 -1
- package/src/components/code/config.json +4 -0
- package/src/components/collection/collection.html +203 -379
- package/src/components/combobox/combobox.html +21 -9
- package/src/components/container/container.html +2616 -80
- package/src/components/copy-to-clipboard/copy-to-clipboard.html +48 -20
- package/src/components/details/Details.tsx +69 -0
- package/src/components/details/config.json +73 -0
- package/src/components/details/details.django.html +7 -0
- package/src/components/details/details.html +186 -0
- package/src/components/error-message/error-message.html +15 -2
- package/src/components/error-page/ErrorPage.tsx +169 -0
- package/src/components/error-page/config.json +152 -0
- package/src/components/error-page/error-page.django.html +80 -0
- package/src/components/error-page/error-page.html +437 -0
- package/src/components/eyebrow/eyebrow.html +8 -4
- package/src/components/fieldset/fieldset.html +33 -7
- package/src/components/file-input/file-input.html +310 -31
- package/src/components/file-list/file-list.html +191 -7
- package/src/components/footer/footer.html +611 -232
- package/src/components/header/header.html +2553 -611
- package/src/components/hero/hero.html +300 -38
- package/src/components/hint/hint.html +7 -2
- package/src/components/identifier/identifier.html +483 -255
- package/src/components/image/Image.tsx +2 -2
- package/src/components/image/image.django.html +4 -10
- package/src/components/image/image.html +144 -29
- package/src/components/indicator/indicator.html +25 -23
- package/src/components/label/label.html +15 -16
- package/src/components/language-selector/language-selector.html +74 -25
- package/src/components/layout/layout.html +991 -21
- package/src/components/legend/legend.html +10 -9
- package/src/components/list/list.html +45 -25
- package/src/components/page/Page.tsx +15 -2
- package/src/components/page/config.json +13 -1
- package/src/components/page/page.django.html +2 -2
- package/src/components/page/page.html +29 -8
- package/src/components/pagination/pagination.html +907 -305
- package/src/components/prose/prose.html +244 -85
- package/src/components/quote/Quote.tsx +1 -1
- package/src/components/quote/config.json +1 -2
- package/src/components/quote/quote.html +2 -7
- package/src/components/radio-buttons/radio-buttons.html +623 -127
- package/src/components/required/required.html +3 -4
- package/src/components/search/search.html +336 -54
- package/src/components/section/section.html +73 -11
- package/src/components/select/select.html +112 -58
- package/src/components/skipnav/skipnav.html +40 -1
- package/src/components/spinner/spinner.html +143 -23
- package/src/components/step-indicator/step-indicator.html +26 -68
- package/src/components/swap/swap.html +99 -154
- package/src/components/table/table.html +2168 -988
- package/src/components/tag/tag.html +73 -17
- package/src/components/task-list/task-list.html +252 -15
- package/src/components/theme-picker/theme-picker.html +26 -8
- package/src/components/toggle/toggle.html +64 -5
- 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
|
-
|
|
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
|
-
|
|
61
|
-
|
|
29
|
+
statusClassName,
|
|
30
|
+
children,
|
|
31
|
+
className,
|
|
32
|
+
role = 'region',
|
|
62
33
|
...props
|
|
63
34
|
}: CarouselProps) {
|
|
64
|
-
const
|
|
65
|
-
const
|
|
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
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
{
|
|
83
|
-
</
|
|
63
|
+
{item.content}
|
|
64
|
+
</div>
|
|
84
65
|
))
|
|
85
66
|
) : (
|
|
86
|
-
<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
|
-
{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
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 %}
|