@homebound/beam 2.120.0 → 2.121.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.
|
@@ -14,8 +14,13 @@ export interface IconButtonProps extends BeamButtonProps, BeamFocusableProps {
|
|
|
14
14
|
buttonRef?: RefObject<HTMLButtonElement>;
|
|
15
15
|
/** Whether to show a 16x16px version of the IconButton */
|
|
16
16
|
compact?: boolean;
|
|
17
|
+
/** Whether to display the contrast variant */
|
|
18
|
+
contrast?: boolean;
|
|
17
19
|
}
|
|
18
20
|
export declare function IconButton(props: IconButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
19
21
|
export declare const iconButtonStylesHover: {
|
|
20
22
|
backgroundColor: import("csstype").Property.BackgroundColor | undefined;
|
|
21
23
|
};
|
|
24
|
+
export declare const iconButtonContrastStylesHover: {
|
|
25
|
+
backgroundColor: import("csstype").Property.BackgroundColor | undefined;
|
|
26
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.iconButtonStylesHover = exports.IconButton = void 0;
|
|
3
|
+
exports.iconButtonContrastStylesHover = exports.iconButtonStylesHover = exports.IconButton = void 0;
|
|
4
4
|
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");
|
|
@@ -10,7 +10,7 @@ const Css_1 = require("../Css");
|
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
12
12
|
function IconButton(props) {
|
|
13
|
-
const { onClick: onPress, disabled, color, icon, autoFocus, inc, buttonRef, tooltip, menuTriggerProps, openInNew, compact = false, } = props;
|
|
13
|
+
const { onClick: onPress, disabled, color, icon, autoFocus, inc, buttonRef, tooltip, menuTriggerProps, openInNew, compact = false, contrast = false, } = props;
|
|
14
14
|
const isDisabled = !!disabled;
|
|
15
15
|
const ariaProps = { onPress, isDisabled, autoFocus, ...menuTriggerProps };
|
|
16
16
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -26,12 +26,13 @@ function IconButton(props) {
|
|
|
26
26
|
const styles = (0, react_1.useMemo)(() => ({
|
|
27
27
|
...iconButtonStylesReset,
|
|
28
28
|
...(compact ? iconButtonCompact : iconButtonNormal),
|
|
29
|
-
...(isHovered && exports.iconButtonStylesHover),
|
|
29
|
+
...(isHovered && (contrast ? exports.iconButtonContrastStylesHover : exports.iconButtonStylesHover)),
|
|
30
30
|
...(isFocusVisible && iconButtonStylesFocus),
|
|
31
31
|
...(isDisabled && iconButtonStylesDisabled),
|
|
32
32
|
}), [isHovered, isFocusVisible, isDisabled, compact]);
|
|
33
|
+
const iconColor = contrast ? contrastIconColor : defaultIconColor;
|
|
33
34
|
const buttonAttrs = { ...testIds, ...buttonProps, ...focusProps, ...hoverProps, ref: ref, css: styles };
|
|
34
|
-
const buttonContent = ((0, jsx_runtime_1.jsx)(components_1.Icon, { icon: icon, color: color || (isDisabled ? Css_1.Palette.Gray400 :
|
|
35
|
+
const buttonContent = ((0, jsx_runtime_1.jsx)(components_1.Icon, { icon: icon, color: color || (isDisabled ? Css_1.Palette.Gray400 : iconColor), inc: compact ? 2 : inc }, void 0));
|
|
35
36
|
const button = typeof onPress === "string" ? ((0, utils_1.isAbsoluteUrl)(onPress) || openInNew ? ((0, jsx_runtime_1.jsx)("a", Object.assign({}, buttonAttrs, { href: onPress, className: components_1.navLink, target: "_blank", rel: "noreferrer noopener" }, { children: buttonContent }), 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));
|
|
36
37
|
// If we're disabled b/c of a non-boolean ReactNode, or the caller specified tooltip text, then show it in a tooltip
|
|
37
38
|
return (0, components_1.maybeTooltip)({
|
|
@@ -41,9 +42,12 @@ function IconButton(props) {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
exports.IconButton = IconButton;
|
|
45
|
+
const defaultIconColor = Css_1.Palette.Gray900;
|
|
46
|
+
const contrastIconColor = Css_1.Palette.White;
|
|
44
47
|
const iconButtonStylesReset = Css_1.Css.bTransparent.bsSolid.bgTransparent.cursorPointer.outline0.dif.aic.jcc.transition.$;
|
|
45
48
|
const iconButtonNormal = Css_1.Css.hPx(28).wPx(28).br8.bw2.$;
|
|
46
49
|
const iconButtonCompact = Css_1.Css.hPx(18).wPx(18).br4.bw1.$;
|
|
47
50
|
exports.iconButtonStylesHover = Css_1.Css.bgGray200.$;
|
|
51
|
+
exports.iconButtonContrastStylesHover = Css_1.Css.bgGray700.$;
|
|
48
52
|
const iconButtonStylesFocus = Css_1.Css.bLightBlue700.$;
|
|
49
53
|
const iconButtonStylesDisabled = Css_1.Css.cursorNotAllowed.$;
|
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MultiSelectField = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const defaultTestId_1 = require("../utils/defaultTestId");
|
|
6
7
|
/** Mocks out `MultiSelectField` as a multiple `<select>` field. */
|
|
7
8
|
function MultiSelectField(props) {
|
|
8
9
|
const { getOptionValue = (o) => o.id, // if unset, assume O implements HasId
|
|
9
10
|
getOptionLabel = (o) => o.name, // if unset, assume O implements HasName
|
|
10
|
-
values, options, onSelect, readOnly = false, errorMsg, onFocus, onBlur, disabled, } = props;
|
|
11
|
-
const tid = (0, utils_1.useTestIds)(props,
|
|
11
|
+
values, options, onSelect, readOnly = false, errorMsg, onFocus, onBlur, disabled, label, } = props;
|
|
12
|
+
const tid = (0, utils_1.useTestIds)(props, (0, defaultTestId_1.defaultTestId)(label));
|
|
12
13
|
return ((0, jsx_runtime_1.jsxs)("select", Object.assign({}, tid, {
|
|
13
14
|
// We're cheating and assume the values are strings...what we should really do is either:
|
|
14
15
|
// a) use beam's valueToKey mapping to string-encode any Value, or
|
|
@@ -4,12 +4,13 @@ exports.SelectField = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
|
+
const defaultTestId_1 = require("../utils/defaultTestId");
|
|
7
8
|
/** Mocks out `SelectField` as a `<select>` field. */
|
|
8
9
|
function SelectField(props) {
|
|
9
10
|
const { getOptionValue = (o) => o.id, // if unset, assume O implements HasId
|
|
10
11
|
getOptionLabel = (o) => o.name, // if unset, assume O implements HasName
|
|
11
|
-
value, options: maybeOptions, onSelect, readOnly = false, errorMsg, onBlur, onFocus, disabled, disabledOptions = [], } = props;
|
|
12
|
-
const tid = (0, utils_1.useTestIds)(props,
|
|
12
|
+
value, options: maybeOptions, onSelect, readOnly = false, errorMsg, onBlur, onFocus, disabled, disabledOptions = [], label, } = props;
|
|
13
|
+
const tid = (0, utils_1.useTestIds)(props, (0, defaultTestId_1.defaultTestId)(label));
|
|
13
14
|
const [options, setOptions] = (0, react_1.useState)(Array.isArray(maybeOptions) ? maybeOptions : maybeOptions.initial);
|
|
14
15
|
const currentOption = options.find((o) => getOptionValue(o) === value) || options[0];
|
|
15
16
|
(0, react_1.useEffect)(() => {
|