@homebound/beam 2.102.5 → 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,6 +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
|
+
/** Denotes if this button is used to download a resource. Uses the anchor tag with the `download` attribute */
|
|
18
|
+
download?: boolean;
|
|
17
19
|
}
|
|
18
20
|
export declare function Button(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
19
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, ...otherProps } = props;
|
|
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, (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));
|
|
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),
|
|
@@ -222,7 +222,7 @@ function renderDiv(style, id, columns, headerRows, filteredRows, firstRowMessage
|
|
|
222
222
|
...(style.firstNonHeaderRowCss ? Css_1.Css.addIn(`& > div:nth-of-type(2) > *`, style.firstNonHeaderRowCss).$ : {}),
|
|
223
223
|
...style.rootCss,
|
|
224
224
|
...xss,
|
|
225
|
-
}, "data-testid": id }, { children: [headerRows.map(([, node]) => node), firstRowMessage && (0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...style.firstRowMessageCss } }, { children: firstRowMessage }), void 0), filteredRows.map(([, node]) => node)] }), void 0));
|
|
225
|
+
}, "data-testid": id }, { children: [headerRows.map(([, node]) => node), firstRowMessage && ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...style.firstRowMessageCss }, "data-gridrow": true }, { children: firstRowMessage }), void 0)), filteredRows.map(([, node]) => node)] }), void 0));
|
|
226
226
|
}
|
|
227
227
|
/** Renders as a table, primarily/solely for good print support. */
|
|
228
228
|
function renderTable(style, id, columns, headerRows, filteredRows, firstRowMessage, _stickyHeader, _firstLastColumnWidth, xss, _virtuosoRef) {
|
|
@@ -51,6 +51,11 @@ function deriveSortState(currentSortState, clickedKey, initialSortState) {
|
|
|
51
51
|
if (!currentSortState || clickedKey !== currentKey) {
|
|
52
52
|
return [clickedKey, GridTable_1.ASC];
|
|
53
53
|
}
|
|
54
|
+
// If there is an `initialSortState` and we're clicking on that same key, then flip the sort.
|
|
55
|
+
// Handles cases where the initial sort is DESC so that we can allow for DESC to ASC sorting.
|
|
56
|
+
if (initialSortState && initialSortState[0] === clickedKey) {
|
|
57
|
+
return [clickedKey, currentDirection === GridTable_1.ASC ? GridTable_1.DESC : GridTable_1.ASC];
|
|
58
|
+
}
|
|
54
59
|
// Otherwise when clicking the current column, toggle through sort states
|
|
55
60
|
if (currentDirection === GridTable_1.ASC) {
|
|
56
61
|
// if ASC -> go to desc
|