@homebound/beam 2.102.8 → 2.102.9
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.
|
@@ -6,7 +6,7 @@ export interface ButtonProps extends BeamButtonProps, BeamFocusableProps {
|
|
|
6
6
|
label: string;
|
|
7
7
|
variant?: ButtonVariant;
|
|
8
8
|
size?: ButtonSize;
|
|
9
|
-
icon?: IconProps["icon"];
|
|
9
|
+
icon?: IconProps["icon"] | null;
|
|
10
10
|
/** Displays contents after the Button's label. Will be ignored for Buttons rendered as a link with an absolute URL */
|
|
11
11
|
endAdornment?: ReactNode;
|
|
12
12
|
/** HTML attributes to apply to the button element when it is being used to trigger a menu. */
|
|
@@ -14,8 +14,8 @@ export interface ButtonProps extends BeamButtonProps, BeamFocusableProps {
|
|
|
14
14
|
buttonRef?: RefObject<HTMLElement>;
|
|
15
15
|
/** Allow for setting "submit" | "button" | "reset" on button element */
|
|
16
16
|
type?: ButtonHTMLAttributes<HTMLButtonElement>["type"];
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/** Denotes if this button is used to download a resource. Uses the anchor tag with the `download` attribute */
|
|
18
|
+
download?: boolean;
|
|
19
19
|
}
|
|
20
20
|
export declare function Button(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
21
|
declare type ButtonSize = "sm" | "md" | "lg";
|
|
@@ -10,10 +10,10 @@ const Css_1 = require("../Css");
|
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
12
12
|
function Button(props) {
|
|
13
|
-
const { onClick: onPress, disabled, endAdornment, menuTriggerProps, tooltip, openInNew,
|
|
13
|
+
const { onClick: onPress, disabled, endAdornment, menuTriggerProps, tooltip, openInNew, download, ...otherProps } = props;
|
|
14
14
|
const isDisabled = !!disabled;
|
|
15
15
|
const ariaProps = { onPress, isDisabled, ...otherProps, ...menuTriggerProps };
|
|
16
|
-
const { label, icon, variant = "primary", size = "sm", buttonRef } = ariaProps;
|
|
16
|
+
const { label, icon = download ? "download" : undefined, variant = "primary", size = "sm", buttonRef } = ariaProps;
|
|
17
17
|
const ref = buttonRef || (0, react_1.useRef)(null);
|
|
18
18
|
const tid = (0, useTestIds_1.useTestIds)(props, label);
|
|
19
19
|
const { buttonProps, isPressed } = (0, react_aria_1.useButton)({
|
|
@@ -41,7 +41,7 @@ function Button(props) {
|
|
|
41
41
|
},
|
|
42
42
|
...tid,
|
|
43
43
|
};
|
|
44
|
-
const button = typeof onPress === "string" ? ((0, utils_1.isAbsoluteUrl)(onPress) || openInNew ? ((0, jsx_runtime_1.jsxs)("a", Object.assign({}, buttonAttrs, { href: onPress, className: components_1.navLink, target: "_blank", rel: "noreferrer noopener" }, { children: [buttonContent, !
|
|
44
|
+
const button = typeof onPress === "string" ? ((0, utils_1.isAbsoluteUrl)(onPress) || openInNew || download ? ((0, jsx_runtime_1.jsxs)("a", Object.assign({}, buttonAttrs, { href: onPress, className: components_1.navLink }, (download ? { download: "" } : { target: "_blank", rel: "noreferrer noopener" }), { children: [buttonContent, !download && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.ml1.$ }, { children: (0, jsx_runtime_1.jsx)(components_1.Icon, { icon: "linkExternal" }, void 0) }), void 0))] }), void 0)) : ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({}, buttonAttrs, { to: onPress, className: components_1.navLink }, { children: buttonContent }), void 0))) : ((0, jsx_runtime_1.jsx)("button", Object.assign({}, buttonAttrs, { children: buttonContent }), void 0));
|
|
45
45
|
// If we're disabled b/c of a non-boolean ReactNode, or the caller specified tooltip text, then show it in a tooltip
|
|
46
46
|
return (0, components_1.maybeTooltip)({
|
|
47
47
|
title: (0, components_1.resolveTooltip)(disabled, tooltip),
|