@expofp/ui 3.49.0 → 3.49.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.
|
@@ -17,25 +17,26 @@ const processLabel = (label) => {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
const Button = (props) => {
|
|
20
|
-
|
|
20
|
+
// Own props are pulled out of `rest` so they never reach the DOM element.
|
|
21
|
+
const { children, inline = false, text, disabled = false, variant = 'primary', size = 'lg', target = '_self', ariaLabel, title, withBadge = false, round, className, ...rest } = props;
|
|
21
22
|
const content = children ?? text;
|
|
22
23
|
const { content: processedContent } = withBadge && typeof content === 'string' ? processLabel(content) : { content };
|
|
23
24
|
const commonClassNames = cn('efp-button', `efp-button--${variant}`, `efp-button--${size}`, {
|
|
24
25
|
'efp-button--inline': inline,
|
|
25
26
|
'is-disabled': disabled,
|
|
26
27
|
'efp-button--round': round,
|
|
27
|
-
},
|
|
28
|
+
}, className);
|
|
28
29
|
if (isLinkProps(props)) {
|
|
29
|
-
const { link,
|
|
30
|
+
const { link, onClick, ...anchorRest } = rest;
|
|
30
31
|
const onKeyDown = (event) => {
|
|
31
32
|
if (disabled || event.key !== ' ')
|
|
32
33
|
return;
|
|
33
34
|
event.preventDefault();
|
|
34
35
|
event.currentTarget.click();
|
|
35
36
|
};
|
|
36
|
-
return (_jsx("a", { ...
|
|
37
|
+
return (_jsx("a", { ...anchorRest, href: disabled ? undefined : link, className: commonClassNames, target: target, rel: "noopener noreferrer", onClick: disabled ? undefined : onClick, onKeyDown: onKeyDown, "aria-label": ariaLabel || undefined, title: title || ariaLabel || (typeof content === 'string' ? content : undefined), role: "button", "aria-disabled": disabled, tabIndex: disabled ? -1 : 0, children: processedContent }));
|
|
37
38
|
}
|
|
38
|
-
const
|
|
39
|
-
return (_jsx("button", { type: "button", ...
|
|
39
|
+
const buttonRest = rest;
|
|
40
|
+
return (_jsx("button", { type: "button", ...buttonRest, className: commonClassNames, disabled: disabled, "aria-label": ariaLabel || undefined, title: title || ariaLabel || (typeof content === 'string' ? content : undefined), children: processedContent }));
|
|
40
41
|
};
|
|
41
42
|
export default Button;
|