@sonic-equipment/ui 2.0.0 → 2.0.1
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MouseEvent, ReactNode } from 'react';
|
|
1
|
+
import { HTMLAttributeAnchorTarget, HTMLAttributeReferrerPolicy, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import { NavigateOptions } from '../../shared/routing/types';
|
|
3
|
-
|
|
3
|
+
interface BaseButtonProps {
|
|
4
4
|
_pseudo?: 'none' | 'focus' | 'hover' | 'active';
|
|
5
5
|
'aria-label'?: string;
|
|
6
6
|
children?: ReactNode;
|
|
@@ -8,28 +8,41 @@ export interface ButtonProps {
|
|
|
8
8
|
color?: 'primary' | 'secondary';
|
|
9
9
|
condensed?: boolean;
|
|
10
10
|
'data-test-selector'?: string;
|
|
11
|
-
download?: string;
|
|
12
|
-
form?: string;
|
|
13
|
-
href?: string;
|
|
14
11
|
icon?: React.ReactNode;
|
|
15
12
|
iconPosition?: 'left' | 'right';
|
|
16
13
|
isDisabled?: boolean;
|
|
17
14
|
isLoading?: string | ReactNode | boolean;
|
|
18
|
-
isValidating?: boolean;
|
|
19
15
|
light?: boolean;
|
|
20
|
-
name?: string;
|
|
21
16
|
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
22
|
-
placebo?: boolean;
|
|
23
|
-
route?: NavigateOptions;
|
|
24
17
|
size?: 'sm' | 'md' | 'lg';
|
|
25
|
-
type?: 'button' | 'submit' | 'reset';
|
|
26
|
-
value?: string;
|
|
27
18
|
variant?: 'solid' | 'outline' | 'ghost';
|
|
28
19
|
withArrow?: boolean;
|
|
29
20
|
}
|
|
21
|
+
/** Renders a `<button>` (or a `<span>` when `placebo`). */
|
|
22
|
+
export interface NativeButtonProps extends BaseButtonProps {
|
|
23
|
+
form?: string;
|
|
24
|
+
href?: never;
|
|
25
|
+
isValidating?: boolean;
|
|
26
|
+
name?: string;
|
|
27
|
+
placebo?: boolean;
|
|
28
|
+
type?: 'button' | 'submit' | 'reset';
|
|
29
|
+
value?: string;
|
|
30
|
+
}
|
|
31
|
+
/** Renders an anchor; picked whenever `href` is set. */
|
|
32
|
+
export interface LinkLikeButtonProps extends BaseButtonProps {
|
|
33
|
+
download?: string;
|
|
34
|
+
href: string;
|
|
35
|
+
hrefLang?: string;
|
|
36
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy;
|
|
37
|
+
rel?: string;
|
|
38
|
+
route?: NavigateOptions;
|
|
39
|
+
target?: HTMLAttributeAnchorTarget;
|
|
40
|
+
}
|
|
41
|
+
export type ButtonProps = NativeButtonProps | LinkLikeButtonProps;
|
|
30
42
|
export declare const Button: {
|
|
31
|
-
(
|
|
43
|
+
(props: ButtonProps & {
|
|
32
44
|
ref?: React.RefObject<HTMLButtonElement | null>;
|
|
33
45
|
}): import("react/jsx-runtime").JSX.Element;
|
|
34
46
|
displayName: string;
|
|
35
47
|
};
|
|
48
|
+
export {};
|
|
@@ -7,16 +7,12 @@ import { ProgressCircle } from '../../loading/progress-circle.js';
|
|
|
7
7
|
import { useRouteLink } from '../../shared/routing/use-route-link.js';
|
|
8
8
|
import buttonStyles from './button.module.css.js';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
function isLinkLike(props) {
|
|
11
|
+
return props.href !== undefined;
|
|
12
|
+
}
|
|
13
|
+
const Button = (props) => {
|
|
14
|
+
const { _pseudo = 'none', 'aria-label': ariaLabel, children: _children, className, color = 'primary', condensed, 'data-test-selector': dataTestSelector, icon, iconPosition = 'left', isDisabled, isLoading = false, light = false, onClick, size = 'lg', variant = 'solid', withArrow = false, } = props;
|
|
11
15
|
const { getRouteLinkProps, RouteLinkElement } = useRouteLink();
|
|
12
|
-
const handleButtonClick = (e) => {
|
|
13
|
-
if (onClick)
|
|
14
|
-
onClick(e);
|
|
15
|
-
e.stopPropagation();
|
|
16
|
-
if (type === 'submit')
|
|
17
|
-
return;
|
|
18
|
-
e.preventDefault();
|
|
19
|
-
};
|
|
20
16
|
const classNames = clsx({ [buttonStyles.condensed]: condensed }, { [buttonStyles.icon]: icon }, { [buttonStyles['loading-uninformative']]: isLoading === true }, {
|
|
21
17
|
[buttonStyles['loading-informative']]: isLoading &&
|
|
22
18
|
(typeof isLoading === 'string' || isValidElement(isLoading)),
|
|
@@ -25,18 +21,44 @@ const Button = ({ _pseudo = 'none', 'aria-label': ariaLabel, children: _children
|
|
|
25
21
|
const showIconOnRight = icon && iconPosition === 'right';
|
|
26
22
|
const iconElement = icon && jsx("span", { className: buttonStyles.icon, children: icon });
|
|
27
23
|
const children = (jsxs(Fragment, { children: [showIconOnLeft && iconElement, jsx("span", { className: buttonStyles.children, children: isLoading ? (isLoading === true ? _children : isLoading) : _children }), withArrow && (jsx(Icon, { className: buttonStyles['right-arrow-icon'], name: "ArrowRightThick" })), showIconOnRight && iconElement, isLoading && (jsx(ProgressCircle, { className: buttonStyles.spinner, size: "sm", variant: color === 'primary' ? 'white' : 'gray' }))] }));
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
if (isLinkLike(props)) {
|
|
25
|
+
const { download, href, hrefLang, referrerPolicy, rel, route, target } = props;
|
|
26
|
+
const anchorProps = {
|
|
27
|
+
'aria-label': ariaLabel,
|
|
28
|
+
className: classNames,
|
|
29
|
+
'data-disabled': isDisabled ? true : undefined,
|
|
30
|
+
'data-test-selector': dataTestSelector,
|
|
31
|
+
hrefLang,
|
|
32
|
+
onClick,
|
|
33
|
+
referrerPolicy,
|
|
34
|
+
rel,
|
|
35
|
+
target,
|
|
36
|
+
};
|
|
37
|
+
if (download !== undefined) {
|
|
38
|
+
// File downloads must be a native link: the route link element
|
|
39
|
+
// prevents the default click and navigates client-side (and prefixes the
|
|
40
|
+
// locale), which would break the download.
|
|
41
|
+
return (jsx("a", { ...anchorProps, download: download, href: href, children: children }));
|
|
42
|
+
}
|
|
43
|
+
if (target && target !== '_self') {
|
|
44
|
+
// The fallback route link navigates in the current tab, ignoring
|
|
45
|
+
// `target`, so other targets get a native link with the locale prefix.
|
|
46
|
+
return (jsx("a", { ...anchorProps, href: getRouteLinkProps(href, route).href, children: children }));
|
|
47
|
+
}
|
|
48
|
+
return (jsx(RouteLinkElement, { ...anchorProps, ...getRouteLinkProps(href, route), children: children }));
|
|
36
49
|
}
|
|
50
|
+
const { form, isValidating = true, name, placebo = false, ref, type = 'button', value, } = props;
|
|
37
51
|
if (placebo) {
|
|
38
52
|
return (jsx("span", { ref: ref, "aria-label": ariaLabel, className: classNames, "data-disabled": isDisabled ? true : undefined, children: children }));
|
|
39
53
|
}
|
|
54
|
+
const handleButtonClick = (e) => {
|
|
55
|
+
if (onClick)
|
|
56
|
+
onClick(e);
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
if (type === 'submit')
|
|
59
|
+
return;
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
};
|
|
40
62
|
return (jsx("button", { ref: ref, "aria-label": ariaLabel, className: classNames, "data-disabled": isDisabled ? true : undefined, "data-test-selector": dataTestSelector, disabled: isDisabled, form: form, formNoValidate: isValidating ? undefined : true, name: name, onClick: handleButtonClick, type: type, value: value, children: children }));
|
|
41
63
|
};
|
|
42
64
|
Button.displayName = 'Button';
|
|
@@ -94,24 +94,40 @@ function ResponsiveImage({ altText, ariaDetails, autoCrop = true, className, 'da
|
|
|
94
94
|
return { height: h, width: maxWidth };
|
|
95
95
|
return { height: h, width: w };
|
|
96
96
|
};
|
|
97
|
+
const currentSrc = sources ? sources.src : src;
|
|
98
|
+
const currentSrcSet = sources ? sources.srcSet : undefined;
|
|
99
|
+
// Re-run when the resolved URL changes (CDN profile resolving, auto-crop
|
|
100
|
+
// swapping the srcset), so a new rendition gets its own loading/error state.
|
|
97
101
|
useEffect(() => {
|
|
98
102
|
const img = imageRef.current;
|
|
99
103
|
if (!img)
|
|
100
104
|
return;
|
|
105
|
+
setIsError(!currentSrc);
|
|
106
|
+
setIsLoading(true);
|
|
107
|
+
// Always listen: the browser can refetch on its own (`sizes="auto"` picks
|
|
108
|
+
// a rendition after layout), which no prop change signals.
|
|
109
|
+
const handleLoad = () => {
|
|
110
|
+
setIsError(false);
|
|
111
|
+
readyFn();
|
|
112
|
+
};
|
|
113
|
+
img.addEventListener('load', handleLoad);
|
|
114
|
+
img.addEventListener('error', errorFn);
|
|
115
|
+
// Already settled before this effect ran (cached, or loaded pre-hydration).
|
|
101
116
|
if (img.complete) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
img.removeEventListener('load', readyFn);
|
|
109
|
-
img.removeEventListener('error', errorFn);
|
|
110
|
-
};
|
|
117
|
+
// SVGs without intrinsic size report naturalWidth 0 in WebKit/Firefox.
|
|
118
|
+
const isSvg = /\.svg(?:[#?]|$)/i.test(img.currentSrc || img.src);
|
|
119
|
+
if (img.naturalWidth > 0 || (isSvg && !!currentSrc))
|
|
120
|
+
readyFn();
|
|
121
|
+
else
|
|
122
|
+
errorFn();
|
|
111
123
|
}
|
|
124
|
+
return () => {
|
|
125
|
+
img.removeEventListener('load', handleLoad);
|
|
126
|
+
img.removeEventListener('error', errorFn);
|
|
127
|
+
};
|
|
112
128
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
|
-
}, []);
|
|
114
|
-
return (jsxs("picture", { ref: pictureRef, className: clsx(styles['responsive-image'], styles[`fit-${fit}`], styles[`loading-effect-${loadingEffect}`], isError && styles['is-error'], isLoading && styles['is-loading'], className), children: [jsx("img", { ref: imageRef, alt: altText || '', "aria-details": ariaDetails, className: styles['image'], "data-auto-crop": measuresBox ? (autoCropRatio?.toFixed(3) ?? 'none') : undefined, "data-test-selector": dataTestSelector, fetchPriority, height: dimensions().height, loading: loading, role: altText && altText !== '' ? undefined : 'presentation', sizes: sources && (loading === 'lazy' ? `auto, ${sizes}` : sizes), src:
|
|
129
|
+
}, [currentSrc, currentSrcSet]);
|
|
130
|
+
return (jsxs("picture", { ref: pictureRef, className: clsx(styles['responsive-image'], styles[`fit-${fit}`], styles[`loading-effect-${loadingEffect}`], isError && styles['is-error'], isLoading && styles['is-loading'], className), children: [jsx("img", { ref: imageRef, alt: altText || '', "aria-details": ariaDetails, className: styles['image'], "data-auto-crop": measuresBox ? (autoCropRatio?.toFixed(3) ?? 'none') : undefined, "data-test-selector": dataTestSelector, fetchPriority, height: dimensions().height, loading: loading, role: altText && altText !== '' ? undefined : 'presentation', sizes: sources && (loading === 'lazy' ? `auto, ${sizes}` : sizes), src: currentSrc, srcSet: currentSrcSet, style: focusPoint && {
|
|
115
131
|
objectPosition: `${focusPoint.x * 100}% ${focusPoint.y * 100}%`,
|
|
116
132
|
}, title: altText ? '' : undefined, width: dimensions().width }), isError && (jsx(StrokeFallbackIcon, { className: styles['icon-missing'], role: "presentation" }))] }));
|
|
117
133
|
}
|
|
@@ -87,7 +87,9 @@ function ResponsiveVideo({ ariaDescription, autoplay, captions, chapters, classN
|
|
|
87
87
|
if (!videoRef.current)
|
|
88
88
|
return;
|
|
89
89
|
if (typeof HTMLMediaElement !== 'undefined' &&
|
|
90
|
-
|
|
90
|
+
// loadedmetadata (HAVE_METADATA) may have fired before hydration; Safari
|
|
91
|
+
// often stays at that state without reaching HAVE_CURRENT_DATA.
|
|
92
|
+
videoRef.current.readyState >= HTMLMediaElement.HAVE_METADATA)
|
|
91
93
|
readyFn();
|
|
92
94
|
supportFullscreenControl = document?.fullscreenEnabled;
|
|
93
95
|
const textTracks = videoRef.current.textTracks;
|
package/dist/styles.css
CHANGED
|
@@ -3931,7 +3931,6 @@
|
|
|
3931
3931
|
var(--color-brand-medium-gray) 50%,
|
|
3932
3932
|
transparent
|
|
3933
3933
|
);
|
|
3934
|
-
content: '';
|
|
3935
3934
|
transition: opacity var(--transition-duration-short);
|
|
3936
3935
|
}
|
|
3937
3936
|
|
|
@@ -3942,6 +3941,7 @@
|
|
|
3942
3941
|
--sep-deg: 90deg;
|
|
3943
3942
|
|
|
3944
3943
|
block-size: var(--sep-hor-thickness);
|
|
3944
|
+
content: '';
|
|
3945
3945
|
inset-block-start: calc(100% + var(--row-gap) / 2);
|
|
3946
3946
|
inset-inline: 0;
|
|
3947
3947
|
}
|
|
@@ -3954,6 +3954,7 @@
|
|
|
3954
3954
|
);
|
|
3955
3955
|
--sep-deg: 180deg;
|
|
3956
3956
|
|
|
3957
|
+
content: '';
|
|
3957
3958
|
inline-size: var(--sep-ver-thickness);
|
|
3958
3959
|
inset-block: 0;
|
|
3959
3960
|
inset-inline-start: calc(100% + var(--column-gap) / 2);
|
|
@@ -15796,7 +15797,7 @@
|
|
|
15796
15797
|
--item-body-fs-min: var(--font-size-16);
|
|
15797
15798
|
--item-body-fs-max: var(--font-size-20);
|
|
15798
15799
|
--nr-of-columns: 1;
|
|
15799
|
-
--item-min-height: 16rem; /*
|
|
15800
|
+
--item-min-height: 16rem; /* 256px */
|
|
15800
15801
|
--item-max-height: 50.625rem; /* 810px */
|
|
15801
15802
|
|
|
15802
15803
|
box-sizing: border-box;
|
|
@@ -16181,11 +16182,10 @@
|
|
|
16181
16182
|
}
|
|
16182
16183
|
|
|
16183
16184
|
.multi-column-section-module-tbbQL .multi-column-section-module-8OrAG {
|
|
16184
|
-
|
|
16185
|
+
overflow: hidden;
|
|
16185
16186
|
background-color: var(--color-brand-light-gray);
|
|
16186
16187
|
grid-row: image;
|
|
16187
16188
|
margin-block-end: var(--item-image-margin);
|
|
16188
|
-
place-items: stretch;
|
|
16189
16189
|
}
|
|
16190
16190
|
|
|
16191
16191
|
.multi-column-section-module-tbbQL:has(img) .multi-column-section-module-8OrAG {
|