@homebound/beam 2.222.4 → 2.223.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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
import { IconProps } from "./Icon";
|
|
2
3
|
export interface ButtonGroupProps {
|
|
3
4
|
buttons: ButtonGroupButton[];
|
|
@@ -9,10 +10,12 @@ export declare type ButtonGroupButton = {
|
|
|
9
10
|
icon?: IconProps["icon"];
|
|
10
11
|
text?: string;
|
|
11
12
|
onClick?: VoidFunction;
|
|
12
|
-
/** Disables the button.
|
|
13
|
-
disabled?: boolean;
|
|
13
|
+
/** Disables the button. Pass a ReactNode to disable the button and show a tooltip */
|
|
14
|
+
disabled?: boolean | ReactNode;
|
|
14
15
|
/** Indicates the active/selected button, as in a tab or toggle. */
|
|
15
16
|
active?: boolean;
|
|
17
|
+
/** Adds tooltip to the button */
|
|
18
|
+
tooltip?: ReactNode;
|
|
16
19
|
};
|
|
17
20
|
export declare function ButtonGroup(props: ButtonGroupProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
18
21
|
declare type ButtonGroupSize = "sm" | "md";
|
|
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_aria_1 = require("react-aria");
|
|
7
7
|
const Icon_1 = require("./Icon");
|
|
8
|
+
const Tooltip_1 = require("./Tooltip");
|
|
8
9
|
const Css_1 = require("../Css");
|
|
9
10
|
const utils_1 = require("../utils");
|
|
10
11
|
const defaultTestId_1 = require("../utils/defaultTestId");
|
|
@@ -18,22 +19,26 @@ function ButtonGroup(props) {
|
|
|
18
19
|
exports.ButtonGroup = ButtonGroup;
|
|
19
20
|
function GroupButton(props) {
|
|
20
21
|
var _a;
|
|
21
|
-
const { icon, text, active, onClick: onPress, disabled, size, ...otherProps } = props;
|
|
22
|
-
const ariaProps = { onPress, isDisabled: disabled, ...otherProps };
|
|
22
|
+
const { icon, text, active, onClick: onPress, disabled, size, tooltip, ...otherProps } = props;
|
|
23
|
+
const ariaProps = { onPress, isDisabled: !!disabled, ...otherProps };
|
|
23
24
|
const ref = (0, react_1.useRef)(null);
|
|
24
25
|
const { buttonProps, isPressed } = (0, react_aria_1.useButton)(ariaProps, ref);
|
|
25
26
|
const { isFocusVisible, focusProps } = (0, react_aria_1.useFocusRing)();
|
|
26
27
|
const { hoverProps, isHovered } = (0, react_aria_1.useHover)(ariaProps);
|
|
27
28
|
const tid = (0, utils_1.useTestIds)(props);
|
|
28
|
-
return (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
return (0, Tooltip_1.maybeTooltip)({
|
|
30
|
+
title: (0, Tooltip_1.resolveTooltip)(disabled, tooltip),
|
|
31
|
+
placement: "top",
|
|
32
|
+
children: ((0, jsx_runtime_1.jsxs)("button", Object.assign({ ref: ref }, buttonProps, focusProps, hoverProps, { css: {
|
|
33
|
+
...Css_1.Css.buttonBase.$,
|
|
34
|
+
...getButtonStyles(),
|
|
35
|
+
...sizeStyles[size],
|
|
36
|
+
...(isFocusVisible ? defaultFocusRingStyles : {}),
|
|
37
|
+
...(active ? activeStyles : {}),
|
|
38
|
+
...(isPressed ? pressedStyles : isHovered ? hoverStyles : {}),
|
|
39
|
+
...(icon ? iconStyles[size] : {}),
|
|
40
|
+
} }, tid[(0, defaultTestId_1.defaultTestId)((_a = text !== null && text !== void 0 ? text : icon) !== null && _a !== void 0 ? _a : "button")], { children: [icon && (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: icon }, void 0), text] }), void 0)),
|
|
41
|
+
});
|
|
37
42
|
}
|
|
38
43
|
const pressedStyles = Css_1.Css.bgGray200.$;
|
|
39
44
|
const activeStyles = Css_1.Css.bgGray300.$;
|